mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
- display.gui-scale is now a number: 0 (auto) or 0.5..4 in 0.5 steps - explicit scale is no longer limited by window size (tiled windows); only an open menu page is shrunk to fit the window - snap Batch2D vertices to pixels on fractional scale (fixes dots above text) - pass app to settings_common via options (not visible inside modules) - gui.get_scale() returns a number
48 lines
2 KiB
Lua
48 lines
2 KiB
Lua
local tostring_overrides = {}
|
|
tostring_overrides["display.framerate"] = function(x)
|
|
if x == -1 then
|
|
return gui.str("V-Sync")
|
|
elseif x == 0 then
|
|
return gui.str("Unlimited")
|
|
else
|
|
return tostring(x)
|
|
end
|
|
end
|
|
|
|
tostring_overrides["display.gui-scale"] = function(x)
|
|
if x == 0 then
|
|
return string.format("%s (%d)", gui.str("Auto"), gui.get_max_scale())
|
|
end
|
|
local effective = gui.get_scale()
|
|
if effective ~= x then
|
|
-- menu is limited by window size
|
|
return string.format("%s (%s %s)", tostring(x), gui.str("Effective"), tostring(effective))
|
|
end
|
|
return tostring(x)
|
|
end
|
|
|
|
local settings = require "core:settings_common".new(document, {app=app, tostring_overrides=tostring_overrides})
|
|
-- templates call these functions by name, so they must be global
|
|
create_trackbar_setting = settings.create_trackbar_setting
|
|
update_trackbar_label = settings.update_trackbar_label
|
|
create_checkbox = settings.create_checkbox
|
|
|
|
function on_open()
|
|
create_trackbar_setting("camera.fov", "FOV", 1, "°")
|
|
create_trackbar_setting("display.framerate", "Framerate", 1, "", "", true)
|
|
create_trackbar_setting("display.gui-scale", "GUI Scale", 0.5, "", "display.gui-scale.tooltip", true)
|
|
|
|
document.root:add(string.format(
|
|
"<select context='settings' onselect='function(opt) app.set_setting(\"display.window-mode\", tonumber(opt)) end' selected='%s'>"..
|
|
"<option value='0'>@Windowed</option>"..
|
|
"<option value='1'>@Fullscreen</option>"..
|
|
"<option value='2'>@Borderless</option>"..
|
|
"</select>", app.get_setting("display.window-mode"))
|
|
)
|
|
|
|
create_checkbox("camera.shaking", "Camera Shaking")
|
|
create_checkbox("camera.inertia", "Camera Inertia")
|
|
create_checkbox("camera.fov-effects", "Camera FOV Effects")
|
|
create_checkbox("display.limit-fps-iconified", "Limit Background FPS")
|
|
create_trackbar_setting("graphics.gamma", "Gamma", 0.05, "", "graphics.gamma.tooltip")
|
|
end
|