diff options
-rw-r--r-- | assets/menu.png | bin | 279 -> 599 bytes | |||
-rw-r--r-- | assets/placeholder-map-icon.png | bin | 1220 -> 5322 bytes | |||
-rw-r--r-- | button.lua | 14 | ||||
-rw-r--r-- | config/menuhost.lua | 5 | ||||
-rw-r--r-- | config/menuselect.lua | 4 | ||||
-rw-r--r-- | mapicons.lua | 8 | ||||
-rw-r--r-- | menu.lua | 25 | ||||
-rw-r--r-- | nautsicons.lua | 46 | ||||
-rw-r--r-- | selector.lua | 39 |
9 files changed, 115 insertions, 26 deletions
diff --git a/assets/menu.png b/assets/menu.png Binary files differindex ec5a398..8088c23 100644 --- a/assets/menu.png +++ b/assets/menu.png diff --git a/assets/placeholder-map-icon.png b/assets/placeholder-map-icon.png Binary files differindex cab79f1..eccb551 100644 --- a/assets/placeholder-map-icon.png +++ b/assets/placeholder-map-icon.png @@ -7,9 +7,7 @@ Button = { x = 0, y = 0, sprite, - quad = love.graphics.newQuad(0, 0, 58,15, 68,15), - arrow_l = love.graphics.newQuad(58, 0, 5, 5, 68,15), - arrow_r = love.graphics.newQuad(63, 0, 5, 5, 68,15), + quads, delay = 2, blinker = 1, parent @@ -20,7 +18,7 @@ function Button:new(parent) setmetatable(o, self) self.__index = self o.parent = parent - self.sprite = love.graphics.newImage("assets/menu.png") + o.sprite, o.quads = parent:getSheet() return o end function Button:setText(text) @@ -53,15 +51,17 @@ end function Button:draw(scale) local x,y = self:getPosition() local blinker = math.floor(self.blinker*4) + local quad = self.quads + local sprite = self.sprite if blinker%2 == 0 then love.graphics.setColor(255, 255, 255, 255) else love.graphics.setColor(255, 100, 100, 255) end - love.graphics.draw(self.sprite, self.quad, x*scale, y*scale, 0, scale, scale) + love.graphics.draw(sprite, quad.button.normal, x*scale, y*scale, 0, scale, scale) if self.focused then - love.graphics.draw(self.sprite, self.arrow_l, (x+54+math.floor(self.delay))*scale, (y+5)*scale, 0, scale, scale) - love.graphics.draw(self.sprite, self.arrow_r, (x-1-math.floor(self.delay))*scale, (y+5)*scale, 0, scale, scale) + love.graphics.draw(sprite, quad.arrow_l, (x+54+math.floor(self.delay))*scale, (y+5)*scale, 0, scale, scale) + love.graphics.draw(sprite, quad.arrow_r, (x-2-math.floor(self.delay))*scale, (y+5)*scale, 0, scale, scale) end love.graphics.setFont(Font) love.graphics.printf(self.text, (x+2)*scale, (y+4)*scale, 54, "center", 0, scale, scale) diff --git a/config/menuhost.lua b/config/menuhost.lua index 53972b3..878ec71 100644 --- a/config/menuhost.lua +++ b/config/menuhost.lua @@ -15,8 +15,9 @@ return { :setMargin(0) :set("global", true) :set("list", require "maplist") - :set("sprite", love.graphics.newImage("assets/placeholder-map-icon.png")) - :set("quads", require "mapicons") + :set("icons_i", love.graphics.newImage("assets/placeholder-map-icon.png")) + :set("icons_q", require "mapicons") + :set("shape", "panorama") :init() , button:new(menu) diff --git a/config/menuselect.lua b/config/menuselect.lua index 20ea607..31cf02e 100644 --- a/config/menuselect.lua +++ b/config/menuselect.lua @@ -17,8 +17,8 @@ return { :setSize(32, 32) :set("list", require "nautslist") :set("global", false) - :set("sprite", love.graphics.newImage("assets/portraits.png")) - :set("quads", require "portraits") + :set("icons_i", love.graphics.newImage("assets/portraits.png")) + :set("icons_q", require "nautsicons") :init() , start_button diff --git a/mapicons.lua b/mapicons.lua new file mode 100644 index 0000000..40ba589 --- /dev/null +++ b/mapicons.lua @@ -0,0 +1,8 @@ +local w, h = 80, 210 +return { + default = love.graphics.newQuad(2, 3,76,37,w,h), + rill = love.graphics.newQuad(2, 45,76,37,w,h), + ribbit = love.graphics.newQuad(2, 87,76,37,w,h), + starstorm = love.graphics.newQuad(2,129,76,37,w,h), + aiguillon = love.graphics.newQuad(2,171,76,37,w,h), +}
\ No newline at end of file @@ -9,12 +9,30 @@ Menu = { scale = getScale(), elements, --table active = 1, - music + music, + sprite, + quads = { + button = { + normal = love.graphics.newQuad(0, 0, 58,15, 80,130), + active = love.graphics.newQuad(0, 0, 58,15, 80,130) + }, + portrait = { + normal = love.graphics.newQuad( 0, 15, 32,32, 80,130), + active = love.graphics.newQuad(32, 15, 32,32, 80,130) + }, + panorama = { + normal = love.graphics.newQuad(0,47, 80,42, 80,130), + active = love.graphics.newQuad(0,88, 80,42, 80,130) + }, + arrow_l = love.graphics.newQuad(68, 0, 6, 6, 80,130), + arrow_r = love.graphics.newQuad(74, 0, 6, 6, 80,130), + } } function Menu:new(name) local o = {} setmetatable(o, self) self.__index = self + self.sprite = love.graphics.newImage("assets/menu.png") o.elements = {} o:load(name) o.music = Music:new("menu.ogg") @@ -31,6 +49,11 @@ function Menu:load(name) self.elements[self.active]:focus() end +-- Return reference to quads table and menu sprite +function Menu:getSheet() + return self.sprite, self.quads +end + -- Cycle elements function Menu:next() self.elements[self.active]:blur() diff --git a/nautsicons.lua b/nautsicons.lua new file mode 100644 index 0000000..a44e01d --- /dev/null +++ b/nautsicons.lua @@ -0,0 +1,46 @@ +-- Spritesheet for character portraits +-- Original size: 331x265 (say what?) +-- Single size: 32x32 1px border merged between +local w, h = 331, 265 +return { + -- EMPTY + empty = love.graphics.newQuad(300,136,28,28,w,h), + -- 1. ROW + froggo = love.graphics.newQuad( 3, 4,28,28,w,h), + cowboy = love.graphics.newQuad( 36, 4,28,28,w,h), + honic = love.graphics.newQuad( 69, 4,28,28,w,h), + gelato = love.graphics.newQuad(102, 4,28,28,w,h), + veno = love.graphics.newQuad(135, 4,28,28,w,h), + lady = love.graphics.newQuad(168, 4,28,28,w,h), + girl = love.graphics.newQuad(201, 4,28,28,w,h), + megoman = love.graphics.newQuad(234, 4,28,28,w,h), + brainos = love.graphics.newQuad(267, 4,28,28,w,h), + -- 2. ROW + woman = love.graphics.newQuad( 3, 70,28,28,w,h), + bison = love.graphics.newQuad( 36, 70,28,28,w,h), + bobito = love.graphics.newQuad( 69, 70,28,28,w,h), + slugzor = love.graphics.newQuad(102, 70,28,28,w,h), + capone = love.graphics.newQuad(135, 70,28,28,w,h), + bug = love.graphics.newQuad(168, 70,28,28,w,h), + calamari = love.graphics.newQuad(201, 70,28,28,w,h), + quack = love.graphics.newQuad(234, 70,28,28,w,h), + scissors = love.graphics.newQuad(267, 70,28,28,w,h), + -- 3. ROW + marine = love.graphics.newQuad( 3, 136,28,28,w,h), + scooter = love.graphics.newQuad( 36, 136,28,28,w,h), + phonebooth = love.graphics.newQuad( 69, 136,28,28,w,h), + weed = love.graphics.newQuad(102, 136,28,28,w,h), + gummybear = love.graphics.newQuad(135, 136,28,28,w,h), + gramps = love.graphics.newQuad(168, 136,28,28,w,h), + biker = love.graphics.newQuad(201, 136,28,28,w,h), + vrooom = love.graphics.newQuad(234, 136,28,28,w,h), + link = love.graphics.newQuad(267, 136,28,28,w,h), + -- 4. ROW + gorilla = love.graphics.newQuad( 3,202,28,28,w,h), + nemo = love.graphics.newQuad( 36,202,28,28,w,h), + rock = love.graphics.newQuad( 69,202,28,28,w,h), + boss = love.graphics.newQuad(102,202,28,28,w,h), + -- ARROWS + arrow_left = love.graphics.newQuad(298,1,4,6,w,h), + arrow_right = love.graphics.newQuad(303,1,4,6,w,h) +} diff --git a/selector.lua b/selector.lua index f2d7b16..a4f9c03 100644 --- a/selector.lua +++ b/selector.lua @@ -7,8 +7,8 @@ selector:new(menu) :setMargin(8) -- each block has marigin on both sides; they do stack :setSize(32, 32) -- size of single graphics frame :set("list", require "nautslist") - :set("sprite", love.graphics.newImage("assets/portraits.png")) - :set("quads", require "portraits") + :set("icons_i", love.graphics.newImage("assets/portraits.png")) + :set("icons_q", require "portraits") :set("global", false) -- true: single selector; false: selector for each controller set present :init() ]] @@ -22,12 +22,16 @@ Selector = { margin = 0, focused = false, global = false, + delay = 2, list, sets, locks, selections, + shape = "portrait", sprite, - quads + quads, + icons_i, + icons_q } -- Constructor @@ -36,6 +40,7 @@ function Selector:new(parent) setmetatable(o, self) self.__index = self o.parent = parent + o.sprite, o.quads = parent:getSheet() return o end @@ -178,9 +183,9 @@ function Selector:drawBlock(n, x, y, scale) local name = self:getListValue(self:getSelection(n)) local locked = self:isLocked(n) local sprite = self.sprite - local quad = self.quads[name] - local arrowl = self.quads.arrow_left - local arrowr = self.quads.arrow_right + local quad = self.quads + local icon = self.icons_i + local iconq = self.icons_q[name] local w,h = self:getSize() local unique = self:isUnique(n) if unique then @@ -189,14 +194,15 @@ function Selector:drawBlock(n, x, y, scale) love.graphics.setColor(140, 140, 140, 255) end if not locked then - love.graphics.draw(sprite, quad.normal, x*scale, y*scale, 0, scale, scale) - if self.focused then - local dy = (h-6)/2 - love.graphics.draw(sprite, arrowl, (x+0-2)* scale, (y+dy)*scale, 0, scale, scale) - love.graphics.draw(sprite, arrowr, (x+w-2)*scale, (y+dy)*scale, 0, scale, scale) - end + love.graphics.draw(sprite, quad[self.shape].normal, x*scale, y*scale, 0, scale, scale) else - love.graphics.draw(sprite, quad.active, x*scale, y*scale, 0, scale, scale) + love.graphics.draw(sprite, quad[self.shape].active, x*scale, y*scale, 0, scale, scale) + end + love.graphics.draw(icon, iconq, (x+2)*scale, (y+3)*scale, 0, scale, scale) + if self.focused and not locked then + local dy = (h-6)/2 + love.graphics.draw(sprite, quad.arrow_l, (x+0-2-math.floor(self.delay))* scale, (y+dy)*scale, 0, scale, scale) + love.graphics.draw(sprite, quad.arrow_r, (x+w-4+math.floor(self.delay))*scale, (y+dy)*scale, 0, scale, scale) end if self:getSelection(n) ~= 1 then love.graphics.setFont(Font) @@ -224,7 +230,12 @@ function Selector:draw(scale) self:drawBlock(n, x+(margin+width)*(n-1)+margin*n, y, scale) end end -function Selector:update(dt) end +function Selector:update(dt) + self.delay = self.delay + dt + if self.delay > Selector.delay then -- Selector.delay is initial + self.delay = self.delay - Selector.delay + end +end -- Controller callbacks function Selector:controlpressed(set, action, key) |