1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 17:19:31 +00:00

Update and rebuild docs

This commit is contained in:
Étienne Fildadut 2022-09-16 20:07:53 +09:00
parent 21679dde5c
commit 7ad5c2d641
19 changed files with 3026 additions and 949 deletions

View file

@ -35,6 +35,7 @@
<ul>
<li><a href="#Module">Module </a></li>
<li><a href="#SignalRegistry_objects">SignalRegistry objects </a></li>
<li><a href="#SignalGroup_objects">SignalGroup objects </a></li>
</ul>
@ -43,6 +44,7 @@
<li><a href="../modules/ubiquitousse.html">ubiquitousse</a></li>
<li><a href="../modules/asset.html">asset</a></li>
<li><a href="../modules/ecs.html">ecs</a></li>
<li><a href="../modules/input.html">input</a></li>
<li><a href="../modules/ldtk.html">ldtk</a></li>
<li><a href="../modules/scene.html">scene</a></li>
<li><strong>signal</strong></li>
@ -60,12 +62,31 @@
<div id="content">
<h1>Module <code>signal</code></h1>
<p>Signal management for Lua.</p>
<p> No dependency.
Optional dependency: LÖVE to hook into LÖVE events.</p>
<p>Simple signal / observer pattern implementation for Lua.</p>
<p>No dependency.
Optional dependency: LÖVE to hook into LÖVE events.</p>
<p>The returned module also acts as a global <a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a>, so you can call the <code>:bind</code>, <code>:emit</code>, etc. methods directly on the module
if you don&rsquo;t need to isolate your signals in separate registries.</p>
<h3>Usage:</h3>
<ul>
<pre class="example">TODO
<pre class="example">local signal = require(&quot;ubiquitousse.signal&quot;)
-- Bind a function to a &quot;hit&quot; signal
signal:bind(&quot;hit&quot;, function(enemy)
print(enemy..&quot; was hit!&quot;)
end)
-- Somewhere else in your code: will call every function bound to &quot;hit&quot; signal with &quot;invader&quot; argument
signal:emit(&quot;hit&quot;, &quot;invader&quot;)
-- We also provides a predefined SignalRegistry (signal.event) which emit signals on LÖVE callbacks
-- You can initialize it with:
signal.registerEvents()
signal.event:bind(&quot;update&quot;, function(dt) print(&quot;called every update&quot;) end)
signal.event:bind(&quot;keypressed&quot;, function(key, scancode) print(&quot;pressed key &quot;..key) end)
-- etc., for every LÖVE callback
</pre>
</ul>
@ -77,8 +98,12 @@
<td class="summary">Creates and return a new SignalRegistry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#group">group ()</a></td>
<td class="summary">Creates and return a new SignalGroup.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#event">event</a></td>
<td class="summary"><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry
<td class="summary"><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on LÖVE events; other ubiquitousse modules may bind to this registry
if avaible.</td>
</tr>
<tr>
@ -93,29 +118,76 @@
<td class="summary">Map of signals to list of listeners.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:bind">SignalRegistry:bind (name, fn, ...)</a></td>
<td class="summary">Bind one or several functions to a signal name.</td>
<td class="name" nowrap><a href="#SignalRegistry.chained">SignalRegistry.chained</a></td>
<td class="summary">List of registries chained to this registry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unbind">SignalRegistry:unbind (name, fn, ...)</a></td>
<td class="summary">Unbind one or several functions to a signal name.</td>
<td class="name" nowrap><a href="#SignalRegistry:bind">SignalRegistry:bind (name, fn)</a></td>
<td class="summary">Bind a function to a signal name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unbindAll">SignalRegistry:unbindAll (name)</a></td>
<td class="name" nowrap><a href="#SignalRegistry:has">SignalRegistry:has (name, fn)</a></td>
<td class="summary">Returns true if fn is bound to the signal.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unbind">SignalRegistry:unbind (name, fn)</a></td>
<td class="summary">Unbind a function from a signal name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unbindPattern">SignalRegistry:unbindPattern (pat, fn)</a></td>
<td class="summary">Unbind a function from every signal whose name match the pattern.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:clear">SignalRegistry:clear (name)</a></td>
<td class="summary">Remove every bound function to a signal name.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:replace">SignalRegistry:replace (name, sourceFn, destFn)</a></td>
<td class="summary">Replace a bound function with another function.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:clear">SignalRegistry:clear ()</a></td>
<td class="summary">Remove every bound function to every signal.</td>
<td class="name" nowrap><a href="#SignalRegistry:clearPattern">SignalRegistry:clearPattern (pat)</a></td>
<td class="summary">Remove every bound function to every signal whose name match the pattern.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:emit">SignalRegistry:emit (name, ...)</a></td>
<td class="summary">Emit a signal, i.e.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:emitPattern">SignalRegistry:emitPattern (pat, ...)</a></td>
<td class="summary">Emit to every signal whose name match the pattern.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:chain">SignalRegistry:chain (registry)</a></td>
<td class="summary">Chain another regsitry to this registry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalRegistry:unchain">SignalRegistry:unchain (registry)</a></td>
<td class="summary">Unchain a specific registry from the registry chaining list.</td>
</tr>
</table>
<h2><a href="#SignalGroup_objects">SignalGroup objects </a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap><a href="#SignalGroup.paused">SignalGroup.paused</a></td>
<td class="summary">Indicate if the signal group if currently paused or not.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup.binds">SignalGroup.binds</a></td>
<td class="summary">List of triplets in the group.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:bind">SignalGroup:bind (registry, name, fn)</a></td>
<td class="summary">Bind a function to a signal name in the given registry.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:clear">SignalGroup:clear ()</a></td>
<td class="summary">Remove every bound triplet in the group.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:pause">SignalGroup:pause ()</a></td>
<td class="summary">Pause the group.</td>
</tr>
<tr>
<td class="name" nowrap><a href="#SignalGroup:resume">SignalGroup:resume ()</a></td>
<td class="summary">Resume the group.</td>
</tr>
</table>
<br/>
@ -149,27 +221,53 @@
</dd>
<dt>
<a name = "group"></a>
<strong>group ()</strong>
</dt>
<dd>
Creates and return a new SignalGroup.
</ul>
</ul>
</ul>
</ul>
<h3>Returns:</h3>
<ol>
<span class="types"><a class="type" href="../modules/signal.html#SignalGroup_objects">SignalGroup</a></span>
</ol>
</dd>
<dt>
<a name = "event"></a>
<strong>event</strong>
</dt>
<dd>
<p><a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on game engine event; other ubiquitousse modules may bind to this registry
<a href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a> which will be used to bind signals that need to be called on LÖVE events; other ubiquitousse modules may bind to this registry
if avaible. </p>
<p> For example, every ubiquitousse module with a &ldquo;update&rdquo; function will bind it to the &ldquo;update&rdquo; signal in the registry;
you can then call this signal on each game update to update every ubiquitousse module easily.</p>
<p> Provided signals:</p>
<ul>
<li><code>update(dt)</code>, should be called on every game update</li>
<li><code>draw()</code>, should be called on every game draw</li>
<li>for LÖVE, there are callbacks for every LÖVE callback function that need to be called on their corresponding LÖVE callback</li>
</ul>
<p> You will need to call <a href="../modules/signal.html#registerEvents">registerEvents</a> for the signal to be called on LÖVE callbacks automatically (otherwise you will have to emit the events
from the LÖVE callbacks manually).</p>
<p> List of signals available: &ldquo;displayrotated&rdquo;, &ldquo;draw&rdquo;, &ldquo;load&rdquo;, &ldquo;lowmemory&rdquo;, &ldquo;quit&rdquo;, &ldquo;update&rdquo;,
&ldquo;directorydropped&rdquo;, &ldquo;filedropped&rdquo;, &ldquo;focus&rdquo;, &ldquo;mousefocus&rdquo;, &ldquo;resize&rdquo;, &ldquo;visible&rdquo;,
&ldquo;keypressed&rdquo;, &ldquo;keyreleased&rdquo;, &ldquo;textedited&rdquo;, &ldquo;textinput&rdquo;,
&ldquo;mousemoved&rdquo;, &ldquo;mousepressed&rdquo;, &ldquo;mousereleased&rdquo;, &ldquo;wheelmoved&rdquo;,
&ldquo;gamepadaxis&rdquo;, &ldquo;gamepadpressed&rdquo;, &ldquo;gamepadreleased&rdquo;,
&ldquo;joystickadded&rdquo;, &ldquo;joystickaxis&rdquo;, &ldquo;joystickhat&rdquo;, &ldquo;joystickpressed&rdquo;, &ldquo;joystickreleased&rdquo;, &ldquo;joystickremoved&rdquo;,
&ldquo;touchmoved&rdquo;, &ldquo;touchpressed&rdquo;, &ldquo;touchreleased&rdquo;.
</ul>
<h3>Type:</h3>
@ -226,7 +324,28 @@
</ul>
<h3>Type:</h3>
<ul>
<code>{["name"]={fn,...}}</code>
<code>{["name"]={fn,[fn]=1,...}}</code>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalRegistry.chained"></a>
<strong>SignalRegistry.chained</strong>
</dt>
<dd>
List of registries chained to this registry.
</ul>
<h3>Type:</h3>
<ul>
<code>{</code> registry, ... }
</ul>
</ul>
</ul>
@ -239,10 +358,10 @@
</dd>
<dt>
<a name = "SignalRegistry:bind"></a>
<strong>SignalRegistry:bind (name, fn, ...)</strong>
<strong>SignalRegistry:bind (name, fn)</strong>
</dt>
<dd>
Bind one or several functions to a signal name.
Bind a function to a signal name.
</ul>
</ul>
@ -259,9 +378,34 @@
<span class="types"><span class="type">function</span></span>
the function to bind to the signal
</li>
<li><span class="parameter">...</span>
<span class="types"><span class="type">function,...</span></span>
other function to bind to the signal
</ul>
</dd>
<dt>
<a name = "SignalRegistry:has"></a>
<strong>SignalRegistry:has (name, fn)</strong>
</dt>
<dd>
Returns true if fn is bound to the signal.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li>
<li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function
</li>
</ul>
@ -272,10 +416,10 @@
</dd>
<dt>
<a name = "SignalRegistry:unbind"></a>
<strong>SignalRegistry:unbind (name, fn, ...)</strong>
<strong>SignalRegistry:unbind (name, fn)</strong>
</dt>
<dd>
Unbind one or several functions to a signal name.
Unbind a function from a signal name.
</ul>
</ul>
@ -292,9 +436,34 @@
<span class="types"><span class="type">function</span></span>
the function to unbind to the signal
</li>
<li><span class="parameter">...</span>
<span class="types"><span class="type">function,...</span></span>
other function to unbind to the signal
</ul>
</dd>
<dt>
<a name = "SignalRegistry:unbindPattern"></a>
<strong>SignalRegistry:unbindPattern (pat, fn)</strong>
</dt>
<dd>
Unbind a function from every signal whose name match the pattern.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Lua pattern string
</li>
<li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function to unbind to the signals
</li>
</ul>
@ -304,8 +473,8 @@
</dd>
<dt>
<a name = "SignalRegistry:unbindAll"></a>
<strong>SignalRegistry:unbindAll (name)</strong>
<a name = "SignalRegistry:clear"></a>
<strong>SignalRegistry:clear (name)</strong>
</dt>
<dd>
Remove every bound function to a signal name.
@ -329,11 +498,11 @@
</dd>
<dt>
<a name = "SignalRegistry:replace"></a>
<strong>SignalRegistry:replace (name, sourceFn, destFn)</strong>
<a name = "SignalRegistry:clearPattern"></a>
<strong>SignalRegistry:clearPattern (pat)</strong>
</dt>
<dd>
Replace a bound function with another function.
Remove every bound function to every signal whose name match the pattern.
</ul>
</ul>
@ -342,17 +511,9 @@
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">name</span>
<li><span class="parameter">pat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li>
<li><span class="parameter">sourceFn</span>
<span class="types"><span class="type">function</span></span>
the function currently bound to the signal
</li>
<li><span class="parameter">destFn</span>
<span class="types"><span class="type">function</span></span>
the function that will replace the previous one
Lua string pattern
</li>
</ul>
@ -360,24 +521,6 @@
</dd>
<dt>
<a name = "SignalRegistry:clear"></a>
<strong>SignalRegistry:clear ()</strong>
</dt>
<dd>
Remove every bound function to every signal.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalRegistry:emit"></a>
@ -406,6 +549,237 @@
</dd>
<dt>
<a name = "SignalRegistry:emitPattern"></a>
<strong>SignalRegistry:emitPattern (pat, ...)</strong>
</dt>
<dd>
Emit to every signal whose name match the pattern.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">pat</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
Lua pattern string
</li>
<li><span class="parameter">...</span>
arguments to pass to the functions bound to each signal
</li>
</ul>
</dd>
<dt>
<a name = "SignalRegistry:chain"></a>
<strong>SignalRegistry:chain (registry)</strong>
</dt>
<dd>
Chain another regsitry to this registry.
I.e., after an event is emitted in this registry it will be automatically emitted in the other registry.
Several registries can be chained to a single registry.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">registry</span>
<span class="types"><a class="type" href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a></span>
</li>
</ul>
</dd>
<dt>
<a name = "SignalRegistry:unchain"></a>
<strong>SignalRegistry:unchain (registry)</strong>
</dt>
<dd>
Unchain a specific registry from the registry chaining list.
Will error if the regsitry is not in the chaining list.
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">registry</span>
<span class="types"><a class="type" href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a></span>
</li>
</ul>
</dd>
</dl>
<h2 class="section-header has-description"><a name="SignalGroup_objects"></a>SignalGroup objects </h2>
<div class="section-description">
Signal group. </p>
<p> A SignalGroup is a list of (registry, signal name, function) triplets.
When the group is active, all of these triplets will bind the specified signal name to the specified function in the specified registry.
When the group is paused, all of these triplets are unbound.</p>
<p> This can be used to maintain a list of signal bindings where every one should be either disabled or enabled at the same time.
For example you may maintain a signal group of signals you want to be emitted when your game is running, and disabled when the game is paused
(like inputs, update, simulation step, etc. signals).
</div>
<dl class="function">
<dt>
<a name = "SignalGroup.paused"></a>
<strong>SignalGroup.paused</strong>
</dt>
<dd>
Indicate if the signal group if currently paused or not.
</ul>
<h3>Type:</h3>
<ul>
<code>boolean</code>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup.binds"></a>
<strong>SignalGroup.binds</strong>
</dt>
<dd>
List of triplets in the group.
</ul>
<h3>Type:</h3>
<ul>
<code>{</code> {registry, "signal name", function}, ... }
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup:bind"></a>
<strong>SignalGroup:bind (registry, name, fn)</strong>
</dt>
<dd>
Bind a function to a signal name in the given registry.
This handles binding the function on its own; you do not need to call <a href="../modules/signal.html#SignalRegistry:bind">SignalRegistry:bind</a> manually.
If the group is paused, this will not bind the function immediately but only on the next time this group is resumed (as expected).
</ul>
</ul>
</ul>
</ul>
<h3>Parameters:</h3>
<ul>
<li><span class="parameter">registry</span>
<span class="types"><a class="type" href="../modules/signal.html#SignalRegistry_objects">SignalRegistry</a></span>
to bind the signal in
</li>
<li><span class="parameter">name</span>
<span class="types"><a class="type" href="https://www.lua.org/manual/5.1/manual.html#5.4">string</a></span>
the name of the signal
</li>
<li><span class="parameter">fn</span>
<span class="types"><span class="type">function</span></span>
the function to bind to the signal
</li>
</ul>
</dd>
<dt>
<a name = "SignalGroup:clear"></a>
<strong>SignalGroup:clear ()</strong>
</dt>
<dd>
Remove every bound triplet in the group.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup:pause"></a>
<strong>SignalGroup:pause ()</strong>
</dt>
<dd>
Pause the group.
The signals bound to this group will be disabled in their given registries.
</ul>
</ul>
</ul>
</ul>
</dd>
<dt>
<a name = "SignalGroup:resume"></a>
<strong>SignalGroup:resume ()</strong>
</dt>
<dd>
Resume the group.
The signals bound to this group will be enabled in their given registries.
</ul>
</ul>
</ul>
</ul>
</dd>
</dl>
@ -414,7 +788,7 @@
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 17:22:39 </i>
<i style="float:right;">Last updated 2022-09-16 20:07:07 </i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>