Closed jakubg1 closed 3 years ago
Example:
lostFocus >>
jump:widget?root/Game/Hud/Frame/Button_Pause.buttonActive=false,3
jump:widget?root/Game/Hud/Banner_Paused.visible=true,2
widgetShow:root/Game/Hud/Banner_Paused
levelPause:
changed to:
function c.lostFocus()
if f.getWidget("root/Game/Hud/Frame/Button_Pause"):isActive()
and not f.getWidget("root/Game/Hud/Banner_Paused"):isVisible()
then
f.getWidget("root/Game/Hud/Banner_Paused"):show()
f.levelPause()
end
end
or:
function c.lostFocus()
local Button_Pause = f.getWidget("root/Game/Hud/Frame/Button_Pause")
local Banner_Paused = f.getWidget("root/Game/Hud/Banner_Paused")
if Button_Pause:isActive() and not Banner_Paused:isVisible()
then
Banner_Paused:show()
f.levelPause()
end
end
Note that this is still subject to change and the method may look different in its final version.
Another example with a wait
command used before:
levelLost >>
widgetButtonDisable:root/Game/Hud/Frame/Button_Pause
widgetShow:root/Game/Hud/Banner_LevelLose
wait:root/Game/Hud/Banner_LevelLose/Panel,hideEnd
levelRestart:
to:
function c.levelLost()
local Button_Pause = f.getWidget("root/Game/Hud/Frame/Button_Pause")
local Banner_LevelLose = f.getWidget("root/Game/Hud/Banner_LevelLose")
local Banner_LevelLose_Panel = f.getWidget("root/Game/Hud/Banner_LevelLose/Panel")
Button_Pause:disable()
Banner_LevelLose:show()
f.scheduleFunction(c.levelLost_2, Banner_LevelLose_Panel, "hideEnd") -- any idea how to make it work better?
end
function c.levelLost_2()
f.levelRestart()
end
When opening the UI functions for doing things like level advancing or saving the progress, add console commands to access them too. This would be useful.
After voting on the SM discord server, it has been decided that:
This makes the new mechanism fast and simple. There was also considered an option to implement actions as a mechanism which would append them to the widgets once spawned, however it has been proven to be a hassle to implement.
Right now, the UI is actually scriptable but it's a made-up custom script syntax. Because there is already some Lua module stuff going on, I think it's time to make UI scriptable also via Lua. This has actually quite a few benefits:
This has of course a disadvantage - Lua knowledge would be slightly more mandatory for altering such code. This is especially important if one would want to create a custom UI for their game. Furthermore, I don't plan any direct Lua scripting support in an upcoming game editor yet.