diff --git a/README.md b/README.md index 5e47a96..5ef4183 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ The state table contains the following fields: * ```over_now``` (boolean) - true if user action moved inside the node this call * ```out_now``` (boolean) - true if user action moved outside the node this call * ```selected``` (boolean) - The radio button state +* ```selected_now``` (boolean) - true if the radio button was selected this call * ```pressed``` (boolean) - true if the radio button is pressed (ie mouse/touch down but not yet released) * ```pressed_now``` (boolean) - true if the radio button was pressed this call * ```released_now``` (boolean) - true if the radio button was released this call diff --git a/assets/fonts/example.font b/assets/fonts/example.font new file mode 100644 index 0000000..4929518 --- /dev/null +++ b/assets/fonts/example.font @@ -0,0 +1,3 @@ +font: "/builtins/fonts/vera_mo_bd.ttf" +material: "/builtins/fonts/font.material" +size: 15 diff --git a/assets/gooey.atlas b/assets/gooey.atlas deleted file mode 100644 index 0aba447..0000000 --- a/assets/gooey.atlas +++ /dev/null @@ -1,111 +0,0 @@ -images { - image: "/assets/images/blue_boxCheckmark.png" -} -images { - image: "/assets/images/blue_boxCross.png" -} -images { - image: "/assets/images/blue_boxTick.png" -} -images { - image: "/assets/images/blue_button00.png" -} -images { - image: "/assets/images/blue_button01.png" -} -images { - image: "/assets/images/blue_button02.png" -} -images { - image: "/assets/images/blue_button03.png" -} -images { - image: "/assets/images/blue_button04.png" -} -images { - image: "/assets/images/blue_button05.png" -} -images { - image: "/assets/images/blue_button06.png" -} -images { - image: "/assets/images/blue_button07.png" -} -images { - image: "/assets/images/blue_button08.png" -} -images { - image: "/assets/images/blue_button09.png" -} -images { - image: "/assets/images/blue_button10.png" -} -images { - image: "/assets/images/blue_button11.png" -} -images { - image: "/assets/images/blue_button12.png" -} -images { - image: "/assets/images/blue_button13.png" -} -images { - image: "/assets/images/blue_checkmark.png" -} -images { - image: "/assets/images/blue_circle.png" -} -images { - image: "/assets/images/blue_cross.png" -} -images { - image: "/assets/images/blue_panel.png" -} -images { - image: "/assets/images/blue_sliderDown.png" -} -images { - image: "/assets/images/blue_sliderLeft.png" -} -images { - image: "/assets/images/blue_sliderRight.png" -} -images { - image: "/assets/images/blue_sliderUp.png" -} -images { - image: "/assets/images/blue_tick.png" -} -images { - image: "/assets/images/dropdownBottom.png" -} -images { - image: "/assets/images/dropdownMid.png" -} -images { - image: "/assets/images/dropdownTop.png" -} -images { - image: "/assets/images/grey_box.png" -} -images { - image: "/assets/images/grey_circle.png" -} -images { - image: "/assets/images/grey_boxTick.png" -} -images { - image: "/assets/images/grey_boxCheckmark.png" -} -images { - image: "/assets/images/grey_boxCross.png" -} -images { - image: "/assets/images/transparent1px.png" -} -images { - image: "/assets/images/grey_button02.png" -} -margin: 0 -extrude_borders: 1 -inner_padding: 1 diff --git a/example/controller.collection b/example/controller.collection new file mode 100644 index 0000000..2c474ed --- /dev/null +++ b/example/controller.collection @@ -0,0 +1,91 @@ +name: "controller" +scale_along_z: 0 +embedded_instances { + id: "go" + data: "components {\n" + " id: \"controller\"\n" + " component: \"/example/controller.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" + "embedded_components {\n" + " id: \"menuproxy\"\n" + " type: \"collectionproxy\"\n" + " data: \"collection: \\\"/example/menu.collection\\\"\\n" + "exclude: false\\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" + "embedded_components {\n" + " id: \"dirtylarryproxy\"\n" + " type: \"collectionproxy\"\n" + " data: \"collection: \\\"/example/dirtylarry.collection\\\"\\n" + "exclude: false\\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" + "embedded_components {\n" + " id: \"kenneyblueproxy\"\n" + " type: \"collectionproxy\"\n" + " data: \"collection: \\\"/example/kenneyblue.collection\\\"\\n" + "exclude: false\\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/controller.script b/example/controller.script new file mode 100644 index 0000000..6580f82 --- /dev/null +++ b/example/controller.script @@ -0,0 +1,27 @@ +local function show(self, proxy) + if self.current_proxy then + msg.post(self.current_proxy, "unload") + end + msg.post(proxy, "async_load") +end + +function init(self) + msg.post(".", "acquire_input_focus") + show(self, "#menuproxy") + msg.post("@render:", "clear_color", { color = vmath.vector4(0.15, 0.15, 0.15, 1.0) }) +end + +function on_message(self, message_id, message, sender) + if message_id == hash("proxy_loaded") then + self.current_proxy = sender + msg.post(sender, "enable") + elseif message_id == hash("show_menu") then + show(self, "#menuproxy") + elseif message_id == hash("show_dirtylarry") then + show(self, "#dirtylarryproxy") + elseif message_id == hash("show_kenneyblue") then + show(self, "#kenneyblueproxy") + else + print(message_id) + end +end diff --git a/example/dirtylarry.collection b/example/dirtylarry.collection new file mode 100644 index 0000000..98d0ce0 --- /dev/null +++ b/example/dirtylarry.collection @@ -0,0 +1,37 @@ +name: "dirtylarry" +scale_along_z: 0 +embedded_instances { + id: "go" + data: "components {\n" + " id: \"dirtylarry\"\n" + " component: \"/example/dirtylarry.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 + } +} diff --git a/example/dirtylarry.gui b/example/dirtylarry.gui new file mode 100644 index 0000000..a3a1979 --- /dev/null +++ b/example/dirtylarry.gui @@ -0,0 +1,1184 @@ +script: "/example/dirtylarry.gui_script" +fonts { + name: "dirtylarry" + font: "/gooey/themes/dirtylarry/fonts/dirtylarry.font" +} +textures { + name: "dirtylarry" + texture: "/gooey/themes/dirtylarry/images/dirtylarry.atlas" +} +background_color { + x: 0.0 + y: 0.0 + z: 0.0 + w: 0.0 +} +nodes { + position { + x: 129.675 + y: 579.61 + 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" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/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: 220.0 + y: 64.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: "dirtylarry/button_normal" + id: "button/bg" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "button" + layer: "below" + inherit_alpha: true + slice9 { + x: 12.0 + y: 12.0 + z: 12.0 + w: 12.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: 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: 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: "BUTTON" + font: "dirtylarry" + id: "button/label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "button/bg" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +nodes { + position { + x: 51.084 + y: 495.125 + 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: "checkbox" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/checkbox.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: 64.0 + y: 68.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: "dirtylarry/checkbox_normal" + id: "checkbox/box" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "checkbox" + layer: "below" + 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: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 50.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: 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: "CHECKBOX" + font: "dirtylarry" + id: "checkbox/label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "checkbox" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +nodes { + position { + x: 51.084 + y: 412.604 + 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: "radio1" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/radio.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: 64.0 + y: 68.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: "dirtylarry/radio_normal" + id: "radio1/button" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "radio1" + layer: "below" + 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: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 60.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: 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: "RADIO 1" + font: "dirtylarry" + id: "radio1/label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "radio1" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +nodes { + position { + x: 51.084 + y: 342.604 + 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: "radio2" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/radio.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: 64.0 + y: 68.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: "dirtylarry/radio_normal" + id: "radio2/button" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "radio2" + layer: "below" + 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: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 60.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: 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: "RADIO 2" + font: "dirtylarry" + id: "radio2/label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "radio2" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +nodes { + position { + x: 51.084 + y: 272.604 + 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: "radio3" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/radio.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: 64.0 + y: 68.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: "dirtylarry/radio_normal" + id: "radio3/button" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "radio3" + layer: "below" + 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: true + size_mode: SIZE_MODE_AUTO +} +nodes { + position { + x: 60.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: 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: "RADIO 3" + font: "dirtylarry" + id: "radio3/label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "radio3" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +nodes { + position { + x: 17.683 + y: 188.619 + 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: "input" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/input.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: 400.0 + y: 64.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: "dirtylarry/input" + id: "input/bg" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + adjust_mode: ADJUST_MODE_FIT + parent: "input" + layer: "below" + inherit_alpha: true + slice9 { + x: 12.0 + y: 12.0 + z: 12.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: 12.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: 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: "" + font: "dirtylarry" + id: "input/text" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "input/bg" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +nodes { + position { + x: 12.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: 2.0 + y: 40.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.5019608 + y: 0.5019608 + z: 0.5019608 + w: 1.0 + } + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "" + id: "input/cursor" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "input/bg" + 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: true + size_mode: SIZE_MODE_MANUAL +} +nodes { + position { + x: 129.675 + y: 1081.551 + 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: "back" + layer: "" + inherit_alpha: true + alpha: 1.0 + template: "/gooey/themes/dirtylarry/components/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: 220.0 + y: 64.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: "dirtylarry/button_normal" + id: "back/bg" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "back" + layer: "below" + inherit_alpha: true + slice9 { + x: 12.0 + y: 12.0 + z: 12.0 + w: 12.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: 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: 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: "< BACK" + font: "dirtylarry" + id: "back/label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "back/bg" + layer: "text" + inherit_alpha: true + alpha: 1.0 + outline_alpha: 1.0 + shadow_alpha: 1.0 + overridden_fields: 8 + template_node_child: true + text_leading: 1.0 + text_tracking: 0.0 +} +layers { + name: "below" +} +layers { + name: "text" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/example/dirtylarry.gui_script b/example/dirtylarry.gui_script new file mode 100644 index 0000000..baef2ba --- /dev/null +++ b/example/dirtylarry.gui_script @@ -0,0 +1,34 @@ +local dirtylarry = require "gooey.themes.dirtylarry.dirtylarry" + +function init(self) + dirtylarry.acquire_input() +end + +function on_input(self, action_id, action) + dirtylarry.button("button", action_id,action, function(button) + print("button1 pressed") + end) + + dirtylarry.button("back", action_id,action, function(button) + msg.post("controller:/go", "show_menu") + end) + + dirtylarry.checkbox("checkbox", action_id, action, function(checkbox) + print("checkbox", checkbox.checked) + end) + + dirtylarry.radiogroup("MYGROUP", action_id, action, function(group_id, action_id, action) + dirtylarry.radio("radio1", group_id, action_id, action, function(radio) + print("radio 1", radio.selected) + end) + dirtylarry.radio("radio2", group_id, action_id, action, function(radio) + print("radio 2", radio.selected) + end) + dirtylarry.radio("radio3", group_id, action_id, action, function(radio) + print("radio 3", radio.selected) + end) + + end) + + local input = dirtylarry.input("input", gui.KEYBOARD_TYPE_DEFAULT, action_id, action, "EMPTY") +end diff --git a/example/kenneyblue.collection b/example/kenneyblue.collection new file mode 100644 index 0000000..0d5d1ca --- /dev/null +++ b/example/kenneyblue.collection @@ -0,0 +1,37 @@ +name: "kenneyblue" +scale_along_z: 0 +embedded_instances { + id: "go" + data: "components {\n" + " id: \"kenneyblue\"\n" + " component: \"/example/kenneyblue.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 + } +} diff --git a/example/example.gui b/example/kenneyblue.gui similarity index 76% rename from example/example.gui rename to example/kenneyblue.gui index 609d3d5..3008cdc 100644 --- a/example/example.gui +++ b/example/kenneyblue.gui @@ -1,11 +1,11 @@ -script: "/example/example.gui_script" +script: "/example/kenneyblue.gui_script" fonts { name: "system_font" font: "/builtins/fonts/system_font.font" } textures { name: "gooey" - texture: "/assets/gooey.atlas" + texture: "/gooey/themes/kenneyblue/images/kenneyblue.atlas" } background_color { x: 0.0 @@ -15,8 +15,8 @@ background_color { } nodes { position { - x: 911.434 - y: 616.743 + x: 299.85 + y: 1039.61 z: 0.0 w: 1.0 } @@ -34,7 +34,7 @@ nodes { } size { x: 420.0 - y: 600.0 + y: 320.0 z: 0.0 w: 1.0 } @@ -88,7 +88,7 @@ nodes { } size { x: 420.0 - y: 580.0 + y: 300.0 z: 0.0 w: 1.0 } @@ -143,7 +143,7 @@ nodes { } size { x: 0.0 - y: 580.0 + y: 300.0 z: 0.0 w: 1.0 } @@ -214,7 +214,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -372,7 +372,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -530,7 +530,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -688,7 +688,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -846,7 +846,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -1004,7 +1004,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -1162,7 +1162,7 @@ nodes { layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/listitem.gui" template_node_child: false } nodes { @@ -1285,8 +1285,62 @@ nodes { } nodes { position { + x: 298.859 + y: 383.431 + z: 0.0 + w: 1.0 + } + rotation { x: 0.0 - y: -449.311 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + size { + x: 420.0 + y: 400.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: "gooey/blue_panel" + id: "panel" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + layer: "" + inherit_alpha: true + slice9 { + x: 5.0 + y: 5.0 + z: 5.0 + w: 5.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: 1.381 + y: 75.166 z: 0.0 w: 1.0 } @@ -1315,12 +1369,12 @@ nodes { w: 1.0 } type: TYPE_TEMPLATE - id: "listitem8" - parent: "listroot" + id: "button" + parent: "panel" layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/button.gui" template_node_child: false } nodes { @@ -1343,8 +1397,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 192.0 + y: 51.0 z: 0.0 w: 1.0 } @@ -1357,30 +1411,30 @@ nodes { type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA texture: "gooey/blue_button04" - id: "listitem8/bg" + id: "button/bg" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_FIT - parent: "listitem8" + parent: "button" layer: "below" inherit_alpha: true slice9 { - x: 10.0 - y: 10.0 - z: 10.0 - w: 11.0 + x: 6.0 + y: 6.0 + z: 6.0 + w: 10.0 } clipping_mode: CLIPPING_MODE_NONE clipping_visible: true clipping_inverted: false alpha: 1.0 template_node_child: true - size_mode: SIZE_MODE_MANUAL + size_mode: SIZE_MODE_AUTO } nodes { position { - x: -185.0 + x: 0.0 y: 0.0 z: 0.0 w: 1.0 @@ -1398,8 +1452,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -1411,12 +1465,12 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "LIST ITEM" + text: "BUTTON" font: "example" - id: "listitem8/text" + id: "button/label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE - pivot: PIVOT_W + pivot: PIVOT_CENTER outline { x: 1.0 y: 1.0 @@ -1431,7 +1485,7 @@ nodes { } adjust_mode: ADJUST_MODE_FIT line_break: false - parent: "listitem8/bg" + parent: "button/bg" layer: "text" inherit_alpha: true alpha: 1.0 @@ -1443,8 +1497,8 @@ nodes { } nodes { position { - x: 0.0 - y: -509.311 + x: -68.482 + y: 12.823 z: 0.0 w: 1.0 } @@ -1473,12 +1527,12 @@ nodes { w: 1.0 } type: TYPE_TEMPLATE - id: "listitem9" - parent: "listroot" + id: "checkbox" + parent: "panel" layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/checkbox.gui" template_node_child: false } nodes { @@ -1501,8 +1555,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 40.0 + y: 38.0 z: 0.0 w: 1.0 } @@ -1514,31 +1568,31 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "gooey/blue_button04" - id: "listitem9/bg" + texture: "gooey/grey_box" + id: "checkbox/box" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_FIT - parent: "listitem9" + parent: "checkbox" layer: "below" inherit_alpha: true slice9 { - x: 10.0 - y: 10.0 - z: 10.0 - w: 11.0 + 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: true - size_mode: SIZE_MODE_MANUAL + size_mode: SIZE_MODE_AUTO } nodes { position { - x: -185.0 + x: 30.0 y: 0.0 z: 0.0 w: 1.0 @@ -1556,8 +1610,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -1569,9 +1623,9 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "LIST ITEM" + text: "CHECKBOX" font: "example" - id: "listitem9/text" + id: "checkbox/label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_W @@ -1589,7 +1643,7 @@ nodes { } adjust_mode: ADJUST_MODE_FIT line_break: false - parent: "listitem9/bg" + parent: "checkbox" layer: "text" inherit_alpha: true alpha: 1.0 @@ -1601,8 +1655,8 @@ nodes { } nodes { position { - x: 0.0 - y: -569.311 + x: -68.666 + y: -42.672 z: 0.0 w: 1.0 } @@ -1631,12 +1685,12 @@ nodes { w: 1.0 } type: TYPE_TEMPLATE - id: "listitem10" - parent: "listroot" + id: "radio1" + parent: "panel" layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/radiobutton.gui" template_node_child: false } nodes { @@ -1659,8 +1713,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 38.0 + y: 38.0 z: 0.0 w: 1.0 } @@ -1672,31 +1726,31 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "gooey/blue_button04" - id: "listitem10/bg" + texture: "gooey/grey_circle" + id: "radio1/button" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_FIT - parent: "listitem10" + parent: "radio1" layer: "below" inherit_alpha: true slice9 { - x: 10.0 - y: 10.0 - z: 10.0 - w: 11.0 + 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: true - size_mode: SIZE_MODE_MANUAL + size_mode: SIZE_MODE_AUTO } nodes { position { - x: -185.0 + x: 30.0 y: 0.0 z: 0.0 w: 1.0 @@ -1714,8 +1768,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -1727,9 +1781,9 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "LIST ITEM" + text: "RADIO" font: "example" - id: "listitem10/text" + id: "radio1/label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_W @@ -1747,7 +1801,7 @@ nodes { } adjust_mode: ADJUST_MODE_FIT line_break: false - parent: "listitem10/bg" + parent: "radio1" layer: "text" inherit_alpha: true alpha: 1.0 @@ -1759,8 +1813,8 @@ nodes { } nodes { position { - x: 0.0 - y: -629.311 + x: -68.666 + y: -92.672 z: 0.0 w: 1.0 } @@ -1789,12 +1843,12 @@ nodes { w: 1.0 } type: TYPE_TEMPLATE - id: "listitem11" - parent: "listroot" + id: "radio2" + parent: "panel" layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/radiobutton.gui" template_node_child: false } nodes { @@ -1817,8 +1871,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 38.0 + y: 38.0 z: 0.0 w: 1.0 } @@ -1830,31 +1884,31 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "gooey/blue_button04" - id: "listitem11/bg" + texture: "gooey/grey_circle" + id: "radio2/button" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_FIT - parent: "listitem11" + parent: "radio2" layer: "below" inherit_alpha: true slice9 { - x: 10.0 - y: 10.0 - z: 10.0 - w: 11.0 + 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: true - size_mode: SIZE_MODE_MANUAL + size_mode: SIZE_MODE_AUTO } nodes { position { - x: -185.0 + x: 30.0 y: 0.0 z: 0.0 w: 1.0 @@ -1872,8 +1926,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -1885,9 +1939,9 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "LIST ITEM" + text: "RADIO" font: "example" - id: "listitem11/text" + id: "radio2/label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_W @@ -1905,7 +1959,7 @@ nodes { } adjust_mode: ADJUST_MODE_FIT line_break: false - parent: "listitem11/bg" + parent: "radio2" layer: "text" inherit_alpha: true alpha: 1.0 @@ -1917,8 +1971,8 @@ nodes { } nodes { position { - x: 0.0 - y: -689.311 + x: -68.666 + y: -142.672 z: 0.0 w: 1.0 } @@ -1947,12 +2001,12 @@ nodes { w: 1.0 } type: TYPE_TEMPLATE - id: "listitem12" - parent: "listroot" + id: "radio3" + parent: "panel" layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/listitem.gui" + template: "/gooey/themes/kenneyblue/components/radiobutton.gui" template_node_child: false } nodes { @@ -1975,8 +2029,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 38.0 + y: 38.0 z: 0.0 w: 1.0 } @@ -1988,31 +2042,31 @@ nodes { } type: TYPE_BOX blend_mode: BLEND_MODE_ALPHA - texture: "gooey/blue_button04" - id: "listitem12/bg" + texture: "gooey/grey_circle" + id: "radio3/button" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_CENTER adjust_mode: ADJUST_MODE_FIT - parent: "listitem12" + parent: "radio3" layer: "below" inherit_alpha: true slice9 { - x: 10.0 - y: 10.0 - z: 10.0 - w: 11.0 + 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: true - size_mode: SIZE_MODE_MANUAL + size_mode: SIZE_MODE_AUTO } nodes { position { - x: -185.0 + x: 30.0 y: 0.0 z: 0.0 w: 1.0 @@ -2030,8 +2084,8 @@ nodes { w: 1.0 } size { - x: 400.0 - y: 60.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -2043,9 +2097,9 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "LIST ITEM" + text: "RADIO" font: "example" - id: "listitem12/text" + id: "radio3/label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_W @@ -2063,7 +2117,7 @@ nodes { } adjust_mode: ADJUST_MODE_FIT line_break: false - parent: "listitem12/bg" + parent: "radio3" layer: "text" inherit_alpha: true alpha: 1.0 @@ -2075,8 +2129,8 @@ nodes { } nodes { position { - x: 227.618 - y: 581.439 + x: 0.0 + y: 149.191 z: 0.0 w: 1.0 } @@ -2106,10 +2160,11 @@ nodes { } type: TYPE_TEMPLATE id: "input" + parent: "panel" layer: "" inherit_alpha: true alpha: 1.0 - template: "/example/templates/input.gui" + template: "/gooey/themes/kenneyblue/components/input.gui" template_node_child: false } nodes { @@ -2287,8 +2342,8 @@ nodes { } nodes { position { - x: 180.98 - y: 228.339 + x: 113.214 + y: 1090.268 z: 0.0 w: 1.0 } @@ -2305,8 +2360,8 @@ nodes { w: 1.0 } size { - x: 300.0 - y: 400.0 + x: 200.0 + y: 100.0 z: 0.0 w: 1.0 } @@ -2316,33 +2371,18 @@ nodes { z: 1.0 w: 1.0 } - type: TYPE_BOX - blend_mode: BLEND_MODE_ALPHA - texture: "gooey/blue_panel" - id: "panel" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT + type: TYPE_TEMPLATE + id: "back" layer: "" inherit_alpha: true - slice9 { - x: 5.0 - y: 5.0 - z: 5.0 - w: 5.0 - } - clipping_mode: CLIPPING_MODE_NONE - clipping_visible: true - clipping_inverted: false alpha: 1.0 + template: "/gooey/themes/kenneyblue/components/button.gui" template_node_child: false - size_mode: SIZE_MODE_MANUAL } nodes { position { - x: 1.381 - y: 118.723 + x: 0.0 + y: 0.0 z: 0.0 w: 1.0 } @@ -2359,8 +2399,8 @@ nodes { w: 1.0 } size { - x: 200.0 - y: 100.0 + x: 192.0 + y: 51.0 z: 0.0 w: 1.0 } @@ -2370,56 +2410,16 @@ nodes { z: 1.0 w: 1.0 } - type: TYPE_TEMPLATE - id: "button" - parent: "panel" - layer: "" - inherit_alpha: true - alpha: 1.0 - template: "/example/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: 192.0 - y: 51.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: "gooey/blue_button04" - id: "button/bg" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "button" - layer: "below" + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "gooey/blue_button04" + id: "back/bg" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "back" + layer: "below" inherit_alpha: true slice9 { x: 6.0 @@ -2467,167 +2467,9 @@ nodes { } type: TYPE_TEXT blend_mode: BLEND_MODE_ALPHA - text: "BUTTON" - font: "example" - id: "button/label" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "button/bg" - layer: "text" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 1.0 - shadow_alpha: 1.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 -} -nodes { - position { - x: -68.482 - y: 56.38 - 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: "checkbox" - parent: "panel" - layer: "" - inherit_alpha: true - alpha: 1.0 - template: "/example/templates/checkbox.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: 40.0 - y: 38.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: "gooey/grey_box" - id: "checkbox/box" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "checkbox" - layer: "below" - 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: true - size_mode: SIZE_MODE_AUTO -} -nodes { - position { - x: 60.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: 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: "CHECKBOX" + text: "< BACK" font: "example" - id: "checkbox/label" + id: "back/label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE pivot: PIVOT_CENTER @@ -2645,486 +2487,13 @@ nodes { } adjust_mode: ADJUST_MODE_FIT line_break: false - parent: "checkbox" - layer: "text" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 1.0 - shadow_alpha: 1.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 -} -nodes { - position { - x: -68.666 - y: 0.885 - 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: "radio1" - parent: "panel" - layer: "" - inherit_alpha: true - alpha: 1.0 - template: "/example/templates/radiobutton.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: 38.0 - y: 38.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: "gooey/grey_circle" - id: "radio1/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "radio1" - layer: "below" - 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: true - size_mode: SIZE_MODE_AUTO -} -nodes { - position { - x: 60.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: 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: "RADIO" - font: "example" - id: "radio1/label" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "radio1" - layer: "text" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 1.0 - shadow_alpha: 1.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 -} -nodes { - position { - x: -68.666 - y: -49.115 - 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: "radio2" - parent: "panel" - layer: "" - inherit_alpha: true - alpha: 1.0 - template: "/example/templates/radiobutton.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: 38.0 - y: 38.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: "gooey/grey_circle" - id: "radio2/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "radio2" - layer: "below" - 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: true - size_mode: SIZE_MODE_AUTO -} -nodes { - position { - x: 60.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: 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: "RADIO" - font: "example" - id: "radio2/label" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "radio2" - layer: "text" - inherit_alpha: true - alpha: 1.0 - outline_alpha: 1.0 - shadow_alpha: 1.0 - template_node_child: true - text_leading: 1.0 - text_tracking: 0.0 -} -nodes { - position { - x: -68.666 - y: -99.115 - 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: "radio3" - parent: "panel" - layer: "" - inherit_alpha: true - alpha: 1.0 - template: "/example/templates/radiobutton.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: 38.0 - y: 38.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: "gooey/grey_circle" - id: "radio3/button" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - adjust_mode: ADJUST_MODE_FIT - parent: "radio3" - layer: "below" - 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: true - size_mode: SIZE_MODE_AUTO -} -nodes { - position { - x: 60.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: 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: "RADIO" - font: "example" - id: "radio3/label" - xanchor: XANCHOR_NONE - yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER - outline { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - shadow { - x: 1.0 - y: 1.0 - z: 1.0 - w: 1.0 - } - adjust_mode: ADJUST_MODE_FIT - line_break: false - parent: "radio3" + parent: "back/bg" layer: "text" inherit_alpha: true alpha: 1.0 outline_alpha: 1.0 shadow_alpha: 1.0 + overridden_fields: 8 template_node_child: true text_leading: 1.0 text_tracking: 0.0 diff --git a/example/kenneyblue.gui_script b/example/kenneyblue.gui_script new file mode 100644 index 0000000..07c0113 --- /dev/null +++ b/example/kenneyblue.gui_script @@ -0,0 +1,51 @@ +local gooey = require "gooey.gooey" +local kenneyblue = require "gooey.themes.kenneyblue.kenneyblue" + + + + +function init(self) + gooey.acquire_input() + self.list_ids = { + "listitem1/bg", "listitem2/bg", "listitem3/bg", "listitem4/bg", "listitem5/bg", + "listitem6/bg", "listitem7/bg" + } + kenneyblue.input("input", gui.KEYBOARD_TYPE_DEFAULT, nil, { x=0, y=0 }, "EMPTY TEXT") +end + +function on_input(self, action_id, action) + kenneyblue.button("button", action_id, action, function(button) + print("pressed button") + end) + + kenneyblue.button("back", action_id, action, function(button) + msg.post("controller:/go", "show_menu") + end) + + kenneyblue.checkbox("checkbox", action_id, action, function(checkbox) + print("checked", checkbox.checked) + end) + + kenneyblue.radiogroup("GROUP1", action_id, action, function(group_id, action_id, action) + kenneyblue.radio("radio1", group_id, action_id, action, function(radio) + print("selected 1", radio.selected) + end) + kenneyblue.radio("radio2", group_id, action_id, action, function(radio) + print("selected 2", radio.selected) + end) + kenneyblue.radio("radio3", group_id, action_id, action, function(radio) + print("selected 3", radio.selected) + end) + end) + + kenneyblue.list("listroot", self.list_ids, action_id, action, function(list) + print("selected list item", list.selected_item) + end) + + kenneyblue.input("input", gui.KEYBOARD_TYPE_DEFAULT, action_id, action, "EMPTY TEXT") +end + +function on_reload(self) + -- Add input-handling code here + -- Remove this function if not needed +end diff --git a/example/example.collection b/example/menu.collection similarity index 83% rename from example/example.collection rename to example/menu.collection index addc5ec..fe2aa46 100644 --- a/example/example.collection +++ b/example/menu.collection @@ -1,10 +1,10 @@ -name: "example" +name: "menu" scale_along_z: 0 embedded_instances { id: "go" data: "components {\n" - " id: \"example\"\n" - " component: \"/example/example.gui\"\n" + " id: \"menu\"\n" + " component: \"/example/menu.gui\"\n" " position {\n" " x: 0.0\n" " y: 0.0\n" diff --git a/example/menu.gui b/example/menu.gui new file mode 100644 index 0000000..3b0f2b2 --- /dev/null +++ b/example/menu.gui @@ -0,0 +1,254 @@ +script: "/example/menu.gui_script" +fonts { + name: "example" + font: "/assets/fonts/example.font" +} +background_color { + x: 0.0 + y: 0.0 + z: 0.0 + w: 0.0 +} +nodes { + position { + x: 320.0 + y: 568.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: 50.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: "" + id: "dirtybutton" + 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_MANUAL +} +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: 200.0 + y: 100.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.2 + y: 0.2 + z: 0.2 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "DIRTY LARRY" + font: "example" + id: "dirtytext" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "dirtybutton" + 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 +} +nodes { + position { + x: 320.0 + y: 498.151 + 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: 50.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: "" + id: "kenneybutton" + 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_MANUAL +} +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: 200.0 + y: 100.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.2 + y: 0.2 + z: 0.2 + w: 1.0 + } + type: TYPE_TEXT + blend_mode: BLEND_MODE_ALPHA + text: "KENNEY" + font: "example" + id: "kenneytext" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "kenneybutton" + 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 +} +layers { + name: "below" +} +layers { + name: "text" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/example/menu.gui_script b/example/menu.gui_script new file mode 100644 index 0000000..acf6924 --- /dev/null +++ b/example/menu.gui_script @@ -0,0 +1,19 @@ +local gooey = require "gooey.gooey" + +function init(self) + gooey.acquire_input() +end + +function on_input(self, action_id, action) + gooey.button("dirtybutton", action_id, action, function() + msg.post("controller:/go", "show_dirtylarry") + end) + gooey.button("kenneybutton", action_id, action, function() + msg.post("controller:/go", "show_kenneyblue") + end) +end + +function on_reload(self) + -- Add input-handling code here + -- Remove this function if not needed +end diff --git a/game.project b/game.project index eefbb2a..a9e3e23 100644 --- a/game.project +++ b/game.project @@ -2,15 +2,18 @@ title = Gooey [bootstrap] -main_collection = /example/example.collectionc +main_collection = /example/controller.collectionc [input] game_binding = /input/game.input_bindingc [display] -width = 1136 -height = 640 +width = 640 +height = 1136 [script] shared_state = 1 +[library] +include_dirs = gooey + diff --git a/gooey/gooey.lua b/gooey/gooey.lua index ee5a2d8..be88303 100644 --- a/gooey/gooey.lua +++ b/gooey/gooey.lua @@ -13,13 +13,15 @@ local radiobuttons = {} local lists = {} local inputfields = {} +local groups = {} + local utf8_gfind = "([%z\1-\127\194-\244][\128-\191]*)" -- Convert string to hash, unless it's already a hash -- @param str String to convert -- @return The hashed string local function to_hash(str) - return type(str) == "string" and hash(str) or id + return type(str) == "string" and hash(str) or str end --- Create a unique key for an hash by combining the id with the current url @@ -33,13 +35,13 @@ local function to_key(hsh) .. hash_to_hex(hsh) end ---- Get an instance (table) for a node or create one if it doesn't +--- Get an instance (table) for an id or create one if it doesn't -- exist --- @param node_id +-- @param id (hash|string) -- @param instances -- @return Instance for the node -local function instance(node_id, instances) - local key = to_key(node_id) +local function instance(id, instances) + local key = to_key(id) instances[key] = instances[key] or {} return instances[key] end @@ -147,6 +149,40 @@ function M.checkbox(node_id, action_id, action, fn) end + +function M.radiogroup(group_id, action_id, action, fn) + local group_id = to_hash(group_id) + + fn(group_id, action_id, action) + + -- get the group and empty it + local group = instance(group_id, groups) + for k,_ in pairs(group) do + group[k] = nil + end + + local selected_radio + local group_key = to_key(group_id) + for _,radio in pairs(radiobuttons) do + if radio.group == group_key then + if radio.selected_now then + selected_radio = radio + end + table.insert(group, radio) + end + end + + if selected_radio then + for _,radio in ipairs(group) do + if radio ~= selected_radio then + radio.selected = false + end + end + end + return group +end + + function M.radio(node_id, group_id, action_id, action, fn) node_id = to_hash(node_id) group_id = to_hash(group_id) @@ -166,6 +202,7 @@ function M.radio(node_id, group_id, action_id, action, fn) if not radio.enabled then radio.pressed_now = false radio.released_now = false + radio.selected_now = false else local touch = action_id == M.TOUCH local pressed = touch and action.pressed and radio.over @@ -173,13 +210,9 @@ function M.radio(node_id, group_id, action_id, action, fn) radio.pressed_now = pressed and not radio.pressed radio.released_now = released and radio.pressed radio.pressed = pressed or (radio.pressed and not released) - if radio.released_now and radio.over then + radio.selected_now = radio.released_now and radio.over + if radio.selected_now then radio.selected = true - for _,rb in pairs(radiobuttons) do - if rb ~= radio and rb.group == radio.group and rb.selected then - rb.selected = false - end - end fn(radio) end end diff --git a/gooey/themes/dirtylarry/components/button.gui b/gooey/themes/dirtylarry/components/button.gui new file mode 100644 index 0000000..68510be --- /dev/null +++ b/gooey/themes/dirtylarry/components/button.gui @@ -0,0 +1,141 @@ +script: "" +fonts { + name: "dirtylarry" + font: "/gooey/themes/dirtylarry/fonts/dirtylarry.font" +} +textures { + name: "dirtylarry" + texture: "/gooey/themes/dirtylarry/images/dirtylarry.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: 220.0 + y: 64.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: "dirtylarry/button_normal" + id: "bg" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + layer: "below" + inherit_alpha: true + slice9 { + x: 12.0 + y: 12.0 + z: 12.0 + w: 12.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: 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: 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: "LABEL" + font: "dirtylarry" + id: "label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "bg" + layer: "text" + 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 +} +layers { + name: "below" +} +layers { + name: "text" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/gooey/themes/dirtylarry/components/checkbox.gui b/gooey/themes/dirtylarry/components/checkbox.gui new file mode 100644 index 0000000..416748a --- /dev/null +++ b/gooey/themes/dirtylarry/components/checkbox.gui @@ -0,0 +1,140 @@ +script: "" +fonts { + name: "dirtylarry" + font: "/gooey/themes/dirtylarry/fonts/dirtylarry.font" +} +textures { + name: "dirtylarry" + texture: "/gooey/themes/dirtylarry/images/dirtylarry.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: 64.0 + y: 68.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: "dirtylarry/checkbox_normal" + id: "box" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + layer: "below" + 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: 50.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: 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: "LABEL" + font: "dirtylarry" + id: "label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + layer: "text" + 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 +} +layers { + name: "below" +} +layers { + name: "text" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/gooey/themes/dirtylarry/components/input.gui b/gooey/themes/dirtylarry/components/input.gui new file mode 100644 index 0000000..c096743 --- /dev/null +++ b/gooey/themes/dirtylarry/components/input.gui @@ -0,0 +1,196 @@ +script: "" +fonts { + name: "dirtylarry" + font: "/gooey/themes/dirtylarry/fonts/dirtylarry.font" +} +textures { + name: "dirtylarry" + texture: "/gooey/themes/dirtylarry/images/dirtylarry.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: 400.0 + y: 64.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: "dirtylarry/input" + id: "bg" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + adjust_mode: ADJUST_MODE_FIT + layer: "below" + inherit_alpha: true + slice9 { + x: 12.0 + y: 12.0 + z: 12.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: 12.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: 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: "" + font: "dirtylarry" + id: "text" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + parent: "bg" + layer: "text" + 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 +} +nodes { + position { + x: 12.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: 2.0 + y: 40.0 + z: 0.0 + w: 1.0 + } + color { + x: 0.5019608 + y: 0.5019608 + z: 0.5019608 + w: 1.0 + } + type: TYPE_BOX + blend_mode: BLEND_MODE_ALPHA + texture: "" + id: "cursor" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + parent: "bg" + 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_MANUAL +} +layers { + name: "below" +} +layers { + name: "text" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/gooey/themes/dirtylarry/components/radio.gui b/gooey/themes/dirtylarry/components/radio.gui new file mode 100644 index 0000000..90eb2c1 --- /dev/null +++ b/gooey/themes/dirtylarry/components/radio.gui @@ -0,0 +1,140 @@ +script: "" +fonts { + name: "dirtylarry" + font: "/gooey/themes/dirtylarry/fonts/dirtylarry.font" +} +textures { + name: "dirtylarry" + texture: "/gooey/themes/dirtylarry/images/dirtylarry.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: 64.0 + y: 68.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: "dirtylarry/radio_normal" + id: "button" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_CENTER + adjust_mode: ADJUST_MODE_FIT + layer: "below" + 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: 60.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: 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: "LABEL" + font: "dirtylarry" + id: "label" + xanchor: XANCHOR_NONE + yanchor: YANCHOR_NONE + pivot: PIVOT_W + outline { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + shadow { + x: 1.0 + y: 1.0 + z: 1.0 + w: 1.0 + } + adjust_mode: ADJUST_MODE_FIT + line_break: false + layer: "text" + 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 +} +layers { + name: "below" +} +layers { + name: "text" +} +material: "/builtins/materials/gui.material" +adjust_reference: ADJUST_REFERENCE_PARENT +max_nodes: 512 diff --git a/gooey/themes/dirtylarry/dirtylarry.lua b/gooey/themes/dirtylarry/dirtylarry.lua new file mode 100644 index 0000000..3ee9cb1 --- /dev/null +++ b/gooey/themes/dirtylarry/dirtylarry.lua @@ -0,0 +1,85 @@ +local gooey = require "gooey.gooey" + + +local M = {} + + +function M.acquire_input() + gooey.acquire_input() +end + +function M.button(node_id, action_id, action, fn) + local button = gooey.button(node_id .. "/bg", action_id, action, fn) + if button.pressed then + gui.play_flipbook(button.node, "button_pressed") + else + gui.play_flipbook(button.node, "button_normal") + end + return button +end + + +function M.checkbox(node_id, action_id, action, fn) + local checkbox = gooey.checkbox(node_id .. "/box", action_id, action, fn) + if checkbox.pressed and not checkbox.checked then + gui.play_flipbook(checkbox.node, "checkbox_pressed") + elseif checkbox.pressed and checkbox.checked then + gui.play_flipbook(checkbox.node, "checkbox_checked_pressed") + elseif checkbox.checked then + gui.play_flipbook(checkbox.node, "checkbox_checked_normal") + else + gui.play_flipbook(checkbox.node, "checkbox_normal") + end + return checkbox +end + + +local function update_radiobutton(radio) + if radio.pressed and not radio.selected then + gui.play_flipbook(radio.node, "radio_pressed") + elseif radio.pressed and radio.selected then + gui.play_flipbook(radio.node, "radio_checked_pressed") + elseif radio.selected then + gui.play_flipbook(radio.node, "radio_checked_normal") + else + gui.play_flipbook(radio.node, "radio_normal") + end +end + +function M.radiogroup(group_id, action_id, action, fn) + local radiobuttons = gooey.radiogroup(group_id, action_id, action, fn) + for _,radio in ipairs(radiobuttons) do + update_radiobutton(radio) + end + return radiobuttons +end + +function M.radio(node_id, group_id, action_id, action, fn) + local radio = gooey.radio(node_id .. "/button", group_id, action_id, action, fn) + update_radiobutton(radio) + return radio +end + + +function M.input(node_id, keyboard_type, action_id, action, empty_text) + local input = gooey.input(node_id .. "/text", keyboard_type, action_id, action) + + if input.empty and not input.selected then + gui.set_text(input.node, empty_text) + end + + local cursor = gui.get_node(node_id .. "/cursor") + if input.selected then + gui.set_enabled(cursor, true) + gui.set_position(cursor, vmath.vector3(14 + input.text_width, 0, 0)) + gui.cancel_animation(cursor, gui.PROP_COLOR) + gui.set_color(cursor, vmath.vector4(1)) + gui.animate(cursor, gui.PROP_COLOR, vmath.vector4(1,1,1,0), gui.EASING_INSINE, 0.8, 0, nil, gui.PLAYBACK_LOOP_PINGPONG) + else + gui.set_enabled(cursor, false) + gui.cancel_animation(cursor, gui.PROP_COLOR) + end + return input +end + +return M \ No newline at end of file diff --git a/gooey/themes/dirtylarry/fonts/dirtylarry.font b/gooey/themes/dirtylarry/fonts/dirtylarry.font new file mode 100644 index 0000000..712decd --- /dev/null +++ b/gooey/themes/dirtylarry/fonts/dirtylarry.font @@ -0,0 +1,16 @@ +font: "/builtins/fonts/vera_mo_bd.ttf" +material: "/builtins/fonts/font.material" +size: 32 +antialias: 1 +alpha: 1.0 +outline_alpha: 0.0 +outline_width: 0.0 +shadow_alpha: 0.0 +shadow_blur: 0 +shadow_x: 0.0 +shadow_y: 0.0 +extra_characters: "" +output_format: TYPE_BITMAP +all_chars: false +cache_width: 0 +cache_height: 0 diff --git a/gooey/themes/dirtylarry/images/button_normal.png b/gooey/themes/dirtylarry/images/button_normal.png new file mode 100644 index 0000000..b579020 Binary files /dev/null and b/gooey/themes/dirtylarry/images/button_normal.png differ diff --git a/gooey/themes/dirtylarry/images/button_pressed.png b/gooey/themes/dirtylarry/images/button_pressed.png new file mode 100644 index 0000000..1893ce5 Binary files /dev/null and b/gooey/themes/dirtylarry/images/button_pressed.png differ diff --git a/gooey/themes/dirtylarry/images/checkbox_checked_normal.png b/gooey/themes/dirtylarry/images/checkbox_checked_normal.png new file mode 100644 index 0000000..e0b05e5 Binary files /dev/null and b/gooey/themes/dirtylarry/images/checkbox_checked_normal.png differ diff --git a/gooey/themes/dirtylarry/images/checkbox_checked_pressed.png b/gooey/themes/dirtylarry/images/checkbox_checked_pressed.png new file mode 100644 index 0000000..b318383 Binary files /dev/null and b/gooey/themes/dirtylarry/images/checkbox_checked_pressed.png differ diff --git a/gooey/themes/dirtylarry/images/checkbox_normal.png b/gooey/themes/dirtylarry/images/checkbox_normal.png new file mode 100644 index 0000000..ba79705 Binary files /dev/null and b/gooey/themes/dirtylarry/images/checkbox_normal.png differ diff --git a/gooey/themes/dirtylarry/images/checkbox_pressed.png b/gooey/themes/dirtylarry/images/checkbox_pressed.png new file mode 100644 index 0000000..9db7674 Binary files /dev/null and b/gooey/themes/dirtylarry/images/checkbox_pressed.png differ diff --git a/gooey/themes/dirtylarry/images/dirtylarry.atlas b/gooey/themes/dirtylarry/images/dirtylarry.atlas new file mode 100644 index 0000000..0fee867 --- /dev/null +++ b/gooey/themes/dirtylarry/images/dirtylarry.atlas @@ -0,0 +1,36 @@ +images { + image: "/gooey/themes/dirtylarry/images/button_normal.png" +} +images { + image: "/gooey/themes/dirtylarry/images/button_pressed.png" +} +images { + image: "/gooey/themes/dirtylarry/images/checkbox_checked_normal.png" +} +images { + image: "/gooey/themes/dirtylarry/images/checkbox_checked_pressed.png" +} +images { + image: "/gooey/themes/dirtylarry/images/checkbox_normal.png" +} +images { + image: "/gooey/themes/dirtylarry/images/checkbox_pressed.png" +} +images { + image: "/gooey/themes/dirtylarry/images/input.png" +} +images { + image: "/gooey/themes/dirtylarry/images/radio_checked_normal.png" +} +images { + image: "/gooey/themes/dirtylarry/images/radio_checked_pressed.png" +} +images { + image: "/gooey/themes/dirtylarry/images/radio_normal.png" +} +images { + image: "/gooey/themes/dirtylarry/images/radio_pressed.png" +} +margin: 0 +extrude_borders: 1 +inner_padding: 0 diff --git a/gooey/themes/dirtylarry/images/input.png b/gooey/themes/dirtylarry/images/input.png new file mode 100644 index 0000000..8c2b9c9 Binary files /dev/null and b/gooey/themes/dirtylarry/images/input.png differ diff --git a/gooey/themes/dirtylarry/images/radio_checked_normal.png b/gooey/themes/dirtylarry/images/radio_checked_normal.png new file mode 100644 index 0000000..f64bf60 Binary files /dev/null and b/gooey/themes/dirtylarry/images/radio_checked_normal.png differ diff --git a/gooey/themes/dirtylarry/images/radio_checked_pressed.png b/gooey/themes/dirtylarry/images/radio_checked_pressed.png new file mode 100644 index 0000000..7ab683b Binary files /dev/null and b/gooey/themes/dirtylarry/images/radio_checked_pressed.png differ diff --git a/gooey/themes/dirtylarry/images/radio_normal.png b/gooey/themes/dirtylarry/images/radio_normal.png new file mode 100644 index 0000000..a82f06e Binary files /dev/null and b/gooey/themes/dirtylarry/images/radio_normal.png differ diff --git a/gooey/themes/dirtylarry/images/radio_pressed.png b/gooey/themes/dirtylarry/images/radio_pressed.png new file mode 100644 index 0000000..0fccea1 Binary files /dev/null and b/gooey/themes/dirtylarry/images/radio_pressed.png differ diff --git a/example/templates/button.gui b/gooey/themes/kenneyblue/components/button.gui similarity index 93% rename from example/templates/button.gui rename to gooey/themes/kenneyblue/components/button.gui index 34edb18..551a0c0 100644 --- a/example/templates/button.gui +++ b/gooey/themes/kenneyblue/components/button.gui @@ -1,11 +1,11 @@ script: "" fonts { name: "example" - font: "/assets/example.font" + font: "/gooey/themes/kenneyblue/fonts/kenneyblue.font" } textures { name: "gooey" - texture: "/assets/gooey.atlas" + texture: "/gooey/themes/kenneyblue/images/kenneyblue.atlas" } background_color { x: 0.0 diff --git a/example/templates/checkbox.gui b/gooey/themes/kenneyblue/components/checkbox.gui similarity index 92% rename from example/templates/checkbox.gui rename to gooey/themes/kenneyblue/components/checkbox.gui index 95cd1f6..7aa7477 100644 --- a/example/templates/checkbox.gui +++ b/gooey/themes/kenneyblue/components/checkbox.gui @@ -1,11 +1,11 @@ script: "" fonts { name: "example" - font: "/assets/example.font" + font: "/gooey/themes/kenneyblue/fonts/kenneyblue.font" } textures { name: "gooey" - texture: "/assets/gooey.atlas" + texture: "/gooey/themes/kenneyblue/images/kenneyblue.atlas" } background_color { x: 0.0 @@ -69,7 +69,7 @@ nodes { } nodes { position { - x: 60.0 + x: 30.0 y: 0.0 z: 0.0 w: 1.0 @@ -105,7 +105,7 @@ nodes { id: "label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER + pivot: PIVOT_W outline { x: 1.0 y: 1.0 diff --git a/example/templates/input.gui b/gooey/themes/kenneyblue/components/input.gui similarity index 95% rename from example/templates/input.gui rename to gooey/themes/kenneyblue/components/input.gui index 20dce70..9288f51 100644 --- a/example/templates/input.gui +++ b/gooey/themes/kenneyblue/components/input.gui @@ -1,11 +1,11 @@ script: "" fonts { name: "example" - font: "/assets/example.font" + font: "/gooey/themes/kenneyblue/fonts/kenneyblue.font" } textures { name: "gooey" - texture: "/assets/gooey.atlas" + texture: "/gooey/themes/kenneyblue/images/kenneyblue.atlas" } background_color { x: 0.0 diff --git a/example/templates/listitem.gui b/gooey/themes/kenneyblue/components/listitem.gui similarity index 94% rename from example/templates/listitem.gui rename to gooey/themes/kenneyblue/components/listitem.gui index 2779338..300f69a 100644 --- a/example/templates/listitem.gui +++ b/gooey/themes/kenneyblue/components/listitem.gui @@ -1,11 +1,11 @@ script: "" fonts { name: "example" - font: "/assets/example.font" + font: "/gooey/themes/kenneyblue/fonts/kenneyblue.font" } textures { name: "gooey" - texture: "/assets/gooey.atlas" + texture: "/gooey/themes/kenneyblue/images/kenneyblue.atlas" } background_color { x: 0.0 diff --git a/example/templates/radiobutton.gui b/gooey/themes/kenneyblue/components/radiobutton.gui similarity index 92% rename from example/templates/radiobutton.gui rename to gooey/themes/kenneyblue/components/radiobutton.gui index ce1b6bd..3724dc1 100644 --- a/example/templates/radiobutton.gui +++ b/gooey/themes/kenneyblue/components/radiobutton.gui @@ -1,11 +1,11 @@ script: "" fonts { name: "example" - font: "/assets/example.font" + font: "/gooey/themes/kenneyblue/fonts/kenneyblue.font" } textures { name: "gooey" - texture: "/assets/gooey.atlas" + texture: "/gooey/themes/kenneyblue/images/kenneyblue.atlas" } background_color { x: 0.0 @@ -69,7 +69,7 @@ nodes { } nodes { position { - x: 60.0 + x: 30.0 y: 0.0 z: 0.0 w: 1.0 @@ -105,7 +105,7 @@ nodes { id: "label" xanchor: XANCHOR_NONE yanchor: YANCHOR_NONE - pivot: PIVOT_CENTER + pivot: PIVOT_W outline { x: 1.0 y: 1.0 diff --git a/assets/example.font b/gooey/themes/kenneyblue/fonts/kenneyblue.font similarity index 82% rename from assets/example.font rename to gooey/themes/kenneyblue/fonts/kenneyblue.font index 73cc36b..32c66f1 100644 --- a/assets/example.font +++ b/gooey/themes/kenneyblue/fonts/kenneyblue.font @@ -1,4 +1,4 @@ -font: "/builtins/fonts/vera_mo_bd.ttf" +font: "/gooey/themes/kenneyblue/fonts/kenvector_future.ttf" material: "/builtins/fonts/font-df.material" size: 15 antialias: 1 diff --git a/gooey/themes/kenneyblue/fonts/kenvector_future.ttf b/gooey/themes/kenneyblue/fonts/kenvector_future.ttf new file mode 100644 index 0000000..39ebdfa Binary files /dev/null and b/gooey/themes/kenneyblue/fonts/kenvector_future.ttf differ diff --git a/assets/images/blue_boxCheckmark.png b/gooey/themes/kenneyblue/images/blue_boxCheckmark.png similarity index 100% rename from assets/images/blue_boxCheckmark.png rename to gooey/themes/kenneyblue/images/blue_boxCheckmark.png diff --git a/assets/images/blue_boxCross.png b/gooey/themes/kenneyblue/images/blue_boxCross.png similarity index 100% rename from assets/images/blue_boxCross.png rename to gooey/themes/kenneyblue/images/blue_boxCross.png diff --git a/assets/images/blue_boxTick.png b/gooey/themes/kenneyblue/images/blue_boxTick.png similarity index 100% rename from assets/images/blue_boxTick.png rename to gooey/themes/kenneyblue/images/blue_boxTick.png diff --git a/assets/images/blue_button00.png b/gooey/themes/kenneyblue/images/blue_button00.png similarity index 100% rename from assets/images/blue_button00.png rename to gooey/themes/kenneyblue/images/blue_button00.png diff --git a/assets/images/blue_button01.png b/gooey/themes/kenneyblue/images/blue_button01.png similarity index 100% rename from assets/images/blue_button01.png rename to gooey/themes/kenneyblue/images/blue_button01.png diff --git a/assets/images/blue_button02.png b/gooey/themes/kenneyblue/images/blue_button02.png similarity index 100% rename from assets/images/blue_button02.png rename to gooey/themes/kenneyblue/images/blue_button02.png diff --git a/assets/images/blue_button03.png b/gooey/themes/kenneyblue/images/blue_button03.png similarity index 100% rename from assets/images/blue_button03.png rename to gooey/themes/kenneyblue/images/blue_button03.png diff --git a/assets/images/blue_button04.png b/gooey/themes/kenneyblue/images/blue_button04.png similarity index 100% rename from assets/images/blue_button04.png rename to gooey/themes/kenneyblue/images/blue_button04.png diff --git a/assets/images/blue_button05.png b/gooey/themes/kenneyblue/images/blue_button05.png similarity index 100% rename from assets/images/blue_button05.png rename to gooey/themes/kenneyblue/images/blue_button05.png diff --git a/assets/images/blue_button06.png b/gooey/themes/kenneyblue/images/blue_button06.png similarity index 100% rename from assets/images/blue_button06.png rename to gooey/themes/kenneyblue/images/blue_button06.png diff --git a/assets/images/blue_button07.png b/gooey/themes/kenneyblue/images/blue_button07.png similarity index 100% rename from assets/images/blue_button07.png rename to gooey/themes/kenneyblue/images/blue_button07.png diff --git a/assets/images/blue_button08.png b/gooey/themes/kenneyblue/images/blue_button08.png similarity index 100% rename from assets/images/blue_button08.png rename to gooey/themes/kenneyblue/images/blue_button08.png diff --git a/assets/images/blue_button09.png b/gooey/themes/kenneyblue/images/blue_button09.png similarity index 100% rename from assets/images/blue_button09.png rename to gooey/themes/kenneyblue/images/blue_button09.png diff --git a/assets/images/blue_button10.png b/gooey/themes/kenneyblue/images/blue_button10.png similarity index 100% rename from assets/images/blue_button10.png rename to gooey/themes/kenneyblue/images/blue_button10.png diff --git a/assets/images/blue_button11.png b/gooey/themes/kenneyblue/images/blue_button11.png similarity index 100% rename from assets/images/blue_button11.png rename to gooey/themes/kenneyblue/images/blue_button11.png diff --git a/assets/images/blue_button12.png b/gooey/themes/kenneyblue/images/blue_button12.png similarity index 100% rename from assets/images/blue_button12.png rename to gooey/themes/kenneyblue/images/blue_button12.png diff --git a/assets/images/blue_button13.png b/gooey/themes/kenneyblue/images/blue_button13.png similarity index 100% rename from assets/images/blue_button13.png rename to gooey/themes/kenneyblue/images/blue_button13.png diff --git a/assets/images/blue_checkmark.png b/gooey/themes/kenneyblue/images/blue_checkmark.png similarity index 100% rename from assets/images/blue_checkmark.png rename to gooey/themes/kenneyblue/images/blue_checkmark.png diff --git a/assets/images/blue_circle.png b/gooey/themes/kenneyblue/images/blue_circle.png similarity index 100% rename from assets/images/blue_circle.png rename to gooey/themes/kenneyblue/images/blue_circle.png diff --git a/assets/images/blue_cross.png b/gooey/themes/kenneyblue/images/blue_cross.png similarity index 100% rename from assets/images/blue_cross.png rename to gooey/themes/kenneyblue/images/blue_cross.png diff --git a/assets/images/blue_panel.png b/gooey/themes/kenneyblue/images/blue_panel.png similarity index 100% rename from assets/images/blue_panel.png rename to gooey/themes/kenneyblue/images/blue_panel.png diff --git a/assets/images/blue_sliderDown.png b/gooey/themes/kenneyblue/images/blue_sliderDown.png similarity index 100% rename from assets/images/blue_sliderDown.png rename to gooey/themes/kenneyblue/images/blue_sliderDown.png diff --git a/assets/images/blue_sliderLeft.png b/gooey/themes/kenneyblue/images/blue_sliderLeft.png similarity index 100% rename from assets/images/blue_sliderLeft.png rename to gooey/themes/kenneyblue/images/blue_sliderLeft.png diff --git a/assets/images/blue_sliderRight.png b/gooey/themes/kenneyblue/images/blue_sliderRight.png similarity index 100% rename from assets/images/blue_sliderRight.png rename to gooey/themes/kenneyblue/images/blue_sliderRight.png diff --git a/assets/images/blue_sliderUp.png b/gooey/themes/kenneyblue/images/blue_sliderUp.png similarity index 100% rename from assets/images/blue_sliderUp.png rename to gooey/themes/kenneyblue/images/blue_sliderUp.png diff --git a/assets/images/blue_tick.png b/gooey/themes/kenneyblue/images/blue_tick.png similarity index 100% rename from assets/images/blue_tick.png rename to gooey/themes/kenneyblue/images/blue_tick.png diff --git a/assets/images/dropdownBottom.png b/gooey/themes/kenneyblue/images/dropdownBottom.png similarity index 100% rename from assets/images/dropdownBottom.png rename to gooey/themes/kenneyblue/images/dropdownBottom.png diff --git a/assets/images/dropdownMid.png b/gooey/themes/kenneyblue/images/dropdownMid.png similarity index 100% rename from assets/images/dropdownMid.png rename to gooey/themes/kenneyblue/images/dropdownMid.png diff --git a/assets/images/dropdownTop.png b/gooey/themes/kenneyblue/images/dropdownTop.png similarity index 100% rename from assets/images/dropdownTop.png rename to gooey/themes/kenneyblue/images/dropdownTop.png diff --git a/assets/images/grey_box.png b/gooey/themes/kenneyblue/images/grey_box.png similarity index 100% rename from assets/images/grey_box.png rename to gooey/themes/kenneyblue/images/grey_box.png diff --git a/assets/images/grey_boxCheckmark.png b/gooey/themes/kenneyblue/images/grey_boxCheckmark.png similarity index 100% rename from assets/images/grey_boxCheckmark.png rename to gooey/themes/kenneyblue/images/grey_boxCheckmark.png diff --git a/assets/images/grey_boxCross.png b/gooey/themes/kenneyblue/images/grey_boxCross.png similarity index 100% rename from assets/images/grey_boxCross.png rename to gooey/themes/kenneyblue/images/grey_boxCross.png diff --git a/assets/images/grey_boxTick.png b/gooey/themes/kenneyblue/images/grey_boxTick.png similarity index 100% rename from assets/images/grey_boxTick.png rename to gooey/themes/kenneyblue/images/grey_boxTick.png diff --git a/assets/images/grey_button02.png b/gooey/themes/kenneyblue/images/grey_button02.png similarity index 100% rename from assets/images/grey_button02.png rename to gooey/themes/kenneyblue/images/grey_button02.png diff --git a/assets/images/grey_circle.png b/gooey/themes/kenneyblue/images/grey_circle.png similarity index 100% rename from assets/images/grey_circle.png rename to gooey/themes/kenneyblue/images/grey_circle.png diff --git a/gooey/themes/kenneyblue/images/kenneyblue.atlas b/gooey/themes/kenneyblue/images/kenneyblue.atlas new file mode 100644 index 0000000..eae48f1 --- /dev/null +++ b/gooey/themes/kenneyblue/images/kenneyblue.atlas @@ -0,0 +1,111 @@ +images { + image: "/gooey/themes/kenneyblue/images/blue_boxCheckmark.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_boxCross.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_boxTick.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button00.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button01.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button02.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button03.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button04.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button05.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button06.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button07.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button08.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button09.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button10.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button11.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button12.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_button13.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_checkmark.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_circle.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_cross.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_panel.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_sliderDown.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_sliderLeft.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_sliderRight.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_sliderUp.png" +} +images { + image: "/gooey/themes/kenneyblue/images/blue_tick.png" +} +images { + image: "/gooey/themes/kenneyblue/images/dropdownBottom.png" +} +images { + image: "/gooey/themes/kenneyblue/images/dropdownMid.png" +} +images { + image: "/gooey/themes/kenneyblue/images/dropdownTop.png" +} +images { + image: "/gooey/themes/kenneyblue/images/grey_box.png" +} +images { + image: "/gooey/themes/kenneyblue/images/grey_circle.png" +} +images { + image: "/gooey/themes/kenneyblue/images/grey_boxTick.png" +} +images { + image: "/gooey/themes/kenneyblue/images/grey_boxCheckmark.png" +} +images { + image: "/gooey/themes/kenneyblue/images/grey_boxCross.png" +} +images { + image: "/gooey/themes/kenneyblue/images/transparent1px.png" +} +images { + image: "/gooey/themes/kenneyblue/images/grey_button02.png" +} +margin: 0 +extrude_borders: 1 +inner_padding: 1 diff --git a/assets/images/transparent1px.png b/gooey/themes/kenneyblue/images/transparent1px.png similarity index 100% rename from assets/images/transparent1px.png rename to gooey/themes/kenneyblue/images/transparent1px.png diff --git a/example/example.gui_script b/gooey/themes/kenneyblue/kenneyblue.lua similarity index 57% rename from example/example.gui_script rename to gooey/themes/kenneyblue/kenneyblue.lua index 1110223..63fdf19 100644 --- a/example/example.gui_script +++ b/gooey/themes/kenneyblue/kenneyblue.lua @@ -1,5 +1,9 @@ local gooey = require "gooey.gooey" + +local M = {} + + local function shake(node, initial_scale) gui.cancel_animation(node, "scale.x") gui.cancel_animation(node, "scale.y") @@ -12,7 +16,14 @@ local function shake(node, initial_scale) end) end -local function update_button(button) + +function M.acquire_input() + gooey.acquire_input() +end + + +function M.button(node_id, action_id, action, fn) + local button = gooey.button(node_id .. "/bg", action_id, action, fn) if button.pressed_now or button.released_now then shake(button.node, vmath.vector3(1)) end @@ -21,9 +32,12 @@ local function update_button(button) else gui.play_flipbook(button.node, hash("blue_button04")) end + return button end -local function update_checkbox(checkbox) + +function M.checkbox(node_id, action_id, action, fn) + local checkbox = gooey.checkbox(node_id .. "/box", action_id, action, fn) if checkbox.pressed_now or checkbox.released_now then shake(checkbox.node, vmath.vector3(1)) end @@ -33,10 +47,12 @@ local function update_checkbox(checkbox) gui.play_flipbook(checkbox.node, hash("blue_boxCross")) else gui.play_flipbook(checkbox.node, hash("grey_box")) - end + end + return checkbox end -local function update_radio(radio) + +local function update_radiobutton(radio) if radio.pressed_now or radio.released_now then shake(radio.node, vmath.vector3(1)) end @@ -49,41 +65,35 @@ local function update_radio(radio) end end -local function update_list(list) - for i,item in pairs(list.items) do - local pos = gui.get_position(item) - if i == list.selected_item then - pos.x = 4 - gui.play_flipbook(item, hash("blue_button03")) - elseif i == list.pressed_item then - pos.x = 1 - gui.play_flipbook(item, hash("blue_button03")) - elseif i == list.over_item_now then - pos.x = 1 - gui.play_flipbook(item, hash("blue_button04")) - elseif i == list.out_item_now then - pos.x = 0 - gui.play_flipbook(item, hash("blue_button04")) - elseif i ~= list.over_item then - pos.x = 0 - gui.play_flipbook(item, hash("blue_button04")) - end - gui.set_position(item, pos) +function M.radiogroup(group_id, action_id, action, fn) + local radiobuttons = gooey.radiogroup(group_id, action_id, action, fn) + for _,radio in ipairs(radiobuttons) do + update_radiobutton(radio) end + return radiobuttons +end + +function M.radio(node_id, group_id, action_id, action, fn) + local radio = gooey.radio(node_id .. "/button", group_id, action_id, action, fn) + update_radiobutton(radio) + return radio end -local function update_input(input, empty_text, cursor_id, bg_id) + +function M.input(node_id, keyboard_type, action_id, action, empty_text) + local input = gooey.input(node_id .. "/text", keyboard_type, action_id, action) + if input.selected_now then - gui.play_flipbook(gui.get_node(bg_id), hash("blue_button05")) + gui.play_flipbook(gui.get_node(node_id .. "/bg"), hash("blue_button05")) elseif input.deselected_now then - gui.play_flipbook(gui.get_node(bg_id), hash("blue_button03")) + gui.play_flipbook(gui.get_node(node_id .. "/bg"), hash("blue_button03")) end - + if input.empty and not input.selected then gui.set_text(input.node, empty_text) end - local cursor = gui.get_node(cursor_id) + local cursor = gui.get_node(node_id .. "/cursor") if input.selected then gui.set_enabled(cursor, true) gui.set_position(cursor, vmath.vector3(4 + input.text_width, 0, 0)) @@ -94,50 +104,32 @@ local function update_input(input, empty_text, cursor_id, bg_id) gui.set_enabled(cursor, false) gui.cancel_animation(cursor, gui.PROP_COLOR) end + return input end -function init(self) - gooey.acquire_input() - self.list_ids = { - "listitem1/bg", "listitem2/bg", "listitem3/bg", "listitem4/bg", "listitem5/bg", - "listitem6/bg", "listitem7/bg", "listitem8/bg", "listitem9/bg", "listitem10/bg", - "listitem11/bg", "listitem12/bg" - } - update_input(gooey.input("input/text", gui.KEYBOARD_TYPE_DEFAULT, nil, { x=0, y=0 }), "EMPTY TEXT", "input/cursor", "input/bg") - msg.post("@render:", "clear_color", { color = vmath.vector4(0.1, 0.15, 0.25, 1.0) }) -end - -function on_input(self, action_id, action) - update_button(gooey.button("button/bg", action_id, action, function(button) - print("pressed button") - end)) - - update_checkbox(gooey.checkbox("checkbox/box", action_id, action, function(checkbox) - print("checked", checkbox.checked) - end)) - - local radio1 = gooey.radio("radio1/button", "GROUP1", action_id, action, function(radio) - print("selected 1", radio.selected) - end) - local radio2 = gooey.radio("radio2/button", "GROUP1", action_id, action, function(radio) - print("selected 2", radio.selected) - end) - local radio3 = gooey.radio("radio3/button", "GROUP1", action_id, action, function(radio) - print("selected 3", radio.selected) - end) - update_radio(radio1) - update_radio(radio2) - update_radio(radio3) - - update_list(gooey.list("listroot", self.list_ids, action_id, action, function(list) - print("selected list item", list.selected_item) - end)) - - update_input(gooey.input("input/text", gui.KEYBOARD_TYPE_DEFAULT, action_id, action), "EMPTY TEXT", "input/cursor", "input/bg") +function M.list(root_id, item_ids, action_id, action, fn) + local list = gooey.list(root_id, item_ids, action_id, action, fn) + for i,item in pairs(list.items) do + local pos = gui.get_position(item) + if i == list.selected_item then + pos.x = 4 + gui.play_flipbook(item, hash("blue_button03")) + elseif i == list.pressed_item then + pos.x = 1 + gui.play_flipbook(item, hash("blue_button03")) + elseif i == list.over_item_now then + pos.x = 1 + gui.play_flipbook(item, hash("blue_button04")) + elseif i == list.out_item_now then + pos.x = 0 + gui.play_flipbook(item, hash("blue_button04")) + elseif i ~= list.over_item then + pos.x = 0 + gui.play_flipbook(item, hash("blue_button04")) + end + gui.set_position(item, pos) + end end -function on_reload(self) - -- Add input-handling code here - -- Remove this function if not needed -end +return M \ No newline at end of file