Update ldoc

This commit is contained in:
Insality
2020-03-22 12:55:17 +03:00
parent 7b2578c0ef
commit d650c2393b
27 changed files with 167 additions and 60 deletions

View File

@@ -34,7 +34,9 @@
<ul>
<li><a href="#Setup">Setup </a></li>
<li><a href="#Components">Components </a></li>
<li><a href="#Creating_components">Creating components </a></li>
<li><a href="#Basic_usage">Basic usage </a></li>
<li><a href="#Druid_Events">Druid Events </a></li>
<li><a href="#Features">Features </a></li>
<li><a href="#Examples">Examples </a></li>
<li><a href="#Documentation">Documentation </a></li>
<li><a href="#Games_powered_by_Druid">Games powered by Druid </a></li>
@@ -83,9 +85,7 @@
<a href="https://insality.github.io/druid/"><img src="media/druid_logo.png" alt=""/></a></p>
<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 druid 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>
@@ -93,7 +93,7 @@
<h3>Dependency</h3>
<p>You can use the druid extension in your own project by adding this project as a <a href="https://www.defold.com/manuals/libraries/">Defold library dependency</a>. Open your game.project file and in the dependencies field under project add:</p>
<p>You can use the <strong>Druid</strong> extension in your own project by adding this project as a <a href="https://www.defold.com/manuals/libraries/">Defold library dependency</a>. Open your game.project file and in the dependencies field under project add:</p>
<blockquote>
<p><a href="https://github.com/Insality/druid/archive/master.zip">https://github.com/Insality/druid/archive/master.zip</a></p>
@@ -101,18 +101,42 @@
<p>Or point to the ZIP file of a <a href="https://github.com/Insality/druid/releases">specific release</a>.</p>
<h3>Input bindings</h3>
<h3>Code</h3>
<p>For <strong>Druid</strong> to work requires next input bindings:</p>
<p>Adjust druid settings, if needed:</p>
<ul>
<li>Mouse trigger - <code>Button 1</code> -> <code>touch</code> <em>For basic input components</em></li>
<li>Key trigger - <code>Backspace</code> -> <code>backspace</code> <em>For back</em>handler component_</li>
<li>Key trigger - <code>Back</code> -> <a href="../modules/druid.text.html#">text</a> <em>For back</em>handler component, Android back button_</li>
</ul>
<p><img src="media/input_binding.png" alt=""/></p>
<h3>Input capturing [optional]</h3>
<p>By default, <strong>Druid</strong> will auto-capture input focus, if any input component will be created. So you don't need to call <code>msg.post(&quot;.&quot;, &quot;acquire_input_focus)&quot;</code></p>
<p>If you not need this behaviour, you can disable it by settings <code>druid.no_auto_input</code> field in <em>game.project</em>:</p>
<pre><code> [druid]
no_auto_input = 1
</code></pre>
<h3>Code [optional]</h3>
<p>Adjust <strong>Druid</strong> settings, if needed:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="comment">-- Used for button component and custom components
</span><span class="comment">-- Callback should play sound by name
</span>druid.set_sound_function(callback)
<span class="comment">-- Used for lang_text component
</span><span class="comment">-- Callback should return localized string by locale id
</span>druid.set_text_function(callback)
<span class="comment">-- Used for change default druid style
@@ -124,7 +148,7 @@
<p><a name="Components"></a></p>
<h2>Components</h2>
<p>Druid provides next basic components:
<p><strong>Druid</strong> provides next basic components:
- <strong>Button</strong> - Basic game button</p>
<ul>
@@ -147,18 +171,26 @@
<p>Full info see on <em>components.md</em></p>
<p><a name="Creating_components"></a></p>
<h2>Creating components</h2>
<p><a name="Basic_usage"></a></p>
<h2>Basic usage</h2>
<p>For using <strong>Druid</strong>, first you should create Druid instance to spawn components. Pass to new Druid instance main engine functions: <em>update</em>, *on<em>message* and *on</em>input*</p>
<p>All <strong>Druid</strong> components as arguments can apply node name string, you can don't do <code>gui.get_node()</code> before</p>
<p>All <strong>Druid</strong> and component methods calling with <code>:</code> like <code>self.druid:new_button()</code></p>
<p>Any components creating via druid:</p>
<pre>
<span class="keyword">local</span> druid = <span class="global">require</span>(<span class="string">"druid.druid"</span>)
<span class="keyword">local</span> <span class="keyword">function</span> button_callback(self)
<span class="global">print</span>(<span class="string">"Button was clicked!"</span>)
<span class="keyword">end</span>
<span class="keyword">local</span> <span class="keyword">function</span> init(self)
self.druid = druid.new(self)
<span class="keyword">local</span> button = self.druid:new_button(node_name, callback)
<span class="keyword">local</span> text = self.druid:new_text(node_text_name)
self.druid:new_button(<span class="string">"button_node_name"</span>, button_callback)
<span class="keyword">end</span>
<span class="keyword">function</span> update(self, dt)
@@ -170,16 +202,36 @@
<span class="keyword">end</span>
<span class="keyword">function</span> on_input(self, action_id, action)
self.druid:on_input(action_id, action)
<span class="keyword">return</span> self.druid:on_input(action_id, action)
<span class="keyword">end</span>
</pre>
<p><a name="Druid_Events"></a></p>
<h2>Druid Events</h2>
<p>Any <strong>Druid</strong> components as callbacks uses Druid Events. In component API (<a href="https://insality.github.io/druid/modules/druid.button.html#Events">button example</a>) pointed list of component events. You can manually subscribe on this events by next API:</p>
<ul>
<li><p><strong>event:subscribe</strong>(callback)</p></li>
<li><p><strong>event:unsubscribe</strong>(callback)</p></li>
<li><p><strong>event:clear</strong>()</p></li>
</ul>
<p>Any events can handle several callbacks, if needed.</p>
<p><a name="Features"></a></p>
<h2>Features</h2>
<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>
</ul>
<p><a name="Examples"></a></p>
<h2>Examples</h2>
<p>See the <a href="https://github.com/insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use Druid</p>
<p>See the <a href="https://github.com/insality/druid/tree/develop/example/kenney">example folder</a> for examples of how to use <strong>Druid</strong></p>
<p>See the <a href="https://github.com/insality/druid-assets">druid-assets repository</a> for examples of how to create custom components and styles</p>
@@ -189,13 +241,13 @@
<p><a name="Documentation"></a></p>
<h2>Documentation</h2>
<p>To learn druid better, read next documentation:
- Druid components
- Create custom components
- Druid asset store
- Druid Styles</p>
<p>To learn <strong>Druid</strong> better, read next documentation:
- <a href="https://insality.github.io/druid/topics/01-components.md.html">Druid components</a>
- <a href="https://insality.github.io/druid/topics/02-creating_custom_components.md.html">Create custom components</a>
- <a href="https://insality.github.io/druid/topics/03-styles.md.html">Druid styles</a>
- <a href="https://insality.github.io/druid/topics/04-druid_assets.md.html">Druid asset store</a></p>
<p>Full druid documentation you can find here:
<p>Full <strong>Druid</strong> documentation you can find here:
https://insality.github.io/druid/</p>
@@ -211,7 +263,8 @@ https://insality.github.io/druid/</p>
<ul>
<li><p>Basic input component</p></li>
<li><p>Add on<em>layout</em>change support (to keep gui data between layout change)</p></li>
<li><p>Add on<em>change</em>language support (call single function to update all druid instance)</p></li>
<li><p>Add on<em>change</em>language support (call single function to update all Druid instance)</p></li>
<li><p>Unit tests</p></li>
<li><p>Better documentation and examples</p></li>
<li><p>Add more comfortable gamepad support for GUI (ability to select button with DPAD and other stuff)</p></li>
</ul>
@@ -224,19 +277,21 @@ https://insality.github.io/druid/</p>
<p>Developed and supporting by <a href="https://github.com/Insality">Insality</a></p>
<p>Assets from <a href="http://www.kenney.nl/">Kenney</a></p>
<p>MIT License</p>
<p><a name="Issues_and_suggestions"></a></p>
<h2>Issues and suggestions</h2>
<p>If you have any issues, questions or suggestions please <a href="https://github.com/Insality/druid/issues">create an issue</a> or contact me: <a href="mailto:insality@gmail.com">insality@gmail.com</a>
<p>If you have any issues, questions or suggestions please <a href="https://github.com/Insality/druid/issues">create an issue</a> or contact me: <a href="mailto:insality@gmail.com">insality@gmail.com</a>
</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-03-22 02:23:51 </i>
<i style="float:right;">Last updated 2020-03-22 12:55:11 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>