Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish the lua data model. #150

Merged
merged 4 commits into from
Dec 2, 2020
Merged

Conversation

actboy168
Copy link
Contributor

This pr continues the work of #146, adding arrays, structures and event callbacks. In addition, it is allowed to continue to register variables and callbacks after constructing the data-model, for example

local options = rmlui.contexts["main"]:OpenDataModel("options", {
    options_changed = false
})
options.graphics = 'ok' -- register new var `graphics `

@mikke89
Copy link
Owner

mikke89 commented Nov 18, 2020

Very cool, thank you! I'll take a closer look at it soon.

@mikke89 mikke89 added data binding Lua Lua binding issues labels Nov 18, 2020
Copy link
Owner

@mikke89 mikke89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again! These changes are very much welcome. My suggestions are just minor tweaks for code consistency.

I noticed one new issue though: In the LuaInvaders options menu, if you click accept, and then open the menu again, the saved options are not correctly loaded and there is a warning message.

The issue seems to be that the checkbox elements in the data-for loop are constructed after the load event, so in lines 79-80 in options.rml the elements are not found. I suggest changing these lines to modify the data model directly:

	Options.datamodel.audios[1].checked = (options['reverb'] == 'true')
	Options.datamodel.audios[2].checked = (options['3d'] == 'true')

Source/Lua/LuaDataModel.cpp Outdated Show resolved Hide resolved
Source/Lua/LuaDataModel.cpp Outdated Show resolved Hide resolved
Source/Lua/LuaDataModel.cpp Outdated Show resolved Hide resolved
@mikke89 mikke89 merged commit 7dbf49c into mikke89:data_binding Dec 2, 2020
@mikke89
Copy link
Owner

mikke89 commented Dec 2, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data binding Lua Lua binding issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants