diff --git a/UnleashedRecomp/config.h b/UnleashedRecomp/config.h index 12099d2..c6f1c43 100644 --- a/UnleashedRecomp/config.h +++ b/UnleashedRecomp/config.h @@ -7,9 +7,9 @@ class Config public: inline static std::vector> Definitions{}; - CONFIG_DEFINE("System", ELanguage, Language, ELanguage_English); + CONFIG_DEFINE("System", Language, Language, Language::English); CONFIG_DEFINE("System", bool, Hints, true); - CONFIG_DEFINE("System", EScoreBehaviour, ScoreBehaviour, EScoreBehaviour_CheckpointReset); + CONFIG_DEFINE("System", ScoreBehaviour, ScoreBehaviour, ScoreBehaviour::CheckpointReset); CONFIG_DEFINE("System", bool, UnleashOutOfControlDrain, true); CONFIG_DEFINE("System", bool, WerehogHubTransformVideo, true); CONFIG_DEFINE("System", bool, LogoSkip, false); @@ -21,11 +21,11 @@ public: CONFIG_DEFINE("Audio", float, MusicVolume, 1.0f); CONFIG_DEFINE("Audio", float, SEVolume, 1.0f); - CONFIG_DEFINE("Audio", EVoiceLanguage, VoiceLanguage, EVoiceLanguage_English); + CONFIG_DEFINE("Audio", VoiceLanguage, VoiceLanguage, VoiceLanguage::English); CONFIG_DEFINE("Audio", bool, Subtitles, true); CONFIG_DEFINE("Audio", bool, WerehogBattleMusic, true); - CONFIG_DEFINE("Video", EGraphicsAPI, GraphicsAPI, EGraphicsAPI_D3D12); + CONFIG_DEFINE("Video", GraphicsAPI, GraphicsAPI, GraphicsAPI::D3D12); CONFIG_DEFINE("Video", size_t, WindowWidth, 1280); CONFIG_DEFINE("Video", size_t, WindowHeight, 720); @@ -42,11 +42,11 @@ public: CONFIG_DEFINE("Video", size_t, MSAA, 4); CONFIG_DEFINE("Video", size_t, AnisotropicFiltering, 16); CONFIG_DEFINE("Video", int32_t, ShadowResolution, 4096); - CONFIG_DEFINE("Video", EGITextureFiltering, GITextureFiltering, EGITextureFiltering_Bicubic); + CONFIG_DEFINE("Video", GITextureFiltering, GITextureFiltering, GITextureFiltering::Bicubic); CONFIG_DEFINE("Video", bool, AlphaToCoverage, false); CONFIG_DEFINE("Video", bool, Xbox360ColorCorrection, false); - CONFIG_DEFINE("Video", EMovieScaleMode, MovieScaleMode, EMovieScaleMode_Fit); - CONFIG_DEFINE("Video", EUIScaleMode, UIScaleMode, EUIScaleMode_Centre); + CONFIG_DEFINE("Video", MovieScaleMode, MovieScaleMode, MovieScaleMode::Fit); + CONFIG_DEFINE("Video", UIScaleMode, UIScaleMode, UIScaleMode::Centre); static std::filesystem::path GetUserPath() { diff --git a/UnleashedRecomp/config_detail.h b/UnleashedRecomp/config_detail.h index 6759e26..8e25513 100644 --- a/UnleashedRecomp/config_detail.h +++ b/UnleashedRecomp/config_detail.h @@ -17,7 +17,7 @@ class ConfigDefBase { public: virtual ~ConfigDefBase() = default; - virtual void ReadValue(toml::v3::ex::parse_result toml) = 0; + virtual void ReadValue(toml::v3::ex::parse_result& toml) = 0; virtual void MakeDefault() = 0; virtual std::string GetSection() const = 0; virtual std::string GetName() const = 0; @@ -47,7 +47,7 @@ public: Config::Definitions.emplace_back(this); } - void ReadValue(toml::v3::ex::parse_result toml) override + void ReadValue(toml::v3::ex::parse_result& toml) override { if (auto pSection = toml[Section].as_table()) { @@ -57,6 +57,10 @@ public: { Value = section[Name].value_or(DefaultValue); } + else if constexpr (std::is_enum_v) + { + Value = T(section[Name].value_or(std::underlying_type_t(DefaultValue))); + } else { Value = section[Name].value_or(DefaultValue); @@ -100,14 +104,14 @@ public: { return Value; } - else if constexpr (std::is_same::value) + else if constexpr (std::is_enum_v) { - return Value ? "true" : "false"; + return std::format("{}", std::underlying_type_t(Value)); + } + else + { + return std::format("{}", Value); } - - std::ostringstream oss; - oss << Value; - return oss.str(); } ConfigDef& operator=(const ConfigDef& other) @@ -129,50 +133,50 @@ public: } }; -enum ELanguage +enum class Language : uint32_t { - ELanguage_English = 1, - ELanguage_Japanese, - ELanguage_German, - ELanguage_French, - ELanguage_Spanish, - ELanguage_Italian + English = 1, + Japanese, + German, + French, + Spanish, + Italian }; -enum EScoreBehaviour +enum class ScoreBehaviour : uint32_t { - EScoreBehaviour_CheckpointReset, - EScoreBehaviour_CheckpointRetain + CheckpointReset, + CheckpointRetain }; -enum EVoiceLanguage +enum class VoiceLanguage : uint32_t { - EVoiceLanguage_English, - EVoiceLanguage_Japanese + English, + Japanese }; -enum EGraphicsAPI +enum class GraphicsAPI : uint32_t { - EGraphicsAPI_D3D12, - EGraphicsAPI_Vulkan + D3D12, + Vulkan }; -enum EGITextureFiltering +enum class GITextureFiltering : uint32_t { - EGITextureFiltering_Linear, - EGITextureFiltering_Bicubic + Linear, + Bicubic }; -enum EMovieScaleMode +enum class MovieScaleMode : uint32_t { - EMovieScaleMode_Stretch, - EMovieScaleMode_Fit, - EMovieScaleMode_Fill + Stretch, + Fit, + Fill }; -enum EUIScaleMode +enum class UIScaleMode : uint32_t { - EUIScaleMode_Stretch, - EUIScaleMode_Edge, - EUIScaleMode_Centre + Stretch, + Edge, + Centre }; diff --git a/UnleashedRecomp/game.cpp b/UnleashedRecomp/game.cpp index 52ca173..74b4810 100644 --- a/UnleashedRecomp/game.cpp +++ b/UnleashedRecomp/game.cpp @@ -73,7 +73,7 @@ PPC_FUNC(sub_82624308) { __imp__sub_82624308(ctx, base); - if (Config::ScoreBehaviour != EScoreBehaviour_CheckpointRetain) + if (Config::ScoreBehaviour != ScoreBehaviour::CheckpointRetain) return; auto pGameDocument = SWA::CGameDocument::GetInstance(); @@ -91,7 +91,7 @@ PPC_FUNC(sub_8245F048) { __imp__sub_8245F048(ctx, base); - if (Config::ScoreBehaviour != EScoreBehaviour_CheckpointRetain) + if (Config::ScoreBehaviour != ScoreBehaviour::CheckpointRetain) return; auto pGameDocument = SWA::CGameDocument::GetInstance(); @@ -212,7 +212,7 @@ void SetXButtonHomingMidAsmHook(PPCRegister& r30) PPC_FUNC_IMPL(__imp__sub_825197C0); PPC_FUNC(sub_825197C0) { - if (Config::Language == ELanguage_Japanese) + if (Config::Language == Language::Japanese) { ctx.r3.u64 = 0; return; diff --git a/UnleashedRecomp/gpu/video.cpp b/UnleashedRecomp/gpu/video.cpp index a72b499..bfb5821 100644 --- a/UnleashedRecomp/gpu/video.cpp +++ b/UnleashedRecomp/gpu/video.cpp @@ -561,7 +561,7 @@ static void CreateHostDevice() Window::Init(); - g_vulkan = Config::GraphicsAPI == EGraphicsAPI_Vulkan; + g_vulkan = Config::GraphicsAPI == GraphicsAPI::Vulkan; LoadShaderCache(); diff --git a/UnleashedRecomp/kernel/imports.cpp b/UnleashedRecomp/kernel/imports.cpp index be0a3fe..040d0d2 100644 --- a/UnleashedRecomp/kernel/imports.cpp +++ b/UnleashedRecomp/kernel/imports.cpp @@ -78,7 +78,7 @@ void XGetVideoMode() uint32_t XGetGameRegion() { // printf("!!! STUB !!! XGetGameRegion\n"); - if (Config::Language == ELanguage_Japanese) + if (Config::Language == Language::Japanese) return 0x0101; return 0x03FF; @@ -191,7 +191,7 @@ void XamShowMessageBoxUIEx() uint32_t XGetLanguage() { // printf("!!! STUB !!! XGetLanguage\n"); - return Config::Language; + return (uint32_t)Config::Language.Value; } 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); + data[0] = std::byteswap((uint32_t)Config::Language.Value); break; // XCONFIG_USER_VIDEO_FLAGS diff --git a/UnleashedRecomp/res/config.toml b/UnleashedRecomp/res/config.toml deleted file mode 100644 index e9b8a94..0000000 --- a/UnleashedRecomp/res/config.toml +++ /dev/null @@ -1,39 +0,0 @@ -[System] -Language = 1 # English = 1; Japanese = 2; German = 3; French = 4; Spanish = 5; Italian = 6. -Hints = true -ScoreBehaviour = 0 # Reset to zero = 0; Reset to last checkpoint score = 1. -UnleashOutOfControlDrain = true -WerehogHubTransformVideo = true -LogoSkip = false - -[Controls] -CameraXInvert = false -CameraYInvert = false -XButtonHoming = true -UnleashCancel = false - -[Audio] -MusicVolume = 1.0 -SEVolume = 1.0 -VoiceLanguage = 0 # English = 0; Japanese = 1. -Subtitles = true -WerehogBattleMusic = true - -[Video] -GraphicsAPI = 0 # D3D12 = 0; Vulkan = 1. -WindowWidth = 1280 -WindowHeight = 720 -ResolutionScale = 1.0 -Fullscreen = false -VSync = true -BufferCount = 3 # Double buffering = 2; Triple buffering = 3. -FPS = 60 # Unlocked = -1; 30 FPS = 30; 60 FPS = 60. -Brightness = 0.5 -MSAA = 4 -AnisotropicFiltering = 16 -ShadowResolution = 4096 # Default = -1; otherwise, any power of two resolution. -GITextureFiltering = 1 # Linear = 0; Bicubic = 1. -AlphaToCoverage = true -Xbox360ColorCorrection = false -MovieScaleMode = 1 # Stretch = 0; Fit = 1; Fill = 2. -UIScaleMode = 2 # Stretch = 0; Edge = 1; Centre = 2. \ No newline at end of file diff --git a/UnleashedRecomp/stdafx.h b/UnleashedRecomp/stdafx.h index 3e6445a..8d850dd 100644 --- a/UnleashedRecomp/stdafx.h +++ b/UnleashedRecomp/stdafx.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/UnleashedRecomp/ui/window.cpp b/UnleashedRecomp/ui/window.cpp index 7fb0ac9..1b53a8e 100644 --- a/UnleashedRecomp/ui/window.cpp +++ b/UnleashedRecomp/ui/window.cpp @@ -79,7 +79,7 @@ void Window::Init() { /* TODO: move this since it'll have to change on soft reboot from the options menu. */ - auto title = Config::Language == ELanguage_Japanese + auto title = Config::Language == Language::Japanese ? "Sonic World Adventure" : "SONIC UNLEASHED";