Hi,
I need help with setting the GUI from scratch when getting there back. I have two Monarch screens loaded via proxies. On the main screen I have a GUI which has a “Focus” button that allows to proceed to the second screen - a “Focus” board. The second screen has a GUI too, but with my “Focus” board to play a matcher game - at the end of the game I’m forcing all blocks to explode and disappear in an animation sequence. Then it goes back to the main screen using monarch.back(). But users can click in main screen “Focus” button again and what is happening is, that the “Focus” gui appears but without the blocks, that were exploded before I want to reset “Focus” gui, so it could just appears like after the first click, thus I would like to ask you guys if you have any idea how to do that? Is there a way to somehow destroy/unload the “Focus” collection and then load it again, so the init() will be triggered at the begining and all the variables will be at the initial state?
I think you can solve your problem by adding { reload = true }
as a parameter in your monarch.show
.
Like this
monarch.show(hash("focus"), { reload = true })
I tried, but it’s not working like this. I think reloading isn’t the same as re-creating.
Can you share your code perhaps?
It’s pretty huge, but the problem regards only this transition. In main script, which is exploration.gui_script, in on_input
I have:
gooey.button("focus_1", action_id, action, btn.focus,btn.nothing)
Then, btn.focus is:
function M.focus(button)
msg.post(HERO_URL, msgs.FOCUS)
monarch.show(hash("focus"), {reload = true}, nil, function() end)
state.set("FOCUS")
gui.set_enabled(gui.get_node("root"), false) -- this disables exploration GUI, as Focus board GUI is a popup
end
Then there is a lot of stuff going in the Focus board, the whole matcher game, but at the end (of turns) the board is destroyed and the returning function is called:
monarch.back({}, function()
print("FOCUS", "Getting back to EXPLORATION")
timer.delay(0.1, false, function()
msg.post(EXPLORATION_URL, msgs.EXPLORATION, { enable = true }) -- this enables the exploration GUI again
end)
Then, in exploration mode, player can click the “focus_1” button again to get back to the pop-up, but, as I said, the state of the whole GUI isn’t restarted and if there is no other workaround I’m thinking about creating an initialization function after every monarch.show(hash(“focus”,…) call - though I don’t want to really
Is there something more I should explain?
Reload should work, at least for a collection proxy. Share a minimal repro and create a ticket if it doesn’t.
Ok, I’ll investigate it
When trying to reproduce it in different project I spotted a very tiny difference -> Preload mask in screen_proxy. In my project it was checked, so neither clear = true
nor reload = true
were working
Ah, ok, so it was a screen with Preload set. Hmm, I think the reload should work in that case regardless. Would you mind creating a GitHub issue and I’ll take a look next week?
Yes, I’ll do
@britzl, thanks for the commit!