mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 04:41:39 +00:00
config_detail: move implementation to cpp, relocate sources
This commit is contained in:
parent
5a110d3838
commit
3257244224
16 changed files with 149 additions and 133 deletions
|
|
@ -28,6 +28,11 @@ set(SWA_PRECOMPILED_HEADERS
|
|||
"stdafx.h"
|
||||
)
|
||||
|
||||
set(SWA_CFG_CXX_SOURCES
|
||||
"cfg/config.cpp"
|
||||
"cfg/config_detail.cpp"
|
||||
)
|
||||
|
||||
set(SWA_KERNEL_CXX_SOURCES
|
||||
"kernel/imports.cpp"
|
||||
"kernel/xdm.cpp"
|
||||
|
|
@ -75,11 +80,11 @@ set(SWA_UI_CXX_SOURCES
|
|||
)
|
||||
|
||||
set(SWA_CXX_SOURCES
|
||||
"config.cpp"
|
||||
"main.cpp"
|
||||
"misc_impl.cpp"
|
||||
"stdafx.cpp"
|
||||
|
||||
|
||||
${SWA_CFG_CXX_SOURCES}
|
||||
${SWA_KERNEL_CXX_SOURCES}
|
||||
${SWA_CPU_CXX_SOURCES}
|
||||
${SWA_GPU_CXX_SOURCES}
|
||||
|
|
|
|||
106
UnleashedRecomp/cfg/config_detail.cpp
Normal file
106
UnleashedRecomp/cfg/config_detail.cpp
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
#include "config.h"
|
||||
#include "config_detail.h"
|
||||
|
||||
// CONFIG_DEFINE
|
||||
template<typename T>
|
||||
ConfigDef<T>::ConfigDef(std::string section, std::string name, T defaultValue) : Section(section), Name(name), DefaultValue(defaultValue)
|
||||
{
|
||||
Config::Definitions.emplace_back(this);
|
||||
}
|
||||
|
||||
// CONFIG_DEFINE_LOCALISED
|
||||
template<typename T>
|
||||
ConfigDef<T>::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);
|
||||
}
|
||||
|
||||
// CONFIG_DEFINE_ENUM
|
||||
template<typename T>
|
||||
ConfigDef<T>::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);
|
||||
}
|
||||
|
||||
// CONFIG_DEFINE_ENUM_LOCALISED
|
||||
template<typename T>
|
||||
ConfigDef<T>::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);
|
||||
}
|
||||
|
||||
// CONFIG_DEFINE_CALLBACK
|
||||
template<typename T>
|
||||
ConfigDef<T>::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);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string ConfigDef<T>::GetNameLocalised() const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::string ConfigDef<T>::GetValueLocalised() const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
|
@ -180,61 +180,20 @@ public:
|
|||
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);
|
||||
}
|
||||
// CONFIG_DEFINE
|
||||
ConfigDef(std::string section, std::string name, T defaultValue);
|
||||
|
||||
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);
|
||||
}
|
||||
// CONFIG_DEFINE_LOCALISED
|
||||
ConfigDef(std::string section, std::string name, std::unordered_map<ELanguage, std::string>* nameLocale, T defaultValue);
|
||||
|
||||
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_DEFINE_ENUM
|
||||
ConfigDef(std::string section, std::string name, T defaultValue, std::unordered_map<std::string, T>* enumTemplate);
|
||||
|
||||
Config::Definitions.emplace_back(this);
|
||||
}
|
||||
// CONFIG_DEFINE_ENUM_LOCALISED
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
// CONFIG_DEFINE_CALLBACK
|
||||
ConfigDef(std::string section, std::string name, T defaultValue, std::function<void(ConfigDef<T>*)> readCallback);
|
||||
|
||||
void ReadValue(toml::v3::ex::parse_result& toml) override
|
||||
{
|
||||
|
|
@ -277,67 +236,14 @@ public:
|
|||
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);
|
||||
}
|
||||
std::string GetNameLocalised() const override;
|
||||
|
||||
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 GetValueLocalised() const override;
|
||||
|
||||
std::string GetDefinition(bool withSection = false) const override
|
||||
{
|
||||
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
#include "imgui_snapshot.h"
|
||||
#include "imgui_common.h"
|
||||
#include "gpu/video.h"
|
||||
#include "ui/window.h"
|
||||
#include "config.h"
|
||||
#include "video.h"
|
||||
#include <ui/window.h>
|
||||
#include <cfg/config.h>
|
||||
|
||||
#include "shader/copy_vs.hlsl.dxil.h"
|
||||
#include "shader/copy_vs.hlsl.spirv.h"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include <cpu/ppc_context.h>
|
||||
#include <cpu/guest_thread.h>
|
||||
#include <apu/audio.h>
|
||||
#include <apu/audio.h>
|
||||
#include "function.h"
|
||||
#include "xex.h"
|
||||
#include "xbox.h"
|
||||
|
|
@ -12,7 +11,7 @@
|
|||
#include "xam.h"
|
||||
#include "xdm.h"
|
||||
#include <timeapi.h>
|
||||
#include "config.h"
|
||||
#include <cfg/config.h>
|
||||
|
||||
#include <ntstatus.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
#include <xex.h>
|
||||
#include <apu/audio.h>
|
||||
#include <hid/hid.h>
|
||||
#include "config.h"
|
||||
#include <cfg/config.h>
|
||||
|
||||
#define GAME_XEX_PATH "game:\\default.xex"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <cpu/guest_code.h>
|
||||
#include "api/SWA.h"
|
||||
#include "ui/window.h"
|
||||
#include "config.h"
|
||||
#include <api/SWA.h>
|
||||
#include <ui/window.h>
|
||||
#include <cfg/config.h>
|
||||
|
||||
void HighFrameRateDeltaTimeFixMidAsmHook(PPCRegister& f1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <cpu/guest_code.h>
|
||||
#include "api/SWA.h"
|
||||
#include "ui/window.h"
|
||||
#include "config.h"
|
||||
#include <api/SWA.h>
|
||||
#include <ui/window.h>
|
||||
#include <cfg/config.h>
|
||||
|
||||
bool DisableHintsMidAsmHook()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#include <cpu/guest_code.h>
|
||||
#include "api/SWA.h"
|
||||
#include "ui/window.h"
|
||||
#include "ui/window_events.h"
|
||||
#include "config.h"
|
||||
#include <api/SWA.h>
|
||||
#include <ui/window.h>
|
||||
#include <ui/window_events.h>
|
||||
#include <cfg/config.h>
|
||||
|
||||
uint32_t m_lastCheckpointScore = 0;
|
||||
float m_lastDarkGaiaEnergy = 0.0f;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <cpu/guest_code.h>
|
||||
#include "config.h"
|
||||
#include <cfg/config.h>
|
||||
|
||||
const char* m_pStageID;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <cpu/guest_code.h>
|
||||
#include "api/SWA.h"
|
||||
#include "ui/window.h"
|
||||
#include "config.h"
|
||||
#include <api/SWA.h>
|
||||
#include <ui/window.h>
|
||||
#include <cfg/config.h>
|
||||
|
||||
constexpr float m_baseAspectRatio = 16.0f / 9.0f;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "window.h"
|
||||
#include "sdl_listener.h"
|
||||
#include <config.h>
|
||||
#include <cfg/config.h>
|
||||
#include <kernel/function.h>
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include "res/icon.h"
|
||||
#include "res/icon_night.h"
|
||||
#include "ui/window_events.h"
|
||||
#include "config.h"
|
||||
#include <res/icon.h>
|
||||
#include <res/icon_night.h>
|
||||
#include <ui/window_events.h>
|
||||
#include <cfg/config.h>
|
||||
|
||||
#define DEFAULT_WIDTH 1280
|
||||
#define DEFAULT_HEIGHT 720
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue