more cursor stuff
This commit is contained in:
parent
c4d1846765
commit
00f4f5a30b
6 changed files with 59 additions and 13 deletions
|
@ -5,23 +5,40 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance)
|
|||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.draw(base, 0, 0, 0, size, size)
|
||||
|
||||
local tooltip
|
||||
local tooltipText
|
||||
local tooltipx
|
||||
local tooltipy
|
||||
|
||||
-- the game is making me do this. im sorry
|
||||
local x = 19
|
||||
local y = 3
|
||||
for b = 1, 7 do
|
||||
local hovered = mouseOverBox(x * size, y * size, sprites['header/buttonbg']:getWidth() * size, sprites['header/buttonbg']:getHeight() * size)
|
||||
local btn = headerbuttons[b]
|
||||
|
||||
|
||||
if (btn and not btn.open) or not btn then
|
||||
-- draw nothing
|
||||
elseif hovered and love.mouse.isDown(1) then
|
||||
love.graphics.draw(sprites['header/buttonbg_down'], x * size, y * size, 0, size, size)
|
||||
if not tooltip then tooltip = btn.tooltip end
|
||||
elseif hovered then
|
||||
love.graphics.draw(sprites['header/buttonbg_hover'], x * size, y * size, 0, size, size)
|
||||
if not tooltip then tooltip = btn.tooltip end
|
||||
else
|
||||
love.graphics.draw(sprites['header/buttonbg'], x * size, y * size, 0, size, size)
|
||||
end
|
||||
|
||||
if tooltip and btn and not tooltipText then
|
||||
if not btn.tooltipText then
|
||||
btn.tooltipText = love.graphics.newText(fonts.pix, tooltip)
|
||||
end
|
||||
|
||||
tooltipText = btn.tooltipText
|
||||
tooltipx = x + sprites['header/buttonbg']:getWidth() * size * 0.5 - tooltipText:getWidth()/2
|
||||
tooltipy = y + sprites['header/buttonbg']:getWidth() * size
|
||||
end
|
||||
|
||||
if btn then
|
||||
if btn.open then
|
||||
-- sprite inside
|
||||
|
@ -88,5 +105,16 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance)
|
|||
love.graphics.setColor(179/255, 254/255, 89/255)
|
||||
local leftpad = 100
|
||||
love.graphics.printf(balance, round(sw * 0.965 - leftpad), round(HEADER_HEIGHT - 25), leftpad, 'right')
|
||||
|
||||
if tooltipText then
|
||||
love.graphics.setColor(254/255, 254/255, 199/255)
|
||||
love.graphics.rectangle('fill', round(tooltipx - 5), round(tooltipy - 5), round(tooltipText:getWidth() + 10), round(tooltipText:getHeight() + 10))
|
||||
love.graphics.setColor(2/255, 2/255, 2/255)
|
||||
love.graphics.rectangle('line', round(tooltipx - 5), round(tooltipy - 5), round(tooltipText:getWidth() + 10), round(tooltipText:getHeight() + 10))
|
||||
|
||||
love.graphics.setFont(fonts.pix)
|
||||
love.graphics.draw(tooltipText, round(tooltipx), round(tooltipy))
|
||||
end
|
||||
|
||||
love.graphics.setFont(fonts.default)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue