mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +00:00
Version 0.9.2 - Alpha (see changelog.txt)
This commit is contained in:
parent
834b7a1d48
commit
e16001022c
@ -1,3 +1,25 @@
|
||||
================================================
|
||||
Version 0.9.2 - Alpha (May 22 - 2012)
|
||||
================================================
|
||||
[ADDED] a new slider method: SetButtonSize(width, height)
|
||||
[ADDED] a new slider method: GetButtonSize()
|
||||
[ADDED] a new slider method: SetSlideType(slidetype)
|
||||
[ADDED] a new slider button method: MoveToY(y)
|
||||
|
||||
[REMOVED] slider method: SetButtonYCenter(y)
|
||||
[REMOVED] slider method: GetButtonYCenter()
|
||||
|
||||
[FIXED] the column list row object not setting it's text's font to it's font
|
||||
[FIXED] a small graient error in the default skins
|
||||
[FIXED] an error that caused tab buttons to be overscrolled with the middle mouse button
|
||||
[FIXED] the scroll area object not moving it's base parent to the top when clicked (only in situatuions where it'sbase parent was a frame)
|
||||
|
||||
[CHANGED] sliders no longer use ycenter for button positioning
|
||||
[CHANGED] slider functionality, sliders can now be horizontal or vertical (use slider:SetSlideType("horizontal" or "vertical"))
|
||||
[CHANGED] lots of code for optimization and general cleanliness
|
||||
[CHANGED] a few minor things in the default skins
|
||||
[CHANGED] scrollbar hover behavior when being moved via it's scroll area being clicked (will no longer auto hover when it reaches the mouse position)
|
||||
|
||||
================================================
|
||||
Version 0.9.1.6 - Alpha (May 17 - 2012)
|
||||
================================================
|
||||
|
55
debug.lua
55
debug.lua
@ -323,7 +323,7 @@ function loveframes.debug.ExamplesMenu()
|
||||
panel1:SetSize(490, 115)
|
||||
|
||||
local slider1 = loveframes.Create("slider", panel1)
|
||||
slider1:SetPos(5, 5)
|
||||
slider1:SetPos(5, 20)
|
||||
slider1:SetWidth(480)
|
||||
slider1:SetMinMax(0, 100)
|
||||
slider1:SetText("Padding")
|
||||
@ -332,8 +332,20 @@ function loveframes.debug.ExamplesMenu()
|
||||
list1:SetPadding(value)
|
||||
end
|
||||
|
||||
local text1 = loveframes.Create("text", panel1)
|
||||
text1:SetPos(5, 5)
|
||||
text1:SetFont(love.graphics.newFont(10))
|
||||
text1:SetText(slider1:GetText())
|
||||
|
||||
local text2 = loveframes.Create("text", panel1)
|
||||
text2:SetFont(love.graphics.newFont(10))
|
||||
text2.Update = function(object, dt)
|
||||
object:SetPos(slider1:GetWidth() - object:GetWidth(), 5)
|
||||
object:SetText(slider1:GetValue())
|
||||
end
|
||||
|
||||
local slider2 = loveframes.Create("slider", panel1)
|
||||
slider2:SetPos(5, 45)
|
||||
slider2:SetPos(5, 60)
|
||||
slider2:SetWidth(480)
|
||||
slider2:SetMinMax(0, 100)
|
||||
slider2:SetText("Spacing")
|
||||
@ -342,6 +354,18 @@ function loveframes.debug.ExamplesMenu()
|
||||
list1:SetSpacing(value)
|
||||
end
|
||||
|
||||
local text3 = loveframes.Create("text", panel1)
|
||||
text3:SetPos(5, 45)
|
||||
text3:SetFont(love.graphics.newFont(10))
|
||||
text3:SetText(slider2:GetText())
|
||||
|
||||
local text4 = loveframes.Create("text", panel1)
|
||||
text4:SetFont(love.graphics.newFont(10))
|
||||
text4.Update = function(object, dt)
|
||||
object:SetPos(slider2:GetWidth() - object:GetWidth(), 45)
|
||||
object:SetText(slider2:GetValue())
|
||||
end
|
||||
|
||||
local button1 = loveframes.Create("button", panel1)
|
||||
button1:SetPos(5, 85)
|
||||
button1:SetSize(480, 25)
|
||||
@ -441,14 +465,27 @@ function loveframes.debug.ExamplesMenu()
|
||||
end
|
||||
|
||||
local slider1 = loveframes.Create("slider", frame1)
|
||||
slider1:SetPos(5, 120)
|
||||
slider1:SetPos(5, 135)
|
||||
slider1:SetWidth(490)
|
||||
slider1:SetText("Progressbar lerp rate")
|
||||
slider1:SetMinMax(1, 50)
|
||||
slider1:SetDecimals(0)
|
||||
slider1.OnValueChanged = function(object2, value)
|
||||
progressbar1:SetLerpRate(value)
|
||||
end
|
||||
|
||||
local text1 = loveframes.Create("text", frame1)
|
||||
text1:SetPos(5, 120)
|
||||
text1:SetText("Lerp Rate")
|
||||
text1:SetFont(love.graphics.newFont(10))
|
||||
|
||||
local text2 = loveframes.Create("text", frame1)
|
||||
text2:SetFont(love.graphics.newFont(10))
|
||||
text2.Update = function(object, dt)
|
||||
object:SetPos(slider1:GetWidth() - object:GetWidth(), 120)
|
||||
object:SetText(slider1:GetValue())
|
||||
end
|
||||
|
||||
end
|
||||
exampleslist:AddItem(progressbarexample)
|
||||
|
||||
@ -461,7 +498,7 @@ function loveframes.debug.ExamplesMenu()
|
||||
|
||||
local frame1 = loveframes.Create("frame")
|
||||
frame1:SetName("Slider")
|
||||
frame1:SetSize(300, 70)
|
||||
frame1:SetSize(300, 275)
|
||||
frame1:Center()
|
||||
|
||||
local slider1 = loveframes.Create("slider", frame1)
|
||||
@ -469,6 +506,16 @@ function loveframes.debug.ExamplesMenu()
|
||||
slider1:SetWidth(290)
|
||||
slider1:SetMinMax(0, 100)
|
||||
|
||||
local slider2 = loveframes.Create("slider", frame1)
|
||||
slider2:SetPos(5, 60)
|
||||
slider2:SetHeight(200)
|
||||
slider2:SetMinMax(0, 100)
|
||||
slider2:SetButtonSize(20, 10)
|
||||
slider2:SetSlideType("vertical")
|
||||
slider2.Update = function(object, dt)
|
||||
object:CenterX()
|
||||
end
|
||||
|
||||
end
|
||||
exampleslist:AddItem(sliderexample)
|
||||
|
||||
|
2
init.lua
2
init.lua
@ -9,7 +9,7 @@ loveframes = {}
|
||||
-- library info
|
||||
loveframes.info = {}
|
||||
loveframes.info.author = "Nikolai Resokav"
|
||||
loveframes.info.version = "0.9.1.6"
|
||||
loveframes.info.version = "0.9.2"
|
||||
loveframes.info.stage = "Alpha"
|
||||
|
||||
-- library configurations
|
||||
|
176
objects/base.lua
176
objects/base.lua
@ -30,7 +30,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:update(dt)
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
local children = self.children
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
@ -42,10 +44,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:draw()
|
||||
|
||||
local children = self.children
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -57,18 +61,22 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.children then
|
||||
for k, v in ipairs(self.children) do
|
||||
if children then
|
||||
for k, v in ipairs(children) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
end
|
||||
|
||||
if self.internals then
|
||||
for k, v in ipairs(self.internals) do
|
||||
if internals then
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
end
|
||||
@ -81,18 +89,22 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.children then
|
||||
for k, v in ipairs(self.children) do
|
||||
if children then
|
||||
for k, v in ipairs(children) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
end
|
||||
|
||||
if self.internals then
|
||||
for k, v in ipairs(self.internals) do
|
||||
if internals then
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
end
|
||||
@ -105,18 +117,22 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:keypressed(key, unicode)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.children then
|
||||
for k, v in ipairs(self.children) do
|
||||
if children then
|
||||
for k, v in ipairs(children) do
|
||||
v:keypressed(key, unicode)
|
||||
end
|
||||
end
|
||||
|
||||
if self.internals then
|
||||
for k, v in ipairs(self.internals) do
|
||||
if internals then
|
||||
for k, v in ipairs(internals) do
|
||||
v:keypressed(key, unicode)
|
||||
end
|
||||
end
|
||||
@ -129,18 +145,22 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:keyreleased(key)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.children then
|
||||
for k, v in ipairs(self.children) do
|
||||
if children then
|
||||
for k, v in ipairs(children) do
|
||||
v:keyreleased(key)
|
||||
end
|
||||
end
|
||||
|
||||
if self.internals then
|
||||
for k, v in ipairs(self.internals) do
|
||||
if internals then
|
||||
for k, v in ipairs(internals) do
|
||||
v:keyreleased(key)
|
||||
end
|
||||
end
|
||||
@ -155,9 +175,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:SetPos(x, y)
|
||||
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if parent == loveframes.base then
|
||||
if parent == base then
|
||||
self.x = x
|
||||
self.y = y
|
||||
else
|
||||
@ -173,9 +194,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:SetX(x)
|
||||
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if parent == loveframes.base then
|
||||
if parent == base then
|
||||
self.x = x
|
||||
else
|
||||
self.staticx = x
|
||||
@ -189,9 +211,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:SetY(y)
|
||||
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if parent == loveframes.base then
|
||||
if parent == base then
|
||||
self.y = y
|
||||
else
|
||||
self.staticy = y
|
||||
@ -266,9 +289,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:Center()
|
||||
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if parent == loveframes.base then
|
||||
if parent == base then
|
||||
local width = love.graphics.getWidth()
|
||||
local height = love.graphics.getHeight()
|
||||
|
||||
@ -290,9 +314,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:CenterX()
|
||||
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if parent == loveframes.base then
|
||||
if parent == base then
|
||||
local width = love.graphics.getWidth()
|
||||
self.x = width/2 - self.width/2
|
||||
else
|
||||
@ -308,9 +333,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:CenterY()
|
||||
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if parent == loveframes.base then
|
||||
if parent == base then
|
||||
local height = love.graphics.getHeight()
|
||||
self.y = height/2 - self.height/2
|
||||
else
|
||||
@ -393,19 +419,15 @@ function base:SetVisible(bool)
|
||||
self.visible = bool
|
||||
|
||||
if children then
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
v:SetVisible(bool)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if internals then
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
v:SetVisible(bool)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -453,7 +475,6 @@ end
|
||||
function base:GetParent()
|
||||
|
||||
local parent = self.parent
|
||||
|
||||
return parent
|
||||
|
||||
end
|
||||
@ -464,20 +485,27 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:Remove()
|
||||
|
||||
if self.parent.internals then
|
||||
local pinternals = self.parent.internals
|
||||
local pchildren = self.parent.children
|
||||
|
||||
for k, v in ipairs(self.parent.internals) do
|
||||
if pinternals then
|
||||
|
||||
for k, v in ipairs(pinternals) do
|
||||
if v == self then
|
||||
table.remove(self.parent.internals, k)
|
||||
table.remove(pinternals, k)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.parent.children) do
|
||||
if v == self then
|
||||
table.remove(self.parent.children, k)
|
||||
if pchildren then
|
||||
|
||||
for k, v in ipairs(pchildren) do
|
||||
if v == self then
|
||||
table.remove(pchildren, k)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -489,16 +517,19 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:SetClickBounds(x, y, width, height)
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
self.clickbounds = {x = x, y = y, width = width, height = height}
|
||||
|
||||
if self.internals then
|
||||
for k, v in ipairs(self.internals) do
|
||||
if internals then
|
||||
for k, v in ipairs(internals) do
|
||||
v:SetClickBounds(x, y, width, height)
|
||||
end
|
||||
end
|
||||
|
||||
if self.children then
|
||||
for k, v in ipairs(self.children) do
|
||||
if children then
|
||||
for k, v in ipairs(children) do
|
||||
v:SetClickBounds(x, y, width, height)
|
||||
end
|
||||
end
|
||||
@ -523,16 +554,19 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:RemoveClickBounds()
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
self.clickbounds = nil
|
||||
|
||||
if self.internals then
|
||||
for k, v in ipairs(self.internals) do
|
||||
if internals then
|
||||
for k, v in ipairs(internals) do
|
||||
v:RemoveClickBounds()
|
||||
end
|
||||
end
|
||||
|
||||
if self.children then
|
||||
for k, v in ipairs(self.children) do
|
||||
if children then
|
||||
for k, v in ipairs(children) do
|
||||
v:RemoveClickBounds()
|
||||
end
|
||||
end
|
||||
@ -550,14 +584,10 @@ function base:InClickBounds()
|
||||
local bounds = self.clickbounds
|
||||
|
||||
if bounds then
|
||||
|
||||
local col = loveframes.util.BoundingBox(x, bounds.x, y, bounds.y, 1, bounds.width, 1, bounds.height)
|
||||
return col
|
||||
|
||||
else
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -575,11 +605,9 @@ function base:IsTopCollision()
|
||||
|
||||
-- loop through the object's parent's children
|
||||
for k, v in ipairs(cols) do
|
||||
|
||||
if v.draworder > draworder then
|
||||
top = false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return top
|
||||
@ -593,11 +621,12 @@ end
|
||||
function base:GetBaseParent(t)
|
||||
|
||||
local t = t or {}
|
||||
local parent
|
||||
local base = loveframes.base
|
||||
local parent = self.parent
|
||||
|
||||
if self.parent ~= loveframes.base then
|
||||
table.insert(t, self.parent)
|
||||
self.parent:GetBaseParent(t)
|
||||
if parent ~= base then
|
||||
table.insert(t, parent)
|
||||
parent:GetBaseParent(t)
|
||||
end
|
||||
|
||||
return t[#t]
|
||||
@ -615,6 +644,7 @@ function base:CheckHover()
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local modalobject = loveframes.modalobject
|
||||
local clickbounds = self.clickbounds
|
||||
|
||||
-- is the mouse inside the object?
|
||||
if selfcol == true then
|
||||
@ -635,7 +665,7 @@ function base:CheckHover()
|
||||
self.hover = false
|
||||
end
|
||||
|
||||
if self.clickbounds then
|
||||
if clickbounds then
|
||||
if self:InClickBounds() == false then
|
||||
self.hover = false
|
||||
end
|
||||
@ -714,8 +744,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:GetChildren()
|
||||
|
||||
if self.children then
|
||||
return self.children
|
||||
local children = self.children
|
||||
|
||||
if children then
|
||||
return children
|
||||
end
|
||||
|
||||
end
|
||||
@ -790,8 +822,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:MoveToTop()
|
||||
|
||||
local pchildren = self.parent.children
|
||||
|
||||
self:Remove()
|
||||
table.insert(self.parent.children, self)
|
||||
table.insert(pchildren, self)
|
||||
|
||||
end
|
||||
|
||||
@ -801,22 +835,21 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function base:SetSkin(name)
|
||||
|
||||
local pchildren = self.parent.children
|
||||
local pinternals = self.parent.internals
|
||||
|
||||
self.skin = name
|
||||
|
||||
if self.children then
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
if pchildren then
|
||||
for k, v in ipairs(pchildren) do
|
||||
v:SetSkin(name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if self.internals then
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
if pinternals then
|
||||
for k, v in ipairs(pinternals) do
|
||||
v:SetSkin(name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -881,9 +914,10 @@ end
|
||||
function base:IsActive()
|
||||
|
||||
local parent = self.parent
|
||||
local pchildren = parent.children
|
||||
local valid = false
|
||||
|
||||
for k, v in ipairs(parent.children) do
|
||||
for k, v in ipairs(pchildren) do
|
||||
if v == self then
|
||||
valid = true
|
||||
end
|
||||
|
@ -31,23 +31,30 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function button:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if self.hover == false then
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
|
||||
if hover == false then
|
||||
self.down = false
|
||||
elseif self.hover == true then
|
||||
if loveframes.hoverobject == self then
|
||||
elseif hover == true then
|
||||
if hoverobject == self then
|
||||
self.down = true
|
||||
end
|
||||
end
|
||||
|
||||
if self.down == false and loveframes.hoverobject == self then
|
||||
if down == false and hoverobject == self then
|
||||
self.hover = true
|
||||
end
|
||||
|
||||
@ -69,19 +76,21 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function button:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
if self.Draw ~= nil then
|
||||
self.Draw(self)
|
||||
else
|
||||
@ -96,11 +105,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function button:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -121,7 +134,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function button:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -34,8 +34,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function checkbox:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -97,19 +100,21 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function checkbox:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
if self.Draw ~= nil then
|
||||
self.Draw(self)
|
||||
else
|
||||
@ -128,11 +133,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function checkbox:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -153,7 +162,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function checkbox:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -206,7 +217,6 @@ function checkbox:SetText(text)
|
||||
|
||||
self.width = self.boxwidth
|
||||
self.height = self.boxheight
|
||||
|
||||
self.internals = {}
|
||||
|
||||
end
|
||||
@ -219,8 +229,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function checkbox:GetText()
|
||||
|
||||
if self.internals[1] then
|
||||
return self.internals[1].text
|
||||
local internals = self.internals
|
||||
local text = internals[1]
|
||||
|
||||
if text then
|
||||
return text.text
|
||||
else
|
||||
return false
|
||||
end
|
||||
@ -288,10 +301,13 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function checkbox:SetFont(font)
|
||||
|
||||
local internals = self.internals
|
||||
local text = internals[1]
|
||||
|
||||
self.font = font
|
||||
|
||||
if self.internals[1] then
|
||||
self.internals[1]:SetFont(font)
|
||||
if text then
|
||||
text:SetFont(font)
|
||||
end
|
||||
|
||||
end
|
@ -33,12 +33,19 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
-- move to parent if there is a parent
|
||||
@ -47,13 +54,11 @@ function collapsiblecategory:update(dt)
|
||||
self.y = self.parent.y + self.staticy
|
||||
end
|
||||
|
||||
if self.open == true then
|
||||
for k, v in ipairs(self.children) do
|
||||
v:update(dt)
|
||||
v:SetWidth(self.width - self.padding*2)
|
||||
v.y = (v.parent.y + v.staticy)
|
||||
v.x = (v.parent.x + v.staticx)
|
||||
end
|
||||
if open == true then
|
||||
curobject:update(dt)
|
||||
curobject:SetWidth(self.width - self.padding*2)
|
||||
curobject.y = (curobject.parent.y + curobject.staticy)
|
||||
curobject.x = (curobject.parent.x + curobject.staticx)
|
||||
end
|
||||
|
||||
if self.Update then
|
||||
@ -68,12 +73,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
@ -81,16 +89,17 @@ function collapsiblecategory:draw()
|
||||
local selfskin = self.skin
|
||||
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
if self.Draw ~= nil then
|
||||
self.Draw(self)
|
||||
else
|
||||
skin.DrawCollapsibleCategory(self)
|
||||
end
|
||||
|
||||
if self.open == true then
|
||||
for k, v in ipairs(self.children) do
|
||||
v:draw()
|
||||
end
|
||||
if open == true then
|
||||
curobject:draw()
|
||||
end
|
||||
|
||||
end
|
||||
@ -101,11 +110,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true then
|
||||
local hover = self.hover
|
||||
local open = self.open
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if hover == true then
|
||||
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
|
||||
|
||||
@ -124,12 +140,8 @@ function collapsiblecategory:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
if self.open == true then
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
if open == true then
|
||||
curobject:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
@ -140,7 +152,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -150,6 +164,8 @@ function collapsiblecategory:mousereleased(x, y, button)
|
||||
local enabled = self.enabled
|
||||
local open = self.open
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, self.closedheight, 1)
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if hover == true and button == "l" and col == true and self.down == true then
|
||||
|
||||
@ -163,12 +179,8 @@ function collapsiblecategory:mousereleased(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
if self.open == true then
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
if open == true then
|
||||
curobject:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
@ -199,8 +211,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:SetObject(object)
|
||||
|
||||
if self.children[1] then
|
||||
self.children[1]:Remove()
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if curobject then
|
||||
curobject:Remove()
|
||||
self.children = {}
|
||||
end
|
||||
|
||||
@ -219,8 +234,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:GetObject()
|
||||
|
||||
if self.children[1] then
|
||||
return self.children[1]
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
if curobject then
|
||||
return curobject
|
||||
else
|
||||
return false
|
||||
end
|
||||
@ -273,17 +291,20 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function collapsiblecategory:SetOpen(bool)
|
||||
|
||||
local children = self.children
|
||||
local curobject = children[1]
|
||||
|
||||
self.open = bool
|
||||
|
||||
if bool == false then
|
||||
self.height = self.closedheight
|
||||
if self.children[1] then
|
||||
self.children[1]:SetVisible(false)
|
||||
if curobject then
|
||||
curobject:SetVisible(false)
|
||||
end
|
||||
else
|
||||
self.height = self.closedheight + self.padding*2 + self.children[1].height
|
||||
if self.children[1] then
|
||||
self.children[1]:SetVisible(true)
|
||||
self.height = self.closedheight + self.padding*2 + curobject.height
|
||||
if curobject then
|
||||
curobject:SetVisible(true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -34,12 +34,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
-- move to parent if there is a parent
|
||||
@ -48,11 +54,11 @@ function columnlist:update(dt)
|
||||
self.y = self.parent.y + self.staticy
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
@ -68,13 +74,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
@ -87,11 +98,11 @@ function columnlist:draw()
|
||||
skin.DrawColumnList(self)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -103,7 +114,17 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:mousepressed(x, y, button)
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local hover = self.hover
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -113,11 +134,11 @@ function columnlist:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
@ -129,48 +150,25 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:mousereleased(x, y, button)
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: keypressed(key)
|
||||
- desc: called when the player presses a key
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:keypressed(key, unicode)
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:keypressed(key, unicode)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
v:keypressed(key, unicode)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: keyreleased(key)
|
||||
- desc: called when the player releases a key
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:keyreleased(key)
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:keyreleased(key)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
v:keyreleased(key)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: Adjustchildren()
|
||||
- desc: adjusts the width of the object's children
|
||||
@ -208,11 +206,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:AddColumn(name)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
columnlistheader:new(name, self)
|
||||
self:AdjustColumns()
|
||||
|
||||
self.internals[1]:SetSize(self.width, self.height)
|
||||
self.internals[1]:SetPos(0, 0)
|
||||
list:SetSize(self.width, self.height)
|
||||
list:SetPos(0, 0)
|
||||
|
||||
end
|
||||
|
||||
@ -222,7 +223,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:AddRow(...)
|
||||
|
||||
self.internals[1]:AddRow(arg)
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
list:AddRow(arg)
|
||||
|
||||
end
|
||||
|
||||
@ -232,8 +236,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:GetColumnSize()
|
||||
|
||||
if #self.children > 0 then
|
||||
return self.children[1].width, self.children[1].height
|
||||
local children = self.children
|
||||
local numchildren = #self.children
|
||||
local column = self.children[1]
|
||||
local colwidth = column.width
|
||||
local colheight = column.height
|
||||
|
||||
if numchildren > 0 then
|
||||
return colwidth, colheight
|
||||
else
|
||||
return 0, 0
|
||||
end
|
||||
@ -246,11 +256,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:SetSize(width, height)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
self.width = width
|
||||
self.height = height
|
||||
|
||||
self.internals[1]:SetSize(width, height)
|
||||
self.internals[1]:SetPos(0, 0)
|
||||
list:SetSize(width, height)
|
||||
list:SetPos(0, 0)
|
||||
|
||||
end
|
||||
|
||||
@ -260,10 +273,13 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:SetWidth(width)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
self.width = width
|
||||
|
||||
self.internals[1]:SetSize(width)
|
||||
self.internals[1]:SetPos(0, 0)
|
||||
list:SetSize(width)
|
||||
list:SetPos(0, 0)
|
||||
|
||||
end
|
||||
|
||||
@ -273,10 +289,13 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:SetHeight(height)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
self.height = height
|
||||
|
||||
self.internals[1]:SetSize(height)
|
||||
self.internals[1]:SetPos(0, 0)
|
||||
list:SetSize(height)
|
||||
list:SetPos(0, 0)
|
||||
|
||||
end
|
||||
|
||||
@ -287,7 +306,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:SetMaxColorIndex(num)
|
||||
|
||||
self.internals[1].colorindexmax = num
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
list.colorindexmax = num
|
||||
|
||||
end
|
||||
|
||||
@ -297,7 +319,10 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:Clear()
|
||||
|
||||
self.internals[1]:Clear()
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
list:Clear()
|
||||
|
||||
end
|
||||
|
||||
@ -309,10 +334,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlist:SetAutoScroll(bool)
|
||||
|
||||
local internals = self.internals
|
||||
local list = internals[1]
|
||||
|
||||
self.autoscroll = bool
|
||||
|
||||
if self.internals[1]:GetScrollBar() ~= false then
|
||||
self.internals[1]:GetScrollBar().autoscroll = bool
|
||||
if list then
|
||||
if list:GetScrollBar() ~= false then
|
||||
list:GetScrollBar().autoscroll = bool
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -53,27 +53,39 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function frame:update(dt)
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local showclose = self.showclose
|
||||
local close = self.internals[1]
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local showclose = self.showclose
|
||||
local close = self.internals[1]
|
||||
local dragging = self.dragging
|
||||
local screenlocked = self.screenlocked
|
||||
local modal = self.modal
|
||||
local base = loveframes.base
|
||||
local basechildren = base.children
|
||||
local numbasechildren = #basechildren
|
||||
local draworder = self.draworder
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
close:SetPos(self.width - 22, 4)
|
||||
self:CheckHover()
|
||||
|
||||
-- dragging check
|
||||
if self.dragging == true then
|
||||
if dragging == true then
|
||||
self.x = x - self.clickx
|
||||
self.y = y - self.clicky
|
||||
end
|
||||
|
||||
-- if screenlocked then keep within screen
|
||||
if self.screenlocked == true then
|
||||
if screenlocked == true then
|
||||
|
||||
local width = love.graphics.getWidth()
|
||||
local height = love.graphics.getHeight()
|
||||
@ -93,28 +105,28 @@ function frame:update(dt)
|
||||
|
||||
end
|
||||
|
||||
if self.modal == true then
|
||||
if modal == true then
|
||||
|
||||
local numtooltips = 0
|
||||
|
||||
for k, v in ipairs(loveframes.base.children) do
|
||||
for k, v in ipairs(basechildren) do
|
||||
if v.type == "tooltip" then
|
||||
numtooltips = numtooltips + 1
|
||||
end
|
||||
end
|
||||
|
||||
if self.draworder ~= #loveframes.base.children - numtooltips then
|
||||
if draworder ~= numbasechildren - numtooltips then
|
||||
self.modalbackground:MoveToTop()
|
||||
self:MoveToTop()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
@ -130,10 +142,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function frame:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
@ -149,12 +166,12 @@ function frame:draw()
|
||||
skin.DrawFrame(self)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
-- loop through the object's children and draw them
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -166,13 +183,17 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function frame:mousepressed(x, y, button)
|
||||
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local width = self.width
|
||||
local height = self.height
|
||||
local selfcol = loveframes.util.BoundingBox(x, self.x, y, self.y, 1, self.width, 1, self.height)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if selfcol == true then
|
||||
|
||||
@ -193,11 +214,11 @@ function frame:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
@ -209,20 +230,26 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function frame:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local dragging = self.dragging
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
-- exit the dragging state
|
||||
if self.dragging == true then
|
||||
if dragging == true then
|
||||
self.dragging = false
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
@ -312,29 +339,30 @@ end
|
||||
function frame:MakeTop()
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local children = loveframes.base.children
|
||||
local numchildren = #children
|
||||
local key = 0
|
||||
local base = loveframes.base
|
||||
local basechildren = base.children
|
||||
local numbasechildren = #basechildren
|
||||
|
||||
if numchildren == 1 then
|
||||
if numbasechildren == 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if children[numchildren] == self then
|
||||
if basechildren[numbasechildren] == self then
|
||||
return
|
||||
end
|
||||
|
||||
-- make this the top element
|
||||
for k, v in ipairs(children) do
|
||||
-- make this the top object
|
||||
for k, v in ipairs(basechildren) do
|
||||
if v == self then
|
||||
table.remove(loveframes.base.children, k)
|
||||
table.insert(loveframes.base.children, self)
|
||||
table.remove(basechildren, k)
|
||||
table.insert(basechildren, self)
|
||||
key = k
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
loveframes.base.children[key]:mousepressed(x, y, "l")
|
||||
basechildren[key]:mousepressed(x, y, "l")
|
||||
|
||||
end
|
||||
|
||||
@ -345,28 +373,31 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function frame:SetModal(bool)
|
||||
|
||||
local modalobject = loveframes.modalobject
|
||||
local mbackground = self.modalbackground
|
||||
|
||||
self.modal = bool
|
||||
|
||||
if bool == true then
|
||||
|
||||
if loveframes.modalobject ~= false then
|
||||
loveframes.modalobject:SetModal(false)
|
||||
if modalobject ~= false then
|
||||
modalobject:SetModal(false)
|
||||
end
|
||||
|
||||
loveframes.modalobject = self
|
||||
|
||||
if self.modalbackground == false then
|
||||
if mbackground == false then
|
||||
self.modalbackground = modalbackground:new(self)
|
||||
self.modal = true
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
if loveframes.modalobject == self then
|
||||
if modalobject == self then
|
||||
|
||||
loveframes.modalobject = false
|
||||
|
||||
if self.modalbackground ~= false then
|
||||
if mbackground ~= false then
|
||||
self.modalbackground:Remove()
|
||||
self.modalbackground = false
|
||||
self.modal = false
|
||||
@ -395,14 +426,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function frame:SetVisible(bool)
|
||||
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
local closebutton = internals[1]
|
||||
|
||||
self.visible = bool
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:SetVisible(bool)
|
||||
end
|
||||
|
||||
if self.showclose == true then
|
||||
self.internals[1].visible = bool
|
||||
closebutton[1].visible = bool
|
||||
end
|
||||
|
||||
end
|
@ -28,8 +28,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function image:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -52,7 +55,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function image:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -94,8 +99,8 @@ end
|
||||
- func: SetColor(table)
|
||||
- desc: sets the object's color
|
||||
--]]---------------------------------------------------------
|
||||
function image:SetColor(t)
|
||||
function image:SetColor(data)
|
||||
|
||||
self.imagecolor = t
|
||||
self.imagecolor = data
|
||||
|
||||
end
|
@ -32,23 +32,30 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function imagebutton:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if self.hover == false then
|
||||
local hover = self.hover
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local down = self.down
|
||||
|
||||
if hover == false then
|
||||
self.down = false
|
||||
elseif self.hover == true then
|
||||
if loveframes.hoverobject == self then
|
||||
elseif hover == true then
|
||||
if hoverobject == self then
|
||||
self.down = true
|
||||
end
|
||||
end
|
||||
|
||||
if self.down == false and loveframes.hoverobject == self then
|
||||
if down == false and hoverobject == self then
|
||||
self.hover = true
|
||||
end
|
||||
|
||||
@ -70,7 +77,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function imagebutton:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -92,16 +101,20 @@ function imagebutton:draw()
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousepressed(x, y, imagebutton)
|
||||
- desc: called when the player presses a mouse imagebutton
|
||||
- func: mousepressed(x, y, button)
|
||||
- desc: called when the player presses a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function imagebutton:mousepressed(x, y, imagebutton)
|
||||
function imagebutton:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and imagebutton == "l" then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -117,12 +130,14 @@ function imagebutton:mousepressed(x, y, imagebutton)
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousereleased(x, y, imagebutton)
|
||||
- desc: called when the player releases a mouse imagebutton
|
||||
- func: mousereleased(x, y, button)
|
||||
- desc: called when the player releases a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function imagebutton:mousereleased(x, y, imagebutton)
|
||||
function imagebutton:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -233,9 +248,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function imagebutton:SizeToImage()
|
||||
|
||||
if self.image then
|
||||
self.width = self.image:getWidth()
|
||||
self.height = self.image:getHeight()
|
||||
local image = self.image
|
||||
|
||||
if image then
|
||||
self.width = image:getWidth()
|
||||
self.height = image:getHeight()
|
||||
end
|
||||
|
||||
end
|
@ -29,23 +29,30 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function closebutton:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if self.hover == false then
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
|
||||
if hover == false then
|
||||
self.down = false
|
||||
elseif self.hover == true then
|
||||
elseif hover == true then
|
||||
if loveframes.hoverobject == self then
|
||||
self.down = true
|
||||
end
|
||||
end
|
||||
|
||||
if self.down == false and loveframes.hoverobject == self then
|
||||
if down == false and hoverobject == self then
|
||||
self.hover = true
|
||||
end
|
||||
|
||||
@ -67,7 +74,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function closebutton:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -94,11 +103,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function closebutton:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -119,11 +132,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function closebutton:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and self.down == true then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and self.down == true then
|
||||
|
||||
if button == "l" then
|
||||
self.OnClick(x, y, self)
|
||||
|
@ -38,8 +38,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlistarea:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -79,7 +82,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlistarea:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,7 @@ function columnlistrow:initialize(parent, data)
|
||||
self.type = "columnlistrow"
|
||||
self.parent = parent
|
||||
self.colorindex = self.parent.rowcolorindex
|
||||
self.font = love.graphics.newFont(12)
|
||||
self.font = love.graphics.newFont(10)
|
||||
self.textcolor = {0, 0, 0, 255}
|
||||
self.width = 80
|
||||
self.height = 25
|
||||
@ -33,8 +33,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlistrow:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -59,7 +62,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlistrow:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -83,6 +88,7 @@ function columnlistrow:draw()
|
||||
local textcolor = self.textcolor
|
||||
|
||||
for k, v in ipairs(self.columndata) do
|
||||
love.graphics.setFont(self.font)
|
||||
love.graphics.setColor(unpack(textcolor))
|
||||
love.graphics.print(v, self.x + x, self.y + self.texty)
|
||||
x = x + cwidth
|
||||
|
@ -52,8 +52,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlistheader:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -90,7 +93,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function columnlistheader:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
-- By Nikolai Resokav --
|
||||
--]]------------------------------------------------
|
||||
|
||||
-- panel class
|
||||
-- modalbackground class
|
||||
modalbackground = class("modalbackground", base)
|
||||
modalbackground:include(loveframes.templates.default)
|
||||
|
||||
@ -36,13 +36,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function modalbackground:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if self.object:IsActive() == false then
|
||||
local object = self.object
|
||||
|
||||
if object:IsActive() == false then
|
||||
self:Remove()
|
||||
loveframes.modalobject = false
|
||||
end
|
||||
|
@ -49,8 +49,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoicelist:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -93,11 +96,6 @@ function multichoicelist:update(dt)
|
||||
v.x = (v.parent.x + v.staticx) - self.offsetx
|
||||
end
|
||||
|
||||
--if loveframes.base.children[#loveframes.base.children] ~= self then
|
||||
-- self:Remove()
|
||||
-- table.insert(loveframes.base.children, self)
|
||||
--end
|
||||
|
||||
if self.Update then
|
||||
self.Update(self, dt)
|
||||
end
|
||||
|
@ -30,8 +30,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoicerow:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -68,6 +71,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoicerow:draw()
|
||||
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
||||
-- scrollbar class
|
||||
scrollarea = class("scrollarea", base)
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: initialize()
|
||||
- desc: initializes the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollarea:initialize(parent, bartype)
|
||||
|
||||
self.type = "scroll-area"
|
||||
@ -23,10 +27,17 @@ function scrollarea:initialize(parent, bartype)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: update(deltatime)
|
||||
- desc: updates the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollarea:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -39,49 +50,59 @@ function scrollarea:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if self.parent.internals[2] then
|
||||
local parent = self.parent
|
||||
local pinternals = parent.internals
|
||||
local button = pinternals[2]
|
||||
local bartype = self.bartype
|
||||
local time = love.timer.getTime()
|
||||
local x, y = love.mouse.getPosition()
|
||||
local listo = parent.parent
|
||||
local down = self.down
|
||||
local scrolldelay = self.scrolldelay
|
||||
local delayamount = self.delayamount
|
||||
local internals = self.internals
|
||||
local bar = internals[1]
|
||||
local hover = self.hover
|
||||
|
||||
if self.bartype == "vertical" then
|
||||
if button then
|
||||
|
||||
if bartype == "vertical" then
|
||||
self.staticx = 0
|
||||
self.staticy = self.parent.internals[2].height - 1
|
||||
self.width = self.parent.width
|
||||
self.height = self.parent.height - self.parent.internals[2].height*2 + 2
|
||||
elseif self.bartype == "horizontal" then
|
||||
self.staticx = self.parent.internals[2].width - 1
|
||||
self.staticy = button.height - 1
|
||||
self.width = parent.width
|
||||
self.height = parent.height - button.height*2 + 2
|
||||
elseif bartype == "horizontal" then
|
||||
self.staticx = button.width - 1
|
||||
self.staticy = 0
|
||||
self.width = self.parent.width - self.parent.internals[2].width*2 + 2
|
||||
self.height = self.parent.height
|
||||
self.width = parent.width - button.width*2 + 2
|
||||
self.height = parent.height
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local time = love.timer.getTime()
|
||||
local x, y = love.mouse.getPosition()
|
||||
local listo = self.parent.parent
|
||||
|
||||
if self.down == true then
|
||||
if self.scrolldelay < time then
|
||||
self.scrolldelay = time + self.delayamount
|
||||
if down == true then
|
||||
if scrolldelay < time then
|
||||
self.scrolldelay = time + delayamount
|
||||
if listo.display == "vertical" then
|
||||
if y > self.internals[1].y then
|
||||
self.internals[1]:Scroll(self.internals[1].height)
|
||||
if y > bar.y then
|
||||
bar:Scroll(bar.height)
|
||||
else
|
||||
self.internals[1]:Scroll(-self.internals[1].height)
|
||||
bar:Scroll(-bar.height)
|
||||
end
|
||||
elseif listo.display == "horizontal" then
|
||||
if x > self.internals[1].x then
|
||||
self.internals[1]:Scroll(self.internals[1].width)
|
||||
if x > bar.x then
|
||||
bar:Scroll(bar.width)
|
||||
else
|
||||
self.internals[1]:Scroll(-self.internals[1].width)
|
||||
bar:Scroll(-bar.width)
|
||||
end
|
||||
end
|
||||
end
|
||||
if self.hover == false then
|
||||
if hover == false then
|
||||
self.down = false
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
@ -91,12 +112,20 @@ function scrollarea:update(dt)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: draw()
|
||||
- desc: draws the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollarea:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
@ -112,56 +141,84 @@ function scrollarea:draw()
|
||||
skin.DrawScrollArea(self)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousepressed(x, y, button)
|
||||
- desc: called when the player presses a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function scrollarea:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local listo = self.parent.parent
|
||||
local time = love.timer.getTime()
|
||||
local internals = self.internals
|
||||
local bar = internals[1]
|
||||
local hover = self.hover
|
||||
local delayamount = self.delayamount
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
if hover == true and button == "l" then
|
||||
self.down = true
|
||||
self.scrolldelay = time + self.delayamount + 0.5
|
||||
self.scrolldelay = time + delayamount + 0.5
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
if listo.display == "vertical" then
|
||||
if y > self.internals[1].y then
|
||||
self.internals[1]:Scroll(self.internals[1].height)
|
||||
bar:Scroll(bar.height)
|
||||
else
|
||||
self.internals[1]:Scroll(-self.internals[1].height)
|
||||
bar:Scroll(-bar.height)
|
||||
end
|
||||
elseif listo.display == "horizontal" then
|
||||
if x > self.internals[1].x then
|
||||
self.internals[1]:Scroll(self.internals[1].width)
|
||||
if x > bar.x then
|
||||
bar:Scroll(bar.width)
|
||||
else
|
||||
self.internals[1]:Scroll(-self.internals[1].width)
|
||||
bar:Scroll(-bar.width)
|
||||
end
|
||||
end
|
||||
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousereleased(x, y, button)
|
||||
- desc: called when the player releases a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function scrollarea:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
if button == "l" then
|
||||
self.down = false
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
||||
-- scrollbar class
|
||||
scrollbar = class("scrollbar", base)
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: initialize()
|
||||
- desc: initializes the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:initialize(parent, bartype)
|
||||
|
||||
self.type = "scrollbar"
|
||||
@ -40,23 +44,32 @@ function scrollbar:initialize(parent, bartype)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: update(deltatime)
|
||||
- desc: updates the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:update(dt)
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local bartype = self.bartype
|
||||
local cols, basecols = {}, {}
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if self.bartype == "vertical" then
|
||||
local x, y = love.mouse.getPosition()
|
||||
local bartype = self.bartype
|
||||
local cols = {}
|
||||
local basecols = {}
|
||||
local dragging = self.dragging
|
||||
|
||||
if bartype == "vertical" then
|
||||
self.width = self.parent.width
|
||||
elseif self.bartype == "horizontal" then
|
||||
elseif bartype == "horizontal" then
|
||||
self.height = self.parent.height
|
||||
end
|
||||
|
||||
@ -76,7 +89,7 @@ function scrollbar:update(dt)
|
||||
self.x = parent.x + parent.width - self.width
|
||||
self.y = parent.y + self.staticy
|
||||
|
||||
if self.dragging == true then
|
||||
if dragging == true then
|
||||
if self.staticy ~= self.lasty then
|
||||
if listo.OnScroll then
|
||||
listo.OnScroll(listo)
|
||||
@ -90,6 +103,8 @@ function scrollbar:update(dt)
|
||||
local remaining = (0 + self.staticy)
|
||||
local percent = remaining/space
|
||||
local extra = listo.extra * percent
|
||||
local autoscroll = self.autoscroll
|
||||
local lastheight = self.lastheight
|
||||
|
||||
listo.offsety = 0 + extra
|
||||
|
||||
@ -103,8 +118,8 @@ function scrollbar:update(dt)
|
||||
listo.offsety = 0
|
||||
end
|
||||
|
||||
if self.autoscroll == true then
|
||||
if listo.itemheight ~= self.lastheight then
|
||||
if autoscroll == true then
|
||||
if listo.itemheight ~= lastheight then
|
||||
self.lastheight = listo.itemheight
|
||||
self:Scroll(self.maxy)
|
||||
end
|
||||
@ -128,7 +143,7 @@ function scrollbar:update(dt)
|
||||
self.x = parent.x + self.staticx
|
||||
self.y = parent.y + self.staticy
|
||||
|
||||
if self.dragging == true then
|
||||
if dragging == true then
|
||||
if self.staticx ~= self.lastx then
|
||||
if listo.OnScroll then
|
||||
listo.OnScroll(listo)
|
||||
@ -142,6 +157,8 @@ function scrollbar:update(dt)
|
||||
local remaining = (0 + self.staticx)
|
||||
local percent = remaining/space
|
||||
local extra = listo.extra * percent
|
||||
local autoscroll = self.autoscroll
|
||||
local lastwidth = self.lastwidth
|
||||
|
||||
listo.offsetx = 0 + extra
|
||||
|
||||
@ -155,8 +172,8 @@ function scrollbar:update(dt)
|
||||
listo.offsetx = 0
|
||||
end
|
||||
|
||||
if self.autoscroll == true then
|
||||
if self.width ~= self.lastwidth then
|
||||
if autoscroll == true then
|
||||
if self.width ~= lastwidth then
|
||||
self.width = self.width
|
||||
self:Scroll(self.maxx)
|
||||
end
|
||||
@ -170,9 +187,15 @@ function scrollbar:update(dt)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: draw()
|
||||
- desc: draws the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -193,13 +216,20 @@ function scrollbar:draw()
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousepressed(x, y, button)
|
||||
- desc: called when the player presses a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local hover = self.hover
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == false then
|
||||
if hover == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -208,8 +238,10 @@ function scrollbar:mousepressed(x, y, button)
|
||||
if baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
if self.dragging == false then
|
||||
|
||||
local dragging = self.dragging
|
||||
|
||||
if dragging == false then
|
||||
|
||||
if button == "l" then
|
||||
|
||||
@ -226,9 +258,15 @@ function scrollbar:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousereleased(x, y, button)
|
||||
- desc: called when the player releases a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -238,18 +276,30 @@ function scrollbar:mousereleased(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetMaxX(x)
|
||||
- desc: sets the object's max x position
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:SetMaxX(x)
|
||||
|
||||
self.maxx = x
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetMaxY(y)
|
||||
- desc: sets the object's max y position
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:SetMaxY(y)
|
||||
|
||||
self.maxy = y
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: Scroll(amount)
|
||||
- desc: scrolls the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbar:Scroll(amount)
|
||||
|
||||
local bartype = self.bartype
|
||||
|
@ -6,6 +6,10 @@
|
||||
-- scrollbar class
|
||||
scrollbody = class("scrollbody", base)
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: initialize()
|
||||
- desc: initializes the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbody:initialize(parent, bartype)
|
||||
|
||||
self.type = "scroll-body"
|
||||
@ -86,6 +90,10 @@ function scrollbody:initialize(parent, bartype)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: update(deltatime)
|
||||
- desc: updates the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbody:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
@ -112,6 +120,10 @@ function scrollbody:update(dt)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: draw()
|
||||
- desc: draws the object
|
||||
--]]---------------------------------------------------------
|
||||
function scrollbody:draw()
|
||||
|
||||
if self.visible == false then
|
||||
@ -137,28 +149,4 @@ function scrollbody:draw()
|
||||
v:draw()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function scrollbody:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function scrollbody:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
end
|
@ -20,14 +20,14 @@ function sliderbutton:initialize(parent)
|
||||
self.staticy = 0
|
||||
self.startx = 0
|
||||
self.clickx = 0
|
||||
self.starty = 0
|
||||
self.clicky = 0
|
||||
self.intervals = true
|
||||
self.internal = true
|
||||
self.down = false
|
||||
self.dragging = false
|
||||
self.parent = parent
|
||||
|
||||
self:SetY(self.parent.ycenter - self.height/2)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
@ -36,26 +36,38 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function sliderbutton:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local intervals = self.intervals
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if self.hover == false then
|
||||
local x, y = love.mouse.getPosition()
|
||||
local intervals = self.intervals
|
||||
local progress = 0
|
||||
local nvalue = 0
|
||||
local pvalue = 0
|
||||
local hover = self.hover
|
||||
local down = self.down
|
||||
local hoverobject = loveframes.hoverobject
|
||||
local parent = self.parent
|
||||
local slidetype = parent.slidetype
|
||||
local dragging = self.dragging
|
||||
|
||||
if hover == false then
|
||||
self.down = false
|
||||
elseif self.hover == true then
|
||||
if loveframes.hoverobject == self then
|
||||
elseif hover == true then
|
||||
if hoverobject == self then
|
||||
self.down = true
|
||||
end
|
||||
end
|
||||
|
||||
if self.down == false and loveframes.hoverobject == self then
|
||||
if down == false and hoverobject == self then
|
||||
self.hover = true
|
||||
end
|
||||
|
||||
@ -65,21 +77,43 @@ function sliderbutton:update(dt)
|
||||
self.y = self.parent.y + self.staticy
|
||||
end
|
||||
|
||||
if self.dragging == true then
|
||||
self.staticx = self.startx + (x - self.clickx)
|
||||
end
|
||||
if slidetype == "horizontal" then
|
||||
|
||||
if (self.staticx + self.width) > self.parent.width then
|
||||
self.staticx = self.parent.width - self.width
|
||||
end
|
||||
|
||||
if self.staticx < 0 then
|
||||
self.staticx = 0
|
||||
end
|
||||
if dragging == true then
|
||||
self.staticx = self.startx + (x - self.clickx)
|
||||
end
|
||||
|
||||
if (self.staticx + self.width) > self.parent.width then
|
||||
self.staticx = self.parent.width - self.width
|
||||
end
|
||||
|
||||
if self.staticx < 0 then
|
||||
self.staticx = 0
|
||||
end
|
||||
|
||||
local progress = loveframes.util.Round(self.staticx/(self.parent.width - self.width), 5)
|
||||
local nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
|
||||
local pvalue = self.parent.value
|
||||
progress = loveframes.util.Round(self.staticx/(self.parent.width - self.width), 5)
|
||||
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
|
||||
pvalue = self.parent.value
|
||||
|
||||
elseif slidetype == "vertical" then
|
||||
|
||||
if dragging == true then
|
||||
self.staticy = self.starty + (y - self.clicky)
|
||||
end
|
||||
|
||||
if (self.staticy + self.height) > self.parent.height then
|
||||
self.staticy = self.parent.height - self.height
|
||||
end
|
||||
|
||||
if self.staticy < 0 then
|
||||
self.staticy = 0
|
||||
end
|
||||
|
||||
progress = loveframes.util.Round(self.staticy/(self.parent.height - self.height), 5)
|
||||
nvalue = self.parent.min + (self.parent.max - self.parent.min) * progress
|
||||
pvalue = self.parent.value
|
||||
|
||||
end
|
||||
|
||||
if nvalue ~= pvalue then
|
||||
self.parent.value = loveframes.util.Round(nvalue, self.parent.decimals)
|
||||
@ -88,6 +122,10 @@ function sliderbutton:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
if dragging == true then
|
||||
loveframes.hoverobject = self
|
||||
end
|
||||
|
||||
if self.Update then
|
||||
self.Update(self, dt)
|
||||
end
|
||||
@ -100,7 +138,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function sliderbutton:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -127,11 +167,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function sliderbutton:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -143,6 +187,8 @@ function sliderbutton:mousepressed(x, y, button)
|
||||
self.dragging = true
|
||||
self.startx = self.staticx
|
||||
self.clickx = x
|
||||
self.starty = self.staticy
|
||||
self.clicky = y
|
||||
loveframes.hoverobject = self
|
||||
|
||||
end
|
||||
@ -155,7 +201,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function sliderbutton:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -164,8 +212,22 @@ function sliderbutton:mousereleased(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: MoveToX(x)
|
||||
- desc: moves the object to the specified x position
|
||||
--]]---------------------------------------------------------
|
||||
function sliderbutton:MoveToX(x)
|
||||
|
||||
self.staticx = x
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: MoveToY(x)
|
||||
- desc: moves the object to the specified y position
|
||||
--]]---------------------------------------------------------
|
||||
function sliderbutton:MoveToY(y)
|
||||
|
||||
self.staticy = y
|
||||
|
||||
end
|
@ -43,8 +43,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabbutton:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -108,12 +111,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabbutton:mousepressed(x, y, button)
|
||||
|
||||
local visible = self.visible
|
||||
|
||||
if self.visible == false then
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -134,16 +140,20 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabbutton:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local pinternals = self.parent.internals
|
||||
local hover = self.hover
|
||||
local parent = self.parent
|
||||
local tabnumber = self.tabnumber
|
||||
|
||||
if self.hover == true and self.down == true then
|
||||
if hover == true and button == "l" then
|
||||
|
||||
if button == "l" then
|
||||
self.parent:SwitchToTab(self.tabnumber)
|
||||
parent:SwitchToTab(tabnumber)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -45,14 +45,19 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tooltip:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
self.width = self.text.width + self.padding*2
|
||||
self.height = self.text.height + self.padding*2
|
||||
local text = self.text
|
||||
|
||||
self.width = text.width + self.padding*2
|
||||
self.height = text.height + self.padding*2
|
||||
|
||||
local object = self.object
|
||||
local draworder = self.draworder
|
||||
@ -82,7 +87,7 @@ function tooltip:update(dt)
|
||||
self:MoveToTop()
|
||||
end
|
||||
|
||||
self.text:SetPos(self.padding, self.padding)
|
||||
text:SetPos(self.padding, self.padding)
|
||||
|
||||
end
|
||||
|
||||
@ -93,7 +98,7 @@ function tooltip:update(dt)
|
||||
|
||||
end
|
||||
|
||||
self.text:update(dt)
|
||||
text:update(dt)
|
||||
|
||||
if self.Update then
|
||||
self.Update(self, dt)
|
||||
@ -107,20 +112,25 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tooltip:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
local show = self.show
|
||||
local text = self.text
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
local selfskin = self.skin
|
||||
local skin = loveframes.skins.available[selfskin] or loveframes.skins.available[index] or loveframes.skins.available[defaultskin]
|
||||
|
||||
if self.show == true then
|
||||
if show == true then
|
||||
|
||||
if self.Draw ~= nil then
|
||||
self.Draw(self)
|
||||
@ -128,36 +138,12 @@ function tooltip:draw()
|
||||
skin.DrawToolTip(self)
|
||||
end
|
||||
|
||||
self.text:draw()
|
||||
text:draw()
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousepressed(x, y, button)
|
||||
- desc: called when the player presses a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function tooltip:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousereleased(x, y, button)
|
||||
- desc: called when the player releases a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function tooltip:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetFollowCursor(bool)
|
||||
- desc: sets whether or not the tooltip should follow the
|
||||
|
122
objects/list.lua
122
objects/list.lua
@ -40,12 +40,19 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
local display = self.display
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if self.parent ~= loveframes.base then
|
||||
self.x = self.parent.x + self.staticx
|
||||
@ -54,17 +61,17 @@ function list:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:update(dt)
|
||||
v:SetClickBounds(self.x, self.y, self.width, self.height)
|
||||
v.y = (v.parent.y + v.staticy) - self.offsety
|
||||
v.x = (v.parent.x + v.staticx) - self.offsetx
|
||||
|
||||
if self.display == "vertical" then
|
||||
if display == "vertical" then
|
||||
if v.lastheight ~= v.height then
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
@ -85,13 +92,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
@ -109,7 +121,7 @@ function list:draw()
|
||||
|
||||
love.graphics.setStencil(stencil)
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
local col = loveframes.util.BoundingBox(self.x, v.x, self.y, v.y, self.width, v.width, self.height, v.height)
|
||||
if col == true then
|
||||
v:draw()
|
||||
@ -118,7 +130,7 @@ function list:draw()
|
||||
|
||||
love.graphics.setStencil()
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -134,13 +146,20 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local toplist = self:IsTopList()
|
||||
local hover = self.hover
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local children = self.children
|
||||
local internals = self.internals
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -150,7 +169,7 @@ function list:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
if self.vbar == true or self.hbar == true then
|
||||
if vbar == true or hbar == true then
|
||||
|
||||
if toplist == true then
|
||||
|
||||
@ -166,36 +185,16 @@ function list:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousereleased(x, y, button)
|
||||
- desc: called when the player releases a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function list:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: AddItem(object)
|
||||
- desc: adds an item to the object
|
||||
@ -205,11 +204,13 @@ function list:AddItem(object)
|
||||
if object.type == "frame" then
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
|
||||
object:Remove()
|
||||
object.parent = self
|
||||
|
||||
table.insert(self.children, object)
|
||||
table.insert(children, object)
|
||||
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
@ -223,7 +224,6 @@ end
|
||||
function list:RemoveItem(object)
|
||||
|
||||
object:Remove()
|
||||
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
|
||||
@ -245,6 +245,8 @@ function list:CalculateSize()
|
||||
local display = self.display
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
local internals = self.internals
|
||||
local children = self.children
|
||||
|
||||
if display == "vertical" then
|
||||
|
||||
@ -254,13 +256,15 @@ function list:CalculateSize()
|
||||
|
||||
self.itemheight = (itemheight - spacing) + padding
|
||||
|
||||
if self.itemheight > height then
|
||||
local itemheight = self.itemheight
|
||||
|
||||
self.extra = self.itemheight - height
|
||||
if itemheight > height then
|
||||
|
||||
self.extra = itemheight - height
|
||||
|
||||
if vbar == false then
|
||||
local scrollbar = scrollbody:new(self, display)
|
||||
table.insert(self.internals, scrollbar)
|
||||
table.insert(internals, scrollbar)
|
||||
self.vbar = true
|
||||
self:GetScrollBar().autoscroll = self.autoscroll
|
||||
end
|
||||
@ -268,7 +272,8 @@ function list:CalculateSize()
|
||||
else
|
||||
|
||||
if vbar == true then
|
||||
self.internals[1]:Remove()
|
||||
local bar = internals[1]
|
||||
bar:Remove()
|
||||
self.vbar = false
|
||||
self.offsety = 0
|
||||
end
|
||||
@ -277,19 +282,21 @@ function list:CalculateSize()
|
||||
|
||||
elseif display == "horizontal" then
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
itemwidth = itemwidth + v.width + spacing
|
||||
end
|
||||
|
||||
self.itemwidth = (itemwidth - spacing) + padding
|
||||
|
||||
if self.itemwidth > width then
|
||||
local itemwidth = self.itemwidth
|
||||
|
||||
if itemwidth > width then
|
||||
|
||||
self.extra = self.itemwidth - width
|
||||
self.extra = itemwidth - width
|
||||
|
||||
if hbar == false then
|
||||
local scrollbar = scrollbody:new(self, display)
|
||||
table.insert(self.internals, scrollbar)
|
||||
table.insert(internals, scrollbar)
|
||||
self.hbar = true
|
||||
self:GetScrollBar().autoscroll = self.autoscroll
|
||||
end
|
||||
@ -297,7 +304,8 @@ function list:CalculateSize()
|
||||
else
|
||||
|
||||
if hbar == true then
|
||||
self.internals[1]:Remove()
|
||||
local bar = internals[1]
|
||||
bar:Remove()
|
||||
self.hbar = false
|
||||
self.offsetx = 0
|
||||
end
|
||||
@ -390,6 +398,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:SetDisplayType(type)
|
||||
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
|
||||
self.display = type
|
||||
|
||||
self.internals = {}
|
||||
@ -398,7 +409,7 @@ function list:SetDisplayType(type)
|
||||
self.offsetx = 0
|
||||
self.offsety = 0
|
||||
|
||||
if #self.children > 0 then
|
||||
if numchildren > 0 then
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
end
|
||||
@ -421,9 +432,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:SetPadding(amount)
|
||||
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
|
||||
self.padding = amount
|
||||
|
||||
if #self.children > 0 then
|
||||
if numchildren > 0 then
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
end
|
||||
@ -436,9 +450,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:SetSpacing(amount)
|
||||
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
|
||||
self.spacing = amount
|
||||
|
||||
if #self.children > 0 then
|
||||
if numchildren > 0 then
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
end
|
||||
@ -464,7 +481,6 @@ end
|
||||
function list:SetWidth(width)
|
||||
|
||||
self.width = width
|
||||
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
|
||||
@ -477,7 +493,6 @@ end
|
||||
function list:SetHeight(height)
|
||||
|
||||
self.height = height
|
||||
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
|
||||
@ -491,7 +506,6 @@ function list:SetSize(width, height)
|
||||
|
||||
self.width = width
|
||||
self.height = height
|
||||
|
||||
self:CalculateSize()
|
||||
self:RedoLayout()
|
||||
|
||||
@ -503,16 +517,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function list:GetScrollBar()
|
||||
|
||||
if self.vbar == true or self.hbar == true then
|
||||
local vbar = self.vbar
|
||||
local hbar = self.hbar
|
||||
|
||||
if vbar == true or hbar == true then
|
||||
local scrollbar = self.internals[1].internals[1].internals[1]
|
||||
|
||||
return scrollbar
|
||||
|
||||
else
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -33,8 +33,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoice:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -59,7 +62,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoice:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -86,11 +91,16 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoice:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and self.haslist == false and button == "l" then
|
||||
local hover = self.hover
|
||||
local haslist = self.haslist
|
||||
|
||||
if hover == true and haslist == false and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -112,7 +122,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoice:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -124,7 +136,8 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function multichoice:AddChoice(choice)
|
||||
|
||||
table.insert(self.choices, choice)
|
||||
local choices = self.choices
|
||||
table.insert(choices, choice)
|
||||
|
||||
end
|
||||
|
||||
@ -145,7 +158,6 @@ end
|
||||
function multichoice:SelectChoice(choice)
|
||||
|
||||
self.choice = choice
|
||||
|
||||
self.list:Close()
|
||||
|
||||
if self.OnChoiceSelected then
|
||||
|
@ -27,12 +27,17 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function panel:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if self.parent ~= loveframes.base and self.parent.type ~= "list" then
|
||||
self.x = self.parent.x + self.staticx
|
||||
@ -41,7 +46,7 @@ function panel:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:update(dt)
|
||||
end
|
||||
|
||||
@ -57,10 +62,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function panel:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local children = self.children
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
@ -77,7 +86,7 @@ function panel:draw()
|
||||
end
|
||||
|
||||
-- loop through the object's children and draw them
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -89,11 +98,16 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function panel:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
local children = self.children
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true and button == "l" then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -103,7 +117,7 @@ function panel:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
@ -115,11 +129,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function panel:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
|
@ -37,8 +37,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function progressbar:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -49,6 +52,7 @@ function progressbar:update(dt)
|
||||
local lerpto = self.lerpto
|
||||
local lerpfrom = self.lerpfrom
|
||||
local value = self.value
|
||||
local completed = self.completed
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -102,7 +106,7 @@ function progressbar:update(dt)
|
||||
end
|
||||
|
||||
-- completion check
|
||||
if self.completed == false then
|
||||
if completed == false then
|
||||
if self.value >= self.max then
|
||||
self.completed = true
|
||||
if self.OnComplete then
|
||||
@ -123,7 +127,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function progressbar:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -15,12 +15,12 @@ function slider:initialize()
|
||||
|
||||
self.type = "slider"
|
||||
self.text = "Slider"
|
||||
self.width = 200
|
||||
self.height = 35
|
||||
self.slidetype = "horizontal"
|
||||
self.width = 5
|
||||
self.height = 5
|
||||
self.max = 10
|
||||
self.min = 0
|
||||
self.value = 0
|
||||
self.ycenter = 25
|
||||
self.decimals = 5
|
||||
self.internal = false
|
||||
self.internals = {}
|
||||
@ -40,12 +40,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function slider:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
local sliderbutton = internals[1]
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
-- move to parent if there is a parent
|
||||
@ -54,6 +60,14 @@ function slider:update(dt)
|
||||
self.y = self.parent.y + self.staticy
|
||||
end
|
||||
|
||||
if sliderbutton then
|
||||
if self.slidetype == "horizontal" then
|
||||
self.height = sliderbutton.height
|
||||
elseif self.slidetype == "vertical" then
|
||||
self.width = sliderbutton.width
|
||||
end
|
||||
end
|
||||
|
||||
-- update internals
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:update(dt)
|
||||
@ -71,10 +85,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function slider:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
@ -91,7 +109,7 @@ function slider:draw()
|
||||
end
|
||||
|
||||
-- draw internals
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -103,25 +121,47 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function slider:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true and button == "l" then
|
||||
|
||||
local xpos = x - self.x
|
||||
local button = self.internals[1]
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
if self.slidetype == "horizontal" then
|
||||
|
||||
button:MoveToX(xpos)
|
||||
button.down = true
|
||||
button.dragging = true
|
||||
button.startx = button.staticx
|
||||
button.clickx = x
|
||||
local xpos = x - self.x
|
||||
local button = self.internals[1]
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
button:MoveToX(xpos)
|
||||
button.down = true
|
||||
button.dragging = true
|
||||
button.startx = button.staticx
|
||||
button.clickx = x
|
||||
|
||||
elseif self.slidetype == "vertical" then
|
||||
|
||||
local ypos = y - self.y
|
||||
local button = self.internals[1]
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
if baseparent and baseparent.type == "frame" then
|
||||
baseparent:MakeTop()
|
||||
end
|
||||
|
||||
button:MoveToY(ypos)
|
||||
button.down = true
|
||||
button.dragging = true
|
||||
button.starty = button.staticy
|
||||
button.clicky = y
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -132,22 +172,6 @@ function slider:mousepressed(x, y, button)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: mousereleased(x, y, button)
|
||||
- desc: called when the player releases a mouse button
|
||||
--]]---------------------------------------------------------
|
||||
function slider:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetValue(value)
|
||||
- desc: sets the object's value
|
||||
@ -164,18 +188,22 @@ function slider:SetValue(value)
|
||||
|
||||
local decimals = self.decimals
|
||||
local newval = loveframes.util.Round(value, decimals)
|
||||
local internals = self.internals
|
||||
|
||||
-- set the new value
|
||||
self.value = newval
|
||||
|
||||
-- slider button object
|
||||
local button = self.internals[1]
|
||||
|
||||
-- new position for the slider button
|
||||
local xpos = self.width * (( newval - self.min ) / (self.max - self.min))
|
||||
local sliderbutton = internals[1]
|
||||
|
||||
-- move the slider button to the new position
|
||||
button:MoveToX(xpos)
|
||||
if self.slidetype == "horizontal" then
|
||||
local xpos = self.width * (( newval - self.min ) / (self.max - self.min))
|
||||
sliderbutton:MoveToX(xpos)
|
||||
elseif self.slidetype == "vertical" then
|
||||
local ypos = self.height * (( newval - self.min ) / (self.max - self.min))
|
||||
sliderbutton:MoveToY(ypos)
|
||||
end
|
||||
|
||||
-- call OnValueChanged
|
||||
if self.OnValueChanged then
|
||||
@ -255,28 +283,6 @@ function slider:GetMinMax()
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetButtonYCenter(y)
|
||||
- desc: sets the object's y center for it's slider
|
||||
button
|
||||
--]]---------------------------------------------------------
|
||||
function slider:SetButtonYCenter(y)
|
||||
|
||||
self.ycenter = y
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetButtonYCenter()
|
||||
- desc: get's the object's y center of it's slider
|
||||
button
|
||||
--]]---------------------------------------------------------
|
||||
function slider:GetButtonYCenter()
|
||||
|
||||
return self.ycenter
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetText(name)
|
||||
- desc: sets the objects's text
|
||||
@ -305,4 +311,47 @@ function slider:SetDecimals(decimals)
|
||||
|
||||
self.decimals = decimals
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetButtonSize(width, height)
|
||||
- desc: sets the objects's button size
|
||||
--]]---------------------------------------------------------
|
||||
function slider:SetButtonSize(width, height)
|
||||
|
||||
local internals = self.internals
|
||||
local sliderbutton = self.internals[1]
|
||||
|
||||
if sliderbutton then
|
||||
sliderbutton.width = width
|
||||
sliderbutton.height = height
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: GetButtonSize()
|
||||
- desc: gets the objects's button size
|
||||
--]]---------------------------------------------------------
|
||||
function slider:GetButtonSize()
|
||||
|
||||
local internals = self.internals
|
||||
local sliderbutton = self.internals[1]
|
||||
|
||||
if sliderbutton then
|
||||
return sliderbutton.width, sliderbutton.height
|
||||
else
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: SetSlideType(slidetype)
|
||||
- desc: sets the objects's slide type
|
||||
--]]---------------------------------------------------------
|
||||
function slider:SetSlideType(slidetype)
|
||||
|
||||
self.slidetype = slidetype
|
||||
|
||||
end
|
123
objects/tabs.lua
123
objects/tabs.lua
@ -38,6 +38,15 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:update(dt)
|
||||
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local x, y = love.mouse.getPosition()
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
@ -45,12 +54,10 @@ function tabs:update(dt)
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local internals = self.internals
|
||||
local tab = self.tab
|
||||
|
||||
-- move to parent if there is a parent
|
||||
if self.parent ~= loveframes.base then
|
||||
@ -60,13 +67,13 @@ function tabs:update(dt)
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
if #self.children > 0 and self.tab == 0 then
|
||||
if numchildren > 0 and tab == 0 then
|
||||
self.tab = 1
|
||||
end
|
||||
|
||||
local pos = 0
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:update(dt)
|
||||
if v.type == "tabbutton" then
|
||||
v.y = (v.parent.y + v.staticy)
|
||||
@ -75,7 +82,7 @@ function tabs:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
for k, v in ipairs(children) do
|
||||
v:update(dt)
|
||||
v:SetPos(padding, tabheight + padding)
|
||||
end
|
||||
@ -92,10 +99,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
@ -117,7 +128,7 @@ function tabs:draw()
|
||||
|
||||
love.graphics.setStencil(stencil)
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:draw()
|
||||
end
|
||||
|
||||
@ -135,11 +146,20 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true then
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local tab = self.tab
|
||||
local internals = self.internals
|
||||
local numinternals = #internals
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true then
|
||||
|
||||
if button == "l" then
|
||||
|
||||
@ -157,7 +177,7 @@ function tabs:mousepressed(x, y, button)
|
||||
|
||||
local buttonheight = self:GetHeightOfButtons()
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
|
||||
local visible = self.internals[#self.internals - 1]:GetVisible()
|
||||
local visible = internals[numinternals - 1]:GetVisible()
|
||||
|
||||
if col == true and visible == true then
|
||||
self.offsetx = self.offsetx + 5
|
||||
@ -172,24 +192,25 @@ function tabs:mousepressed(x, y, button)
|
||||
|
||||
local buttonheight = self:GetHeightOfButtons()
|
||||
local col = loveframes.util.BoundingBox(self.x, x, self.y, y, self.width, 1, buttonheight, 1)
|
||||
local visible = self.internals[#self.internals]:GetVisible()
|
||||
local visible = internals[numinternals]:GetVisible()
|
||||
|
||||
if col == true and visible == true then
|
||||
self.offsetx = self.offsetx - 5
|
||||
local bwidth = self:GetWidthOfButtons()
|
||||
if (self.offsetx + bwidth) < self.width then
|
||||
self.offsetx = bwidth - self.width
|
||||
else
|
||||
self.offsetx = self.offsetx - 5
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
if #self.children > 0 then
|
||||
self.children[self.tab]:mousepressed(x, y, button)
|
||||
if numchildren > 0 then
|
||||
children[tab]:mousepressed(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
@ -200,16 +221,22 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
local children = self.children
|
||||
local numchildren = #children
|
||||
local tab = self.tab
|
||||
local internals = self.internals
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
v:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
if #self.children > 0 then
|
||||
self.children[self.tab]:mousereleased(x, y, button)
|
||||
if numchildren > 0 then
|
||||
children[tab]:mousereleased(x, y, button)
|
||||
end
|
||||
|
||||
end
|
||||
@ -223,6 +250,9 @@ function tabs:AddTab(name, object, tip, image)
|
||||
local tabheight = self.tabheight
|
||||
local padding = self.padding
|
||||
local autosize = self.autosize
|
||||
local retainsize = object.retainsize
|
||||
local tabnumber = self.tabnumber
|
||||
local internals = self.internals
|
||||
|
||||
object:Remove()
|
||||
object.parent = self
|
||||
@ -232,18 +262,18 @@ function tabs:AddTab(name, object, tip, image)
|
||||
object:SetHeight(self.height - 35)
|
||||
|
||||
table.insert(self.children, object)
|
||||
self.internals[self.tabnumber] = tabbutton:new(self, name, self.tabnumber, tip, image)
|
||||
self.internals[self.tabnumber].height = self.tabheight
|
||||
self.tabnumber = self.tabnumber + 1
|
||||
internals[tabnumber] = tabbutton:new(self, name, tabnumber, tip, image)
|
||||
internals[tabnumber].height = self.tabheight
|
||||
self.tabnumber = tabnumber + 1
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
self:SwitchToTab(k)
|
||||
break
|
||||
end
|
||||
|
||||
self:AddScrollButtons()
|
||||
|
||||
if autosize == true and object.retainsize == false then
|
||||
if autosize == true and retainsize == false then
|
||||
object:SetSize(self.width - padding*2, (self.height - tabheight) - padding*2)
|
||||
end
|
||||
|
||||
@ -256,9 +286,11 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:AddScrollButtons()
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
local internals = self.internals
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
if v.type == "scrollbutton" then
|
||||
table.remove(self.internals, k)
|
||||
table.remove(internals, k)
|
||||
end
|
||||
end
|
||||
|
||||
@ -305,8 +337,8 @@ function tabs:AddScrollButtons()
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(self.internals, leftbutton)
|
||||
table.insert(self.internals, rightbutton)
|
||||
table.insert(internals, leftbutton)
|
||||
table.insert(internals, rightbutton)
|
||||
|
||||
end
|
||||
|
||||
@ -317,8 +349,9 @@ end
|
||||
function tabs:GetWidthOfButtons()
|
||||
|
||||
local width = 0
|
||||
local internals = self.internals
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
for k, v in ipairs(internals) do
|
||||
if v.type == "tabbutton" then
|
||||
width = width + v.width
|
||||
end
|
||||
@ -344,12 +377,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:SwitchToTab(tabnumber)
|
||||
|
||||
for k, v in ipairs(self.children) do
|
||||
local children = self.children
|
||||
|
||||
for k, v in ipairs(children) do
|
||||
v.visible = false
|
||||
end
|
||||
|
||||
self.tab = tabnumber
|
||||
self.children[self.tab].visible = true
|
||||
self.children[tabnumber].visible = true
|
||||
|
||||
end
|
||||
|
||||
@ -359,12 +394,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:SetScrollButtonSize(width, height)
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
if v.type == "scrollbutton" then
|
||||
v:SetSize(width, height)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -395,14 +430,14 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:SetTabHeight(height)
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
self.tabheight = height
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
if v.type == "tabbutton" then
|
||||
v:SetHeight(self.tabheight)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -413,12 +448,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function tabs:SetToolTipFont(font)
|
||||
|
||||
for k, v in ipairs(self.internals) do
|
||||
|
||||
local internals = self.internals
|
||||
|
||||
for k, v in ipairs(internals) do
|
||||
if v.type == "tabbutton" and v.tooltip then
|
||||
v.tooltip:SetFont(font)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
@ -130,9 +130,7 @@ function text:SetText(t)
|
||||
local parts = loveframes.util.SplitSring(v, " ")
|
||||
|
||||
for i, j in ipairs(parts) do
|
||||
|
||||
table.insert(self.text, {color = prevcolor, text = j})
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@ -215,12 +213,17 @@ function text:DrawText()
|
||||
local lines = 0
|
||||
local totalwidth = 0
|
||||
local prevtextwidth
|
||||
local x = self.x
|
||||
local y = self.y
|
||||
|
||||
for k, v in ipairs(textdata) do
|
||||
|
||||
if type(v.text) == "string" then
|
||||
local text = v.text
|
||||
local color = v.color
|
||||
|
||||
local width = font:getWidth(v.text)
|
||||
if type(text) == "string" then
|
||||
|
||||
local width = font:getWidth(text)
|
||||
totalwidth = totalwidth + width
|
||||
|
||||
if maxw > 0 then
|
||||
@ -243,8 +246,8 @@ function text:DrawText()
|
||||
prevtextwidth = width
|
||||
|
||||
love.graphics.setFont(font)
|
||||
love.graphics.setColor(unpack(v.color))
|
||||
love.graphics.print(v.text, self.x + drawx, self.y + drawy)
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.print(text, x + drawx, y + drawy)
|
||||
|
||||
else
|
||||
|
||||
@ -255,8 +258,8 @@ function text:DrawText()
|
||||
prevtextwidth = width
|
||||
|
||||
love.graphics.setFont(font)
|
||||
love.graphics.setColor(unpack(v.color))
|
||||
love.graphics.print(v.text, self.x + drawx, self.y)
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.print(text, x + drawx, y)
|
||||
|
||||
end
|
||||
|
||||
@ -332,10 +335,12 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function text:SetFont(font)
|
||||
|
||||
local original = self.original
|
||||
|
||||
self.font = font
|
||||
|
||||
if self.original then
|
||||
self:SetText(self.original)
|
||||
if original then
|
||||
self:SetText(original)
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -46,13 +46,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:update(dt)
|
||||
|
||||
if self.visible == false then
|
||||
if self.alwaysupdate == false then
|
||||
local visible = self.visible
|
||||
local alwaysupdate = self.alwaysupdate
|
||||
|
||||
if visible == false then
|
||||
if alwaysupdate == false then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local time = love.timer.getTime()
|
||||
local keydown = self.keydown
|
||||
local unicode = self.unicode
|
||||
|
||||
self:CheckHover()
|
||||
|
||||
@ -62,9 +67,9 @@ function textinput:update(dt)
|
||||
self.y = self.parent.y + self.staticy
|
||||
end
|
||||
|
||||
if self.keydown ~= "none" then
|
||||
if keydown ~= "none" then
|
||||
if time > self.delay then
|
||||
self:RunKey(self.keydown, self.unicode)
|
||||
self:RunKey(keydown, unicode)
|
||||
self.delay = time + 0.02
|
||||
end
|
||||
end
|
||||
@ -84,13 +89,21 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:draw()
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
loveframes.drawcount = loveframes.drawcount + 1
|
||||
self.draworder = loveframes.drawcount
|
||||
|
||||
local font = self.font
|
||||
local textcolor = self.textcolor
|
||||
local text = self.text
|
||||
local textx = self.textx
|
||||
local texty = self.texty
|
||||
|
||||
-- skin variables
|
||||
local index = loveframes.config["ACTIVESKIN"]
|
||||
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
||||
@ -107,9 +120,9 @@ function textinput:draw()
|
||||
skin.DrawTextInput(self)
|
||||
end
|
||||
|
||||
love.graphics.setFont(self.font)
|
||||
love.graphics.setColor(unpack(self.textcolor))
|
||||
love.graphics.print(self.text, self.textx, self.texty)
|
||||
love.graphics.setFont(font)
|
||||
love.graphics.setColor(unpack(textcolor))
|
||||
love.graphics.print(text, textx, self.texty)
|
||||
|
||||
love.graphics.setStencil()
|
||||
|
||||
@ -125,7 +138,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:mousepressed(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -133,7 +148,9 @@ function textinput:mousepressed(x, y, button)
|
||||
return
|
||||
end
|
||||
|
||||
if self.hover == true then
|
||||
local hover = self.hover
|
||||
|
||||
if hover == true then
|
||||
|
||||
local baseparent = self:GetBaseParent()
|
||||
|
||||
@ -159,7 +176,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:mousereleased(x, y, button)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -175,13 +194,16 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:keypressed(key, unicode)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
self.delay = love.timer.getTime() + 0.80
|
||||
self.keydown = key
|
||||
local time = love.timer.getTime()
|
||||
|
||||
self.delay = time + 0.80
|
||||
self.keydown = key
|
||||
self:RunKey(key, unicode)
|
||||
|
||||
end
|
||||
@ -192,7 +214,9 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:keyreleased(key)
|
||||
|
||||
if self.visible == false then
|
||||
local visible = self.visible
|
||||
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -205,17 +229,11 @@ end
|
||||
- desc: runs a key event on the object
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:RunKey(key, unicode)
|
||||
|
||||
local text = self.text
|
||||
local ckey = ""
|
||||
local font = self.font
|
||||
local swidth = self.width
|
||||
local twidth = font:getWidth(self.text)
|
||||
local textxoffset = self.textxoffset
|
||||
|
||||
self.unicode = unicode
|
||||
local visible = self.visible
|
||||
local focus = self.focus
|
||||
|
||||
if self.visible == false then
|
||||
if visible == false then
|
||||
return
|
||||
end
|
||||
|
||||
@ -223,28 +241,39 @@ function textinput:RunKey(key, unicode)
|
||||
return
|
||||
end
|
||||
|
||||
local text = self.text
|
||||
local ckey = ""
|
||||
local font = self.font
|
||||
local swidth = self.width
|
||||
local twidth = font:getWidth(self.text)
|
||||
local textxoffset = self.textxoffset
|
||||
local blinkx = self.blinkx
|
||||
local blinknum = self.blinknum
|
||||
|
||||
self.unicode = unicode
|
||||
|
||||
if key == "left" then
|
||||
self:MoveBlinker(-1)
|
||||
if self.blinkx <= self.x and self.blinknum ~= 0 then
|
||||
local width = self.font:getWidth(self.text:sub(self.blinknum, self.blinknum + 1))
|
||||
if blinkx <= self.x and blinknum ~= 0 then
|
||||
local width = self.font:getWidth(self.text:sub(blinknum, blinknum + 1))
|
||||
self.xoffset = self.xoffset + width
|
||||
elseif self.blinknum == 0 and self.xoffset ~= 0 then
|
||||
elseif blinknum == 0 and self.xoffset ~= 0 then
|
||||
self.xoffset = 0
|
||||
end
|
||||
elseif key == "right" then
|
||||
self:MoveBlinker(1)
|
||||
if self.blinkx >= self.x + self.width and self.blinknum ~= #self.text then
|
||||
local width = self.font:getWidth(self.text:sub(self.blinknum, self.blinknum))
|
||||
if blinkx >= self.x + swidth and blinknum ~= #self.text then
|
||||
local width = self.font:getWidth(self.text:sub(blinknum, blinknum))
|
||||
self.xoffset = self.xoffset - width
|
||||
elseif self.blinknum == #self.text and self.xoffset ~= ((0 - font:getWidth(self.text)) + self.width) then
|
||||
self.xoffset = ((0 - font:getWidth(self.text)) + self.width)
|
||||
elseif blinknum == #self.text and self.xoffset ~= ((0 - font:getWidth(self.text)) + swidth) then
|
||||
self.xoffset = ((0 - font:getWidth(self.text)) + swidth)
|
||||
end
|
||||
end
|
||||
|
||||
-- key input checking system
|
||||
if key == "backspace" then
|
||||
if text ~= "" then
|
||||
self.text = self:RemoveFromeText(self.blinknum)
|
||||
self.text = self:RemoveFromeText(blinknum)
|
||||
self:MoveBlinker(-1)
|
||||
end
|
||||
elseif key == "return" then
|
||||
@ -254,8 +283,8 @@ function textinput:RunKey(key, unicode)
|
||||
else
|
||||
if unicode > 31 and unicode < 127 then
|
||||
ckey = string.char(unicode)
|
||||
if self.blinknum ~= 0 and self.blinknum ~= #self.text then
|
||||
self.text = self:AddIntoText(unicode, self.blinknum)
|
||||
if blinknum ~= 0 and blinknum ~= #self.text then
|
||||
self.text = self:AddIntoText(unicode, blinknum)
|
||||
self:MoveBlinker(1)
|
||||
else
|
||||
self.text = text .. ckey
|
||||
@ -313,12 +342,15 @@ end
|
||||
function textinput:RunBlink()
|
||||
|
||||
local time = love.timer.getTime()
|
||||
local blink = self.blink
|
||||
local blinknum = self.blinknum
|
||||
local text = self.text
|
||||
|
||||
if self.xoffset > 0 then
|
||||
self.xoffset = 0
|
||||
end
|
||||
|
||||
if self.blink < time then
|
||||
if blink < time then
|
||||
if self.showblink == true then
|
||||
self.showblink = false
|
||||
else
|
||||
@ -329,8 +361,8 @@ function textinput:RunBlink()
|
||||
|
||||
local width = 0
|
||||
|
||||
for i=1, self.blinknum do
|
||||
width = width + self.font:getWidth(self.text:sub(i, i))
|
||||
for i=1, blinknum do
|
||||
width = width + self.font:getWidth(text:sub(i, i))
|
||||
end
|
||||
|
||||
self.blinkx = self.textx + width
|
||||
@ -352,8 +384,6 @@ function textinput:AddIntoText(t, p)
|
||||
|
||||
return new
|
||||
|
||||
--print(part1, part2)
|
||||
|
||||
end
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
@ -363,15 +393,18 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function textinput:RemoveFromeText(p)
|
||||
|
||||
if self.blinknum ~= 0 then
|
||||
local s = self.text
|
||||
local blinknum = self.blinknum
|
||||
local text = self.text
|
||||
|
||||
if blinknum ~= 0 then
|
||||
local s = text
|
||||
local part1 = s:sub(1, p - 1)
|
||||
local part2 = s:sub(p + 1)
|
||||
local new = part1 .. part2
|
||||
return new
|
||||
end
|
||||
|
||||
return self.text
|
||||
return text
|
||||
|
||||
end
|
||||
|
||||
|
@ -123,13 +123,11 @@ skin.controls.textinput_blinker_color = {0, 0, 0, 255}
|
||||
-- slider
|
||||
skin.controls.slider_bar_color = bordercolor
|
||||
skin.controls.slider_bar_outline_color = {220, 220, 220, 255}
|
||||
skin.controls.slider_text_color = {0, 0, 0, 255}
|
||||
skin.controls.slider_text_font = smallfont
|
||||
|
||||
-- checkbox
|
||||
skin.controls.checkbox_border_color = bordercolor
|
||||
skin.controls.checkbox_body_color = {255, 255, 255, 255}
|
||||
skin.controls.checkbox_check_color = {0, 0, 0, 255}
|
||||
skin.controls.checkbox_check_color = {128, 204, 255, 255}
|
||||
skin.controls.checkbox_text_color = {0, 0, 0, 255}
|
||||
skin.controls.checkbox_text_font = smallfont
|
||||
|
||||
@ -540,21 +538,21 @@ function skin.DrawScrollBar(object)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_body_down_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
|
||||
gradientcolor = {skin.controls.scrollbar_body_down_color[1] - 20, skin.controls.scrollbar_body_down_color[2] - 20, skin.controls.scrollbar_body_down_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_border_down_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
|
||||
elseif object.hover == true then
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_body_hover_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
|
||||
gradientcolor = {skin.controls.scrollbar_body_hover_color[1] - 20, skin.controls.scrollbar_body_hover_color[2] - 20, skin.controls.scrollbar_body_hover_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_border_hover_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
|
||||
else
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_body_nohover_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
|
||||
gradientcolor = {skin.controls.scrollbar_body_nohover_color[1] - 20, skin.controls.scrollbar_body_nohover_color[2] - 20, skin.controls.scrollbar_body_nohover_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_border_nohover_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
|
||||
end
|
||||
@ -758,11 +756,14 @@ function skin.DrawMultiChoiceList(object)
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: DrawOverMultiChoiceList(object)
|
||||
- desc: draws over the multi choice list object
|
||||
--]]---------------------------------------------------------
|
||||
function skin.DrawOverMultiChoiceList(object)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.multichoicelist_border_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), true)
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight() + 1)
|
||||
|
||||
end
|
||||
|
||||
@ -950,19 +951,23 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function skin.DrawSlider(object)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
|
||||
love.graphics.rectangle("fill", object:GetX(), object:GetY() + object.ycenter - 5, object:GetWidth(), 10)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object.ycenter - 0.5, object:GetWidth() - 10, 1)
|
||||
|
||||
love.graphics.setFont(skin.controls.slider_text_font)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_text_color))
|
||||
love.graphics.print(object.text, object:GetX(), object:GetY())
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_text_color))
|
||||
love.graphics.printf(object.value, object:GetX() + object:GetWidth(), object:GetY(), 0, "right")
|
||||
if object.slidetype == "horizontal" then
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
|
||||
love.graphics.rectangle("fill", object:GetX(), object:GetY() + object:GetHeight()/2 - 5, object:GetWidth(), 10)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object:GetHeight()/2, object:GetWidth() - 10, 1)
|
||||
|
||||
elseif object.slidetype == "vertical" then
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2 - 5, object:GetY(), 10, object:GetHeight())
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2, object:GetY() + 5, 1, object:GetHeight() - 10)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1030,6 +1035,7 @@ function skin.DrawCheckBox(object)
|
||||
local linesize = (1 * (object.boxwidth * 0.05))
|
||||
local checked = object.checked
|
||||
local height = font:getHeight()
|
||||
local gradientcolor = {}
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.checkbox_body_color))
|
||||
love.graphics.rectangle("fill", object:GetX(), object:GetY(), object.boxwidth, object.boxheight)
|
||||
@ -1039,11 +1045,11 @@ function skin.DrawCheckBox(object)
|
||||
|
||||
if checked == true then
|
||||
|
||||
love.graphics.setLine(linesize, "smooth")
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.checkbox_check_color))
|
||||
love.graphics.line(object:GetX() + 5 + linesize, object:GetY() + 5 + linesize, object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + object.boxheight - 5 - linesize)
|
||||
love.graphics.line(object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + 5 + linesize, object:GetX() + 5 + linesize, object:GetY() + object.boxheight - 5 - linesize)
|
||||
love.graphics.rectangle("fill", object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8)
|
||||
|
||||
gradientcolor = {skin.controls.checkbox_check_color[1] - 20, skin.controls.checkbox_check_color[2] - 20, skin.controls.checkbox_check_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8, "up", gradientcolor)
|
||||
|
||||
end
|
||||
|
||||
|
@ -123,13 +123,11 @@ skin.controls.textinput_blinker_color = {0, 0, 0, 255}
|
||||
-- slider
|
||||
skin.controls.slider_bar_color = bordercolor
|
||||
skin.controls.slider_bar_outline_color = {220, 220, 220, 255}
|
||||
skin.controls.slider_text_color = {0, 0, 0, 255}
|
||||
skin.controls.slider_text_font = smallfont
|
||||
|
||||
-- checkbox
|
||||
skin.controls.checkbox_border_color = bordercolor
|
||||
skin.controls.checkbox_body_color = {255, 255, 255, 255}
|
||||
skin.controls.checkbox_check_color = {0, 0, 0, 255}
|
||||
skin.controls.checkbox_check_color = {255, 173, 51, 255}
|
||||
skin.controls.checkbox_text_color = {0, 0, 0, 255}
|
||||
skin.controls.checkbox_text_font = smallfont
|
||||
|
||||
@ -541,21 +539,21 @@ function skin.DrawScrollBar(object)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_body_down_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
|
||||
gradientcolor = {skin.controls.scrollbar_body_down_color[1] - 20, skin.controls.scrollbar_body_down_color[2] - 20, skin.controls.scrollbar_body_down_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_border_down_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
|
||||
elseif object.hover == true then
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_body_hover_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
|
||||
gradientcolor = {skin.controls.scrollbar_body_hover_color[1] - 20, skin.controls.scrollbar_body_hover_color[2] - 20, skin.controls.scrollbar_body_hover_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_border_hover_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
|
||||
else
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_body_nohover_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 1, object:GetY() + 1, object:GetWidth() - 2, object:GetHeight() - 2)
|
||||
gradientcolor = {skin.controls.scrollbar_body_nohover_color[1] - 20, skin.controls.scrollbar_body_nohover_color[2] - 20, skin.controls.scrollbar_body_nohover_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
skin.DrawGradient(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), "up", gradientcolor)
|
||||
love.graphics.setColor(unpack(skin.controls.scrollbar_border_nohover_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight())
|
||||
end
|
||||
@ -759,11 +757,14 @@ function skin.DrawMultiChoiceList(object)
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[---------------------------------------------------------
|
||||
- func: DrawOverMultiChoiceList(object)
|
||||
- desc: draws over the multi choice list object
|
||||
--]]---------------------------------------------------------
|
||||
function skin.DrawOverMultiChoiceList(object)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.multichoicelist_border_color))
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY(), object:GetWidth(), object:GetHeight(), true)
|
||||
skin.OutlinedRectangle(object:GetX(), object:GetY() - 1, object:GetWidth(), object:GetHeight() + 1)
|
||||
|
||||
end
|
||||
|
||||
@ -951,19 +952,23 @@ end
|
||||
--]]---------------------------------------------------------
|
||||
function skin.DrawSlider(object)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
|
||||
love.graphics.rectangle("fill", object:GetX(), object:GetY() + object.ycenter - 5, object:GetWidth(), 10)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object.ycenter - 0.5, object:GetWidth() - 10, 1)
|
||||
|
||||
love.graphics.setFont(skin.controls.slider_text_font)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_text_color))
|
||||
love.graphics.print(object.text, object:GetX(), object:GetY())
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_text_color))
|
||||
love.graphics.printf(object.value, object:GetX() + object:GetWidth(), object:GetY(), 0, "right")
|
||||
if object.slidetype == "horizontal" then
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
|
||||
love.graphics.rectangle("fill", object:GetX(), object:GetY() + object:GetHeight()/2 - 5, object:GetWidth(), 10)
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 5, object:GetY() + object:GetHeight()/2, object:GetWidth() - 10, 1)
|
||||
|
||||
elseif object.slidetype == "vertical" then
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_outline_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2 - 5, object:GetY(), 10, object:GetHeight())
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.slider_bar_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + object:GetWidth()/2, object:GetY() + 5, 1, object:GetHeight() - 10)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -1031,6 +1036,7 @@ function skin.DrawCheckBox(object)
|
||||
local linesize = (1 * (object.boxwidth * 0.05))
|
||||
local checked = object.checked
|
||||
local height = font:getHeight()
|
||||
local gradientcolor = {}
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.checkbox_body_color))
|
||||
love.graphics.rectangle("fill", object:GetX(), object:GetY(), object.boxwidth, object.boxheight)
|
||||
@ -1040,11 +1046,11 @@ function skin.DrawCheckBox(object)
|
||||
|
||||
if checked == true then
|
||||
|
||||
love.graphics.setLine(linesize, "smooth")
|
||||
|
||||
love.graphics.setColor(unpack(skin.controls.checkbox_check_color))
|
||||
love.graphics.line(object:GetX() + 5 + linesize, object:GetY() + 5 + linesize, object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + object.boxheight - 5 - linesize)
|
||||
love.graphics.line(object:GetX() + object.boxwidth - 5 - linesize, object:GetY() + 5 + linesize, object:GetX() + 5 + linesize, object:GetY() + object.boxheight - 5 - linesize)
|
||||
love.graphics.setColor(unpack(skin.controls.checkbox_check_color))
|
||||
love.graphics.rectangle("fill", object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8)
|
||||
|
||||
gradientcolor = {skin.controls.checkbox_check_color[1] - 20, skin.controls.checkbox_check_color[2] - 20, skin.controls.checkbox_check_color[3] - 20, 255}
|
||||
skin.DrawGradient(object:GetX() + 4, object:GetY() + 4, object.boxwidth - 8, object.boxheight - 8, "up", gradientcolor)
|
||||
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user