2012-05-06 00:24:42 +00:00
|
|
|
--[[------------------------------------------------
|
2012-09-29 23:20:41 +00:00
|
|
|
-- Love Frames - A GUI library for LOVE --
|
2013-02-11 21:15:40 +00:00
|
|
|
-- Copyright (c) 2013 Kenny Shields --
|
2012-05-06 00:24:42 +00:00
|
|
|
--]]------------------------------------------------
|
|
|
|
|
|
|
|
-- frame class
|
2012-11-24 22:42:16 +00:00
|
|
|
local newobject = loveframes.NewObject("frame", "loveframes_object_frame", true)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: initialize()
|
|
|
|
- desc: initializes the object
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:initialize()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
self.type = "frame"
|
|
|
|
self.name = "Frame"
|
|
|
|
self.width = 300
|
|
|
|
self.height = 150
|
|
|
|
self.clickx = 0
|
|
|
|
self.clicky = 0
|
|
|
|
self.internal = false
|
|
|
|
self.draggable = true
|
|
|
|
self.screenlocked = false
|
|
|
|
self.parentlocked = false
|
|
|
|
self.dragging = false
|
|
|
|
self.modal = false
|
2012-12-10 14:19:35 +00:00
|
|
|
self.modalbackground = false
|
2012-12-28 12:19:02 +00:00
|
|
|
self.showclose = true
|
|
|
|
self.internals = {}
|
|
|
|
self.children = {}
|
2013-05-05 23:51:20 +00:00
|
|
|
self.icon = nil
|
2012-12-28 12:19:02 +00:00
|
|
|
self.OnClose = nil
|
2012-09-29 23:20:41 +00:00
|
|
|
|
|
|
|
-- create the close button for the frame
|
2012-11-24 22:42:16 +00:00
|
|
|
local close = loveframes.objects["closebutton"]:new()
|
2012-05-06 00:24:42 +00:00
|
|
|
close.parent = self
|
|
|
|
close.OnClick = function()
|
2012-09-29 23:20:41 +00:00
|
|
|
local onclose = self.OnClose
|
2012-05-06 00:24:42 +00:00
|
|
|
self:Remove()
|
2012-09-29 23:20:41 +00:00
|
|
|
if onclose then
|
|
|
|
onclose(self)
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(self.internals, close)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: update(deltatime)
|
|
|
|
- desc: updates the element
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:update(dt)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local visible = self.visible
|
2012-05-22 07:10:18 +00:00
|
|
|
local alwaysupdate = self.alwaysupdate
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
|
|
|
if not alwaysupdate then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local x, y = love.mouse.getPosition()
|
|
|
|
local showclose = self.showclose
|
|
|
|
local close = self.internals[1]
|
|
|
|
local dragging = self.dragging
|
|
|
|
local screenlocked = self.screenlocked
|
|
|
|
local parentlocked = self.parentlocked
|
|
|
|
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
|
|
|
|
local parent = self.parent
|
|
|
|
local update = self.Update
|
2012-09-02 00:56:32 +00:00
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
self:CheckHover()
|
|
|
|
|
|
|
|
-- dragging check
|
2012-09-29 23:20:41 +00:00
|
|
|
if dragging then
|
2012-10-22 14:19:02 +00:00
|
|
|
if parent == base then
|
|
|
|
self.x = x - self.clickx
|
|
|
|
self.y = y - self.clicky
|
2012-11-24 22:42:16 +00:00
|
|
|
else
|
|
|
|
self.staticx = x - self.clickx
|
|
|
|
self.staticy = y - self.clicky
|
2012-10-22 14:19:02 +00:00
|
|
|
end
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- if screenlocked then keep within screen
|
2012-11-24 22:42:16 +00:00
|
|
|
if screenlocked then
|
2012-05-06 00:24:42 +00:00
|
|
|
local width = love.graphics.getWidth()
|
|
|
|
local height = love.graphics.getHeight()
|
2012-09-29 23:20:41 +00:00
|
|
|
local selfwidth = self.width
|
|
|
|
local selfheight = self.height
|
2012-05-06 00:24:42 +00:00
|
|
|
if self.x < 0 then
|
|
|
|
self.x = 0
|
|
|
|
end
|
2012-09-29 23:20:41 +00:00
|
|
|
if self.x + selfwidth > width then
|
|
|
|
self.x = width - selfwidth
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
if self.y < 0 then
|
|
|
|
self.y = 0
|
|
|
|
end
|
2012-09-29 23:20:41 +00:00
|
|
|
if self.y + selfheight > height then
|
|
|
|
self.y = height - selfheight
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-11-24 22:42:16 +00:00
|
|
|
if parentlocked then
|
|
|
|
local width = self.parent.width
|
|
|
|
local height = self.parent.height
|
|
|
|
local selfwidth = self.width
|
|
|
|
local selfheight = self.height
|
|
|
|
if self.staticx < 0 then
|
|
|
|
self.staticx = 0
|
|
|
|
end
|
|
|
|
if self.staticx + selfwidth > width then
|
|
|
|
self.staticx = width - selfwidth
|
|
|
|
end
|
|
|
|
if self.staticy < 0 then
|
|
|
|
self.staticy = 0
|
|
|
|
end
|
|
|
|
if self.staticy + selfheight > height then
|
|
|
|
self.staticy = height - selfheight
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
if modal then
|
2012-09-02 00:56:32 +00:00
|
|
|
local tip = false
|
|
|
|
local key = 0
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(basechildren) do
|
2012-09-02 00:56:32 +00:00
|
|
|
if v.type == "tooltip" and v.show == true then
|
|
|
|
tip = v
|
|
|
|
key = k
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
end
|
2012-09-02 00:56:32 +00:00
|
|
|
if tip ~= false then
|
|
|
|
self:Remove()
|
|
|
|
self.modalbackground:Remove()
|
|
|
|
table.insert(basechildren, key - 2, self.modalbackground)
|
|
|
|
table.insert(basechildren, key - 1, self)
|
|
|
|
end
|
|
|
|
if self.modalbackground.draworder > self.draworder then
|
|
|
|
self:MakeTop()
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
if parent ~= base then
|
|
|
|
self.x = self.parent.x + self.staticx
|
|
|
|
self.y = self.parent.y + self.staticy
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:update(dt)
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:update(dt)
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if update then
|
|
|
|
update(self, dt)
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: draw()
|
|
|
|
- desc: draws the object
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:draw()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local internals = self.internals
|
|
|
|
local skins = loveframes.skins.available
|
|
|
|
local skinindex = loveframes.config["ACTIVESKIN"]
|
|
|
|
local defaultskin = loveframes.config["DEFAULTSKIN"]
|
|
|
|
local selfskin = self.skin
|
|
|
|
local skin = skins[selfskin] or skins[skinindex]
|
|
|
|
local drawfunc = skin.DrawFrame or skins[defaultskin].DrawFrame
|
|
|
|
local draw = self.Draw
|
|
|
|
local drawcount = loveframes.drawcount
|
2012-09-29 23:20:41 +00:00
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- set the object's draw order
|
|
|
|
self:SetDrawOrder()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if draw then
|
|
|
|
draw(self)
|
2012-05-06 00:24:42 +00:00
|
|
|
else
|
2012-09-02 00:56:32 +00:00
|
|
|
drawfunc(self)
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:draw()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- loop through the object's children and draw them
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:draw()
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: mousepressed(x, y, button)
|
|
|
|
- desc: called when the player presses a mouse button
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:mousepressed(x, y, button)
|
2013-02-11 21:15:40 +00:00
|
|
|
|
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
2012-05-22 07:10:18 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
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)
|
2012-05-22 07:10:18 +00:00
|
|
|
local internals = self.internals
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local dragging = self.dragging
|
|
|
|
local parent = self.parent
|
|
|
|
local base = loveframes.base
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if selfcol then
|
2012-05-06 00:24:42 +00:00
|
|
|
local top = self:IsTopCollision()
|
|
|
|
-- initiate dragging if not currently dragging
|
2012-10-22 14:19:02 +00:00
|
|
|
if not dragging and top and button == "l" then
|
2012-09-29 23:20:41 +00:00
|
|
|
if y < self.y + 25 and self.draggable then
|
2012-11-24 22:42:16 +00:00
|
|
|
if parent == base then
|
|
|
|
self.clickx = x - self.x
|
|
|
|
self.clicky = y - self.y
|
|
|
|
else
|
|
|
|
self.clickx = x - self.staticx
|
|
|
|
self.clicky = y - self.staticy
|
|
|
|
end
|
2012-05-06 00:24:42 +00:00
|
|
|
self.dragging = true
|
|
|
|
end
|
|
|
|
end
|
2012-09-29 23:20:41 +00:00
|
|
|
if top and button == "l" then
|
2012-05-06 00:24:42 +00:00
|
|
|
self:MakeTop()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousepressed(x, y, button)
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousepressed(x, y, button)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: mousereleased(x, y, button)
|
|
|
|
- desc: called when the player releases a mouse button
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:mousereleased(x, y, button)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2013-02-11 21:15:40 +00:00
|
|
|
local state = loveframes.state
|
|
|
|
local selfstate = self.state
|
|
|
|
|
|
|
|
if state ~= selfstate then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local visible = self.visible
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not visible then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local dragging = self.dragging
|
|
|
|
local children = self.children
|
2012-05-22 07:10:18 +00:00
|
|
|
local internals = self.internals
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
-- exit the dragging state
|
2012-09-29 23:20:41 +00:00
|
|
|
if dragging then
|
2012-05-06 00:24:42 +00:00
|
|
|
self.dragging = false
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(internals) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousereleased(x, y, button)
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-06 00:24:42 +00:00
|
|
|
v:mousereleased(x, y, button)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetName(name)
|
|
|
|
- desc: sets the frame's name
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetName(name)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
self.name = name
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetName()
|
|
|
|
- desc: gets the frame's name
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetName()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetDraggable(true/false)
|
|
|
|
- desc: sets whether the frame can be dragged or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetDraggable(bool)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
self.draggable = bool
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetDraggable()
|
|
|
|
- desc: gets whether the frame can be dragged ot not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetDraggable()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
return self.draggable
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetScreenLocked(bool)
|
|
|
|
- desc: sets whether the frame can be moved passed the
|
|
|
|
boundaries of the window or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetScreenLocked(bool)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
self.screenlocked = bool
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetScreenLocked()
|
|
|
|
- desc: gets whether the frame can be moved passed the
|
|
|
|
boundaries of window or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetScreenLocked()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
return self.screenlocked
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: ShowCloseButton(bool)
|
|
|
|
- desc: sets whether the close button should be drawn
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:ShowCloseButton(bool)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
local close = self.internals[1]
|
|
|
|
|
|
|
|
close.visible = bool
|
2012-05-15 02:47:38 +00:00
|
|
|
self.showclose = bool
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: MakeTop()
|
|
|
|
- desc: makes the object the top object in the drawing
|
|
|
|
order
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:MakeTop()
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local x, y = love.mouse.getPosition()
|
|
|
|
local key = 0
|
|
|
|
local base = loveframes.base
|
|
|
|
local basechildren = base.children
|
2012-05-22 07:10:18 +00:00
|
|
|
local numbasechildren = #basechildren
|
2012-12-28 12:19:02 +00:00
|
|
|
local parent = self.parent
|
2012-05-06 00:24:42 +00:00
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- check to see if the object's parent is not the base object
|
|
|
|
if parent ~= base then
|
|
|
|
local baseparent = self:GetBaseParent()
|
|
|
|
if baseparent.type == "frame" then
|
|
|
|
baseparent:MakeTop()
|
|
|
|
end
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- check to see if the object is the only child of the base object
|
2012-05-22 07:10:18 +00:00
|
|
|
if numbasechildren == 1 then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-10-22 14:19:02 +00:00
|
|
|
-- check to see if the object is already at the top
|
2012-05-22 07:10:18 +00:00
|
|
|
if basechildren[numbasechildren] == self then
|
2012-05-06 00:24:42 +00:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
-- make this the top object
|
|
|
|
for k, v in ipairs(basechildren) do
|
2012-05-06 00:24:42 +00:00
|
|
|
if v == self then
|
2012-05-22 07:10:18 +00:00
|
|
|
table.remove(basechildren, k)
|
|
|
|
table.insert(basechildren, self)
|
2012-05-06 00:24:42 +00:00
|
|
|
key = k
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetModal(bool)
|
|
|
|
- desc: makes the object the top object in the drawing
|
|
|
|
order
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetModal(bool)
|
2012-05-15 02:47:38 +00:00
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
local modalobject = loveframes.modalobject
|
|
|
|
local mbackground = self.modalbackground
|
2012-12-28 12:19:02 +00:00
|
|
|
local parent = self.parent
|
|
|
|
local base = loveframes.base
|
2012-10-22 14:19:02 +00:00
|
|
|
|
|
|
|
if parent ~= base then
|
|
|
|
return
|
|
|
|
end
|
2012-05-22 07:10:18 +00:00
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
self.modal = bool
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if bool then
|
|
|
|
if modalobject then
|
2012-05-22 07:10:18 +00:00
|
|
|
modalobject:SetModal(false)
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
loveframes.modalobject = self
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if not mbackground then
|
2012-11-24 22:42:16 +00:00
|
|
|
self.modalbackground = loveframes.objects["modalbackground"]:new(self)
|
2012-05-15 02:47:38 +00:00
|
|
|
self.modal = true
|
|
|
|
end
|
|
|
|
else
|
2012-05-22 07:10:18 +00:00
|
|
|
if modalobject == self then
|
2012-05-15 02:47:38 +00:00
|
|
|
loveframes.modalobject = false
|
2012-09-29 23:20:41 +00:00
|
|
|
if mbackground then
|
2012-05-15 02:47:38 +00:00
|
|
|
self.modalbackground:Remove()
|
|
|
|
self.modalbackground = false
|
|
|
|
self.modal = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetModal()
|
|
|
|
- desc: gets whether or not the object is in a modal
|
|
|
|
state
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:GetModal()
|
2012-05-15 02:47:38 +00:00
|
|
|
|
|
|
|
return self.modal
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetVisible(bool)
|
|
|
|
- desc: set's whether the object is visible or not
|
|
|
|
--]]---------------------------------------------------------
|
2012-11-24 22:42:16 +00:00
|
|
|
function newobject:SetVisible(bool)
|
2012-05-15 02:47:38 +00:00
|
|
|
|
2012-12-28 12:19:02 +00:00
|
|
|
local children = self.children
|
|
|
|
local internals = self.internals
|
2012-05-22 07:10:18 +00:00
|
|
|
local closebutton = internals[1]
|
|
|
|
|
2012-05-15 02:47:38 +00:00
|
|
|
self.visible = bool
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
for k, v in ipairs(children) do
|
2012-05-15 02:47:38 +00:00
|
|
|
v:SetVisible(bool)
|
|
|
|
end
|
|
|
|
|
2012-09-29 23:20:41 +00:00
|
|
|
if self.showclose then
|
2012-05-27 16:58:37 +00:00
|
|
|
closebutton.visible = bool
|
2012-05-15 02:47:38 +00:00
|
|
|
end
|
|
|
|
|
2012-11-24 22:42:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetParentLocked(bool)
|
|
|
|
- desc: sets whether the frame can be moved passed the
|
2013-03-23 19:50:44 +00:00
|
|
|
boundaries of its parent or not
|
2012-11-24 22:42:16 +00:00
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetParentLocked(bool)
|
|
|
|
|
|
|
|
self.parentlocked = bool
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetParentLocked(bool)
|
|
|
|
- desc: gets whether the frame can be moved passed the
|
2013-03-23 19:50:44 +00:00
|
|
|
boundaries of its parent or not
|
2012-11-24 22:42:16 +00:00
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetParentLocked()
|
|
|
|
|
|
|
|
return self.parentlocked
|
|
|
|
|
2013-05-05 23:51:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: SetIcon(icon)
|
|
|
|
- desc: sets the object's icon
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:SetIcon(icon)
|
|
|
|
|
|
|
|
if type(icon) == "string" then
|
|
|
|
self.icon = love.graphics.newImage(icon)
|
|
|
|
else
|
|
|
|
self.icon = icon
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
- func: GetIcon()
|
|
|
|
- desc: gets the object's icon
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
function newobject:GetIcon()
|
|
|
|
|
|
|
|
local icon = self.icon
|
|
|
|
|
|
|
|
if icon then
|
|
|
|
return icon
|
|
|
|
end
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
end
|