mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-26 05:14:21 +00:00
114 lines
2.8 KiB
Lua
114 lines
2.8 KiB
Lua
|
--[[------------------------------------------------
|
|||
|
-- L<>VE Frames --
|
|||
|
-- By Nikolai Resokav --
|
|||
|
--]]------------------------------------------------
|
|||
|
|
|||
|
-- multichoicerow class
|
|||
|
multichoicerow = class("multichoicerow", base)
|
|||
|
multichoicerow:include(loveframes.templates.default)
|
|||
|
|
|||
|
--[[---------------------------------------------------------
|
|||
|
- func: initialize()
|
|||
|
- desc: initializes the object
|
|||
|
--]]---------------------------------------------------------
|
|||
|
function multichoicerow:initialize()
|
|||
|
|
|||
|
self.type = "multichoice-row"
|
|||
|
self.text = ""
|
|||
|
self.width = 50
|
|||
|
self.height = 25
|
|||
|
self.hover = false
|
|||
|
self.internal = true
|
|||
|
self.down = false
|
|||
|
self.canclick = false
|
|||
|
self.OnClick = nil
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--[[---------------------------------------------------------
|
|||
|
- func: update(deltatime)
|
|||
|
- desc: updates the object
|
|||
|
--]]---------------------------------------------------------
|
|||
|
function multichoicerow:update(dt)
|
|||
|
|
|||
|
if self.visible == false then
|
|||
|
if self.alwaysupdate == false then
|
|||
|
return
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
self:CheckHover()
|
|||
|
|
|||
|
-- move to parent if there is a parent
|
|||
|
if self.parent ~= loveframes.base then
|
|||
|
self.x = self.parent.x + self.staticx
|
|||
|
self.y = self.parent.y + self.staticy
|
|||
|
end
|
|||
|
|
|||
|
if self.Update then
|
|||
|
self.Update(self, dt)
|
|||
|
end
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--[[---------------------------------------------------------
|
|||
|
- func: draw()
|
|||
|
- desc: draws the object
|
|||
|
--]]---------------------------------------------------------
|
|||
|
function multichoicerow:draw()
|
|||
|
|
|||
|
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]
|
|||
|
|
|||
|
if self.Draw ~= nil then
|
|||
|
self.Draw(self)
|
|||
|
else
|
|||
|
skin.DrawMultiChoiceRow(self)
|
|||
|
end
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--[[---------------------------------------------------------
|
|||
|
- func: mousepressed(x, y, button)
|
|||
|
- desc: called when the player presses a mouse button
|
|||
|
--]]---------------------------------------------------------
|
|||
|
function multichoicerow:mousepressed(x, y, button)
|
|||
|
|
|||
|
if self.visible == false then
|
|||
|
return
|
|||
|
end
|
|||
|
|
|||
|
self.down = true
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
--[[---------------------------------------------------------
|
|||
|
- func: mousereleased(x, y, button)
|
|||
|
- desc: called when the player releases a mouse button
|
|||
|
--]]---------------------------------------------------------
|
|||
|
function multichoicerow:mousereleased(x, y, button)
|
|||
|
|
|||
|
if self.visible == false then
|
|||
|
return
|
|||
|
end
|
|||
|
|
|||
|
if self.hover == true and self.down == true and self.canclick == true and button == "l" then
|
|||
|
self.parent.list:SelectChoice(self.text)
|
|||
|
end
|
|||
|
|
|||
|
self.down = false
|
|||
|
self.canclick = true
|
|||
|
|
|||
|
end
|
|||
|
|
|||
|
function multichoicerow:SetText(text)
|
|||
|
|
|||
|
self.text = text
|
|||
|
|
|||
|
end
|