mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
improvements and changes for SCP-Clicker and in general
This commit is contained in:
parent
c94f8ef5b3
commit
b0e4b99528
@ -32,6 +32,7 @@
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Issues">Issues</a></li>
|
||||
<li><a href="#Methods">Methods</a></li>
|
||||
</ul>
|
||||
|
||||
@ -39,6 +40,7 @@
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><strong>element</strong></li>
|
||||
<li><a href="../classes/window.html">window</a></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
@ -64,6 +66,13 @@
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Issues">Issues</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#element.debugDraw-todo7">element.debugDraw-todo7</a></td>
|
||||
<td class="summary">doc me</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Methods">Methods</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
@ -98,12 +107,34 @@
|
||||
<td class="name" nowrap><a href="#element.getHeight">element.getHeight (self)</a></td>
|
||||
<td class="summary">Returns an element's height.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#element.move">element.move (self, x, y)</a></td>
|
||||
<td class="summary">Moves an element by specified x/y.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Issues"></a>Issues</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "element.debugDraw-todo7"></a>
|
||||
<strong>element.debugDraw-todo7</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
doc me
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
|
||||
|
||||
<dl class="function">
|
||||
@ -169,7 +200,7 @@
|
||||
<strong>element.setSize (w, h)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Sets an element's width/height.
|
||||
Sets an element's width/height. Fixes alignment if needed.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
@ -335,6 +366,44 @@
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "element.move"></a>
|
||||
<strong>element.move (self, x, y)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Moves an element by specified x/y.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">x</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">y</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
<span class="types"><a class="type" href="../classes/element.html#">element</a></span>
|
||||
self
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
@ -343,7 +412,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-10-30 23:39:49 </i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
151
docs/classes/window.html
Normal file
151
docs/classes/window.html
Normal file
@ -0,0 +1,151 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>Documentation</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>Pop.Box()</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Issues">Issues</a></li>
|
||||
<li><a href="#Methods">Methods</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../classes/element.html">element</a></li>
|
||||
<li><strong>window</strong></li>
|
||||
</ul>
|
||||
<h2>Modules</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../modules/pop.html">pop</a></li>
|
||||
<li><a href="../modules/main.html">main</a></li>
|
||||
<li><a href="../modules/util.html">util</a></li>
|
||||
<li><a href="../modules/Element.html">Element</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Class <code>window</code></h1>
|
||||
<p>A generic window element.</p>
|
||||
<p> Built-in support for minimize, maximize, and close
|
||||
buttons, as well as drag-to-resize and drag-to-move. Title bar customizable.</p>
|
||||
<h3>Info:</h3>
|
||||
<ul>
|
||||
<li><strong>Copyright</strong>: Paul Liverman III (2016)</li>
|
||||
<li><strong>License</strong>: The MIT License (MIT)</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Issues">Issues</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#window.new-todo8">window.new-todo8</a></td>
|
||||
<td class="summary">if data, do stuff about it</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Methods">Methods</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#window.new">window.new (self, @, @)</a></td>
|
||||
<td class="summary">Constructor expects nothing, or a data table describing it.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Issues"></a>Issues</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "window.new-todo8"></a>
|
||||
<strong>window.new-todo8</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
if data, do stuff about it
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Methods"></a>Methods</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "window.new"></a>
|
||||
<strong>window.new (self, @, @)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Constructor expects nothing, or a data table describing it.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">self</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">@</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">@</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
@ -39,6 +39,7 @@
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="classes/element.html">element</a></li>
|
||||
<li><a href="classes/window.html">window</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -73,13 +74,17 @@
|
||||
<td class="name" nowrap><a href="classes/element.html">element</a></td>
|
||||
<td class="summary">A generic element every element must inherit from.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="classes/window.html">window</a></td>
|
||||
<td class="summary">A generic window element.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-10-30 23:39:49 </i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -48,6 +48,7 @@
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../classes/element.html">element</a></li>
|
||||
<li><a href="../classes/window.html">window</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -490,7 +491,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-10-30 23:39:49 </i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -30,6 +30,10 @@
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
@ -42,6 +46,7 @@
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../classes/element.html">element</a></li>
|
||||
<li><a href="../classes/window.html">window</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -60,18 +65,47 @@
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#love.draw">love.draw ()</a></td>
|
||||
<td class="summary">
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "love.draw"></a>
|
||||
<strong>love.draw ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-10-30 23:39:49 </i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -48,6 +48,7 @@
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../classes/element.html">element</a></li>
|
||||
<li><a href="../classes/window.html">window</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -70,8 +71,8 @@
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#load">load ()</a></td>
|
||||
<td class="summary">Loads elements, skins, extensions, and initializes <code>pop.screen</code>.</td>
|
||||
<td class="name" nowrap><a href="#load">load (The)</a></td>
|
||||
<td class="summary">Loads elements, skins, extensions from a specified path.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#create">create (element, parent, ...)</a></td>
|
||||
@ -149,11 +150,11 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#textinput-todo4">textinput-todo4</a></td>
|
||||
<td class="summary">doc me</td>
|
||||
<td class="summary">document pop.import</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#textinput-todo4-todo5">textinput-todo4-todo5</a></td>
|
||||
<td class="summary">doc me</td>
|
||||
<td class="summary">document pop.export</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#printElementTree-todo6">printElementTree-todo6</a></td>
|
||||
@ -170,22 +171,31 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "load"></a>
|
||||
<strong>load ()</strong>
|
||||
<strong>load (The)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Loads elements, skins, extensions, and initializes <code>pop.screen</code>. </p>
|
||||
Loads elements, skins, extensions from a specified path. Initializes
|
||||
<code>pop.screen</code> on first call.</p>
|
||||
|
||||
<p> <strong>IMPORTANT</strong>: Intended to only be called once, and is automatically called
|
||||
when you require Pop.Box.
|
||||
<p> Automatically called when you require Pop.Box for its internals. Subsequent
|
||||
calls can be used to add more elements/skins/extensions.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">The</span>
|
||||
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.4">string[opt]</a></span>
|
||||
path to load from. Within this path should be
|
||||
elements, skins, and extensions directories, containing whatever items you
|
||||
want to load.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h3>See also:</h3>
|
||||
<ul>
|
||||
<li><a href="../modules/pop.html#">pop</a></li>
|
||||
<li><a href="../modules/Element.html#">Element</a></li>
|
||||
<a href="../modules/Element.html#">Element</a>
|
||||
</ul>
|
||||
|
||||
|
||||
@ -566,6 +576,11 @@ table.insert element.parent, element.parent\removeChild(element),</td>
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">For</span>
|
||||
<span class="types"><span class="type">constants</span></span>
|
||||
now, just stores values to be used with mouse clicks
|
||||
for compatibility with differing LOVE versions.
|
||||
</li>
|
||||
<li><span class="parameter">elements</span>
|
||||
<span class="types"><a class="type" href="http://www.lua.org/manual/5.1/manual.html#5.5">table</a></span>
|
||||
All GUI classes are stored here.
|
||||
@ -657,7 +672,7 @@ table.insert element.parent, element.parent\removeChild(element),
|
||||
<strong>textinput-todo4</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
doc me
|
||||
document pop.import
|
||||
|
||||
|
||||
|
||||
@ -671,7 +686,7 @@ table.insert element.parent, element.parent\removeChild(element),
|
||||
<strong>textinput-todo4-todo5</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
doc me
|
||||
document pop.export
|
||||
|
||||
|
||||
|
||||
@ -701,7 +716,7 @@ table.insert element.parent, element.parent\removeChild(element),
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-10-30 23:39:49 </i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -46,6 +46,7 @@
|
||||
<h2>Classes</h2>
|
||||
<ul class="$(kind=='Topics' and '' or 'nowrap'">
|
||||
<li><a href="../classes/element.html">element</a></li>
|
||||
<li><a href="../classes/window.html">window</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
@ -125,7 +126,7 @@
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i>
|
||||
<i style="float:right;">Last updated 2016-10-30 23:39:49 </i>
|
||||
<i style="float:right;">Last updated 2017-04-08 13:43:44 </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
|
@ -75,6 +75,17 @@ do
|
||||
end,
|
||||
getHeight = function(self)
|
||||
return self.data.h
|
||||
end,
|
||||
move = function(self, x, y)
|
||||
if x == nil then
|
||||
x = 0
|
||||
end
|
||||
if y == nil then
|
||||
y = 0
|
||||
end
|
||||
self.data.x = self.data.x + x
|
||||
self.data.y = self.data.y + y
|
||||
return self
|
||||
end
|
||||
}
|
||||
_base_0.__index = _base_0
|
||||
|
@ -116,3 +116,10 @@ class element
|
||||
--- @treturn integer Height.
|
||||
getHeight: =>
|
||||
return @data.h
|
||||
|
||||
--- Moves an element by specified x/y.
|
||||
--- @treturn element self
|
||||
move: (x=0, y=0) =>
|
||||
@data.x += x
|
||||
@data.y += y
|
||||
return @
|
||||
|
@ -38,9 +38,15 @@ do
|
||||
self.parent, self.data = parent, data
|
||||
_class_0.__parent.__init(self, self.parent, self.data)
|
||||
self.data.type = "text"
|
||||
if not (self.data.text) then
|
||||
self.data.text = text
|
||||
end
|
||||
if not (self.data.fontFile) then
|
||||
self.data.fontFile = fontFile
|
||||
end
|
||||
if not (self.data.fontSize) then
|
||||
self.data.fontSize = fontSize
|
||||
end
|
||||
if not (self.data.color) then
|
||||
self.data.color = {
|
||||
255,
|
||||
@ -49,8 +55,10 @@ do
|
||||
255
|
||||
}
|
||||
end
|
||||
if self.data.fontFile then
|
||||
if "string" == type(self.data.fontFile) then
|
||||
self.font = graphics.newFont(self.data.fontFile, self.data.fontSize)
|
||||
elseif "number" == type(self.data.fontFile) then
|
||||
self.font = graphics.newFont(self.data.fontFile)
|
||||
else
|
||||
self.font = graphics.newFont(self.data.fontSize)
|
||||
end
|
||||
|
@ -13,13 +13,15 @@ class text extends element
|
||||
super @parent, @data
|
||||
|
||||
@data.type = "text"
|
||||
@data.text = text
|
||||
@data.fontFile = fontFile
|
||||
@data.fontSize = fontSize
|
||||
@data.text = text unless @data.text
|
||||
@data.fontFile = fontFile unless @data.fontFile
|
||||
@data.fontSize = fontSize unless @data.fontSize
|
||||
@data.color = {255, 255, 255, 255} unless @data.color
|
||||
|
||||
if @data.fontFile
|
||||
if "string" == type @data.fontFile
|
||||
@font = graphics.newFont(@data.fontFile, @data.fontSize)
|
||||
elseif "number" == type @data.fontFile
|
||||
@font = graphics.newFont(@data.fontFile)
|
||||
else
|
||||
@font = graphics.newFont(@data.fontSize)
|
||||
|
||||
|
55
init.lua
55
init.lua
@ -34,26 +34,51 @@ do
|
||||
local _obj_0 = require(tostring(path) .. "/lib/bitser/bitser")
|
||||
dumps, loads = _obj_0.dumps, _obj_0.loads
|
||||
end
|
||||
local major, minor, revision = love.getVersion()
|
||||
if major == 0 and minor == 9 then
|
||||
pop.constants = {
|
||||
left_mouse = "l",
|
||||
middle_mouse = "m",
|
||||
right_mouse = "r",
|
||||
button_4 = "x1",
|
||||
button_5 = "x2",
|
||||
mouse_wheel_down = "wd",
|
||||
mouse_wheel_up = "wu"
|
||||
}
|
||||
elseif major == 0 and minor == 10 then
|
||||
pop.constants = {
|
||||
left_mouse = 1,
|
||||
middle_mouse = 2,
|
||||
right_mouse = 3,
|
||||
button_4 = 4,
|
||||
button_5 = 5
|
||||
}
|
||||
else
|
||||
pop.constants = { }
|
||||
end
|
||||
pop.elements = { }
|
||||
pop.skins = { }
|
||||
pop.extensions = { }
|
||||
pop.screen = false
|
||||
pop.focused = false
|
||||
pop.log = log
|
||||
pop.load = function()
|
||||
log("Loading elements from \"" .. tostring(path) .. "/elements\"")
|
||||
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements")
|
||||
pop.load = function(load_path)
|
||||
if load_path == nil then
|
||||
load_path = path
|
||||
end
|
||||
log("Loading elements from \"" .. tostring(load_path) .. "/elements\"")
|
||||
local elements = filesystem.getDirectoryItems(tostring(load_path) .. "/elements")
|
||||
for i = 1, #elements do
|
||||
local _continue_0 = false
|
||||
repeat
|
||||
if not (elements[i]:sub(-4) == ".lua") then
|
||||
log("Ignored non-Lua file \"" .. tostring(path) .. "/elements/" .. tostring(elements[i]) .. "\"")
|
||||
log("Ignored non-Lua file \"" .. tostring(load_path) .. "/elements/" .. tostring(elements[i]) .. "\"")
|
||||
_continue_0 = true
|
||||
break
|
||||
end
|
||||
local name = elements[i]:sub(1, -5)
|
||||
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/elements/" .. tostring(name) .. "\"")
|
||||
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name))
|
||||
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(load_path) .. "/elements/" .. tostring(name) .. "\"")
|
||||
pop.elements[name] = require(tostring(load_path) .. "/elements/" .. tostring(name))
|
||||
if pop.elements[name].load then
|
||||
pop.elements[name].load(pop)
|
||||
end
|
||||
@ -74,18 +99,18 @@ pop.load = function()
|
||||
break
|
||||
end
|
||||
end
|
||||
local skins = filesystem.getDirectoryItems(tostring(path) .. "/skins")
|
||||
local skins = filesystem.getDirectoryItems(tostring(load_path) .. "/skins")
|
||||
for i = 1, #skins do
|
||||
local _continue_0 = false
|
||||
repeat
|
||||
if not (skins[i]:sub(-4) == ".lua") then
|
||||
log("Ignored non-Lua file \"" .. tostring(path) .. "/skins/" .. tostring(skins[i]) .. "\"")
|
||||
log("Ignored non-Lua file \"" .. tostring(load_path) .. "/skins/" .. tostring(skins[i]) .. "\"")
|
||||
_continue_0 = true
|
||||
break
|
||||
end
|
||||
local name = skins[i]:sub(1, -5)
|
||||
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/skins/" .. tostring(name) .. "\"")
|
||||
pop.skins[name] = require(tostring(path) .. "/skins/" .. tostring(name))
|
||||
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(load_path) .. "/skins/" .. tostring(name) .. "\"")
|
||||
pop.skins[name] = require(tostring(load_path) .. "/skins/" .. tostring(name))
|
||||
if pop.skins[name].load then
|
||||
pop.skins[name].load(pop)
|
||||
end
|
||||
@ -96,18 +121,18 @@ pop.load = function()
|
||||
break
|
||||
end
|
||||
end
|
||||
local extensions = filesystem.getDirectoryItems(tostring(path) .. "/extensions")
|
||||
local extensions = filesystem.getDirectoryItems(tostring(load_path) .. "/extensions")
|
||||
for i = 1, #extensions do
|
||||
local _continue_0 = false
|
||||
repeat
|
||||
if not (extensions[i]:sub(-4) == ".lua") then
|
||||
log("Ignored non-Lua file \"" .. tostring(path) .. "/extensions/" .. tostring(extensions[i]) .. "\"")
|
||||
log("Ignored non-Lua file \"" .. tostring(load_path) .. "/extensions/" .. tostring(extensions[i]) .. "\"")
|
||||
_continue_0 = true
|
||||
break
|
||||
end
|
||||
local name = extensions[i]:sub(1, -5)
|
||||
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/extensions/" .. tostring(name) .. "\"")
|
||||
pop.extensions[name] = require(tostring(path) .. "/extensions/" .. tostring(name))
|
||||
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(load_path) .. "/extensions/" .. tostring(name) .. "\"")
|
||||
pop.extensions[name] = require(tostring(load_path) .. "/extensions/" .. tostring(name))
|
||||
if pop.extensions[name].load then
|
||||
pop.extensions[name].load(pop)
|
||||
end
|
||||
@ -118,8 +143,10 @@ pop.load = function()
|
||||
break
|
||||
end
|
||||
end
|
||||
if not (pop.screen) then
|
||||
pop.screen = pop.create("element", false):setSize(graphics.getWidth(), graphics.getHeight())
|
||||
return log("Created \"pop.screen\"")
|
||||
end
|
||||
end
|
||||
pop.create = function(element, parent, data, ...)
|
||||
if parent == nil then
|
||||
|
74
init.moon
74
init.moon
@ -33,6 +33,8 @@ import inheritsFromElement from require "#{path}/util"
|
||||
import dumps, loads from require "#{path}/lib/bitser/bitser"
|
||||
|
||||
--- @table pop
|
||||
--- @tfield constants For now, just stores values to be used with mouse clicks
|
||||
--- for compatibility with differing LOVE versions.
|
||||
--- @tfield table elements All GUI classes are stored here.
|
||||
--- @tfield table skins All skins are stored here.
|
||||
--- @tfield table extensions All extensions are loaded here.
|
||||
@ -43,6 +45,31 @@ import dumps, loads from require "#{path}/lib/bitser/bitser"
|
||||
--- @see pop.load
|
||||
--- @see Element
|
||||
|
||||
major, minor, revision = love.getVersion!
|
||||
if major == 0 and minor == 9
|
||||
pop.constants = {
|
||||
left_mouse: "l"
|
||||
middle_mouse: "m"
|
||||
right_mouse: "r"
|
||||
|
||||
button_4: "x1"
|
||||
button_5: "x2"
|
||||
|
||||
mouse_wheel_down: "wd"
|
||||
mouse_wheel_up: "wu"
|
||||
}
|
||||
elseif major == 0 and minor == 10
|
||||
pop.constants = {
|
||||
left_mouse: 1
|
||||
middle_mouse: 2
|
||||
right_mouse: 3
|
||||
button_4: 4
|
||||
button_5: 5
|
||||
--no mouse wheel, may lead to problems?
|
||||
}
|
||||
else
|
||||
pop.constants = {} -- this would be an unsupported version currently
|
||||
|
||||
pop.elements = {}
|
||||
pop.skins = {}
|
||||
pop.extensions = {}
|
||||
@ -52,29 +79,31 @@ pop.log = log
|
||||
|
||||
|
||||
|
||||
--- Loads elements, skins, extensions, and initializes `pop.screen`.
|
||||
--- Loads elements, skins, extensions from a specified path. Initializes
|
||||
--- `pop.screen` on first call.
|
||||
---
|
||||
--- **IMPORTANT**: Intended to only be called once, and is automatically called
|
||||
--- when you require Pop.Box.
|
||||
--- Automatically called when you require Pop.Box for its internals. Subsequent
|
||||
--- calls can be used to add more elements/skins/extensions.
|
||||
--- @function load
|
||||
--- @see pop
|
||||
--- @tparam string[opt] The path to load from. Within this path should be
|
||||
--- elements, skins, and extensions directories, containing whatever items you
|
||||
--- want to load.
|
||||
--- @see Element
|
||||
--- @todo @ see Skins, see Extensions
|
||||
|
||||
pop.load = ->
|
||||
--@todo @ see Skins
|
||||
--@todo @ see Extensions
|
||||
log "Loading elements from \"#{path}/elements\""
|
||||
elements = filesystem.getDirectoryItems "#{path}/elements"
|
||||
pop.load = (load_path=path) ->
|
||||
log "Loading elements from \"#{load_path}/elements\""
|
||||
elements = filesystem.getDirectoryItems "#{load_path}/elements"
|
||||
for i = 1, #elements
|
||||
-- ignore non-Lua files
|
||||
unless elements[i]\sub(-4) == ".lua"
|
||||
log "Ignored non-Lua file \"#{path}/elements/#{elements[i]}\""
|
||||
log "Ignored non-Lua file \"#{load_path}/elements/#{elements[i]}\""
|
||||
continue
|
||||
|
||||
-- require into pop.elements table by filename
|
||||
name = elements[i]\sub 1, -5
|
||||
log "Requiring \"#{name}\" from \"#{path}/elements/#{name}\""
|
||||
pop.elements[name] = require "#{path}/elements/#{name}"
|
||||
log "Requiring \"#{name}\" from \"#{load_path}/elements/#{name}\""
|
||||
pop.elements[name] = require "#{load_path}/elements/#{name}"
|
||||
|
||||
-- call the element's load function if it exists
|
||||
if pop.elements[name].load
|
||||
@ -93,17 +122,17 @@ pop.load = ->
|
||||
log "Wrapper created: \"pop.#{name}()\""
|
||||
|
||||
|
||||
skins = filesystem.getDirectoryItems "#{path}/skins"
|
||||
skins = filesystem.getDirectoryItems "#{load_path}/skins"
|
||||
for i = 1, #skins
|
||||
-- ignore non-Lua files
|
||||
unless skins[i]\sub(-4) == ".lua"
|
||||
log "Ignored non-Lua file \"#{path}/skins/#{skins[i]}\""
|
||||
log "Ignored non-Lua file \"#{load_path}/skins/#{skins[i]}\""
|
||||
continue
|
||||
|
||||
-- require into pop.skins table by filename
|
||||
name = skins[i]\sub 1, -5
|
||||
log "Requiring \"#{name}\" from \"#{path}/skins/#{name}\""
|
||||
pop.skins[name] = require "#{path}/skins/#{name}"
|
||||
log "Requiring \"#{name}\" from \"#{load_path}/skins/#{name}\""
|
||||
pop.skins[name] = require "#{load_path}/skins/#{name}"
|
||||
|
||||
-- call the skin's load function if it exists
|
||||
if pop.skins[name].load
|
||||
@ -112,17 +141,17 @@ pop.load = ->
|
||||
log "Skin loaded: \"#{name}\""
|
||||
|
||||
|
||||
extensions = filesystem.getDirectoryItems "#{path}/extensions"
|
||||
extensions = filesystem.getDirectoryItems "#{load_path}/extensions"
|
||||
for i = 1, #extensions
|
||||
-- ignore non-Lua files
|
||||
unless extensions[i]\sub(-4) == ".lua"
|
||||
log "Ignored non-Lua file \"#{path}/extensions/#{extensions[i]}\""
|
||||
log "Ignored non-Lua file \"#{load_path}/extensions/#{extensions[i]}\""
|
||||
continue
|
||||
|
||||
-- require into pop.extensions by filename
|
||||
name = extensions[i]\sub 1, -5
|
||||
log "Requiring \"#{name}\" from \"#{path}/extensions/#{name}\""
|
||||
pop.extensions[name] = require "#{path}/extensions/#{name}"
|
||||
log "Requiring \"#{name}\" from \"#{load_path}/extensions/#{name}\""
|
||||
pop.extensions[name] = require "#{load_path}/extensions/#{name}"
|
||||
|
||||
-- call the extension's load function if it exists
|
||||
if pop.extensions[name].load
|
||||
@ -132,6 +161,7 @@ pop.load = ->
|
||||
|
||||
|
||||
-- Initialize pop.screen (top element, GUI area)
|
||||
unless pop.screen
|
||||
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!)
|
||||
log "Created \"pop.screen\""
|
||||
|
||||
@ -383,7 +413,7 @@ pop.textinput = (text) ->
|
||||
|
||||
|
||||
|
||||
--- @todo doc me
|
||||
--- @todo document pop.import
|
||||
|
||||
pop.import = (data, parent=pop.screen) ->
|
||||
local element
|
||||
@ -399,7 +429,7 @@ pop.import = (data, parent=pop.screen) ->
|
||||
|
||||
|
||||
|
||||
--- @todo doc me
|
||||
--- @todo document pop.export
|
||||
|
||||
pop.export = (element=pop.screen) ->
|
||||
return dumps(element.data)
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit a384174649e8429cc3270a46cfacc37acaf6e042
|
Loading…
Reference in New Issue
Block a user