summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-04 22:00:58 +0200
committerAki <nthirtyone@gmail.com>2017-09-04 22:00:58 +0200
commitfd07ad0d87bc836f14c7be4bcb4042db78afdd95 (patch)
tree6bea8a9771a1533c1b22128d7827334d4f69907f
parent3f353552da6bb67aa1e7018399e62c7eace9b8c2 (diff)
downloadroflnauts-fd07ad0d87bc836f14c7be4bcb4042db78afdd95.zip
roflnauts-fd07ad0d87bc836f14c7be4bcb4042db78afdd95.tar.gz
roflnauts-fd07ad0d87bc836f14c7be4bcb4042db78afdd95.tar.bz2
Basic draw for Selector
-rw-r--r--not/Selector.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/not/Selector.lua b/not/Selector.lua
index 9083b24..1c13e76 100644
--- a/not/Selector.lua
+++ b/not/Selector.lua
@@ -74,6 +74,10 @@ function Selector:isUnique ()
return true
end
+function Selector:getText ()
+ return tostring(self:getSelected())
+end
+
function Selector:focus ()
self.focused = true
return true
@@ -83,4 +87,23 @@ function Selector:blur ()
self.focused = false
end
+-- TODO: Temporary function to determine quad to use. Will be obsolete when BoxElement will be done. See also `not/Element@getSize`.
+function Selector:getShapeString ()
+ if self.shape == Selector.SHAPE_PORTRAIT then
+ return "portrait"
+ end
+ if self.shape == Selector.SHAPE_PANORAMA then
+ return "panorama"
+ end
+end
+
+function Selector:draw (scale)
+ local x, y = self:getPosition()
+ local w, h = self:getSize()
+ love.graphics.setColor(255, 255, 255, 255)
+ love.graphics.draw(self.atlas, self.quads[self:getShapeString()].normal, x*scale, y*scale, 0, scale, scale)
+ love.graphics.setFont(Font)
+ love.graphics.printf(self:getText(), (x-w)*scale, (y+h+1)*scale, w*3, "center", 0, scale, scale)
+end
+
return Selector