mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
Move examples to new collections
This commit is contained in:
parent
24237899af
commit
04d6babdff
@ -176,3 +176,192 @@ embedded_instances {
|
||||
z: 1.0
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "general_buttons"
|
||||
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_buttons\"\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/buttons/buttons.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
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "general_texts"
|
||||
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_texts\"\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/texts/texts.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
|
||||
}
|
||||
}
|
||||
embedded_instances {
|
||||
id: "general_sliders"
|
||||
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_sliders\"\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/sliders/sliders.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
|
||||
}
|
||||
}
|
||||
|
37
example/examples/general/buttons/buttons.collection
Normal file
37
example/examples/general/buttons/buttons.collection
Normal file
@ -0,0 +1,37 @@
|
||||
name: "buttons"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"buttons\"\n"
|
||||
" component: \"/example/examples/general/buttons/buttons.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
|
||||
}
|
||||
}
|
1315
example/examples/general/buttons/buttons.gui
Normal file
1315
example/examples/general/buttons/buttons.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,27 @@
|
||||
local druid = require("druid.druid")
|
||||
local sprite_style = require("druid.styles.sprites.style")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
||||
local function usual_callback()
|
||||
print("Usual callback")
|
||||
end
|
||||
|
||||
|
||||
local function long_tap_callback(self, params, button, hold_time)
|
||||
print("Long tap callback", hold_time)
|
||||
end
|
||||
|
||||
|
||||
local function hold_callback(self, params, button, hold_time)
|
||||
print("On hold callback", hold_time)
|
||||
end
|
||||
|
||||
|
||||
local function repeated_callback(self, params, button, click_in_row)
|
||||
print("Repeated callback", click_in_row)
|
||||
end
|
||||
|
||||
|
||||
local function double_tap_callback(self, params, button, click_in_row)
|
||||
print("Double tap callback", click_in_row)
|
||||
end
|
||||
@ -48,9 +51,27 @@ local function setup_buttons(self)
|
||||
end
|
||||
|
||||
|
||||
function M.setup_page(self)
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
setup_buttons(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
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
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,105 @@
|
||||
local lang = require("example.lang")
|
||||
local druid = require("druid.druid")
|
||||
|
||||
local function empty_callback(self, param)
|
||||
print("Empty callback. Param", param)
|
||||
end
|
||||
|
||||
|
||||
local function random_progress(progress, text)
|
||||
local rnd = math.random()
|
||||
|
||||
gui.set_text(text, math.ceil(rnd * 100) .. "%")
|
||||
progress:to(rnd)
|
||||
end
|
||||
|
||||
|
||||
local function setup_button(self)
|
||||
local b = self.druid:new_button("button_simple", lang.toggle_locale, "button_param")
|
||||
self.druid:new_button("button_template/button", function()
|
||||
msg.post("@system:", "toggle_profile")
|
||||
print(b:is_enabled())
|
||||
b:set_enabled(not b:is_enabled())
|
||||
end, "button_param")
|
||||
end
|
||||
|
||||
|
||||
local function setup_texts(self)
|
||||
self.druid:new_lang_text("text_button", "ui_section_button")
|
||||
self.druid:new_lang_text("text_text", "ui_section_text")
|
||||
self.druid:new_lang_text("text_timer", "ui_section_timer")
|
||||
self.druid:new_lang_text("text_progress", "ui_section_progress")
|
||||
self.druid:new_lang_text("text_slider", "ui_section_slider")
|
||||
self.druid:new_lang_text("text_radio", "ui_section_radio")
|
||||
self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
|
||||
self.druid:new_lang_text("text_input", "ui_section_input")
|
||||
|
||||
self.druid:new_lang_text("text_translated", "ui_text_example")
|
||||
self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
|
||||
self.druid:new_text("text_simple", "Simple")
|
||||
end
|
||||
|
||||
|
||||
local function setup_progress(self)
|
||||
self.progress = self.druid:new_progress("progress_fill", "x", 0.4)
|
||||
random_progress(self.progress, gui.get_node("text_progress_amount"))
|
||||
timer.delay(2, true, function()
|
||||
random_progress(self.progress, gui.get_node("text_progress_amount"))
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local function setup_slider(self)
|
||||
local slider = self.druid:new_slider("slider_pin", vmath.vector3(95, 0, 0), function(_, value)
|
||||
gui.set_text(gui.get_node("text_progress_slider"), math.ceil(value * 100) .. "%")
|
||||
end)
|
||||
|
||||
slider:set(0.2)
|
||||
end
|
||||
|
||||
|
||||
local function setup_checkbox(self)
|
||||
local radio_group = self.druid:new_radio_group(
|
||||
{"radio1/check", "radio2/check", "radio3/check"},
|
||||
nil,
|
||||
{"radio1/back", "radio2/back", "radio3/back"})
|
||||
|
||||
local checkbox_group = self.druid:new_checkbox_group(
|
||||
{"checkbox1/check", "checkbox2/check", "checkbox3/check"},
|
||||
nil,
|
||||
{"checkbox1/back", "checkbox2/back", "checkbox3/back"})
|
||||
|
||||
radio_group:set_state(2)
|
||||
checkbox_group:set_state({true, false, true})
|
||||
end
|
||||
|
||||
|
||||
local function setup_timer(self)
|
||||
self.timer = self.druid:new_timer("timer", 300, 0, empty_callback)
|
||||
end
|
||||
|
||||
|
||||
local function setup_back_handler(self)
|
||||
self.druid:new_back_handler(empty_callback, "back button")
|
||||
end
|
||||
|
||||
|
||||
local function setup_input(self)
|
||||
local input = self.druid:new_input("input_box", "input_text")
|
||||
input:set_text("hello!")
|
||||
end
|
||||
|
||||
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
setup_texts(self)
|
||||
setup_button(self)
|
||||
setup_progress(self)
|
||||
setup_timer(self)
|
||||
setup_checkbox(self)
|
||||
setup_slider(self)
|
||||
setup_back_handler(self)
|
||||
setup_input(self)
|
||||
end
|
||||
|
||||
|
||||
|
37
example/examples/general/sliders/sliders.collection
Normal file
37
example/examples/general/sliders/sliders.collection
Normal file
@ -0,0 +1,37 @@
|
||||
name: "sliders"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"sliders\"\n"
|
||||
" component: \"/example/examples/general/sliders/sliders.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
|
||||
}
|
||||
}
|
1084
example/examples/general/sliders/sliders.gui
Normal file
1084
example/examples/general/sliders/sliders.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
||||
local M = {}
|
||||
local druid = require("druid.druid")
|
||||
|
||||
|
||||
function M.setup_page(self)
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
|
||||
local slider = self.druid:new_slider("slider_simple_pin", vmath.vector3(95, 0, 0), function(_, value)
|
||||
gui.set_text(gui.get_node("slider_simple_text"), math.ceil(value * 100) .. "%")
|
||||
end)
|
||||
@ -17,4 +19,21 @@ function M.setup_page(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
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
|
@ -16,7 +16,7 @@ background_color {
|
||||
nodes {
|
||||
position {
|
||||
x: 300.0
|
||||
y: 400.0
|
||||
y: 415.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
@ -34,7 +34,7 @@ nodes {
|
||||
}
|
||||
size {
|
||||
x: 600.0
|
||||
y: 800.0
|
||||
y: 830.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
@ -130,6 +130,12 @@ nodes {
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
layers {
|
||||
name: "image"
|
||||
}
|
||||
layers {
|
||||
name: "text"
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
max_nodes: 512
|
||||
|
37
example/examples/general/texts/texts.collection
Normal file
37
example/examples/general/texts/texts.collection
Normal file
@ -0,0 +1,37 @@
|
||||
name: "texts"
|
||||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "go"
|
||||
data: "components {\n"
|
||||
" id: \"texts\"\n"
|
||||
" component: \"/example/examples/general/texts/texts.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
|
||||
}
|
||||
}
|
1070
example/examples/general/texts/texts.gui
Normal file
1070
example/examples/general/texts/texts.gui
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
local M = {}
|
||||
local druid = require("druid.druid")
|
||||
|
||||
local pivots = {
|
||||
gui.PIVOT_CENTER,
|
||||
@ -12,6 +12,7 @@ local pivots = {
|
||||
gui.PIVOT_NW
|
||||
}
|
||||
|
||||
|
||||
local function setup_texts(self)
|
||||
self.druid:new_text("text_inline")
|
||||
self.druid:new_text("text_multiline")
|
||||
@ -45,9 +46,27 @@ local function setup_texts(self)
|
||||
end
|
||||
|
||||
|
||||
function M.setup_page(self)
|
||||
function init(self)
|
||||
self.druid = druid.new(self)
|
||||
setup_texts(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
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
|
@ -5,11 +5,7 @@ local monarch = require("monarch.monarch")
|
||||
local empty_style = require("druid.styles.empty.style")
|
||||
local default_style = require("druid.styles.default.style")
|
||||
|
||||
local main_page = require("example.page.main_page")
|
||||
local text_page = require("example.page.texts_page")
|
||||
local button_page = require("example.page.button_page")
|
||||
local scroll_page = require("example.page.scroll_page")
|
||||
local slider_page = require("example.page.slider_page")
|
||||
local input_page = require("example.page.input_page")
|
||||
local grid_page = require("example.page.grid_page")
|
||||
local infinity_page = require("example.page.infinity_page")
|
||||
@ -20,16 +16,20 @@ local function back_to_lobby(self)
|
||||
monarch.back()
|
||||
gui.set_enabled(gui.get_node("C_Anchor"), true)
|
||||
gui.set_enabled(self.button_menu.node, false)
|
||||
|
||||
self.text_header:set_to("Druid")
|
||||
end
|
||||
|
||||
|
||||
local function show_scene(self, scene_name, text_header)
|
||||
monarch.show(scene_name)
|
||||
|
||||
self.text_header:set_to(text_header)
|
||||
gui.set_enabled(gui.get_node("C_Anchor"), false)
|
||||
gui.set_enabled(self.button_menu.node, true)
|
||||
|
||||
self.text_header:set_to(text_header)
|
||||
end
|
||||
|
||||
|
||||
local function init_top_panel(self)
|
||||
self.druid:new_blocker("panel_top")
|
||||
|
||||
@ -42,7 +42,7 @@ local function init_top_panel(self)
|
||||
sys.open_url("https://insality.github.io/druid/")
|
||||
end)
|
||||
|
||||
self.text_header = self.druid:new_text("text_header")
|
||||
self.text_header = self.druid:new_text("text_header", "Druid")
|
||||
end
|
||||
|
||||
|
||||
@ -76,6 +76,18 @@ local function get_button(self, text, scene_name)
|
||||
end
|
||||
|
||||
|
||||
local function get_button_disabled(self, text, scene_name)
|
||||
local prefab = gui.get_node("prefab_button")
|
||||
local nodes = gui.clone_tree(prefab)
|
||||
local root = nodes["prefab_button"]
|
||||
gui.play_flipbook(nodes["icon_button"], "back_gray")
|
||||
gui.set_enabled(root, true)
|
||||
gui.set_text(nodes["text_button_lobby"], text)
|
||||
|
||||
return root
|
||||
end
|
||||
|
||||
|
||||
local function init_lobby(self)
|
||||
gui.set_enabled(gui.get_node("prefabs"), false)
|
||||
|
||||
@ -85,10 +97,10 @@ local function init_lobby(self)
|
||||
|
||||
self.lobby_grid:add(get_title(self, "General examples"))
|
||||
self.lobby_grid:add(get_button(self, "Overview", "general_overview"))
|
||||
self.lobby_grid:add(get_button(self, "Buttons", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Texts", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Lang Text", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Sliders", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Buttons", "general_buttons"))
|
||||
self.lobby_grid:add(get_button(self, "Texts", "general_texts"))
|
||||
self.lobby_grid:add(get_button_disabled(self, "Lang Text", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Sliders", "general_sliders"))
|
||||
self.lobby_grid:add(get_button(self, "Scrolls", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Grids", "scene_name"))
|
||||
self.lobby_grid:add(get_button(self, "Progress Bar", "scene_name"))
|
||||
|
@ -122,517 +122,6 @@ nodes {
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "lobby"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "C_Anchor"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 350.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 600.0
|
||||
y: 800.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "lobby_view"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_N
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "lobby"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_STENCIL
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 600.0
|
||||
y: 800.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "lobby_content"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_N
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "lobby_view"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "prefabs"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "lobby"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_AUTO
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 600.0
|
||||
y: 80.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "prefab_header"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "prefabs"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.9
|
||||
y: 0.9
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 500.0
|
||||
y: 60.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: "Title of component"
|
||||
font: "game"
|
||||
id: "prefab_text"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "prefab_header"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 0.0
|
||||
template_node_child: false
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: -74.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 600.0
|
||||
y: 60.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/empty"
|
||||
id: "prefab_button"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "prefabs"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 400.0
|
||||
y: 55.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_BOX
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
texture: "kenney/button_green"
|
||||
id: "icon_button"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "prefab_button"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
slice9 {
|
||||
x: 20.0
|
||||
y: 20.0
|
||||
z: 20.0
|
||||
w: 20.0
|
||||
}
|
||||
clipping_mode: CLIPPING_MODE_NONE
|
||||
clipping_visible: true
|
||||
clipping_inverted: false
|
||||
alpha: 1.0
|
||||
template_node_child: false
|
||||
size_mode: SIZE_MODE_MANUAL
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: 4.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
rotation {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
scale {
|
||||
x: 0.75
|
||||
y: 0.75
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
size {
|
||||
x: 450.0
|
||||
y: 60.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
color {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
type: TYPE_TEXT
|
||||
blend_mode: BLEND_MODE_ALPHA
|
||||
text: "Button name"
|
||||
font: "game"
|
||||
id: "text_button_lobby"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
outline {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 1.0
|
||||
}
|
||||
shadow {
|
||||
x: 1.0
|
||||
y: 1.0
|
||||
z: 1.0
|
||||
w: 1.0
|
||||
}
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
line_break: false
|
||||
parent: "icon_button"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 0.0
|
||||
template_node_child: false
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
|
@ -18,6 +18,7 @@ local en = {
|
||||
ui_section_slider = "Slider",
|
||||
ui_section_radio = "Radio",
|
||||
ui_section_checkbox = "Checkbox",
|
||||
ui_section_input = "Input",
|
||||
ui_text_example = "Translated",
|
||||
ui_text_change_lang = "Change lang",
|
||||
}
|
||||
@ -38,6 +39,7 @@ local ru = {
|
||||
ui_section_slider = "Слайдер",
|
||||
ui_section_radio = "Выбор",
|
||||
ui_section_checkbox = "Мн. выбор",
|
||||
ui_section_input = "Ввод текста",
|
||||
ui_text_example = "Переведен",
|
||||
ui_text_change_lang = "Сменить язык",
|
||||
}
|
||||
|
@ -1,107 +0,0 @@
|
||||
local lang = require("example.lang")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
||||
local function empty_callback(self, param)
|
||||
print("Empty callback. Param", param)
|
||||
end
|
||||
|
||||
|
||||
local function random_progress(progress, text)
|
||||
local rnd = math.random()
|
||||
|
||||
gui.set_text(text, math.ceil(rnd * 100) .. "%")
|
||||
progress:to(rnd)
|
||||
end
|
||||
|
||||
|
||||
local function setup_button(self)
|
||||
local b = self.druid:new_button("button_simple", lang.toggle_locale, "button_param")
|
||||
self.druid:new_button("button_template/button", function()
|
||||
msg.post("@system:", "toggle_profile")
|
||||
print(b:is_enabled())
|
||||
b:set_enabled(not b:is_enabled())
|
||||
end, "button_param")
|
||||
end
|
||||
|
||||
|
||||
local function setup_texts(self)
|
||||
self.druid:new_lang_text("text_button", "ui_section_button")
|
||||
self.druid:new_lang_text("text_text", "ui_section_text")
|
||||
self.druid:new_lang_text("text_timer", "ui_section_timer")
|
||||
self.druid:new_lang_text("text_progress", "ui_section_progress")
|
||||
self.druid:new_lang_text("text_slider", "ui_section_slider")
|
||||
self.druid:new_lang_text("text_radio", "ui_section_radio")
|
||||
self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
|
||||
|
||||
self.druid:new_lang_text("text_translated", "ui_text_example")
|
||||
self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
|
||||
self.druid:new_text("text_simple", "Simple")
|
||||
end
|
||||
|
||||
|
||||
local function setup_progress(self)
|
||||
self.progress = self.druid:new_progress("progress_fill", "x", 0.4)
|
||||
random_progress(self.progress, gui.get_node("text_progress_amount"))
|
||||
timer.delay(2, true, function()
|
||||
random_progress(self.progress, gui.get_node("text_progress_amount"))
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local function setup_slider(self)
|
||||
local slider = self.druid:new_slider("slider_pin", vmath.vector3(95, 0, 0), function(_, value)
|
||||
gui.set_text(gui.get_node("text_progress_slider"), math.ceil(value * 100) .. "%")
|
||||
end)
|
||||
|
||||
slider:set(0.2)
|
||||
end
|
||||
|
||||
|
||||
local function setup_checkbox(self)
|
||||
local radio_group = self.druid:new_radio_group(
|
||||
{"radio1/check", "radio2/check", "radio3/check"},
|
||||
nil,
|
||||
{"radio1/back", "radio2/back", "radio3/back"})
|
||||
|
||||
local checkbox_group = self.druid:new_checkbox_group(
|
||||
{"checkbox1/check", "checkbox2/check", "checkbox3/check"},
|
||||
nil,
|
||||
{"checkbox1/back", "checkbox2/back", "checkbox3/back"})
|
||||
|
||||
radio_group:set_state(2)
|
||||
checkbox_group:set_state({true, false, true})
|
||||
end
|
||||
|
||||
|
||||
local function setup_timer(self)
|
||||
self.timer = self.druid:new_timer("timer", 300, 0, empty_callback)
|
||||
end
|
||||
|
||||
|
||||
local function setup_back_handler(self)
|
||||
self.druid:new_back_handler(empty_callback, "back button")
|
||||
end
|
||||
|
||||
|
||||
local function setup_input(self)
|
||||
local input = self.druid:new_input("input_box", "input_text")
|
||||
input:set_text("hello!")
|
||||
end
|
||||
|
||||
|
||||
function M.setup_page(self)
|
||||
setup_texts(self)
|
||||
|
||||
setup_button(self)
|
||||
setup_progress(self)
|
||||
setup_timer(self)
|
||||
setup_checkbox(self)
|
||||
setup_slider(self)
|
||||
setup_back_handler(self)
|
||||
setup_input(self)
|
||||
end
|
||||
|
||||
|
||||
return M
|
Loading…
x
Reference in New Issue
Block a user