Skip to content

Commit

Permalink
#Fix ui_scale. Schedule for next frame
Browse files Browse the repository at this point in the history
  • Loading branch information
immortalx74 committed Nov 1, 2022
1 parent 75f321d commit dd73a01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ NOTE: Helper to get the ui scale
|`scale`|number|ui scale

<span style="color:DeepSkyBlue">Returns:</span> `nothing`
NOTE: Helper to set the ui scale
NOTE: Helper to set the ui scale. Don't call this every frame (it causes textures to be regenerated)

---

Expand Down
11 changes: 8 additions & 3 deletions ui/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ local last_off_x = -50000
local last_off_y = -50000
local margin = 14
local ui_scale = 0.0005
local new_scale = nil
local controller_vibrate = false
local image_buttons_default_ttl = 2
local font = { handle, w, h, scale = 1 }
Expand Down Expand Up @@ -499,7 +500,7 @@ function UI.GetScale()
end

function UI.SetScale( scale )
ui_scale = scale
new_scale = scale
end

function UI.SetTextBoxText( id, text )
Expand Down Expand Up @@ -656,11 +657,17 @@ function UI.RenderFrame( main_pass )

if theme_changed then
GenerateOSKTextures( main_pass )
theme_changed = false
end

table.insert( passes, main_pass )
lovr.graphics.submit( passes )

if new_scale then
ui_scale = new_scale
end
new_scale = nil

ClearTable( windows )
ClearTable( passes )
ray = nil
Expand All @@ -675,8 +682,6 @@ function UI.RenderFrame( main_pass )
end
end
end

theme_changed = false
end

function UI.SameLine()
Expand Down

0 comments on commit dd73a01

Please sign in to comment.