mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Add deep linking for exampes in html
This commit is contained in:
parent
271fdd2b57
commit
ffa3bafa00
@ -48,4 +48,5 @@ globals = {
|
|||||||
"buffer",
|
"buffer",
|
||||||
"resource",
|
"resource",
|
||||||
"defos",
|
"defos",
|
||||||
|
"html5",
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function show_scene(self, scene_name, text_header)
|
local function show_scene(self, scene_name, text_header)
|
||||||
|
print("Show scene:", scene_name)
|
||||||
|
|
||||||
monarch.show(scene_name)
|
monarch.show(scene_name)
|
||||||
gui.set_enabled(gui.get_node("C_Anchor"), false)
|
gui.set_enabled(gui.get_node("C_Anchor"), false)
|
||||||
gui.set_enabled(self.button_menu.node, true)
|
gui.set_enabled(self.button_menu.node, true)
|
||||||
@ -60,6 +62,9 @@ local function get_button(self, text, scene_name)
|
|||||||
local nodes = gui.clone_tree(prefab)
|
local nodes = gui.clone_tree(prefab)
|
||||||
local root = nodes["prefab_button"]
|
local root = nodes["prefab_button"]
|
||||||
gui.set_enabled(root, true)
|
gui.set_enabled(root, true)
|
||||||
|
|
||||||
|
self.scene_names[scene_name] = text
|
||||||
|
|
||||||
self.druid:new_button(root, function()
|
self.druid:new_button(root, function()
|
||||||
show_scene(self, scene_name, text)
|
show_scene(self, scene_name, text)
|
||||||
end):set_click_zone(self.lobby_scroll.view_node)
|
end):set_click_zone(self.lobby_scroll.view_node)
|
||||||
@ -84,6 +89,7 @@ end
|
|||||||
|
|
||||||
local function init_lobby(self)
|
local function init_lobby(self)
|
||||||
gui.set_enabled(gui.get_node("prefabs"), false)
|
gui.set_enabled(gui.get_node("prefabs"), false)
|
||||||
|
self.scene_names = {}
|
||||||
|
|
||||||
self.lobby_scroll = self.druid:new_scroll("lobby_view", "lobby_content")
|
self.lobby_scroll = self.druid:new_scroll("lobby_view", "lobby_content")
|
||||||
self.lobby_grid = self.druid:new_dynamic_grid("lobby_content")
|
self.lobby_grid = self.druid:new_dynamic_grid("lobby_content")
|
||||||
@ -130,6 +136,18 @@ local function init_lobby(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function check_url(self)
|
||||||
|
if not html5 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local example_arg = html5.run("new URLSearchParams(window.location.search).get('example')")
|
||||||
|
if example_arg and self.scene_names[example_arg] then
|
||||||
|
print("Start example: ", example_arg)
|
||||||
|
show_scene(self, example_arg, self.scene_names[example_arg] or "unknown")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function init(self)
|
function init(self)
|
||||||
-- Main lobby have more render priority (top panel)
|
-- Main lobby have more render priority (top panel)
|
||||||
gui.set_render_order(10)
|
gui.set_render_order(10)
|
||||||
@ -140,6 +158,8 @@ function init(self)
|
|||||||
|
|
||||||
init_top_panel(self)
|
init_top_panel(self)
|
||||||
init_lobby(self)
|
init_lobby(self)
|
||||||
|
|
||||||
|
timer.delay(0, false, check_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ end
|
|||||||
|
|
||||||
function init(self)
|
function init(self)
|
||||||
self.druid = druid.new(self)
|
self.druid = druid.new(self)
|
||||||
self.grid = self.druid:new_grid("grid", "prefab", 5)
|
self.grid = self.druid:new_static_grid("grid", "prefab", 5)
|
||||||
|
|
||||||
self.prefab = gui.get_node("prefab")
|
self.prefab = gui.get_node("prefab")
|
||||||
gui.set_enabled(self.prefab, false)
|
gui.set_enabled(self.prefab, false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user