summaryrefslogtreecommitdiff
path: root/msgbox.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2025-11-02 20:12:02 +0000
committerubq323 <ubq323@ubq323.website>2025-11-02 20:12:02 +0000
commitf238f1637d53389e4e804de72b7789c8fe312433 (patch)
tree36b97b8744b41133c8c192d6b35c1e66461271a6 /msgbox.lua
parenta71eeea17a7b54f46710f8d0ccb5e1e22fd54752 (diff)
refactor msgbox a little
Diffstat (limited to 'msgbox.lua')
-rw-r--r--msgbox.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/msgbox.lua b/msgbox.lua
index 720bfab..4956d91 100644
--- a/msgbox.lua
+++ b/msgbox.lua
@@ -1,10 +1,9 @@
-local font = love.graphics.getFont()
-
+local G = love.graphics
local msgs = {}
local function add(str)
- table.insert(msgs, 1, {text=love.graphics.newText(font,str),time=10})
+ table.insert(msgs, 1, {text=G.newText(G.getFont(),str),time=10})
end
local margin_bottom = 70
@@ -12,7 +11,7 @@ local margin_bottom = 70
local function draw()
if #msgs == 0 then return end
- local W,H = love.graphics.getDimensions()
+ local W,H = G.getDimensions()
local maxw = 0
local sumh = 0
for _,msg in ipairs(msgs) do
@@ -20,15 +19,15 @@ local function draw()
maxw = math.max(maxw,text:getWidth())
sumh = sumh + text:getHeight()
end
- love.graphics.setColor(0,0,0,0.8)
- love.graphics.rectangle("fill",0,H-sumh-margin_bottom,maxw,sumh)
+ G.setColor(0,0,0,0.8)
+ G.rectangle("fill",0,H-sumh-margin_bottom,maxw,sumh)
- love.graphics.setColor(1,1,1)
+ G.setColor(1,1,1)
local cury = H
for _,msg in ipairs(msgs) do
local text = msg.text
local h = text:getHeight()
- love.graphics.draw(text,0,cury-h-margin_bottom)
+ G.draw(text,0,cury-h-margin_bottom)
cury = cury - h
end
end