config: implemented name and enum localisation

This commit is contained in:
Hyper 2024-11-15 19:27:46 +00:00
parent 8a11917ce5
commit 5a110d3838
6 changed files with 566 additions and 229 deletions

View file

@ -18,7 +18,7 @@ void Config::Load()
{ {
def->ReadValue(toml); def->ReadValue(toml);
#if _DEBUG #if _DEBUG
printf("%s (0x%llx)\n", def->GetDefinition().c_str(), def->GetValue()); printf("%s (0x%p)\n", def->GetDefinition().c_str(), def->GetValue());
#endif #endif
} }
} }

View file

@ -1,57 +1,59 @@
#pragma once #pragma once
#include "config_detail.h" #include "config_detail.h"
#include "config_locale.h"
class Config class Config
{ {
public: public:
inline static std::vector<IConfigDef*> Definitions{}; inline static std::vector<IConfigDef*> Definitions{};
CONFIG_DEFINE_ENUM("System", ELanguage, Language, ELanguage::English); CONFIG_DEFINE_ENUM_LOCALISED("System", ELanguage, Language, ELanguage::English);
CONFIG_DEFINE("System", bool, Hints, true); CONFIG_DEFINE_LOCALISED("System", bool, Hints, true);
CONFIG_DEFINE("System", bool, ControlTutorial, true); CONFIG_DEFINE_LOCALISED("System", bool, ControlTutorial, true);
CONFIG_DEFINE_ENUM("System", EScoreBehaviour, ScoreBehaviour, EScoreBehaviour::CheckpointReset); CONFIG_DEFINE_LOCALISED("System", bool, SaveScoreAtCheckpoints, false);
CONFIG_DEFINE("System", bool, UnleashOutOfControlDrain, true); CONFIG_DEFINE_LOCALISED("System", bool, UnleashOutOfControlDrain, true);
CONFIG_DEFINE("System", bool, WerehogHubTransformVideo, true); CONFIG_DEFINE_LOCALISED("System", bool, WerehogHubTransformVideo, true);
CONFIG_DEFINE_HIDE("System", bool, LogoSkip, false); CONFIG_DEFINE_LOCALISED("System", bool, LogoSkip, false);
CONFIG_DEFINE("Controls", bool, CameraXInvert, false); CONFIG_DEFINE_LOCALISED("Controls", bool, CameraXInvert, false);
CONFIG_DEFINE("Controls", bool, CameraYInvert, false); CONFIG_DEFINE_LOCALISED("Controls", bool, CameraYInvert, false);
CONFIG_DEFINE("Controls", bool, XButtonHoming, true); CONFIG_DEFINE_LOCALISED("Controls", bool, XButtonHoming, true);
CONFIG_DEFINE("Controls", bool, UnleashCancel, false); CONFIG_DEFINE_LOCALISED("Controls", bool, UnleashCancel, false);
CONFIG_DEFINE("Audio", float, MusicVolume, 1.0f); CONFIG_DEFINE_LOCALISED("Audio", float, MusicVolume, 1.0f);
CONFIG_DEFINE("Audio", float, SEVolume, 1.0f); CONFIG_DEFINE_LOCALISED("Audio", float, SEVolume, 1.0f);
CONFIG_DEFINE_ENUM("Audio", EVoiceLanguage, VoiceLanguage, EVoiceLanguage::English); CONFIG_DEFINE_ENUM_LOCALISED("Audio", EVoiceLanguage, VoiceLanguage, EVoiceLanguage::English);
CONFIG_DEFINE("Audio", bool, Subtitles, true); CONFIG_DEFINE_LOCALISED("Audio", bool, Subtitles, true);
CONFIG_DEFINE("Audio", bool, WerehogBattleMusic, true); CONFIG_DEFINE_LOCALISED("Audio", bool, WerehogBattleMusic, true);
CONFIG_DEFINE_ENUM("Video", EGraphicsAPI, GraphicsAPI, EGraphicsAPI::D3D12); CONFIG_DEFINE_ENUM("Video", EGraphicsAPI, GraphicsAPI, EGraphicsAPI::D3D12);
CONFIG_DEFINE_HIDE("Video", int32_t, WindowX, WINDOWPOS_CENTRED); CONFIG_DEFINE("Video", int32_t, WindowX, WINDOWPOS_CENTRED);
CONFIG_DEFINE_HIDE("Video", int32_t, WindowY, WINDOWPOS_CENTRED); CONFIG_DEFINE("Video", int32_t, WindowY, WINDOWPOS_CENTRED);
CONFIG_DEFINE("Video", int32_t, WindowWidth, 1280); CONFIG_DEFINE_LOCALISED("Video", int32_t, WindowWidth, 1280);
CONFIG_DEFINE("Video", int32_t, WindowHeight, 720); CONFIG_DEFINE_LOCALISED("Video", int32_t, WindowHeight, 720);
CONFIG_DEFINE_ENUM_HIDE("Video", EWindowState, WindowState, EWindowState::Normal); CONFIG_DEFINE_ENUM("Video", EWindowState, WindowState, EWindowState::Normal);
CONFIG_DEFINE_CALLBACK("Video", float, ResolutionScale, 1.0f, CONFIG_DEFINE_CALLBACK("Video", float, ResolutionScale, 1.0f,
{ {
def->NameLocale = &g_ResolutionScale_locale;
def->Value = std::clamp(def->Value, 0.25f, 2.0f); def->Value = std::clamp(def->Value, 0.25f, 2.0f);
}); });
CONFIG_DEFINE("Video", bool, Fullscreen, false); CONFIG_DEFINE_LOCALISED("Video", bool, Fullscreen, false);
CONFIG_DEFINE("Video", bool, VSync, true); CONFIG_DEFINE_LOCALISED("Video", bool, VSync, true);
CONFIG_DEFINE("Video", bool, TripleBuffering, true); CONFIG_DEFINE_LOCALISED("Video", bool, TripleBuffering, true);
CONFIG_DEFINE("Video", int32_t, FPS, 60); CONFIG_DEFINE("Video", int32_t, FPS, 60);
CONFIG_DEFINE("Video", float, Brightness, 0.5f); CONFIG_DEFINE_LOCALISED("Video", float, Brightness, 0.5f);
CONFIG_DEFINE("Video", size_t, MSAA, 4); CONFIG_DEFINE_LOCALISED("Video", size_t, MSAA, 4);
CONFIG_DEFINE_HIDE("Video", size_t, AnisotropicFiltering, 16); CONFIG_DEFINE_LOCALISED("Video", size_t, AnisotropicFiltering, 16);
CONFIG_DEFINE_ENUM("Video", EShadowResolution, ShadowResolution, EShadowResolution::x4096); CONFIG_DEFINE_ENUM_LOCALISED("Video", EShadowResolution, ShadowResolution, EShadowResolution::x4096);
CONFIG_DEFINE_ENUM("Video", EGITextureFiltering, GITextureFiltering, EGITextureFiltering::Bicubic); CONFIG_DEFINE_ENUM_LOCALISED("Video", EGITextureFiltering, GITextureFiltering, EGITextureFiltering::Bicubic);
CONFIG_DEFINE("Video", bool, AlphaToCoverage, true); CONFIG_DEFINE_LOCALISED("Video", bool, AlphaToCoverage, true);
CONFIG_DEFINE("Video", bool, MotionBlur, true); CONFIG_DEFINE_LOCALISED("Video", bool, MotionBlur, true);
CONFIG_DEFINE("Video", bool, Xbox360ColourCorrection, false); CONFIG_DEFINE_LOCALISED("Video", bool, Xbox360ColourCorrection, false);
CONFIG_DEFINE_ENUM("Video", EMovieScaleMode, MovieScaleMode, EMovieScaleMode::Fit); CONFIG_DEFINE_ENUM_LOCALISED("Video", EMovieScaleMode, MovieScaleMode, EMovieScaleMode::Fit);
CONFIG_DEFINE_ENUM("Video", EUIScaleMode, UIScaleMode, EUIScaleMode::Centre); CONFIG_DEFINE_ENUM_LOCALISED("Video", EUIScaleMode, UIScaleMode, EUIScaleMode::Centre);
static std::filesystem::path GetUserPath() static std::filesystem::path GetUserPath()
{ {

View file

@ -7,195 +7,32 @@
#define CONFIG_DEFINE(section, type, name, defaultValue) \ #define CONFIG_DEFINE(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, defaultValue}; inline static ConfigDef<type> name{section, #name, defaultValue};
#define CONFIG_DEFINE_HIDE(section, type, name, defaultValue) \ #define CONFIG_DEFINE_LOCALISED(section, type, name, defaultValue) \
inline static ConfigDef<type, false> name{section, #name, defaultValue}; inline static ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue};
#define CONFIG_DEFINE_ENUM(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, defaultValue, &g_##type##_template};
#define CONFIG_DEFINE_ENUM_LOCALISED(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue, &g_##type##_template, &g_##type##_locale};
#define CONFIG_DEFINE_CALLBACK(section, type, name, defaultValue, readCallback) \
inline static ConfigDef<type> name{section, #name, defaultValue, [](ConfigDef<type>* def) readCallback};
#define CONFIG_DEFINE_LOCALE(name) \
inline static std::unordered_map<ELanguage, std::string> g_##name##_locale =
#define CONFIG_DEFINE_ENUM_LOCALE(type) \
inline static std::unordered_map<ELanguage, std::unordered_map<type, std::string>> g_##type##_locale =
#define CONFIG_DEFINE_ENUM_TEMPLATE(type) \ #define CONFIG_DEFINE_ENUM_TEMPLATE(type) \
inline static std::unordered_map<std::string, type> g_##type##_template = inline static std::unordered_map<std::string, type> g_##type##_template =
#define CONFIG_DEFINE_ENUM(section, type, name, defaultValue) \
inline static ConfigDef<type> name{section, #name, defaultValue, g_##type##_template};
#define CONFIG_DEFINE_ENUM_HIDE(section, type, name, defaultValue) \
inline static ConfigDef<type, false> name{section, #name, defaultValue, g_##type##_template};
#define CONFIG_DEFINE_IMPL(section, type, name, defaultValue, readImpl) \
inline static ConfigDef<type> name{section, #name, defaultValue, [](ConfigDef<type, true>* def, const toml::v3::table& table) readImpl};
#define CONFIG_DEFINE_CALLBACK(section, type, name, defaultValue, readCallback) \
inline static ConfigDef<type> name{section, #name, defaultValue, [](ConfigDef<type, true>* def) readCallback};
#define CONFIG_GET_DEFAULT(name) Config::name.DefaultValue #define CONFIG_GET_DEFAULT(name) Config::name.DefaultValue
#define CONFIG_SET_DEFAULT(name) Config::name.MakeDefault(); #define CONFIG_SET_DEFAULT(name) Config::name.MakeDefault();
#define WINDOWPOS_CENTRED 0x2FFF0000 #define WINDOWPOS_CENTRED 0x2FFF0000
class IConfigDef
{
public:
virtual ~IConfigDef() = default;
virtual void ReadValue(toml::v3::ex::parse_result& toml) = 0;
virtual void MakeDefault() = 0;
virtual bool IsMenuOption() const = 0;
virtual std::string_view GetSection() const = 0;
virtual std::string_view GetName() const = 0;
virtual void* GetValue() = 0;
virtual std::string GetDefinition(bool withSection = false) const = 0;
virtual std::string ToString() const = 0;
};
template<typename T, bool isMenuOption = true>
class ConfigDef : public IConfigDef
{
public:
std::string Section{};
std::string Name{};
T DefaultValue{};
T Value{ DefaultValue };
std::unordered_map<std::string, T> EnumTemplate{};
std::map<T, std::string> EnumTemplateReverse{};
std::function<void(ConfigDef<T, isMenuOption>*, const toml::v3::table&)> ReadImpl;
std::function<void(ConfigDef<T, isMenuOption>*)> ReadCallback;
ConfigDef(std::string section, std::string name, T defaultValue)
: Section(section), Name(name), DefaultValue(defaultValue)
{
Config::Definitions.emplace_back(this);
}
ConfigDef(std::string section, std::string name, T defaultValue, std::unordered_map<std::string, T> enumTemplate)
: Section(section), Name(name), DefaultValue(defaultValue), EnumTemplate(enumTemplate)
{
for (const auto& pair : EnumTemplate)
EnumTemplateReverse[pair.second] = pair.first;
Config::Definitions.emplace_back(this);
}
ConfigDef(std::string section, std::string name, T defaultValue, std::function<void(ConfigDef<T, isMenuOption>*)> readCallback)
: Section(section), Name(name), DefaultValue(defaultValue), ReadCallback(readCallback)
{
Config::Definitions.emplace_back(this);
}
ConfigDef(std::string section, std::string name, T defaultValue, std::function<void(ConfigDef<T, isMenuOption>*, const toml::v3::table&)> readImpl)
: Section(section), Name(name), DefaultValue(defaultValue), ReadImpl(readImpl)
{
Config::Definitions.emplace_back(this);
}
void ReadValue(toml::v3::ex::parse_result& toml) override
{
if (auto pSection = toml[Section].as_table())
{
const auto& section = *pSection;
if (ReadImpl)
{
ReadImpl(this, section);
}
else
{
if constexpr (std::is_same<T, std::string>::value)
{
Value = section[Name].value_or<std::string>(DefaultValue);
}
else if constexpr (std::is_enum_v<T>)
{
auto it = EnumTemplate.begin();
Value = EnumTemplate[section[Name].value_or<std::string>(static_cast<std::string>(it->first))];
}
else
{
Value = section[Name].value_or(DefaultValue);
}
if (ReadCallback)
ReadCallback(this);
}
}
}
void MakeDefault() override
{
Value = DefaultValue;
}
bool IsMenuOption() const override
{
return isMenuOption;
}
std::string_view GetSection() const override
{
return Section;
}
std::string_view GetName() const override
{
return Name;
}
void* GetValue() override
{
return &Value;
}
std::string GetDefinition(bool withSection = false) const override
{
std::string result;
if (withSection)
result += "[" + Section + "]\n";
result += Name + " = " + ToString();
return result;
}
std::string ToString() const override
{
std::string result = "\"N/A\"";
if constexpr (std::is_same_v<T, std::string>)
{
result = std::format("\"{}\"", Value);
}
else if constexpr (std::is_enum_v<T>)
{
auto it = EnumTemplateReverse.find(Value);
if (it != EnumTemplateReverse.end())
result = std::format("\"{}\"", it->second);
}
else
{
result = std::format("{}", Value);
}
return result;
}
ConfigDef& operator=(const ConfigDef& other)
{
if (this != &other)
Value = other.Value;
return *this;
}
operator T() const
{
return Value;
}
void operator=(const T& other)
{
Value = other;
}
};
enum class ELanguage : uint32_t enum class ELanguage : uint32_t
{ {
English = 1, English = 1,
@ -216,18 +53,6 @@ CONFIG_DEFINE_ENUM_TEMPLATE(ELanguage)
{ "Italian", ELanguage::Italian } { "Italian", ELanguage::Italian }
}; };
enum class EScoreBehaviour : uint32_t
{
CheckpointReset,
CheckpointRetain
};
CONFIG_DEFINE_ENUM_TEMPLATE(EScoreBehaviour)
{
{ "CheckpointReset", EScoreBehaviour::CheckpointReset },
{ "CheckpointRetain", EScoreBehaviour::CheckpointRetain }
};
enum class EVoiceLanguage : uint32_t enum class EVoiceLanguage : uint32_t
{ {
English, English,
@ -287,13 +112,13 @@ CONFIG_DEFINE_ENUM_TEMPLATE(EShadowResolution)
enum class EGITextureFiltering : uint32_t enum class EGITextureFiltering : uint32_t
{ {
Linear, Bilinear,
Bicubic Bicubic
}; };
CONFIG_DEFINE_ENUM_TEMPLATE(EGITextureFiltering) CONFIG_DEFINE_ENUM_TEMPLATE(EGITextureFiltering)
{ {
{ "Linear", EGITextureFiltering::Linear }, { "Bilinear", EGITextureFiltering::Bilinear },
{ "Bicubic", EGITextureFiltering::Bicubic } { "Bicubic", EGITextureFiltering::Bicubic }
}; };
@ -325,3 +150,251 @@ CONFIG_DEFINE_ENUM_TEMPLATE(EUIScaleMode)
{ "Centre", EUIScaleMode::Centre }, { "Centre", EUIScaleMode::Centre },
{ "Center", EUIScaleMode::Centre } { "Center", EUIScaleMode::Centre }
}; };
class IConfigDef
{
public:
virtual ~IConfigDef() = default;
virtual void ReadValue(toml::v3::ex::parse_result& toml) = 0;
virtual void MakeDefault() = 0;
virtual std::string_view GetSection() const = 0;
virtual std::string_view GetName() const = 0;
virtual std::string GetNameLocalised() const = 0;
virtual void* GetValue() = 0;
virtual std::string GetValueLocalised() const = 0;
virtual std::string GetDefinition(bool withSection = false) const = 0;
virtual std::string ToString(bool strWithQuotes = true) const = 0;
};
template<typename T>
class ConfigDef : public IConfigDef
{
public:
std::string Section{};
std::string Name{};
std::unordered_map<ELanguage, std::string>* NameLocale;
T DefaultValue{};
T Value{ DefaultValue };
std::unordered_map<std::string, T>* EnumTemplate;
std::map<T, std::string> EnumTemplateReverse{};
std::unordered_map<ELanguage, std::unordered_map<T, std::string>>* EnumLocale;
std::function<void(ConfigDef<T>*)> ReadCallback;
ConfigDef(std::string section, std::string name, T defaultValue)
: Section(section), Name(name), DefaultValue(defaultValue)
{
Config::Definitions.emplace_back(this);
}
ConfigDef(std::string section, std::string name, std::unordered_map<ELanguage, std::string>* nameLocale, T defaultValue)
: Section(section), Name(name), NameLocale(nameLocale), DefaultValue(defaultValue)
{
Config::Definitions.emplace_back(this);
}
ConfigDef
(
std::string section,
std::string name,
T defaultValue,
std::unordered_map<std::string, T>* enumTemplate
)
: Section(section), Name(name), DefaultValue(defaultValue), EnumTemplate(enumTemplate)
{
for (const auto& pair : *EnumTemplate)
EnumTemplateReverse[pair.second] = pair.first;
Config::Definitions.emplace_back(this);
}
ConfigDef
(
std::string section,
std::string name,
std::unordered_map<ELanguage, std::string>* nameLocale,
T defaultValue,
std::unordered_map<std::string, T>* enumTemplate,
std::unordered_map<ELanguage, std::unordered_map<T, std::string>>* enumLocale
)
: Section(section), Name(name), NameLocale(nameLocale), DefaultValue(defaultValue), EnumTemplate(enumTemplate), EnumLocale(enumLocale)
{
for (const auto& pair : *EnumTemplate)
EnumTemplateReverse[pair.second] = pair.first;
Config::Definitions.emplace_back(this);
}
ConfigDef(std::string section, std::string name, T defaultValue, std::function<void(ConfigDef<T>*)> readCallback)
: Section(section), Name(name), DefaultValue(defaultValue), ReadCallback(readCallback)
{
Config::Definitions.emplace_back(this);
}
ConfigDef(std::string section, std::string name, std::unordered_map<ELanguage, std::string> nameLocale, T defaultValue, std::function<void(ConfigDef<T>*)> readCallback)
: Section(section), Name(name), NameLocale(nameLocale), DefaultValue(defaultValue), ReadCallback(readCallback)
{
Config::Definitions.emplace_back(this);
}
void ReadValue(toml::v3::ex::parse_result& toml) override
{
if (auto pSection = toml[Section].as_table())
{
const auto& section = *pSection;
if constexpr (std::is_same<T, std::string>::value)
{
Value = section[Name].value_or<std::string>(DefaultValue);
}
else if constexpr (std::is_enum_v<T>)
{
auto it = EnumTemplate->begin();
Value = EnumTemplate->at(section[Name].value_or<std::string>(static_cast<std::string>(it->first)));
}
else
{
Value = section[Name].value_or(DefaultValue);
}
if (ReadCallback)
ReadCallback(this);
}
}
void MakeDefault() override
{
Value = DefaultValue;
}
std::string_view GetSection() const override
{
return Section;
}
std::string_view GetName() const override
{
return Name;
}
std::string GetNameLocalised() const override
{
if (!NameLocale)
return Name;
if (!NameLocale->count(Config::Language))
{
if (NameLocale->count(ELanguage::English))
{
return NameLocale->at(ELanguage::English);
}
else
{
return Name;
}
}
return NameLocale->at(Config::Language);
}
void* GetValue() override
{
return &Value;
}
std::string GetValueLocalised() const override
{
auto language = Config::Language;
std::unordered_map<ELanguage, std::unordered_map<T, std::string>>* locale = nullptr;
if constexpr (std::is_enum_v<T>)
{
locale = EnumLocale;
}
else if constexpr (std::is_same_v<T, bool>)
{
locale = &g_bool_locale;
}
if (!locale)
return ToString(false);
if (!locale->count(language))
{
if (locale->count(ELanguage::English))
{
language = ELanguage::English;
}
else
{
return ToString(false);
}
}
auto strings = locale->at(language);
if (!strings.count(Value))
return ToString(false);
return strings.at(Value);
}
std::string GetDefinition(bool withSection = false) const override
{
std::string result;
if (withSection)
result += "[" + Section + "]\n";
result += Name + " = " + ToString();
return result;
}
std::string ToString(bool strWithQuotes = true) const override
{
std::string result = "N/A";
if constexpr (std::is_same_v<T, std::string>)
{
result = std::format("{}", Value);
if (strWithQuotes)
result = std::format("\"{}\"", result);
}
else if constexpr (std::is_enum_v<T>)
{
auto it = EnumTemplateReverse.find(Value);
if (it != EnumTemplateReverse.end())
result = std::format("{}", it->second);
if (strWithQuotes)
result = std::format("\"{}\"", result);
}
else
{
result = std::format("{}", Value);
}
return result;
}
ConfigDef& operator=(const ConfigDef& other)
{
if (this != &other)
Value = other.Value;
return *this;
}
operator T() const
{
return Value;
}
void operator=(const T& other)
{
Value = other;
}
};

View file

@ -0,0 +1,261 @@
#pragma once
#include "config_detail.h"
CONFIG_DEFINE_ENUM_LOCALE(bool)
{
{
ELanguage::English, { { true, "ON" }, { false, "OFF" } }
},
{
ELanguage::Japanese, { { true, "オン" }, { false, "オフ" } }
},
{
ELanguage::German, { { true, "EIN" }, { false, "AUS" } }
},
{
ELanguage::French, { { true, "OUI" }, { false, "NON" } }
},
{
ELanguage::Spanish, { { true, "" }, { false, "NO" } }
},
{
ELanguage::Italian, { { true, "" }, { false, "NO" } }
}
};
CONFIG_DEFINE_LOCALE(Language)
{
{ ELanguage::English, "Language" },
{ ELanguage::Japanese, "言語" },
{ ELanguage::German, "Sprache" },
{ ELanguage::French, "Langue" },
{ ELanguage::Spanish, "Idioma" },
{ ELanguage::Italian, "Lingua" }
};
CONFIG_DEFINE_ENUM_LOCALE(ELanguage)
{
{
ELanguage::English,
{
{ ELanguage::English, "ENGLISH" },
{ ELanguage::Japanese, "日本語" },
{ ELanguage::German, "DEUTSCH" },
{ ELanguage::French, "FRANÇAIS" },
{ ELanguage::Spanish, "ESPAÑOL" },
{ ELanguage::Italian, "ITALIANO" },
}
}
};
CONFIG_DEFINE_LOCALE(Hints)
{
{ ELanguage::English, "Hints" }
};
CONFIG_DEFINE_LOCALE(ControlTutorial)
{
{ ELanguage::English, "Control Tutorial" }
};
CONFIG_DEFINE_LOCALE(SaveScoreAtCheckpoints)
{
{ ELanguage::English, "Save Score at Checkpoints" }
};
CONFIG_DEFINE_LOCALE(UnleashOutOfControlDrain)
{
{ ELanguage::English, "Decrease Unleash Gauge whilst Out Of Control" }
};
CONFIG_DEFINE_LOCALE(WerehogHubTransformVideo)
{
{ ELanguage::English, "Werehog Transformation Video" }
};
CONFIG_DEFINE_LOCALE(LogoSkip)
{
{ ELanguage::English, "Skip Intro Logos" }
};
CONFIG_DEFINE_LOCALE(CameraXInvert)
{
{ ELanguage::English, "Invert Camera X" }
};
CONFIG_DEFINE_LOCALE(CameraYInvert)
{
{ ELanguage::English, "Invert Camera Y" }
};
CONFIG_DEFINE_LOCALE(XButtonHoming)
{
{ ELanguage::English, "Homing Attack on Boost" }
};
CONFIG_DEFINE_LOCALE(UnleashCancel)
{
{ ELanguage::English, "Allow Cancelling Unleash" }
};
CONFIG_DEFINE_LOCALE(MusicVolume)
{
{ ELanguage::English, "Music Volume" }
};
CONFIG_DEFINE_LOCALE(SEVolume)
{
{ ELanguage::English, "SE Volume" }
};
CONFIG_DEFINE_LOCALE(VoiceLanguage)
{
{ ELanguage::English, "Voice Language" }
};
CONFIG_DEFINE_ENUM_LOCALE(EVoiceLanguage)
{
{
ELanguage::English,
{
{ EVoiceLanguage::English, "ENGLISH" },
{ EVoiceLanguage::Japanese, "日本語" }
}
}
};
CONFIG_DEFINE_LOCALE(Subtitles)
{
{ ELanguage::English, "Subtitles" }
};
CONFIG_DEFINE_LOCALE(WerehogBattleMusic)
{
{ ELanguage::English, "Werehog Battle Theme" }
};
CONFIG_DEFINE_LOCALE(WindowWidth)
{
{ ELanguage::English, "Window Width" }
};
CONFIG_DEFINE_LOCALE(WindowHeight)
{
{ ELanguage::English, "Window Height" }
};
CONFIG_DEFINE_LOCALE(ResolutionScale)
{
{ ELanguage::English, "Resolution Scale" }
};
CONFIG_DEFINE_LOCALE(Fullscreen)
{
{ ELanguage::English, "Fullscreen" }
};
CONFIG_DEFINE_LOCALE(VSync)
{
{ ELanguage::English, "V-Sync" }
};
CONFIG_DEFINE_LOCALE(TripleBuffering)
{
{ ELanguage::English, "Triple Buffering" }
};
CONFIG_DEFINE_LOCALE(Brightness)
{
{ ELanguage::English, "Brightness" }
};
CONFIG_DEFINE_LOCALE(MSAA)
{
{ ELanguage::English, "Anti-Aliasing" }
};
CONFIG_DEFINE_LOCALE(AnisotropicFiltering)
{
{ ELanguage::English, "Anisotropic Filtering" }
};
CONFIG_DEFINE_LOCALE(ShadowResolution)
{
{ ELanguage::English, "Shadow Resolution" }
};
CONFIG_DEFINE_ENUM_LOCALE(EShadowResolution)
{
{
ELanguage::English,
{
{ EShadowResolution::Original, "ORIGINAL" },
}
}
};
CONFIG_DEFINE_LOCALE(GITextureFiltering)
{
{ ELanguage::English, "GI Texture Filtering" }
};
CONFIG_DEFINE_ENUM_LOCALE(EGITextureFiltering)
{
{
ELanguage::English,
{
{ EGITextureFiltering::Bilinear, "BILINEAR" },
{ EGITextureFiltering::Bicubic, "BICUBIC" },
}
}
};
CONFIG_DEFINE_LOCALE(AlphaToCoverage)
{
{ ELanguage::English, "Transparency Anti-Aliasing" }
};
CONFIG_DEFINE_LOCALE(MotionBlur)
{
{ ELanguage::English, "Motion Blur" }
};
CONFIG_DEFINE_LOCALE(Xbox360ColourCorrection)
{
{ ELanguage::English, "Xbox 360 Colour Correction" }
};
CONFIG_DEFINE_LOCALE(MovieScaleMode)
{
{ ELanguage::English, "Movie Scale Mode" }
};
CONFIG_DEFINE_ENUM_LOCALE(EMovieScaleMode)
{
{
ELanguage::English,
{
{ EMovieScaleMode::Stretch, "STRETCH" },
{ EMovieScaleMode::Fit, "FIT" },
{ EMovieScaleMode::Fill, "FILL" },
}
}
};
CONFIG_DEFINE_LOCALE(UIScaleMode)
{
{ ELanguage::English, "UI Scale Mode" }
};
CONFIG_DEFINE_ENUM_LOCALE(EUIScaleMode)
{
{
ELanguage::English,
{
{ EUIScaleMode::Stretch, "STRETCH" },
{ EUIScaleMode::Edge, "EDGE" },
{ EUIScaleMode::Centre, "CENTRE" },
}
}
};

View file

@ -15,7 +15,7 @@ PPC_FUNC(sub_82624308)
{ {
__imp__sub_82624308(ctx, base); __imp__sub_82624308(ctx, base);
if (Config::ScoreBehaviour != EScoreBehaviour::CheckpointRetain) if (!Config::SaveScoreAtCheckpoints)
return; return;
auto pGameDocument = SWA::CGameDocument::GetInstance(); auto pGameDocument = SWA::CGameDocument::GetInstance();
@ -33,7 +33,7 @@ PPC_FUNC(sub_8245F048)
{ {
__imp__sub_8245F048(ctx, base); __imp__sub_8245F048(ctx, base);
if (Config::ScoreBehaviour != EScoreBehaviour::CheckpointRetain) if (!Config::SaveScoreAtCheckpoints)
return; return;
auto pGameDocument = SWA::CGameDocument::GetInstance(); auto pGameDocument = SWA::CGameDocument::GetInstance();

View file

@ -292,8 +292,8 @@ static void DrawCategories()
drawList->PushClipRect({ clipRectMin.x, clipRectMin.y + gridSize * 6.0f }, clipRectMax); drawList->PushClipRect({ clipRectMin.x, clipRectMin.y + gridSize * 6.0f }, clipRectMax);
} }
template<typename T, bool isMenuOption = true> template<typename T>
static void DrawConfigOption(int32_t rowIndex, const ConfigDef<T, isMenuOption>& config) static void DrawConfigOption(int32_t rowIndex, const ConfigDef<T>& config)
{ {
auto drawList = ImGui::GetForegroundDrawList(); auto drawList = ImGui::GetForegroundDrawList();
auto clipRectMin = drawList->GetClipRectMin(); auto clipRectMin = drawList->GetClipRectMin();
@ -316,10 +316,12 @@ static void DrawConfigOption(int32_t rowIndex, const ConfigDef<T, isMenuOption>&
if (ImGui::IsMouseHoveringRect(min, max, false)) if (ImGui::IsMouseHoveringRect(min, max, false))
drawList->AddRectFilledMultiColor(min, max, COLOR0, COLOR0, COLOR1, COLOR1); drawList->AddRectFilledMultiColor(min, max, COLOR0, COLOR0, COLOR1, COLOR1);
float size = Scale(26.0f); auto configName = config.GetNameLocalised();
auto textSize = g_seuratFont->CalcTextSizeA(size, FLT_MAX, 0.0f, config.Name.c_str());
drawList->AddText(g_seuratFont, size, { min.x + gridSize, min.y + (optionHeight - textSize.y) / 2.0f }, IM_COL32_WHITE, config.GetName().data()); float size = Scale(26.0f);
auto textSize = g_seuratFont->CalcTextSizeA(size, FLT_MAX, 0.0f, configName.c_str());
drawList->AddText(g_seuratFont, size, { min.x + gridSize, min.y + (optionHeight - textSize.y) / 2.0f }, IM_COL32_WHITE, configName.c_str());
// Right side // Right side
min = { max.x + (clipRectMax.x - max.x - valueWidth) / 2.0f, min.y + (optionHeight - valueHeight) / 2.0f }; min = { max.x + (clipRectMax.x - max.x - valueWidth) / 2.0f, min.y + (optionHeight - valueHeight) / 2.0f };
@ -333,8 +335,7 @@ static void DrawConfigOption(int32_t rowIndex, const ConfigDef<T, isMenuOption>&
SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE); SetShaderModifier(IMGUI_SHADER_MODIFIER_NONE);
auto valueText = config.ToString(); auto valueText = config.GetValueLocalised();
std::transform(valueText.begin(), valueText.end(), valueText.begin(), toupper);
size = Scale(20.0f); size = Scale(20.0f);
textSize = g_newRodinFont->CalcTextSizeA(size, FLT_MAX, 0.0f, valueText.data()); textSize = g_newRodinFont->CalcTextSizeA(size, FLT_MAX, 0.0f, valueText.data());
@ -372,7 +373,7 @@ static void DrawConfigOptions()
DrawConfigOption(rowIndex++, Config::Language); DrawConfigOption(rowIndex++, Config::Language);
DrawConfigOption(rowIndex++, Config::Hints); DrawConfigOption(rowIndex++, Config::Hints);
DrawConfigOption(rowIndex++, Config::ControlTutorial); DrawConfigOption(rowIndex++, Config::ControlTutorial);
DrawConfigOption(rowIndex++, Config::ScoreBehaviour); DrawConfigOption(rowIndex++, Config::SaveScoreAtCheckpoints);
DrawConfigOption(rowIndex++, Config::UnleashOutOfControlDrain); DrawConfigOption(rowIndex++, Config::UnleashOutOfControlDrain);
DrawConfigOption(rowIndex++, Config::WerehogHubTransformVideo); DrawConfigOption(rowIndex++, Config::WerehogHubTransformVideo);
DrawConfigOption(rowIndex++, Config::LogoSkip); DrawConfigOption(rowIndex++, Config::LogoSkip);