summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-04 22:23:32 +0200
committerAki <nthirtyone@gmail.com>2017-09-04 22:23:32 +0200
commit48f8e2e9b19a074306a9db896b84b27b21a2cc99 (patch)
treebdd97eb6112d7638f39909314a366e4ffdacf97d
parentfd07ad0d87bc836f14c7be4bcb4042db78afdd95 (diff)
downloadroflnauts-48f8e2e9b19a074306a9db896b84b27b21a2cc99.zip
roflnauts-48f8e2e9b19a074306a9db896b84b27b21a2cc99.tar.gz
roflnauts-48f8e2e9b19a074306a9db896b84b27b21a2cc99.tar.bz2
Testing new Selector and added update, locked drawing
-rw-r--r--config/menus/host.lua22
-rw-r--r--not/Selector.lua16
2 files changed, 21 insertions, 17 deletions
diff --git a/config/menus/host.lua b/config/menus/host.lua
index 38cc463..e7b41c2 100644
--- a/config/menus/host.lua
+++ b/config/menus/host.lua
@@ -6,8 +6,6 @@ local Selector = require "not.Selector"
local width, height = love.graphics.getWidth()/getScale(), love.graphics.getHeight()/getScale()
local bx = width/2-29
-local map_Selector = Selector(menu)
-
if background == nil or not background:is(require "not.MenuBackground") then
background = require "not.MenuBackground"(menu)
end
@@ -23,34 +21,28 @@ do
local i, name = map.portrait, map.name
if i then
icons[name] = love.graphics.newQuad((i-1)*76, 0, 76, 37, 532, 37)
- table.insert(maps, name)
+ table.insert(maps, map)
end
end
end
end
+local mapSelector = Selector(maps, nil, menu)
+
return {
background,
- map_Selector
+ mapSelector
:setPosition(width/2, 40)
- :setSize(80, 42)
- :setMargin(0)
- :set("global", true)
- :set("first", true)
- :set("list", maps)
- :set("icons_i", love.graphics.newImage("assets/maps.png"))
- :set("icons_q", icons)
- :set("shape", "panorama")
- :init()
+ :set("shape", Selector.SHAPE_PANORAMA)
,
Button(menu)
:setText("Next")
:setPosition(bx,101)
:set("isEnabled", function ()
- return map_Selector:isLocked()
+ return mapSelector:getLocked()
end)
:set("active", function (self)
- MAP = map_Selector:getFullSelection(true)[1][1] -- please, don't kill me for this, kek
+ MAP = mapSelector:getSelected().name -- TODO: It uses map name for compatibility with old code.
self.parent:open("select")
end)
,
diff --git a/not/Selector.lua b/not/Selector.lua
index 1c13e76..d96c2f9 100644
--- a/not/Selector.lua
+++ b/not/Selector.lua
@@ -6,10 +6,11 @@ Selector.DEFAULT_DELAY = 2
Selector.SHAPE_PORTRAIT = 1
Selector.SHAPE_PANORAMA = 2
-function Selector:new (group, parent)
+function Selector:new (list, group, parent)
Selector.__super.new(self, parent)
self.atlas, self.quads = parent:getSheet()
self.group = group
+ self.list = list
self.delay = Selector.DEFAULT_DELAY
self.shape = Selector.SHAPE_PORTRAIT
self.focused = false
@@ -100,10 +101,21 @@ end
function Selector:draw (scale)
local x, y = self:getPosition()
local w, h = self:getSize()
+ local boxType = "normal"
+ if self:getLocked() then
+ boxType = "active"
+ end
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.draw(self.atlas, self.quads[self:getShapeString()][boxType], 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
+function Selector:update (dt)
+ self.delay = self.delay + dt
+ if self.delay > Selector.DEFAULT_DELAY then
+ self.delay = self.delay - Selector.DEFAULT_DELAY
+ end
+end
+
return Selector