diff --git a/example/example.collection b/example/example.collection index 42fe135..270fc16 100644 --- a/example/example.collection +++ b/example/example.collection @@ -35,3 +35,43 @@ embedded_instances { z: 1.0 } } +embedded_instances { + id: "sounds" + data: "embedded_components {\n" + " id: \"click\"\n" + " type: \"sound\"\n" + " data: \"sound: \\\"/example/res/click.ogg\\\"\\n" + "looping: 0\\n" + "group: \\\"master\\\"\\n" + "gain: 0.4\\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 + } +} diff --git a/example/example.gui b/example/example.gui index c283e40..eb5d5b0 100644 --- a/example/example.gui +++ b/example/example.gui @@ -1,7 +1,11 @@ script: "/example/example.gui.gui_script" fonts { - name: "system_font" - font: "/builtins/fonts/system_font.font" + name: "game" + font: "/example/game.font" +} +textures { + name: "gui" + texture: "/example/gui.atlas" } background_color { x: 0.0 @@ -23,14 +27,14 @@ nodes { w: 1.0 } scale { - x: 1.0 - y: 1.0 + x: 0.5 + y: 0.5 z: 1.0 w: 1.0 } size { - x: 200.0 - y: 100.0 + x: 426.0 + y: 190.0 z: 0.0 w: 1.0 } @@ -42,7 +46,7 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "" + texture: "gui/green_long" id: "button_1" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -66,7 +70,7 @@ nodes { nodes { position { x: 0.0 - y: 0.0 + y: 20.0 z: 0.0 w: 1.0 } @@ -77,8 +81,8 @@ nodes { w: 1.0 } scale { - x: 2.0 - y: 2.0 + x: 1.0 + y: 1.0 z: 1.0 w: 1.0 } @@ -89,15 +93,15 @@ nodes { w: 1.0 } color { - x: 0.0 - y: 0.0 - z: 0.0 + x: 1.0 + y: 1.0 + z: 1.0 w: 1.0 } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA text: "Button 1" - font: "system_font" + font: "game" id: "text_1" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -109,9 +113,9 @@ nodes { w: 1.0 } shadow { - x: 1.0 - y: 1.0 - z: 1.0 + x: 0.0 + y: 0.0 + z: 0.0 w: 1.0 } adjust_mode: ADJUST_MODE_FIT @@ -140,14 +144,14 @@ nodes { w: 1.0 } scale { - x: 1.0 - y: 1.0 + x: 0.5 + y: 0.5 z: 1.0 w: 1.0 } size { - x: 200.0 - y: 100.0 + x: 426.0 + y: 190.0 z: 0.0 w: 1.0 } @@ -159,7 +163,7 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "" + texture: "gui/green_long" id: "button_2" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -183,7 +187,7 @@ nodes { nodes { position { x: 0.0 - y: 0.0 + y: 20.0 z: 0.0 w: 1.0 } @@ -194,8 +198,8 @@ nodes { w: 1.0 } scale { - x: 2.0 - y: 2.0 + x: 1.0 + y: 1.0 z: 1.0 w: 1.0 } @@ -206,15 +210,15 @@ nodes { w: 1.0 } color { - x: 0.0 - y: 0.0 - z: 0.0 + x: 1.0 + y: 1.0 + z: 1.0 w: 1.0 } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA text: "Button 2" - font: "system_font" + font: "game" id: "text_2" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -226,9 +230,9 @@ nodes { w: 1.0 } shadow { - x: 1.0 - y: 1.0 - z: 1.0 + x: 0.0 + y: 0.0 + z: 0.0 w: 1.0 } adjust_mode: ADJUST_MODE_FIT @@ -257,14 +261,14 @@ nodes { w: 1.0 } scale { - x: 1.0 - y: 1.0 + x: 0.5 + y: 0.5 z: 1.0 w: 1.0 } size { - x: 200.0 - y: 100.0 + x: 426.0 + y: 190.0 z: 0.0 w: 1.0 } @@ -276,7 +280,7 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "" + texture: "gui/green_long" id: "button_3" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -300,7 +304,7 @@ nodes { nodes { position { x: 0.0 - y: 0.0 + y: 20.0 z: 0.0 w: 1.0 } @@ -311,8 +315,8 @@ nodes { w: 1.0 } scale { - x: 2.0 - y: 2.0 + x: 1.0 + y: 1.0 z: 1.0 w: 1.0 } @@ -323,15 +327,15 @@ nodes { w: 1.0 } color { - x: 0.0 - y: 0.0 - z: 0.0 + x: 1.0 + y: 1.0 + z: 1.0 w: 1.0 } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA text: "Button 3" - font: "system_font" + font: "game" id: "text_3" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE @@ -343,9 +347,9 @@ nodes { w: 1.0 } shadow { - x: 1.0 - y: 1.0 - z: 1.0 + x: 0.0 + y: 0.0 + z: 0.0 w: 1.0 } adjust_mode: ADJUST_MODE_FIT diff --git a/example/example.gui.gui_script b/example/example.gui.gui_script index 3c347cd..e7bc075 100644 --- a/example/example.gui.gui_script +++ b/example/example.gui.gui_script @@ -1,8 +1,17 @@ -local druid = require "druid.druid" +local druid = require("druid.druid") +local druid_settings = require("druid.settings") + +local function setup_druid(self) + druid_settings.play_sound = function(name) + sound.play("sounds#" .. name) + end +end function init(self) + setup_druid(self) self.druid = druid.new(self) + self.druid:new_button("button_1", function() print("On button 1") end) diff --git a/example/game.font b/example/game.font new file mode 100644 index 0000000..2b014d6 --- /dev/null +++ b/example/game.font @@ -0,0 +1,17 @@ +font: "/example/res/exo2.ttf" +material: "/builtins/fonts/font.material" +size: 64 +antialias: 1 +alpha: 1.0 +outline_alpha: 0.0 +outline_width: 0.0 +shadow_alpha: 1.0 +shadow_blur: 0 +shadow_x: 3.0 +shadow_y: -5.0 +extra_characters: "" +output_format: TYPE_BITMAP +all_chars: false +cache_width: 0 +cache_height: 0 +render_mode: MODE_MULTI_LAYER diff --git a/example/gui.atlas b/example/gui.atlas new file mode 100644 index 0000000..0170ec5 --- /dev/null +++ b/example/gui.atlas @@ -0,0 +1,9 @@ +images { + image: "/example/res/gray_long.png" +} +images { + image: "/example/res/green_long.png" +} +margin: 0 +extrude_borders: 0 +inner_padding: 0 diff --git a/example/res/click.ogg b/example/res/click.ogg new file mode 100755 index 0000000..5d223f3 Binary files /dev/null and b/example/res/click.ogg differ diff --git a/example/res/exo2.ttf b/example/res/exo2.ttf new file mode 100755 index 0000000..49f0b49 Binary files /dev/null and b/example/res/exo2.ttf differ diff --git a/example/res/gray_long.png b/example/res/gray_long.png new file mode 100644 index 0000000..cc29967 Binary files /dev/null and b/example/res/gray_long.png differ diff --git a/example/res/green_long.png b/example/res/green_long.png new file mode 100644 index 0000000..92e1420 Binary files /dev/null and b/example/res/green_long.png differ