From f238f1637d53389e4e804de72b7789c8fe312433 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Sun, 2 Nov 2025 20:12:02 +0000 Subject: refactor msgbox a little --- msgbox.lua | 15 +++++++-------- 1 file 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 -- cgit v1.2.3