mirror of
https://github.com/Insality/druid.git
synced 2025-06-27 18:37:44 +02:00
Add checkboxes example
This commit is contained in:
parent
fbe5db7875
commit
02601c142d
@ -53,7 +53,7 @@ end
|
|||||||
function Checkbox.init(self, node, callback, click_node, initial_state)
|
function Checkbox.init(self, node, callback, click_node, initial_state)
|
||||||
self.druid = self:get_druid()
|
self.druid = self:get_druid()
|
||||||
self.node = self:get_node(node)
|
self.node = self:get_node(node)
|
||||||
self.click_node = self:get_node(click_node)
|
self.click_node = self:get_node(click_node or node)
|
||||||
|
|
||||||
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
self.button = self.druid:new_button(self.click_node or self.node, on_click)
|
||||||
self:set_state(initial_state, true, true)
|
self:set_state(initial_state, true, true)
|
||||||
|
@ -1562,3 +1562,66 @@ embedded_instances {
|
|||||||
z: 1.0
|
z: 1.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "general_checkboxes"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"screen_factory\"\n"
|
||||||
|
" component: \"/monarch/screen_factory.script\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"screen_id\"\n"
|
||||||
|
" value: \"general_checkboxes\"\n"
|
||||||
|
" type: PROPERTY_TYPE_HASH\n"
|
||||||
|
" }\n"
|
||||||
|
" properties {\n"
|
||||||
|
" id: \"popup\"\n"
|
||||||
|
" value: \"true\"\n"
|
||||||
|
" type: PROPERTY_TYPE_BOOLEAN\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
"embedded_components {\n"
|
||||||
|
" id: \"collectionfactory\"\n"
|
||||||
|
" type: \"collectionfactory\"\n"
|
||||||
|
" data: \"prototype: \\\"/example/examples/general/checkboxes/checkboxes.collection\\\"\\n"
|
||||||
|
"load_dynamically: false\\n"
|
||||||
|
"\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -128,7 +128,7 @@ local function init_lobby(self)
|
|||||||
self.lobby_grid:add(get_button(self, "Grids", "general_grid", "/general/grid/grid.gui_script"))
|
self.lobby_grid:add(get_button(self, "Grids", "general_grid", "/general/grid/grid.gui_script"))
|
||||||
self.lobby_grid:add(get_button_disabled(self, "Progress Bar", "scene_name"))
|
self.lobby_grid:add(get_button_disabled(self, "Progress Bar", "scene_name"))
|
||||||
self.lobby_grid:add(get_button(self, "Data List", "general_data_list", "/general/data_list/data_list.gui_script"))
|
self.lobby_grid:add(get_button(self, "Data List", "general_data_list", "/general/data_list/data_list.gui_script"))
|
||||||
self.lobby_grid:add(get_button_disabled(self, "Checkboxes", "scene_name"))
|
self.lobby_grid:add(get_button(self, "Checkboxes", "general_checkboxes", "/general/checkboxes/checkboxes.gui_script"))
|
||||||
self.lobby_grid:add(get_button(self, "Input text", "general_input", "/general/input/input.gui_script"))
|
self.lobby_grid:add(get_button(self, "Input text", "general_input", "/general/input/input.gui_script"))
|
||||||
self.lobby_grid:add(get_button(self, "Swipe", "general_swipe", "/general/swipe/swipe.gui_script"))
|
self.lobby_grid:add(get_button(self, "Swipe", "general_swipe", "/general/swipe/swipe.gui_script"))
|
||||||
self.lobby_grid:add(get_button(self, "Drag", "general_drag", "/general/drag/drag.gui_script"))
|
self.lobby_grid:add(get_button(self, "Drag", "general_drag", "/general/drag/drag.gui_script"))
|
||||||
|
37
example/examples/general/checkboxes/checkboxes.collection
Normal file
37
example/examples/general/checkboxes/checkboxes.collection
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: "checkboxes"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "go"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"checkboxes\"\n"
|
||||||
|
" component: \"/example/examples/general/checkboxes/checkboxes.gui\"\n"
|
||||||
|
" position {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" }\n"
|
||||||
|
" rotation {\n"
|
||||||
|
" x: 0.0\n"
|
||||||
|
" y: 0.0\n"
|
||||||
|
" z: 0.0\n"
|
||||||
|
" w: 1.0\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
""
|
||||||
|
position {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale3 {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
}
|
||||||
|
}
|
1454
example/examples/general/checkboxes/checkboxes.gui
Normal file
1454
example/examples/general/checkboxes/checkboxes.gui
Normal file
File diff suppressed because it is too large
Load Diff
45
example/examples/general/checkboxes/checkboxes.gui_script
Normal file
45
example/examples/general/checkboxes/checkboxes.gui_script
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
|
||||||
|
local function on_single_checkbox(self, value)
|
||||||
|
print("Single checkbox callback. Value:", value)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
|
||||||
|
local single_checkbox = self.druid:new_checkbox("checkbox/check", on_single_checkbox)
|
||||||
|
|
||||||
|
local radio_group = self.druid:new_radio_group(
|
||||||
|
{"radio1/check", "radio2/check", "radio3/check"},
|
||||||
|
nil,
|
||||||
|
{"radio1/back", "radio2/back", "radio3/back"}) -- last row optional. It's input node (default - click node)
|
||||||
|
radio_group:set_state(2, true)
|
||||||
|
|
||||||
|
local checkbox_group = self.druid:new_checkbox_group(
|
||||||
|
{"checkbox1/check", "checkbox2/check", "checkbox3/check"},
|
||||||
|
nil,
|
||||||
|
{"checkbox1/back", "checkbox2/back", "checkbox3/back"}) -- last row optional. It's input node (default - click node)
|
||||||
|
checkbox_group:set_state({true, false, true}, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function final(self)
|
||||||
|
self.druid:final()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function update(self, dt)
|
||||||
|
self.druid:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_message(self, message_id, message, sender)
|
||||||
|
self.druid:on_message(message_id, message, sender)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function on_input(self, action_id, action)
|
||||||
|
return self.druid:on_input(action_id, action)
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user