2012-05-06 00:24:42 +00:00
|
|
|
|
--[[------------------------------------------------
|
2012-09-02 21:13:13 +00:00
|
|
|
|
-- L<>ve Frames --
|
|
|
|
|
-- Copyright 2012 Kenny Shields --
|
2012-05-06 00:24:42 +00:00
|
|
|
|
--]]------------------------------------------------
|
|
|
|
|
|
|
|
|
|
-- 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
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
|
- func: update(deltatime)
|
|
|
|
|
- desc: updates the object
|
|
|
|
|
--]]---------------------------------------------------------
|
|
|
|
|
function multichoicerow:update(dt)
|
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
|
local visible = self.visible
|
|
|
|
|
local alwaysupdate = self.alwaysupdate
|
|
|
|
|
|
|
|
|
|
if visible == false then
|
|
|
|
|
if alwaysupdate == false then
|
2012-05-06 00:24:42 +00:00
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self:CheckHover()
|
|
|
|
|
|
2012-05-13 03:57:27 +00:00
|
|
|
|
if self.hover == false then
|
|
|
|
|
self.down = false
|
|
|
|
|
elseif self.hover == true then
|
|
|
|
|
if loveframes.hoverobject == self then
|
|
|
|
|
self.down = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if self.down == false and loveframes.hoverobject == self then
|
|
|
|
|
self.hover = true
|
|
|
|
|
end
|
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
|
-- 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()
|
|
|
|
|
|
2012-05-22 07:10:18 +00:00
|
|
|
|
local visible = self.visible
|
|
|
|
|
|
|
|
|
|
if visible == false then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
|
2012-09-02 00:56:32 +00:00
|
|
|
|
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.DrawMultiChoiceRow or skins[defaultskin].DrawMultiChoiceRow
|
|
|
|
|
|
2012-05-06 00:24:42 +00:00
|
|
|
|
loveframes.drawcount = loveframes.drawcount + 1
|
|
|
|
|
self.draworder = loveframes.drawcount
|
|
|
|
|
|
|
|
|
|
if self.Draw ~= nil then
|
|
|
|
|
self.Draw(self)
|
|
|
|
|
else
|
2012-09-02 00:56:32 +00:00
|
|
|
|
drawfunc(self)
|
2012-05-06 00:24:42 +00:00
|
|
|
|
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
|
|
|
|
|
|
2012-05-13 03:57:27 +00:00
|
|
|
|
if self.hover == true and button == "l" then
|
|
|
|
|
|
|
|
|
|
self.down = true
|
|
|
|
|
loveframes.hoverobject = self
|
|
|
|
|
|
|
|
|
|
end
|
2012-05-06 00:24:42 +00:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
2012-05-13 03:57:27 +00:00
|
|
|
|
--[[---------------------------------------------------------
|
|
|
|
|
- func: SetText(text)
|
|
|
|
|
- desc: sets the object's text
|
|
|
|
|
--]]---------------------------------------------------------
|
2012-05-06 00:24:42 +00:00
|
|
|
|
function multichoicerow:SetText(text)
|
|
|
|
|
|
|
|
|
|
self.text = text
|
|
|
|
|
|
|
|
|
|
end
|