mirror of
https://github.com/Insality/druid
synced 2025-06-27 10:27:48 +02:00
work on main example page
This commit is contained in:
parent
528170f462
commit
6d8d0e822a
@ -11,7 +11,7 @@ shadow_x: 3.0
|
||||
shadow_y: -4.0
|
||||
extra_characters: ""
|
||||
output_format: TYPE_DISTANCE_FIELD
|
||||
all_chars: false
|
||||
all_chars: true
|
||||
cache_width: 0
|
||||
cache_height: 0
|
||||
render_mode: MODE_MULTI_LAYER
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,43 @@
|
||||
local const = require("druid.const")
|
||||
|
||||
local M = {}
|
||||
|
||||
local data = {
|
||||
local en = {
|
||||
main_page = "Main page",
|
||||
ui_section_button = "Button",
|
||||
ui_section_text = "Text",
|
||||
ui_section_timer = "Timer",
|
||||
ui_section_progress = "Progress",
|
||||
ui_section_slider = "Slider",
|
||||
ui_section_radio = "Radio",
|
||||
ui_section_checkbox = "Checkbox",
|
||||
ui_text_example = "Translated",
|
||||
}
|
||||
|
||||
local ru = {
|
||||
main_page = "Основное",
|
||||
ui_section_button = "Кнопка",
|
||||
ui_section_text = "Текст",
|
||||
ui_section_timer = "Таймер",
|
||||
ui_section_progress = "Прогресс",
|
||||
ui_section_slider = "Слайдер",
|
||||
ui_section_radio = "Выбор",
|
||||
ui_section_checkbox = "Мн. выбор",
|
||||
ui_text_example = "Переведен",
|
||||
}
|
||||
|
||||
|
||||
local data = en
|
||||
|
||||
|
||||
function M.get_locale(lang_id)
|
||||
return data[lang_id] or lang_id
|
||||
end
|
||||
|
||||
|
||||
function M.toggle_locale()
|
||||
data = data == en and ru or en
|
||||
msg.post("/gui#main", const.ON_CHANGE_LANGUAGE)
|
||||
end
|
||||
|
||||
return M
|
@ -1,5 +1,8 @@
|
||||
local lang = require("example.kenney.lang")
|
||||
|
||||
local M = {}
|
||||
|
||||
|
||||
local function empty_callback(self, param)
|
||||
print("Empty callback. Param", param)
|
||||
end
|
||||
@ -14,16 +17,30 @@ end
|
||||
|
||||
|
||||
local function setup_button(self)
|
||||
self.druid:new_button("button_simple", empty_callback, "button_param")
|
||||
self.druid:new_button("button_simple", lang.toggle_locale, "button_param")
|
||||
self.druid:new_button("button_template/button", empty_callback, "button_param")
|
||||
end
|
||||
|
||||
|
||||
local function setup_texts(self)
|
||||
self.druid:new_text("text_button", "ui_section_button", true)
|
||||
self.druid:new_text("text_text", "ui_section_text", true)
|
||||
self.druid:new_text("text_timer", "ui_section_timer", true)
|
||||
self.druid:new_text("text_progress", "ui_section_progress", true)
|
||||
self.druid:new_text("text_slider", "ui_section_slider", true)
|
||||
self.druid:new_text("text_radio", "ui_section_radio", true)
|
||||
self.druid:new_text("text_checkbox", "ui_section_checkbox", true)
|
||||
|
||||
self.druid:new_text("text_simple", "Simple")
|
||||
self.druid:new_text("text_translated", "ui_text_example", true)
|
||||
end
|
||||
|
||||
|
||||
local function setup_progress(self)
|
||||
local progress = self.druid:new_progress("progress_fill", "x", 0.4)
|
||||
random_progress(progress, gui.get_node("text_progress"))
|
||||
timer.delay(2, true, function()
|
||||
random_progress(progress, gui.get_node("text_progress"))
|
||||
random_progress(progress, gui.get_node("text_progress_amount"))
|
||||
end)
|
||||
end
|
||||
|
||||
@ -40,14 +57,12 @@ local function setup_grid(self)
|
||||
end, i)
|
||||
self.druid:new_text(nodes["button_template/text"], "Grid"..i)
|
||||
grid:add(root)
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function setup_timer(self)
|
||||
self.timer = self.druid:new_timer("text_timer", 120, 0, empty_callback)
|
||||
self.timer = self.druid:new_timer("timer", 300, 0, empty_callback)
|
||||
end
|
||||
|
||||
|
||||
@ -63,6 +78,8 @@ end
|
||||
|
||||
|
||||
function M.setup_page(self)
|
||||
setup_texts(self)
|
||||
|
||||
setup_button(self)
|
||||
setup_progress(self)
|
||||
setup_grid(self)
|
||||
|
123
example/kenney/templates/checkbox.gui
Normal file
123
example/kenney/templates/checkbox.gui
Normal file
@ -0,0 +1,123 @@
|
||||
script: ""
|
||||
textures {
|
||||
name: "kenney"
|
||||
texture: "/example/kenney/assets/images/kenney.atlas"
|
||||
}
|
||||
background_color {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
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: 38.0
|
||||
y: 36.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/check_back_square"
|
||||
id: "back"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
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: 21.0
|
||||
y: 20.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/checkmark"
|
||||
id: "check"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "back"
|
||||
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
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
max_nodes: 512
|
123
example/kenney/templates/radio.gui
Normal file
123
example/kenney/templates/radio.gui
Normal file
@ -0,0 +1,123 @@
|
||||
script: ""
|
||||
textures {
|
||||
name: "kenney"
|
||||
texture: "/example/kenney/assets/images/kenney.atlas"
|
||||
}
|
||||
background_color {
|
||||
x: 0.0
|
||||
y: 0.0
|
||||
z: 0.0
|
||||
w: 0.0
|
||||
}
|
||||
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: 36.0
|
||||
y: 36.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/check_back_circle"
|
||||
id: "back"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
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.5
|
||||
y: 0.5
|
||||
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: 17.0
|
||||
y: 17.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/tick"
|
||||
id: "check"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "back"
|
||||
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
|
||||
}
|
||||
material: "/builtins/materials/gui.material"
|
||||
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||
max_nodes: 512
|
Loading…
x
Reference in New Issue
Block a user