diff --git a/code/components/nui-core/include/NUIWindow.h b/code/components/nui-core/include/NUIWindow.h index 386a51d3a0..abf39aa8e1 100644 --- a/code/components/nui-core/include/NUIWindow.h +++ b/code/components/nui-core/include/NUIWindow.h @@ -212,4 +212,6 @@ class void HandlePopupShow(bool show); bool IsFixedSizeWindow() const; + + int GetFixedSizeMode() const; }; diff --git a/code/components/nui-core/src/NUIWindow.cpp b/code/components/nui-core/src/NUIWindow.cpp index 79fd4db320..4aa7ccc861 100644 --- a/code/components/nui-core/src/NUIWindow.cpp +++ b/code/components/nui-core/src/NUIWindow.cpp @@ -30,6 +30,7 @@ extern nui::GameInterface* g_nuiGi; extern std::wstring GetNUIStoragePath(); static bool nuiFixedSizeEnabled; +static int nuiFixedSizeMode; namespace nui { @@ -562,8 +563,17 @@ void NUIWindow::UpdateFrame() if (IsFixedSizeWindow()) { - resX = 1920; - resY = 1080; + const int fixedSizeMode = GetFixedSizeMode(); + if (fixedSizeMode == 0) + { + resX = 1920; + resY = 1080; + } + else if (fixedSizeMode == 1) + { + resX = 2560; + resY = 1440; + } } if (m_width != resX || m_height != resY) @@ -959,7 +969,13 @@ bool NUIWindow::IsFixedSizeWindow() const return nuiFixedSizeEnabled && m_name == "root"; } +int NUIWindow::GetFixedSizeMode() const +{ + return nuiFixedSizeMode; +} + static InitFunction initFunction([] { static ConVar nuiFixedSize("nui_useFixedSize", ConVar_Archive | ConVar_UserPref, false, &nuiFixedSizeEnabled); + static ConVar nuiFixedSizeMode("nui_fixedSizeMode", ConVar_Archive | ConVar_UserPref, 0, &nuiFixedSizeMode); }); diff --git a/ext/cfx-ui/src/assets/languages/locale-en.json b/ext/cfx-ui/src/assets/languages/locale-en.json index 1f5d1e4d4f..70bfeeb42a 100644 --- a/ext/cfx-ui/src/assets/languages/locale-en.json +++ b/ext/cfx-ui/src/assets/languages/locale-en.json @@ -128,7 +128,9 @@ "#Settings_InProcessGpu": "NUI in-process GPU", "#Settings_InProcessGpuDesc": "Fix 'UI lag' at high GPU usage, but may cause reliability issues with GPU crashes (requires restart)", "#Settings_FixedSizeNUI": "Fixed-size NUI", - "#Settings_FixedSizeNUIDesc": "Force in-server UI to 1920x1080 resolution, scaled/letterboxed to fit (for servers with UI assuming 1920x1080)", + "#Settings_FixedSizeNUIDesc": "Force in-server UI to one one of the specified resolutions resolutions, scaled/letterboxed to fit (for servers with UI assuming clients will have 1920x1080 or 2560x1440)", + "#Settings_FixedSizeNUIMode": "Fixed-size NUI mode", + "#Settings_FixedSizeNUIModeDesc": "", "#Settings_NoiseSuppression": "Voice chat noise suppression", "#Settings_NoiseSuppressionDesc": "Enable background noise suppression (using RNNoise) for the built-in voice chat", "#Settings_ConnectedProfiles": "Linked identities", diff --git a/ext/cfx-ui/src/cfx/apps/mpMenu/settings.tsx b/ext/cfx-ui/src/cfx/apps/mpMenu/settings.tsx index 1febe1564f..41a8aed5c6 100644 --- a/ext/cfx-ui/src/cfx/apps/mpMenu/settings.tsx +++ b/ext/cfx-ui/src/cfx/apps/mpMenu/settings.tsx @@ -1,7 +1,7 @@ import emojiList from 'emoji.json/emoji-compact.json'; import { BrandIcon, Icons } from "cfx/ui/Icons"; import { BsDisplay } from "react-icons/bs"; -import { ISetting, ISettings } from "cfx/common/services/settings/types"; +import { FixedUiScaling, ISetting, ISettings } from "cfx/common/services/settings/types"; import { useService } from "cfx/base/servicesContainer"; import { CurrentGameName } from "cfx/base/gameRuntime"; import { CustomBackdropControl } from "./parts/SettingsFlyout/CustomBackdropControl/CustomBackdropControl"; @@ -221,6 +221,20 @@ const GAME_GAME_SETTINGS = new Map([ ...convarAccessorsBoolean('nui_useFixedSize'), }], + ['fixedSizeNuiMode', { + type: 'switch', + + label: $L('#Settings_FixedSizeNUIMode'), + + options: { + [FixedUiScaling.ScaleBy_1920x1080]: '1920x1080', + [FixedUiScaling.ScaleBy_2560x1440]: '2560x1440', + }, + + ...convarAccessorsString("nui_fixedSizeMode"), + + visible: () => useService(IConvarService).getBoolean('nui_useFixedSize'), + }], ['noiseSuppression', { type: 'checkbox', diff --git a/ext/cfx-ui/src/cfx/common/services/settings/types.ts b/ext/cfx-ui/src/cfx/common/services/settings/types.ts index 1d303123ab..7cf12d8ef0 100644 --- a/ext/cfx-ui/src/cfx/common/services/settings/types.ts +++ b/ext/cfx-ui/src/cfx/common/services/settings/types.ts @@ -82,4 +82,9 @@ export type ICategory = { settings: Map, }; +export enum FixedUiScaling { + ScaleBy_1920x1080, + ScaleBy_2560x1440 +} + export type ISettings = Map;