Skip to content

Commit

Permalink
Set focus, transition and receiver as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Aug 2, 2023
1 parent c601174 commit 0191a4e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
Binary file modified docs/setup_factory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/setup_proxy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 19 additions & 10 deletions monarch/monarch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions monarch/screen_factory.script
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ 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)


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,
Expand Down
8 changes: 4 additions & 4 deletions monarch/screen_proxy.script
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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,
Expand Down

0 comments on commit 0191a4e

Please sign in to comment.