diff --git a/druid/base/text.lua b/druid/base/text.lua index fff35e5..b60a141 100644 --- a/druid/base/text.lua +++ b/druid/base/text.lua @@ -16,36 +16,40 @@ 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 --- Setup scale x, but can only be smaller, than start text scale local function setup_max_width(self) - local metrics = gui.get_text_metrics_from_node(self.node) - local cur_scale = gui.get_scale(self.node) + 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 + 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) + self.scale = new_scale end diff --git a/example/kenney/assets/fonts/exo2.ttf b/example/kenney/assets/fonts/exo2.ttf new file mode 100755 index 0000000..49f0b49 Binary files /dev/null and b/example/kenney/assets/fonts/exo2.ttf differ diff --git a/example/kenney/assets/fonts/game.font b/example/kenney/assets/fonts/game.font new file mode 100644 index 0000000..5bc9993 --- /dev/null +++ b/example/kenney/assets/fonts/game.font @@ -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 diff --git a/example/kenney/assets/images/back/back_blue.png b/example/kenney/assets/images/back/back_blue.png new file mode 100755 index 0000000..73dcfd0 Binary files /dev/null and b/example/kenney/assets/images/back/back_blue.png differ diff --git a/example/kenney/assets/images/back/back_gray.png b/example/kenney/assets/images/back/back_gray.png new file mode 100755 index 0000000..3d6f82c Binary files /dev/null and b/example/kenney/assets/images/back/back_gray.png differ diff --git a/example/kenney/assets/images/back/back_green.png b/example/kenney/assets/images/back/back_green.png new file mode 100755 index 0000000..8ec8548 Binary files /dev/null and b/example/kenney/assets/images/back/back_green.png differ diff --git a/example/kenney/assets/images/back/back_red.png b/example/kenney/assets/images/back/back_red.png new file mode 100755 index 0000000..e771c39 Binary files /dev/null and b/example/kenney/assets/images/back/back_red.png differ diff --git a/example/kenney/assets/images/buttons/button_blue.png b/example/kenney/assets/images/buttons/button_blue.png new file mode 100755 index 0000000..5ec356a Binary files /dev/null and b/example/kenney/assets/images/buttons/button_blue.png differ diff --git a/example/kenney/assets/images/buttons/button_green.png b/example/kenney/assets/images/buttons/button_green.png new file mode 100755 index 0000000..1da6a09 Binary files /dev/null and b/example/kenney/assets/images/buttons/button_green.png differ diff --git a/example/kenney/assets/images/buttons/button_red.png b/example/kenney/assets/images/buttons/button_red.png new file mode 100755 index 0000000..7263038 Binary files /dev/null and b/example/kenney/assets/images/buttons/button_red.png differ diff --git a/example/kenney/assets/images/buttons/button_yellow.png b/example/kenney/assets/images/buttons/button_yellow.png new file mode 100755 index 0000000..e00e7e3 Binary files /dev/null and b/example/kenney/assets/images/buttons/button_yellow.png differ diff --git a/example/kenney/assets/images/empty.png b/example/kenney/assets/images/empty.png new file mode 100755 index 0000000..5da9ec0 Binary files /dev/null and b/example/kenney/assets/images/empty.png differ diff --git a/example/kenney/assets/images/kenney.atlas b/example/kenney/assets/images/kenney.atlas new file mode 100644 index 0000000..f2df027 --- /dev/null +++ b/example/kenney/assets/images/kenney.atlas @@ -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 diff --git a/example/kenney/assets/images/progress/progress_back.png b/example/kenney/assets/images/progress/progress_back.png new file mode 100755 index 0000000..662b16a Binary files /dev/null and b/example/kenney/assets/images/progress/progress_back.png differ diff --git a/example/kenney/assets/images/progress/progress_fill_green.png b/example/kenney/assets/images/progress/progress_fill_green.png new file mode 100755 index 0000000..195fa3b Binary files /dev/null and b/example/kenney/assets/images/progress/progress_fill_green.png differ diff --git a/example/kenney/assets/images/progress/progress_fill_red.png b/example/kenney/assets/images/progress/progress_fill_red.png new file mode 100755 index 0000000..32f5f4c Binary files /dev/null and b/example/kenney/assets/images/progress/progress_fill_red.png differ diff --git a/example/kenney/assets/images/progress/progress_fill_yellow.png b/example/kenney/assets/images/progress/progress_fill_yellow.png new file mode 100755 index 0000000..70ee720 Binary files /dev/null and b/example/kenney/assets/images/progress/progress_fill_yellow.png differ diff --git a/example/kenney/assets/images/radio/check_back_circle.png b/example/kenney/assets/images/radio/check_back_circle.png new file mode 100755 index 0000000..877a3e0 Binary files /dev/null and b/example/kenney/assets/images/radio/check_back_circle.png differ diff --git a/example/kenney/assets/images/radio/check_back_square.png b/example/kenney/assets/images/radio/check_back_square.png new file mode 100755 index 0000000..f17bb8f Binary files /dev/null and b/example/kenney/assets/images/radio/check_back_square.png differ diff --git a/example/kenney/assets/images/radio/checkmark.png b/example/kenney/assets/images/radio/checkmark.png new file mode 100755 index 0000000..3ad298e Binary files /dev/null and b/example/kenney/assets/images/radio/checkmark.png differ diff --git a/example/kenney/assets/images/radio/tick.png b/example/kenney/assets/images/radio/tick.png new file mode 100755 index 0000000..f0c945d Binary files /dev/null and b/example/kenney/assets/images/radio/tick.png differ diff --git a/example/kenney/assets/images/slider/slider_back.png b/example/kenney/assets/images/slider/slider_back.png new file mode 100755 index 0000000..d28abb9 Binary files /dev/null and b/example/kenney/assets/images/slider/slider_back.png differ diff --git a/example/kenney/assets/images/slider/slider_move.png b/example/kenney/assets/images/slider/slider_move.png new file mode 100755 index 0000000..04018c5 Binary files /dev/null and b/example/kenney/assets/images/slider/slider_move.png differ diff --git a/example/kenney/assets/sounds/click.ogg b/example/kenney/assets/sounds/click.ogg new file mode 100755 index 0000000..4f17f1c Binary files /dev/null and b/example/kenney/assets/sounds/click.ogg differ diff --git a/example/kenney/gui/main/main.gui b/example/kenney/gui/main/main.gui new file mode 100644 index 0000000..87559e7 --- /dev/null +++ b/example/kenney/gui/main/main.gui @@ -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 diff --git a/example/kenney/gui/main/main.gui_script b/example/kenney/gui/main/main.gui_script new file mode 100644 index 0000000..4ed09fd --- /dev/null +++ b/example/kenney/gui/main/main.gui_script @@ -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 diff --git a/example/kenney/init.script b/example/kenney/init.script new file mode 100644 index 0000000..6362a95 --- /dev/null +++ b/example/kenney/init.script @@ -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 diff --git a/example/kenney/kenney.collection b/example/kenney/kenney.collection new file mode 100644 index 0000000..3b0225f --- /dev/null +++ b/example/kenney/kenney.collection @@ -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 + } +} diff --git a/example/kenney/lang.lua b/example/kenney/lang.lua new file mode 100644 index 0000000..8125cb0 --- /dev/null +++ b/example/kenney/lang.lua @@ -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 \ No newline at end of file diff --git a/example/kenney/templates/button.gui b/example/kenney/templates/button.gui new file mode 100644 index 0000000..4beda9c --- /dev/null +++ b/example/kenney/templates/button.gui @@ -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 diff --git a/game.project b/game.project index 16e04b5..c918863 100644 --- a/game.project +++ b/game.project @@ -1,5 +1,5 @@ [bootstrap] -main_collection = /example/scroll.collectionc +main_collection = /example/kenney/kenney.collectionc [script] shared_state = 1