go through App in a couple more places
This commit is contained in:
parent
5b95e51c36
commit
a603847d18
8
app.lua
8
app.lua
|
@ -163,6 +163,10 @@ function App.newText(font, s)
|
|||
return {type='text', data=s, text=love.graphics.newText(font, s)}
|
||||
end
|
||||
|
||||
function App.width(text)
|
||||
return text.text:getWidth()
|
||||
end
|
||||
|
||||
function App.screen.draw(obj, x,y)
|
||||
if type(obj) == 'userdata' then
|
||||
-- ignore most things as graphics the test harness can't handle
|
||||
|
@ -192,10 +196,6 @@ function App.run_after_mousepress(x,y, button)
|
|||
App.draw()
|
||||
end
|
||||
|
||||
function App.width(text)
|
||||
return text.text:getWidth()
|
||||
end
|
||||
|
||||
function App.screen.check(y, expected_contents, msg)
|
||||
--? print('checking for "'..expected_contents..'" at y '..tostring(y))
|
||||
local screen_row = 'y'..tostring(y)
|
||||
|
|
|
@ -56,11 +56,11 @@ function Drawing.draw(line)
|
|||
local name_text
|
||||
-- TODO: avoid computing name width on every repaint
|
||||
if p.name == '' then
|
||||
name_text = love.graphics.newText(love.graphics.getFont(), 'm') -- 1em
|
||||
name_text = App.newText(love.graphics.getFont(), 'm') -- 1em
|
||||
else
|
||||
name_text = love.graphics.newText(love.graphics.getFont(), p.name)
|
||||
name_text = App.newText(love.graphics.getFont(), p.name)
|
||||
end
|
||||
love.graphics.rectangle('fill', x,y, math.floor(name_text:getWidth()*Zoom), math.floor(15*Zoom))
|
||||
love.graphics.rectangle('fill', x,y, math.floor(App.width(name_text)*Zoom), math.floor(15*Zoom))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue