Reduce how often the UI renders for the overlay tool

This commit is contained in:
Empathic Qubit 2021-04-30 03:20:53 -04:00
parent 8fbc113a3e
commit d2f7a1a5d8

View file

@ -24,7 +24,7 @@ local FG_COLOR = 0x00ffffff
local BG_COLOR = 0x99000000 local BG_COLOR = 0x99000000
local TILE_RADIUS = 5 local TILE_RADIUS = 5
local count = 0 local frame = 0
local detailsidx = -1 local detailsidx = -1
local jumping = false local jumping = false
local helddown = false local helddown = false
@ -202,10 +202,11 @@ local function sprite_details(idx)
text(0, 0, "Sprite "..idx..(locked and " (Locked)" or "")..":\n\n"..util.table_to_string(sprite)) text(0, 0, "Sprite "..idx..(locked and " (Locked)" or "")..":\n\n"..util.table_to_string(sprite))
end end
function on_paint (not_synth) local overlayCtx = nil
count = count + 1 local overlay = nil
local function renderOverlay(guiWidth, guiHeight)
local guiWidth, guiHeight = gui.resolution() overlayCtx:set()
overlayCtx:clear()
if showhelp then if showhelp then
text(0, 0, [[ text(0, 0, [[
@ -395,6 +396,24 @@ Current area: %04x
end end
text(guiWidth - 125, 20, "Help [Hold 0]") text(guiWidth - 125, 20, "Help [Hold 0]")
overlay = overlayCtx:render()
gui.renderctx.setnull()
end
function on_paint (not_synth)
frame = frame + 1
local guiWidth, guiHeight = gui.resolution()
if overlayCtx == nil then
overlayCtx = gui.renderctx.new(guiWidth, guiHeight)
end
if frame % 3 == 0 then
renderOverlay(guiWidth, guiHeight)
end
overlay:draw(0, 0)
end end
function on_timer() function on_timer()