3
0
mirror of https://github.com/britzl/monarch.git synced 2025-06-26 18:07:46 +02:00

Set focus, transition and receiver as deprecated

This commit is contained in:
Björn Ritzl 2023-08-02 07:47:32 +02:00
parent c601174b9d
commit 0191a4e540
5 changed files with 26 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -20,6 +20,9 @@ local MSG_UNLOAD = hash("unload")
local MSG_ENABLE = hash("enable")
local MSG_DISABLE = hash("disable")
local DEPRECATED = hash("/__DEPRECATED__")
-- transition messages
M.TRANSITION = {}
M.TRANSITION.DONE = hash("transition_done")
@ -269,12 +272,6 @@ end
-- keep input focus when below a popup
-- * others_keep_input_focus_when_below_screen - If screens below this
-- screen should keep input focus
-- * transition_url - URL to a script that is responsible for the
-- screen transitions
-- * focus_url - URL to a script that is to be notified of focus
-- lost/gained events
-- * receiver_url - URL to a script that is to receive messages sent
-- using monarch.send()
-- * auto_preload - true if the screen should be automatically preloaded
function M.register_proxy(id, proxy, settings)
assert(proxy, "You must provide a collection proxy URL")
@ -284,6 +281,15 @@ function M.register_proxy(id, proxy, settings)
screen.focus_url = settings and settings.focus_url
screen.receiver_url = settings and settings.receiver_url
screen.auto_preload = settings and settings.auto_preload
if screen.transition_url.path == DEPRECATED then
screen.transition_url = nil
end
if screen.focus_url.path == DEPRECATED then
screen.focus_url = nil
end
if screen.receiver_url.path == DEPRECATED then
screen.receiver_url = nil
end
if screen.auto_preload then
M.preload(id)
end
@ -306,10 +312,6 @@ M.register = M.register_proxy
-- keep input focus when below a popup
-- * others_keep_input_focus_when_below_screen - If screens below this
-- screen should keep input focus
-- * transition_id - Id of the game object in the collection that is responsible
-- for the screen transitions
-- * focus_id - Id of the game object in the collection that is to be notified
-- of focus lost/gained events
-- * auto_preload - true if the screen should be automatically preloaded
function M.register_factory(id, factory, settings)
assert(factory, "You must provide a collection factory URL")
@ -318,6 +320,13 @@ function M.register_factory(id, factory, settings)
screen.transition_id = settings and settings.transition_id
screen.focus_id = settings and settings.focus_id
screen.auto_preload = settings and settings.auto_preload
if screen.transition_id == DEPRECATED then
screen.transition_id = nil
end
if screen.focus_id == DEPRECATED then
screen.focus_id = nil
end
if screen.auto_preload then
M.preload(id)
end

View File

@ -6,8 +6,8 @@ go.property("popup", false)
go.property("popup_on_popup", false)
go.property("screen_keeps_input_focus_when_below_popup", false)
go.property("others_keep_input_focus_when_below_screen", false)
go.property("transition_id", hash(""))
go.property("focus_id", hash(""))
go.property("transition_id", hash("__DEPRECATED__"))
go.property("focus_id", hash("__DEPRECATED__"))
go.property("preload", false)
@ -15,7 +15,7 @@ function init(self)
monarch = require "monarch.monarch"
assert(not self.popup_on_popup or (self.popup_on_popup and self.popup), "Popup on Popups can only be set if the Popup flag is set")
assert(self.screen_factory ~= msg.url(), "You must specify either a factory URL")
local settings = {
popup = self.popup,
popup_on_popup = self.popup_on_popup,

View File

@ -7,9 +7,9 @@ go.property("popup_on_popup", false)
go.property("timestep_below_popup", 1)
go.property("screen_keeps_input_focus_when_below_popup", false)
go.property("others_keep_input_focus_when_below_screen", false)
go.property("transition_url", msg.url())
go.property("focus_url", msg.url())
go.property("receiver_url", msg.url())
go.property("transition_url", msg.url("__DEPRECATED__"))
go.property("focus_url", msg.url("__DEPRECATED__"))
go.property("receiver_url", msg.url("__DEPRECATED__"))
go.property("preload", false)
@ -19,7 +19,7 @@ function init(self)
assert(not self.popup_on_popup or (self.popup_on_popup and self.popup), "Popup on Popups can only be set if the Popup flag is set")
assert(self.screen_proxy ~= url, "You must specify either a proxy URL")
assert(self.timestep_below_popup >= 0, "Timestep must be positive")
local settings = {
popup = self.popup,
popup_on_popup = self.popup_on_popup,