add kenney assets and start gui screen
@ -16,22 +16,27 @@ function M.init(self, node, value, is_locale, max_width)
|
||||
self.max_width = max_width
|
||||
self.node = helper.get_node(node)
|
||||
self.start_scale = gui.get_scale(self.node)
|
||||
self.scale = self.start_scale
|
||||
self.last_color = gui.get_color(self.node)
|
||||
|
||||
if is_locale then
|
||||
self.text_id = value
|
||||
self:translate()
|
||||
self:translate(value)
|
||||
else
|
||||
self:set_to(value or 0)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function M.translate(self)
|
||||
if self.text_id then
|
||||
self:set_to(settings.get_text(self.text_id))
|
||||
end
|
||||
function M.translate(self, locale_id)
|
||||
self.last_locale = locale_id or self.last_locale
|
||||
self:set_to(settings.get_text(self.last_locale))
|
||||
end
|
||||
|
||||
|
||||
function M.on_change_language(self)
|
||||
M.translate(self)
|
||||
end
|
||||
|
||||
|
||||
@ -40,12 +45,11 @@ local function setup_max_width(self)
|
||||
local metrics = gui.get_text_metrics_from_node(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
|
||||
scale_modifier = math.min(scale_modifier, self.start_scale.x)
|
||||
local new_scale = vmath.vector3(scale_modifier, scale_modifier, cur_scale.z)
|
||||
gui.set_scale(self.node, new_scale)
|
||||
end
|
||||
self.scale = new_scale
|
||||
end
|
||||
|
||||
|
||||
|
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: false
|
||||
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
561
example/kenney/gui/main/main.gui
Normal file
@ -0,0 +1,561 @@
|
||||
script: "/example/kenney/gui/main/main.gui_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: 300.0
|
||||
y: 450.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: "root"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
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: 450.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: "N_Anchor"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
parent: "root"
|
||||
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: 100.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/back_gray"
|
||||
id: "panel_top"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_N
|
||||
adjust_mode: ADJUST_MODE_STRETCH
|
||||
parent: "N_Anchor"
|
||||
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: -200.0
|
||||
y: -50.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: 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_TEMPLATE
|
||||
id: "button_left"
|
||||
parent: "panel_top"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/example/kenney/templates/button.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
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_left/button"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "button_left"
|
||||
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: true
|
||||
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: "button_left/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_left/button"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.78
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 200.0
|
||||
y: -50.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: 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_TEMPLATE
|
||||
id: "button_right"
|
||||
parent: "panel_top"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
template: "/example/kenney/templates/button.gui"
|
||||
template_node_child: false
|
||||
}
|
||||
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_right/button"
|
||||
xanchor: XANCHOR_NONE
|
||||
yanchor: YANCHOR_NONE
|
||||
pivot: PIVOT_CENTER
|
||||
adjust_mode: ADJUST_MODE_FIT
|
||||
parent: "button_right"
|
||||
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: true
|
||||
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: "button_right/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_right/button"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 0.0
|
||||
shadow_alpha: 0.78
|
||||
template_node_child: true
|
||||
text_leading: 1.0
|
||||
text_tracking: 0.0
|
||||
}
|
||||
nodes {
|
||||
position {
|
||||
x: 0.0
|
||||
y: -43.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: 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: "Title"
|
||||
font: "game"
|
||||
id: "text_header"
|
||||
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: "panel_top"
|
||||
layer: ""
|
||||
inherit_alpha: true
|
||||
alpha: 1.0
|
||||
outline_alpha: 1.0
|
||||
shadow_alpha: 1.0
|
||||
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
|
35
example/kenney/gui/main/main.gui_script
Normal file
@ -0,0 +1,35 @@
|
||||
local druid = require("druid.druid")
|
||||
|
||||
|
||||
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)
|
||||
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
|
107
example/kenney/kenney.collection
Normal file
@ -0,0 +1,107 @@
|
||||
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: "components {\n"
|
||||
" id: \"click\"\n"
|
||||
" component: \"/example/kenney/assets/sounds/click.ogg\"\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
|
||||
}
|
||||
}
|
12
example/kenney/lang.lua
Normal file
@ -0,0 +1,12 @@
|
||||
local M = {}
|
||||
|
||||
local data = {
|
||||
main_page = "Main page",
|
||||
}
|
||||
|
||||
|
||||
function M.get_locale(lang_id)
|
||||
return data[lang_id] or lang_id
|
||||
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
|
@ -1,5 +1,5 @@
|
||||
[bootstrap]
|
||||
main_collection = /example/scroll.collectionc
|
||||
main_collection = /example/kenney/kenney.collectionc
|
||||
|
||||
[script]
|
||||
shared_state = 1
|
||||
|