Merge pull request #145 from Insality/release/0.7.0

Release/0.7.0 to master
This commit is contained in:
Maxim Tuprikov
2021-10-23 17:48:53 +03:00
committed by GitHub
103 changed files with 8202 additions and 187 deletions

View File

@@ -1,6 +1,6 @@
MIT License 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal 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: **Druid** requires the following input bindings:
- Mouse trigger - `Button 1` -> `touch` _For basic input components_ - 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 - `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 - `Back` -> `key_back` _For back_handler component, Android back button, input component_
- Key trigger - `Enter` -> `key_enter` _For input component, optional_ - 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) ![](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] ### 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")` 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 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] ### Code [optional]
Adjust **Druid** settings, if needed: Adjust **Druid** settings, if needed:

View File

@@ -11,7 +11,8 @@ local druid = {}
function druid.new(context, style) end function druid.new(context, style) end
--- Druid on language change. --- 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. --- Callback on global language change event.
function druid.on_language_change() end function druid.on_language_change() end
@@ -28,6 +29,11 @@ function druid.on_window_callback(event) end
---@param module table lua table with component ---@param module table lua table with component
function druid.register(name, module) end 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. --- Set new default style.
---@param style table Druid style module ---@param style table Druid style module
function druid.set_default_style(style) end 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 ---@param callback function Get localized text function
function druid.set_text_function(callback) end 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 ---@class druid.back_handler : druid.base_component
---@field on_back druid_event On back handler callback(self, params) ---@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 ---@field ALL field Component Interests
local druid__base_component = {} 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 --- Get current component context
---@param self druid.base_component ---@param self druid.base_component
---@return table BaseComponent context ---@return table BaseComponent context
@@ -163,6 +179,7 @@ function druid__blocker.set_enabled(self, state) end
---@class druid.button : druid.base_component ---@class druid.button : druid.base_component
---@field anim_node node Animation node ---@field anim_node node Animation node
---@field click_zone node Restriction zone ---@field click_zone node Restriction zone
---@field hash node_id The hash of trigger node
---@field hover druid.hover Druid hover logic component ---@field hover druid.hover Druid hover logic component
---@field node node Trigger node ---@field node node Trigger node
---@field on_click druid_event On release button callback(self, params, button_instance) ---@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 ---@return bool True, if button is enabled
function druid__button.is_enabled(self) end 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. --- Strict button click area.
---@param self druid.button ---@param self druid.button
---@param zone node Gui node ---@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 node node Gui node
---@param index number The node position. By default add as last 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 ---@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. --- Clear grid nodes array.
---@param self druid.dynamic_grid ---@param self druid.dynamic_grid
@@ -444,8 +468,9 @@ function druid__dynamic_grid.init(self, parent) end
---@param self druid.dynamic_grid ---@param self druid.dynamic_grid
---@param index number The grid node index to remove ---@param index number The grid node index to remove
---@param shift_policy number How shift nodes, if required. See const.SHIFT ---@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 ---@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. --- Change set position function for grid nodes.
---@param self druid.dynamic_grid ---@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 INERT_THRESHOLD field Scroll speed to stop inertion
---@field POINTS_DEADZONE field Speed to check points of interests in no_inertion mode ---@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 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_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 ---@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 = {} 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_remove_item druid_event On item remove callback(self, index)
---@field on_update_positions druid_event On update item positions callback(self) ---@field on_update_positions druid_event On update item positions callback(self)
---@field parent node Parent gui node ---@field parent node Parent gui node
---@field style druid.static_grid.style Component style params.
local druid__static_grid = {} local druid__static_grid = {}
--- Add new item to the grid --- Add new item to the grid
@@ -836,7 +863,8 @@ local druid__static_grid = {}
---@param item node Gui node ---@param item node Gui node
---@param index number The item position. By default add as last item ---@param index number The item position. By default add as last item
---@param shift_policy number How shift nodes, if required. See const.SHIFT ---@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. --- Clear grid nodes array.
---@param self druid.static_grid ---@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 self druid.static_grid
---@param index number The grid node index to remove ---@param index number The grid node index to remove
---@param shift_policy number How shift nodes, if required. See const.SHIFT ---@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 ---@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. --- Set grid anchor.
---@param self druid.static_grid ---@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 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 ---@class druid.swipe : druid.base_component
---@field click_zone node Restriction zone ---@field click_zone node Restriction zone
---@field node node Swipe node ---@field node node Swipe node
@@ -934,9 +968,10 @@ local druid__swipe__style = {}
---@class druid.text : druid.base_component ---@class druid.text : druid.base_component
---@field adjust_type number Current text size adjust settings
---@field color vector3 Current text color ---@field color vector3 Current text color
---@field is_no_adjust bool Current text size adjust settings
---@field node node Text node ---@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_pivot druid_event On change pivot callback(self, pivot)
---@field on_set_text druid_event On set text callback(self, text) ---@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) ---@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 scale vector3 Current text node scale
---@field start_scale vector3 Initial text node scale ---@field start_scale vector3 Initial text node scale
---@field start_size vector3 Initial text node size ---@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 ---@field text_area vector3 Current text node available are
local druid__text = {} 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 --- Calculate text width with font with respect to trailing space
---@param self druid.text ---@param self druid.text
---@param text string ---@param text string
@@ -956,8 +998,8 @@ function druid__text.get_text_width(self, text) end
---@param self druid.text ---@param self druid.text
---@param node node Gui text node ---@param node node Gui text node
---@param value string Initial text. Default value is node text from GUI scene. ---@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 ---@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, no_adjust) end function druid__text.init(self, node, value, adjust_type) end
--- Return true, if text with line break --- Return true, if text with line break
---@param self druid.text ---@param self druid.text
@@ -967,29 +1009,53 @@ function druid__text.is_multiline(self) end
--- Set alpha --- Set alpha
---@param self druid.text ---@param self druid.text
---@param alpha number Alpha for node ---@param alpha number Alpha for node
---@return druid.text Current text instance
function druid__text.set_alpha(self, alpha) end function druid__text.set_alpha(self, alpha) end
--- Set color --- Set color
---@param self druid.text ---@param self druid.text
---@param color vector4 Color for node ---@param color vector4 Color for node
---@return druid.text Current text instance
function druid__text.set_color(self, color) end 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. --- Set text pivot.
---@param self druid.text ---@param self druid.text
---@param pivot gui.pivot Gui pivot constant ---@param pivot gui.pivot Gui pivot constant
---@return druid.text Current text instance
function druid__text.set_pivot(self, pivot) end function druid__text.set_pivot(self, pivot) end
--- Set scale --- Set scale
---@param self druid.text ---@param self druid.text
---@param scale vector3 Scale for node ---@param scale vector3 Scale for node
---@return druid.text Current text instance
function druid__text.set_scale(self, scale) end 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 --- Set text to text field
---@param self druid.text ---@param self druid.text
---@param set_to string Text for node ---@param set_to string Text for node
---@return druid.text Current text instance
function druid__text.set_to(self, set_to) end 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 ---@class druid.timer : druid.base_component
---@field from number Initial timer value ---@field from number Initial timer value
---@field node node Trigger node ---@field node node Trigger node
@@ -1248,6 +1314,7 @@ function druid_instance.on_focus_lost(self) end
---@param self druid_instance ---@param self druid_instance
---@param action_id hash Action_id from on_input ---@param action_id hash Action_id from on_input
---@param action table Action 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 function druid_instance.on_input(self, action_id, action) end
--- Druid on layout change function. --- 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) ---@return vector4 Vector with distance to node border: (left, top, right, down)
function helper.get_border(node, offset) end 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 --- Get node offset for given gui pivot
---@param pivot gui.pivot The node pivot ---@param pivot gui.pivot The node pivot
---@return vector3 Vector offset with [-1..1] values ---@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":11568,"pieces":[{"name":"game.arci0","offset":0}]},{"name":"game.arcd","size":388522,"pieces":[{"name":"game.arcd0","offset":0}]},{"name":"game.dmanifest","size":25565,"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] [project]
title = druid title = druid
version = 0.6.466 version = 0.7.499
write_log = 0 write_log = 0
compress_archive = 1 compress_archive = 1
publisher = Insality publisher = Insality
developer = Insality developer = Insality
commit_sha = ffa3bafa002c561f6f4a31e8bbca228c3606b1cc commit_sha = 1ae77e727fd29b01a514e73820b3e02213aeb7db
build_time = 2021-05-30T08:51:36Z build_time = 2021-10-23T14:38:03Z
[display] [display]
width = 600 width = 600
@@ -35,7 +35,7 @@ world_count = 4
gravity_x = 0 gravity_x = 0
gravity_z = 0 gravity_z = 0
scale = 1 scale = 1
allow_dynamic_transforms = 0 allow_dynamic_transforms = 1
debug_scale = 30 debug_scale = 30
max_collisions = 64 max_collisions = 64
max_contacts = 128 max_contacts = 128
@@ -121,9 +121,9 @@ default_language = en
localizations = en localizations = en
[android] [android]
version_code = 466 version_code = 499
minimum_sdk_version = 16 minimum_sdk_version = 16
target_sdk_version = 29 target_sdk_version = 30
package = com.insality.druid package = com.insality.druid
manifest = /builtins/manifests/android/AndroidManifest.xml manifest = /builtins/manifests/android/AndroidManifest.xml
iap_provider = GooglePlay iap_provider = GooglePlay
@@ -149,6 +149,7 @@ cssfile = /builtins/manifests/web/light_theme.css
archive_location_prefix = archive archive_location_prefix = archive
show_fullscreen_button = 0 show_fullscreen_button = 0
show_made_with_defold = 0 show_made_with_defold = 0
show_console_banner = 1
scale_mode = fit scale_mode = fit
engine_arguments = --verify-graphics-calls=false engine_arguments = --verify-graphics-calls=false
splash_image = /media/druid_logo.png splash_image = /media/druid_logo.png
@@ -191,6 +192,17 @@ run_while_iconified = 0
[druid] [druid]
no_auto_input = 0 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] [native_extension]
app_manifest = /example/game.appmanifest app_manifest = /example/game.appmanifest

Binary file not shown.

View File

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

View File

@@ -169,7 +169,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -214,7 +214,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </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="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> <td class="summary">Setup component context and his style table</td>
</tr> </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> </table>
<h2><a href="#Fields">Fields</a></h2> <h2><a href="#Fields">Fields</a></h2>
<table class="function_list"> <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> </dd>
</dl> </dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2> <h2 class="section-header "><a name="Fields"></a>Fields</h2>
@@ -577,7 +608,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -212,7 +212,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -101,6 +101,10 @@
<td class="name" nowrap><a href="#get_key_trigger">get_key_trigger(self)</a></td> <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> <td class="summary">Get key-code to trigger this button</td>
</tr> </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> </table>
<h2><a href="#Tables">Tables</a></h2> <h2><a href="#Tables">Tables</a></h2>
<table class="function_list"> <table class="function_list">
@@ -140,6 +144,10 @@
<td class="summary">Trigger node</td> <td class="summary">Trigger node</td>
</tr> </tr>
<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="name" nowrap><a href="#anim_node">anim_node</a></td>
<td class="summary">Animation node</td> <td class="summary">Animation node</td>
</tr> </tr>
@@ -320,7 +328,7 @@
</li> </li>
<li><span class="parameter">key</span> <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 The action_id of the key
</li> </li>
</ul> </ul>
@@ -355,13 +363,46 @@
<h3>Returns:</h3> <h3>Returns:</h3>
<ol> <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 The action_id of the key
</ol> </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> </dd>
</dl> </dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2> <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> </dd>
<dt> <dt>
<a name = "anim_node"></a> <a name = "anim_node"></a>
@@ -714,7 +775,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -333,7 +333,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -245,7 +245,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -499,7 +499,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -489,7 +489,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -271,7 +271,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -144,10 +144,18 @@
<td class="summary">Druid on layout change function.</td> <td class="summary">Druid on layout change function.</td>
</tr> </tr>
<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> <td class="summary">Druid on language change.</td>
</tr> </tr>
<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="name" nowrap><a href="#new_button">new_button(self, node, callback[, params[, anim_node]])</a></td>
<td class="summary">Create button basic component</td> <td class="summary">Create button basic component</td>
</tr> </tr>
@@ -392,6 +400,12 @@
</li> </li>
</ul> </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> </dd>
<dt> <dt>
<a name = "druid.on_language_change"></a> <a name = "druid.on_language_change"></a>
<strong>druid.on_language_change()</strong> <strong>druid.on_language_change(self)</strong>
</dt> </dt>
<dd> <dd>
Druid on language change. Druid on language change.
@@ -506,6 +520,69 @@
call manualy to update all translations 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="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -85,11 +85,11 @@
<td class="summary">Return pos for grid node index</td> <td class="summary">Return pos for grid node index</td>
</tr> </tr>
<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> <td class="summary">Add new node to the grid</td>
</tr> </tr>
<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> <td class="summary">Remove the item from the grid.</td>
</tr> </tr>
<tr> <tr>
@@ -247,7 +247,7 @@
</dd> </dd>
<dt> <dt>
<a name = "add"></a> <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> </dt>
<dd> <dd>
Add new node to the grid Add new node to the grid
@@ -273,6 +273,11 @@
How shift nodes, if required. See const.SHIFT How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT) (<em>default</em> SHIFT.RIGHT)
</li> </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> </ul>
@@ -282,7 +287,7 @@
</dd> </dd>
<dt> <dt>
<a name = "remove"></a> <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> </dt>
<dd> <dd>
Remove the item from the grid. Note that gui node will be not deleted 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 How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT) (<em>default</em> SHIFT.RIGHT)
</li> </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> </ul>
<h3>Returns:</h3> <h3>Returns:</h3>
@@ -776,7 +786,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -330,7 +330,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -688,7 +688,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -243,7 +243,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -522,7 +522,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -245,7 +245,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -814,6 +814,11 @@
If true, invert direction for touchpad and mouse wheel scroll If true, invert direction for touchpad and mouse wheel scroll
(<em>default</em> false) (<em>default</em> false)
</li> </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> </ul>
@@ -1113,7 +1118,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -421,7 +421,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -33,6 +33,7 @@
<h2>Contents</h2> <h2>Contents</h2>
<ul> <ul>
<li><a href="#Functions">Functions</a></li> <li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li> <li><a href="#Fields">Fields</a></li>
</ul> </ul>
@@ -98,11 +99,11 @@
<td class="summary">Set grid anchor.</td> <td class="summary">Set grid anchor.</td>
</tr> </tr>
<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> <td class="summary">Add new item to the grid</td>
</tr> </tr>
<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> <td class="summary">Remove the item from the grid.</td>
</tr> </tr>
<tr> <tr>
@@ -130,6 +131,13 @@
<td class="summary">Return StaticGrid offset, where StaticGrid content starts.</td> <td class="summary">Return StaticGrid offset, where StaticGrid content starts.</td>
</tr> </tr>
</table> </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> <h2><a href="#Fields">Fields</a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
@@ -343,7 +351,7 @@
</dd> </dd>
<dt> <dt>
<a name = "add"></a> <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> </dt>
<dd> <dd>
Add new item to the grid Add new item to the grid
@@ -369,6 +377,11 @@
How shift nodes, if required. See const.SHIFT How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT) (<em>default</em> SHIFT.RIGHT)
</li> </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> </ul>
@@ -378,7 +391,7 @@
</dd> </dd>
<dt> <dt>
<a name = "remove"></a> <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> </dt>
<dd> <dd>
Remove the item from the grid. Note that gui node will be not deleted 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 How shift nodes, if required. See const.SHIFT
(<em>default</em> SHIFT.RIGHT) (<em>default</em> SHIFT.RIGHT)
</li> </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> </ul>
<h3>Returns:</h3> <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> </dd>
</dl> </dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2> <h2 class="section-header "><a name="Fields"></a>Fields</h2>
@@ -831,7 +877,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -283,7 +283,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -33,6 +33,7 @@
<h2>Contents</h2> <h2>Contents</h2>
<ul> <ul>
<li><a href="#Functions">Functions</a></li> <li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li> <li><a href="#Fields">Fields</a></li>
</ul> </ul>
@@ -79,7 +80,7 @@
<h2><a href="#Functions">Functions</a></h2> <h2><a href="#Functions">Functions</a></h2>
<table class="function_list"> <table class="function_list">
<tr> <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> <td class="summary">Component init function</td>
</tr> </tr>
<tr> <tr>
@@ -110,6 +111,25 @@
<td class="name" nowrap><a href="#is_multiline">is_multiline(self)</a></td> <td class="name" nowrap><a href="#is_multiline">is_multiline(self)</a></td>
<td class="summary">Return true, if text with line break</td> <td class="summary">Return true, if text with line break</td>
</tr> </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> </table>
<h2><a href="#Fields">Fields</a></h2> <h2><a href="#Fields">Fields</a></h2>
<table class="function_list"> <table class="function_list">
@@ -130,6 +150,10 @@
<td class="summary">Text node</td> <td class="summary">Text node</td>
</tr> </tr>
<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="name" nowrap><a href="#pos">pos</a></td>
<td class="summary">Current text position</td> <td class="summary">Current text position</td>
</tr> </tr>
@@ -150,7 +174,7 @@
<td class="summary">Current text node available are</td> <td class="summary">Current text node available are</td>
</tr> </tr>
<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> <td class="summary">Current text size adjust settings</td>
</tr> </tr>
<tr> <tr>
@@ -168,7 +192,7 @@
<dl class="function"> <dl class="function">
<dt> <dt>
<a name = "init"></a> <a name = "init"></a>
<strong>init(self, node[, value[, no_adjust]])</strong> <strong>init(self, node[, value[, adjust_type=0]])</strong>
</dt> </dt>
<dd> <dd>
Component init function Component init function
@@ -189,10 +213,10 @@
Initial text. Default value is node text from GUI scene. Initial text. Default value is node text from GUI scene.
(<em>optional</em>) (<em>optional</em>)
</li> </li>
<li><span class="parameter">no_adjust</span> <li><span class="parameter">adjust_type</span>
<span class="types"><span class="type">bool</span></span> <span class="types"><span class="type">int</span></span>
If true, text will be not auto-adjust size Adjust type for text. By default is DOWNSCALE. Look const.TEXT_ADJUST for reference
(<em>optional</em>) (<em>default</em> 0)
</li> </li>
</ul> </ul>
@@ -247,6 +271,12 @@
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -272,6 +302,12 @@
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -297,6 +333,12 @@
</li> </li>
</ul> </ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">Text</span></span>
Current text instance
</ol>
@@ -322,6 +364,12 @@
</li> </li>
</ul> </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> <strong>set_pivot(self, pivot)</strong>
</dt> </dt>
<dd> <dd>
Set text pivot. Text will re-anchor inside Set text pivot. Text will re-anchor inside text area
his text area
<h3>Parameters:</h3> <h3>Parameters:</h3>
@@ -348,6 +395,12 @@
</li> </li>
</ul> </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> </dd>
</dl> </dl>
<h2 class="section-header "><a name="Fields"></a>Fields</h2> <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> </dd>
<dt> <dt>
<a name = "pos"></a> <a name = "pos"></a>
@@ -565,16 +768,16 @@
</dd> </dd>
<dt> <dt>
<a name = "is_no_adjust"></a> <a name = "adjust_type"></a>
<strong>is_no_adjust</strong> <strong>adjust_type</strong>
</dt> </dt>
<dd> <dd>
Current text size adjust settings Current text size adjust settings
<ul> <ul>
<li><span class="parameter">is_no_adjust</span> <li><span class="parameter">adjust_type</span>
<span class="types"><span class="type">bool</span></span> <span class="types"><span class="type">number</span></span>
</li> </li>
</ul> </ul>
@@ -611,7 +814,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -403,7 +403,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -92,6 +92,10 @@
<td class="summary">Check if node is enabled in gui hierarchy.</td> <td class="summary">Check if node is enabled in gui hierarchy.</td>
</tr> </tr>
<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="name" nowrap><a href="#get_pivot_offset">get_pivot_offset(pivot)</a></td>
<td class="summary">Get node offset for given gui pivot</td> <td class="summary">Get node offset for given gui pivot</td>
</tr> </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> </dd>
<dt> <dt>
<a name = "get_pivot_offset"></a> <a name = "get_pivot_offset"></a>
@@ -356,7 +387,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -314,7 +314,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@@ -1,5 +1,3 @@
# Druid components # Druid components
@@ -42,7 +40,7 @@ _fill example usecases_
Basic Druid text component. Text components by default have the text size adjusting. Basic Druid text component. Text components by default have the text size adjusting.
### Setup ### 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 ### 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_ - 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,6 +51,14 @@ Create text node with druid: `text = druid:new_text(node_name, [initial_value],
![](../media/text_anchor.gif) ![](../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
[Blocker API here](https://insality.github.io/druid/modules/Blocker.html) [Blocker API here](https://insality.github.io/druid/modules/Blocker.html)

View File

@@ -23,7 +23,7 @@ end
function M.update(self, dt) function M.update(self, dt)
end 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) function M.on_input(self, action_id, action)
end end
@@ -35,8 +35,12 @@ end
function M.on_message(self, message_id, message, sender) function M.on_message(self, message_id, message, sender)
end end
-- Call only if component with ON_ANGUAGECHANinterest -- Call only if component with ON_LANGUAGE_CHANGE interest
function M.on_anguagechanself) 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 end
-- Call only if component with ON_LAYOUT_CHANGE interest -- Call only if component with ON_LAYOUT_CHANGE interest
@@ -56,6 +60,10 @@ end
function M.on_focus_gained(self) function M.on_focus_gained(self)
end 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 -- Call on component remove or on druid:final
function M.on_remove(self) function M.on_remove(self)
end 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_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_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_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_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 ## Best practice on custom components
On each component recommended describe component scheme in next way: On each component recommended describe component scheme in next way:

View File

@@ -149,6 +149,7 @@ 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) Wanna something more? [Add an issues!](https://github.com/Insality/druid/issues)
Have a good day. Have a good day.
**Changelog 0.6.0** **Changelog 0.6.0**
--- ---
@@ -202,3 +203,70 @@ Have a good day.
- This is basic implementation, it is work not perfect - 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. - **#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 - **#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) --- Component to handle back key (android, backspace)
-- @module BackHandler -- @module BackHandler
-- @within BaseComponent -- @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 --- Component to block input on specify zone by node
-- @module Blocker -- @module Blocker
-- @within BaseComponent -- @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 --- Component to handle basic GUI button
-- @module Button -- @module Button
-- @within BaseComponent -- @within BaseComponent
@@ -24,6 +26,9 @@
---Trigger node ---Trigger node
-- @tfield node node -- @tfield node node
---The hash of trigger node
-- @tfield node_id hash
---Animation node ---Animation node
-- @tfield[opt=node] node anim_node -- @tfield[opt=node] node anim_node
@@ -52,7 +57,11 @@ local const = require("druid.const")
local helper = require("druid.helper") local helper = require("druid.helper")
local component = require("druid.component") 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) 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.style.on_click(self, self.anim_node)
self.click_in_row = self.click_in_row + 1 self.click_in_row = self.click_in_row + 1
self.on_repeated_click:trigger(self:get_context(), self.params, self, self.click_in_row) self.on_repeated_click:trigger(self:get_context(), self.params, self, self.click_in_row)
end end
@@ -126,7 +136,20 @@ local function on_button_release(self)
return false return false
end 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 if self.can_action then
self.can_action = false self.can_action = false
@@ -148,9 +171,6 @@ local function on_button_release(self)
self.last_released_time = time self.last_released_time = time
end end
return true return true
else
self.style.on_click_disabled(self, self.anim_node)
return false
end end
end end
@@ -190,6 +210,7 @@ end
function Button.init(self, node, callback, params, anim_node) function Button.init(self, node, callback, params, anim_node)
self.druid = self:get_druid() self.druid = self:get_druid()
self.node = self:get_node(node) 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.anim_node = anim_node and self:get_node(anim_node) or self.node
self.start_scale = gui.get_scale(self.anim_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.click_in_row = 0
self.key_trigger = nil self.key_trigger = nil
self._check_function = nil
self._failure_callback = nil
-- Event stubs -- Event stubs
self.on_click = Event(callback) self.on_click = Event(callback)
self.on_repeated_click = Event() self.on_repeated_click = Event()
@@ -214,6 +238,16 @@ function Button.init(self, node, callback, params, anim_node)
end 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) function Button.on_input(self, action_id, action)
if not is_input_match(self, action_id) then if not is_input_match(self, action_id) then
return false return false
@@ -288,6 +322,31 @@ function Button.on_input_interrupt(self)
end 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 --- Set enabled button component state
-- @tparam Button self -- @tparam Button self
-- @tparam bool state Enabled state -- @tparam bool state Enabled state
@@ -341,4 +400,14 @@ function Button.get_key_trigger(self)
end 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 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. --- Component to handle drag action on node.
-- Drag have correct handling for multitouch and swap -- Drag have correct handling for multitouch and swap
-- touched while dragging. Drag will be processed even -- touched while dragging. Drag will be processed even
@@ -49,7 +51,7 @@ local const = require("druid.const")
local helper = require("druid.helper") local helper = require("druid.helper")
local component = require("druid.component") 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) local function start_touch(self, touch)
@@ -187,6 +189,16 @@ function Drag.init(self, node, on_drag_callback)
end 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) function Drag.on_input_interrupt(self)
if self.is_drag or self.is_touch then if self.is_drag or self.is_touch then
end_touch(self) 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 --- Component to handle hover node interaction
-- @module Hover -- @module Hover
-- @within BaseComponent -- @within BaseComponent
@@ -16,7 +18,7 @@ local const = require("druid.const")
local helper = require("druid.helper") local helper = require("druid.helper")
local component = require("druid.component") 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 --- Component init function
@@ -36,6 +38,16 @@ function Hover.init(self, node, on_hover_callback)
end 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) function Hover.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return false 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. --- Component to handle scroll content.
-- Scroll consist from two nodes: scroll parent and scroll input -- Scroll consist from two nodes: scroll parent and scroll input
-- Scroll input the user input zone, it's static -- Scroll input the user input zone, it's static
@@ -59,7 +61,12 @@ local const = require("druid.const")
local helper = require("druid.helper") local helper = require("druid.helper")
local component = require("druid.component") 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) 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=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=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_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) function Scroll.on_style_change(self, style)
self.style = {} self.style = {}
self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0 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.SMALL_CONTENT_SCROLL = style.SMALL_CONTENT_SCROLL or false
self.style.WHEEL_SCROLL_SPEED = style.WHEEL_SCROLL_SPEED or 0 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_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._is_inert = not (self.style.FRICT == 0 or
self.style.FRICT_HOLD == 0 or self.style.FRICT_HOLD == 0 or
@@ -170,6 +179,16 @@ function Scroll.init(self, view_node, content_node)
end 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) function Scroll.on_layout_change(self)
gui.set_position(self.content_node, self.position) gui.set_position(self.content_node, self.position)
end end
@@ -597,11 +616,11 @@ end
function Scroll._check_threshold(self) function Scroll._check_threshold(self)
local is_stopped = false 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 is_stopped = true
self.inertion.x = 0 self.inertion.x = 0
end 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 is_stopped = true
self.inertion.y = 0 self.inertion.y = 0
end end
@@ -736,15 +755,28 @@ function Scroll._process_scroll_wheel(self, action_id, action)
return false return false
end end
local koef = (action_id == const.ACTION_SCROLL_UP) and 1 or -1 local koef = (action_id == const.ACTION_SCROLL_UP) and 1 or -1
if self.style.WHEEL_SCROLL_INVERTED then if self.style.WHEEL_SCROLL_INVERTED then
koef = -koef koef = -koef
end end
if self.drag.can_y then if self.style.WHEEL_SCROLL_BY_INERTION then
self.inertion.y = (self.inertion.y + self.style.WHEEL_SCROLL_SPEED * koef) * self.style.FRICT_HOLD 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 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 end
return true 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. --- Component to handle placing components by row and columns.
-- Grid can anchor your elements, get content size and other -- Grid can anchor your elements, get content size and other
-- @module StaticGrid -- @module StaticGrid
@@ -63,6 +65,17 @@ local function _extend_border(border, pos, size, pivot)
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=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 --- Component init function
-- @tparam StaticGrid self -- @tparam StaticGrid self
-- @tparam node parent The gui node parent, where items will be placed -- @tparam node parent The gui node parent, where items will be placed
@@ -167,7 +180,8 @@ end
-- @tparam node item Gui node -- @tparam node item Gui node
-- @tparam[opt] number index The item position. By default add as last item -- @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 -- @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 shift_policy = shift_policy or const.SHIFT.RIGHT
index = index or ((self.last_index or 0) + 1) 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_indexes()
self:_update_borders() 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_add_item:trigger(self:get_context(), item, index)
self.on_change_items:trigger(self:get_context(), index) self.on_change_items:trigger(self:get_context(), index)
@@ -204,8 +218,9 @@ end
-- @tparam StaticGrid self -- @tparam StaticGrid self
-- @tparam number index The grid node index to remove -- @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=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 -- @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 shift_policy = shift_policy or const.SHIFT.RIGHT
assert(self.nodes[index], "No grid item at given index " .. index) assert(self.nodes[index], "No grid item at given index " .. index)
@@ -223,7 +238,7 @@ function StaticGrid.remove(self, index, shift_policy)
end end
end end
self:_update() self:_update(is_instant)
self.on_remove_item:trigger(self:get_context(), index) self.on_remove_item:trigger(self:get_context(), index)
self.on_change_items: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 -- @tparam bool is_instant If true, node position update instantly, otherwise with set_position_function callback
-- @local -- @local
function StaticGrid._update_pos(self, is_instant) function StaticGrid._update_pos(self, is_instant)
local zero_offset = self:_get_zero_offset()
for i, node in pairs(self.nodes) do for i, node in pairs(self.nodes) do
local pos = self:get_pos(i) local pos = self:get_pos(i)
pos.x = pos.x + zero_offset.x
pos.y = pos.y + zero_offset.y
if is_instant then if is_instant then
gui.set_position(node, pos) gui.set_position(node, pos)
@@ -399,4 +418,23 @@ function StaticGrid._update_pos(self, is_instant)
end 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 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. --- Component to handle swipe gestures on node.
-- Swipe will be triggered, if swipe was started and -- Swipe will be triggered, if swipe was started and
-- ended on one node -- ended on one node
@@ -21,7 +23,7 @@ local const = require("druid.const")
local helper = require("druid.helper") local helper = require("druid.helper")
local component = require("druid.component") 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) local function start_swipe(self, action)
@@ -97,6 +99,16 @@ function Swipe.init(self, node, on_swipe_callback)
end 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) function Swipe.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then if action_id ~= const.ACTION_TOUCH then
return false 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. --- Component to handle all GUI texts.
-- Druid text can adjust itself for text node size -- Druid text can adjust itself for text node size
-- Text will never will be outside of his text size (even multiline) -- Text will never will be outside of his text size (even multiline)
@@ -17,6 +19,9 @@
--- Text node --- Text node
-- @tfield node node -- @tfield node node
--- The node id of text node
-- @tfield hash node_id
--- Current text position --- Current text position
-- @tfield vector3 pos -- @tfield vector3 pos
@@ -33,7 +38,7 @@
-- @tfield vector3 text_area -- @tfield vector3 text_area
--- Current text size adjust settings --- Current text size adjust settings
-- @tfield bool is_no_adjust -- @tfield number adjust_type
--- Current text color --- Current text color
-- @tfield vector3 color -- @tfield vector3 color
@@ -42,9 +47,10 @@
local Event = require("druid.event") local Event = require("druid.event")
local const = require("druid.const") local const = require("druid.const")
local utf8 = require("druid.system.utf8")
local component = require("druid.component") 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) local function update_text_size(self)
@@ -57,24 +63,36 @@ local function update_text_size(self)
end end
--- Setup scale x, but can only be smaller, than start text scale --- Reset initial scale for text
local function update_text_area_size(self) local function reset_default_scale(self)
gui.set_scale(self.node, self.start_scale) gui.set_scale(self.node, self.start_scale)
gui.set_size(self.node, self.start_size) 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_width = self.text_area.x
local max_height = self.text_area.y local max_height = self.text_area.y
local metrics = gui.get_text_metrics_from_node(self.node) 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 local scale_modifier = max_width / metrics.width
scale_modifier = math.min(scale_modifier, self.start_scale.x) scale_modifier = math.min(scale_modifier, self.start_scale.x)
local scale_modifier_height = max_height / metrics.height if self:is_multiline() then
scale_modifier = math.min(scale_modifier, scale_modifier_height) 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) gui.set_scale(self.node, new_scale)
self.scale = new_scale self.scale = new_scale
@@ -84,6 +102,33 @@ local function update_text_area_size(self)
end 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 -- calculate space width with font
local function get_space_width(self, font) local function get_space_width(self, font)
if not self._space_width[font] then if not self._space_width[font] then
@@ -96,15 +141,59 @@ local function get_space_width(self, font)
end 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 --- Component init function
-- @tparam Text self -- @tparam Text self
-- @tparam node node Gui text node -- @tparam node node Gui text node
-- @tparam[opt] string value Initial text. Default value is node text from GUI scene. -- @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 -- @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, no_adjust) function Text.init(self, node, value, adjust_type)
self.node = self:get_node(node) self.node = self:get_node(node)
self.pos = gui.get_position(self.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.start_scale = gui.get_scale(self.node)
self.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.x = self.text_area.x * self.start_scale.x
self.text_area.y = self.text_area.y * self.start_scale.y 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.color = gui.get_color(self.node)
self.on_set_text = Event() self.on_set_text = Event()
@@ -132,6 +221,17 @@ function Text.on_layout_change(self)
end 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 --- Calculate text width with font with respect to trailing space
-- @tparam Text self -- @tparam Text self
-- @tparam[opt] string text -- @tparam[opt] string text
@@ -156,49 +256,61 @@ end
--- Set text to text field --- Set text to text field
-- @tparam Text self -- @tparam Text self
-- @tparam string set_to Text for node -- @tparam string set_to Text for node
-- @treturn Text Current text instance
function Text.set_to(self, set_to) function Text.set_to(self, set_to)
set_to = set_to or ""
self.last_value = set_to self.last_value = set_to
gui.set_text(self.node, set_to) gui.set_text(self.node, set_to)
self.on_set_text:trigger(self:get_context(), set_to) self.on_set_text:trigger(self:get_context(), set_to)
if not self.is_no_adjust then update_adjust(self)
update_text_area_size(self)
end return self
end end
--- Set color --- Set color
-- @tparam Text self -- @tparam Text self
-- @tparam vector4 color Color for node -- @tparam vector4 color Color for node
-- @treturn Text Current text instance
function Text.set_color(self, color) function Text.set_color(self, color)
self.color = color self.color = color
gui.set_color(self.node, color) gui.set_color(self.node, color)
return self
end end
--- Set alpha --- Set alpha
-- @tparam Text self -- @tparam Text self
-- @tparam number alpha Alpha for node -- @tparam number alpha Alpha for node
-- @treturn Text Current text instance
function Text.set_alpha(self, alpha) function Text.set_alpha(self, alpha)
self.color.w = alpha self.color.w = alpha
gui.set_color(self.node, self.color) gui.set_color(self.node, self.color)
return self
end end
--- Set scale --- Set scale
-- @tparam Text self -- @tparam Text self
-- @tparam vector3 scale Scale for node -- @tparam vector3 scale Scale for node
-- @treturn Text Current text instance
function Text.set_scale(self, scale) function Text.set_scale(self, scale)
self.last_scale = scale self.last_scale = scale
gui.set_scale(self.node, scale) gui.set_scale(self.node, scale)
return self
end end
--- Set text pivot. Text will re-anchor inside --- Set text pivot. Text will re-anchor inside text area
-- his text area
-- @tparam Text self -- @tparam Text self
-- @tparam gui.pivot pivot Gui pivot constant -- @tparam gui.pivot pivot Gui pivot constant
-- @treturn Text Current text instance
function Text.set_pivot(self, pivot) function Text.set_pivot(self, pivot)
local prev_pivot = gui.get_pivot(self.node) local prev_pivot = gui.get_pivot(self.node)
local prev_offset = const.PIVOTS[prev_pivot] local prev_offset = const.PIVOTS[prev_pivot]
@@ -216,6 +328,8 @@ function Text.set_pivot(self, pivot)
gui.set_position(self.node, self.pos) gui.set_position(self.node, self.pos)
self.on_set_pivot:trigger(self:get_context(), pivot) self.on_set_pivot:trigger(self:get_context(), pivot)
return self
end end
@@ -227,4 +341,36 @@ function Text.is_multiline(self)
end 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 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. --- Basic class for all Druid components.
-- To create you component, use `component.create` -- To create you component, use `component.create`
-- @module BaseComponent -- @module BaseComponent
@@ -16,9 +18,11 @@ BaseComponent.ALL = const.ALL
BaseComponent.ON_INPUT = const.ON_INPUT BaseComponent.ON_INPUT = const.ON_INPUT
BaseComponent.ON_UPDATE = const.ON_UPDATE BaseComponent.ON_UPDATE = const.ON_UPDATE
BaseComponent.ON_MESSAGE = const.ON_MESSAGE 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_LOST = const.ON_FOCUS_LOST
BaseComponent.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED BaseComponent.ON_FOCUS_GAINED = const.ON_FOCUS_GAINED
BaseComponent.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE BaseComponent.ON_LAYOUT_CHANGE = const.ON_LAYOUT_CHANGE
BaseComponent.ON_MESSAGE_INPUT = const.ON_MESSAGE_INPUT
BaseComponent.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE BaseComponent.ON_LANGUAGE_CHANGE = const.ON_LANGUAGE_CHANGE
@@ -27,9 +31,11 @@ BaseComponent.ALL_INTERESTS = {
BaseComponent.ON_INPUT, BaseComponent.ON_INPUT,
BaseComponent.ON_UPDATE, BaseComponent.ON_UPDATE,
BaseComponent.ON_MESSAGE, BaseComponent.ON_MESSAGE,
BaseComponent.ON_LATE_INIT,
BaseComponent.ON_FOCUS_LOST, BaseComponent.ON_FOCUS_LOST,
BaseComponent.ON_FOCUS_GAINED, BaseComponent.ON_FOCUS_GAINED,
BaseComponent.ON_LAYOUT_CHANGE, BaseComponent.ON_LAYOUT_CHANGE,
BaseComponent.ON_MESSAGE_INPUT,
BaseComponent.ON_LANGUAGE_CHANGE, BaseComponent.ON_LANGUAGE_CHANGE,
} }
@@ -39,6 +45,7 @@ BaseComponent.SPECIFIC_UI_MESSAGES = {
[BaseComponent.ON_FOCUS_LOST] = "on_focus_lost", [BaseComponent.ON_FOCUS_LOST] = "on_focus_lost",
[BaseComponent.ON_FOCUS_GAINED] = "on_focus_gained", [BaseComponent.ON_FOCUS_GAINED] = "on_focus_gained",
[BaseComponent.ON_LAYOUT_CHANGE] = "on_layout_change", [BaseComponent.ON_LAYOUT_CHANGE] = "on_layout_change",
[BaseComponent.ON_MESSAGE_INPUT] = "on_message_input",
[BaseComponent.ON_LANGUAGE_CHANGE] = "on_language_change", [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 if self._component.input_priority ~= value then
self._component.input_priority = value self._component.input_priority = value
self._component._is_input_priority_changed = true 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 end
return self return self
@@ -351,6 +363,26 @@ function BaseComponent.__remove_children(self, children)
end 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 --- Create new component. It will inheritance from basic
-- druid component. -- druid component.
-- @tparam string name BaseComponent name -- @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 --- Druid constants
-- @local -- @local
-- @module DruidConst -- @module DruidConst
@@ -5,18 +7,21 @@
local M = {} local M = {}
M.ACTION_TEXT = hash("text") M.ACTION_TEXT = hash(sys.get_config("druid.input_text", "text"))
M.ACTION_MARKED_TEXT = hash("marked_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_ESC = hash(sys.get_config("druid.input_key_esc", "key_esc"))
M.ACTION_ENTER = hash("key_enter") M.ACTION_BACK = hash(sys.get_config("druid.input_key_back", "key_back"))
M.ACTION_BACK = hash("key_back") M.ACTION_ENTER = hash(sys.get_config("druid.input_key_enter", "key_enter"))
M.ACTION_ESC = hash("key_esc") 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(sys.get_config("druid.input_scroll_up", "scroll_up"))
M.ACTION_SCROLL_UP = hash("scroll_up") M.ACTION_SCROLL_DOWN = hash(sys.get_config("druid.input_scroll_down", "scroll_down"))
M.ACTION_MULTITOUCH = hash("multitouch")
M.ACTION_SCROLL_DOWN = hash("scroll_down")
M.IS_STENCIL_CHECK = sys.get_config("druid.stencil_check") == "1"
M.RELEASED = "released" M.RELEASED = "released"
@@ -31,9 +36,11 @@ M.ALL = "all"
M.ON_INPUT = hash("on_input") M.ON_INPUT = hash("on_input")
M.ON_UPDATE = hash("on_update") M.ON_UPDATE = hash("on_update")
M.ON_MESSAGE = hash("on_message") 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_LOST = hash("on_focus_lost")
M.ON_FOCUS_GAINED = hash("on_focus_gained") M.ON_FOCUS_GAINED = hash("on_focus_gained")
M.ON_LAYOUT_CHANGE = hash("layout_changed") M.ON_LAYOUT_CHANGE = hash("layout_changed")
M.ON_MESSAGE_INPUT = hash("on_message_input")
M.ON_LANGUAGE_CHANGE = hash("on_language_change") M.ON_LANGUAGE_CHANGE = hash("on_language_change")
@@ -42,6 +49,16 @@ M.PRIORITY_INPUT_HIGH = 20
M.PRIORITY_INPUT_MAX = 100 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 = { M.PIVOTS = {
[gui.PIVOT_CENTER] = vmath.vector3(0), [gui.PIVOT_CENTER] = vmath.vector3(0),
[gui.PIVOT_N] = vmath.vector3(0, 0.5, 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), [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.SYS_INFO = sys.get_sys_info()
M.CURRENT_SYSTEM_NAME = M.SYS_INFO.system_name 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 = { M.SIDE = {
X = "x", X = "x",
Y = "y" 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. --- Druid UI Library.
-- Powerful Defold component based UI library. Use standart -- Powerful Defold component based UI library. Use standart
-- components or make your own game-specific components to -- components or make your own game-specific components to
@@ -83,8 +85,7 @@ end
-- @tparam function callback Get localized text function -- @tparam function callback Get localized text function
function M.set_text_function(callback) function M.set_text_function(callback)
settings.get_text = callback or const.EMPTY_FUNCTION settings.get_text = callback or const.EMPTY_FUNCTION
-- TODO: Update all localized text M.on_language_change()
-- Need to store all current druid instances to iterate over it?
end 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 --- Lua event small library
-- @module DruidEvent -- @module DruidEvent
-- @alias druid_event -- @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 --- Druid checkbox component
-- @module Checkbox -- @module Checkbox
-- @within BaseComponent -- @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 --- Checkbox group module
-- @module CheckboxGroup -- @module CheckboxGroup
-- @within BaseComponent -- @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 --- Druid component template
-- @module druid.component -- @module druid.component
-- @local -- @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. --- Component to manage data for huge dataset in scroll.
-- It requires Druid Scroll and Druid Grid (Static or Dynamic) components -- It requires Druid Scroll and Druid Grid (Static or Dynamic) components
-- @module DataList -- @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 --- Component to handle placing components in row
-- @module DynamicGrid -- @module DynamicGrid
-- @within BaseComponent -- @within BaseComponent
@@ -138,7 +140,8 @@ end
-- @tparam node node Gui node -- @tparam node node Gui node
-- @tparam[opt] number index The node position. By default add as last 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 -- @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 shift_policy = shift_policy or const.SHIFT.RIGHT
local delta = shift_policy -- -1 or 1 or 0 local delta = shift_policy -- -1 or 1 or 0
@@ -168,7 +171,7 @@ function DynamicGrid.add(self, node, index, shift_policy)
end end
-- Sync grid data -- Sync grid data
self:_update() self:_update(is_instant)
self.on_add_item:trigger(self:get_context(), node, index) self.on_add_item:trigger(self:get_context(), node, index)
self.on_change_items:trigger(self:get_context(), index) self.on_change_items:trigger(self:get_context(), index)
@@ -179,8 +182,9 @@ end
-- @tparam DynamicGrid self -- @tparam DynamicGrid self
-- @tparam number index The grid node index to remove -- @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=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 -- @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 shift_policy = shift_policy or const.SHIFT.RIGHT
local delta = shift_policy -- -1 or 1 or 0 local delta = shift_policy -- -1 or 1 or 0
@@ -202,7 +206,7 @@ function DynamicGrid.remove(self, index, shift_policy)
end end
-- Sync grid data -- Sync grid data
self:_update() self:_update(is_instant)
self.on_remove_item:trigger(self:get_context(), index) self.on_remove_item:trigger(self:get_context(), index)
self.on_change_items: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. --- Druid input text component.
-- Carry on user text input -- Carry on user text input
-- @author Part of code from Britzl gooey input component -- @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 --- Component to handle all GUI texts
-- Good working with localization system -- Good working with localization system
-- @module LangText -- @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. --- Basic progress bar component.
-- For correct progress bar init it should be in max size from gui -- For correct progress bar init it should be in max size from gui
-- @module Progress -- @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 --- Radio group module
-- @module RadioGroup -- @module RadioGroup
-- @within BaseComponent -- @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 --- Druid slider component
-- @module Slider -- @module Slider
-- @within BaseComponent -- @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. --- Component to handle GUI timers.
-- Timer updating by game delta time. If game is not focused - -- Timer updating by game delta time. If game is not focused -
-- timer will be not updated. -- 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 -- Druid helper module for gui layouts
-- @module helper -- @module helper
@@ -169,6 +171,32 @@ function M.is_enabled(node)
end 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 --- Get node offset for given gui pivot
-- @function helper.get_pivot_offset -- @function helper.get_pivot_offset
-- @tparam gui.pivot pivot The node pivot -- @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 --- Druid inner module to acquire/release input
-- @module helper.input -- @module helper.input
-- @local -- @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 --- Druid module with utils on string formats
-- @local -- @local
-- @module helper.formats -- @module helper.formats
@@ -42,4 +44,4 @@ function M.interpolate_string(s, tab)
end 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 = {} 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 settings = require("druid.system.settings")
local anims = require("druid.styles.default.anims") 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"] = { M["scroll"] = {
ANIM_SPEED = 0.2, -- gui.animation speed to point ANIM_SPEED = 0.2, -- gui.animation speed to point
BACK_SPEED = 0.35, -- Lerp speed of return to soft position BACK_SPEED = 0.35, -- Lerp speed of return to soft position
@@ -65,8 +73,9 @@ M["scroll"] = {
INERT_SPEED = 30, -- koef. of inert speed INERT_SPEED = 30, -- koef. of inert speed
EXTRA_STRETCH_SIZE = 100, -- extra size in pixels outside of scroll (stretch effect) 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 POINTS_DEADZONE = 20, -- Speed to check points of interests in no_inertion mode
WHEEL_SCROLL_SPEED = 0, WHEEL_SCROLL_SPEED = 0, -- Amount of pixels to scroll by one wheel event (0 to disable)
WHEEL_SCROLL_INVERTED = false, 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 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 return M

View File

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

View File

@@ -1,3 +1,5 @@
-- Copyright (c) 2021 Maxim Tuprikov <insality@gmail.com>. This code is licensed under MIT license
local M = {} 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: --- Instance of Druid. Make one instance per gui_script with next code:
-- --
-- local druid = require("druid.druid") -- local druid = require("druid.druid")
@@ -132,8 +134,8 @@ local function check_sort_input_stack(self, components)
local component = components[i] local component = components[i]
if component:_is_input_priority_changed() then if component:_is_input_priority_changed() then
is_need_sort_input_stack = true is_need_sort_input_stack = true
component:_reset_input_priority_changed()
end end
component:_reset_input_priority_changed()
end end
if is_need_sort_input_stack then if is_need_sort_input_stack then
@@ -142,7 +144,35 @@ local function check_sort_input_stack(self, components)
end 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 if #components == 0 then
return is_input_consumed return is_input_consumed
end end
@@ -150,7 +180,7 @@ local function process_input(action_id, action, components, is_input_consumed)
for i = #components, 1, -1 do for i = #components, 1, -1 do
local component = components[i] local component = components[i]
local meta = component._meta 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 if not is_input_consumed then
is_input_consumed = component:on_input(action_id, action) is_input_consumed = component:on_input(action_id, action)
else else
@@ -177,6 +207,9 @@ function DruidInstance.initialize(self, context, style)
self._late_remove = {} self._late_remove = {}
self.url = msg.url() self.url = msg.url()
self._input_blacklist = nil
self._input_whitelist = nil
self.components = {} self.components = {}
for i = 1, #base_component.ALL_INTERESTS do for i = 1, #base_component.ALL_INTERESTS do
self.components[base_component.ALL_INTERESTS[i]] = {} self.components[base_component.ALL_INTERESTS[i]] = {}
@@ -192,13 +225,7 @@ end
function DruidInstance.create(self, component, ...) function DruidInstance.create(self, component, ...)
helper.deprecated("The druid:create is deprecated. Please use druid:new instead") helper.deprecated("The druid:create is deprecated. Please use druid:new instead")
local instance = create(self, component) return DruidInstance.new(self, component, ...)
if instance.init then
instance:init(...)
end
return instance
end end
@@ -283,6 +310,12 @@ end
-- @tparam DruidInstance self -- @tparam DruidInstance self
-- @tparam number dt Delta time -- @tparam number dt Delta time
function DruidInstance.update(self, dt) 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] local components = self.components[base_component.ON_UPDATE]
for i = 1, #components do for i = 1, #components do
components[i]:update(dt) components[i]:update(dt)
@@ -294,13 +327,13 @@ end
-- @tparam DruidInstance self -- @tparam DruidInstance self
-- @tparam hash action_id Action_id from on_input -- @tparam hash action_id Action_id from on_input
-- @tparam table action Action 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) function DruidInstance.on_input(self, action_id, action)
self._is_input_processing = true self._is_input_processing = true
local is_input_consumed = false
local components = self.components[base_component.ON_INPUT] local components = self.components[base_component.ON_INPUT]
check_sort_input_stack(self, components) 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 self._is_input_processing = false
@@ -321,9 +354,21 @@ end
-- @tparam table message Message from on_message -- @tparam table message Message from on_message
-- @tparam hash sender Sender from on_message -- @tparam hash sender Sender from on_message
function DruidInstance.on_message(self, message_id, message, sender) 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 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] local components = self.components[message_id]
if components then if components then
for i = 1, #components do for i = 1, #components do
@@ -376,6 +421,7 @@ end
--- Druid on language change. --- Druid on language change.
-- This one called by global gruid.on_language_change, but can be -- This one called by global gruid.on_language_change, but can be
-- call manualy to update all translations -- call manualy to update all translations
-- @tparam DruidInstance self
-- @function druid.on_language_change -- @function druid.on_language_change
function DruidInstance.on_language_change(self) function DruidInstance.on_language_change(self)
local components = self.components[base_component.ON_LANGUAGE_CHANGE] local components = self.components[base_component.ON_LANGUAGE_CHANGE]
@@ -385,6 +431,52 @@ function DruidInstance.on_language_change(self)
end end
--- Set whitelist components for input processing.
-- If whitelist is not empty and component not contains in this list,
-- component will be not processed on input step
-- @tparam DruidInstance self
-- @tparam[opt=nil] table|Component whitelist_components The array of component to whitelist
-- @function druid.set_whitelist
function DruidInstance.set_whitelist(self, whitelist_components)
if whitelist_components and whitelist_components.isInstanceOf then
whitelist_components = { whitelist_components }
end
for i = 1, #whitelist_components do
local component = whitelist_components[i]
local childrens = component:get_childrens()
for j = 1, #childrens do
table.insert(whitelist_components, childrens[j])
end
end
self._input_whitelist = whitelist_components
end
--- Set blacklist components for input processing.
-- If blacklist is not empty and component contains in this list,
-- component will be not processed on input step
-- @tparam DruidInstance self
-- @tparam[opt=nil] table|Component blacklist_components The array of component to blacklist
-- @function druid.set_blacklist
function DruidInstance.set_blacklist(self, blacklist_components)
if blacklist_components and blacklist_components.isInstanceOf then
blacklist_components = { blacklist_components }
end
for i = 1, #blacklist_components do
local component = blacklist_components[i]
local childrens = component:get_childrens()
for j = 1, #childrens do
table.insert(blacklist_components, childrens[j])
end
end
self._input_blacklist = blacklist_components
end
--- Create button basic component --- Create button basic component
-- @tparam DruidInstance self -- @tparam DruidInstance self
-- @tparam node node Gui node -- @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 --- Druid settings file
-- @module settings -- @module settings
-- @local -- @local

View File

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

View File

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

View File

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

View File

@@ -240,7 +240,7 @@ embedded_instances {
} }
} }
embedded_instances { embedded_instances {
id: "general_texts" id: "texts_general"
data: "components {\n" data: "components {\n"
" id: \"screen_factory\"\n" " id: \"screen_factory\"\n"
" component: \"/monarch/screen_factory.script\"\n" " component: \"/monarch/screen_factory.script\"\n"
@@ -257,7 +257,7 @@ embedded_instances {
" }\n" " }\n"
" properties {\n" " properties {\n"
" id: \"screen_id\"\n" " id: \"screen_id\"\n"
" value: \"general_texts\"\n" " value: \"texts_general\"\n"
" type: PROPERTY_TYPE_HASH\n" " type: PROPERTY_TYPE_HASH\n"
" }\n" " }\n"
" properties {\n" " properties {\n"
@@ -269,7 +269,7 @@ embedded_instances {
"embedded_components {\n" "embedded_components {\n"
" id: \"collectionfactory\"\n" " id: \"collectionfactory\"\n"
" type: \"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" "load_dynamically: false\\n"
"\"\n" "\"\n"
" position {\n" " position {\n"
@@ -869,6 +869,69 @@ embedded_instances {
z: 1.0 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 { embedded_instances {
id: "grid_animations" id: "grid_animations"
data: "components {\n" data: "components {\n"
@@ -932,3 +995,255 @@ embedded_instances {
z: 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 { nodes {
position { position {
x: -230.0 x: -240.0
y: -35.0 y: -35.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
@@ -910,7 +910,7 @@ nodes {
} }
nodes { nodes {
position { position {
x: 230.0 x: 240.0
y: -35.0 y: -35.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0
@@ -1093,7 +1093,7 @@ nodes {
w: 1.0 w: 1.0
} }
size { size {
x: 300.0 x: 360.0
y: 45.0 y: 45.0
z: 0.0 z: 0.0
w: 1.0 w: 1.0

View File

@@ -38,6 +38,10 @@ local function init_top_panel(self)
sys.open_url("https://insality.github.io/druid/") sys.open_url("https://insality.github.io/druid/")
end) 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") self.text_header = self.druid:new_text("text_header", "Druid")
end end
@@ -98,8 +102,6 @@ local function init_lobby(self)
self.lobby_grid:add(get_title(self, "General examples")) 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, "Overview", "general_overview"))
self.lobby_grid:add(get_button(self, "Buttons", "general_buttons")) 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, "Sliders", "general_sliders"))
self.lobby_grid:add(get_button(self, "Scrolls", "general_scroll")) self.lobby_grid:add(get_button(self, "Scrolls", "general_scroll"))
self.lobby_grid:add(get_button(self, "Grids", "general_grid")) self.lobby_grid:add(get_button(self, "Grids", "general_grid"))
@@ -110,13 +112,19 @@ local function init_lobby(self)
self.lobby_grid:add(get_button_disabled(self, "Swipe", "scene_name")) 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_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_title(self, "Scrolls"))
self.lobby_grid:add(get_button_disabled(self, "Nested scrolls", "scroll_scene")) 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, "With points of interest", "scroll_scene"))
self.lobby_grid:add(get_button_disabled(self, "Without inertion", "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_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, "Dynamic grid", "scroll_scene"))
self.lobby_grid:add(get_button_disabled(self, "Scroll binding", "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_button(self, "Add/Remove animations", "grid_animations"))
@@ -129,9 +137,11 @@ local function init_lobby(self)
self.lobby_grid:add(get_title(self, "System")) self.lobby_grid:add(get_title(self, "System"))
self.lobby_grid:add(get_button_disabled(self, "Styles")) 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, "Custom components"))
self.lobby_grid:add(get_button_disabled(self, "Component interests")) 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_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")) self.lobby_grid:add(get_button_disabled(self, "Input priority"))
end end

View File

@@ -1304,6 +1304,293 @@ nodes {
text_leading: 1.0 text_leading: 1.0
text_tracking: 0.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 { layers {
name: "image" name: "image"
} }

View File

@@ -27,6 +27,28 @@ local function double_tap_callback(self, params, button, click_in_row)
end 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) local function setup_buttons(self)
self.druid:new_button("button_usual/button", usual_callback) self.druid:new_button("button_usual/button", usual_callback)
@@ -48,6 +70,9 @@ local function setup_buttons(self)
-- Button with another node for animating -- Button with another node for animating
self.druid:new_button("button_anim/button", usual_callback, nil, "anim_node_icon") 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 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

View File

@@ -0,0 +1,37 @@
name: "texts_adjust"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"texts_adjust\"\n"
" component: \"/example/examples/texts/texts_adjust/texts_adjust.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,59 @@
local druid = require("druid.druid")
local const = require("druid.const")
function init(self)
self.druid = druid.new(self)
self.texts = {
self.druid:new_text("text_scale", nil, const.TEXT_ADJUST.DOWNSCALE),
self.druid:new_text("text_trim", nil, const.TEXT_ADJUST.TRIM),
self.druid:new_text("text_no_adjust", nil, const.TEXT_ADJUST.NO_ADJUST),
self.druid:new_text("text_scale_limited", nil, const.TEXT_ADJUST.DOWNSCALE_LIMITED)
:set_minimal_scale(0.5),
self.druid:new_text("text_scroll", nil, const.TEXT_ADJUST.SCROLL),
self.druid:new_text("text_scroll_scale", nil, const.TEXT_ADJUST.SCALE_THEN_SCROLL)
:set_minimal_scale(0.5)
}
local initial_texts = {}
local text_sizes = {}
for _, text in pairs(self.texts) do
initial_texts[text] = text.last_value
text_sizes[text] = 0
end
timer.delay(0.25, true, function()
for _, text in pairs(self.texts) do
local text_string = string.sub(initial_texts[text], 1, text_sizes[text])
text_sizes[text] = text_sizes[text] + 1
if text_sizes[text] > #initial_texts[text] then
text_sizes[text] = 0
end
text:set_to(text_string)
end
end)
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

@@ -4,7 +4,7 @@ embedded_instances {
id: "go" id: "go"
data: "components {\n" data: "components {\n"
" id: \"texts\"\n" " id: \"texts\"\n"
" component: \"/example/examples/general/texts/texts.gui\"\n" " component: \"/example/examples/texts/texts_general/texts_general.gui\"\n"
" position {\n" " position {\n"
" x: 0.0\n" " x: 0.0\n"
" y: 0.0\n" " y: 0.0\n"

View File

@@ -1,4 +1,4 @@
script: "/example/examples/general/texts/texts.gui_script" script: "/example/examples/texts/texts_general/texts_general.gui_script"
fonts { fonts {
name: "game" name: "game"
font: "/example/assets/fonts/game.font" font: "/example/assets/fonts/game.font"

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