Skip to content

Commit

Permalink
add gui scale setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauumm committed Nov 5, 2023
1 parent fc6e060 commit 76ce33e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ local function add_setting(category, name, default, options)
end

add_setting("Gameplay", "game_resolution_scale", 1, { min = 1, max = 10, step = 1 })
add_setting("UI", "gui_scale", 1, { min = 0.5, max = 2, step = 0.1 })
add_setting("UI", "area_based_gui_scale", false)
add_setting("UI", "background_preview", true)
add_setting("UI", "background_preview_has_text", false)
Expand Down
5 changes: 2 additions & 3 deletions ui/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ local ui = {}
local keyboard_navigation = require("ui.keyboard_navigation")
local current_screen
local transform = love.math.newTransform()
local gui_scale = 1

---set gui scale
---@param scale number
Expand Down Expand Up @@ -38,10 +37,10 @@ local function calculate_layout()
transform:translate(game_handler.get_game_position())
end
local width, height = ui.get_dimensions()
local scale = gui_scale
local scale = config.get("gui_scale")
if config.get("area_based_gui_scale") then
-- 1080p as reference for user setting in this scale mode
scale = gui_scale / math.max(1920 / width, 1080 / height)
scale = scale / math.max(1920 / width, 1080 / height)
end
ui.set_scale(scale)
local res_width, res_height = current_screen:calculate_layout(width, height)
Expand Down

0 comments on commit 76ce33e

Please sign in to comment.