60 Commits
0.6.0 ... 0.8.0

Author SHA1 Message Date
Maxim Tuprikov
10fad9c871 Merge pull request #167 from Insality/develop
Release 0.8.0
2022-02-12 17:22:52 +02:00
Insality
3b329f9c25 Update docs, annotations and style for checkbox 2022-02-12 17:17:36 +02:00
Insality
4e0fd264b1 Prepare for release 0.8.0 2022-02-12 17:02:27 +02:00
Insality
a75dd5a6f9 Merge branch 'master' into develop 2022-02-12 16:20:48 +02:00
Maxim Tuprikov
c12bfe63a5 Merge pull request #166 from SalavatR/patch-1 2022-02-02 16:19:18 +02:00
SalavatR
21830d9886 Update input.lua
function set_allowed_characters(NAME_PATTERN) isn't working with Cyrillic symbols  in range "[А-я]", string.match includes chars №, ₽ and may be more
2022-02-02 19:51:15 +06:00
Insality
3ac2986171 #162 Add static grid last row alignment 2022-01-27 22:29:13 +02:00
Insality
97e7631d22 #155 Add margin to total width in centrate_nodes 2022-01-27 19:35:29 +02:00
Insality
f534baf2ee #163 Default locale id from text node for lang_text component 2022-01-27 18:31:33 +02:00
Insality
54f80aeccd #160 Remove component interests, now setup it with function declaring 2022-01-27 01:48:05 +02:00
Insality
7a5faa2b85 #164 Fix scroll_to_percent wrong Y position 2022-01-27 01:15:12 +02:00
Insality
b7d2891fed #153 Add Druid acquire input to late_init step 2022-01-27 01:13:23 +02:00
Insality
ef455a71eb #00 Add more self chaining to Lang text component 2022-01-27 01:12:49 +02:00
Insality
30f48f1d27 #00 Add text arg to on_input_unselect event 2022-01-27 01:11:34 +02:00
Insality
b42d16d999 #152 Add instans set_state for Checkbox component 2022-01-27 01:09:24 +02:00
Insality
8d0f9e5070 #154 Change text adjust const to strings 2022-01-27 01:06:35 +02:00
Insality
43adb5f52d #147 Remove ... from lang_text to fixed arguments, add lang_text:format additional functions 2021-11-20 11:14:04 +02:00
Insality
d0c91c9cb5 #151 Fix text adjust by height 2021-11-20 11:12:34 +02:00
Insality
098df24265 #150 Fix scroll to percentage on Y position 2021-11-20 11:11:52 +02:00
Insality
154d9fc166 #148 remove scroll inertion after scroll animate or set_to 2021-11-20 11:11:24 +02:00
Insality
dbb883b1b8 #149 Call button style functions after actual callback 2021-11-20 11:10:29 +02:00
Maxim Tuprikov
9459ecc6b2 Merge pull request #145 from Insality/release/0.7.0
Release/0.7.0 to master
2021-10-23 17:48:53 +03:00
Insality
c16c3e4074 Update docs 2021-10-23 17:45:46 +03:00
Insality
d2e4362f48 Update example app 2021-10-23 17:39:24 +03:00
Insality
1ae77e727f Increase version to 0.7.0 2021-10-23 17:33:14 +03:00
Insality
e6f0a86f12 Update docs 2021-10-23 17:32:52 +03:00
Insality
db0196f55e Update changelog 2021-10-23 17:32:35 +03:00
Insality
009c3999c4 #142 Add WHEEL_SCROLL_BY_INERTION Scroll style param 2021-10-23 17:10:15 +03:00
Insality
d24301cd13 #144 Add checks for is scroll available to check POI in that intertion side 2021-10-23 16:34:14 +03:00
Insality
ba312742d2 #107 Better scale text adjust by height for multiline text nodes 2021-10-23 16:18:43 +03:00
Insality
ab3f5f8e31 #104 Add is_instant flag to add/remove Static and Dynamic Grid components 2021-10-23 15:16:38 +03:00
Insality
a4a03db813 #110 Add set_check_function for Buttom component 2021-10-23 15:04:12 +03:00
Insality
273dd33843 #111 Fix game.project field compare type 2021-10-23 14:11:26 +03:00
Insality
91fb8ced52 #111 Add druid.stencil_check for auto stencil check to call set_click_zone 2021-10-23 14:08:24 +03:00
Insality
063e4f4a31 Add message input TEXT_SET, update docs/changelog 2021-10-23 13:30:50 +03:00
Insality
0179e68887 #91 Add license comments 2021-10-23 13:08:39 +03:00
Insality
1da5476837 #81 Add simple input control via messages 2021-10-22 00:56:46 +03:00
Insality
bbdf2b405d Add #143 to changelog 2021-10-21 00:40:19 +03:00
Insality
a8c2185d20 #143 Update all lang components on set_text_function 2021-10-21 00:38:23 +03:00
Insality
94197391a5 Update docs for #78 text update 2021-10-20 20:52:14 +03:00
Insality
4ef8316949 #78 Add text different adjust types 2021-10-20 20:24:31 +03:00
Insality
a501d3418b Add #125 to changelog 2021-10-17 18:28:55 +03:00
Insality
19ece205f8 #125 Now set_input_priority affects on all children of component 2021-10-17 18:28:11 +03:00
Insality
a014fca1a1 #66 Add set_whitelist and set_blacklist functions 2021-10-17 17:50:49 +03:00
Insality
a9de3771e3 #112 Add allow remap default Druid input bindings 2021-10-17 16:55:23 +03:00
Insality
087ca36d12 Add 132 to changelog 2021-10-17 16:43:59 +03:00
Insality
1219b02c10 #131 Add dynamic_poses for static grid 2021-10-17 16:36:45 +03:00
Maxim Tuprikov
b4560daa69 Merge pull request #136 from SalavatR/develop
Update scroll.lua
2021-08-07 13:03:45 +03:00
Maxim Tuprikov
ecc6e27057 Merge pull request #134 from astrochili/develop
Update README.md
2021-08-07 13:03:15 +03:00
SalavatR
732dad747c Update scroll.lua 2021-08-04 20:44:36 +06:00
Roman Silin
b3dc9581d1 Update README.md 2021-07-18 16:48:01 +03:00
Insality
5d74531b4a Merge branch 'develop', add .gitattributes 2021-05-30 12:09:22 +03:00
Insality
8d3332204b Add git attributes for syntax highlight 2021-05-30 12:06:27 +03:00
Insality
105f672676 Merge branch 'develop': add example for grid animations 2021-05-30 11:54:20 +03:00
Insality
305c300f31 Update example 2021-05-30 11:52:56 +03:00
Insality
ffa3bafa00 Add deep linking for exampes in html 2021-05-30 11:50:37 +03:00
Insality
271fdd2b57 #132 Add example: add/remove grid with animations 2021-05-23 21:10:09 +03:00
Insality
63a6af3faa Fix typo 2021-04-08 00:29:57 +03:00
Insality
40c3609162 Update docs 2021-04-08 00:29:16 +03:00
Insality
d2fcb1aa85 Update changelogs 2021-04-06 00:34:29 +03:00
110 changed files with 9482 additions and 441 deletions

18
.gitattributes vendored Normal file
View File

@@ -0,0 +1,18 @@
# Defold GLSL Shaders
*.fp linguist-language=GLSL
*.vp linguist-language=GLSL
# Defold Lua Files
*.editor_script linguist-language=Lua
*.render_script linguist-language=Lua
*.script linguist-language=Lua
*.gui_script linguist-language=Lua
# Defold Files
*.atlas linguist-language=JSON5
*.collection linguist-language=JSON5
*.font linguist-language=JSON5
*.go linguist-language=JSON5
*.gui linguist-language=JSON5
*.tilemap linguist-language=JSON5
*.tilesource linguist-language=JSON5

View File

@@ -48,4 +48,5 @@ globals = {
"buffer",
"resource",
"defos",
"html5",
}

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2020 Maxim Tuprikov
Copyright (c) 2021 Maxim Tuprikov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -22,6 +22,8 @@ Or point to the ZIP file of a [specific release](https://github.com/Insality/dru
**Druid** requires the following input bindings:
- Mouse trigger - `Button 1` -> `touch` _For basic input components_
- Mouse trigger - `Wheel up` -> `scroll_up` _For scroll component_
- Mouse trigger - `Wheel down` -> `scroll_down` _For scroll component_
- Key trigger - `Backspace` -> `key_backspace` _For back_handler component, input component_
- Key trigger - `Back` -> `key_back` _For back_handler component, Android back button, input component_
- Key trigger - `Enter` -> `key_enter` _For input component, optional_
@@ -32,6 +34,25 @@ Or point to the ZIP file of a [specific release](https://github.com/Insality/dru
![](media/input_binding_1.png)
### Change key bindings [optional]
If you have to use your own key bindings (and key name), you can change it in your *game.project* file.
Here is current default values for key bindings:
```
[druid]
input_text = text
input_touch = touch
input_marked_text = marked_text
input_key_esc = key_esc
input_key_back = key_back
input_key_enter = key_enter
input_key_backspace = key_backspace
input_multitouch = multitouch
input_scroll_up = scroll_up
input_scroll_down = scroll_down
```
### Input capturing [optional]
By default, **Druid** will auto-capture input focus, if any input component will be created. So you don't need to call `msg.post(".", "acquire_input_focus")`
@@ -42,6 +63,16 @@ If you don't need this behaviour, you can disable it by settings `druid.no_auto_
no_auto_input = 1
```
### Stencil check [optional]
When creating input components inside stencil nodes, you probably will use `component:set_click_zone()` to restrict clicks outside this stencil zone.
Druid can do it automatically on _late_init_ component step. To enable this feature add next field in your _game.project_ file
```
[druid]
stencil_check = 1
```
### Code [optional]
Adjust **Druid** settings, if needed:
@@ -101,6 +132,8 @@ druid.on_window_callback(event)
- **[Dynamic Grid](docs_md/01-components.md#dynamic-grid)** - Component to manage node positions with different sizes. Only in one row or column
- **[Data List](docs_md/01-components.md#data-list)** - Component to manage data for huge dataset in scroll
- **[Input](docs_md/01-components.md#input)** - User text input component
- **[Lang text](docs_md/01-components.md#lang-text)** - Wrap on Text component to handle localization

View File

@@ -11,7 +11,8 @@ local druid = {}
function druid.new(context, style) end
--- Druid on language change.
function druid.on_language_change() end
---@param self druid_instance
function druid.on_language_change(self) end
--- Callback on global language change event.
function druid.on_language_change() end
@@ -28,6 +29,11 @@ function druid.on_window_callback(event) end
---@param module table lua table with component
function druid.register(name, module) end
--- Set blacklist components for input processing.
---@param self druid_instance
---@param blacklist_components table|Component The array of component to blacklist
function druid.set_blacklist(self, blacklist_components) end
--- Set new default style.
---@param style table Druid style module
function druid.set_default_style(style) end
@@ -40,6 +46,11 @@ function druid.set_sound_function(callback) end
---@param callback function Get localized text function
function druid.set_text_function(callback) end
--- Set whitelist components for input processing.
---@param self druid_instance
---@param whitelist_components table|Component The array of component to whitelist
function druid.set_whitelist(self, whitelist_components) end
---@class druid.back_handler : druid.base_component
---@field on_back druid_event On back handler callback(self, params)
@@ -60,9 +71,14 @@ function druid__back_handler.on_input(self, action_id, action) end
---@class druid.base_component
---@field ALL field Component Interests
---@field ON_INPUT field Component Interests
local druid__base_component = {}
--- Return all children components, recursive
---@param self druid.base_component
---@return table Array of childrens if the Druid component instance
function druid__base_component.get_childrens(self) end
--- Get current component context
---@param self druid.base_component
---@return table BaseComponent context
@@ -163,6 +179,7 @@ function druid__blocker.set_enabled(self, state) end
---@class druid.button : druid.base_component
---@field anim_node node Animation node
---@field click_zone node Restriction zone
---@field hash node_id The hash of trigger node
---@field hover druid.hover Druid hover logic component
---@field node node Trigger node
---@field on_click druid_event On release button callback(self, params, button_instance)
@@ -196,6 +213,12 @@ function druid__button.init(self, node, callback, params, anim_node) end
---@return bool True, if button is enabled
function druid__button.is_enabled(self) end
--- Set function for additional check for button click availability
---@param check_function function Should return true or false. If true - button can be pressed.
---@param failure_callback function Function what will be called on button click, if check function return false
---@return druid.button Current button instance
function druid__button.set_check_function(check_function, failure_callback) end
--- Strict button click area.
---@param self druid.button
---@param zone node Gui node
@@ -245,13 +268,15 @@ function druid__checkbox.get_state(self) end
---@param node node Gui node
---@param callback function Checkbox callback
---@param click_node node Trigger node, by default equals to node
function druid__checkbox.init(self, node, callback, click_node) end
---@param initial_state boolean The initial state of checkbox, default - false
function druid__checkbox.init(self, node, callback, click_node, initial_state) end
--- Set checkbox state
---@param self druid.checkbox
---@param state bool Checkbox state
---@param is_silent bool Don't trigger on_change_state if true
function druid__checkbox.set_state(self, state, is_silent) end
---@param is_instant bool If instant checkbox change
function druid__checkbox.set_state(self, state, is_silent, is_instant) end
---@class druid.checkbox.style
@@ -279,7 +304,8 @@ function druid__checkbox_group.init(self, nodes, callback, click_nodes) end
--- Set checkbox group state
---@param self druid.checkbox_group
---@param indexes bool[] Array of checkbox state
function druid__checkbox_group.set_state(self, indexes) end
---@param is_instant boolean If instant state change
function druid__checkbox_group.set_state(self, indexes, is_instant) end
---@class druid.data_list : druid.base_component
@@ -393,7 +419,8 @@ function druid__dynamic_grid._get_side_vector(self, side, is_forward) end
---@param node node Gui node
---@param index number The node position. By default add as last node
---@param shift_policy number How shift nodes, if required. See const.SHIFT
function druid__dynamic_grid.add(self, node, index, shift_policy) end
---@param is_instance boolean If true, update node positions instantly
function druid__dynamic_grid.add(self, node, index, shift_policy, is_instance) end
--- Clear grid nodes array.
---@param self druid.dynamic_grid
@@ -444,8 +471,9 @@ function druid__dynamic_grid.init(self, parent) end
---@param self druid.dynamic_grid
---@param index number The grid node index to remove
---@param shift_policy number How shift nodes, if required. See const.SHIFT
---@param is_instance boolean If true, update node positions instantly
---@return Node The deleted gui node from grid
function druid__dynamic_grid.remove(self, index, shift_policy) end
function druid__dynamic_grid.remove(self, index, shift_policy, is_instance) end
--- Change set position function for grid nodes.
---@param self druid.dynamic_grid
@@ -502,7 +530,7 @@ function druid__hover.set_mouse_hover(self, state) end
---@field on_input_full druid_event On input field text change to max length string callback(self, input_text)
---@field on_input_select druid_event On input field select callback(self, button_node)
---@field on_input_text druid_event On input field text change callback(self, input_text)
---@field on_input_unselect druid_event On input field unselect callback(self, button_node)
---@field on_input_unselect druid_event On input field unselect callback(self, input_text)
---@field on_input_wrong druid_event On trying user input with not allowed character callback(self, params, button_instance)
---@field style druid.input.style Component style params.
---@field text druid.text Text component
@@ -559,22 +587,31 @@ local druid__input__style = {}
---@field text Text The text component
local druid__lang_text = {}
--- Format string with new text params on localized text
---@param self druid.lang_text
---@param ... string Locale arguments to pass in text function
---@return druid.lang_text Current instance
function druid__lang_text.format(self, ...) end
--- Component init function
---@param self druid.lang_text
---@param node node The text node
---@param locale_id string Default locale id, optional
---@param locale_id string Default locale id or text from node as default
---@param no_adjust bool If true, will not correct text size
function druid__lang_text.init(self, node, locale_id, no_adjust) end
--- Setup raw text to lang_text component
---@param self druid.lang_text
---@param text string Text for text node
---@return druid.lang_text Current instance
function druid__lang_text.set_to(self, text) end
--- Translate the text by locale_id
---@param self druid.lang_text
---@param locale_id string Locale id
function druid__lang_text.translate(self, locale_id) end
---@param ... string Locale arguments to pass in text function
---@return druid.lang_text Current instance
function druid__lang_text.translate(self, locale_id, ...) end
---@class druid.progress : druid.base_component
@@ -651,7 +688,8 @@ function druid__radio_group.init(self, nodes, callback, click_nodes) end
--- Set radio group state
---@param self druid.radio_group
---@param index number Index in radio group
function druid__radio_group.set_state(self, index) end
---@param is_instant boolean If is instant state change
function druid__radio_group.set_state(self, index, is_instant) end
---@class druid.scroll : druid.base_component
@@ -780,6 +818,7 @@ function druid__scroll.set_vertical_scroll(self, state) end
---@field INERT_THRESHOLD field Scroll speed to stop inertion
---@field POINTS_DEADZONE field Speed to check points of interests in no_inertion mode
---@field SMALL_CONTENT_SCROLL field If true, content node with size less than view node size can be scrolled
---@field WHEEL_SCROLL_BY_INERTION field If true, wheel will add inertion to scroll. Direct set position otherwise.
---@field WHEEL_SCROLL_INVERTED field If true, invert direction for touchpad and mouse wheel scroll
---@field WHEEL_SCROLL_SPEED field The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
local druid__scroll__style = {}
@@ -829,6 +868,7 @@ function druid__slider.set_steps(self, steps) end
---@field on_remove_item druid_event On item remove callback(self, index)
---@field on_update_positions druid_event On update item positions callback(self)
---@field parent node Parent gui node
---@field style druid.static_grid.style Component style params.
local druid__static_grid = {}
--- Add new item to the grid
@@ -836,7 +876,8 @@ local druid__static_grid = {}
---@param item node Gui node
---@param index number The item position. By default add as last item
---@param shift_policy number How shift nodes, if required. See const.SHIFT
function druid__static_grid.add(self, item, index, shift_policy) end
---@param is_instance boolean If true, update node positions instantly
function druid__static_grid.add(self, item, index, shift_policy, is_instance) end
--- Clear grid nodes array.
---@param self druid.static_grid
@@ -892,8 +933,9 @@ function druid__static_grid.init(self, parent, element, in_row) end
---@param self druid.static_grid
---@param index number The grid node index to remove
---@param shift_policy number How shift nodes, if required. See const.SHIFT
---@param is_instance boolean If true, update node positions instantly
---@return Node The deleted gui node from grid
function druid__static_grid.remove(self, index, shift_policy) end
function druid__static_grid.remove(self, index, shift_policy, is_instance) end
--- Set grid anchor.
---@param self druid.static_grid
@@ -907,6 +949,12 @@ function druid__static_grid.set_anchor(self, anchor) end
function druid__static_grid.set_position_function(self, callback) end
---@class druid.static_grid.style
---@field IS_ALIGN_LAST_ROW field If true, always align last row of the grid as grid pivot sets
---@field IS_DYNAMIC_NODE_POSES field If true, always center grid content as grid pivot sets
local druid__static_grid__style = {}
---@class druid.swipe : druid.base_component
---@field click_zone node Restriction zone
---@field node node Swipe node
@@ -934,9 +982,10 @@ local druid__swipe__style = {}
---@class druid.text : druid.base_component
---@field adjust_type number Current text size adjust settings
---@field color vector3 Current text color
---@field is_no_adjust bool Current text size adjust settings
---@field node node Text node
---@field node_id hash The node id of text node
---@field on_set_pivot druid_event On change pivot callback(self, pivot)
---@field on_set_text druid_event On set text callback(self, text)
---@field on_update_text_scale druid_event On adjust text size callback(self, new_scale)
@@ -944,9 +993,16 @@ local druid__swipe__style = {}
---@field scale vector3 Current text node scale
---@field start_scale vector3 Initial text node scale
---@field start_size vector3 Initial text node size
---@field style druid.text.style Component style params.
---@field text_area vector3 Current text node available are
local druid__text = {}
--- Return current text adjust type
---@param self unknown
---@param adjust_type unknown
---@return number The current text adjust type
function druid__text.get_text_adjust(self, adjust_type) end
--- Calculate text width with font with respect to trailing space
---@param self druid.text
---@param text string
@@ -956,8 +1012,8 @@ function druid__text.get_text_width(self, text) end
---@param self druid.text
---@param node node Gui text node
---@param value string Initial text. Default value is node text from GUI scene.
---@param no_adjust bool If true, text will be not auto-adjust size
function druid__text.init(self, node, value, no_adjust) end
---@param adjust_type int Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
function druid__text.init(self, node, value, adjust_type) end
--- Return true, if text with line break
---@param self druid.text
@@ -967,29 +1023,53 @@ function druid__text.is_multiline(self) end
--- Set alpha
---@param self druid.text
---@param alpha number Alpha for node
---@return druid.text Current text instance
function druid__text.set_alpha(self, alpha) end
--- Set color
---@param self druid.text
---@param color vector4 Color for node
---@return druid.text Current text instance
function druid__text.set_color(self, color) end
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
---@param self druid.text
---@param minimal_scale number If pass nil - not use minimal scale
---@return druid.text Current text instance
function druid__text.set_minimal_scale(self, minimal_scale) end
--- Set text pivot.
---@param self druid.text
---@param pivot gui.pivot Gui pivot constant
---@return druid.text Current text instance
function druid__text.set_pivot(self, pivot) end
--- Set scale
---@param self druid.text
---@param scale vector3 Scale for node
---@return druid.text Current text instance
function druid__text.set_scale(self, scale) end
--- Set text adjust, refresh the current text visuals, if needed
---@param self druid.text
---@param adjust_type number See const.TEXT_ADJUST. If pass nil - use current adjust type
---@param minimal_scale number If pass nil - not use minimal scale
---@return druid.text Current text instance
function druid__text.set_text_adjust(self, adjust_type, minimal_scale) end
--- Set text to text field
---@param self druid.text
---@param set_to string Text for node
---@return druid.text Current text instance
function druid__text.set_to(self, set_to) end
---@class druid.text.style
---@field DEFAULT_ADJUST field The default adjust type for any text component
---@field TRIM_POSTFIX field The postfix for TRIM adjust type
local druid__text__style = {}
---@class druid.timer : druid.base_component
---@field from number Initial timer value
---@field node node Trigger node
@@ -1026,7 +1106,7 @@ function druid__timer.set_to(self, set_to) end
---@class druid_const
---@field ALL field Component Interests
---@field ON_INPUT field Component Interests
local druid_const = {}
@@ -1118,8 +1198,9 @@ function druid_instance.new_button(self, node, callback, params, anim_node) end
---@param node node Gui node
---@param callback function Checkbox callback
---@param click_node node Trigger node, by default equals to node
---@param initial_state boolean The initial state of checkbox, default - false
---@return druid.checkbox checkbox component
function druid_instance.new_checkbox(self, node, callback, click_node) end
function druid_instance.new_checkbox(self, node, callback, click_node, initial_state) end
--- Create checkbox_group component
---@param self druid_instance
@@ -1248,6 +1329,7 @@ function druid_instance.on_focus_lost(self) end
---@param self druid_instance
---@param action_id hash Action_id from on_input
---@param action table Action from on_input
---@return bool The boolean value is input was consumed
function druid_instance.on_input(self, action_id, action) end
--- Druid on layout change function.
@@ -1323,6 +1405,11 @@ function helper.deprecated(message) end
---@return vector4 Vector with distance to node border: (left, top, right, down)
function helper.get_border(node, offset) end
--- Return closest non inverted clipping parent node for node
---@param node node Gui node
---@return node|nil The clipping node
function helper.get_closest_stencil_node(node) end
--- Get node offset for given gui pivot
---@param pivot gui.pivot The node pivot
---@return vector3 Vector offset with [-1..1] values

View File

@@ -1 +1 @@
{"content":[{"name":"game.projectc","size":3432,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":10608,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":384566,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":23386,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}
{"content":[{"name":"game.projectc","size":3748,"pieces":[{"name":"game.projectc0","offset":0}]},{"name":"game.arci","size":13488,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":948433,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":13875,"pieces":[{"name":"game.dmanifest0","offset":0}]},{"name":"game.public.der","size":162,"pieces":[{"name":"game.public.der0","offset":0}]}]}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,12 +1,12 @@
[project]
title = druid
version = 0.6.459
version = 0.8.519
write_log = 0
compress_archive = 1
publisher = Insality
developer = Insality
commit_sha = 015564f5b3e0d5e63e422056c69e53826ed689bf
build_time = 2021-04-05T21:00:43Z
commit_sha = 4e0fd264b169693d088a47f2bb53376a1808fb1e
build_time = 2022-02-12T15:15:53Z
[display]
width = 600
@@ -35,7 +35,7 @@ world_count = 4
gravity_x = 0
gravity_z = 0
scale = 1
allow_dynamic_transforms = 0
allow_dynamic_transforms = 1
debug_scale = 30
max_collisions = 64
max_contacts = 128
@@ -121,9 +121,9 @@ default_language = en
localizations = en
[android]
version_code = 459
version_code = 519
minimum_sdk_version = 16
target_sdk_version = 29
target_sdk_version = 30
package = com.insality.druid
manifest = /builtins/manifests/android/AndroidManifest.xml
iap_provider = GooglePlay
@@ -149,6 +149,7 @@ cssfile = /builtins/manifests/web/light_theme.css
archive_location_prefix = archive
show_fullscreen_button = 0
show_made_with_defold = 0
show_console_banner = 1
scale_mode = fit
engine_arguments = --verify-graphics-calls=false
splash_image = /media/druid_logo.png
@@ -191,6 +192,17 @@ run_while_iconified = 0
[druid]
no_auto_input = 0
stencil_check = 0
input_text = text
input_touch = touch
input_marked_text = marked_text
input_key_esc = key_esc
input_key_back = key_back
input_key_enter = key_enter
input_key_backspace = key_backspace
input_multitouch = multitouch
input_scroll_up = scroll_up
input_scroll_down = scroll_down
[native_extension]
app_manifest = /example/game.appmanifest

Binary file not shown.

View File

@@ -30,7 +30,7 @@ var FileLoader = {
return;
}
currentAttempt = currentAttempt + 1;
setTimeout(obj.send, FileLoader.options.retryInterval);
setTimeout(obj.send.bind(obj), FileLoader.options.retryInterval);
};
xhr.onload = function(e) {
if (onload) onload(xhr, e);

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -7,7 +7,7 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- The above 4 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>druid 0.6.459</title>
<title>druid 0.8.519</title>
<style type='text/css'>
/* Disable user selection to avoid strange bug in Chrome on Windows:
* Selecting a text outside the canvas, then clicking+draging would
@@ -160,7 +160,8 @@
var is_iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
var buttonHeight = 0;
// Resize on init, screen resize and orientation change
var prevInnerWidth = -1;
var prevInnerHeight = -1;
function resize_game_canvas() {
// Hack for iOS when exit from Fullscreen mode
if (is_iOS) {
@@ -171,6 +172,12 @@
var game_canvas = document.getElementById('canvas');
var innerWidth = window.innerWidth;
var innerHeight = window.innerHeight - buttonHeight;
if (prevInnerWidth == innerWidth && prevInnerHeight == innerHeight)
{
return;
}
prevInnerWidth = innerWidth;
prevInnerHeight = innerHeight;
var width = 600;
var height = 900;
var targetRatio = width / height;
@@ -201,6 +208,7 @@
resize_game_canvas();
window.addEventListener('resize', resize_game_canvas, false);
window.addEventListener('orientationchange', resize_game_canvas, false);
window.addEventListener('focus', resize_game_canvas, false);
</script>
<script id='engine-start' type='text/javascript'>

View File

@@ -169,7 +169,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -149,11 +149,11 @@
</li>
<li><span class="parameter">action_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
on_input action id
</li>
<li><span class="parameter">action</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
on_input action
</li>
</ul>
@@ -214,7 +214,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -133,11 +133,15 @@
<td class="name" nowrap><a href="#setup_component">setup_component(self, druid_instance, context, style)</a></td>
<td class="summary">Setup component context and his style table</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_childrens">get_childrens(self)</a></td>
<td class="summary">Return all children components, recursive</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#ALL">ALL</a></td>
<td class="name" nowrap><a href="#ON_INPUT">ON_INPUT</a></td>
<td class="summary">Component Interests</td>
</tr>
</table>
@@ -166,7 +170,7 @@
</li>
<li><span class="parameter">druid_style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid style module
</li>
</ul>
@@ -191,7 +195,7 @@
</li>
<li><span class="parameter">template</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
BaseComponent template name
</li>
</ul>
@@ -216,7 +220,7 @@
</li>
<li><span class="parameter">nodes</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
BaseComponent nodes table
</li>
</ul>
@@ -245,7 +249,7 @@
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
BaseComponent context
</ol>
@@ -271,7 +275,7 @@
</li>
<li><span class="parameter">node_or_name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <span class="type">node</span></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
Node name or node itself
</li>
</ul>
@@ -334,7 +338,7 @@
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The component name
</ol>
@@ -528,15 +532,15 @@
</li>
<li><span class="parameter">druid_instance</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
The parent druid instance
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid context. Usually it is self of script
</li>
<li><span class="parameter">style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid style module
</li>
</ul>
@@ -551,14 +555,41 @@
</dd>
<dt>
<a name = "get_childrens"></a>
<strong>get_childrens(self)</strong>
</dt>
<dd>
Return all children components, recursive
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">BaseComponent</span></span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Array of childrens if the Druid component instance
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
<dl class="function">
<dt>
<a name = "ALL"></a>
<strong>ALL</strong>
<a name = "ON_INPUT"></a>
<strong>ON_INPUT</strong>
</dt>
<dd>
Component Interests
@@ -577,7 +608,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -212,7 +212,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -101,6 +101,10 @@
<td class="name" nowrap><a href="#get_key_trigger">get_key_trigger(self)</a></td>
<td class="summary">Get key-code to trigger this button</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_check_function">set_check_function([check_function[, failure_callback]])</a></td>
<td class="summary">Set function for additional check for button click availability</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
@@ -140,6 +144,10 @@
<td class="summary">Trigger node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#hash">hash</a></td>
<td class="summary">The hash of trigger node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#anim_node">anim_node</a></td>
<td class="summary">Animation node</td>
</tr>
@@ -199,7 +207,7 @@
Button callback
</li>
<li><span class="parameter">params</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Button callback params
(<em>optional</em>)
</li>
@@ -320,7 +328,7 @@
</li>
<li><span class="parameter">key</span>
<span class="types"><span class="type">hash</span></span>
<span class="types"><a class="type" href="../modules/Button.html#hash">hash</a></span>
The action_id of the key
</li>
</ul>
@@ -355,13 +363,46 @@
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">hash</span></span>
<span class="types"><a class="type" href="../modules/Button.html#hash">hash</a></span>
The action_id of the key
</ol>
</dd>
<dt>
<a name = "set_check_function"></a>
<strong>set_check_function([check_function[, failure_callback]])</strong>
</dt>
<dd>
Set function for additional check for button click availability
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">check_function</span>
<span class="types"><span class="type">function</span></span>
Should return true or false. If true - button can be pressed.
(<em>optional</em>)
</li>
<li><span class="parameter">failure_callback</span>
<span class="types"><span class="type">function</span></span>
Function what will be called on button click, if check function return false
(<em>optional</em>)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Button</span></span>
Current button instance
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
@@ -564,6 +605,26 @@
</dd>
<dt>
<a name = "hash"></a>
<strong>hash</strong>
</dt>
<dd>
The hash of trigger node
<ul>
<li><span class="parameter">hash</span>
<span class="types"><a class="type" href="../modules/Button.html#node">node_id</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "anim_node"></a>
@@ -714,7 +775,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -78,11 +78,11 @@
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node, callback[, click_node=node])</a></td>
<td class="name" nowrap><a href="#init">init(self, node, callback[, click_node=node[, initial_state=false]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(self, state, is_silent)</a></td>
<td class="name" nowrap><a href="#set_state">set_state(self, state, is_silent, is_instant)</a></td>
<td class="summary">Set checkbox state</td>
</tr>
<tr>
@@ -126,7 +126,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node, callback[, click_node=node])</strong>
<strong>init(self, node, callback[, click_node=node[, initial_state=false]])</strong>
</dt>
<dd>
Component init function
@@ -151,6 +151,11 @@
Trigger node, by default equals to node
(<em>default</em> node)
</li>
<li><span class="parameter">initial_state</span>
<span class="types"><span class="type">boolean</span></span>
The initial state of checkbox, default - false
(<em>default</em> false)
</li>
</ul>
@@ -160,7 +165,7 @@
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(self, state, is_silent)</strong>
<strong>set_state(self, state, is_silent, is_instant)</strong>
</dt>
<dd>
Set checkbox state
@@ -180,6 +185,10 @@
<span class="types"><span class="type">bool</span></span>
Don't trigger on_change_state if true
</li>
<li><span class="parameter">is_instant</span>
<span class="types"><span class="type">bool</span></span>
If instant checkbox change
</li>
</ul>
@@ -333,7 +342,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -81,7 +81,7 @@
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(self, indexes)</a></td>
<td class="name" nowrap><a href="#set_state">set_state(self, indexes, is_instant)</a></td>
<td class="summary">Set checkbox group state</td>
</tr>
<tr>
@@ -144,7 +144,7 @@
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(self, indexes)</strong>
<strong>set_state(self, indexes, is_instant)</strong>
</dt>
<dd>
Set checkbox group state
@@ -160,6 +160,10 @@
<span class="types"><span class="type">bool[]</span></span>
Array of checkbox state
</li>
<li><span class="parameter">is_instant</span>
<span class="types"><span class="type">boolean</span></span>
If instant state change
</li>
</ul>
@@ -228,7 +232,7 @@
<ul>
<li><span class="parameter">checkboxes</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
</li>
</ul>
@@ -245,7 +249,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -218,7 +218,7 @@
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
The new data array
</li>
</ul>
@@ -333,7 +333,7 @@
</li>
<li><span class="parameter">data</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
</li>
</ul>
@@ -499,7 +499,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -489,7 +489,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -152,7 +152,7 @@
Callback itself
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Additional context as first param to callback call
</li>
</ul>
@@ -181,7 +181,7 @@
Callback itself
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Additional context as first param to callback call
</li>
</ul>
@@ -271,7 +271,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -144,10 +144,18 @@
<td class="summary">Druid on layout change function.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid.on_language_change">druid.on_language_change()</a></td>
<td class="name" nowrap><a href="#druid.on_language_change">druid.on_language_change(self)</a></td>
<td class="summary">Druid on language change.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid.set_whitelist">druid.set_whitelist(self[, whitelist_components=nil])</a></td>
<td class="summary">Set whitelist components for input processing.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#druid.set_blacklist">druid.set_blacklist(self[, blacklist_components=nil])</a></td>
<td class="summary">Set blacklist components for input processing.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#new_button">new_button(self, node, callback[, params[, anim_node]])</a></td>
<td class="summary">Create button basic component</td>
</tr>
@@ -201,7 +209,7 @@
<td class="summary">Create slider component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#new_checkbox">new_checkbox(self, node, callback[, click_node=node])</a></td>
<td class="name" nowrap><a href="#new_checkbox">new_checkbox(self, node, callback[, click_node=node[, initial_state=false]])</a></td>
<td class="summary">Create checkbox component</td>
</tr>
<tr>
@@ -252,11 +260,11 @@
</li>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid context. Usually it is self of script
</li>
<li><span class="parameter">style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid style module
</li>
</ul>
@@ -387,11 +395,17 @@
Action_id from on_input
</li>
<li><span class="parameter">action</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Action from on_input
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
The boolean value is input was consumed
</ol>
@@ -416,7 +430,7 @@
Message_id from on_message
</li>
<li><span class="parameter">message</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Message from on_message
</li>
<li><span class="parameter">sender</span>
@@ -498,7 +512,7 @@
</dd>
<dt>
<a name = "druid.on_language_change"></a>
<strong>druid.on_language_change()</strong>
<strong>druid.on_language_change(self)</strong>
</dt>
<dd>
Druid on language change.
@@ -506,6 +520,69 @@
call manualy to update all translations
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidInstance</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "druid.set_whitelist"></a>
<strong>druid.set_whitelist(self[, whitelist_components=nil])</strong>
</dt>
<dd>
Set whitelist components for input processing.
If whitelist is not empty and component not contains in this list,
component will be not processed on input step
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidInstance</span></span>
</li>
<li><span class="parameter">whitelist_components</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">Component</span></span>
The array of component to whitelist
(<em>default</em> nil)
</li>
</ul>
</dd>
<dt>
<a name = "druid.set_blacklist"></a>
<strong>druid.set_blacklist(self[, blacklist_components=nil])</strong>
</dt>
<dd>
Set blacklist components for input processing.
If blacklist is not empty and component contains in this list,
component will be not processed on input step
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">DruidInstance</span></span>
</li>
<li><span class="parameter">blacklist_components</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a> or <span class="type">Component</span></span>
The array of component to blacklist
(<em>default</em> nil)
</li>
</ul>
@@ -535,7 +612,7 @@
Button callback
</li>
<li><span class="parameter">params</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Button callback params
(<em>optional</em>)
</li>
@@ -678,7 +755,7 @@
Gui text node
</li>
<li><span class="parameter">value</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Initial text. Default value is node text from GUI scene.
(<em>optional</em>)
</li>
@@ -936,7 +1013,7 @@
The text node
</li>
<li><span class="parameter">locale_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Default locale id
</li>
<li><span class="parameter">no_adjust</span>
@@ -998,7 +1075,7 @@
</dd>
<dt>
<a name = "new_checkbox"></a>
<strong>new_checkbox(self, node, callback[, click_node=node])</strong>
<strong>new_checkbox(self, node, callback[, click_node=node[, initial_state=false]])</strong>
</dt>
<dd>
Create checkbox component
@@ -1023,6 +1100,11 @@
Trigger node, by default equals to node
(<em>default</em> node)
</li>
<li><span class="parameter">initial_state</span>
<span class="types"><span class="type">boolean</span></span>
The initial state of checkbox, default - false
(<em>default</em> false)
</li>
</ul>
<h3>Returns:</h3>
@@ -1251,11 +1333,11 @@
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <span class="type">node</span></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <span class="type">node</span></span>
Progress bar fill node or node name
</li>
<li><span class="parameter">key</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Progress bar direction: const.SIDE.X or const.SIDE.Y
</li>
<li><span class="parameter">init_value</span>
@@ -1283,7 +1365,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -85,11 +85,11 @@
<td class="summary">Return pos for grid node index</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(self, node[, index[, shift_policy=SHIFT.RIGHT]])</a></td>
<td class="name" nowrap><a href="#add">add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]])</a></td>
<td class="summary">Add new node to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT])</a></td>
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]])</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
@@ -247,7 +247,7 @@
</dd>
<dt>
<a name = "add"></a>
<strong>add(self, node[, index[, shift_policy=SHIFT.RIGHT]])</strong>
<strong>add(self, node[, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]])</strong>
</dt>
<dd>
Add new node to the grid
@@ -273,6 +273,11 @@
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
<li><span class="parameter">is_instance</span>
<span class="types"><span class="type">boolean</span></span>
If true, update node positions instantly
(<em>default</em> false)
</li>
</ul>
@@ -282,7 +287,7 @@
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT])</strong>
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]])</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
@@ -303,6 +308,11 @@
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
<li><span class="parameter">is_instance</span>
<span class="types"><span class="type">boolean</span></span>
If true, update node positions instantly
(<em>default</em> false)
</li>
</ul>
<h3>Returns:</h3>
@@ -776,7 +786,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -330,7 +330,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -126,7 +126,7 @@
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_unselect">on_input_unselect</a></td>
<td class="summary">On input field unselect callback(self, button_node)</td>
<td class="summary">On input field unselect callback(self, input_text)</td>
</tr>
<tr>
<td class="name" nowrap><a href="#on_input_text">on_input_text</a></td>
@@ -196,7 +196,7 @@
</li>
<li><span class="parameter">input_text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The string to apply for input field
</li>
</ul>
@@ -267,7 +267,7 @@
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The current input field text
</ol>
@@ -324,7 +324,7 @@
</li>
<li><span class="parameter">characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Regulax exp. for validate user input
</li>
</ul>
@@ -383,7 +383,7 @@
(<em>default</em> false)
</li>
<li><span class="parameter">MASK_DEFAULT_CHAR</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Default character mask for password input
(<em>default</em> *)
</li>
@@ -405,7 +405,7 @@
(self, button_node) Callback on wrong user input
</li>
<li><span class="parameter">button_style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Custom button style for input node
</li>
</ul>
@@ -444,7 +444,7 @@
<strong>on_input_unselect</strong>
</dt>
<dd>
On input field unselect callback(self, button_node)
On input field unselect callback(self, input_text)
<ul>
@@ -650,7 +650,7 @@
<ul>
<li><span class="parameter">allowerd_characters</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
(<em>optional</em>)
</li>
@@ -688,7 +688,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -86,9 +86,13 @@
<td class="summary">Setup raw text to lang_text component</td>
</tr>
<tr>
<td class="name" nowrap><a href="#translate">translate(self, locale_id)</a></td>
<td class="name" nowrap><a href="#translate">translate(self, locale_id, ...)</a></td>
<td class="summary">Translate the text by locale_id</td>
</tr>
<tr>
<td class="name" nowrap><a href="#format">format(self, ...)</a></td>
<td class="summary">Format string with new text params on localized text</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
@@ -128,8 +132,8 @@
The text node
</li>
<li><span class="parameter">locale_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
Default locale id, optional
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Default locale id or text from node as default
</li>
<li><span class="parameter">no_adjust</span>
<span class="types"><span class="type">bool</span></span>
@@ -157,11 +161,17 @@
</li>
<li><span class="parameter">text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Text for text node
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">LangText</span></span>
Current instance
</ol>
@@ -169,7 +179,7 @@
</dd>
<dt>
<a name = "translate"></a>
<strong>translate(self, locale_id)</strong>
<strong>translate(self, locale_id, ...)</strong>
</dt>
<dd>
Translate the text by locale_id
@@ -182,11 +192,52 @@
</li>
<li><span class="parameter">locale_id</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Locale id
</li>
<li><span class="parameter">...</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Locale arguments to pass in text function
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">LangText</span></span>
Current instance
</ol>
</dd>
<dt>
<a name = "format"></a>
<strong>format(self, ...)</strong>
</dt>
<dd>
Format string with new text params on localized text
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">LangText</span></span>
</li>
<li><span class="parameter">...</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Locale arguments to pass in text function
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">LangText</span></span>
Current instance
</ol>
@@ -243,7 +294,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -168,11 +168,11 @@
</li>
<li><span class="parameter">node</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a> or <a class="type" href="../modules/Progress.html#node">node</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a> or <a class="type" href="../modules/Progress.html#node">node</a></span>
Progress bar fill node or node name
</li>
<li><span class="parameter">key</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Progress bar direction: const.SIDE.X or const.SIDE.Y
</li>
<li><span class="parameter">init_value</span>
@@ -425,7 +425,7 @@
<ul>
<li><span class="parameter">key</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
</li>
</ul>
@@ -522,7 +522,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -81,7 +81,7 @@
<td class="summary">Component init function</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_state">set_state(self, index)</a></td>
<td class="name" nowrap><a href="#set_state">set_state(self, index, is_instant)</a></td>
<td class="summary">Set radio group state</td>
</tr>
<tr>
@@ -144,7 +144,7 @@
</dd>
<dt>
<a name = "set_state"></a>
<strong>set_state(self, index)</strong>
<strong>set_state(self, index, is_instant)</strong>
</dt>
<dd>
Set radio group state
@@ -160,6 +160,10 @@
<span class="types"><span class="type">number</span></span>
Index in radio group
</li>
<li><span class="parameter">is_instant</span>
<span class="types"><span class="type">boolean</span></span>
If is instant state change
</li>
</ul>
@@ -245,7 +249,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -555,7 +555,7 @@
</li>
<li><span class="parameter">points</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Array of vector3 points
</li>
</ul>
@@ -814,6 +814,11 @@
If true, invert direction for touchpad and mouse wheel scroll
(<em>default</em> false)
</li>
<li><span class="parameter">WHEEL_SCROLL_BY_INERTION</span>
<span class="types"><span class="type">bool</span></span>
If true, wheel will add inertion to scroll. Direct set position otherwise.
(<em>default</em> false)
</li>
</ul>
@@ -1113,7 +1118,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -421,7 +421,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -33,6 +33,7 @@
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
@@ -98,11 +99,11 @@
<td class="summary">Set grid anchor.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#add">add(self, item[, index[, shift_policy=SHIFT.RIGHT]])</a></td>
<td class="name" nowrap><a href="#add">add(self, item[, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]])</a></td>
<td class="summary">Add new item to the grid</td>
</tr>
<tr>
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT])</a></td>
<td class="name" nowrap><a href="#remove">remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]])</a></td>
<td class="summary">Remove the item from the grid.</td>
</tr>
<tr>
@@ -130,6 +131,13 @@
<td class="summary">Return StaticGrid offset, where StaticGrid content starts.</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
<tr>
@@ -343,7 +351,7 @@
</dd>
<dt>
<a name = "add"></a>
<strong>add(self, item[, index[, shift_policy=SHIFT.RIGHT]])</strong>
<strong>add(self, item[, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]]])</strong>
</dt>
<dd>
Add new item to the grid
@@ -369,6 +377,11 @@
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
<li><span class="parameter">is_instance</span>
<span class="types"><span class="type">boolean</span></span>
If true, update node positions instantly
(<em>default</em> false)
</li>
</ul>
@@ -378,7 +391,7 @@
</dd>
<dt>
<a name = "remove"></a>
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT])</strong>
<strong>remove(self, index[, shift_policy=SHIFT.RIGHT[, is_instance=false]])</strong>
</dt>
<dd>
Remove the item from the grid. Note that gui node will be not deleted
@@ -399,6 +412,11 @@
How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT)
</li>
<li><span class="parameter">is_instance</span>
<span class="types"><span class="type">boolean</span></span>
If true, update node positions instantly
(<em>default</em> false)
</li>
</ul>
<h3>Returns:</h3>
@@ -579,6 +597,39 @@
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">IS_DYNAMIC_NODE_POSES</span>
<span class="types"><span class="type">bool</span></span>
If true, always center grid content as grid pivot sets
(<em>default</em> false)
</li>
<li><span class="parameter">IS_ALIGN_LAST_ROW</span>
<span class="types"><span class="type">bool</span></span>
If true, always align last row of the grid as grid pivot sets
(<em>default</em> false)
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
@@ -831,7 +882,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -283,7 +283,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -33,6 +33,7 @@
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>
@@ -79,7 +80,7 @@
<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#init">init(self, node[, value[, no_adjust]])</a></td>
<td class="name" nowrap><a href="#init">init(self, node[, value[, adjust_type=0]])</a></td>
<td class="summary">Component init function</td>
</tr>
<tr>
@@ -110,6 +111,25 @@
<td class="name" nowrap><a href="#is_multiline">is_multiline(self)</a></td>
<td class="summary">Return true, if text with line break</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_text_adjust">set_text_adjust(self[, adjust_type[, minimal_scale]])</a></td>
<td class="summary">Set text adjust, refresh the current text visuals, if needed</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_minimal_scale">set_minimal_scale(self, minimal_scale)</a></td>
<td class="summary">Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_text_adjust">get_text_adjust(self, adjust_type)</a></td>
<td class="summary">Return current text adjust type</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#style">style</a></td>
<td class="summary">Component style params.</td>
</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
@@ -130,6 +150,10 @@
<td class="summary">Text node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#node_id">node_id</a></td>
<td class="summary">The node id of text node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#pos">pos</a></td>
<td class="summary">Current text position</td>
</tr>
@@ -150,7 +174,7 @@
<td class="summary">Current text node available are</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_no_adjust">is_no_adjust</a></td>
<td class="name" nowrap><a href="#adjust_type">adjust_type</a></td>
<td class="summary">Current text size adjust settings</td>
</tr>
<tr>
@@ -168,7 +192,7 @@
<dl class="function">
<dt>
<a name = "init"></a>
<strong>init(self, node[, value[, no_adjust]])</strong>
<strong>init(self, node[, value[, adjust_type=0]])</strong>
</dt>
<dd>
Component init function
@@ -185,14 +209,14 @@
Gui text node
</li>
<li><span class="parameter">value</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Initial text. Default value is node text from GUI scene.
(<em>optional</em>)
</li>
<li><span class="parameter">no_adjust</span>
<span class="types"><span class="type">bool</span></span>
If true, text will be not auto-adjust size
(<em>optional</em>)
<li><span class="parameter">adjust_type</span>
<span class="types"><span class="type">int</span></span>
Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
(<em>default</em> 0)
</li>
</ul>
@@ -216,7 +240,7 @@
</li>
<li><span class="parameter">text</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
(<em>optional</em>)
</li>
@@ -242,11 +266,17 @@
</li>
<li><span class="parameter">set_to</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Text for node
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -272,6 +302,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -297,6 +333,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -322,6 +364,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -332,8 +380,7 @@
<strong>set_pivot(self, pivot)</strong>
</dt>
<dd>
Set text pivot. Text will re-anchor inside
his text area
Set text pivot. Text will re-anchor inside text area
<h3>Parameters:</h3>
@@ -348,6 +395,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -379,6 +432,136 @@
</dd>
<dt>
<a name = "set_text_adjust"></a>
<strong>set_text_adjust(self[, adjust_type[, minimal_scale]])</strong>
</dt>
<dd>
Set text adjust, refresh the current text visuals, if needed
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">adjust_type</span>
<span class="types"><span class="type">number</span></span>
See const.TEXT_ADJUST. If pass nil - use current adjust type
(<em>optional</em>)
</li>
<li><span class="parameter">minimal_scale</span>
<span class="types"><span class="type">number</span></span>
If pass nil - not use minimal scale
(<em>optional</em>)
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
</dd>
<dt>
<a name = "set_minimal_scale"></a>
<strong>set_minimal_scale(self, minimal_scale)</strong>
</dt>
<dd>
Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
<span class="types"><span class="type">Text</span></span>
</li>
<li><span class="parameter">minimal_scale</span>
<span class="types"><span class="type">number</span></span>
If pass nil - not use minimal scale
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
</dd>
<dt>
<a name = "get_text_adjust"></a>
<strong>get_text_adjust(self, adjust_type)</strong>
</dt>
<dd>
Return current text adjust type
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">self</span>
</li>
<li><span class="parameter">adjust_type</span>
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">number</span></span>
The current text adjust type
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
<dl class="function">
<dt>
<a name = "style"></a>
<strong>style</strong>
</dt>
<dd>
Component style params.
You can override this component styles params in druid styles table
or create your own style
<h3>Fields:</h3>
<ul>
<li><span class="parameter">TRIM_POSTFIX</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The postfix for TRIM adjust type
(<em>default</em> ...)
</li>
<li><span class="parameter">DEFAULT_ADJUST</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The default adjust type for any text component
(<em>default</em> DOWNSCALE)
</li>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
@@ -463,6 +646,26 @@
</dd>
<dt>
<a name = "node_id"></a>
<strong>node_id</strong>
</dt>
<dd>
The node id of text node
<ul>
<li><span class="parameter">node_id</span>
<span class="types"><span class="type">hash</span></span>
</li>
</ul>
</dd>
<dt>
<a name = "pos"></a>
@@ -565,16 +768,16 @@
</dd>
<dt>
<a name = "is_no_adjust"></a>
<strong>is_no_adjust</strong>
<a name = "adjust_type"></a>
<strong>adjust_type</strong>
</dt>
<dd>
Current text size adjust settings
<ul>
<li><span class="parameter">is_no_adjust</span>
<span class="types"><span class="type">bool</span></span>
<li><span class="parameter">adjust_type</span>
<span class="types"><span class="type">number</span></span>
</li>
</ul>
@@ -611,7 +814,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -403,7 +403,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -92,6 +92,10 @@
<td class="summary">Check if node is enabled in gui hierarchy.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_closest_stencil_node">get_closest_stencil_node(node)</a></td>
<td class="summary">Return closest non inverted clipping parent node for node</td>
</tr>
<tr>
<td class="name" nowrap><a href="#get_pivot_offset">get_pivot_offset(pivot)</a></td>
<td class="summary">Get node offset for given gui pivot</td>
</tr>
@@ -242,6 +246,33 @@
</dd>
<dt>
<a name = "get_closest_stencil_node"></a>
<strong>get_closest_stencil_node(node)</strong>
</dt>
<dd>
Return closest non inverted clipping parent node for node
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">node</span>
<span class="types"><span class="type">node</span></span>
Gui node
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">node</span> or <span class="type">nil</span></span>
The clipping node
</ol>
</dd>
<dt>
<a name = "get_pivot_offset"></a>
@@ -339,7 +370,7 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">message</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
The deprecated message
</li>
</ul>
@@ -356,7 +387,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -142,11 +142,11 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
module name
</li>
<li><span class="parameter">module</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
lua table with component
</li>
</ul>
@@ -167,11 +167,11 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">context</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid context. Usually it is self of script
</li>
<li><span class="parameter">style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid style module
(<em>optional</em>)
</li>
@@ -199,7 +199,7 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">style</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.6">table</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
Druid style module
</li>
</ul>
@@ -268,7 +268,7 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">event</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.3/manual.html#6.4">string</a></span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Event param from window listener
</li>
</ul>
@@ -314,7 +314,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-04-06 00:03:14 </i>
<i style="float:right;">Last updated 2022-02-12 17:16:44 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -1,10 +1,8 @@
# Druid components
## Button
[Button API here](https://insality.github.io/druid/modules/druid.button.html)
[Button API here](https://insality.github.io/druid/modules/Button.html)
### Overview
Basic Druid input component. Handle input on node and provide different callbacks on touch events.
@@ -36,13 +34,13 @@ _fill example usecases_
## Text
[Text API here](https://insality.github.io/druid/modules/druid.text.html)
[Text API here](https://insality.github.io/druid/modules/Text.html)
### Overview
Basic Druid text component. Text components by default have the text size adjusting.
### Setup
Create text node with druid: `text = druid:new_text(node_name, [initial_value], [is_disable_size_adjust])`
Create text node with druid: `text = druid:new_text(node_name, [initial_value], [text_adjust_type])`
### Notes
- Text component by default have auto adjust text sizing. Text never will be bigger, than text node size, which you can setup in GUI scene. It can be disabled on component creating by settings argument `is_no_adjust` to _true_
@@ -53,9 +51,17 @@ Create text node with druid: `text = druid:new_text(node_name, [initial_value],
![](../media/text_anchor.gif)
- There is several text adjust types. Default Downscale. You can change the default adjust type in the text style table.
- **const.TEXT_ADJUST.DOWNSCALE** - Change text's scale to fit in the text node size
- **const.TEXT_ADJUST.TRIM** - Trim the text with postfix (default - "...", override in styles) to fit in the text node size
- **const.TEXT_ADJUST.NO_ADJUST** - No any adjust, like default Defold text node
- **const.TEXT_ADJUST.DOWNSCALE_LIMITED** - Change text's scale list downscale, but there is limit for text's scale
- **const.TEXT_ADJUST.SCROLL** - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect.
- **const.TEXT_ADJUST.SCALE_THEN_SCROLL** - Combine two modes: first limited downscale, then scroll
## Blocker
[Blocker API here](https://insality.github.io/druid/modules/druid.blocker.html)
[Blocker API here](https://insality.github.io/druid/modules/Blocker.html)
### Overview
Druid component for block input. Use it to block input in special zone.
@@ -75,7 +81,7 @@ So you can do the safe zones, when you have the big buttons
## Back Handler
[Back handler API here](https://insality.github.io/druid/modules/druid.back_handler.html)
[Back handler API here](https://insality.github.io/druid/modules/BackHandler.html)
### Overview
Component to handle back button. It handle Android back button and Backspace key. Key triggers in `input.binding` should be setup for correct working.
@@ -87,7 +93,7 @@ Setup callback with `druid:new_back_handler(callback)`
## Lang text
[Lang text API here](https://insality.github.io/druid/modules/druid.lang_text.html)
[Lang text API here](https://insality.github.io/druid/modules/LangText.html)
### Overview
Wrap on Text component to handle localization. It uses druid get_text_function to set text by it's id
@@ -99,7 +105,7 @@ Create lang text component with druid `text = druid:new_lang_text(node_name, loc
## Scroll
[Scroll API here](https://insality.github.io/druid/modules/druid.scroll.html)
[Scroll API here](https://insality.github.io/druid/modules/Scroll.html)
### Overview
Basic Druid scroll component. Handle all scrolling stuff in druid GUI
@@ -120,7 +126,7 @@ Usually, Place _view_node_ and as children add _content_node_:
*Here content_node below view_node, in game content_node be able to scroll left until end*
### Notes
- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll [style settings](https://insality.github.io/druid/modules/druid.scroll.html#Style)
- Scroll by default style have inertion and extra size for strecthing effect. It can be adjust via scroll [style settings](https://insality.github.io/druid/modules/Scroll.html#Style)
- You can setup "points of interest". Scroll always will be centered on closes point of interest. It is able to create slider without inertion and points of interest on each scroll element.
- Scroll have next events:
- *on_scroll* (self, position) On scroll move callback
@@ -133,7 +139,7 @@ Usually, Place _view_node_ and as children add _content_node_:
## Progress
[Progress API here](https://insality.github.io/druid/modules/druid.progress.html)
[Progress API here](https://insality.github.io/druid/modules/Progress.html)
### Overview
Basic Druid progress bar component
@@ -151,7 +157,7 @@ Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or ju
## Slider
[Slider API here](https://insality.github.io/druid/modules/druid.slider.html)
[Slider API here](https://insality.github.io/druid/modules/Slider.html)
### Overview
Basic Druid slider component
@@ -167,7 +173,7 @@ Pin node (node_name in params) should be placed in zero position (initial). It w
## Input
[Input API here](https://insality.github.io/druid/modules/druid.input.html)
[Input API here](https://insality.github.io/druid/modules/Input.html)
### Overview
Basic Druid text input component
@@ -187,7 +193,7 @@ Create input component with druid: `input = druid:new_input(button_node_name, te
## Checkbox
[Checkbox API here](https://insality.github.io/druid/modules/druid.checkbox.html)
[Checkbox API here](https://insality.github.io/druid/modules/Checkbox.html)
### Overview
Basic Druid checkbox component.
@@ -201,7 +207,7 @@ Create checkbox component with druid: `checkbox = druid:new_checkbox(node, callb
## Checkbox group
[Checkbox group API here](https://insality.github.io/druid/modules/druid.checkbox_group.html)
[Checkbox group API here](https://insality.github.io/druid/modules/CheckboxGroup.html)
### Overview
Several checkboxes in one group
@@ -215,7 +221,7 @@ Create checkbox_group component with druid: `group = druid:new_checkbox_group(no
## Radio group
[Radio group API here](https://insality.github.io/druid/modules/druid.radio_group.html)
[Radio group API here](https://insality.github.io/druid/modules/RadioGroup.html)
### Overview
Several checkboxes in one group with single choice
@@ -230,7 +236,7 @@ Create radio_group component with druid: `group = druid:new_radio_group(nodes[],
## Timer
[Timer API here](https://insality.github.io/druid/modules/druid.timer.html)
[Timer API here](https://insality.github.io/druid/modules/Timer.html)
### Overview
Handle timer work on gui text node
@@ -245,7 +251,7 @@ Create timer component with druid: `timer = druid:new_timer(text_node, from_seco
## Static Grid
[Static Grid API here](https://insality.github.io/druid/modules/druid.static_grid.html)
[Static Grid API here](https://insality.github.io/druid/modules/StaticGrid.html)
### Overview
Component for manage node positions.
@@ -266,7 +272,7 @@ Create component with druid: `grid = druid:new_static_grid(parent_node, prefab_
## Dynamic Grid
[Dynamic Grid API here](https://insality.github.io/druid/modules/druid.dynamic_grid.html)
[Dynamic Grid API here](https://insality.github.io/druid/modules/DynamicGrid.html)
### Overview
Component for manage node positions with different node sizes.
@@ -276,7 +282,7 @@ Dynamic Grid can't have gaps between elements
Dynamic Grid should have __West__, __East__, __South__ or __North__ pivot (vertical or horizontal element placement)
### Setup
Create component with druid: `grid = druid:new_dynamic_grid(parent_node)`
Create component with druid: `grid = druid:new_dynamic_grid(parent_node)`
Check the _parent_node_ have correct pivot point. You will get the error otherwise.
@@ -290,8 +296,34 @@ Check the _parent_node_ have correct pivot point. You will get the error otherwi
- First node placed at Grid pivot point. Other nodes placed nearby of other nodes.
- On *add/remove* nodes always shifted. You can point the shift side in this functions (*is_shift_left* boolean argumentp
## Data List
[Data List API here](https://insality.github.io/druid/modules/DataList.html)
### Overview
Component to manage data for huge dataset in scroll. DataList create elements only in scroll view.
It requires Druid Scroll and Druid Grid (Static or Dynamic) components
### Setup
Create component with druid: `grid = druid:new_data_list(scroll, grid, create_callback)`
- scroll - already created Scroll component
- grid - already created StaticGrid or DynamicGrid component
- create_function - your function to create node instances. This callback have next parameters: fun(self, data, index, data_list)
- self - Script/Druid context
- data- your element data
- index - element index
- data_list - current DataList component
Create function should return root node and optionaly, Druid component. Its required to manage create/remove lifecycle.
### Notes
- Set data with `data_list:set_data({...})` after component initialize
- You can use `data_list:scroll_to_index()` function to show data element
## Hover
[Hover API here](https://insality.github.io/druid/modules/druid.hover.html)
[Hover API here](https://insality.github.io/druid/modules/Hover.html)
### Overview
System Druid component, handle hover node state.
@@ -306,7 +338,7 @@ Create hover component with druid: `hover = druid:new_hover(node, callback)`
## Swipe
[Swipe API here](https://insality.github.io/druid/modules/druid.swipe.html)
[Swipe API here](https://insality.github.io/druid/modules/Swipe.html)
### Overview
System Druid component, handle swipe actions on node
@@ -327,7 +359,7 @@ Create swipe component with druid: `hover = druid:new_swipe(node, swipe_callback
## Drag
[Drag API here](https://insality.github.io/druid/modules/druid.drag.html)
[Drag API here](https://insality.github.io/druid/modules/Drag.html)
### Overview
System Druid component, handle drag actions on node

View File

@@ -19,44 +19,53 @@ local M = component.create("my_component")
function M.init(self, ...)
end
-- Call only if exist interest: component.ON_UPDATE
-- [OPTIONAL] If declared, will call this on script.update function
function M.update(self, dt)
end
-- Call only if exist interest: component.ON_INPUT or component.ON_INPUT_HIGH
-- [OPTIONAL] If declared, will call this on script.on_input function
function M.on_input(self, action_id, action)
end
-- Call on component creation and on component:set_style() function
-- [OPTIONAL] If declared, will call on component creation and on component:set_style() function
function M.on_style_change(self, style)
end
-- Call only if exist interest: component.ON_MESSAGE
-- [OPTIONAL] If declared, will call this on script.on_message function
function M.on_message(self, message_id, message, sender)
end
-- Call only if component with ON_ANGUAGECHANinterest
function M.on_anguagechanself)
-- [OPTIONAL] If declared, will call this on druid.on_language_change call
function M.on_language_change(self)
end
-- Call only if component with ON_LAYOUT_CHANGE interest
-- [OPTIONAL] If declared, will call this on const.ON_MESSAGE_INPUT message to Druid script instance
function M.on_message_input(self, node_id, message)
end
-- [OPTIONAL] If declared, will call this on layout changing
function M.on_layout_change(self)
end
-- Call, if input was capturing before this component
-- [OPTIONAL] If declared, will call this on layout changing, if input was capturing before this component
-- Example: scroll is start scrolling, so you need unhover button
function M.on_input_interrupt(self)
end
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
-- [OPTIONAL] If declared, will call this if game lost focus
function M.on_focus_lost(self)
end
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
-- [OPTIONAL] If declared, will call this if game gained focus
function M.on_focus_gained(self)
end
-- Call on component remove or on druid:final
-- [OPTIONAL] If declared, will call this if late init step (first frame on update)
function M.on_late_init(self)
end
-- [OPTIONAL] If declared, will call this on component remove from Druid instance
function M.on_remove(self)
end
@@ -92,25 +101,6 @@ function init(self)
end
```
### Interest
Interest - is a way to indicate what events your component will respond to.
There is next interests in druid:
- **ON_MESSAGE** - component will receive messages from on_message
- **ON_UPDATE** - component will be updated from update
- **ON_INPUT_HIGH** - component will receive input from on_input, before other components with ON_INPUT
- **ON_INPUT** - component will receive input from on_input, after other components with ON_INPUT_HIGH
- **ON_LANGUAGE_CHANGE** - will call _on_language_change_ function on language change trigger
- **ON_LAYOUT_CHANGE** will call _on_layout_change_ function on layout change trigger
- **ON_FOCUS_LOST** will call _on_focust_lost_ function in on focus lost event. You need to pass window_callback to global `druid:on_window_callback`
- **ON_FOCUS_GAINED** will call _on_focust_gained_ function in on focus gained event. You need to pass window_callback to global `druid:on_window_callback`
## Best practice on custom components
On each component recommended describe component scheme in next way:
@@ -148,4 +138,4 @@ end
## Power of using templates
You can use one component, but creating and customizing templates for them. Templates only requires to match the component scheme.
You can use one component, but creating and customizing templates for them. Templates only requires to match the component scheme.

View File

@@ -136,7 +136,7 @@ Also check _component.template.lua_ what you can use for your own custom compone
Hey! Are you tired from **Druid** updates? _(It's a joke)_
Finally, got a time to release component to process huge amount of data. So introducing: **DataList** component. I can't say what it's "infinity" scroll, but it can help to solve your problem with `GUI nodes limit reached` and helps with scroll optimization. Give feedback about it!
Finally, got a time to release component to process huge amount of data. So introducing: **DataList** component. It can help solve your problem with `GUI nodes limit reached` and helps with scroll optimization. Give feedback about it!
The next important stuff is **EmmyLua** docs. I'm implemented EmmyLua doc generator from LuaDoc and Protofiles, so now you can use EmmyLua annotations inside your IDE instead of website API looking or source code scanning.
@@ -144,11 +144,12 @@ Also the **Druid examples** is reworked, so each example will be in separate col
Input priority got reworked too. Now instead of two input stacks: usual and high, Druid use simple input priority value.
And I should note here is several breaking changes, take a look in changelogs.
And I should note here are several breaking changes, take a look in changelogs.
Wanna something more? [Add an issues!](https://github.com/Insality/druid/issues)
Have a good day.
**Changelog 0.6.0**
---
@@ -183,7 +184,7 @@ Have a good day.
- Lang text now can be initialized without default locale id
- Input component: rename field _selected_ to _is_selected_ (according to the docs)
- **#92** Setup repo for CI and unit tests. (Yea, successful build and tests badges!)
- **#86** Fix a lot of event triggers on scroll inertia moving
- **#86** Fix a lot of event triggers on scroll inertia moving
- **#101** Fix scroll to other node instead of swipe direction with scroll's points of interest (without inert settings)
- **#103** Add `helper.centate_nodes` function. It can horizontal align several Box and Text nodes
- **#105** Add `Input:select` and `Input:unselect` function.
@@ -202,3 +203,115 @@ Have a good day.
- This is basic implementation, it is work not perfect
- **#124** Add `Scroll:set_click_zone` function. This is just link to `Drag:set_click_zone` function inside scroll component.
- **#127** The `druid:create` is deprecated. Use `druid:new` for creating custom components
### Druid 0.7.0:
Hello! Here I'm again with new Druid stuff for you!
The feature I want a long time to deliver for you: the different Text size adjust modes. Druid use the text node sizes to fit the text into this box.
There are new adjust modes such as Trim, Scroll, Downscale with restrictions and Downscale + Scroll. You can change default adjust mode via text style table, but by default there is no changes - it's downscale adjust mode as before.
I'll hope it can be useful for you for in different cases and now it will be much easy to fit all your texts for different languages!
The next features is made for add more control for availability of user input. So meet the whitelists, blacklists and custom check functions for Buttons. Now you can easily choose the more suitable way to enable/disable/restrict input for you users. I'm sure it can be useful for you tutorials.
Another small, but cool feature on my mind is `druid.stencil_check`. If you did interactive elements inside the Scroll, probably you used `component:set_click_zone` to restrict input zone by stencil scroll view node. With this feature, Druid will do it automaticaly for you! You can enable this feature in your `game.project`. It will not override you existing `set_click_zone`.
Now you even able to remap default input keys! Also there are several bugfixes with Scroll, Text, Grids.
Wanna something more? [Add an issues!](https://github.com/Insality/druid/issues)
Good luck!
**Changelog 0.7.0**
---
- **#78** [Text] Update Text component:
- Add text adjust type instead of _no_adjust_ param.
- const.TEXT_ADJUST.DOWNSCALE - Change text's scale to fit in the text node size
- const.TEXT_ADJUST.TRIM - Trim the text with postfix (default - "...", override in styles) to fit in the text node size
- const.TEXT_ADJUST.NO_ADJUST - No any adjust, like default Defold text node
- const.TEXT_ADJUST.DOWNSCALE_LIMITED - Change text's scale list downscale, but there is limit for text's scale
- const.TEXT_ADJUST.SCROLL - Change text's pivot to imitate scrolling in the text box. Use with stencil node for better effect.
- const.TEXT_ADJUST.SCALE_THEN_SCROLL - Combine two modes: first limited downscale, then scroll
- **#110** [Button] Add `Button:set_check_function(check_function, failure_callback)` function to add your custom click condition to button.
- `Button:set_enabled` has more priority than this to check button availability
- The `check_function` should return _true_ of _false_. If true - button can be clicked by user
- The `failure_callback` will be called if `check_function` will return false
- Example with `set_check_function` in general:buttons example collection
- **#66** Add `druid:set_whitelist()` and `druid.set_blacklist()` functions. It's affects only on input process step, you can allow/forbid interact with list of specific components
- You can pass array of components, single component or nil in these functions
- **#111** Add autocheck for input and stencil nodes. To enable this feature, add `druid.stencil_check = 1` to your _game.project_ file.
- This feature is using for auto setup `component:set_click_zone` to restrict clicks outside scrolls zone for example. Now you can don't think about click zone and let Druid do it instead of you!
- Add `helper.get_closest_stencil_node` function to get closest parent of non inverted stencil node
- Add `component.ON_LATE_INIT` interest. Component with this will call `component.on_late_init` function once after component init on update step. This can be used to do something after all gui components are inited
- **#81** Add ability to interact with Druid input via messages:
- Currently add for Button and Text component only:
- Send to _gui.script_ message: `druid_const.ON_MESSAGE_INPUT`. The message table params:
- `node_id` - the name of the node with component on it
- `action` - value from `druid_const.MESSAGE_INPUT`. Available values:
- **BUTTON_CLICK** - usual button click callback
- **BUTTON_LONG_CLICK** - button long click callback
- **BUTTON_DOUBLE_CLICK** - button double click callback
- **BUTTON_REPEATED_CLICK** - button repeated click callback
- **TEXT_SET** - set text for Text component
- `value` - optional field for several actions. For example value is text for **TEXT_SET**
- Add Druid component interest: `component.ON_MESSAGE_INPUT`
- Implement new interest via function `component:on_message_input(node_id, message)`
- See **System: Message input** example
- **#131** [Static Grid] Add style param: `IS_DYNAMIC_NODE_POSES` (default: false). Always align by content size with node anchor.
- If true - Static Grid will by always align to content anchor.
- If false (currently behaviour) - all poses for static grid is predefined and not depends on element's count (see example: static grid and static grid with dynamic poses)
- **#125** Now `component:set_input_priority()` affects on all component's children too
- **#143** Update all lang components on `druid.set_text_function` call
- **#112** Allow remap default Druid input bindings via `game.project`
- **#107** [Text] Better scale text adjust by height for multiline text nodes (but still not perfect)
- **#144** [Scroll] Fix some glitches with scroll Points of Interest. Remove false detection of scroll stopped.
- **#142** [Scroll] Add Scroll style param `WHEEL_SCROLL_BY_INERTION` (default - false). If true - mouse wheel will add inertion to scroll, if false - set position directly per mouse wheel event.
- This fix caused because Mac trackpad seems have additional mouse wheel events for simulate inertion. If you uncomfortable with this, you can disable `WHEEL_SCROLL_BY_INERTION` for more controllable scroll by mouse wheel.
- **#132** Add example with grid add/remove with animations
### Druid 0.8.0
Hello!
In this Druid update no any huge special features. Mostly the bug fixes and reworking the component's interest points. If you used interests in your custom components, you should remove it from `component.create` and all should works as before.
Also added last row allignment in Static Grid component with "dynamic content poses" style enabled. You can look how it is work here: https://insality.github.io/druid/druid/?example=grid_static_grid_dynamic_pos
You can say thanks to me via stars on GitHub 3! :wink:
Wanna something more? [Add an issues!](https://github.com/Insality/druid/issues)
Have a nice day!
**Changelog 0.8.0**
---
- **#160** __[BREAKING]__ Remove component interests list
- The component interests now setup via function declaration inside your components. The functions are still the same.
- Now `component.create` function have next signature: _create(component_name, input_priority)_
- Your should remove interests list from your custom components if exists
- From `component.create("custom", { component.ON_INPUT, component.ON_LATE_INIT }, const.PRIORITY_INPUT_HIGH)` to
`component.create("custom", const.PRIORITY_INPUT_HIGH)`
- **#166** [Input] Fix issue with Cyrillic symbols in range "[А-я]"
- **#162** [Static Grid] Add last row alignment with dynamic content poses enabled
- Add style param: _static_grid.IS_ALIGN_LAST_ROW_, true by default. Works only if _static_grid.IS_DYNAMIC_NODE_POSES_ enabled. See the "Static grid with dynamic poses" example.
- **#163** [Lang Text] Set default locale_id value from text node
- **#147** [Lang Text] Remove `...` from lang_text to fixed arguments, add _format_ function to change only string format arguments
- There are some issues with `...`. Now Lang Text will support up to 7 _string.format_ arguments
- [Lang Text] Add more self chaining to Lang text component (_set_to_, _translate_ and _format_ functions)
- **#151** [Text] Fix text adjust by height
- It still have not perfect fitting, but it's good enough!
- **#164 #150** [Scroll] Fix `scroll:scroll_to_percent` by Y position
- **#148** [Scroll] Remove scroll inertion after scroll `animate` or `set_to` functions
- [Input] Add current text argument to _on_input_unselect_ event
- **#152** [Checkbox] Add _is_instant_ argument to `set_state` function
- Add _initial_state_ argument to Checkbox component constructor
- Update Checkbox style, add _is_instant_ param
- **#149** [Button] Call button style functions after actual callback
- **#153** System: Mode Druid acquire input to late_init step
- Required to solve issues, when go input acquire can be later, when gui input acquire (on init step)
- **#154** System: Change text adjust const to strings
- **#155** Fix: Add margin to total width calculation in `helper.centrate_nodes`

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle back key (android, backspace)
-- @module BackHandler
-- @within BaseComponent
@@ -15,7 +17,7 @@ local Event = require("druid.event")
local const = require("druid.const")
local component = require("druid.component")
local BackHandler = component.create("back_handler", { component.ON_INPUT })
local BackHandler = component.create("back_handler")
--- Component init function

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to block input on specify zone by node
-- @module Blocker
-- @within BaseComponent
@@ -11,7 +13,7 @@
local const = require("druid.const")
local component = require("druid.component")
local Blocker = component.create("blocker", { component.ON_INPUT })
local Blocker = component.create("blocker")
--- Component init function

86
druid/base/button.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle basic GUI button
-- @module Button
-- @within BaseComponent
@@ -24,6 +26,9 @@
---Trigger node
-- @tfield node node
---The hash of trigger node
-- @tfield node_id hash
---Animation node
-- @tfield[opt=node] node anim_node
@@ -52,7 +57,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Button = component.create("button", { component.ON_INPUT })
local Button = component.create("button")
local function is_input_match(self, action_id)
@@ -79,10 +84,9 @@ end
local function on_button_click(self)
self.style.on_click(self, self.anim_node)
self.click_in_row = 1
self.on_click:trigger(self:get_context(), self.params, self)
self.style.on_click(self, self.anim_node)
end
@@ -92,27 +96,24 @@ local function on_button_repeated_click(self)
self.is_repeated_started = true
end
self.style.on_click(self, self.anim_node)
self.click_in_row = self.click_in_row + 1
self.on_repeated_click:trigger(self:get_context(), self.params, self, self.click_in_row)
self.style.on_click(self, self.anim_node)
end
local function on_button_long_click(self)
self.style.on_click(self, self.anim_node)
self.click_in_row = 1
local time = socket.gettime() - self.last_pressed_time
self.on_long_click:trigger(self:get_context(), self.params, self, time)
self.style.on_click(self, self.anim_node)
end
local function on_button_double_click(self)
self.style.on_click(self, self.anim_node)
self.click_in_row = self.click_in_row + 1
self.on_double_click:trigger(self:get_context(), self.params, self, self.click_in_row)
self.style.on_click(self, self.anim_node)
end
@@ -126,7 +127,20 @@ local function on_button_release(self)
return false
end
if not self.disabled then
local check_function_result = true
if self._check_function then
check_function_result = self._check_function(self:get_context())
end
if self.disabled then
self.style.on_click_disabled(self, self.anim_node)
return true
elseif not check_function_result then
if self._failure_callback then
self._failure_callback(self:get_context())
end
return true
else
if self.can_action then
self.can_action = false
@@ -148,9 +162,6 @@ local function on_button_release(self)
self.last_released_time = time
end
return true
else
self.style.on_click_disabled(self, self.anim_node)
return false
end
end
@@ -190,6 +201,7 @@ end
function Button.init(self, node, callback, params, anim_node)
self.druid = self:get_druid()
self.node = self:get_node(node)
self.node_id = gui.get_id(self.node)
self.anim_node = anim_node and self:get_node(anim_node) or self.node
self.start_scale = gui.get_scale(self.anim_node)
@@ -204,6 +216,9 @@ function Button.init(self, node, callback, params, anim_node)
self.click_in_row = 0
self.key_trigger = nil
self._check_function = nil
self._failure_callback = nil
-- Event stubs
self.on_click = Event(callback)
self.on_repeated_click = Event()
@@ -214,6 +229,16 @@ function Button.init(self, node, callback, params, anim_node)
end
function Button.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)
if stencil_node then
self:set_click_zone(stencil_node)
end
end
end
function Button.on_input(self, action_id, action)
if not is_input_match(self, action_id) then
return false
@@ -288,6 +313,31 @@ function Button.on_input_interrupt(self)
end
function Button.on_message_input(self, node_id, message)
if node_id ~= self.node_id or self.disabled or not helper.is_enabled(self.node) then
return false
end
if message.action == const.MESSAGE_INPUT.BUTTON_CLICK then
on_button_click(self)
end
if message.action == const.MESSAGE_INPUT.BUTTON_LONG_CLICK then
on_button_long_click(self)
end
if message.action == const.MESSAGE_INPUT.BUTTON_DOUBLE_CLICK then
on_button_double_click(self)
end
if message.action == const.MESSAGE_INPUT.BUTTON_REPEATED_CLICK then
on_button_repeated_click(self)
self.is_repeated_started = false
self.last_pressed_time = socket.gettime()
end
end
--- Set enabled button component state
-- @tparam Button self
-- @tparam bool state Enabled state
@@ -341,4 +391,14 @@ function Button.get_key_trigger(self)
end
--- Set function for additional check for button click availability
-- @tparam[opt] function check_function Should return true or false. If true - button can be pressed.
-- @tparam[opt] function failure_callback Function what will be called on button click, if check function return false
-- @treturn Button Current button instance
function Button.set_check_function(self, check_function, failure_callback)
self._check_function = check_function
self._failure_callback = failure_callback
end
return Button

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle drag action on node.
-- Drag have correct handling for multitouch and swap
-- touched while dragging. Drag will be processed even
@@ -49,7 +51,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Drag = component.create("drag", { component.ON_INPUT }, const.PRIORITY_INPUT_HIGH)
local Drag = component.create("drag", const.PRIORITY_INPUT_HIGH)
local function start_touch(self, touch)
@@ -187,6 +189,16 @@ function Drag.init(self, node, on_drag_callback)
end
function Drag.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)
if stencil_node then
self:set_click_zone(stencil_node)
end
end
end
function Drag.on_input_interrupt(self)
if self.is_drag or self.is_touch then
end_touch(self)

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle hover node interaction
-- @module Hover
-- @within BaseComponent
@@ -16,7 +18,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Hover = component.create("hover", { component.ON_INPUT })
local Hover = component.create("hover")
--- Component init function
@@ -36,6 +38,16 @@ function Hover.init(self, node, on_hover_callback)
end
function Hover.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)
if stencil_node then
self:set_click_zone(stencil_node)
end
end
end
function Hover.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return false

44
druid/base/scroll.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle scroll content.
-- Scroll consist from two nodes: scroll parent and scroll input
-- Scroll input the user input zone, it's static
@@ -59,7 +61,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Scroll = component.create("scroll", { component.ON_INPUT, component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
local Scroll = component.create("scroll")
local function inverse_lerp(min, max, current)
@@ -106,6 +108,7 @@ end
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
-- @tfield[opt=0] bool WHEEL_SCROLL_SPEED The scroll speed via mouse wheel scroll or touchpad. Set to 0 to disable wheel scrolling
-- @tfield[opt=false] bool WHEEL_SCROLL_INVERTED If true, invert direction for touchpad and mouse wheel scroll
-- @tfield[opt=false] bool WHEEL_SCROLL_BY_INERTION If true, wheel will add inertion to scroll. Direct set position otherwise.
function Scroll.on_style_change(self, style)
self.style = {}
self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0
@@ -121,6 +124,7 @@ function Scroll.on_style_change(self, style)
self.style.SMALL_CONTENT_SCROLL = style.SMALL_CONTENT_SCROLL or false
self.style.WHEEL_SCROLL_SPEED = style.WHEEL_SCROLL_SPEED or 0
self.style.WHEEL_SCROLL_INVERTED = style.WHEEL_SCROLL_INVERTED or false
self.style.WHEEL_SCROLL_BY_INERTION = style.WHEEL_SCROLL_BY_INERTION or false
self._is_inert = not (self.style.FRICT == 0 or
self.style.FRICT_HOLD == 0 or
@@ -170,6 +174,16 @@ function Scroll.init(self, view_node, content_node)
end
function Scroll.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)
if stencil_node then
self:set_click_zone(stencil_node)
end
end
end
function Scroll.on_layout_change(self)
gui.set_position(self.content_node, self.position)
end
@@ -263,7 +277,7 @@ function Scroll.scroll_to_percent(self, percent, is_instant)
local pos = vmath.vector3(
-helper.lerp(border.x, border.z, 1 - percent.x),
-helper.lerp(border.w, border.y, 1 - percent.y),
helper.lerp(border.y, border.w, 1 - percent.y),
0
)
@@ -512,6 +526,9 @@ end
--- Cancel animation on other animation or input touch
function Scroll._cancel_animate(self)
self.inertion.x = 0
self.inertion.y = 0
if self.is_animate then
self.target_position = gui.get_position(self.content_node)
self.position.x = self.target_position.x
@@ -597,11 +614,11 @@ end
function Scroll._check_threshold(self)
local is_stopped = false
if math.abs(self.inertion.x) < self.style.INERT_THRESHOLD then
if self.drag.can_x and math.abs(self.inertion.x) < self.style.INERT_THRESHOLD then
is_stopped = true
self.inertion.x = 0
end
if math.abs(self.inertion.y) < self.style.INERT_THRESHOLD then
if self.drag.can_y and math.abs(self.inertion.y) < self.style.INERT_THRESHOLD then
is_stopped = true
self.inertion.y = 0
end
@@ -736,15 +753,28 @@ function Scroll._process_scroll_wheel(self, action_id, action)
return false
end
local koef = (action_id == const.ACTION_SCROLL_UP) and 1 or -1
if self.style.WHEEL_SCROLL_INVERTED then
koef = -koef
end
if self.drag.can_y then
self.inertion.y = (self.inertion.y + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD
if self.style.WHEEL_SCROLL_BY_INERTION then
if self.drag.can_y then
self.inertion.y = (self.inertion.y + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD
elseif self.drag.can_x then
self.inertion.x = (self.inertion.x + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD
end
else
self.inertion.x = (self.inertion.x + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD
if self.drag.can_y then
self.target_position.y = self.target_position.y + self.style.WHEEL_SCROLL_SPEED * koef
self.inertion.y = 0
elseif self.drag.can_x then
self.target_position.x = self.target_position.x + self.style.WHEEL_SCROLL_SPEED * koef
self.inertion.x = 0
end
self:_set_scroll_position(self.target_position)
end
return true

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle placing components by row and columns.
-- Grid can anchor your elements, get content size and other
-- @module StaticGrid
@@ -47,7 +49,7 @@ local Event = require("druid.event")
local helper = require("druid.helper")
local component = require("druid.component")
local StaticGrid = component.create("static_grid", { component.ON_LAYOUT_CHANGE })
local StaticGrid = component.create("static_grid")
local function _extend_border(border, pos, size, pivot)
@@ -63,6 +65,19 @@ local function _extend_border(border, pos, size, pivot)
end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table style
-- @tfield[opt=false] bool IS_DYNAMIC_NODE_POSES If true, always center grid content as grid pivot sets
-- @tfield[opt=false] bool IS_ALIGN_LAST_ROW If true, always align last row of the grid as grid pivot sets
function StaticGrid.on_style_change(self, style)
self.style = {}
self.style.IS_DYNAMIC_NODE_POSES = style.IS_DYNAMIC_NODE_POSES or false
self.style.IS_ALIGN_LAST_ROW = style.IS_ALIGN_LAST_ROW or false
end
--- Component init function
-- @tparam StaticGrid self
-- @tparam node parent The gui node parent, where items will be placed
@@ -109,7 +124,9 @@ function StaticGrid.get_pos(self, index)
local row = math.ceil(index / self.in_row) - 1
local col = (index - row * self.in_row) - 1
_temp_pos.x = col * self.node_size.x + self._zero_offset.x
local zero_offset_x = self:_get_zero_offset_x(row)
_temp_pos.x = col * self.node_size.x + zero_offset_x
_temp_pos.y = -row * self.node_size.y + self._zero_offset.y
_temp_pos.z = 0
@@ -167,7 +184,8 @@ end
-- @tparam node item Gui node
-- @tparam[opt] number index The item position. By default add as last item
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
function StaticGrid.add(self, item, index, shift_policy)
-- @tparam[opt=false] boolean is_instance If true, update node positions instantly
function StaticGrid.add(self, item, index, shift_policy, is_instant)
shift_policy = shift_policy or const.SHIFT.RIGHT
index = index or ((self.last_index or 0) + 1)
@@ -191,9 +209,9 @@ function StaticGrid.add(self, item, index, shift_policy)
self:_update_indexes()
self:_update_borders()
gui.set_position(item, self:get_pos(index))
gui.set_position(item, self:get_pos(index) + self:_get_zero_offset())
self:_update_pos()
self:_update_pos(is_instant)
self.on_add_item:trigger(self:get_context(), item, index)
self.on_change_items:trigger(self:get_context(), index)
@@ -204,8 +222,9 @@ end
-- @tparam StaticGrid self
-- @tparam number index The grid node index to remove
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
-- @tparam[opt=false] boolean is_instance If true, update node positions instantly
-- @treturn Node The deleted gui node from grid
function StaticGrid.remove(self, index, shift_policy)
function StaticGrid.remove(self, index, shift_policy, is_instant)
shift_policy = shift_policy or const.SHIFT.RIGHT
assert(self.nodes[index], "No grid item at given index " .. index)
@@ -223,7 +242,7 @@ function StaticGrid.remove(self, index, shift_policy)
end
end
self:_update()
self:_update(is_instant)
self.on_remove_item:trigger(self:get_context(), index)
self.on_change_items:trigger(self:get_context(), index)
@@ -385,8 +404,12 @@ end
-- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local
function StaticGrid._update_pos(self, is_instant)
local zero_offset = self:_get_zero_offset()
for i, node in pairs(self.nodes) do
local pos = self:get_pos(i)
pos.x = pos.x + zero_offset.x
pos.y = pos.y + zero_offset.y
if is_instant then
gui.set_position(node, pos)
@@ -399,4 +422,46 @@ function StaticGrid._update_pos(self, is_instant)
end
--- Return elements offset for correct posing nodes. Correct posing at
-- parent pivot node (0:0) with adjusting of node sizes and anchoring
-- @function static_grid:_get_zero_offset
-- @treturn vector3 The offset vector
-- @local
function StaticGrid:_get_zero_offset()
if not self.style.IS_DYNAMIC_NODE_POSES then
return const.VECTOR_ZERO
end
-- zero offset: center pos - border size * anchor
return vmath.vector3(
-((self.border.x + self.border.z)/2 + (self.border.z - self.border.x) * self.pivot.x),
-((self.border.y + self.border.w)/2 + (self.border.y - self.border.w) * self.pivot.y),
0
)
end
--- Return offset x for last row in grid. Used to align this row accorting to grid's anchor
-- @function static:_grid:_get_zero_offset_x
-- @treturn number The offset x value
-- @local
function StaticGrid:_get_zero_offset_x(row_index)
if not self.style.IS_DYNAMIC_NODE_POSES or not self.style.IS_ALIGN_LAST_ROW then
return self._zero_offset.x
end
local offset_x = self._zero_offset.x
local last_row = math.ceil(self.last_index / self.in_row) - 1
if last_row > 0 and last_row == row_index then
local elements_in_row = (self.last_index - (last_row * self.in_row)) - 1
local offset = elements_in_row * self.node_size.x * self.anchor.x
offset_x = self.node_size.x * self.node_pivot.x - self.node_size.x * self.pivot.x - offset
end
return offset_x
end
return StaticGrid

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle swipe gestures on node.
-- Swipe will be triggered, if swipe was started and
-- ended on one node
@@ -21,7 +23,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Swipe = component.create("swipe", { component.ON_INPUT })
local Swipe = component.create("swipe")
local function start_swipe(self, action)
@@ -97,6 +99,16 @@ function Swipe.init(self, node, on_swipe_callback)
end
function Swipe.on_late_init(self)
if not self.click_zone and const.IS_STENCIL_CHECK then
local stencil_node = helper.get_closest_stencil_node(self.node)
if stencil_node then
self:set_click_zone(stencil_node)
end
end
end
function Swipe.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then
return false

179
druid/base/text.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle all GUI texts.
-- Druid text can adjust itself for text node size
-- Text will never will be outside of his text size (even multiline)
@@ -17,6 +19,9 @@
--- Text node
-- @tfield node node
--- The node id of text node
-- @tfield hash node_id
--- Current text position
-- @tfield vector3 pos
@@ -33,7 +38,7 @@
-- @tfield vector3 text_area
--- Current text size adjust settings
-- @tfield bool is_no_adjust
-- @tfield number adjust_type
--- Current text color
-- @tfield vector3 color
@@ -42,9 +47,10 @@
local Event = require("druid.event")
local const = require("druid.const")
local utf8 = require("druid.system.utf8")
local component = require("druid.component")
local Text = component.create("text", { component.ON_LAYOUT_CHANGE })
local Text = component.create("text")
local function update_text_size(self)
@@ -57,24 +63,37 @@ local function update_text_size(self)
end
--- Setup scale x, but can only be smaller, than start text scale
local function update_text_area_size(self)
--- Reset initial scale for text
local function reset_default_scale(self)
gui.set_scale(self.node, self.start_scale)
gui.set_size(self.node, self.start_size)
end
--- Setup scale x, but can only be smaller, than start text scale
local function update_text_area_size(self)
reset_default_scale(self)
local max_width = self.text_area.x
local max_height = self.text_area.y
local metrics = gui.get_text_metrics_from_node(self.node)
local cur_scale = gui.get_scale(self.node)
local scale_modifier = max_width / metrics.width
scale_modifier = math.min(scale_modifier, self.start_scale.x)
local scale_modifier_height = max_height / metrics.height
scale_modifier = math.min(scale_modifier, scale_modifier_height)
if self:is_multiline() then
local max_text_area_square = max_width * max_height
local cur_text_area_square = metrics.height * metrics.width * self.start_scale.x
scale_modifier = self.start_scale.x * math.sqrt(max_text_area_square / cur_text_area_square)
scale_modifier = math.min(scale_modifier, self.start_scale.x)
end
local new_scale = vmath.vector3(scale_modifier, scale_modifier, cur_scale.z)
if self._minimal_scale then
scale_modifier = math.max(scale_modifier, self._minimal_scale)
end
local new_scale = vmath.vector3(scale_modifier, scale_modifier, self.start_scale.z)
gui.set_scale(self.node, new_scale)
self.scale = new_scale
@@ -84,6 +103,33 @@ local function update_text_area_size(self)
end
local function update_text_with_trim(self, trim_postfix)
local max_width = self.text_area.x
local text_width = self:get_text_width()
if text_width > max_width then
local text_length = utf8.len(self.last_value)
local new_text = self.last_value
while text_width > max_width do
text_length = text_length - 1
new_text = utf8.sub(self.last_value, 1, text_length)
text_width = self:get_text_width(new_text .. trim_postfix)
end
gui.set_text(self.node, new_text .. trim_postfix)
end
end
local function update_text_with_anchor_shift(self)
if self:get_text_width() >= self.text_area.x then
self:set_pivot(const.REVERSE_PIVOTS[self.start_pivot])
else
self:set_pivot(self.start_pivot)
end
end
-- calculate space width with font
local function get_space_width(self, font)
if not self._space_width[font] then
@@ -96,15 +142,59 @@ local function get_space_width(self, font)
end
local function update_adjust(self)
if not self.adjust_type or self.adjust_type == const.TEXT_ADJUST.NO_ADJUST then
reset_default_scale(self)
return
end
if self.adjust_type == const.TEXT_ADJUST.DOWNSCALE then
update_text_area_size(self)
end
if self.adjust_type == const.TEXT_ADJUST.TRIM then
update_text_with_trim(self, self.style.TRIM_POSTFIX)
end
if self.adjust_type == const.TEXT_ADJUST.DOWNSCALE_LIMITED then
update_text_area_size(self)
end
if self.adjust_type == const.TEXT_ADJUST.SCROLL then
update_text_with_anchor_shift(self)
end
if self.adjust_type == const.TEXT_ADJUST.SCALE_THEN_SCROLL then
update_text_area_size(self)
update_text_with_anchor_shift(self)
end
end
--- Component style params.
-- You can override this component styles params in druid styles table
-- or create your own style
-- @table style
-- @tfield[opt=...] string TRIM_POSTFIX The postfix for TRIM adjust type
-- @tfield[opt=DOWNSCALE] string DEFAULT_ADJUST The default adjust type for any text component
function Text.on_style_change(self, style)
self.style = {}
self.style.TRIM_POSTFIX = style.TRIM_POSTFIX or "..."
self.style.DEFAULT_ADJUST = style.DEFAULT_ADJUST or const.TEXT_ADJUST.DOWNSCALE
end
--- Component init function
-- @tparam Text self
-- @tparam node node Gui text node
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene.
-- @tparam[opt] bool no_adjust If true, text will be not auto-adjust size
function Text.init(self, node, value, no_adjust)
-- @tparam[opt=0] int adjust_type Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
function Text.init(self, node, value, adjust_type)
self.node = self:get_node(node)
self.pos = gui.get_position(self.node)
self.node_id = gui.get_id(self.node)
self.start_pivot = gui.get_pivot(self.node)
self.start_scale = gui.get_scale(self.node)
self.scale = gui.get_scale(self.node)
@@ -113,7 +203,7 @@ function Text.init(self, node, value, no_adjust)
self.text_area.x = self.text_area.x * self.start_scale.x
self.text_area.y = self.text_area.y * self.start_scale.y
self.is_no_adjust = no_adjust
self.adjust_type = adjust_type or self.style.DEFAULT_ADJUST
self.color = gui.get_color(self.node)
self.on_set_text = Event()
@@ -132,6 +222,17 @@ function Text.on_layout_change(self)
end
function Text.on_message_input(self, node_id, message)
if node_id ~= self.node_id then
return false
end
if message.action == const.MESSAGE_INPUT.TEXT_SET then
Text.set_to(self, message.value)
end
end
--- Calculate text width with font with respect to trailing space
-- @tparam Text self
-- @tparam[opt] string text
@@ -156,49 +257,61 @@ end
--- Set text to text field
-- @tparam Text self
-- @tparam string set_to Text for node
-- @treturn Text Current text instance
function Text.set_to(self, set_to)
set_to = set_to or ""
self.last_value = set_to
gui.set_text(self.node, set_to)
self.on_set_text:trigger(self:get_context(), set_to)
if not self.is_no_adjust then
update_text_area_size(self)
end
update_adjust(self)
return self
end
--- Set color
-- @tparam Text self
-- @tparam vector4 color Color for node
-- @treturn Text Current text instance
function Text.set_color(self, color)
self.color = color
gui.set_color(self.node, color)
return self
end
--- Set alpha
-- @tparam Text self
-- @tparam number alpha Alpha for node
-- @treturn Text Current text instance
function Text.set_alpha(self, alpha)
self.color.w = alpha
gui.set_color(self.node, self.color)
return self
end
--- Set scale
-- @tparam Text self
-- @tparam vector3 scale Scale for node
-- @treturn Text Current text instance
function Text.set_scale(self, scale)
self.last_scale = scale
gui.set_scale(self.node, scale)
return self
end
--- Set text pivot. Text will re-anchor inside
-- his text area
--- Set text pivot. Text will re-anchor inside text area
-- @tparam Text self
-- @tparam gui.pivot pivot Gui pivot constant
-- @treturn Text Current text instance
function Text.set_pivot(self, pivot)
local prev_pivot = gui.get_pivot(self.node)
local prev_offset = const.PIVOTS[prev_pivot]
@@ -216,6 +329,8 @@ function Text.set_pivot(self, pivot)
gui.set_position(self.node, self.pos)
self.on_set_pivot:trigger(self:get_context(), pivot)
return self
end
@@ -227,4 +342,36 @@ function Text.is_multiline(self)
end
--- Set text adjust, refresh the current text visuals, if needed
-- @tparam Text self
-- @tparam[opt] number adjust_type See const.TEXT_ADJUST. If pass nil - use current adjust type
-- @tparam[opt] number minimal_scale If pass nil - not use minimal scale
-- @treturn Text Current text instance
function Text.set_text_adjust(self, adjust_type, minimal_scale)
self.adjust_type = adjust_type
self._minimal_scale = minimal_scale
self:set_to(self.last_value)
return self
end
--- Set minimal scale for DOWNSCALE_LIMITED or SCALE_THEN_SCROLL adjust types
-- @tparam Text self
-- @tparam number minimal_scale If pass nil - not use minimal scale
-- @treturn Text Current text instance
function Text.set_minimal_scale(self, minimal_scale)
self._minimal_scale = minimal_scale
return self
end
--- Return current text adjust type
-- @treturn number The current text adjust type
function Text.get_text_adjust(self, adjust_type)
return self.adjust_type
end
return Text

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Basic class for all Druid components.
-- To create you component, use `component.create`
-- @module BaseComponent
@@ -12,39 +14,37 @@ local BaseComponent = class("druid.component")
--- Component Interests
BaseComponent.ALL = const.ALL
BaseComponent.ON_INPUT = const.ON_INPUT
BaseComponent.ON_UPDATE = const.ON_UPDATE
BaseComponent.ON_MESSAGE = const.ON_MESSAGE
BaseComponent.ON_LATE_INIT = const.ON_LATE_INIT
BaseComponent.ON_FOCUS_LOST = const.ON_FOCUS_LOST
BaseComponent.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED
BaseComponent.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE
BaseComponent.ON_MESSAGE_INPUT = const.ON_MESSAGE_INPUT
BaseComponent.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE
BaseComponent.ALL_INTERESTS = {
BaseComponent.ALL,
BaseComponent.ON_INPUT,
BaseComponent.ON_UPDATE,
BaseComponent.ON_MESSAGE,
BaseComponent.ON_LATE_INIT,
BaseComponent.ON_FOCUS_LOST,
BaseComponent.ON_FOCUS_GAINED,
BaseComponent.ON_LAYOUT_CHANGE,
BaseComponent.ON_MESSAGE_INPUT,
BaseComponent.ON_LANGUAGE_CHANGE,
}
-- Value is method name of component
-- Mapping from on_message method to specific method name
BaseComponent.SPECIFIC_UI_MESSAGES = {
[BaseComponent.ON_FOCUS_LOST] = "on_focus_lost",
[BaseComponent.ON_FOCUS_GAINED] = "on_focus_gained",
[BaseComponent.ON_LAYOUT_CHANGE] = "on_layout_change",
[BaseComponent.ON_LANGUAGE_CHANGE] = "on_language_change",
}
BaseComponent.UI_INPUT = {
[BaseComponent.ON_INPUT] = true
[hash(BaseComponent.ON_FOCUS_LOST)] = "on_focus_lost",
[hash(BaseComponent.ON_FOCUS_GAINED)] = "on_focus_gained",
[hash(BaseComponent.ON_LAYOUT_CHANGE)] = "on_layout_change",
[hash(BaseComponent.ON_MESSAGE_INPUT)] = "on_message_input",
[hash(BaseComponent.ON_LANGUAGE_CHANGE)] = "on_language_change",
}
@@ -169,6 +169,11 @@ function BaseComponent.set_input_priority(self, value)
if self._component.input_priority ~= value then
self._component.input_priority = value
self._component._is_input_priority_changed = true
local children = self:get_childrens()
for i = 1, #children do
children[i]:set_input_priority(value)
end
end
return self
@@ -255,15 +260,11 @@ end
-- by `BaseComponent.static.create`
-- @tparam BaseComponent self
-- @tparam string name BaseComponent name
-- @tparam[opt={}] table interest List of component's interest
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
-- @local
function BaseComponent.initialize(self, name, interest, input_priority)
interest = interest or {}
function BaseComponent.initialize(self, name, input_priority)
self._component = {
name = name,
interest = interest,
input_priority = input_priority or const.PRIORITY_INPUT,
default_input_priority = input_priority or const.PRIORITY_INPUT,
_is_input_priority_changed = true, -- Default true for sort once time after GUI init
@@ -307,7 +308,15 @@ end
-- @treturn table List of component interests
-- @local
function BaseComponent.__get_interests(self)
return self._component.interest
local interests = {}
for index = 1, #BaseComponent.ALL_INTERESTS do
local interest = BaseComponent.ALL_INTERESTS[index]
if self[interest] and type(self[interest]) == "function" then
table.insert(interests, interest)
end
end
return interests
end
@@ -351,18 +360,37 @@ function BaseComponent.__remove_children(self, children)
end
--- Return all children components, recursive
-- @tparam BaseComponent self
-- @treturn table Array of childrens if the Druid component instance
function BaseComponent.get_childrens(self)
local childrens = {}
for i = 1, #self._meta.children do
local children = self._meta.children[i]
table.insert(childrens, children)
local recursive_childrens = children:get_childrens()
for j = 1, #recursive_childrens do
table.insert(childrens, recursive_childrens[j])
end
end
return childrens
end
--- Create new component. It will inheritance from basic
-- druid component.
-- @tparam string name BaseComponent name
-- @tparam[opt={}] table interest List of component's interest
-- @tparam[opt=DEFAULT] number input_priority The input priority. The bigger number processed first
-- @local
function BaseComponent.static.create(name, interest, input_priority)
function BaseComponent.static.create(name, input_priority)
-- Yea, inheritance here
local new_class = class(name, BaseComponent)
new_class.initialize = function(self)
BaseComponent.initialize(self, name, interest, input_priority)
BaseComponent.initialize(self, name, input_priority)
end
return new_class

76
druid/const.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid constants
-- @local
-- @module DruidConst
@@ -5,18 +7,21 @@
local M = {}
M.ACTION_TEXT = hash("text")
M.ACTION_MARKED_TEXT = hash("marked_text")
M.ACTION_TEXT = hash(sys.get_config("druid.input_text", "text"))
M.ACTION_TOUCH = hash(sys.get_config("druid.input_touch", "touch"))
M.ACTION_MARKED_TEXT = hash(sys.get_config("druid.input_marked_text", "marked_text"))
M.ACTION_BACKSPACE = hash("key_backspace")
M.ACTION_ENTER = hash("key_enter")
M.ACTION_BACK = hash("key_back")
M.ACTION_ESC = hash("key_esc")
M.ACTION_ESC = hash(sys.get_config("druid.input_key_esc", "key_esc"))
M.ACTION_BACK = hash(sys.get_config("druid.input_key_back", "key_back"))
M.ACTION_ENTER = hash(sys.get_config("druid.input_key_enter", "key_enter"))
M.ACTION_MULTITOUCH = hash(sys.get_config("druid.input_multitouch", "multitouch"))
M.ACTION_BACKSPACE = hash(sys.get_config("druid.input_key_backspace", "key_backspace"))
M.ACTION_TOUCH = hash("touch")
M.ACTION_SCROLL_UP = hash("scroll_up")
M.ACTION_MULTITOUCH = hash("multitouch")
M.ACTION_SCROLL_DOWN = hash("scroll_down")
M.ACTION_SCROLL_UP = hash(sys.get_config("druid.input_scroll_up", "scroll_up"))
M.ACTION_SCROLL_DOWN = hash(sys.get_config("druid.input_scroll_down", "scroll_down"))
M.IS_STENCIL_CHECK = sys.get_config("druid.stencil_check") == "1"
M.RELEASED = "released"
@@ -27,14 +32,15 @@ M.ZERO = "0"
--- Component Interests
M.ALL = "all"
M.ON_INPUT = hash("on_input")
M.ON_UPDATE = hash("on_update")
M.ON_MESSAGE = hash("on_message")
M.ON_FOCUS_LOST = hash("on_focus_lost")
M.ON_FOCUS_GAINED = hash("on_focus_gained")
M.ON_LAYOUT_CHANGE = hash("layout_changed")
M.ON_LANGUAGE_CHANGE = hash("on_language_change")
M.ON_INPUT = "on_input"
M.ON_UPDATE = "update"
M.ON_MESSAGE = "on_message"
M.ON_LATE_INIT = "on_late_init"
M.ON_FOCUS_LOST = "on_focus_lost"
M.ON_FOCUS_GAINED = "on_focus_gained"
M.ON_LAYOUT_CHANGE = "on_layout_changed"
M.ON_MESSAGE_INPUT = "on_message_input"
M.ON_LANGUAGE_CHANGE = "on_language_change"
M.PRIORITY_INPUT = 10
@@ -42,6 +48,16 @@ M.PRIORITY_INPUT_HIGH = 20
M.PRIORITY_INPUT_MAX = 100
M.MESSAGE_INPUT = {
BUTTON_CLICK = "button_click",
BUTTON_LONG_CLICK = "button_long_click",
BUTTON_DOUBLE_CLICK = "button_double_click",
BUTTON_REPEATED_CLICK = "button_repeated_click",
-- (value)
TEXT_SET = "text_set",
}
M.PIVOTS = {
[gui.PIVOT_CENTER] = vmath.vector3(0),
[gui.PIVOT_N] = vmath.vector3(0, 0.5, 0),
@@ -54,7 +70,21 @@ M.PIVOTS = {
[gui.PIVOT_NW] = vmath.vector3(-0.5, 0.5, 0),
}
M.REVERSE_PIVOTS = {
[gui.PIVOT_CENTER] = gui.PIVOT_CENTER,
[gui.PIVOT_N] = gui.PIVOT_S,
[gui.PIVOT_NE] = gui.PIVOT_SW,
[gui.PIVOT_E] = gui.PIVOT_W,
[gui.PIVOT_SE] = gui.PIVOT_NW,
[gui.PIVOT_S] = gui.PIVOT_N,
[gui.PIVOT_SW] = gui.PIVOT_NE,
[gui.PIVOT_W] = gui.PIVOT_E,
[gui.PIVOT_NW] = gui.PIVOT_SE,
}
M.VECTOR_ZERO = vmath.vector3(0)
M.VECTOR_ONE = vmath.vector3(1)
M.SYS_INFO = sys.get_sys_info()
M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name
@@ -76,6 +106,16 @@ M.SHIFT = {
}
M.TEXT_ADJUST = {
DOWNSCALE = "downscale",
TRIM = "trim",
NO_ADJUST = "no_adjust",
DOWNSCALE_LIMITED = "downscale_limited",
SCROLL = "scroll",
SCALE_THEN_SCROLL = "scale_then_scroll",
}
M.SIDE = {
X = "x",
Y = "y"

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid UI Library.
-- Powerful Defold component based UI library. Use standart
-- components or make your own game-specific components to
@@ -83,8 +85,7 @@ end
-- @tparam function callback Get localized text function
function M.set_text_function(callback)
settings.get_text = callback or const.EMPTY_FUNCTION
-- TODO: Update all localized text
-- Need to store all current druid instances to iterate over it?
M.on_language_change()
end

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Lua event small library
-- @module DruidEvent
-- @alias druid_event

16
druid/extended/checkbox.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid checkbox component
-- @module Checkbox
-- @within BaseComponent
@@ -20,7 +22,7 @@
local Event = require("druid.event")
local component = require("druid.component")
local Checkbox = component.create("checkbox", { component.ON_LAYOUT_CHANGE })
local Checkbox = component.create("checkbox")
local function on_click(self)
@@ -47,13 +49,14 @@ end
-- @tparam node node Gui node
-- @tparam function callback Checkbox callback
-- @tparam[opt=node] node click_node Trigger node, by default equals to node
function Checkbox.init(self, node, callback, click_node)
-- @tparam[opt=false] boolean initial_state The initial state of checkbox, default - false
function Checkbox.init(self, node, callback, click_node, initial_state)
self.druid = self:get_druid()
self.node = self:get_node(node)
self.click_node = self:get_node(click_node)
self.button = self.druid:new_button(self.click_node or self.node, on_click)
self:set_state(false, true)
self:set_state(initial_state, true, true)
self.on_change_state = Event(callback)
end
@@ -68,13 +71,16 @@ end
-- @tparam Checkbox self
-- @tparam bool state Checkbox state
-- @tparam bool is_silent Don't trigger on_change_state if true
function Checkbox.set_state(self, state, is_silent)
-- @tparam bool is_instant If instant checkbox change
function Checkbox.set_state(self, state, is_silent, is_instant)
self.state = state
self.style.on_change_state(self, self.node, state)
self.style.on_change_state(self, self.node, state, is_instant)
if not is_silent then
self.on_change_state:trigger(self:get_context(), state)
end
return self
end

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Checkbox group module
-- @module CheckboxGroup
-- @within BaseComponent
@@ -42,10 +44,11 @@ end
--- Set checkbox group state
-- @tparam CheckboxGroup self
-- @tparam bool[] indexes Array of checkbox state
function CheckboxGroup.set_state(self, indexes)
-- @tparam boolean is_instant If instant state change
function CheckboxGroup.set_state(self, indexes, is_instant)
for i = 1, #indexes do
if self.checkboxes[i] then
self.checkboxes[i]:set_state(indexes[i], true)
self.checkboxes[i]:set_state(indexes[i], true, is_instant)
end
end
end

View File

@@ -1,9 +1,11 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid component template
-- @module druid.component
-- @local
local component = require("druid.component")
local Component = component.create("my_component_name", { component.ON_UPDATE })
local Component = component.create("my_component_name")
-- Component constructor
@@ -11,54 +13,54 @@ function Component:init(...)
end
-- Call only if exist interest: component.ON_UPDATE
-- [OPTIONAL] Call every update step
function Component:update(dt)
end
-- Call only if exist interest: component.ON_INPUT
-- [OPTIONAL] Call default on_input from gui script
function Component:on_input(action_id, action)
return false
end
-- Call on component creation and on component:set_style() function
-- [OPTIONAL] Call on component creation and on component:set_style() function
function Component:on_style_change(style)
end
-- Call only if exist interest: component.ON_MESSAGE
-- [OPTIONAL] Call default on_message from gui script
function Component:on_message(message_id, message, sender)
end
-- Call only if component with ON_LANGUAGE_CHANGE interest
-- [OPTIONAL] Call if druid has triggered on_language_change
function Component:on_language_change()
end
-- Call only if component with ON_LAYOUT_CHANGE interest
-- [OPTIONAL] Call if game layout has changed and need to restore values in component
function Component:on_layout_change()
end
-- Call, if input was capturing before this component
-- [OPTIONAL] Call, if input was capturing before this component
-- Example: scroll is start scrolling, so you need unhover button
function Component:on_input_interrupt()
end
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
-- [OPTIONAL] Call, if game lost focus
function Component:on_focus_lost()
end
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
-- [OPTIONAL] Call, if game gained focus
function Component:on_focus_gained()
end
-- Call on component remove or on druid:final
-- [OPTIONAL] Call on component remove or on druid:final
function Component:on_remove()
end

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to manage data for huge dataset in scroll.
-- It requires Druid Scroll and Druid Grid (Static or Dynamic) components
-- @module DataList

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle placing components in row
-- @module DynamicGrid
-- @within BaseComponent
@@ -43,7 +45,7 @@ local Event = require("druid.event")
local helper = require("druid.helper")
local component = require("druid.component")
local DynamicGrid = component.create("dynamic_grid", { component.ON_LAYOUT_CHANGE })
local DynamicGrid = component.create("dynamic_grid")
local SIDE_VECTORS = {
@@ -138,7 +140,8 @@ end
-- @tparam node node Gui node
-- @tparam[opt] number index The node position. By default add as last node
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
function DynamicGrid.add(self, node, index, shift_policy)
-- @tparam[opt=false] boolean is_instance If true, update node positions instantly
function DynamicGrid.add(self, node, index, shift_policy, is_instant)
shift_policy = shift_policy or const.SHIFT.RIGHT
local delta = shift_policy -- -1 or 1 or 0
@@ -168,7 +171,7 @@ function DynamicGrid.add(self, node, index, shift_policy)
end
-- Sync grid data
self:_update()
self:_update(is_instant)
self.on_add_item:trigger(self:get_context(), node, index)
self.on_change_items:trigger(self:get_context(), index)
@@ -179,8 +182,9 @@ end
-- @tparam DynamicGrid self
-- @tparam number index The grid node index to remove
-- @tparam[opt=SHIFT.RIGHT] number shift_policy How shift nodes, if required. See const.SHIFT
-- @tparam[opt=false] boolean is_instance If true, update node positions instantly
-- @treturn Node The deleted gui node from grid
function DynamicGrid.remove(self, index, shift_policy)
function DynamicGrid.remove(self, index, shift_policy, is_instant)
shift_policy = shift_policy or const.SHIFT.RIGHT
local delta = shift_policy -- -1 or 1 or 0
@@ -202,7 +206,7 @@ function DynamicGrid.remove(self, index, shift_policy)
end
-- Sync grid data
self:_update()
self:_update(is_instant)
self.on_remove_item:trigger(self:get_context(), index)
self.on_change_items:trigger(self:get_context(), index)

12
druid/extended/input.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid input text component.
-- Carry on user text input
-- @author Part of code from Britzl gooey input component
@@ -8,7 +10,7 @@
--- On input field select callback(self, button_node)
-- @tfield druid_event on_input_select
--- On input field unselect callback(self, button_node)
--- On input field unselect callback(self, input_text)
-- @tfield druid_event on_input_unselect
--- On input field text change callback(self, input_text)
@@ -51,7 +53,7 @@ local const = require("druid.const")
local component = require("druid.component")
local utf8 = require("druid.system.utf8")
local Input = component.create("input", { component.ON_INPUT, component.ON_FOCUS_LOST })
local Input = component.create("input")
--- Mask text by replacing every character with a mask character
@@ -164,8 +166,8 @@ function Input.on_input(self, action_id, action)
end)
-- ignore arrow keys
if not string.match(hex, "EF9C8[0-3]") then
if not self.allowed_characters or action.text:match(self.allowed_characters) then
if not utf8.match(hex, "EF9C8[0-3]") then
if not self.allowed_characters or utf8.match(action.text, self.allowed_characters) then
input_text = self.value .. action.text
if self.max_length then
input_text = utf8.sub(input_text, 1, self.max_length)
@@ -305,7 +307,7 @@ function Input.unselect(self)
self.is_selected = false
gui.hide_keyboard()
self.on_input_unselect:trigger(self:get_context())
self.on_input_unselect:trigger(self:get_context(), self:get_text())
self.style.on_unselect(self, self.button.node)
end

35
druid/extended/lang_text.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle all GUI texts
-- Good working with localization system
-- @module LangText
@@ -16,24 +18,23 @@ local Event = require("druid.event")
local settings = require("druid.system.settings")
local component = require("druid.component")
local LangText = component.create("lang_text", { component.ON_LANGUAGE_CHANGE })
local LangText = component.create("lang_text")
--- Component init function
-- @tparam LangText self
-- @tparam node node The text node
-- @tparam string locale_id Default locale id, optional
-- @tparam string locale_id Default locale id or text from node as default
-- @tparam bool no_adjust If true, will not correct text size
function LangText.init(self, node, locale_id, no_adjust)
self.druid = self:get_druid()
self.text = self.druid:new_text(node, locale_id, no_adjust)
self.node = self.text.node
self.last_locale_args = {}
self.on_change = Event()
if locale_id then
self:translate(locale_id)
end
self:translate(locale_id or gui.get_text(self.node))
return self
end
@@ -49,21 +50,39 @@ end
--- Setup raw text to lang_text component
-- @tparam LangText self
-- @tparam string text Text for text node
-- @treturn LangText Current instance
function LangText.set_to(self, text)
self.last_locale = false
self.text:set_to(text)
self.on_change:trigger()
return self
end
--- Translate the text by locale_id
-- @tparam LangText self
-- @tparam string locale_id Locale id
function LangText.translate(self, locale_id, ...)
self.last_locale_args = {...}
-- @tparam string ... Locale arguments to pass in text function
-- @treturn LangText Current instance
function LangText.translate(self, locale_id, a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }
self.last_locale = locale_id or self.last_locale
self.text:set_to(settings.get_text(self.last_locale, ...) or "")
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
return self
end
--- Format string with new text params on localized text
-- @tparam LangText self
-- @tparam string ... Locale arguments to pass in text function
-- @treturn LangText Current instance
function LangText.format(self, a, b, c, d, e, f, g)
self.last_locale_args = { a, b, c, d, e, f, g }
self.text:set_to(settings.get_text(self.last_locale, a, b, c, d, e, f, g) or "")
return self
end
return LangText

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Basic progress bar component.
-- For correct progress bar init it should be in max size from gui
-- @module Progress
@@ -32,7 +34,7 @@ local const = require("druid.const")
local helper = require("druid.helper")
local component = require("druid.component")
local Progress = component.create("progress", { component.ON_UPDATE, component.ON_LAYOUT_CHANGE })
local Progress = component.create("progress")
local function check_steps(self, from, to, exactly)

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Radio group module
-- @module RadioGroup
-- @within BaseComponent
@@ -17,9 +19,9 @@ local component = require("druid.component")
local RadioGroup = component.create("radio_group")
local function on_checkbox_click(self, index)
local function on_checkbox_click(self, index, is_instant)
for i = 1, #self.checkboxes do
self.checkboxes[i]:set_state(i == index, true)
self.checkboxes[i]:set_state(i == index, true, is_instant)
end
self.on_radio_click:trigger(self:get_context(), index)
@@ -51,8 +53,9 @@ end
--- Set radio group state
-- @tparam RadioGroup self
-- @tparam number index Index in radio group
function RadioGroup.set_state(self, index)
on_checkbox_click(self, index)
-- @tparam boolean is_instant If is instant state change
function RadioGroup.set_state(self, index, is_instant)
on_checkbox_click(self, index, is_instant)
end

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid slider component
-- @module Slider
-- @within BaseComponent
@@ -38,7 +40,7 @@ local helper = require("druid.helper")
local const = require("druid.const")
local component = require("druid.component")
local Slider = component.create("slider", { component.ON_INPUT, component.ON_LAYOUT_CHANGE }, const.PRIORITY_INPUT_HIGH)
local Slider = component.create("slider", const.PRIORITY_INPUT_HIGH)
local function on_change_value(self)

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Component to handle GUI timers.
-- Timer updating by game delta time. If game is not focused -
-- timer will be not updated.
@@ -33,7 +35,7 @@ local formats = require("druid.helper.formats")
local helper = require("druid.helper")
local component = require("druid.component")
local Timer = component.create("timer", { component.ON_UPDATE })
local Timer = component.create("timer")
--- Component init function

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
-- Druid helper module for gui layouts
-- @module helper
@@ -74,6 +76,7 @@ function M.centrate_nodes(margin, ...)
node_widths[i] = get_width(node)
width = width + node_widths[i]
end
width = width + margin * (count - 1)
-- Posing all elements
local pos_x = 0
@@ -169,6 +172,32 @@ function M.is_enabled(node)
end
--- Return closest non inverted clipping parent node for node
-- @function helper.get_closest_stencil_node
-- @tparam node node Gui node
-- @treturn node|nil The clipping node
function M.get_closest_stencil_node(node)
if not node then
return nil
end
local parent = gui.get_parent(node)
while parent do
local clipping_mode = gui.get_clipping_mode(parent)
local is_clipping_normal = not gui.get_clipping_inverted(parent)
if is_clipping_normal and clipping_mode == gui.CLIPPING_MODE_STENCIL then
return parent
end
parent = gui.get_parent(parent)
end
return nil
end
--- Get node offset for given gui pivot
-- @function helper.get_pivot_offset
-- @tparam gui.pivot pivot The node pivot

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid inner module to acquire/release input
-- @module helper.input
-- @local

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid module with utils on string formats
-- @local
-- @module helper.formats
@@ -42,4 +44,4 @@ function M.interpolate_string(s, tab)
end
return M
return M

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
local M = {}

View File

@@ -1,3 +1,6 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
local const = require("druid.const")
local settings = require("druid.system.settings")
local anims = require("druid.styles.default.anims")
@@ -56,6 +59,12 @@ M["drag"] = {
}
M["static_grid"] = {
IS_DYNAMIC_NODE_POSES = false, -- Always align by content size with node anchor
IS_ALIGN_LAST_ROW = true, -- Align the last row of grid
}
M["scroll"] = {
ANIM_SPEED = 0.2, -- gui.animation speed to point
BACK_SPEED = 0.35, -- Lerp speed of return to soft position
@@ -65,8 +74,9 @@ M["scroll"] = {
INERT_SPEED = 30, -- koef. of inert speed
EXTRA_STRETCH_SIZE = 100, -- extra size in pixels outside of scroll (stretch effect)
POINTS_DEADZONE = 20, -- Speed to check points of interests in no_inertion mode
WHEEL_SCROLL_SPEED = 0,
WHEEL_SCROLL_INVERTED = false,
WHEEL_SCROLL_SPEED = 0, -- Amount of pixels to scroll by one wheel event (0 to disable)
WHEEL_SCROLL_INVERTED = false, -- Boolean to invert wheel scroll side
WHEEL_SCROLL_BY_INERTION = false, -- If true, wheel will add inertion to scroll. Direct set position otherwise.
SMALL_CONTENT_SCROLL = true, -- If true, content node with size less than view node size can be scrolled
}
@@ -78,9 +88,15 @@ M["progress"] = {
M["checkbox"] = {
on_change_state = function(self, node, state)
on_change_state = function(self, node, state, is_instant)
local target = state and 1 or 0
gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1)
if not is_instant then
gui.animate(node, "color.w", target, gui.EASING_OUTSINE, 0.1)
else
local color = gui.get_color(node)
color.w = target
gui.set_color(node, color)
end
end
}
@@ -125,4 +141,10 @@ M["input"] = {
}
M["text"] = {
TRIM_POSTFIX = "...",
DEFAULT_ADJUST = const.TEXT_ADJUST.DOWNSCALE
}
return M

View File

@@ -1 +1,3 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
return {}

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
local M = {}

170
druid/system/druid_instance.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Instance of Druid. Make one instance per gui_script with next code:
--
-- local druid = require("druid.druid")
@@ -61,7 +63,7 @@ local DruidInstance = class("druid.druid_instance")
local function input_init(self)
if sys.get_config("druid.no_auto_input") == "1" then
if self._no_auto_input then
return
end
@@ -73,7 +75,7 @@ end
local function input_release(self)
if sys.get_config("druid.no_auto_input") == "1" then
if self._no_auto_input then
return
end
@@ -85,7 +87,7 @@ end
local function sort_input_stack(self)
local input_components = self.components[base_component.ON_INPUT]
local input_components = self.components_interest[base_component.ON_INPUT]
if not input_components then
return
end
@@ -105,16 +107,12 @@ local function create(self, instance_class)
local instance = instance_class()
instance:setup_component(self, self._context, self._style)
table.insert(self.components[base_component.ALL], instance)
table.insert(self.components_all, instance)
local register_to = instance:__get_interests()
for i = 1, #register_to do
local interest = register_to[i]
table.insert(self.components[interest], instance)
if base_component.UI_INPUT[interest] then
input_init(self)
end
table.insert(self.components_interest[interest], instance)
end
return instance
@@ -132,8 +130,8 @@ local function check_sort_input_stack(self, components)
local component = components[i]
if component:_is_input_priority_changed() then
is_need_sort_input_stack = true
component:_reset_input_priority_changed()
end
component:_reset_input_priority_changed()
end
if is_need_sort_input_stack then
@@ -142,7 +140,35 @@ local function check_sort_input_stack(self, components)
end
local function process_input(action_id, action, components, is_input_consumed)
--- Check whitelists and blacklists for input components
local function can_use_input_component(self, component)
local can_by_whitelist = true
local can_by_blacklist = true
if self._input_whitelist and #self._input_whitelist > 0 then
if helper.contains(self._input_whitelist, component) then
can_by_whitelist = true
else
can_by_whitelist = false
end
end
if self._input_blacklist and #self._input_blacklist > 0 then
if helper.contains(self._input_blacklist, component) then
can_by_blacklist = false
else
can_by_blacklist = true
end
end
return can_by_blacklist and can_by_whitelist
end
local function process_input(self, action_id, action, components)
local is_input_consumed = false
if #components == 0 then
return is_input_consumed
end
@@ -150,7 +176,7 @@ local function process_input(action_id, action, components, is_input_consumed)
for i = #components, 1, -1 do
local component = components[i]
local meta = component._meta
if meta.input_enabled then
if meta.input_enabled and can_use_input_component(self, component) then
if not is_input_consumed then
is_input_consumed = component:on_input(action_id, action)
else
@@ -177,9 +203,14 @@ function DruidInstance.initialize(self, context, style)
self._late_remove = {}
self.url = msg.url()
self.components = {}
self._input_blacklist = nil
self._input_whitelist = nil
self._no_auto_input = (sys.get_config("druid.no_auto_input") == "1")
self.components_interest = {}
self.components_all = {}
for i = 1, #base_component.ALL_INTERESTS do
self.components[base_component.ALL_INTERESTS[i]] = {}
self.components_interest[base_component.ALL_INTERESTS[i]] = {}
end
end
@@ -192,13 +223,7 @@ end
function DruidInstance.create(self, component, ...)
helper.deprecated("The druid:create is deprecated. Please use druid:new instead")
local instance = create(self, component)
if instance.init then
instance:init(...)
end
return instance
return DruidInstance.new(self, component, ...)
end
@@ -221,7 +246,7 @@ end
-- on all druid components
-- @tparam DruidInstance self
function DruidInstance.final(self)
local components = self.components[base_component.ALL]
local components = self.components_all
for i = #components, 1, -1 do
if components[i].on_remove then
@@ -256,7 +281,7 @@ function DruidInstance.remove(self, component)
end
component._meta.children = {}
local all_components = self.components[base_component.ALL]
local all_components = self.components_all
for i = #all_components, 1, -1 do
if all_components[i] == component then
if component.on_remove then
@@ -269,7 +294,7 @@ function DruidInstance.remove(self, component)
local interests = component:__get_interests()
for i = 1, #interests do
local interest = interests[i]
local components = self.components[interest]
local components = self.components_interest[interest]
for j = #components, 1, -1 do
if components[j] == component then
table.remove(components, j)
@@ -283,7 +308,18 @@ end
-- @tparam DruidInstance self
-- @tparam number dt Delta time
function DruidInstance.update(self, dt)
local components = self.components[base_component.ON_UPDATE]
local late_init_components = self.components_interest[base_component.ON_LATE_INIT]
while late_init_components[1] do
late_init_components[1]:on_late_init()
table.remove(late_init_components, 1)
end
if not self.input_inited and #self.components_interest[base_component.ON_INPUT] > 0 then
-- Input init on late init step, to be sure it goes after user go acquire input
input_init(self)
end
local components = self.components_interest[base_component.ON_UPDATE]
for i = 1, #components do
components[i]:update(dt)
end
@@ -294,13 +330,13 @@ end
-- @tparam DruidInstance self
-- @tparam hash action_id Action_id from on_input
-- @tparam table action Action from on_input
-- @treturn bool The boolean value is input was consumed
function DruidInstance.on_input(self, action_id, action)
self._is_input_processing = true
local is_input_consumed = false
local components = self.components[base_component.ON_INPUT]
local components = self.components_interest[base_component.ON_INPUT]
check_sort_input_stack(self, components)
is_input_consumed = process_input(action_id, action, components, is_input_consumed)
local is_input_consumed = process_input(self, action_id, action, components)
self._is_input_processing = false
@@ -321,10 +357,22 @@ end
-- @tparam table message Message from on_message
-- @tparam hash sender Sender from on_message
function DruidInstance.on_message(self, message_id, message, sender)
-- TODO: refactor for more juicy code
local specific_ui_message = base_component.SPECIFIC_UI_MESSAGES[message_id]
local on_message_input_message = base_component.ON_MESSAGE_INPUT
if specific_ui_message then
local components = self.components[message_id]
if specific_ui_message == on_message_input_message then
local components = self.components_interest[base_component.ON_MESSAGE_INPUT]
if components then
for i = 1, #components do
local component = components[i]
if can_use_input_component(self, component) then
component[specific_ui_message](component, hash(message.node_id), message)
end
end
end
elseif specific_ui_message then
local components = self.components_interest[specific_ui_message]
if components then
for i = 1, #components do
local component = components[i]
@@ -332,7 +380,7 @@ function DruidInstance.on_message(self, message_id, message, sender)
end
end
else
local components = self.components[base_component.ON_MESSAGE]
local components = self.components_interest[base_component.ON_MESSAGE]
for i = 1, #components do
components[i]:on_message(message_id, message, sender)
end
@@ -344,7 +392,7 @@ end
-- This one called by on_window_callback by global window listener
-- @tparam DruidInstance self
function DruidInstance.on_focus_lost(self)
local components = self.components[base_component.ON_FOCUS_LOST]
local components = self.components_interest[base_component.ON_FOCUS_LOST]
for i = 1, #components do
components[i]:on_focus_lost()
end
@@ -355,7 +403,7 @@ end
-- This one called by on_window_callback by global window listener
-- @tparam DruidInstance self
function DruidInstance.on_focus_gained(self)
local components = self.components[base_component.ON_FOCUS_GAINED]
local components = self.components_interest[base_component.ON_FOCUS_GAINED]
for i = 1, #components do
components[i]:on_focus_gained()
end
@@ -366,7 +414,7 @@ end
-- Called on update gui layout
-- @tparam DruidInstance self
function DruidInstance.on_layout_change(self)
local components = self.components[base_component.ON_LAYOUT_CHANGE]
local components = self.components_interest[base_component.ON_LAYOUT_CHANGE]
for i = 1, #components do
components[i]:on_layout_change()
end
@@ -376,15 +424,62 @@ end
--- Druid on language change.
-- This one called by global gruid.on_language_change, but can be
-- call manualy to update all translations
-- @tparam DruidInstance self
-- @function druid.on_language_change
function DruidInstance.on_language_change(self)
local components = self.components[base_component.ON_LANGUAGE_CHANGE]
local components = self.components_interest[base_component.ON_LANGUAGE_CHANGE]
for i = 1, #components do
components[i]:on_language_change()
end
end
--- Set whitelist components for input processing.
-- If whitelist is not empty and component not contains in this list,
-- component will be not processed on input step
-- @tparam DruidInstance self
-- @tparam[opt=nil] table|Component whitelist_components The array of component to whitelist
-- @function druid.set_whitelist
function DruidInstance.set_whitelist(self, whitelist_components)
if whitelist_components and whitelist_components.isInstanceOf then
whitelist_components = { whitelist_components }
end
for i = 1, #whitelist_components do
local component = whitelist_components[i]
local childrens = component:get_childrens()
for j = 1, #childrens do
table.insert(whitelist_components, childrens[j])
end
end
self._input_whitelist = whitelist_components
end
--- Set blacklist components for input processing.
-- If blacklist is not empty and component contains in this list,
-- component will be not processed on input step
-- @tparam DruidInstance self
-- @tparam[opt=nil] table|Component blacklist_components The array of component to blacklist
-- @function druid.set_blacklist
function DruidInstance.set_blacklist(self, blacklist_components)
if blacklist_components and blacklist_components.isInstanceOf then
blacklist_components = { blacklist_components }
end
for i = 1, #blacklist_components do
local component = blacklist_components[i]
local childrens = component:get_childrens()
for j = 1, #childrens do
table.insert(blacklist_components, childrens[j])
end
end
self._input_blacklist = blacklist_components
end
--- Create button basic component
-- @tparam DruidInstance self
-- @tparam node node Gui node
@@ -530,10 +625,11 @@ end
-- @tparam node node Gui node
-- @tparam function callback Checkbox callback
-- @tparam[opt=node] node click_node Trigger node, by default equals to node
-- @tparam[opt=false] boolean initial_state The initial state of checkbox, default - false
-- @treturn Checkbox checkbox component
function DruidInstance.new_checkbox(self, node, callback, click_node)
function DruidInstance.new_checkbox(self, node, callback, click_node, initial_state)
-- return helper.extended_component("checkbox")
return DruidInstance.new(self, checkbox, node, callback, click_node)
return DruidInstance.new(self, checkbox, node, callback, click_node, initial_state)
end

4
druid/system/settings.lua Normal file → Executable file
View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid settings file
-- @module settings
-- @local
@@ -7,7 +9,7 @@ local M = {}
M.default_style = nil
function M.get_text(name, ...)
function M.get_text(name, a, b, c, d, e, f)
return "[Druid]: locales not inited"
end

View File

@@ -1,4 +1,4 @@
--- @license MIT, Insality 2020
--- @license MIT, Insality 2021
--- @source https://github.com/Insality/druid
local M = {}

View File

@@ -1,4 +1,4 @@
# @license MIT, Insality 2020
# @license MIT, Insality 2021
# @source https://github.com/Insality/druid
import sys

View File

@@ -1,5 +1,5 @@
#!/bin/bash
# @license MIT, Insality 2020
# @license MIT, Insality 2021
# @source https://github.com/Insality/druid
echo "Run bash for $1"

View File

@@ -240,7 +240,7 @@ embedded_instances {
}
}
embedded_instances {
id: "general_texts"
id: "texts_general"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.script\"\n"
@@ -257,7 +257,7 @@ embedded_instances {
" }\n"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"general_texts\"\n"
" value: \"texts_general\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
@@ -269,7 +269,7 @@ embedded_instances {
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/general/texts/texts.collection\\\"\\n"
" data: \"prototype: \\\"/example/examples/texts/texts_general/texts_general.collection\\\"\\n"
"load_dynamically: false\\n"
"\"\n"
" position {\n"
@@ -869,3 +869,381 @@ embedded_instances {
z: 1.0
}
}
embedded_instances {
id: "grid_static_grid"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"grid_static_grid\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/grid/static_grid/static_grid.collection\\\"\\n"
"load_dynamically: 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
}
}
embedded_instances {
id: "grid_animations"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"grid_animations\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/grid/grid_animations/grid_animations.collection\\\"\\n"
"load_dynamically: 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
}
}
embedded_instances {
id: "grid_static_grid_dynamic_pos"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"grid_static_grid_dynamic_pos\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/grid/static_grid_dynamic_pos/static_grid_dynamic_pos.collection\\\"\\n"
"load_dynamically: 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
}
}
embedded_instances {
id: "system_whitelist_blacklist"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"system_whitelist_blacklist\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/system/whitelist_blacklist/whitelist_blacklist.collection\\\"\\n"
"load_dynamically: 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
}
}
embedded_instances {
id: "texts_adjust"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"texts_adjust\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/texts/texts_adjust/texts_adjust.collection\\\"\\n"
"load_dynamically: 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
}
}
embedded_instances {
id: "system_message_input"
data: "components {\n"
" id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.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"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"system_message_input\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
" properties {\n"
" id: \"popup\"\n"
" value: \"true\"\n"
" type: PROPERTY_TYPE_BOOLEAN\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionfactory\"\n"
" type: \"collectionfactory\"\n"
" data: \"prototype: \\\"/example/examples/system/message_input/message_input.collection\\\"\\n"
"load_dynamically: 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
}
}

View File

@@ -745,7 +745,7 @@ nodes {
}
nodes {
position {
x: -230.0
x: -240.0
y: -35.0
z: 0.0
w: 1.0
@@ -910,7 +910,7 @@ nodes {
}
nodes {
position {
x: 230.0
x: 240.0
y: -35.0
z: 0.0
w: 1.0
@@ -1093,7 +1093,7 @@ nodes {
w: 1.0
}
size {
x: 300.0
x: 360.0
y: 45.0
z: 0.0
w: 1.0

View File

@@ -17,6 +17,8 @@ end
local function show_scene(self, scene_name, text_header)
print("Show scene:", scene_name)
monarch.show(scene_name)
gui.set_enabled(gui.get_node("C_Anchor"), false)
gui.set_enabled(self.button_menu.node, true)
@@ -36,6 +38,10 @@ local function init_top_panel(self)
sys.open_url("https://insality.github.io/druid/")
end)
-- self.button_code = self.druid:new_button("button_code/button", function()
-- sys.open_url("https://github.com/Insality/druid/blob/develop/example/examples/general/overview/overview.gui_script")
-- end)
self.text_header = self.druid:new_text("text_header", "Druid")
end
@@ -60,6 +66,9 @@ local function get_button(self, text, scene_name)
local nodes = gui.clone_tree(prefab)
local root = nodes["prefab_button"]
gui.set_enabled(root, true)
self.scene_names[scene_name] = text
self.druid:new_button(root, function()
show_scene(self, scene_name, text)
end):set_click_zone(self.lobby_scroll.view_node)
@@ -84,6 +93,7 @@ end
local function init_lobby(self)
gui.set_enabled(gui.get_node("prefabs"), false)
self.scene_names = {}
self.lobby_scroll = self.druid:new_scroll("lobby_view", "lobby_content")
self.lobby_grid = self.druid:new_dynamic_grid("lobby_content")
@@ -92,8 +102,6 @@ local function init_lobby(self)
self.lobby_grid:add(get_title(self, "General examples"))
self.lobby_grid:add(get_button(self, "Overview", "general_overview"))
self.lobby_grid:add(get_button(self, "Buttons", "general_buttons"))
self.lobby_grid:add(get_button(self, "Texts", "general_texts"))
self.lobby_grid:add(get_button_disabled(self, "Lang Text", "scene_name"))
self.lobby_grid:add(get_button(self, "Sliders", "general_sliders"))
self.lobby_grid:add(get_button(self, "Scrolls", "general_scroll"))
self.lobby_grid:add(get_button(self, "Grids", "general_grid"))
@@ -104,15 +112,22 @@ local function init_lobby(self)
self.lobby_grid:add(get_button_disabled(self, "Swipe", "scene_name"))
self.lobby_grid:add(get_button_disabled(self, "Drag", "scene_name"))
self.lobby_grid:add(get_title(self, "Texts"))
self.lobby_grid:add(get_button(self, "Texts", "texts_general"))
self.lobby_grid:add(get_button(self, "Adjust types", "texts_adjust"))
self.lobby_grid:add(get_button_disabled(self, "Lang Text", "texts_lang_text"))
self.lobby_grid:add(get_title(self, "Scrolls"))
self.lobby_grid:add(get_button_disabled(self, "Nested scrolls", "scroll_scene"))
self.lobby_grid:add(get_button_disabled(self, "With points of interest", "scroll_scene"))
self.lobby_grid:add(get_button_disabled(self, "Without inertion", "scroll_scene"))
self.lobby_grid:add(get_title(self, "Grids"))
self.lobby_grid:add(get_button_disabled(self, "Static grid", "scroll_scene"))
self.lobby_grid:add(get_button(self, "Static grid", "grid_static_grid"))
self.lobby_grid:add(get_button(self, "Static with dynamic pos", "grid_static_grid_dynamic_pos"))
self.lobby_grid:add(get_button_disabled(self, "Dynamic grid", "scroll_scene"))
self.lobby_grid:add(get_button_disabled(self, "Scroll binding", "scroll_scene"))
self.lobby_grid:add(get_button(self, "Add/Remove animations", "grid_animations"))
self.lobby_grid:add(get_title(self, "Data list / Infinity scroll"))
self.lobby_grid:add(get_button(self, "With static grid", "data_list_static_grid"))
@@ -122,13 +137,27 @@ local function init_lobby(self)
self.lobby_grid:add(get_title(self, "System"))
self.lobby_grid:add(get_button_disabled(self, "Styles"))
self.lobby_grid:add(get_button(self, "Whitelist / Blacklist", "system_whitelist_blacklist"))
self.lobby_grid:add(get_button_disabled(self, "Custom components"))
self.lobby_grid:add(get_button_disabled(self, "Component interests"))
self.lobby_grid:add(get_button_disabled(self, "Nested Druids"))
self.lobby_grid:add(get_button(self, "Message input", "system_message_input"))
self.lobby_grid:add(get_button_disabled(self, "Input priority"))
end
local function check_url(self)
if not html5 then
return
end
local example_arg = html5.run("new URLSearchParams(window.location.search).get('example')")
if example_arg and self.scene_names[example_arg] then
print("Start example: ", example_arg)
show_scene(self, example_arg, self.scene_names[example_arg] or "unknown")
end
end
function init(self)
-- Main lobby have more render priority (top panel)
gui.set_render_order(10)
@@ -139,6 +168,8 @@ function init(self)
init_top_panel(self)
init_lobby(self)
timer.delay(0, false, check_url)
end

View File

@@ -1304,6 +1304,293 @@ nodes {
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 200.0
y: 80.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_custom_check"
parent: "root"
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: 130.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "button_custom_check/button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_custom_check"
layer: "image"
inherit_alpha: true
slice9 {
x: 15.0
y: 15.0
z: 15.0
w: 15.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 7.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.6
y: 0.6
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: "Check func"
font: "game"
id: "button_custom_check/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 0.101960786
y: 0.2
z: 0.6
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "button_custom_check/button"
layer: "text"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 3
overridden_fields: 8
overridden_fields: 18
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 200.0
y: 180.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.5
y: 0.5
z: 1.0
w: 1.0
}
size {
x: 400.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 with additional check function."
font: "game"
id: "text_custom_check"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "root"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 200.0
y: -20.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.5
y: 0.5
z: 1.0
w: 1.0
}
size {
x: 400.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: "Failure callback: false"
font: "game"
id: "text_custom_result"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
shadow {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: true
parent: "root"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 1.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
layers {
name: "image"
}

View File

@@ -27,6 +27,28 @@ local function double_tap_callback(self, params, button, click_in_row)
end
local function check_function(self)
self._some_test_value = self._some_test_value or 0
self._some_test_value = self._some_test_value + 1
return self._some_test_value % 2 == 0
end
local function failure_check_callback(self)
gui.set_text(gui.get_node("text_custom_result"), "Failure callback: true")
end
local function check_clicked_callback(self)
local node = gui.get_node("text_custom_result")
gui.set_text(node, "Failure callback: false")
gui.set_scale(node, vmath.vector3(0.75))
gui.animate(node, gui.PROP_SCALE, 0.5, gui.EASING_OUTSINE, 0.2)
end
local function setup_buttons(self)
self.druid:new_button("button_usual/button", usual_callback)
@@ -48,6 +70,9 @@ local function setup_buttons(self)
-- Button with another node for animating
self.druid:new_button("button_anim/button", usual_callback, nil, "anim_node_icon")
self.druid:new_button("button_custom_check/button", check_clicked_callback)
:set_check_function(check_function, failure_check_callback)
end

View File

@@ -210,7 +210,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Button:"
text: "ui_section_button"
font: "game"
id: "text_button"
xanchor: XANCHOR_NONE
@@ -604,7 +604,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Text:"
text: "ui_section_text"
font: "game"
id: "text_text"
xanchor: XANCHOR_NONE
@@ -848,7 +848,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Timer:"
text: "ui_section_timer"
font: "game"
id: "text_timer"
xanchor: XANCHOR_NONE
@@ -1029,7 +1029,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Progress bar:"
text: "ui_section_progress"
font: "game"
id: "text_progress"
xanchor: XANCHOR_NONE
@@ -1320,7 +1320,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Slider:"
text: "ui_section_slider"
font: "game"
id: "text_slider"
xanchor: XANCHOR_NONE
@@ -1611,7 +1611,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Radio:"
text: "ui_section_radio"
font: "game"
id: "text_radio"
xanchor: XANCHOR_NONE
@@ -2234,7 +2234,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Checkbox:"
text: "ui_section_checkbox"
font: "game"
id: "text_checkbox"
xanchor: XANCHOR_NONE
@@ -2857,7 +2857,7 @@ nodes {
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Input:"
text: "ui_section_input"
font: "game"
id: "text_input"
xanchor: XANCHOR_NONE

View File

@@ -25,14 +25,14 @@ end
local function setup_texts(self)
self.druid:new_lang_text("text_button", "ui_section_button")
self.druid:new_lang_text("text_text", "ui_section_text")
self.druid:new_lang_text("text_timer", "ui_section_timer")
self.druid:new_lang_text("text_progress", "ui_section_progress")
self.druid:new_lang_text("text_slider", "ui_section_slider")
self.druid:new_lang_text("text_radio", "ui_section_radio")
self.druid:new_lang_text("text_checkbox", "ui_section_checkbox")
self.druid:new_lang_text("text_input", "ui_section_input")
self.druid:new_lang_text("text_button")
self.druid:new_lang_text("text_text")
self.druid:new_lang_text("text_timer")
self.druid:new_lang_text("text_progress")
self.druid:new_lang_text("text_slider")
self.druid:new_lang_text("text_radio")
self.druid:new_lang_text("text_checkbox")
self.druid:new_lang_text("text_input")
self.druid:new_lang_text("text_translated", "ui_text_example")
self.druid:new_lang_text("text_button_lang", "ui_text_change_lang")
@@ -69,8 +69,8 @@ local function setup_checkbox(self)
nil,
{"checkbox1/back", "checkbox2/back", "checkbox3/back"})
radio_group:set_state(2)
checkbox_group:set_state({true, false, true})
radio_group:set_state(2, true)
checkbox_group:set_state({true, false, true}, true)
end

View File

@@ -0,0 +1,37 @@
name: "grid_animations"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"grid_animations\"\n"
" component: \"/example/examples/grid/grid_animations/grid_animations.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
}
}

View File

@@ -0,0 +1,626 @@
script: "/example/examples/grid/grid_animations/grid_animations.gui_script"
fonts {
name: "game"
font: "/example/assets/fonts/game.font"
}
textures {
name: "kenney"
texture: "/example/assets/images/kenney.atlas"
}
background_color {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
nodes {
position {
x: 300.0
y: 415.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 600.0
y: 830.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_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: -100.0
y: -200.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_add"
parent: "root"
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: 130.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "button_add/button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_add"
layer: "image"
inherit_alpha: true
slice9 {
x: 15.0
y: 15.0
z: 15.0
w: 15.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 7.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.7
y: 0.7
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Add\n"
""
font: "game"
id: "button_add/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 0.101960786
y: 0.2
z: 0.6
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "button_add/button"
layer: "text"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 100.0
y: -200.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_remove"
parent: "root"
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: 130.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "button_remove/button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_remove"
layer: "image"
inherit_alpha: true
slice9 {
x: 15.0
y: 15.0
z: 15.0
w: 15.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 7.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.7
y: 0.7
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Remove\n"
""
font: "game"
id: "button_remove/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 0.101960786
y: 0.2
z: 0.6
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "button_remove/button"
layer: "text"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 0.0
y: 108.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 600.0
y: 200.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "grid"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_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: 80.0
y: 110.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "prefab"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_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: 80.0
y: 110.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_green"
id: "prefab_icon"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "prefab"
layer: ""
inherit_alpha: true
slice9 {
x: 10.0
y: 10.0
z: 10.0
w: 10.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: -2.0
y: 8.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.5
y: 1.5
z: 1.0
w: 1.0
}
size {
x: 30.0
y: 30.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.9019608
z: 0.6
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "1"
font: "game"
id: "prefab_text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "prefab_icon"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.5
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
layers {
name: "image"
}
layers {
name: "text"
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512

View File

@@ -0,0 +1,65 @@
local druid = require("druid.druid")
local function add_element(self)
-- Limit up to 10 nodes in this example
if #self.grid.nodes >= 10 then
return
end
-- Make new element to insert into the grid
local nodes = gui.clone_tree(self.prefab)
gui.set_enabled(nodes["prefab"], true)
self.grid:add(nodes["prefab"])
gui.set_text(nodes["prefab_text"], #self.grid.nodes)
-- Animate new element after _grid:add_
-- Note, what Grid component take care of node position, so we can't
-- animate position of the root node. We need insert one more anchor node to make
-- it possible. In this example it is "prefab_icon"
gui.animate(nodes["prefab_icon"], "position.y", 20, gui.EASING_OUTSINE, 0.4, 0, nil, gui.PLAYBACK_ONCE_BACKWARD)
gui.animate(nodes["prefab_icon"], "color.w", 0, gui.EASING_OUTSINE, 0.3, 0, nil, gui.PLAYBACK_ONCE_BACKWARD)
end
local function remove_element(self)
if #self.grid.nodes > 0 then
local root = self.grid:remove(#self.grid.nodes)
-- We should instant remove element from the grid, but node itself delete after the animation
gui.animate(root, "color.w", 0, gui.EASING_OUTSINE, 0.2, 0, function()
gui.delete_node(root)
end)
end
end
function init(self)
self.druid = druid.new(self)
self.grid = self.druid:new_static_grid("grid", "prefab", 5)
self.prefab = gui.get_node("prefab")
gui.set_enabled(self.prefab, false)
self.druid:new_button("button_add/button", add_element)
self.druid:new_button("button_remove/button", remove_element)
end
function final(self)
self.druid:final()
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end

View File

@@ -0,0 +1,37 @@
name: "static_grid"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"static_grid\"\n"
" component: \"/example/examples/grid/static_grid/static_grid.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
}
}

View File

@@ -0,0 +1,628 @@
script: "/example/examples/grid/static_grid/static_grid.gui_script"
fonts {
name: "game"
font: "/example/assets/fonts/game.font"
}
textures {
name: "kenney"
texture: "/example/assets/images/kenney.atlas"
}
background_color {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
nodes {
position {
x: 300.0
y: 415.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 600.0
y: 830.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_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: 409.0
y: 360.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: 49.0
y: 49.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_green"
id: "prefab"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 0.8
template_node_child: false
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: -270.0
y: 370.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_NW_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 270.0
y: 370.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_NE_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NE
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 370.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_N_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: -270.0
y: -130.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_SW_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_SW
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 270.0
y: -130.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_SE_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_SE
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: -130.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_S_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_S
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: -270.0
y: 120.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_W_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_W
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 120.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_C_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 270.0
y: 120.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_E_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_E
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
layers {
name: "image"
}
layers {
name: "text"
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512

View File

@@ -0,0 +1,87 @@
local druid = require("druid.druid")
function init(self)
self.druid = druid.new(self)
local prefab = gui.get_node("prefab")
gui.set_enabled(prefab, false)
local grid_nw = self.druid:new_static_grid("grid_NW_anchor", prefab, 3)
local grid_ne = self.druid:new_static_grid("grid_NE_anchor", prefab, 3)
local grid_n = self.druid:new_static_grid("grid_N_anchor", prefab, 3)
local grid_sw = self.druid:new_static_grid("grid_SW_anchor", prefab, 3)
local grid_se = self.druid:new_static_grid("grid_SE_anchor", prefab, 3)
local grid_s = self.druid:new_static_grid("grid_S_anchor", prefab, 3)
local grid_w = self.druid:new_static_grid("grid_C_anchor", prefab, 3)
local grid_e = self.druid:new_static_grid("grid_W_anchor", prefab, 3)
local grid_c = self.druid:new_static_grid("grid_E_anchor", prefab, 3)
local update_pos_func = function(node, pos) gui.animate(node, "position", pos, gui.EASING_OUTSINE, 0.2) end
grid_nw:set_position_function(update_pos_func)
grid_ne:set_position_function(update_pos_func)
grid_n:set_position_function(update_pos_func)
grid_sw:set_position_function(update_pos_func)
grid_se:set_position_function(update_pos_func)
grid_s:set_position_function(update_pos_func)
grid_w:set_position_function(update_pos_func)
grid_e:set_position_function(update_pos_func)
grid_c:set_position_function(update_pos_func)
local grids = {
grid_nw,
grid_ne,
grid_n,
grid_sw,
grid_se,
grid_s,
grid_c,
grid_w,
grid_e,
}
for i = 1, #grids do
grids[i].style.IS_DYNAMIC_NODE_POSES = false
end
local animate_grides = function()
for _, grid in ipairs(grids) do
for i = 1, #grid.nodes do
gui.delete_node(grid.nodes[i])
end
grid:clear()
for i = 1, 9 do
timer.delay(i, false, function()
local node = gui.clone(prefab)
gui.set_enabled(node, true)
grid:add(node)
end)
end
end
end
animate_grides()
timer.delay(10, true, animate_grides)
end
function final(self)
self.druid:final()
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end

View File

@@ -0,0 +1,37 @@
name: "static_grid_dynamic_pos"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"static_grid_dynamic_pos\"\n"
" component: \"/example/examples/grid/static_grid_dynamic_pos/static_grid_dynamic_pos.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
}
}

View File

@@ -0,0 +1,628 @@
script: "/example/examples/grid/static_grid_dynamic_pos/static_grid_dynamic_pos.gui_script"
fonts {
name: "game"
font: "/example/assets/fonts/game.font"
}
textures {
name: "kenney"
texture: "/example/assets/images/kenney.atlas"
}
background_color {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
nodes {
position {
x: 300.0
y: 415.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 600.0
y: 830.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "root"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_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: 409.0
y: 360.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: 49.0
y: 49.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_green"
id: "prefab"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 0.8
template_node_child: false
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: -270.0
y: 370.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_NW_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NW
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 270.0
y: 370.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_NE_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_NE
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 370.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_N_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: -270.0
y: -130.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_SW_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_SW
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 270.0
y: -130.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_SE_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_SE
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: -130.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_S_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_S
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: -270.0
y: 120.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_W_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_W
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 120.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_C_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 270.0
y: 120.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: 100.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 0.7019608
z: 0.4
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_E_anchor"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_E
adjust_mode: ADJUST_MODE_FIT
parent: "root"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
layers {
name: "image"
}
layers {
name: "text"
}
material: "/builtins/materials/gui.material"
adjust_reference: ADJUST_REFERENCE_PARENT
max_nodes: 512

View File

@@ -0,0 +1,87 @@
local druid = require("druid.druid")
function init(self)
self.druid = druid.new(self)
local prefab = gui.get_node("prefab")
gui.set_enabled(prefab, false)
local grid_nw = self.druid:new_static_grid("grid_NW_anchor", prefab, 3)
local grid_ne = self.druid:new_static_grid("grid_NE_anchor", prefab, 3)
local grid_n = self.druid:new_static_grid("grid_N_anchor", prefab, 3)
local grid_sw = self.druid:new_static_grid("grid_SW_anchor", prefab, 3)
local grid_se = self.druid:new_static_grid("grid_SE_anchor", prefab, 3)
local grid_s = self.druid:new_static_grid("grid_S_anchor", prefab, 3)
local grid_w = self.druid:new_static_grid("grid_C_anchor", prefab, 3)
local grid_e = self.druid:new_static_grid("grid_W_anchor", prefab, 3)
local grid_c = self.druid:new_static_grid("grid_E_anchor", prefab, 3)
local update_pos_func = function(node, pos) gui.animate(node, "position", pos, gui.EASING_OUTSINE, 0.2) end
grid_nw:set_position_function(update_pos_func)
grid_ne:set_position_function(update_pos_func)
grid_n:set_position_function(update_pos_func)
grid_sw:set_position_function(update_pos_func)
grid_se:set_position_function(update_pos_func)
grid_s:set_position_function(update_pos_func)
grid_w:set_position_function(update_pos_func)
grid_e:set_position_function(update_pos_func)
grid_c:set_position_function(update_pos_func)
local grids = {
grid_nw,
grid_ne,
grid_n,
grid_sw,
grid_se,
grid_s,
grid_c,
grid_w,
grid_e,
}
for i = 1, #grids do
grids[i].style.IS_DYNAMIC_NODE_POSES = true
end
local animate_grides = function()
for _, grid in ipairs(grids) do
for i = 1, #grid.nodes do
gui.delete_node(grid.nodes[i])
end
grid:clear()
for i = 1, 9 do
timer.delay(i, false, function()
local node = gui.clone(prefab)
gui.set_enabled(node, true)
grid:add(node)
end)
end
end
end
animate_grides()
timer.delay(10, true, animate_grides)
end
function final(self)
self.druid:final()
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end

View File

@@ -0,0 +1,37 @@
name: "message_input"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"message_input\"\n"
" component: \"/example/examples/system/message_input/message_input.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
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,76 @@
local druid = require("druid.druid")
local const = require("druid.const")
local function click_callback(self, text, some)
print("Button tap callback:", text, some)
end
local function trigger_callback(self, params)
msg.post(".", const.ON_MESSAGE_INPUT, params)
end
local function set_random_text_callback(self, params)
params.value = "Value: " .. math.random(0, 99)
trigger_callback(self, params)
end
function init(self)
self.druid = druid.new(self)
self.button_test = self.druid:new_button("button_test/button", click_callback)
self.button_test.on_long_click:subscribe(function() print("long click") end)
self.button_test.on_double_click:subscribe(function() print("double click") end)
self.button_test.on_repeated_click:subscribe(function() print("repeated_click") end)
self.druid:new_text("text_random")
self.druid:new_button("button_trigger_click/button", trigger_callback, {
node_id = "button_test/button",
action = const.MESSAGE_INPUT.BUTTON_CLICK
})
self.druid:new_button("button_trigger_double/button", trigger_callback, {
node_id = "button_test/button",
action = const.MESSAGE_INPUT.BUTTON_DOUBLE_CLICK
})
self.druid:new_button("button_trigger_long/button", trigger_callback, {
node_id = "button_test/button",
action = const.MESSAGE_INPUT.BUTTON_LONG_CLICK
})
self.druid:new_button("button_trigger_repeated/button", trigger_callback, {
node_id = "button_test/button",
action = const.MESSAGE_INPUT.BUTTON_REPEATED_CLICK
})
self.druid:new_button("button_text_random/button", set_random_text_callback, {
node_id = "text_random",
action = const.MESSAGE_INPUT.TEXT_SET
})
end
function final(self)
self.druid:final()
end
function update(self, dt)
self.druid:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
return self.druid:on_input(action_id, action)
end

View File

@@ -0,0 +1,37 @@
name: "whitelist_blacklist"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"whitelist_blacklist\"\n"
" component: \"/example/examples/system/whitelist_blacklist/whitelist_blacklist.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
}
}

Some files were not shown because too many files have changed in this diff Show More