19 Commits
0.4.2 ... 0.4.4

Author SHA1 Message Date
Insality
bce68d9c35 Merge branch 'develop' 2020-07-19 13:11:15 +03:00
Insality
40b2837608 Add changelog 2020-07-19 13:10:54 +03:00
Insality
f182439f2a #76 add params for lang text string.format 2020-07-18 22:16:24 +03:00
Insality
a561892fb6 #80 fix hover function call set_enabled 2020-07-18 21:47:15 +03:00
Insality
3ba51f3e9d #79 fix remove in on_input, add grid page example 2020-07-18 21:42:51 +03:00
Insality
69dd2ce9e3 Add my editor scripts for gui 2020-06-18 01:58:42 +03:00
Insality
5f873c2305 Merge branch 'develop' 2020-06-14 20:15:07 +03:00
Insality
80ad0dc3b5 Increase Druid version 2020-06-14 20:14:49 +03:00
Insality
29137614ab Update docs 2020-06-14 20:14:05 +03:00
Insality
844f0dc356 #71 fix blocker input events 2020-06-14 20:09:23 +03:00
Insality
409657c12b #72 fix return in on_input functions 2020-06-14 13:34:30 +03:00
Insality
e8b1809321 #74 typo fix strech -> stretch 2020-06-14 13:26:22 +03:00
Insality
2ef288402e Typo fix in custom component 2020-06-14 13:23:21 +03:00
Insality
bf81bdfae0 Add custom component template 2020-06-14 13:23:01 +03:00
Insality
a2f8926cb0 Fix typo 2020-05-24 23:23:53 +03:00
Insality
e621edd654 Fix nodes component type check 2020-05-24 23:19:49 +03:00
Insality
474b97469e #69 Fix annotations in button component 2020-05-24 22:56:53 +03:00
Insality
d3a56f717e #62 Add release_input_focus on druid:final if auto_input enabled 2020-05-24 22:53:40 +03:00
Insality
f4f04a17df #65 Add hover set_enabled function, disabled button do not provide hover events 2020-05-24 22:48:46 +03:00
57 changed files with 1284 additions and 109 deletions

View File

@@ -5,7 +5,7 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/insality/druid)](https://github.com/Insality/druid/releases)
**Druid** - powerful defold component UI library. Use basic **Druid** components or make your own game-specific components to make amazing GUI in your games.
**Druid** - powerful Defold component UI library. Use basic **Druid** components or make your own game-specific components to make amazing GUI in your games.
## Setup
@@ -184,18 +184,19 @@ function on_message(self, message_id, message, sender)
end
```
- *final* required function for correct druid lifecycle
- *on_input* used for almost all basic druid components
- *update* used for progress bar, scroll and timer base components
- *on_message* used for specific druid events, like language change or layout change
- *final* used for custom components, what have to do several action before destroy
Recommended is fully integrate al druid lifecycles functions
Recommended is fully integrate all druid lifecycles functions
## Features
- Druid input goes as stack. Last created button will checked first. So create your GUI from back
- Don't forget about `return` in `on_input`: `return self.druid:on_input()`. It need, if you have more than 1 acquire inputs (several druid, other input system, etc)
- Druid by default do _acquire_input_focus_. So you don't need do it manually. Buy only if you have components, which requires _on_input_
## Examples

View File

@@ -200,7 +200,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -510,7 +510,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -218,7 +218,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -237,7 +237,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -99,11 +99,11 @@
<td class="summary">Return button enabled state</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone, Self)</a></td>
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="summary">Strict button click area.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_key_trigger">set_key_trigger(key, Self)</a></td>
<td class="name" nowrap><a href="#set_key_trigger">set_key_trigger(key)</a></td>
<td class="summary">Set key-code to trigger this button</td>
</tr>
<tr>
@@ -185,6 +185,12 @@
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
Current button instance
</ol>
@@ -212,7 +218,7 @@
</dd>
<dt>
<a name = "set_click_zone"></a>
<strong>set_click_zone(zone, Self)</strong>
<strong>set_click_zone(zone)</strong>
</dt>
<dd>
Strict button click area. Useful for
@@ -225,12 +231,14 @@
<span class="types"><span class="type">node</span></span>
Gui node
</li>
<li><span class="parameter">Self</span>
<span class="types"><span class="type">druid.button</span></span>
instance to make chain calls
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
Current button instance
</ol>
@@ -238,7 +246,7 @@
</dd>
<dt>
<a name = "set_key_trigger"></a>
<strong>set_key_trigger(key, Self)</strong>
<strong>set_key_trigger(key)</strong>
</dt>
<dd>
Set key-code to trigger this button
@@ -250,12 +258,14 @@
<span class="types"><span class="type">hash</span></span>
The action_id of the key
</li>
<li><span class="parameter">Self</span>
<span class="types"><span class="type">druid.button</span></span>
instance to make chain calls
</li>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">druid.button</span></span>
Current button instance
</ol>
@@ -438,7 +448,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -282,7 +282,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -242,7 +242,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -282,7 +282,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -374,7 +374,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -298,7 +298,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -102,6 +102,14 @@
<td class="name" nowrap><a href="#set_click_zone">set_click_zone(zone)</a></td>
<td class="summary">Strict hover click area.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_enabled">set_enabled(state)</a></td>
<td class="summary">Set enable state of hover component.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#is_enabled">is_enabled()</a></td>
<td class="summary">Return current hover enabled state</td>
</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
@@ -206,6 +214,49 @@
</dd>
<dt>
<a name = "set_enabled"></a>
<strong>set_enabled(state)</strong>
</dt>
<dd>
Set enable state of hover component.
If hover is not enabled, it will not generate
any hover events
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">state</span>
<span class="types"><span class="type">bool</span></span>
The hover enabled state
</li>
</ul>
</dd>
<dt>
<a name = "is_enabled"></a>
<strong>is_enabled()</strong>
</dt>
<dd>
Return current hover enabled state
<h3>Returns:</h3>
<ol>
<span class="types"><span class="type">bool</span></span>
The hover enabled state
</ol>
</dd>
</dl>
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
@@ -243,7 +294,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -329,7 +329,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -194,7 +194,7 @@
<ol>
<span class="types"><span class="type">druid.input</span></span>
Self instance to make chain calls
Current input instance
</ol>
@@ -223,7 +223,7 @@
<ol>
<span class="types"><span class="type">druid.input</span></span>
Self instance to make chain calls
Current input instance
</ol>
@@ -388,7 +388,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -243,7 +243,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -386,7 +386,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -242,7 +242,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -122,7 +122,7 @@
<td class="summary">Return if scroll have inertion.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#set_extra_strech_size">set_extra_strech_size([stretch_size=0])</a></td>
<td class="name" nowrap><a href="#set_extra_stretch_size">set_extra_stretch_size([stretch_size=0])</a></td>
<td class="summary">Set extra size for scroll stretching.</td>
</tr>
<tr>
@@ -311,7 +311,7 @@
<ol>
<span class="types"><span class="type">druid.scroll</span></span>
Self instance
Current scroll instance
</ol>
@@ -340,7 +340,7 @@
<ol>
<span class="types"><span class="type">druid.scroll</span></span>
Self instance
Current scroll instance
</ol>
@@ -368,8 +368,8 @@
</dd>
<dt>
<a name = "set_extra_strech_size"></a>
<strong>set_extra_strech_size([stretch_size=0])</strong>
<a name = "set_extra_stretch_size"></a>
<strong>set_extra_stretch_size([stretch_size=0])</strong>
</dt>
<dd>
Set extra size for scroll stretching.
@@ -389,7 +389,7 @@
<ol>
<span class="types"><span class="type">druid.scroll</span></span>
Self instance
Current scroll instance
</ol>
@@ -437,7 +437,7 @@
<ol>
<span class="types"><span class="type">druid.scroll</span></span>
Self instance
Current scroll instance
</ol>
@@ -586,7 +586,7 @@
Scroll gui.animation speed for scroll_to function
(<em>default</em> 0.2)
</li>
<li><span class="parameter">EXTRA_STRECH_SIZE</span>
<li><span class="parameter">EXTRA_STRETCH_SIZE</span>
<span class="types"><span class="type">number</span></span>
extra size in pixels outside of scroll (stretch effect)
(<em>default</em> 0)
@@ -610,7 +610,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -281,7 +281,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -256,7 +256,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -407,7 +407,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -296,7 +296,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -242,7 +242,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -913,7 +913,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -129,7 +129,8 @@ Where node name is name of node from GUI scene. You can use <code>node_name</cod
- **on_double_click** - different callback, if tap button 2+ in row, don'</span>t trigger <span class="keyword">if</span> callback is empty
</pre>
<p>- If button have double click event and it is triggered, usual callback will be not invoked
<p>- Click event will not trigger, if between pressed and released state cursor was outside of node zone
- If button have double click event and it is triggered, usual callback will be not invoked
- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use <a href="../modules/druid.button.html#set_click_zone">button:set_click_zone</a> to restrict button click zone
- Button can have key trigger to use then by key: <a href="../modules/druid.button.html#set_key_trigger">button:set_key_trigger</a>
- Animation node can be used for example to animate small icon on big panel. Node name of trigger zone will be <code>big panel</code> and animation node will be <code>small icon</code></p>
@@ -239,7 +240,7 @@ Where node name is name of node from GUI scene. You can use <code>node_name</cod
<p>- You can adjust scroll content size by <code>scroll:set_size(node_size)</code>. It will setup new size to <em>content node</em>
- You can enabled or disable inertion mode via <code>scroll:set_intert(state)</code>
- You can adjust extra stretch size via <code>scroll:set_extra_stretch_size</code>
- You can adjust extra stretch size via <a href="../modules/druid.scroll.html#set_extra_stretch_size">scroll:set_extra_stretch_size</a>
- Multitouch is required for scroll. Scroll is correctly handling touch_id swap while dragging scroll</p>
@@ -386,7 +387,8 @@ Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or ju
<h3>Notes</h3>
<p>- By default, hover handles <em>hover event</em> with pressed touch action_id. So it's mean, what mouse or touch have to be pressed
- On desktop platforms there is <em>on</em>mouse<em>hover</em> event. It's event on mouse hover without any action id</p>
- On desktop platforms there is <em>on</em>mouse<em>hover</em> event. It's event on mouse hover without any action id
- By default, assume what node is on not hovered state (both <em>hover</em> and <em>mouse</em>hover_)</p>
<p><a name="Swipe"></a></p>
@@ -463,7 +465,7 @@ Key is value from druid const: const.SIDE.X (or just "x") or const.SIDE.Y (or ju
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -121,8 +121,8 @@
</span><span class="keyword">function</span> M.on_message(self, message_id, message, sender)
<span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_LANGUAGE_CHANGE interest
</span><span class="keyword">function</span> M.on_language_change(self)
<span class="comment">-- Call only if component with ON_ANGUAGECHANinterest
</span><span class="keyword">function</span> M.on_anguagechanself)
<span class="keyword">end</span>
<span class="comment">-- Call only if component with ON_LAYOUT_CHANGE interest
@@ -245,7 +245,7 @@ There is next interests in druid:
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -155,7 +155,7 @@ You can pass <em>nil</em> or <em>empty</em>table_ to use default values for all
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -92,7 +92,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -90,7 +90,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -90,7 +90,7 @@
<p><a href="https://github.com/Insality/druid/releases"><img src="https://img.shields.io/github/v/release/insality/druid" alt="GitHub release (latest by date)"/></a></p>
<p><strong>Druid</strong> - powerful defold component UI library. Use basic <strong>Druid</strong> components or make your own game-specific components to make amazing GUI in your games.</p>
<p><strong>Druid</strong> - powerful Defold component UI library. Use basic <strong>Druid</strong> components or make your own game-specific components to make amazing GUI in your games.</p>
<p><a name="Setup"></a></p>
@@ -271,13 +271,13 @@
<ul>
<li><em>final</em> required function for correct druid lifecycle</li>
<li>*on_input* used for almost all basic druid components</li>
<li><em>update</em> used for progress bar, scroll and timer base components</li>
<li>*on_message* used for specific druid events, like language change or layout change</li>
<li><em>final</em> used for custom components, what have to do several action before destroy</li>
</ul>
<p>Recommended is fully integrate al druid lifecycles functions</p>
<p>Recommended is fully integrate all druid lifecycles functions</p>
<p><a name="Features"></a></p>
@@ -286,6 +286,7 @@
<ul>
<li>Druid input goes as stack. Last created button will checked first. So create your GUI from back</li>
<li>Don't forget about <code>return</code> in <code>on_input</code>: <code>return self.druid:on_input()</code>. It need, if you have more than 1 acquire inputs (several druid, other input system, etc)</li>
<li>Druid by default do <em>acquire</em>input<em>focus</em>. So you don't need do it manually. Buy only if you have components, which requires <em>on</em>input_ </li>
</ul>
@@ -339,7 +340,7 @@ https://insality.github.io/druid/</p>
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -72,8 +72,7 @@
<div id="content">
<p>Druid 0.3.0:</p>
Druid 0.3.0:</p>
<ul>
<li><p><code>Druid:final()</code> now is important function for correct working</p></li>
@@ -133,11 +132,11 @@
- on_drag_start (self)
- on_drag (self, dx, dy)
- on_drag_end (self)
- You can restriction side of draggin by changing _drag.can_x_ <span class="keyword">and</span> _drag.can_y_ fields
- You can setup drag deadzone to detect, when dragging is started (by default <span class="number">10</span> pixels)
- You can restriction side of dragging by changing _drag.can_x_ <span class="keyword">and</span> _drag.can_y_ fields
- You can setup drag deadzone to detect, when dragging is started (_by default <span class="number">10</span> pixels_)
</pre>
</li>
<li><p>Druid <em>Scroll</em> component fully reworked. Input logic moved to <em>Drag</em> component</p>
<li><p>[Breaking changes] Druid <em>Scroll</em> component fully reworked. Input logic moved to <em>Drag</em> component</p>
<pre>
- Update scroll documentation
@@ -151,7 +150,7 @@
- Different anchoring is supported (<span class="keyword">for</span> easier layouting)
- Function _scroll_to_ now accept position relative to _content node_. It's more easier <span class="keyword">for</span> handling. _Example:_ <span class="keyword">if</span> you have children node of _content_node_, you can pass this node position to scroll to this.
- **Resolve #<span class="number">52</span>**: _Content node size_ now can be less than _view node size_. In this case, content will be scrolled only inside _view size_ (can be disabled via style field: _SMALL_CONTENT_SCROLL_)
- **Fix #<span class="number">50</span>**: If style:SOFT_ZONE_SIZE equals to [<span class="number">0.</span>.<span class="number">1</span>], scroll can be disappeared
- **Fix #<span class="number">50</span>**: If style.SOFT_ZONE_SIZE equals to [<span class="number">0.</span>.<span class="number">1</span>], scroll can be disappeared
</pre>
</li>
<li><p>Druid <em>Grid</em> Update</p>
@@ -172,9 +171,9 @@
<pre>
- Styles <span class="global">table</span> now can be empty, every component have their default style values
- Remove <span class="backtick"><code>component:get_style</code></span> <span class="keyword">function</span>. Now style can be only set
- Remove <span class="backtick"><code>component:get_style</code></span> <span class="keyword">function</span>. Now you can only set styles
- To get style values <span class="keyword">in</span> component, add <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span>. It's invoked on <span class="backtick"><a href="../modules/component.html#set_style">component:set_style</a></span> <span class="keyword">function</span>
- You can look up default values inside <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span> <span class="keyword">or</span> style component API on Druid API
- You can look up default values inside <span class="backtick"><code>component:on_style_change</code></span> <span class="keyword">function</span> <span class="keyword">or</span> style component API on [Druid API](https://insality.github.<span class="global">io</span>/druid/index.html)
</pre>
</li>
<li><p>Druid update:</p>
@@ -183,17 +182,24 @@
- Now <span class="keyword">function</span> <span class="backtick"><code>druid:remove</code></span> remove instance <span class="keyword">and</span> all instance children components. No more manual deleting child components (#<span class="number">41</span>)
</pre>
</li>
<li><p><strong>Fix:</strong> Blocker component bug (blocker had very high priority, so it's block even button components, created after bloker)</p></li>
<li><p><strong>Fix:</strong> Blocker component bug (blocker had very high priority, so it's block even button components, created after blocker)</p></li>
<li><p><strong>Fix #58:</strong> Bug, when druid instance should be always named <a href="../modules/druid.html#">druid</a> (ex: <code>self.druid = druid.new(self)</code>)</p></li>
<li><p><strong>Fix #53:</strong> Bug with final <em>Druid instance</em> without any components</p></li>
</ul>
<p>Druid 0.5.0:
- <strong>Fix #61:</strong> Button component: fix button animation node creation
- <strong>Fix #64:</strong> Hover component: wrong mouse_hover default state
- <strong>Fix #71:</strong> Blocker: blocker now correct block mouse hover event
- <strong>Fix #72:</strong> Fix <code>return nil</code> in some <code>on_input</code> functions
- <strong>Fix #74:</strong> Fix typo: strech -> stretch. Scroll function <code>set_extra_stretch_size</code> renamed
</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2020-05-09 16:07:15 </i>
<i style="float:right;">Last updated 2020-06-14 20:13:02 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>

View File

@@ -25,6 +25,7 @@ Where node name is name of node from GUI scene. You can use `node_name` as input
- **on_long_click** - callback on long button tap, don't trigger if callback is empty
- **on_hold_click** - hold callback, before long_click trigger, don't trigger if callback is empty
- **on_double_click** - different callback, if tap button 2+ in row, don't trigger if callback is empty
- Click event will not trigger, if between pressed and released state cursor was outside of node zone
- If button have double click event and it is triggered, usual callback will be not invoked
- If you have stencil on buttons and you don't want trigger them outside of stencil node, you can use `button:set_click_zone` to restrict button click zone
- Button can have key trigger to use then by key: `button:set_key_trigger`

View File

@@ -36,8 +36,8 @@ end
function M.on_message(self, message_id, message, sender)
end
-- Call only if component with ON_LANGUAGE_CHANGE interest
function M.on_language_change(self)
-- Call only if component with ON_ANGUAGECHANinterest
function M.on_anguagechanself)
end
-- Call only if component with ON_LAYOUT_CHANGE interest

View File

@@ -96,3 +96,11 @@ Druid 0.4.0:
Druid 0.5.0:
- **Fix #61:** Button component: fix button animation node creation
- **Fix #64:** Hover component: wrong mouse_hover default state
- **Fix #71:** Blocker: blocker now correct block mouse hover event
- **Fix #72:** Fix `return nil` in some `on_input` functions
- **Fix #74:** Fix typo: strech -> stretch. Scroll function `set_extra_stretch_size` renamed
- **Fix #76:** Add params for lang text localization component
- **Fix #79:** Fix druid:remove inside on_input callback
- **Fix #80:** Fix hover set_enable typo function call
- Add `component.tempalte.lua` as template for Druid custom component

View File

@@ -29,7 +29,9 @@ end
function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then
if action_id ~= const.ACTION_TOUCH and
action_id ~= const.ACTION_MULTITOUCH and
action_id ~= nil then
return false
end

View File

@@ -265,9 +265,13 @@ end
--- Set enabled button component state
-- @function button:set_enabled
-- @tparam bool state Enabled state
-- @treturn druid.button Current button instance
function M.set_enabled(self, state)
self.disabled = not state
self.hover:set_enabled(state)
self.style.on_set_enabled(self, self.node, state)
return self
end
@@ -283,10 +287,11 @@ end
-- no click events outside stencil node
-- @function button:set_click_zone
-- @tparam node zone Gui node
-- @tparam druid.button Self instance to make chain calls
-- @treturn druid.button Current button instance
function M.set_click_zone(self, zone)
self.click_zone = self:get_node(zone)
self.hover:set_click_zone(zone)
return self
end
@@ -294,9 +299,10 @@ end
--- Set key-code to trigger this button
-- @function button:set_key_trigger
-- @tparam hash key The action_id of the key
-- @tparam druid.button Self instance to make chain calls
-- @treturn druid.button Current button instance
function M.set_key_trigger(self, key)
self.key_trigger = hash(key)
return self
end

View File

@@ -0,0 +1,64 @@
local const = require("druid.const")
local component = require("druid.component")
local M = component.create("my_component_name", { const.ON_UPDATE })
-- Component constructor
function M.init(self, ...)
end
-- Call only if exist interest: const.ON_UPDATE
function M.update(self, dt)
end
-- Call only if exist interest: const.ON_INPUT or const.ON_INPUT_HIGH
function M.on_input(self, action_id, action)
return false
end
-- Call on component creation and on component:set_style() function
function M.on_style_change(self, style)
end
-- Call only if exist interest: const.ON_MESSAGE
function M.on_message(self, message_id, message, sender)
end
-- Call only if component with ON_LANGUAGE_CHANGE interest
function M.on_language_change(self)
end
-- Call only if component with ON_LAYOUT_CHANGE interest
function M.on_layout_change(self)
end
-- Call, if input was capturing before this component
-- Example: scroll is start scrolling, so you need unhover button
function M.on_input_interrupt(self)
end
-- Call, if game lost focus. Need ON_FOCUS_LOST intereset
function M.on_focus_lost(self)
end
-- Call, if game gained focus. Need ON_FOCUS_GAINED intereset
function M.on_focus_gained(self)
end
-- Call on component remove or on druid:final
function M.on_remove(self)
end
return M

View File

@@ -172,7 +172,7 @@ end
function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then
return
return false
end
if not helper.is_enabled(self.node) then

View File

@@ -24,6 +24,8 @@ function M.init(self, node, on_hover_callback)
self._is_hovered = false
self._is_mouse_hovered = false
self._is_enabled = true
self.on_hover = Event(on_hover_callback)
self.on_mouse_hover = Event()
end
@@ -31,14 +33,14 @@ end
function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH and action_id ~= nil then
return
return false
end
if not action_id and helper.is_mobile() then
return false
end
if not helper.is_enabled(self.node) then
if not helper.is_enabled(self.node) or not self._is_enabled then
return false
end
@@ -63,7 +65,7 @@ end
function M.on_input_interrupt(self)
M.set_hover(self, false)
self:set_hover(false)
end
@@ -97,4 +99,31 @@ function M.set_click_zone(self, zone)
end
--- Set enable state of hover component.
-- If hover is not enabled, it will not generate
-- any hover events
-- @function hover:set_enabled
-- @tparam bool state The hover enabled state
function M.set_enabled(self, state)
self._is_enabled = state
if not state then
if self._is_hovered then
self:set_hover(false)
end
if self._is_mouse_hovered then
self:set_mouse_hover(false)
end
end
end
--- Return current hover enabled state
-- @function hover:is_enabled
-- @treturn bool The hover enabled state
function M.is_enabled(self)
return self._is_enabled
end
return M

View File

@@ -282,7 +282,7 @@ end
-- Pass nil to make input field unliminted (by default)
-- @function input:set_max_length
-- @tparam number max_length Maximum length for input text field
-- @treturn druid.input Self instance to make chain calls
-- @treturn druid.input Current input instance
function M.set_max_length(self, max_length)
self.max_length = max_length
return self
@@ -294,7 +294,7 @@ end
-- ex: [%a%d] for alpha and numeric
-- @function input:set_allowerd_characters
-- @tparam string characters Regulax exp. for validate user input
-- @treturn druid.input Self instance to make chain calls
-- @treturn druid.input Current input instance
function M.set_allowed_characters(self, characters)
self.allowed_characters = characters
return self

View File

@@ -26,6 +26,7 @@ local M = component.create("lang_text", { const.ON_LANGUAGE_CHANGE })
function M.init(self, node, locale_id, no_adjust)
self.druid = self:get_druid()
self.text = self.druid:new_text(node, locale_id, no_adjust)
self.last_locale_args = {}
self.on_change = Event()
@@ -37,7 +38,7 @@ end
function M.on_language_change(self)
if self.last_locale then
M.translate(self)
M.translate(self, self.last_locale, unpack(self.last_locale_args))
end
end
@@ -55,9 +56,10 @@ end
--- Translate the text by locale_id
-- @function lang_text:translate
-- @tparam string locale_id Locale id
function M.translate(self, locale_id)
function M.translate(self, locale_id, ...)
self.last_locale_args = {...}
self.last_locale = locale_id or self.last_locale
self.text:set_to(settings.get_text(self.last_locale))
self.text:set_to(settings.get_text(self.last_locale, ...))
end

View File

@@ -290,7 +290,7 @@ local function update_size(self)
-- We add extra size only if scroll is available
-- Even the content zone size less than view zone size
local content_border_extra = helper.get_border(self.content_node)
local stretch_size = self.style.EXTRA_STRECH_SIZE
local stretch_size = self.style.EXTRA_STRETCH_SIZE
if self.drag.can_x then
local sign = content_size.x > view_size.x and 1 or -1
@@ -325,11 +325,11 @@ end
-- @tfield[opt=20] number POINTS_DEADZONE Speed to check points of interests in no_inertion mode
-- @tfield[opt=0.35] number BACK_SPEED Scroll back returning lerp speed
-- @tfield[opt=0.2] number ANIM_SPEED Scroll gui.animation speed for scroll_to function
-- @tfield[opt=0] number EXTRA_STRECH_SIZE extra size in pixels outside of scroll (stretch effect)
-- @tfield[opt=0] number EXTRA_STRETCH_SIZE extra size in pixels outside of scroll (stretch effect)
-- @tfield[opt=false] bool SMALL_CONTENT_SCROLL If true, content node with size less than view node size can be scrolled
function M.on_style_change(self, style)
self.style = {}
self.style.EXTRA_STRECH_SIZE = style.EXTRA_STRECH_SIZE or 0
self.style.EXTRA_STRETCH_SIZE = style.EXTRA_STRETCH_SIZE or 0
self.style.ANIM_SPEED = style.ANIM_SPEED or 0.2
self.style.BACK_SPEED = style.BACK_SPEED or 0.35
@@ -473,7 +473,7 @@ end
-- It will change content gui node size
-- @function scroll:set_size
-- @tparam vector3 size The new size for content node
-- @treturn druid.scroll Self instance
-- @treturn druid.scroll Current scroll instance
function M.set_size(self, size)
gui.set_size(self.content_node, size)
update_size(self)
@@ -487,9 +487,10 @@ end
-- If no points, just simple drag without inertion
-- @function scroll:set_inert
-- @tparam bool state Inert scroll state
-- @treturn druid.scroll Self instance
-- @treturn druid.scroll Current scroll instance
function M.set_inert(self, state)
self._is_inert = state
return self
end
@@ -504,11 +505,11 @@ end
--- Set extra size for scroll stretching.
-- Set 0 to disable stretching effect
-- @function scroll:set_extra_strech_size
-- @function scroll:set_extra_stretch_size
-- @tparam[opt=0] number stretch_size Size in pixels of additional scroll area
-- @treturn druid.scroll Self instance
function M.set_extra_strech_size(self, stretch_size)
self.style.EXTRA_STRECH_SIZE = stretch_size or 0
-- @treturn druid.scroll Current scroll instance
function M.set_extra_stretch_size(self, stretch_size)
self.style.EXTRA_STRETCH_SIZE = stretch_size or 0
update_size(self)
return self
@@ -527,7 +528,7 @@ end
-- Scroll will always centered on closer points
-- @function scroll:set_points
-- @tparam table points Array of vector3 points
-- @treturn druid.scroll Self instance
-- @treturn druid.scroll Current scroll instance
function M.set_points(self, points)
self.points = points

View File

@@ -95,7 +95,7 @@ end
function M.on_input(self, action_id, action)
if action_id ~= const.ACTION_TOUCH then
return
return false
end
if not helper.is_enabled(self.node) then

View File

@@ -109,13 +109,15 @@ function Component.get_node(self, node_or_name)
template_name = template_name .. "/"
end
local node_type = type(node_or_name)
if nodes then
assert(type(node_or_name) == "strings", "You should pass node name instead of node")
assert(node_type == const.STRING, "You should pass node name instead of node")
return nodes[template_name .. node_or_name]
else
if type(node_or_name) == const.STRING then
if node_type == const.STRING then
return gui.get_node(template_name .. node_or_name)
else
-- Assume it's already node from gui.get_node
return node_or_name
end
end

View File

@@ -63,7 +63,7 @@ M["scroll"] = {
FRICT_HOLD = 0.79, -- mult. for inert, while touching
INERT_THRESHOLD = 2.5, -- speed to stop inertion
INERT_SPEED = 30, -- koef. of inert speed
EXTRA_STRECH_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
SCROLL_WHEEL_SPEED = 20,

View File

@@ -58,6 +58,18 @@ local function input_init(self)
end
local function input_release(self)
if sys.get_config("druid.no_auto_input") == "1" then
return
end
if self.input_inited then
self.input_inited = false
druid_input.remove()
end
end
-- Create the component itself
local function create(self, instance_class)
local instance = instance_class()
@@ -123,6 +135,8 @@ function Druid.initialize(self, context, style)
self._context = context
self._style = style or settings.default_style
self._deleted = false
self._is_input_processing = false
self._late_remove = {}
self.url = msg.url()
self.components = {}
@@ -160,6 +174,8 @@ function Druid.final(self)
end
self._deleted = true
input_release(self)
end
@@ -168,10 +184,15 @@ end
-- @function druid:remove
-- @tparam Component component Component instance
function Druid.remove(self, component)
if self._is_input_processing then
table.insert(self._late_remove, component)
return
end
local all_components = self.components[const.ALL]
-- Recursive remove all children of component
for i = 1, #all_components do
for i = #all_components, 1, -1 do
local inst = all_components[i]
if inst:is_child_of(component) then
self:remove(inst)
@@ -183,7 +204,7 @@ function Druid.remove(self, component)
if component.on_remove then
component:on_remove()
end
table.remove(self, i)
table.remove(all_components, i)
end
end
@@ -216,6 +237,8 @@ end
-- @tparam hash action_id Action_id from on_input
-- @tparam table action Action from on_input
function Druid.on_input(self, action_id, action)
self._is_input_processing = true
local is_input_consumed = false
is_input_consumed = process_input(action_id, action,
@@ -224,6 +247,15 @@ function Druid.on_input(self, action_id, action)
is_input_consumed = process_input(action_id, action,
self.components[const.ON_INPUT], is_input_consumed)
self._is_input_processing = false
if #self._late_remove > 0 then
for i = 1, #self._late_remove do
self:remove(self._late_remove[i])
end
self._late_remove = {}
end
return is_input_consumed
end

View File

@@ -6,7 +6,8 @@ local M = {}
M.default_style = nil
function M.get_text(name)
function M.get_text(name, ...)
return "[Druid]: locales not inited"
end

View File

@@ -0,0 +1,76 @@
--- @license MIT, Insality 2020
--- @source https://github.com/Insality/druid
local M = {}
local function ends_with(str, ending)
return ending == "" or str:sub(-#ending) == ending
end
function M.get_commands()
return {
{
label = "Print gui scheme",
locations = { "Outline" },
query = {
selection = {type = "outline", cardinality = "many"}
},
active = function(opts)
return true
end,
run = function(opts)
print("local SCHEME = {")
for i = 1, #opts.selection do
local file = opts.selection[i]
if editor.can_get(file, "id") then
local id = editor.get(file, "id")
print("\t" .. string.upper(id) .. " = \"" .. id .. "\",")
end
end
print("}")
print("")
end
},
{
label = "Assign layers",
locations = {"Edit"},
query = {
selection = {type = "resource", cardinality = "one"}
},
active = function(opts)
local path = editor.get(opts.selection, "path")
return ends_with(path, ".gui")
end,
run = function(opts)
local file = opts.selection
print("Run script for", editor.get(file, "path"))
return {
{
action = "shell",
command = {
"bash",
"./editor_scripts/setup_layers.sh",
"." .. editor.get(file, "path")
}
}
}
end
}
}
end
return M

View File

@@ -0,0 +1,44 @@
# @license MIT, Insality 2020
# @source https://github.com/Insality/druid
import sys
import deftree
def main():
filename = sys.argv[1]
print("Auto setup layers for file", filename)
tree = deftree.parse(filename)
root = tree.get_root()
layers = []
for texture in root.iter_elements("textures"):
layers.append(texture.get_attribute("name").value)
for fonts in root.iter_elements("fonts"):
layers.append(fonts.get_attribute("name").value)
to_remove_layers = []
for layer in root.iter_elements("layers"):
to_remove_layers.append(layer)
for layer in to_remove_layers:
root.remove(layer)
for layer in layers:
new_layer = root.add_element("layers")
new_layer.add_attribute("name", layer)
for node in root.iter_elements("nodes"):
texture = node.get_attribute("texture")
font = node.get_attribute("font")
if texture:
layer = texture.value.split("/")[0]
node.set_attribute("layer", layer)
if font:
layer = font.value
node.set_attribute("layer", layer)
tree.write()
main()

8
editor_scripts/setup_layers.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
# @license MIT, Insality 2020
# @source https://github.com/Insality/druid
echo "Run bash for $1"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
/usr/local/bin/python3.7 $DIR/setup_layers.py $@

View File

@@ -9693,6 +9693,766 @@ nodes {
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 3600.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: 1.0
y: 1.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "grid_page"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_STRETCH
parent: "C_Anchor"
layer: "image"
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_AUTO
}
nodes {
position {
x: 0.0
y: 200.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 400.0
y: 400.0
z: 0.0
w: 1.0
}
color {
x: 0.8
y: 1.0
z: 0.8
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: ""
id: "grid_nodes"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_N
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page"
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: -150.0
y: 250.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_add"
parent: "grid_page"
layer: ""
inherit_alpha: true
alpha: 1.0
template: "/example/templates/button.gui"
template_node_child: false
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 130.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "button_add/button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_add"
layer: "image"
inherit_alpha: true
slice9 {
x: 15.0
y: 15.0
z: 15.0
w: 15.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 7.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.7
y: 0.7
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Add"
font: "game"
id: "button_add/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 0.101960786
y: 0.2
z: 0.6
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "button_add/button"
layer: "text"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 0.0
y: 250.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEMPLATE
id: "button_remove"
parent: "grid_page"
layer: ""
inherit_alpha: true
alpha: 1.0
template: "/example/templates/button.gui"
template_node_child: false
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 130.0
y: 60.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/button_blue"
id: "button_remove/button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_remove"
layer: "image"
inherit_alpha: true
slice9 {
x: 15.0
y: 15.0
z: 15.0
w: 15.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 7.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.7
y: 0.7
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Remove"
font: "game"
id: "button_remove/text"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
outline {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
shadow {
x: 0.101960786
y: 0.2
z: 0.6
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "button_remove/button"
layer: "text"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 150.0
y: 250.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_clear"
parent: "grid_page"
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_clear/button"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "button_clear"
layer: "image"
inherit_alpha: true
slice9 {
x: 15.0
y: 15.0
z: 15.0
w: 15.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: true
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 7.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 0.7
y: 0.7
z: 1.0
w: 1.0
}
size {
x: 200.0
y: 100.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "Clear"
font: "game"
id: "button_clear/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_clear/button"
layer: "text"
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.78
overridden_fields: 8
template_node_child: true
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: -160.0
y: 160.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
size {
x: 80.0
y: 80.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_BOX
blend_mode: BLEND_MODE_ALPHA
texture: "kenney/empty"
id: "grid_nodes_prefab"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "grid_page"
layer: ""
inherit_alpha: true
slice9 {
x: 0.0
y: 0.0
z: 0.0
w: 0.0
}
clipping_mode: CLIPPING_MODE_NONE
clipping_visible: true
clipping_inverted: false
alpha: 1.0
template_node_child: false
size_mode: SIZE_MODE_MANUAL
}
nodes {
position {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale {
x: 1.5
y: 1.5
z: 1.0
w: 1.0
}
size {
x: 36.0
y: 36.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/slider_move"
id: "grid_nodes_dot"
xanchor: XANCHOR_NONE
yanchor: YANCHOR_NONE
pivot: PIVOT_CENTER
adjust_mode: ADJUST_MODE_FIT
parent: "grid_nodes_prefab"
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_AUTO
}
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: 0.75
y: 0.75
z: 1.0
w: 1.0
}
size {
x: 50.0
y: 50.0
z: 0.0
w: 1.0
}
color {
x: 1.0
y: 1.0
z: 1.0
w: 1.0
}
type: TYPE_TEXT
blend_mode: BLEND_MODE_ALPHA
text: "1"
font: "game"
id: "grid_nodes_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: 1.0
y: 1.0
z: 1.0
w: 1.0
}
adjust_mode: ADJUST_MODE_FIT
line_break: false
parent: "grid_nodes_dot"
layer: ""
inherit_alpha: true
alpha: 1.0
outline_alpha: 0.0
shadow_alpha: 0.0
template_node_child: false
text_leading: 1.0
text_tracking: 0.0
}
nodes {
position {
x: 0.0

View File

@@ -9,6 +9,7 @@ local button_page = require("example.page.button_page")
local scroll_page = require("example.page.scroll_page")
local slider_page = require("example.page.slider_page")
local input_page = require("example.page.input_page")
local grid_page = require("example.page.grid_page")
local pages = {
"main_page",
@@ -17,6 +18,7 @@ local pages = {
"scroll_page",
"slider_page",
"input_page",
"grid_page",
}
local function on_control_button(self, delta)
@@ -70,6 +72,7 @@ function init(self)
scroll_page.setup_page(self)
slider_page.setup_page(self)
input_page.setup_page(self)
grid_page.setup_page(self)
init_top_panel(self)

View File

@@ -7,8 +7,8 @@ local function setup_druid()
sound.play("kenney:/sound#" .. name)
end)
druid.set_text_function(function(lang_id)
return lang.get_locale(lang_id)
druid.set_text_function(function(lang_id, ...)
return lang.get_locale(lang_id, ...)
end)
druid.on_language_change()

View File

@@ -9,6 +9,7 @@ local en = {
scroll_page = "Scroll page",
slider_page = "Slider page",
input_page = "Input page",
grid_page = "Grid page",
ui_section_button = "Button",
ui_section_text = "Text",
ui_section_timer = "Timer",
@@ -27,6 +28,7 @@ local ru = {
scroll_page = "Скролл",
slider_page = "Слайдеры",
input_page = "Текст. ввод",
grid_page = "Сетка",
ui_section_button = "Кнопка",
ui_section_text = "Текст",
ui_section_timer = "Таймер",
@@ -42,8 +44,14 @@ local ru = {
local data = en
function M.get_locale(lang_id)
return data[lang_id] or lang_id
function M.get_locale(lang_id, ...)
local localized_text = data[lang_id] or lang_id
if #{...} > 0 then
localized_text = string.format(localized_text, ...)
end
return localized_text
end

View File

@@ -0,0 +1,57 @@
local M = {}
local function add_node(self)
local prefab = gui.get_node("grid_nodes_prefab")
local cloned = gui.clone_tree(prefab)
gui.set_enabled(cloned["grid_nodes_prefab"], true)
local index = #self.grid_nodes + 1
gui.set_text(cloned["grid_nodes_text"], index)
local button = self.druid:new_button(cloned["grid_nodes_prefab"], function()
print(index)
end)
table.insert(self.grid_node_buttons, button)
self.grid_nodes:add(cloned["grid_nodes_prefab"])
end
local function clear_nodes(self)
local nodes = self.grid_nodes.nodes
for i = 1, #nodes do
gui.delete_node(nodes[i])
end
for i = 1, #self.grid_node_buttons do
self.druid:remove(self.grid_node_buttons[i])
end
self.grid_node_buttons = {}
self.grid_nodes:clear()
end
local function remove_node(self)
-- Remove is not implemented yet
end
function M.setup_page(self)
self.grid_nodes = self.druid:new_grid("grid_nodes", "grid_nodes_prefab", 5)
self.grid_node_buttons = {}
gui.set_enabled(gui.get_node("grid_nodes_prefab"), false)
for i = 1, 15 do
add_node(self)
end
self.druid:new_button("button_add/button", add_node)
self.druid:new_button("button_clear/button", clear_nodes)
local remove_button = self.druid:new_button("button_remove/button", remove_node)
gui.set_enabled(remove_button.node, false)
end
return M

View File

@@ -54,7 +54,7 @@ function M.setup_page(self)
-- Content with less size than view
self.druid:new_scroll("scroll_smaller_view", "scroll_smaller_content")
:set_extra_strech_size(0)
:set_extra_stretch_size(0)
:set_inert(false)
-- Scroll with points of interests

View File

@@ -10,7 +10,7 @@ height = 900
[project]
title = druid
version = 0.4.0
version = 0.4.3
[library]
include_dirs = druid