mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
config: use enum classes
This commit is contained in:
parent
91b3a6c9c1
commit
23b5bdab85
8 changed files with 55 additions and 89 deletions
|
|
@ -7,9 +7,9 @@ class Config
|
||||||
public:
|
public:
|
||||||
inline static std::vector<std::shared_ptr<ConfigDefBase>> Definitions{};
|
inline static std::vector<std::shared_ptr<ConfigDefBase>> Definitions{};
|
||||||
|
|
||||||
CONFIG_DEFINE("System", ELanguage, Language, ELanguage_English);
|
CONFIG_DEFINE("System", Language, Language, Language::English);
|
||||||
CONFIG_DEFINE("System", bool, Hints, true);
|
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, UnleashOutOfControlDrain, true);
|
||||||
CONFIG_DEFINE("System", bool, WerehogHubTransformVideo, true);
|
CONFIG_DEFINE("System", bool, WerehogHubTransformVideo, true);
|
||||||
CONFIG_DEFINE("System", bool, LogoSkip, false);
|
CONFIG_DEFINE("System", bool, LogoSkip, false);
|
||||||
|
|
@ -21,11 +21,11 @@ public:
|
||||||
|
|
||||||
CONFIG_DEFINE("Audio", float, MusicVolume, 1.0f);
|
CONFIG_DEFINE("Audio", float, MusicVolume, 1.0f);
|
||||||
CONFIG_DEFINE("Audio", float, SEVolume, 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, Subtitles, true);
|
||||||
CONFIG_DEFINE("Audio", bool, WerehogBattleMusic, 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, WindowWidth, 1280);
|
||||||
CONFIG_DEFINE("Video", size_t, WindowHeight, 720);
|
CONFIG_DEFINE("Video", size_t, WindowHeight, 720);
|
||||||
|
|
||||||
|
|
@ -42,11 +42,11 @@ public:
|
||||||
CONFIG_DEFINE("Video", size_t, MSAA, 4);
|
CONFIG_DEFINE("Video", size_t, MSAA, 4);
|
||||||
CONFIG_DEFINE("Video", size_t, AnisotropicFiltering, 16);
|
CONFIG_DEFINE("Video", size_t, AnisotropicFiltering, 16);
|
||||||
CONFIG_DEFINE("Video", int32_t, ShadowResolution, 4096);
|
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, AlphaToCoverage, false);
|
||||||
CONFIG_DEFINE("Video", bool, Xbox360ColorCorrection, false);
|
CONFIG_DEFINE("Video", bool, Xbox360ColorCorrection, false);
|
||||||
CONFIG_DEFINE("Video", EMovieScaleMode, MovieScaleMode, EMovieScaleMode_Fit);
|
CONFIG_DEFINE("Video", MovieScaleMode, MovieScaleMode, MovieScaleMode::Fit);
|
||||||
CONFIG_DEFINE("Video", EUIScaleMode, UIScaleMode, EUIScaleMode_Centre);
|
CONFIG_DEFINE("Video", UIScaleMode, UIScaleMode, UIScaleMode::Centre);
|
||||||
|
|
||||||
static std::filesystem::path GetUserPath()
|
static std::filesystem::path GetUserPath()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ class ConfigDefBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~ConfigDefBase() = default;
|
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 void MakeDefault() = 0;
|
||||||
virtual std::string GetSection() const = 0;
|
virtual std::string GetSection() const = 0;
|
||||||
virtual std::string GetName() const = 0;
|
virtual std::string GetName() const = 0;
|
||||||
|
|
@ -47,7 +47,7 @@ public:
|
||||||
Config::Definitions.emplace_back(this);
|
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())
|
if (auto pSection = toml[Section].as_table())
|
||||||
{
|
{
|
||||||
|
|
@ -57,6 +57,10 @@ public:
|
||||||
{
|
{
|
||||||
Value = section[Name].value_or<std::string>(DefaultValue);
|
Value = section[Name].value_or<std::string>(DefaultValue);
|
||||||
}
|
}
|
||||||
|
else if constexpr (std::is_enum_v<T>)
|
||||||
|
{
|
||||||
|
Value = T(section[Name].value_or(std::underlying_type_t<T>(DefaultValue)));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Value = section[Name].value_or(DefaultValue);
|
Value = section[Name].value_or(DefaultValue);
|
||||||
|
|
@ -100,14 +104,14 @@ public:
|
||||||
{
|
{
|
||||||
return Value;
|
return Value;
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_same<T, bool>::value)
|
else if constexpr (std::is_enum_v<T>)
|
||||||
{
|
{
|
||||||
return Value ? "true" : "false";
|
return std::format("{}", std::underlying_type_t<T>(Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return std::format("{}", Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << Value;
|
|
||||||
return oss.str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigDef& operator=(const ConfigDef& other)
|
ConfigDef& operator=(const ConfigDef& other)
|
||||||
|
|
@ -129,50 +133,50 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ELanguage
|
enum class Language : uint32_t
|
||||||
{
|
{
|
||||||
ELanguage_English = 1,
|
English = 1,
|
||||||
ELanguage_Japanese,
|
Japanese,
|
||||||
ELanguage_German,
|
German,
|
||||||
ELanguage_French,
|
French,
|
||||||
ELanguage_Spanish,
|
Spanish,
|
||||||
ELanguage_Italian
|
Italian
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EScoreBehaviour
|
enum class ScoreBehaviour : uint32_t
|
||||||
{
|
{
|
||||||
EScoreBehaviour_CheckpointReset,
|
CheckpointReset,
|
||||||
EScoreBehaviour_CheckpointRetain
|
CheckpointRetain
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EVoiceLanguage
|
enum class VoiceLanguage : uint32_t
|
||||||
{
|
{
|
||||||
EVoiceLanguage_English,
|
English,
|
||||||
EVoiceLanguage_Japanese
|
Japanese
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EGraphicsAPI
|
enum class GraphicsAPI : uint32_t
|
||||||
{
|
{
|
||||||
EGraphicsAPI_D3D12,
|
D3D12,
|
||||||
EGraphicsAPI_Vulkan
|
Vulkan
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EGITextureFiltering
|
enum class GITextureFiltering : uint32_t
|
||||||
{
|
{
|
||||||
EGITextureFiltering_Linear,
|
Linear,
|
||||||
EGITextureFiltering_Bicubic
|
Bicubic
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EMovieScaleMode
|
enum class MovieScaleMode : uint32_t
|
||||||
{
|
{
|
||||||
EMovieScaleMode_Stretch,
|
Stretch,
|
||||||
EMovieScaleMode_Fit,
|
Fit,
|
||||||
EMovieScaleMode_Fill
|
Fill
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EUIScaleMode
|
enum class UIScaleMode : uint32_t
|
||||||
{
|
{
|
||||||
EUIScaleMode_Stretch,
|
Stretch,
|
||||||
EUIScaleMode_Edge,
|
Edge,
|
||||||
EUIScaleMode_Centre
|
Centre
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ PPC_FUNC(sub_82624308)
|
||||||
{
|
{
|
||||||
__imp__sub_82624308(ctx, base);
|
__imp__sub_82624308(ctx, base);
|
||||||
|
|
||||||
if (Config::ScoreBehaviour != EScoreBehaviour_CheckpointRetain)
|
if (Config::ScoreBehaviour != ScoreBehaviour::CheckpointRetain)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
||||||
|
|
@ -91,7 +91,7 @@ PPC_FUNC(sub_8245F048)
|
||||||
{
|
{
|
||||||
__imp__sub_8245F048(ctx, base);
|
__imp__sub_8245F048(ctx, base);
|
||||||
|
|
||||||
if (Config::ScoreBehaviour != EScoreBehaviour_CheckpointRetain)
|
if (Config::ScoreBehaviour != ScoreBehaviour::CheckpointRetain)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
auto pGameDocument = SWA::CGameDocument::GetInstance();
|
||||||
|
|
@ -212,7 +212,7 @@ void SetXButtonHomingMidAsmHook(PPCRegister& r30)
|
||||||
PPC_FUNC_IMPL(__imp__sub_825197C0);
|
PPC_FUNC_IMPL(__imp__sub_825197C0);
|
||||||
PPC_FUNC(sub_825197C0)
|
PPC_FUNC(sub_825197C0)
|
||||||
{
|
{
|
||||||
if (Config::Language == ELanguage_Japanese)
|
if (Config::Language == Language::Japanese)
|
||||||
{
|
{
|
||||||
ctx.r3.u64 = 0;
|
ctx.r3.u64 = 0;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -561,7 +561,7 @@ static void CreateHostDevice()
|
||||||
|
|
||||||
Window::Init();
|
Window::Init();
|
||||||
|
|
||||||
g_vulkan = Config::GraphicsAPI == EGraphicsAPI_Vulkan;
|
g_vulkan = Config::GraphicsAPI == GraphicsAPI::Vulkan;
|
||||||
|
|
||||||
LoadShaderCache();
|
LoadShaderCache();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ void XGetVideoMode()
|
||||||
uint32_t XGetGameRegion()
|
uint32_t XGetGameRegion()
|
||||||
{
|
{
|
||||||
// printf("!!! STUB !!! XGetGameRegion\n");
|
// printf("!!! STUB !!! XGetGameRegion\n");
|
||||||
if (Config::Language == ELanguage_Japanese)
|
if (Config::Language == Language::Japanese)
|
||||||
return 0x0101;
|
return 0x0101;
|
||||||
|
|
||||||
return 0x03FF;
|
return 0x03FF;
|
||||||
|
|
@ -191,7 +191,7 @@ void XamShowMessageBoxUIEx()
|
||||||
uint32_t XGetLanguage()
|
uint32_t XGetLanguage()
|
||||||
{
|
{
|
||||||
// printf("!!! STUB !!! XGetLanguage\n");
|
// printf("!!! STUB !!! XGetLanguage\n");
|
||||||
return Config::Language;
|
return (uint32_t)Config::Language.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t XGetAVPack()
|
uint32_t XGetAVPack()
|
||||||
|
|
@ -336,7 +336,7 @@ uint32_t ExGetXConfigSetting(uint16_t Category, uint16_t Setting, void* Buffer,
|
||||||
|
|
||||||
// XCONFIG_USER_LANGUAGE
|
// XCONFIG_USER_LANGUAGE
|
||||||
case 0x0009:
|
case 0x0009:
|
||||||
data[0] = std::byteswap((uint32_t)Config::Language);
|
data[0] = std::byteswap((uint32_t)Config::Language.Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// XCONFIG_USER_VIDEO_FLAGS
|
// XCONFIG_USER_VIDEO_FLAGS
|
||||||
|
|
|
||||||
|
|
@ -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.
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <format>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ void Window::Init()
|
||||||
{
|
{
|
||||||
/* TODO: move this since it'll have to change
|
/* TODO: move this since it'll have to change
|
||||||
on soft reboot from the options menu. */
|
on soft reboot from the options menu. */
|
||||||
auto title = Config::Language == ELanguage_Japanese
|
auto title = Config::Language == Language::Japanese
|
||||||
? "Sonic World Adventure"
|
? "Sonic World Adventure"
|
||||||
: "SONIC UNLEASHED";
|
: "SONIC UNLEASHED";
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue