Strip UI Scaling
This commit is contained in:
parent
92b12fb5b7
commit
b229ab6aa1
3 changed files with 9 additions and 45 deletions
|
@ -1,46 +1,19 @@
|
||||||
-- If enabled, scale UI for resolutions greater than 1080p when necessary.
|
|
||||||
-- Reports to a global when active, so that existing scaling can be disabled.
|
|
||||||
local vmf = get_mod("VMF")
|
local vmf = get_mod("VMF")
|
||||||
|
|
||||||
local _ui_scaling_enabled
|
local _ui_scaling_enabled
|
||||||
|
|
||||||
-- ####################################################################################################################
|
|
||||||
-- ##### Hooks ########################################################################################################
|
|
||||||
-- ####################################################################################################################
|
|
||||||
|
|
||||||
vmf:hook("UIResolutionScale", function (func, ...)
|
|
||||||
|
|
||||||
local width, height = UIResolution()
|
|
||||||
|
|
||||||
if (width > UIResolutionWidthFragments() and height > UIResolutionHeightFragments() and _ui_scaling_enabled) then
|
|
||||||
|
|
||||||
local max_scaling_factor = 4
|
|
||||||
|
|
||||||
-- Changed to allow scaling up to quadruple the original max scale (1 -> 4)
|
|
||||||
local width_scale = math.min(width / UIResolutionWidthFragments(), max_scaling_factor)
|
|
||||||
local height_scale = math.min(height / UIResolutionHeightFragments(), max_scaling_factor)
|
|
||||||
|
|
||||||
return math.min(width_scale, height_scale)
|
|
||||||
else
|
|
||||||
return func(...)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
-- ##### VMF internal functions and variables #########################################################################
|
-- ##### VMF internal functions and variables #########################################################################
|
||||||
-- ####################################################################################################################
|
-- ####################################################################################################################
|
||||||
|
|
||||||
vmf.load_ui_scaling_settings = function ()
|
vmf.check_if_ui_scaling_was_used_before = function()
|
||||||
_ui_scaling_enabled = vmf:get("ui_scaling")
|
_ui_scaling_enabled = _ui_scaling_enabled or vmf:get("ui_scaling")
|
||||||
if _ui_scaling_enabled then
|
if _ui_scaling_enabled then
|
||||||
RESOLUTION_LOOKUP.ui_scaling = true
|
vmf:set("ui_scaling", nil)
|
||||||
else
|
if UIResolutionScale() > 1 then
|
||||||
RESOLUTION_LOOKUP.ui_scaling = false
|
vmf:warning("UI SCALING WAS STRIPPED FROM THE VMF AND HAS BEEN RELEASED AS A SEPARATE MOD. " ..
|
||||||
|
"YOU CAN FIND THE DOWNLOAD LINK IN THE VMF WORKSHOP DESCRIPTION. " ..
|
||||||
|
"This message will be shown to you only during this game session.")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ####################################################################################################################
|
|
||||||
-- ##### Script #######################################################################################################
|
|
||||||
-- ####################################################################################################################
|
|
||||||
|
|
||||||
vmf.load_ui_scaling_settings()
|
|
||||||
|
|
|
@ -19,11 +19,6 @@ vmf_mod_data.options = {
|
||||||
range = {1, 1000},
|
range = {1, 1000},
|
||||||
unit_text = "percent"
|
unit_text = "percent"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
setting_id = "ui_scaling",
|
|
||||||
type = "checkbox",
|
|
||||||
default_value = true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
setting_id = "developer_mode",
|
setting_id = "developer_mode",
|
||||||
type = "checkbox",
|
type = "checkbox",
|
||||||
|
@ -192,10 +187,6 @@ vmf.on_setting_changed = function (setting_id)
|
||||||
|
|
||||||
vmf.load_custom_textures_settings()
|
vmf.load_custom_textures_settings()
|
||||||
|
|
||||||
elseif setting_id == "ui_scaling" then
|
|
||||||
|
|
||||||
vmf.load_ui_scaling_settings()
|
|
||||||
|
|
||||||
elseif setting_id == "logging_mode"
|
elseif setting_id == "logging_mode"
|
||||||
or setting_id == "output_mode_echo"
|
or setting_id == "output_mode_echo"
|
||||||
or setting_id == "output_mode_error"
|
or setting_id == "output_mode_error"
|
||||||
|
@ -239,7 +230,6 @@ if not vmf:get("vmf_initialized") then
|
||||||
vmf.load_custom_textures_settings()
|
vmf.load_custom_textures_settings()
|
||||||
vmf.load_dev_console_settings()
|
vmf.load_dev_console_settings()
|
||||||
vmf.load_chat_history_settings()
|
vmf.load_chat_history_settings()
|
||||||
vmf.load_ui_scaling_settings()
|
|
||||||
--vmf.load_vmf_options_view_settings()
|
--vmf.load_vmf_options_view_settings()
|
||||||
|
|
||||||
vmf:set("vmf_initialized", true)
|
vmf:set("vmf_initialized", true)
|
||||||
|
|
|
@ -107,6 +107,7 @@ function vmf_mod_object:on_game_state_changed(status, state)
|
||||||
|
|
||||||
if status == "enter" and state == "StateIngame" then
|
if status == "enter" and state == "StateIngame" then
|
||||||
vmf.create_keybinds_input_service()
|
vmf.create_keybinds_input_service()
|
||||||
|
vmf.check_if_ui_scaling_was_used_before() -- @TODO: strip it in a few months
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue