From 9aefd8368970e2a3ffa9fe9504778d9238373f87 Mon Sep 17 00:00:00 2001 From: harry Date: Sun, 6 Apr 2025 20:54:57 +0100 Subject: [PATCH] makes various uis more compatible with high dpi monitors, adds a preference for smaller windows (#90418) ## About The Pull Request various uis (tgui-say, vv, player panel, anything using `/datum/browser`) would not correct for dpi. they now do we also have a preference to allow you to have smaller windows that are zoomed out, instead of larger windows that are not zoomed #### of note, this does require a small change to the usage of css viewport units, like `vh` and `vw`. they need to be fed through the `vp(100vw)` function first. there was only one such unit in the codebase on 4k monitor with 200% scaling: fixed (pref on default) ![BiygmRan0QqxOMqL@2x](https://github.com/user-attachments/assets/1bdbc93c-1cd4-4a17-bf18-6cca7a5df032) pref disabled ![DUWSVJNXt3xuQJEy@2x](https://github.com/user-attachments/assets/1b87ed9e-0498-44c4-ab1b-2c0321e70ce0) ## Why It's Good For The Game 516 fucked with uis again and this unfucks them a bit ## Changelog :cl: qol: there's a new UI preference called UI scale which allows people that use windows scaling to have their UIs original size with the contents zoomed out, instead of the default, which is the UIs being larger with the contents "normal" size fix: various UIs did not respect windows scaling, they now do /:cl: --------- Co-authored-by: harryob <55142896+harryob@users.noreply.github.com> --- code/datums/browser.dm | 16 +++++++-- code/modules/admin/player_panel.dm | 10 +++++- .../admin/view_variables/view_variables.dm | 9 ++++- code/modules/client/client_defines.dm | 3 ++ code/modules/client/client_procs.dm | 8 +++++ code/modules/client/preferences/tgui.dm | 13 +++++++ code/modules/tgui/tgui.dm | 1 + code/modules/tgui_input/say_modal/modal.dm | 7 ++-- tgui/packages/tgui-say/TguiSay.tsx | 16 ++++++--- tgui/packages/tgui-say/helpers.ts | 34 +++++++++++-------- tgui/packages/tgui/backend.ts | 1 + tgui/packages/tgui/drag.ts | 29 +++++++++++----- .../features/game_preferences/tgui.tsx | 7 ++++ tgui/packages/tgui/layouts/Window.tsx | 4 ++- tgui/packages/tgui/styles/functions.scss | 6 ++++ .../tgui/styles/layouts/TitleBar.scss | 3 +- tgui/packages/tgui/styles/main.scss | 5 +++ 17 files changed, 136 insertions(+), 36 deletions(-) diff --git a/code/datums/browser.dm b/code/datums/browser.dm index 360420ab00b..5bfaa5ea3c8 100644 --- a/code/datums/browser.dm +++ b/code/datums/browser.dm @@ -68,6 +68,14 @@ for (file in stylesheets) head_content += "" + if(user.client?.window_scaling && user.client?.window_scaling != 1 && !user.client?.prefs.read_preference(/datum/preference/toggle/ui_scale) && width && height) + head_content += {" + + "} for (file in scripts) head_content += "" @@ -105,8 +113,12 @@ to_chat(user, span_userdanger("The [title] browser you tried to open failed a sanity check! Please report this on GitHub!")) return var/window_size = "" - if (width && height) - window_size = "size=[width]x[height];" + if(width && height) + if(user.client?.prefs?.read_preference(/datum/preference/toggle/ui_scale)) + var/scaling = user.client.window_scaling + window_size = "size=[width * scaling]x[height * scaling];" + else + window_size = "size=[width]x[height];" var/datum/asset/simple/namespaced/common/common_asset = get_asset_datum(/datum/asset/simple/namespaced/common) common_asset.send(user) if (stylesheets.len) diff --git a/code/modules/admin/player_panel.dm b/code/modules/admin/player_panel.dm index 36b6a5b2c4a..c6cd2387cc6 100644 --- a/code/modules/admin/player_panel.dm +++ b/code/modules/admin/player_panel.dm @@ -4,10 +4,14 @@ log_admin("[key_name(usr)] checked the player panel.") var/dat = "Player Panel" + var/ui_scale = owner.prefs.read_preference(/datum/preference/toggle/ui_scale) + //javascript, the part that does most of the work~ dat += {" + [!ui_scale && owner.window_scaling ? "" : ""] +