Add UI scaling. Code reduction.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "SDK/UI_InGameMenu_classes.hpp"
|
||||
#include "SDK/UI_PauseMenu_classes.hpp"
|
||||
#include "SDK/UI_Saves_classes.hpp"
|
||||
#include "SDK/UI_Upgrades_classes.hpp"
|
||||
#include "SDK/Styx3_classes.hpp"
|
||||
|
||||
using namespace SDK;
|
||||
@@ -105,6 +106,7 @@ static UUserWidget* g_SavesWidget = nullptr;
|
||||
static UUserWidget* g_MapWidget = nullptr;
|
||||
static UUserWidget* g_GameOverWidget = nullptr;
|
||||
static UUserWidget* g_LoadingWidget = nullptr;
|
||||
static UUserWidget* g_UpgradeWidget = nullptr;
|
||||
static UWidget* g_StatusWidget = nullptr;
|
||||
static UWidget* g_GaugesWidget = nullptr;
|
||||
static UWidget* g_ChangeWheelWidget = nullptr;
|
||||
@@ -291,6 +293,8 @@ static void ProcessEvent() {
|
||||
HandleWidget(static_cast<UUI_MainMenu_C*>(object), g_UIMainMenuWidget);
|
||||
else if (object->IsA(UUI_Saves_C::StaticClass()))
|
||||
HandleWidget(static_cast<UUI_Saves_C*>(object), g_SavesWidget);
|
||||
else if (object->IsA(UUI_Upgrades_C::StaticClass()))
|
||||
HandleWidget(static_cast<UUI_Upgrades_C*>(object), g_UpgradeWidget);
|
||||
else if (objectName.rfind("UI_Map_C", 0) == 0)
|
||||
HandleWidget(static_cast<UUserWidget*>(object), g_MapWidget);
|
||||
else if (objectName.rfind("UI_GameOver_C", 0) == 0)
|
||||
@@ -367,7 +371,7 @@ static void HUDUpdate(bool writeLog) {
|
||||
if (writeLog) logger->info("HUD & UI scaling fix {}", g_fix_enabled && g_HUD_fix_enabled ? "enabled" : "disabled");
|
||||
float UIoffset = (g_fix_enabled && g_HUD_fix_enabled) ? g_UIOffsets : 0.f;
|
||||
float HUDoffset = (g_fix_enabled && g_HUD_fix_enabled) ? g_HUDOffsets : 0.f;
|
||||
float compensation = (g_fix_enabled && g_HUD_fix_enabled) ? -90.f : 0.f;
|
||||
float compensation = (g_fix_enabled && g_HUD_fix_enabled) ? -0.f : 0.f;
|
||||
float targetWidth = 1920.f;
|
||||
float targetHeight = 1080.f;
|
||||
CenterWidget(g_UIMainMenuWidget, UIoffset, screenWidth, screenHeight, targetWidth, targetHeight, compensation);
|
||||
@@ -379,6 +383,7 @@ static void HUDUpdate(bool writeLog) {
|
||||
CenterWidget(g_SavesWidget, UIoffset, screenWidth, screenHeight, targetWidth, targetHeight, compensation);
|
||||
CenterWidget(g_MapWidget, UIoffset, screenWidth, screenHeight, targetWidth, targetHeight, compensation);
|
||||
CenterWidget(g_GameOverWidget, UIoffset, screenWidth, screenHeight, targetWidth, targetHeight, compensation);
|
||||
CenterWidget(g_UpgradeWidget, UIoffset, screenWidth, screenHeight, targetWidth, targetHeight, compensation);
|
||||
ApplyOffsetsSmart(g_StatusWidget, HUDoffset, 0.f, 1);
|
||||
ApplyOffsetsSmart(g_GaugesWidget, 0, HUDoffset + 690.f, 1); // Use original left and right offset + for Anchors of type 1, 1, 1, 1
|
||||
ApplyOffsetsSmart(g_AbilityWheelWidget, 0, HUDoffset + 78.f, 1); // Use original left and right offset + for Anchors of type 1, 1, 1, 1
|
||||
@@ -389,7 +394,7 @@ static void HUDUpdate(bool writeLog) {
|
||||
}
|
||||
|
||||
static void FOVFixEnabled() {
|
||||
if (g_fix_enabled && (g_fov_fix_enabled || g_ultrawide_fix_enabled) && CameraComponentaddress) {
|
||||
if (CameraComponentaddress) {
|
||||
if (!FOVHook) { // Hook only once
|
||||
FOVHook = safetyhook::create_mid(CameraComponentaddress + 0xa,
|
||||
[](SafetyHookContext& ctx) {
|
||||
@@ -401,13 +406,9 @@ static void FOVFixEnabled() {
|
||||
g_FOV_Out = ctx.xmm0.f32[0];
|
||||
});
|
||||
}
|
||||
else FOVHook.enable();
|
||||
logger->info("FOV fix enabled");
|
||||
}
|
||||
if (!(g_fix_enabled && (g_fov_fix_enabled || g_ultrawide_fix_enabled)) && CameraComponentaddress) {
|
||||
if (FOVHook) FOVHook.disable();
|
||||
logger->info("FOV fix disabled");
|
||||
}
|
||||
if (CameraComponentaddress)
|
||||
logger->info("FOV fix {}", g_fix_enabled && g_fov_fix_enabled ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
static void UltraWideFixEnabled() {
|
||||
|
||||
Reference in New Issue
Block a user