LoveFrames/loveframes/objects/internal/treenodebutton.lua

109 lines
2.3 KiB
Lua
Raw Normal View History

2014-06-29 05:16:25 +00:00
--[[------------------------------------------------
-- Love Frames - A GUI library for LOVE --
-- Copyright (c) 2012-2014 Kenny Shields --
--]]------------------------------------------------
2019-03-06 23:19:58 +00:00
return function(loveframes)
---------- module start ----------
2014-06-29 05:16:25 +00:00
-- button object
local newobject = loveframes.NewObject("treenodebutton", "loveframes_object_treenodebutton", true)
--[[---------------------------------------------------------
- func: initialize()
- desc: initializes the object
--]]---------------------------------------------------------
function newobject:initialize()
self.type = "treenodebutton"
self.width = 16
self.height = 16
self.internal = true
2019-03-06 23:19:58 +00:00
self:SetDrawFunc()
2014-06-29 05:16:25 +00:00
end
--[[---------------------------------------------------------
- func: update(deltatime)
- desc: updates the object
--]]---------------------------------------------------------
function newobject:update(dt)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
local alwaysupdate = self.alwaysupdate
if not visible then
if not alwaysupdate then
return
end
end
self:CheckHover()
local parent = self.parent
local base = loveframes.base
local update = self.Update
-- move to parent if there is a parent
if parent ~= base then
self.x = self.parent.x + self.staticx
self.y = self.parent.y + self.staticy
end
if update then
update(self, dt)
end
end
--[[---------------------------------------------------------
- func: mousepressed(x, y, button)
- desc: called when the player presses a mouse button
--]]---------------------------------------------------------
function newobject:mousepressed(x, y, button)
local state = loveframes.state
local selfstate = self.state
if state ~= selfstate then
return
end
local visible = self.visible
if not visible then
return
end
local hover = self.hover
2015-10-31 13:40:19 +00:00
if hover and button == 1 then
local bool = not self.parent.open
if bool then
local onopen = self.parent.OnOpen
if onopen then
onopen(self.parent)
end
else
local onclose = self.parent.OnClose
if onclose then
onclose(self.parent)
end
end
self.parent:SetOpen(bool)
2014-06-29 05:16:25 +00:00
print("!")
print(self.parent.level)
end
2014-11-09 21:24:10 +00:00
end
2019-03-06 23:19:58 +00:00
---------- module end ----------
end