mirror of
https://gitea.com/SweetSea-ButImNotSweet/tromi_mobile.git
synced 2025-01-08 17:33:09 +08:00
Set default draw function for button
This commit is contained in:
49
load.lua
49
load.lua
@@ -2,29 +2,40 @@
|
|||||||
bigint = require "libs.bigint.bigint"
|
bigint = require "libs.bigint.bigint"
|
||||||
number_names = require "libs.bigint.named-powers-of-ten"
|
number_names = require "libs.bigint.named-powers-of-ten"
|
||||||
|
|
||||||
BUTTON = require "libs.simple-button"
|
|
||||||
BUTTON.setDefaultOption{
|
|
||||||
draw = function(self)
|
|
||||||
love.graphics.setColor(self.backgroundColor)
|
|
||||||
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
|
||||||
|
|
||||||
if self._hovering then
|
|
||||||
love.graphics.setColor(self.hoverColor)
|
|
||||||
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
|
||||||
end
|
|
||||||
|
|
||||||
drawText(self.name, self.x, self.y + (self.h * 0.25), self.w, 'center')
|
|
||||||
|
|
||||||
love.graphics.setColor(self.borderColor)
|
|
||||||
love.graphics.rectangle('line', self.x, self.y, self.w, self.h, self.r)
|
|
||||||
end,
|
|
||||||
backgroundColor = {0, 0, 0, 0.7}
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Fonts
|
-- Fonts
|
||||||
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 28)
|
FONT_tromi = love.graphics.newFont('res/fonts/monofonto rg.otf', 28)
|
||||||
FONT_big = love.graphics.newFont('res/fonts/monofonto rg.otf', 56)
|
FONT_big = love.graphics.newFont('res/fonts/monofonto rg.otf', 56)
|
||||||
|
|
||||||
|
local font_height = FONT_tromi:getHeight() * 0.5
|
||||||
|
-- BUTTON library
|
||||||
|
BUTTON = require "libs.simple-button"
|
||||||
|
BUTTON.setDefaultOption{
|
||||||
|
draw = function(self)
|
||||||
|
love.graphics.setColor(0, 0, 0, 0.8)
|
||||||
|
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
||||||
|
|
||||||
|
if self._hovering then
|
||||||
|
love.graphics.setColor(0.4, 1, 1, 0.5)
|
||||||
|
love.graphics.rectangle('fill', self.x, self.y, self.w, self.h, self.r)
|
||||||
|
end
|
||||||
|
|
||||||
|
local lineAmount
|
||||||
|
do
|
||||||
|
local _, t = FONT_tromi:getWrap(self.text, self.w * 2)
|
||||||
|
lineAmount = #t
|
||||||
|
end
|
||||||
|
|
||||||
|
local textHeight = font_height * (lineAmount * 0.5)
|
||||||
|
local textPos = self.y + (self.h * 0.5) - textHeight
|
||||||
|
|
||||||
|
drawText(self.text, self.x, textPos, self.w, 'center')
|
||||||
|
|
||||||
|
love.graphics.setColor(1, 1, 1, 0.8)
|
||||||
|
love.graphics.setLineWidth(1)
|
||||||
|
love.graphics.rectangle('line', self.x, self.y, self.w, self.h, self.r)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
-- Graphics
|
-- Graphics
|
||||||
ShowLoadingText('backgrounds')
|
ShowLoadingText('backgrounds')
|
||||||
local gc_newImage, gc_newVideo = love.graphics.newImage, love.graphics.newVideo
|
local gc_newImage, gc_newVideo = love.graphics.newImage, love.graphics.newVideo
|
||||||
|
|||||||
Reference in New Issue
Block a user