From 231a78a11871fd0cb816903401f0210fb98785ae Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:18:17 +0100 Subject: [PATCH] config: override type operator --- UnleashedRecomp/config_detail.h | 35 +++++------------------------- UnleashedRecomp/game.cpp | 12 +++++----- UnleashedRecomp/gpu/video.cpp | 8 +++---- UnleashedRecomp/kernel/imports.cpp | 4 ++-- UnleashedRecomp/ui/window.cpp | 6 ++--- UnleashedRecomp/ui/window.h | 8 +++---- 6 files changed, 24 insertions(+), 49 deletions(-) diff --git a/UnleashedRecomp/config_detail.h b/UnleashedRecomp/config_detail.h index f68457d..ed70482 100644 --- a/UnleashedRecomp/config_detail.h +++ b/UnleashedRecomp/config_detail.h @@ -96,40 +96,15 @@ public: return *this; } + operator T() const + { + return Value; + } + void operator=(const T& other) { Value = other; } - - bool operator==(const T& other) const - { - return Value == other; - } - - bool operator!=(const T& other) const - { - return Value != other; - } - - bool operator<(const T& other) const - { - return Value < other; - } - - bool operator>(const T& other) const - { - return Value > other; - } - - bool operator<=(const T& other) const - { - return Value <= other; - } - - bool operator>=(const T& other) const - { - return Value >= other; - } }; enum ELanguage diff --git a/UnleashedRecomp/game.cpp b/UnleashedRecomp/game.cpp index b68a311..52ca173 100644 --- a/UnleashedRecomp/game.cpp +++ b/UnleashedRecomp/game.cpp @@ -119,7 +119,7 @@ PPC_FUNC(sub_824DCF38) { /* Force the Werehog transition ID to use a different transition. */ - if (!Config::WerehogHubTransformVideo.Value) + if (!Config::WerehogHubTransformVideo) { /* 0 - Tails Electric NOW LOADING @@ -160,12 +160,12 @@ PPC_FUNC(sub_823AF7A8) m_lastDarkGaiaEnergy = pEvilSonicContext->m_DarkGaiaEnergy; // Don't drain energy if out of control. - if (!Config::UnleashOutOfControlDrain.Value && pEvilSonicContext->m_OutOfControlCount && ctx.f1.f64 < 0.0) + if (!Config::UnleashOutOfControlDrain && pEvilSonicContext->m_OutOfControlCount && ctx.f1.f64 < 0.0) return; __imp__sub_823AF7A8(ctx, base); - if (!Config::UnleashCancel.Value) + if (!Config::UnleashCancel) return; auto pInputState = SWA::CInputState::GetInstance(); @@ -198,12 +198,12 @@ void PostUnleashMidAsmHook(PPCRegister& r30) bool DisableHintsMidAsmHook() { - return !Config::Hints.Value; + return !Config::Hints; } void SetXButtonHomingMidAsmHook(PPCRegister& r30) { - r30.u32 = Config::XButtonHoming.Value; + r30.u32 = Config::XButtonHoming; } /* Hook function that gets the game region @@ -240,7 +240,7 @@ void GetStageIDMidAsmHook(PPCRegister& r5) PPC_FUNC_IMPL(__imp__sub_82547DF0); PPC_FUNC(sub_82547DF0) { - if (Config::LogoSkip.Value) + if (Config::LogoSkip) { ctx.r4.u64 = 0; ctx.r5.u64 = 0; diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index 7c70f78..a72b499 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -1171,7 +1171,7 @@ static GuestSurface* CreateSurface(uint32_t width, uint32_t height, uint32_t for desc.depth = 1; desc.mipLevels = 1; desc.arraySize = 1; - desc.multisampling.sampleCount = multiSample != 0 && Config::MSAA > 1 ? Config::MSAA.Value : RenderSampleCount::COUNT_1; + desc.multisampling.sampleCount = multiSample != 0 && Config::MSAA > 1 ? Config::MSAA : RenderSampleCount::COUNT_1; desc.format = ConvertFormat(format); desc.flags = desc.format == RenderFormat::D32_FLOAT ? RenderTextureFlag::DEPTH_TARGET : RenderTextureFlag::RENDER_TARGET; @@ -2614,7 +2614,7 @@ void IndexBufferLengthMidAsmHook(PPCRegister& r3) void SetShadowResolutionMidAsmHook(PPCRegister& r11) { if (Config::ShadowResolution > 0) - r11.u64 = Config::ShadowResolution.Value; + r11.u64 = Config::ShadowResolution; } void Primitive2DHalfPixelOffsetMidAsmHook(PPCRegister& f13) @@ -2624,8 +2624,8 @@ void Primitive2DHalfPixelOffsetMidAsmHook(PPCRegister& f13) static void SetResolution(be* device) { - uint32_t width = uint32_t(g_swapChain->getWidth() * Config::ResolutionScale.Value); - uint32_t height = uint32_t(g_swapChain->getHeight() * Config::ResolutionScale.Value); + uint32_t width = uint32_t(g_swapChain->getWidth() * Config::ResolutionScale); + uint32_t height = uint32_t(g_swapChain->getHeight() * Config::ResolutionScale); device[46] = width == 0 ? 880 : width; device[47] = height == 0 ? 720 : height; } diff --git a/UnleashedRecomp/kernel/imports.cpp b/UnleashedRecomp/kernel/imports.cpp index ab110ac..be0a3fe 100644 --- a/UnleashedRecomp/kernel/imports.cpp +++ b/UnleashedRecomp/kernel/imports.cpp @@ -191,7 +191,7 @@ void XamShowMessageBoxUIEx() uint32_t XGetLanguage() { // printf("!!! STUB !!! XGetLanguage\n"); - return Config::Language.Value; + return Config::Language; } uint32_t XGetAVPack() @@ -336,7 +336,7 @@ uint32_t ExGetXConfigSetting(uint16_t Category, uint16_t Setting, void* Buffer, // XCONFIG_USER_LANGUAGE case 0x0009: - data[0] = std::byteswap((uint32_t)Config::Language.Value); + data[0] = std::byteswap((uint32_t)Config::Language); break; // XCONFIG_USER_VIDEO_FLAGS diff --git a/UnleashedRecomp/ui/window.cpp b/UnleashedRecomp/ui/window.cpp index f404a92..7fb0ac9 100644 --- a/UnleashedRecomp/ui/window.cpp +++ b/UnleashedRecomp/ui/window.cpp @@ -92,8 +92,8 @@ void Window::Init() s_window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, - Config::WindowWidth.Value, - Config::WindowHeight.Value, + Config::WindowWidth, + Config::WindowHeight, SDL_WINDOW_RESIZABLE); if (auto icon = GetIconSurface()) @@ -103,7 +103,7 @@ void Window::Init() } SetWindowDimensions(); - SetFullscreen(Config::Fullscreen.Value); + SetFullscreen(Config::Fullscreen); SDL_SysWMinfo info; SDL_VERSION(&info.version); diff --git a/UnleashedRecomp/ui/window.h b/UnleashedRecomp/ui/window.h index b1077a2..07cbaaf 100644 --- a/UnleashedRecomp/ui/window.h +++ b/UnleashedRecomp/ui/window.h @@ -29,8 +29,8 @@ public: static bool IsDisplayResolution(int w, int h, bool isExact = true) { - auto width = w <= 0 ? Config::WindowWidth.Value : w; - auto height = h <= 0 ? Config::WindowHeight.Value : h; + auto width = w <= 0 ? Config::WindowWidth : w; + auto height = h <= 0 ? Config::WindowHeight : h; SDL_Rect displayRect; if (SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(s_window), &displayRect) == ERROR_SUCCESS) @@ -83,8 +83,8 @@ public: static void SetWindowDimensions(int w = -1, int h = -1) { - auto width = w <= 0 ? Config::WindowWidth.Value : w; - auto height = h <= 0 ? Config::WindowHeight.Value : h; + auto width = w <= 0 ? Config::WindowWidth : w; + auto height = h <= 0 ? Config::WindowHeight : h; auto isPendingMaximise = false; if (IsDisplayResolution(width, height))