improvements and changes for SCP-Clicker and in general

This commit is contained in:
Paul Liverman III 2017-04-08 13:44:31 -07:00
parent c94f8ef5b3
commit b0e4b99528
14 changed files with 428 additions and 68 deletions

View File

@ -32,6 +32,7 @@
<h2>Contents</h2> <h2>Contents</h2>
<ul> <ul>
<li><a href="#Issues">Issues</a></li>
<li><a href="#Methods">Methods</a></li> <li><a href="#Methods">Methods</a></li>
</ul> </ul>
@ -39,6 +40,7 @@
<h2>Classes</h2> <h2>Classes</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><strong>element</strong></li> <li><strong>element</strong></li>
<li><a href="../classes/window.html">window</a></li>
</ul> </ul>
<h2>Modules</h2> <h2>Modules</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
@ -64,6 +66,13 @@
</ul> </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> <h2><a href="#Methods">Methods</a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
@ -98,12 +107,34 @@
<td class="name" nowrap><a href="#element.getHeight">element.getHeight (self)</a></td> <td class="name" nowrap><a href="#element.getHeight">element.getHeight (self)</a></td>
<td class="summary">Returns an element's height.</td> <td class="summary">Returns an element's height.</td>
</tr> </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> </table>
<br/> <br/>
<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> <h2 class="section-header "><a name="Methods"></a>Methods</h2>
<dl class="function"> <dl class="function">
@ -169,7 +200,7 @@
<strong>element.setSize (w, h)</strong> <strong>element.setSize (w, h)</strong>
</dt> </dt>
<dd> <dd>
Sets an element's width/height. Sets an element's width/height. Fixes alignment if needed.
<h3>Parameters:</h3> <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> </dd>
</dl> </dl>
@ -343,7 +412,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

151
docs/classes/window.html Normal file
View 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>

View File

@ -39,6 +39,7 @@
<h2>Classes</h2> <h2>Classes</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="classes/element.html">element</a></li> <li><a href="classes/element.html">element</a></li>
<li><a href="classes/window.html">window</a></li>
</ul> </ul>
</div> </div>
@ -73,13 +74,17 @@
<td class="name" nowrap><a href="classes/element.html">element</a></td> <td class="name" nowrap><a href="classes/element.html">element</a></td>
<td class="summary">A generic element every element must inherit from.</td> <td class="summary">A generic element every element must inherit from.</td>
</tr> </tr>
<tr>
<td class="name" nowrap><a href="classes/window.html">window</a></td>
<td class="summary">A generic window element.</td>
</tr>
</table> </table>
</div> <!-- id="content" --> </div> <!-- id="content" -->
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -48,6 +48,7 @@
<h2>Classes</h2> <h2>Classes</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../classes/element.html">element</a></li> <li><a href="../classes/element.html">element</a></li>
<li><a href="../classes/window.html">window</a></li>
</ul> </ul>
</div> </div>
@ -490,7 +491,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -30,6 +30,10 @@
<li><a href="../index.html">Index</a></li> <li><a href="../index.html">Index</a></li>
</ul> </ul>
<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
</ul>
<h2>Modules</h2> <h2>Modules</h2>
@ -42,6 +46,7 @@
<h2>Classes</h2> <h2>Classes</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../classes/element.html">element</a></li> <li><a href="../classes/element.html">element</a></li>
<li><a href="../classes/window.html">window</a></li>
</ul> </ul>
</div> </div>
@ -60,18 +65,47 @@
</ul> </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/>
<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="content" -->
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -48,6 +48,7 @@
<h2>Classes</h2> <h2>Classes</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../classes/element.html">element</a></li> <li><a href="../classes/element.html">element</a></li>
<li><a href="../classes/window.html">window</a></li>
</ul> </ul>
</div> </div>
@ -70,8 +71,8 @@
<h2><a href="#Functions">Functions</a></h2> <h2><a href="#Functions">Functions</a></h2>
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" nowrap><a href="#load">load ()</a></td> <td class="name" nowrap><a href="#load">load (The)</a></td>
<td class="summary">Loads elements, skins, extensions, and initializes <code>pop.screen</code>.</td> <td class="summary">Loads elements, skins, extensions from a specified path.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#create">create (element, parent, ...)</a></td> <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>
<tr> <tr>
<td class="name" nowrap><a href="#textinput-todo4">textinput-todo4</a></td> <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>
<tr> <tr>
<td class="name" nowrap><a href="#textinput-todo4-todo5">textinput-todo4-todo5</a></td> <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>
<tr> <tr>
<td class="name" nowrap><a href="#printElementTree-todo6">printElementTree-todo6</a></td> <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"> <dl class="function">
<dt> <dt>
<a name = "load"></a> <a name = "load"></a>
<strong>load ()</strong> <strong>load (The)</strong>
</dt> </dt>
<dd> <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 <p> Automatically called when you require Pop.Box for its internals. Subsequent
when you require Pop.Box. 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> <h3>See also:</h3>
<ul> <ul>
<li><a href="../modules/pop.html#">pop</a></li> <a href="../modules/Element.html#">Element</a>
<li><a href="../modules/Element.html#">Element</a></li>
</ul> </ul>
@ -566,6 +576,11 @@ table.insert element.parent, element.parent\removeChild(element),</td>
<h3>Fields:</h3> <h3>Fields:</h3>
<ul> <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> <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> <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. All GUI classes are stored here.
@ -657,7 +672,7 @@ table.insert element.parent, element.parent\removeChild(element),
<strong>textinput-todo4</strong> <strong>textinput-todo4</strong>
</dt> </dt>
<dd> <dd>
doc me document pop.import
@ -671,7 +686,7 @@ table.insert element.parent, element.parent\removeChild(element),
<strong>textinput-todo4-todo5</strong> <strong>textinput-todo4-todo5</strong>
</dt> </dt>
<dd> <dd>
doc me document pop.export
@ -701,7 +716,7 @@ table.insert element.parent, element.parent\removeChild(element),
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -46,6 +46,7 @@
<h2>Classes</h2> <h2>Classes</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'"> <ul class="$(kind=='Topics' and '' or 'nowrap'">
<li><a href="../classes/element.html">element</a></li> <li><a href="../classes/element.html">element</a></li>
<li><a href="../classes/window.html">window</a></li>
</ul> </ul>
</div> </div>
@ -125,7 +126,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.3</a></i> <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="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View File

@ -75,6 +75,17 @@ do
end, end,
getHeight = function(self) getHeight = function(self)
return self.data.h 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 end
} }
_base_0.__index = _base_0 _base_0.__index = _base_0

View File

@ -116,3 +116,10 @@ class element
--- @treturn integer Height. --- @treturn integer Height.
getHeight: => getHeight: =>
return @data.h 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 @

View File

@ -38,9 +38,15 @@ do
self.parent, self.data = parent, data self.parent, self.data = parent, data
_class_0.__parent.__init(self, self.parent, self.data) _class_0.__parent.__init(self, self.parent, self.data)
self.data.type = "text" self.data.type = "text"
self.data.text = text if not (self.data.text) then
self.data.fontFile = fontFile self.data.text = text
self.data.fontSize = fontSize 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 if not (self.data.color) then
self.data.color = { self.data.color = {
255, 255,
@ -49,8 +55,10 @@ do
255 255
} }
end end
if self.data.fontFile then if "string" == type(self.data.fontFile) then
self.font = graphics.newFont(self.data.fontFile, self.data.fontSize) 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 else
self.font = graphics.newFont(self.data.fontSize) self.font = graphics.newFont(self.data.fontSize)
end end

View File

@ -13,13 +13,15 @@ class text extends element
super @parent, @data super @parent, @data
@data.type = "text" @data.type = "text"
@data.text = text @data.text = text unless @data.text
@data.fontFile = fontFile @data.fontFile = fontFile unless @data.fontFile
@data.fontSize = fontSize @data.fontSize = fontSize unless @data.fontSize
@data.color = {255, 255, 255, 255} unless @data.color @data.color = {255, 255, 255, 255} unless @data.color
if @data.fontFile if "string" == type @data.fontFile
@font = graphics.newFont(@data.fontFile, @data.fontSize) @font = graphics.newFont(@data.fontFile, @data.fontSize)
elseif "number" == type @data.fontFile
@font = graphics.newFont(@data.fontFile)
else else
@font = graphics.newFont(@data.fontSize) @font = graphics.newFont(@data.fontSize)

View File

@ -34,26 +34,51 @@ do
local _obj_0 = require(tostring(path) .. "/lib/bitser/bitser") local _obj_0 = require(tostring(path) .. "/lib/bitser/bitser")
dumps, loads = _obj_0.dumps, _obj_0.loads dumps, loads = _obj_0.dumps, _obj_0.loads
end 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.elements = { }
pop.skins = { } pop.skins = { }
pop.extensions = { } pop.extensions = { }
pop.screen = false pop.screen = false
pop.focused = false pop.focused = false
pop.log = log pop.log = log
pop.load = function() pop.load = function(load_path)
log("Loading elements from \"" .. tostring(path) .. "/elements\"") if load_path == nil then
local elements = filesystem.getDirectoryItems(tostring(path) .. "/elements") 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 for i = 1, #elements do
local _continue_0 = false local _continue_0 = false
repeat repeat
if not (elements[i]:sub(-4) == ".lua") then 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 _continue_0 = true
break break
end end
local name = elements[i]:sub(1, -5) local name = elements[i]:sub(1, -5)
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/elements/" .. tostring(name) .. "\"") log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(load_path) .. "/elements/" .. tostring(name) .. "\"")
pop.elements[name] = require(tostring(path) .. "/elements/" .. tostring(name)) pop.elements[name] = require(tostring(load_path) .. "/elements/" .. tostring(name))
if pop.elements[name].load then if pop.elements[name].load then
pop.elements[name].load(pop) pop.elements[name].load(pop)
end end
@ -74,18 +99,18 @@ pop.load = function()
break break
end end
end end
local skins = filesystem.getDirectoryItems(tostring(path) .. "/skins") local skins = filesystem.getDirectoryItems(tostring(load_path) .. "/skins")
for i = 1, #skins do for i = 1, #skins do
local _continue_0 = false local _continue_0 = false
repeat repeat
if not (skins[i]:sub(-4) == ".lua") then 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 _continue_0 = true
break break
end end
local name = skins[i]:sub(1, -5) local name = skins[i]:sub(1, -5)
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/skins/" .. tostring(name) .. "\"") log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(load_path) .. "/skins/" .. tostring(name) .. "\"")
pop.skins[name] = require(tostring(path) .. "/skins/" .. tostring(name)) pop.skins[name] = require(tostring(load_path) .. "/skins/" .. tostring(name))
if pop.skins[name].load then if pop.skins[name].load then
pop.skins[name].load(pop) pop.skins[name].load(pop)
end end
@ -96,18 +121,18 @@ pop.load = function()
break break
end end
end end
local extensions = filesystem.getDirectoryItems(tostring(path) .. "/extensions") local extensions = filesystem.getDirectoryItems(tostring(load_path) .. "/extensions")
for i = 1, #extensions do for i = 1, #extensions do
local _continue_0 = false local _continue_0 = false
repeat repeat
if not (extensions[i]:sub(-4) == ".lua") then 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 _continue_0 = true
break break
end end
local name = extensions[i]:sub(1, -5) local name = extensions[i]:sub(1, -5)
log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(path) .. "/extensions/" .. tostring(name) .. "\"") log("Requiring \"" .. tostring(name) .. "\" from \"" .. tostring(load_path) .. "/extensions/" .. tostring(name) .. "\"")
pop.extensions[name] = require(tostring(path) .. "/extensions/" .. tostring(name)) pop.extensions[name] = require(tostring(load_path) .. "/extensions/" .. tostring(name))
if pop.extensions[name].load then if pop.extensions[name].load then
pop.extensions[name].load(pop) pop.extensions[name].load(pop)
end end
@ -118,8 +143,10 @@ pop.load = function()
break break
end end
end end
pop.screen = pop.create("element", false):setSize(graphics.getWidth(), graphics.getHeight()) if not (pop.screen) then
return log("Created \"pop.screen\"") pop.screen = pop.create("element", false):setSize(graphics.getWidth(), graphics.getHeight())
return log("Created \"pop.screen\"")
end
end end
pop.create = function(element, parent, data, ...) pop.create = function(element, parent, data, ...)
if parent == nil then if parent == nil then

View File

@ -33,6 +33,8 @@ import inheritsFromElement from require "#{path}/util"
import dumps, loads from require "#{path}/lib/bitser/bitser" import dumps, loads from require "#{path}/lib/bitser/bitser"
--- @table pop --- @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 elements All GUI classes are stored here.
--- @tfield table skins All skins are stored here. --- @tfield table skins All skins are stored here.
--- @tfield table extensions All extensions are loaded 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 pop.load
--- @see Element --- @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.elements = {}
pop.skins = {} pop.skins = {}
pop.extensions = {} 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 --- Automatically called when you require Pop.Box for its internals. Subsequent
--- when you require Pop.Box. --- calls can be used to add more elements/skins/extensions.
--- @function load --- @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 --- @see Element
--- @todo @ see Skins, see Extensions
pop.load = -> pop.load = (load_path=path) ->
--@todo @ see Skins log "Loading elements from \"#{load_path}/elements\""
--@todo @ see Extensions elements = filesystem.getDirectoryItems "#{load_path}/elements"
log "Loading elements from \"#{path}/elements\""
elements = filesystem.getDirectoryItems "#{path}/elements"
for i = 1, #elements for i = 1, #elements
-- ignore non-Lua files -- ignore non-Lua files
unless elements[i]\sub(-4) == ".lua" 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 continue
-- require into pop.elements table by filename -- require into pop.elements table by filename
name = elements[i]\sub 1, -5 name = elements[i]\sub 1, -5
log "Requiring \"#{name}\" from \"#{path}/elements/#{name}\"" log "Requiring \"#{name}\" from \"#{load_path}/elements/#{name}\""
pop.elements[name] = require "#{path}/elements/#{name}" pop.elements[name] = require "#{load_path}/elements/#{name}"
-- call the element's load function if it exists -- call the element's load function if it exists
if pop.elements[name].load if pop.elements[name].load
@ -93,17 +122,17 @@ pop.load = ->
log "Wrapper created: \"pop.#{name}()\"" log "Wrapper created: \"pop.#{name}()\""
skins = filesystem.getDirectoryItems "#{path}/skins" skins = filesystem.getDirectoryItems "#{load_path}/skins"
for i = 1, #skins for i = 1, #skins
-- ignore non-Lua files -- ignore non-Lua files
unless skins[i]\sub(-4) == ".lua" 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 continue
-- require into pop.skins table by filename -- require into pop.skins table by filename
name = skins[i]\sub 1, -5 name = skins[i]\sub 1, -5
log "Requiring \"#{name}\" from \"#{path}/skins/#{name}\"" log "Requiring \"#{name}\" from \"#{load_path}/skins/#{name}\""
pop.skins[name] = require "#{path}/skins/#{name}" pop.skins[name] = require "#{load_path}/skins/#{name}"
-- call the skin's load function if it exists -- call the skin's load function if it exists
if pop.skins[name].load if pop.skins[name].load
@ -112,17 +141,17 @@ pop.load = ->
log "Skin loaded: \"#{name}\"" log "Skin loaded: \"#{name}\""
extensions = filesystem.getDirectoryItems "#{path}/extensions" extensions = filesystem.getDirectoryItems "#{load_path}/extensions"
for i = 1, #extensions for i = 1, #extensions
-- ignore non-Lua files -- ignore non-Lua files
unless extensions[i]\sub(-4) == ".lua" 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 continue
-- require into pop.extensions by filename -- require into pop.extensions by filename
name = extensions[i]\sub 1, -5 name = extensions[i]\sub 1, -5
log "Requiring \"#{name}\" from \"#{path}/extensions/#{name}\"" log "Requiring \"#{name}\" from \"#{load_path}/extensions/#{name}\""
pop.extensions[name] = require "#{path}/extensions/#{name}" pop.extensions[name] = require "#{load_path}/extensions/#{name}"
-- call the extension's load function if it exists -- call the extension's load function if it exists
if pop.extensions[name].load if pop.extensions[name].load
@ -132,8 +161,9 @@ pop.load = ->
-- Initialize pop.screen (top element, GUI area) -- Initialize pop.screen (top element, GUI area)
pop.screen = pop.create("element", false)\setSize(graphics.getWidth!, graphics.getHeight!) unless pop.screen
log "Created \"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) -> pop.import = (data, parent=pop.screen) ->
local element local element
@ -399,7 +429,7 @@ pop.import = (data, parent=pop.screen) ->
--- @todo doc me --- @todo document pop.export
pop.export = (element=pop.screen) -> pop.export = (element=pop.screen) ->
return dumps(element.data) return dumps(element.data)

@ -1 +0,0 @@
Subproject commit a384174649e8429cc3270a46cfacc37acaf6e042