Compare commits
No commits in common. '7da12d303545d940cfdb5a4b78bab599292f201b' and '8440be2ab1162fba986d7ff98350b5ff2f07fe1c' have entirely different histories.
7da12d3035
...
8440be2ab1
@ -1,43 +0,0 @@ |
||||
GUI = Object:extend() |
||||
|
||||
function GUI:new() end |
||||
|
||||
function GUI:newButton(x, y, w, h, text, selected) |
||||
love.graphics.setColor(255, 255, 255) -- reset colours |
||||
|
||||
--x,y is the top left corner of the button |
||||
local rounding = 30 -- used for rounding the buttons |
||||
local xoff = x + 10 |
||||
local yoff = y - 10 |
||||
local textX, textY = 0, 0 |
||||
-- Get width and height of text |
||||
local tw = MenuFont:getWidth(text) |
||||
local th = MenuFont:getHeight(text) |
||||
love.graphics.setFont(MenuFont) |
||||
|
||||
if not selected then |
||||
love.graphics.setColor(love.math.colorFromBytes(41, 134, 204)) |
||||
love.graphics.rectangle("fill", x, y, w, h, rounding, rounding) |
||||
|
||||
-- Calculate position to center the text |
||||
textX = x + (w - tw) / 2 |
||||
textY = y + (h - th) / 2 |
||||
-- Place text inside the rectangle |
||||
love.graphics.setColor(0, 0, 0) |
||||
love.graphics.print(text, textX, textY) |
||||
elseif selected then |
||||
-- If selected, raise the button and draw a shadow |
||||
love.graphics.setColor(love.math.colorFromBytes(0, 0, 0)) |
||||
love.graphics.rectangle("fill", x, y, w, h, rounding, rounding) -- shadow |
||||
|
||||
love.graphics.setColor(love.math.colorFromBytes(244, 67, 54)) |
||||
love.graphics.rectangle("fill", xoff, yoff, w, h, rounding, rounding) -- button offset |
||||
|
||||
-- Calculate position to center the text |
||||
textX = xoff + (w - tw) / 2 |
||||
textY = yoff + (h - th) / 2 |
||||
-- Place text inside the rectangle |
||||
love.graphics.setColor(1, 1, 1) |
||||
love.graphics.print(text, textX, textY) |
||||
end |
||||
end |
@ -1,6 +0,0 @@ |
||||
function truncate(number, decdigits) |
||||
number = number * (10 ^ decdigits) |
||||
number = math.floor(number) |
||||
number = number / (10 ^ decdigits) |
||||
return number |
||||
end |
Loading…
Reference in new issue