mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
more improvements/changes!
This commit is contained in:
parent
d589e1440b
commit
e895e83ec4
@ -456,7 +456,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -144,7 +144,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -84,7 +84,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -491,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -105,7 +105,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -159,7 +159,7 @@ table.insert element.parent, element.parent\removeChild(element),</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>
|
||||||
<td class="summary">Correct this once elements are reimplemented if it needs correction.</td>
|
<td class="summary">Write debugInfo things for elements.</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@ -707,7 +707,7 @@ table.insert element.parent, element.parent\removeChild(element),
|
|||||||
<strong>printElementTree-todo6</strong>
|
<strong>printElementTree-todo6</strong>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
Correct this once elements are reimplemented if it needs correction.
|
Write debugInfo things for elements.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -723,7 +723,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -126,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 2017-04-09 18:24:55 </i>
|
<i style="float:right;">Last updated 2017-04-10 20:32:12 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -53,6 +53,7 @@ do
|
|||||||
if toPixel == nil then
|
if toPixel == nil then
|
||||||
toPixel = true
|
toPixel = true
|
||||||
end
|
end
|
||||||
|
local dx, dy = self.data.x, self.data.y
|
||||||
if x then
|
if x then
|
||||||
self.data.x = x
|
self.data.x = x
|
||||||
end
|
end
|
||||||
@ -75,6 +76,13 @@ do
|
|||||||
self.data.x = floor(self.data.x)
|
self.data.x = floor(self.data.x)
|
||||||
self.data.y = floor(self.data.y)
|
self.data.y = floor(self.data.y)
|
||||||
end
|
end
|
||||||
|
dx = self.data.x - dx
|
||||||
|
dy = self.data.y - dy
|
||||||
|
local _list_0 = self.child
|
||||||
|
for _index_0 = 1, #_list_0 do
|
||||||
|
local child = _list_0[_index_0]
|
||||||
|
child:move(dx, dy)
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
setSize = function(self, w, h)
|
setSize = function(self, w, h)
|
||||||
@ -111,6 +119,11 @@ do
|
|||||||
if y == nil then
|
if y == nil then
|
||||||
y = 0
|
y = 0
|
||||||
end
|
end
|
||||||
|
local _list_0 = self.child
|
||||||
|
for _index_0 = 1, #_list_0 do
|
||||||
|
local child = _list_0[_index_0]
|
||||||
|
child:move(x, y)
|
||||||
|
end
|
||||||
self.data.x = self.data.x + x
|
self.data.x = self.data.x + x
|
||||||
self.data.y = self.data.y + y
|
self.data.y = self.data.y + y
|
||||||
return self
|
return self
|
||||||
|
@ -75,9 +75,13 @@ class element
|
|||||||
|
|
||||||
--- @todo document this
|
--- @todo document this
|
||||||
setPosition: (x, y, toPixel=true) =>
|
setPosition: (x, y, toPixel=true) =>
|
||||||
|
dx, dy = @data.x, @data.y
|
||||||
|
|
||||||
if x
|
if x
|
||||||
|
--dx = x - @data.x
|
||||||
@data.x = x
|
@data.x = x
|
||||||
if y
|
if y
|
||||||
|
--dy = y - @data.y
|
||||||
@data.y = y
|
@data.y = y
|
||||||
|
|
||||||
switch @data.horizontal
|
switch @data.horizontal
|
||||||
@ -96,6 +100,12 @@ class element
|
|||||||
@data.x = floor @data.x
|
@data.x = floor @data.x
|
||||||
@data.y = floor @data.y
|
@data.y = floor @data.y
|
||||||
|
|
||||||
|
-- new minus old is difference that children need to be moved
|
||||||
|
dx = @data.x - dx
|
||||||
|
dy = @data.y - dy
|
||||||
|
for child in *@child
|
||||||
|
child\move dx, dy
|
||||||
|
|
||||||
return @
|
return @
|
||||||
|
|
||||||
--- Sets an element's width/height. Fixes alignment if needed.
|
--- Sets an element's width/height. Fixes alignment if needed.
|
||||||
@ -145,6 +155,9 @@ class element
|
|||||||
--- Moves an element by specified x/y.
|
--- Moves an element by specified x/y.
|
||||||
--- @treturn element self
|
--- @treturn element self
|
||||||
move: (x=0, y=0) =>
|
move: (x=0, y=0) =>
|
||||||
|
for child in *@child
|
||||||
|
child\move x, y
|
||||||
|
|
||||||
@data.x += x
|
@data.x += x
|
||||||
@data.y += y
|
@data.y += y
|
||||||
return @
|
return @
|
||||||
|
20
init.lua
20
init.lua
@ -256,7 +256,7 @@ pop.mousereleased = function(x, y, button, element)
|
|||||||
local clickedHandled = false
|
local clickedHandled = false
|
||||||
local mousereleasedHandled = false
|
local mousereleasedHandled = false
|
||||||
if element then
|
if element then
|
||||||
if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then
|
if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h) then
|
||||||
for i = #element.child, 1, -1 do
|
for i = #element.child, 1, -1 do
|
||||||
clickedHandled, mousereleasedHandled = pop.mousereleased(x, y, button, element.child[i])
|
clickedHandled, mousereleasedHandled = pop.mousereleased(x, y, button, element.child[i])
|
||||||
if clickedHandled or mousereleasedHandled then
|
if clickedHandled or mousereleasedHandled then
|
||||||
@ -331,16 +331,16 @@ pop.debugDraw = function(element)
|
|||||||
if element == nil then
|
if element == nil then
|
||||||
element = pop.screen
|
element = pop.screen
|
||||||
end
|
end
|
||||||
if element.debugDraw then
|
|
||||||
element:debugDraw()
|
|
||||||
else
|
|
||||||
graphics.setLineWidth(1)
|
graphics.setLineWidth(1)
|
||||||
graphics.setColor(0, 0, 0, 100)
|
graphics.setColor(0, 0, 0, 100)
|
||||||
graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h)
|
graphics.rectangle("fill", element.data.x, element.data.y, element.data.w, element.data.h)
|
||||||
graphics.setColor(150, 150, 150, 150)
|
graphics.setColor(150, 150, 150, 150)
|
||||||
graphics.rectangle("line", element.data.x, element.data.y, element.data.w, element.data.h)
|
graphics.rectangle("line", element.data.x, element.data.y, element.data.w, element.data.h)
|
||||||
graphics.setColor(200, 200, 200, 255)
|
graphics.setColor(200, 200, 200, 255)
|
||||||
graphics.print(".", element.data.x, element.data.y)
|
if element.debugInfo then
|
||||||
|
graphics.print(tostring(element.__class.__name:sub(1, 1)) .. " (" .. tostring(element:debugInfo()) .. ")", element.data.x, element.data.y)
|
||||||
|
else
|
||||||
|
graphics.print(tostring(element.__class.__name:sub(1, 1)), element.data.x, element.data.y)
|
||||||
end
|
end
|
||||||
for i = 1, #element.child do
|
for i = 1, #element.child do
|
||||||
pop.debugDraw(element.child[i])
|
pop.debugDraw(element.child[i])
|
||||||
@ -354,14 +354,8 @@ pop.printElementTree = function(element, depth)
|
|||||||
depth = 0
|
depth = 0
|
||||||
end
|
end
|
||||||
local cls = element.__class.__name
|
local cls = element.__class.__name
|
||||||
if cls == "text" then
|
if element.debugInfo then
|
||||||
cls = cls .. " (\"" .. tostring(element:getText():gsub("\n", "\\n")) .. "\")"
|
cls = tostring(cls) .. " (" .. tostring(element:debugInfo()) .. ")"
|
||||||
elseif cls == "box" then
|
|
||||||
local bg = element:getBackground()
|
|
||||||
if type(bg) == "table" then
|
|
||||||
bg = tostring(bg[1]) .. ", " .. tostring(bg[2]) .. ", " .. tostring(bg[3]) .. ", " .. tostring(bg[4])
|
|
||||||
end
|
|
||||||
cls = cls .. " (" .. tostring(bg) .. ")"
|
|
||||||
end
|
end
|
||||||
if depth > 0 then
|
if depth > 0 then
|
||||||
log(string.rep("-", depth) .. " " .. tostring(cls))
|
log(string.rep("-", depth) .. " " .. tostring(cls))
|
||||||
|
26
init.moon
26
init.moon
@ -341,7 +341,7 @@ pop.mousereleased = (x, y, button, element) ->
|
|||||||
|
|
||||||
-- if we have an element, and are within its bounds
|
-- if we have an element, and are within its bounds
|
||||||
if element
|
if element
|
||||||
if (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h)
|
if element.data.draw and (x >= element.data.x) and (x <= element.data.x + element.data.w) and (y >= element.data.y) and (y <= element.data.y + element.data.h)
|
||||||
-- check its children in reverse for handling a clicked or mousereleased event
|
-- check its children in reverse for handling a clicked or mousereleased event
|
||||||
for i = #element.child, 1, -1
|
for i = #element.child, 1, -1
|
||||||
clickedHandled, mousereleasedHandled = pop.mousereleased x, y, button, element.child[i]
|
clickedHandled, mousereleasedHandled = pop.mousereleased x, y, button, element.child[i]
|
||||||
@ -456,17 +456,18 @@ pop.export = (element=pop.screen) ->
|
|||||||
--- @see Element
|
--- @see Element
|
||||||
|
|
||||||
pop.debugDraw = (element=pop.screen) ->
|
pop.debugDraw = (element=pop.screen) ->
|
||||||
--@todo Make this better in the future when different element types have been created and whatnot.
|
--@todo Remove element.debugDraw functions.
|
||||||
if element.debugDraw
|
|
||||||
element\debugDraw!
|
|
||||||
else
|
|
||||||
graphics.setLineWidth 1
|
graphics.setLineWidth 1
|
||||||
graphics.setColor 0, 0, 0, 100
|
graphics.setColor 0, 0, 0, 100
|
||||||
graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h
|
graphics.rectangle "fill", element.data.x, element.data.y, element.data.w, element.data.h
|
||||||
graphics.setColor 150, 150, 150, 150
|
graphics.setColor 150, 150, 150, 150
|
||||||
graphics.rectangle "line", element.data.x, element.data.y, element.data.w, element.data.h
|
graphics.rectangle "line", element.data.x, element.data.y, element.data.w, element.data.h
|
||||||
graphics.setColor 200, 200, 200, 255
|
graphics.setColor 200, 200, 200, 255
|
||||||
graphics.print ".", element.data.x, element.data.y
|
|
||||||
|
if element.debugInfo
|
||||||
|
graphics.print "#{element.__class.__name\sub 1, 1} (#{element\debugInfo!})", element.data.x, element.data.y
|
||||||
|
else
|
||||||
|
graphics.print "#{element.__class.__name\sub 1, 1}", element.data.x, element.data.y
|
||||||
|
|
||||||
for i = 1, #element.child
|
for i = 1, #element.child
|
||||||
pop.debugDraw element.child[i]
|
pop.debugDraw element.child[i]
|
||||||
@ -480,18 +481,11 @@ pop.debugDraw = (element=pop.screen) ->
|
|||||||
--- @see Element
|
--- @see Element
|
||||||
|
|
||||||
pop.printElementTree = (element=pop.screen, depth=0) ->
|
pop.printElementTree = (element=pop.screen, depth=0) ->
|
||||||
--- @todo Correct this once elements are reimplemented if it needs correction.
|
--- @todo Write debugInfo things for elements.
|
||||||
cls = element.__class.__name
|
cls = element.__class.__name
|
||||||
|
|
||||||
if cls == "text"
|
if element.debugInfo
|
||||||
cls = cls .. " (\"#{element\getText!\gsub "\n", "\\n"}\")"
|
cls = "#{cls} (#{element\debugInfo!})"
|
||||||
elseif cls == "box"
|
|
||||||
bg = element\getBackground!
|
|
||||||
|
|
||||||
if type(bg) == "table"
|
|
||||||
bg = "#{bg[1]}, #{bg[2]}, #{bg[3]}, #{bg[4]}"
|
|
||||||
|
|
||||||
cls = cls .. " (#{bg})"
|
|
||||||
|
|
||||||
if depth > 0
|
if depth > 0
|
||||||
log string.rep("-", depth) .. " #{cls}"
|
log string.rep("-", depth) .. " #{cls}"
|
||||||
|
Loading…
Reference in New Issue
Block a user