Merge pull request #30 from AGulev/feature/druid-example
Feature/druid example
1
.gitignore
vendored
@ -8,3 +8,4 @@ Thumbs.db
|
|||||||
.project
|
.project
|
||||||
.cproject
|
.cproject
|
||||||
builtins
|
builtins
|
||||||
|
dist
|
||||||
|
@ -13,8 +13,8 @@ end
|
|||||||
|
|
||||||
function M.set_state(self, indexes)
|
function M.set_state(self, indexes)
|
||||||
for i = 1, #indexes do
|
for i = 1, #indexes do
|
||||||
if self.checkbox[indexes[i]] then
|
if self.checkboxes[i] then
|
||||||
self.checkbox[indexes[i]]:set_state(true, true)
|
self.checkboxes[i]:set_state(indexes[i], true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -23,7 +23,6 @@ function M.init(self, scroll_parent, input_zone, border)
|
|||||||
self.node = helper.get_node(scroll_parent)
|
self.node = helper.get_node(scroll_parent)
|
||||||
self.input_zone = helper.get_node(input_zone)
|
self.input_zone = helper.get_node(input_zone)
|
||||||
self.zone_size = gui.get_size(self.input_zone)
|
self.zone_size = gui.get_size(self.input_zone)
|
||||||
self:set_border(border)
|
|
||||||
self.soft_size = settings.SOFT_ZONE_SIZE
|
self.soft_size = settings.SOFT_ZONE_SIZE
|
||||||
|
|
||||||
-- Distance from node to node's center
|
-- Distance from node to node's center
|
||||||
@ -34,7 +33,8 @@ function M.init(self, scroll_parent, input_zone, border)
|
|||||||
|
|
||||||
self.is_inert = true
|
self.is_inert = true
|
||||||
self.inert = vmath.vector3(0)
|
self.inert = vmath.vector3(0)
|
||||||
self.pos = gui.get_position(self.node)
|
self.start_pos = gui.get_position(self.node)
|
||||||
|
self.pos = self.start_pos
|
||||||
self.target = vmath.vector3(self.pos)
|
self.target = vmath.vector3(self.pos)
|
||||||
|
|
||||||
self.input = {
|
self.input = {
|
||||||
@ -43,6 +43,8 @@ function M.init(self, scroll_parent, input_zone, border)
|
|||||||
start_y = 0,
|
start_y = 0,
|
||||||
side = false,
|
side = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self:set_border(border)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -390,6 +392,12 @@ end
|
|||||||
--- Set the scroll possibly area
|
--- Set the scroll possibly area
|
||||||
function M.set_border(self, border)
|
function M.set_border(self, border)
|
||||||
self.border = border
|
self.border = border
|
||||||
|
|
||||||
|
self.border.x = self.border.x + self.start_pos.x
|
||||||
|
self.border.z = self.border.z + self.start_pos.x
|
||||||
|
self.border.y = self.border.y + self.start_pos.y
|
||||||
|
self.border.w = self.border.w + self.start_pos.y
|
||||||
|
|
||||||
border.z = math.max(border.x, border.z)
|
border.z = math.max(border.x, border.z)
|
||||||
border.w = math.max(border.y, border.w)
|
border.w = math.max(border.y, border.w)
|
||||||
self.can_x = (border.x ~= border.z)
|
self.can_x = (border.x ~= border.z)
|
||||||
|
@ -16,36 +16,42 @@ function M.init(self, node, value, is_locale, max_width)
|
|||||||
self.max_width = max_width
|
self.max_width = max_width
|
||||||
self.node = helper.get_node(node)
|
self.node = helper.get_node(node)
|
||||||
self.start_scale = gui.get_scale(self.node)
|
self.start_scale = gui.get_scale(self.node)
|
||||||
|
self.scale = self.start_scale
|
||||||
self.last_color = gui.get_color(self.node)
|
self.last_color = gui.get_color(self.node)
|
||||||
|
|
||||||
if is_locale then
|
if is_locale then
|
||||||
self.text_id = value
|
self:translate(value)
|
||||||
self:translate()
|
|
||||||
else
|
else
|
||||||
self:set_to(value or 0)
|
self:set_to(value or 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function M.translate(self)
|
function M.translate(self, locale_id)
|
||||||
if self.text_id then
|
self.last_locale = locale_id or self.last_locale
|
||||||
self:set_to(settings.get_text(self.text_id))
|
self:set_to(settings.get_text(self.last_locale))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.on_change_language(self)
|
||||||
|
if self.last_locale then
|
||||||
|
M.translate(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Setup scale x, but can only be smaller, than start text scale
|
--- Setup scale x, but can only be smaller, than start text scale
|
||||||
local function setup_max_width(self)
|
local function setup_max_width(self)
|
||||||
local metrics = gui.get_text_metrics_from_node(self.node)
|
local metrics = gui.get_text_metrics_from_node(self.node)
|
||||||
local cur_scale = gui.get_scale(self.node)
|
local cur_scale = gui.get_scale(self.node)
|
||||||
|
|
||||||
if metrics.width * cur_scale.x > self.max_width then
|
local scale_modifier = self.max_width / metrics.width
|
||||||
local scale_modifier = self.max_width / metrics.width
|
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||||
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
local new_scale = vmath.vector3(scale_modifier, scale_modifier, cur_scale.z)
|
||||||
local new_scale = vmath.vector3(scale_modifier, scale_modifier, cur_scale.z)
|
gui.set_scale(self.node, new_scale)
|
||||||
gui.set_scale(self.node, new_scale)
|
self.scale = new_scale
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,17 +16,17 @@ local _fct_metatable = {}
|
|||||||
--- Basic components
|
--- Basic components
|
||||||
M.comps = {
|
M.comps = {
|
||||||
button = require("druid.base.button"),
|
button = require("druid.base.button"),
|
||||||
back_handler = require("druid.base.back_handler"),
|
|
||||||
blocker = require("druid.base.blocker"),
|
blocker = require("druid.base.blocker"),
|
||||||
|
back_handler = require("druid.base.back_handler"),
|
||||||
text = require("druid.base.text"),
|
text = require("druid.base.text"),
|
||||||
timer = require("druid.base.timer"),
|
timer = require("druid.base.timer"),
|
||||||
progress = require("druid.base.progress"),
|
progress = require("druid.base.progress"),
|
||||||
grid = require("druid.base.grid"),
|
grid = require("druid.base.grid"),
|
||||||
scroll = require("druid.base.scroll"),
|
scroll = require("druid.base.scroll"),
|
||||||
checkbox = require("druid.base.checkbox"),
|
|
||||||
radio_group = require("druid.base.radio_group"),
|
|
||||||
checkbox_group = require("druid.base.checkbox_group"),
|
|
||||||
slider = require("druid.base.slider"),
|
slider = require("druid.base.slider"),
|
||||||
|
checkbox = require("druid.base.checkbox"),
|
||||||
|
checkbox_group = require("druid.base.checkbox_group"),
|
||||||
|
radio_group = require("druid.base.radio_group"),
|
||||||
|
|
||||||
progress_rich = require("druid.rich.progress_rich"),
|
progress_rich = require("druid.rich.progress_rich"),
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ embedded_instances {
|
|||||||
"looping: 0\\n"
|
"looping: 0\\n"
|
||||||
"group: \\\"master\\\"\\n"
|
"group: \\\"master\\\"\\n"
|
||||||
"gain: 0.4\\n"
|
"gain: 0.4\\n"
|
||||||
|
"pan: 0.0\\n"
|
||||||
|
"speed: 1.0\\n"
|
||||||
"\"\n"
|
"\"\n"
|
||||||
" position {\n"
|
" position {\n"
|
||||||
" x: 0.0\n"
|
" x: 0.0\n"
|
||||||
|
BIN
example/kenney/assets/fonts/exo2.ttf
Executable file
17
example/kenney/assets/fonts/game.font
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
font: "/example/kenney/assets/fonts/exo2.ttf"
|
||||||
|
material: "/builtins/fonts/font-df.material"
|
||||||
|
size: 40
|
||||||
|
antialias: 1
|
||||||
|
alpha: 1.0
|
||||||
|
outline_alpha: 1.0
|
||||||
|
outline_width: 2.0
|
||||||
|
shadow_alpha: 1.0
|
||||||
|
shadow_blur: 0
|
||||||
|
shadow_x: 3.0
|
||||||
|
shadow_y: -4.0
|
||||||
|
extra_characters: ""
|
||||||
|
output_format: TYPE_DISTANCE_FIELD
|
||||||
|
all_chars: true
|
||||||
|
cache_width: 0
|
||||||
|
cache_height: 0
|
||||||
|
render_mode: MODE_MULTI_LAYER
|
BIN
example/kenney/assets/images/back/back_blue.png
Executable file
After Width: | Height: | Size: 438 B |
BIN
example/kenney/assets/images/back/back_gray.png
Executable file
After Width: | Height: | Size: 585 B |
BIN
example/kenney/assets/images/back/back_green.png
Executable file
After Width: | Height: | Size: 440 B |
BIN
example/kenney/assets/images/back/back_red.png
Executable file
After Width: | Height: | Size: 442 B |
BIN
example/kenney/assets/images/buttons/button_blue.png
Executable file
After Width: | Height: | Size: 480 B |
BIN
example/kenney/assets/images/buttons/button_green.png
Executable file
After Width: | Height: | Size: 474 B |
BIN
example/kenney/assets/images/buttons/button_red.png
Executable file
After Width: | Height: | Size: 480 B |
BIN
example/kenney/assets/images/buttons/button_yellow.png
Executable file
After Width: | Height: | Size: 452 B |
BIN
example/kenney/assets/images/empty.png
Executable file
After Width: | Height: | Size: 14 KiB |
60
example/kenney/assets/images/kenney.atlas
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/back/back_blue.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/back/back_gray.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/back/back_green.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/back/back_red.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/buttons/button_green.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/buttons/button_red.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/buttons/button_yellow.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/empty.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/progress/progress_back.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/progress/progress_fill_green.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/progress/progress_fill_red.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/progress/progress_fill_yellow.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/radio/check_back_circle.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/radio/check_back_square.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/radio/checkmark.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/radio/tick.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/slider/slider_back.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/slider/slider_move.png"
|
||||||
|
}
|
||||||
|
images {
|
||||||
|
image: "/example/kenney/assets/images/buttons/button_blue.png"
|
||||||
|
}
|
||||||
|
margin: 0
|
||||||
|
extrude_borders: 2
|
||||||
|
inner_padding: 0
|
BIN
example/kenney/assets/images/progress/progress_back.png
Executable file
After Width: | Height: | Size: 439 B |
BIN
example/kenney/assets/images/progress/progress_fill_green.png
Executable file
After Width: | Height: | Size: 471 B |
BIN
example/kenney/assets/images/progress/progress_fill_red.png
Executable file
After Width: | Height: | Size: 479 B |
BIN
example/kenney/assets/images/progress/progress_fill_yellow.png
Executable file
After Width: | Height: | Size: 458 B |
BIN
example/kenney/assets/images/radio/check_back_circle.png
Executable file
After Width: | Height: | Size: 817 B |
BIN
example/kenney/assets/images/radio/check_back_square.png
Executable file
After Width: | Height: | Size: 535 B |
BIN
example/kenney/assets/images/radio/checkmark.png
Executable file
After Width: | Height: | Size: 366 B |
BIN
example/kenney/assets/images/radio/tick.png
Executable file
After Width: | Height: | Size: 293 B |
BIN
example/kenney/assets/images/slider/slider_back.png
Executable file
After Width: | Height: | Size: 153 B |
BIN
example/kenney/assets/images/slider/slider_move.png
Executable file
After Width: | Height: | Size: 897 B |
BIN
example/kenney/assets/sounds/click.ogg
Executable file
3483
example/kenney/gui/main/main.gui
Normal file
37
example/kenney/gui/main/main.gui_script
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
local druid = require("druid.druid")
|
||||||
|
|
||||||
|
local main_page = require("example.kenney.page.main")
|
||||||
|
|
||||||
|
local function on_control_button(self, side)
|
||||||
|
print("Click on button side", side)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function init_top_panel(self)
|
||||||
|
self.druid:new_button("button_left/button", on_control_button, "left")
|
||||||
|
self.druid:new_button("button_right/button", on_control_button, "right")
|
||||||
|
self.header = self.druid:new_text("text_header", "main_page", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
self.druid = druid.new(self)
|
||||||
|
|
||||||
|
init_top_panel(self)
|
||||||
|
main_page.setup_page(self)
|
||||||
|
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)
|
||||||
|
self.druid:on_input(action_id, action)
|
||||||
|
end
|
24
example/kenney/init.script
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
local const = require("druid.const")
|
||||||
|
local settings = require("druid.settings")
|
||||||
|
local lang = require("example.kenney.lang")
|
||||||
|
|
||||||
|
|
||||||
|
local function setup_druid()
|
||||||
|
settings.play_sound = function(name)
|
||||||
|
sound.play("kenney:/sound#" .. name)
|
||||||
|
end
|
||||||
|
|
||||||
|
settings.get_text = function(lang_id)
|
||||||
|
return lang.get_locale(lang_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TODO: Call druid.finish_setup?
|
||||||
|
-- Need to update all gui, in case, when gui init was befure this init
|
||||||
|
msg.post("/gui#main", const.ON_CHANGE_LANGUAGE)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function init(self)
|
||||||
|
setup_druid()
|
||||||
|
msg.post("@render:", "clear_color", { color = vmath.vector4(0.8, 0.9, 0.85, 1) })
|
||||||
|
end
|
114
example/kenney/kenney.collection
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
name: "kenney"
|
||||||
|
scale_along_z: 0
|
||||||
|
embedded_instances {
|
||||||
|
id: "gui"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"main\"\n"
|
||||||
|
" component: \"/example/kenney/gui/main/main.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
embedded_instances {
|
||||||
|
id: "system"
|
||||||
|
data: "components {\n"
|
||||||
|
" id: \"init\"\n"
|
||||||
|
" component: \"/example/kenney/init.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"
|
||||||
|
"}\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: "sound"
|
||||||
|
data: "embedded_components {\n"
|
||||||
|
" id: \"click\"\n"
|
||||||
|
" type: \"sound\"\n"
|
||||||
|
" data: \"sound: \\\"/example/kenney/assets/sounds/click.ogg\\\"\\n"
|
||||||
|
"looping: 0\\n"
|
||||||
|
"group: \\\"master\\\"\\n"
|
||||||
|
"gain: 1.0\\n"
|
||||||
|
"pan: 0.0\\n"
|
||||||
|
"speed: 1.0\\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
|
||||||
|
}
|
||||||
|
}
|
45
example/kenney/lang.lua
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
local const = require("druid.const")
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
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",
|
||||||
|
ui_text_change_lang = "Change lang",
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = "Переведен",
|
||||||
|
ui_text_change_lang = "Сменить язык",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
120
example/kenney/page/main.lua
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
local lang = require("example.kenney.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)
|
||||||
|
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)
|
||||||
|
self.druid:new_text("text_button_lang", "ui_text_change_lang", true, 150 * 0.7)
|
||||||
|
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"))
|
||||||
|
timer.delay(2, true, function()
|
||||||
|
random_progress(self.progress, gui.get_node("text_progress_amount"))
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function setup_grid(self)
|
||||||
|
local grid = self.druid:new_grid("grid", "button_template/button", 3)
|
||||||
|
|
||||||
|
for i = 1, 12 do
|
||||||
|
local nodes = gui.clone_tree(gui.get_node("button_template/button"))
|
||||||
|
|
||||||
|
local root = nodes["button_template/button"]
|
||||||
|
self.druid:new_button(root, function(context, param)
|
||||||
|
grid:set_offset(vmath.vector3(param))
|
||||||
|
end, i)
|
||||||
|
self.druid:new_text(nodes["button_template/text"], "Grid"..i)
|
||||||
|
grid:add(root)
|
||||||
|
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_scroll(self)
|
||||||
|
self.scroll = self.druid:new_scroll("scroll_content", "main_page", vmath.vector4(0, 0, 0, 200))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function setup_back_handler(self)
|
||||||
|
self.druid:new_back_handler(empty_callback, "back button")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function M.setup_page(self)
|
||||||
|
setup_texts(self)
|
||||||
|
|
||||||
|
setup_button(self)
|
||||||
|
setup_progress(self)
|
||||||
|
setup_grid(self)
|
||||||
|
setup_timer(self)
|
||||||
|
setup_checkbox(self)
|
||||||
|
setup_scroll(self)
|
||||||
|
setup_slider(self)
|
||||||
|
setup_back_handler(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return M
|
135
example/kenney/templates/button.gui
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
script: ""
|
||||||
|
fonts {
|
||||||
|
name: "game"
|
||||||
|
font: "/example/kenney/assets/fonts/game.font"
|
||||||
|
}
|
||||||
|
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: 130.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/button_blue"
|
||||||
|
id: "button"
|
||||||
|
xanchor: XANCHOR_NONE
|
||||||
|
yanchor: YANCHOR_NONE
|
||||||
|
pivot: PIVOT_CENTER
|
||||||
|
adjust_mode: ADJUST_MODE_FIT
|
||||||
|
layer: ""
|
||||||
|
inherit_alpha: true
|
||||||
|
slice9 {
|
||||||
|
x: 15.0
|
||||||
|
y: 15.0
|
||||||
|
z: 15.0
|
||||||
|
w: 15.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: 7.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
rotation {
|
||||||
|
x: 0.0
|
||||||
|
y: 0.0
|
||||||
|
z: 0.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
scale {
|
||||||
|
x: 0.7
|
||||||
|
y: 0.7
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
size {
|
||||||
|
x: 200.0
|
||||||
|
y: 100.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: "Tap me!"
|
||||||
|
font: "game"
|
||||||
|
id: "text"
|
||||||
|
xanchor: XANCHOR_NONE
|
||||||
|
yanchor: YANCHOR_NONE
|
||||||
|
pivot: PIVOT_CENTER
|
||||||
|
outline {
|
||||||
|
x: 1.0
|
||||||
|
y: 1.0
|
||||||
|
z: 1.0
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
shadow {
|
||||||
|
x: 0.101960786
|
||||||
|
y: 0.2
|
||||||
|
z: 0.6
|
||||||
|
w: 1.0
|
||||||
|
}
|
||||||
|
adjust_mode: ADJUST_MODE_FIT
|
||||||
|
line_break: false
|
||||||
|
parent: "button"
|
||||||
|
layer: ""
|
||||||
|
inherit_alpha: true
|
||||||
|
alpha: 1.0
|
||||||
|
outline_alpha: 0.0
|
||||||
|
shadow_alpha: 0.78
|
||||||
|
template_node_child: false
|
||||||
|
text_leading: 1.0
|
||||||
|
text_tracking: 0.0
|
||||||
|
}
|
||||||
|
material: "/builtins/materials/gui.material"
|
||||||
|
adjust_reference: ADJUST_REFERENCE_PARENT
|
||||||
|
max_nodes: 512
|
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
@ -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
|
@ -1,5 +1,5 @@
|
|||||||
[bootstrap]
|
[bootstrap]
|
||||||
main_collection = /example/scroll.collectionc
|
main_collection = /example/kenney/kenney.collectionc
|
||||||
|
|
||||||
[script]
|
[script]
|
||||||
shared_state = 1
|
shared_state = 1
|
||||||
|
2
settings_deployer
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
use_latest_bob=true
|