39 Commits
0.6.0 ... 0.7.0

Author SHA1 Message Date
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
108 changed files with 9083 additions and 209 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)
@@ -63,6 +74,11 @@ function druid__back_handler.on_input(self, action_id, action) end
---@field ALL 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
@@ -393,7 +416,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 +468,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
@@ -780,6 +805,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 +855,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 +863,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 +920,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 +936,11 @@ 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_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 +968,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 +979,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 +998,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 +1009,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
@@ -1248,6 +1314,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 +1390,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":948341,"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.7.499
write_log = 0
compress_archive = 1
publisher = Insality
developer = Insality
commit_sha = 015564f5b3e0d5e63e422056c69e53826ed689bf
build_time = 2021-04-05T21:00:43Z
commit_sha = 1ae77e727fd29b01a514e73820b3e02213aeb7db
build_time = 2021-10-23T14:38:03Z
[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 = 499
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.7.499</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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -133,6 +133,10 @@
<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">
@@ -551,6 +555,33 @@
</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.3/manual.html#6.6">table</a></span>
Array of childrens if the Druid component instance
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
@@ -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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </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>
@@ -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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -333,7 +333,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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -245,7 +245,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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </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>
@@ -392,6 +400,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
The boolean value is input was consumed
</ol>
@@ -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.3/manual.html#6.6">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.3/manual.html#6.6">table</a> or <span class="type">Component</span></span>
The array of component to blacklist
(<em>default</em> nil)
</li>
</ul>
@@ -1283,7 +1360,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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -243,7 +243,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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -245,7 +245,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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </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,34 @@
</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>
</ul>
</dd>
</dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
@@ -831,7 +877,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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </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
@@ -189,10 +213,10 @@
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>
@@ -247,6 +271,12 @@
</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.3/manual.html#6.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.3/manual.html#6.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 2021-10-23 17:45:31 </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 2021-10-23 17:45:31 </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>
@@ -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 2021-10-23 17:45:31 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -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 2021-10-23 17:45:31 </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

@@ -23,7 +23,7 @@ end
function M.update(self, dt)
end
-- Call only if exist interest: component.ON_INPUT or component.ON_INPUT_HIGH
-- Call only if exist interest: component.ON_INPUT
function M.on_input(self, action_id, action)
end
@@ -35,8 +35,12 @@ end
function M.on_message(self, message_id, message, sender)
end
-- Call only if component with ON_ANGUAGECHANinterest
function M.on_anguagechanself)
-- Call only if component with ON_LANGUAGE_CHANGE interest
function M.on_language_change(self)
end
-- Call only if component with ON_MESSAGE_INPUT interest
function M.on_message_input(self, node_id, message)
end
-- Call only if component with ON_LAYOUT_CHANGE interest
@@ -56,6 +60,10 @@ end
function M.on_focus_gained(self)
end
-- Call only if exist interest: component.ON_LATE_INIT
function M.on_late_init(self)
end
-- Call on component remove or on druid:final
function M.on_remove(self)
end
@@ -105,12 +113,16 @@ There is next interests in druid:
- **ON_LANGUAGE_CHANGE** - will call _on_language_change_ function on language change trigger
- **ON_MESSAGE_INPUT** - will call _on_message_input_ function on Druid _const.ON_MESSAGE_INPUT_ message
- **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`
- **ON_LATE_INIT** will call _on_late_init_ function once after component init on update step.
## Best practice on custom components
On each component recommended describe component scheme in next way:

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**
---
@@ -202,3 +203,70 @@ 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

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

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

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,11 @@ 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", {
component.ON_INPUT,
component.ON_MESSAGE_INPUT,
component.ON_LATE_INIT
})
local function is_input_match(self, action_id)
@@ -95,6 +104,7 @@ local function on_button_repeated_click(self)
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)
end
@@ -126,7 +136,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 +171,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 +210,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 +225,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 +238,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 +322,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 +400,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", { component.ON_INPUT, component.ON_LATE_INIT }, 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.ON_INPUT, component.ON_LATE_INIT })
--- 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

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,12 @@ 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", {
component.ON_INPUT,
component.ON_UPDATE,
component.ON_LAYOUT_CHANGE,
component.ON_LATE_INIT
})
local function inverse_lerp(min, max, current)
@@ -106,6 +113,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 +129,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 +179,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
@@ -597,11 +616,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 +755,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
@@ -63,6 +65,17 @@ 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
function StaticGrid.on_style_change(self, style)
self.style = {}
self.style.IS_DYNAMIC_NODE_POSES = style.IS_DYNAMIC_NODE_POSES or false
end
--- Component init function
-- @tparam StaticGrid self
-- @tparam node parent The gui node parent, where items will be placed
@@ -167,7 +180,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 +205,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 +218,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 +238,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 +400,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 +418,23 @@ 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 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", { component.ON_INPUT, component.ON_LATE_INIT })
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

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", { component.ON_LAYOUT_CHANGE, component.ON_MESSAGE_INPUT })
local function update_text_size(self)
@@ -57,24 +63,36 @@ 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)
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 +102,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 +141,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 +202,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 +221,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 +256,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 +328,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 +341,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
@@ -16,9 +18,11 @@ 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
@@ -27,9 +31,11 @@ BaseComponent.ALL_INTERESTS = {
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,
}
@@ -39,6 +45,7 @@ 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_MESSAGE_INPUT] = "on_message_input",
[BaseComponent.ON_LANGUAGE_CHANGE] = "on_language_change",
}
@@ -169,6 +176,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
@@ -351,6 +363,26 @@ 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

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"
@@ -31,9 +36,11 @@ M.ALL = "all"
M.ON_INPUT = hash("on_input")
M.ON_UPDATE = hash("on_update")
M.ON_MESSAGE = hash("on_message")
M.ON_LATE_INIT = hash("on_late_init")
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_MESSAGE_INPUT = hash("on_message_input")
M.ON_LANGUAGE_CHANGE = hash("on_language_change")
@@ -42,6 +49,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 +71,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 +107,16 @@ M.SHIFT = {
}
M.TEXT_ADJUST = {
DOWNSCALE = 0,
TRIM = 1,
NO_ADJUST = 2,
DOWNSCALE_LIMITED = 3,
SCROLL = 4,
SCALE_THEN_SCROLL = 5,
}
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

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

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

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
--- Druid component template
-- @module druid.component
-- @local

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
@@ -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)

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

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

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

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

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

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.

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
@@ -169,6 +171,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,11 @@ M["drag"] = {
}
M["static_grid"] = {
IS_DYNAMIC_NODE_POSES = false, -- Always align by content size with node anchor
}
M["scroll"] = {
ANIM_SPEED = 0.2, -- gui.animation speed to point
BACK_SPEED = 0.35, -- Lerp speed of return to soft position
@@ -65,8 +73,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
}
@@ -125,4 +134,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 = {}

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")
@@ -132,8 +134,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 +144,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 +180,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,6 +207,9 @@ function DruidInstance.initialize(self, context, style)
self._late_remove = {}
self.url = msg.url()
self._input_blacklist = nil
self._input_whitelist = nil
self.components = {}
for i = 1, #base_component.ALL_INTERESTS do
self.components[base_component.ALL_INTERESTS[i]] = {}
@@ -192,13 +225,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
@@ -283,6 +310,12 @@ end
-- @tparam DruidInstance self
-- @tparam number dt Delta time
function DruidInstance.update(self, dt)
local late_init_components = self.components[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
local components = self.components[base_component.ON_UPDATE]
for i = 1, #components do
components[i]:update(dt)
@@ -294,13 +327,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]
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,9 +354,21 @@ 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.SPECIFIC_UI_MESSAGES[base_component.ON_MESSAGE_INPUT]
if specific_ui_message then
if specific_ui_message == on_message_input_message then
local components = self.components[message_id]
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[message_id]
if components then
for i = 1, #components do
@@ -376,6 +421,7 @@ 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]
@@ -385,6 +431,52 @@ function DruidInstance.on_language_change(self)
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

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

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

@@ -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,83 @@
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,
}
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
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,66 @@
local druid = require("druid.druid")
local function click_callback(self)
print("Just tap callback")
end
function init(self)
self.druid_whitelist = druid.new(self)
-- Whitelist
self.button_wl_left = self.druid_whitelist:new_button("button_whitelist_1/button", click_callback)
self.button_wl_middle = self.druid_whitelist:new_button("button_whitelist_2/button", click_callback)
self.button_wl_right = self.druid_whitelist:new_button("button_whitelist_3/button", click_callback)
self.druid_whitelist:set_whitelist(self.button_wl_left)
self.druid_blacklist = druid.new(self)
-- Blacklist
self.button_bl_left = self.druid_blacklist:new_button("button_blacklist_1/button", click_callback)
self.button_bl_middle = self.druid_blacklist:new_button("button_blacklist_2/button", click_callback)
self.button_bl_right = self.druid_blacklist:new_button("button_blacklist_3/button", click_callback)
self.druid_blacklist:set_blacklist(self.button_bl_left)
self.druid_wb = druid.new(self)
-- Blacklist and Whitelist
self.button_wb_left = self.druid_wb:new_button("button_wb_1/button", click_callback)
self.button_wb_middle = self.druid_wb:new_button("button_wb_2/button", click_callback)
self.button_wb_right = self.druid_wb:new_button("button_wb_3/button", click_callback)
self.druid_wb:set_whitelist(self.button_wb_left)
self.druid_wb:set_blacklist(self.button_wb_left)
end
function final(self)
self.druid_whitelist:final()
self.druid_blacklist:final()
self.druid_wb:final()
end
function update(self, dt)
self.druid_whitelist:update(dt)
self.druid_blacklist:update(dt)
self.druid_wb:update(dt)
end
function on_message(self, message_id, message, sender)
self.druid_whitelist:on_message(message_id, message, sender)
self.druid_blacklist:on_message(message_id, message, sender)
self.druid_wb:on_message(message_id, message, sender)
end
function on_input(self, action_id, action)
local result_1 = self.druid_whitelist:on_input(action_id, action)
local result_2 = self.druid_blacklist:on_input(action_id, action)
local result_3 = self.druid_wb:on_input(action_id, action)
return result_1 or result_2 or result_3
end

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