mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-18 22:12:18 +00:00
Implemented hidden config values, removed DLL exports (#112)
This commit is contained in:
parent
d297c07edb
commit
95bd71a23e
11 changed files with 89 additions and 68 deletions
|
|
@ -1,13 +1,12 @@
|
||||||
|
#include <api/SWA.h>
|
||||||
#include <apu/embedded_player.h>
|
#include <apu/embedded_player.h>
|
||||||
|
#include <cpu/guest_stack_var.h>
|
||||||
#include <kernel/function.h>
|
#include <kernel/function.h>
|
||||||
#include <kernel/heap.h>
|
#include <kernel/heap.h>
|
||||||
#include <kernel/memory.h>
|
#include <kernel/memory.h>
|
||||||
#include <cpu/guest_stack_var.h>
|
|
||||||
#include <ui/installer_wizard.h>
|
|
||||||
#include <ui/game_window.h>
|
#include <ui/game_window.h>
|
||||||
#include <api/boost/smart_ptr/shared_ptr.h>
|
|
||||||
|
|
||||||
SWA_API void Game_PlaySound(const char* pName)
|
void Game_PlaySound(const char* pName)
|
||||||
{
|
{
|
||||||
if (EmbeddedPlayer::s_isActive)
|
if (EmbeddedPlayer::s_isActive)
|
||||||
{
|
{
|
||||||
|
|
@ -29,12 +28,12 @@ SWA_API void Game_PlaySound(const char* pName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API void Window_SetDisplay(int displayIndex)
|
void Window_SetDisplay(int displayIndex)
|
||||||
{
|
{
|
||||||
GameWindow::SetDisplay(displayIndex);
|
GameWindow::SetDisplay(displayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API void Window_SetFullscreen(bool isEnabled)
|
void Window_SetFullscreen(bool isEnabled)
|
||||||
{
|
{
|
||||||
GameWindow::SetFullscreen(isEnabled);
|
GameWindow::SetFullscreen(isEnabled);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
SWA_API void Game_PlaySound(const char* pName);
|
void Game_PlaySound(const char* pName);
|
||||||
SWA_API void Window_SetDisplay(int displayIndex);
|
void Window_SetDisplay(int displayIndex);
|
||||||
SWA_API void Window_SetFullscreen(bool isEnabled);
|
void Window_SetFullscreen(bool isEnabled);
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef _MSVC
|
|
||||||
#define SWA_DLLEXPORT __declspec(dllexport)
|
|
||||||
#define SWA_DLLIMPORT __declspec(dllimport)
|
|
||||||
#else
|
|
||||||
// TODO
|
|
||||||
#define SWA_DLLEXPORT
|
|
||||||
#define SWA_DLLIMPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SWA_IMPL
|
|
||||||
#define SWA_API extern "C" SWA_DLLEXPORT
|
|
||||||
#else
|
|
||||||
#define SWA_API extern "C" SWA_DLLIMPORT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PROC_ADDRESS(libraryName, procName) \
|
#define PROC_ADDRESS(libraryName, procName) \
|
||||||
GetProcAddress(LoadLibrary(TEXT(libraryName)), procName)
|
GetProcAddress(LoadLibrary(TEXT(libraryName)), procName)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ uint32_t RtlSizeHeap(uint32_t heapHandle, uint32_t flags, uint32_t memoryPointer
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XAllocMem(uint32_t size, uint32_t flags)
|
uint32_t XAllocMem(uint32_t size, uint32_t flags)
|
||||||
{
|
{
|
||||||
void* ptr = (flags & 0x80000000) != 0 ?
|
void* ptr = (flags & 0x80000000) != 0 ?
|
||||||
g_userHeap.AllocPhysical(size, (1ull << ((flags >> 24) & 0xF))) :
|
g_userHeap.AllocPhysical(size, (1ull << ((flags >> 24) & 0xF))) :
|
||||||
|
|
@ -113,7 +113,7 @@ SWA_API uint32_t XAllocMem(uint32_t size, uint32_t flags)
|
||||||
return g_memory.MapVirtual(ptr);
|
return g_memory.MapVirtual(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API void XFreeMem(uint32_t baseAddress, uint32_t flags)
|
void XFreeMem(uint32_t baseAddress, uint32_t flags)
|
||||||
{
|
{
|
||||||
if (baseAddress != NULL)
|
if (baseAddress != NULL)
|
||||||
g_userHeap.Free(g_memory.Translate(baseAddress));
|
g_userHeap.Free(g_memory.Translate(baseAddress));
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ struct FindHandle : KernelObject
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SWA_API FileHandle* XCreateFileA
|
FileHandle* XCreateFileA
|
||||||
(
|
(
|
||||||
const char* lpFileName,
|
const char* lpFileName,
|
||||||
uint32_t dwDesiredAccess,
|
uint32_t dwDesiredAccess,
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ void XamRegisterContent(uint32_t type, const std::string_view name, const std::s
|
||||||
XamRegisterContent(data, root);
|
XamRegisterContent(data, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamNotifyCreateListener(uint64_t qwAreas)
|
uint32_t XamNotifyCreateListener(uint64_t qwAreas)
|
||||||
{
|
{
|
||||||
auto* listener = CreateKernelObject<XamListener>();
|
auto* listener = CreateKernelObject<XamListener>();
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ SWA_API uint32_t XamNotifyCreateListener(uint64_t qwAreas)
|
||||||
return GetKernelHandle(listener);
|
return GetKernelHandle(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API void XamNotifyEnqueueEvent(uint32_t dwId, uint32_t dwParam)
|
void XamNotifyEnqueueEvent(uint32_t dwId, uint32_t dwParam)
|
||||||
{
|
{
|
||||||
for (const auto& listener : gListeners)
|
for (const auto& listener : gListeners)
|
||||||
{
|
{
|
||||||
|
|
@ -164,7 +164,7 @@ SWA_API void XamNotifyEnqueueEvent(uint32_t dwId, uint32_t dwParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API bool XNotifyGetNext(uint32_t hNotification, uint32_t dwMsgFilter, be<uint32_t>* pdwId, be<uint32_t>* pParam)
|
bool XNotifyGetNext(uint32_t hNotification, uint32_t dwMsgFilter, be<uint32_t>* pdwId, be<uint32_t>* pParam)
|
||||||
{
|
{
|
||||||
auto& listener = *GetKernelObject<XamListener>(hNotification);
|
auto& listener = *GetKernelObject<XamListener>(hNotification);
|
||||||
|
|
||||||
|
|
@ -205,7 +205,7 @@ SWA_API bool XNotifyGetNext(uint32_t hNotification, uint32_t dwMsgFilter, be<uin
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamShowMessageBoxUI(uint32_t dwUserIndex, be<uint16_t>* wszTitle, be<uint16_t>* wszText, uint32_t cButtons,
|
uint32_t XamShowMessageBoxUI(uint32_t dwUserIndex, be<uint16_t>* wszTitle, be<uint16_t>* wszText, uint32_t cButtons,
|
||||||
xpointer<be<uint16_t>>* pwszButtons, uint32_t dwFocusButton, uint32_t dwFlags, be<uint32_t>* pResult, XXOVERLAPPED* pOverlapped)
|
xpointer<be<uint16_t>>* pwszButtons, uint32_t dwFocusButton, uint32_t dwFlags, be<uint32_t>* pResult, XXOVERLAPPED* pOverlapped)
|
||||||
{
|
{
|
||||||
int button{};
|
int button{};
|
||||||
|
|
@ -255,7 +255,7 @@ SWA_API uint32_t XamShowMessageBoxUI(uint32_t dwUserIndex, be<uint16_t>* wszTitl
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamContentCreateEnumerator(uint32_t dwUserIndex, uint32_t DeviceID, uint32_t dwContentType,
|
uint32_t XamContentCreateEnumerator(uint32_t dwUserIndex, uint32_t DeviceID, uint32_t dwContentType,
|
||||||
uint32_t dwContentFlags, uint32_t cItem, be<uint32_t>* pcbBuffer, be<uint32_t>* phEnum)
|
uint32_t dwContentFlags, uint32_t cItem, be<uint32_t>* pcbBuffer, be<uint32_t>* phEnum)
|
||||||
{
|
{
|
||||||
if (dwUserIndex != 0)
|
if (dwUserIndex != 0)
|
||||||
|
|
@ -276,7 +276,7 @@ SWA_API uint32_t XamContentCreateEnumerator(uint32_t dwUserIndex, uint32_t Devic
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamEnumerate(uint32_t hEnum, uint32_t dwFlags, void* pvBuffer, uint32_t cbBuffer, be<uint32_t>* pcItemsReturned, XXOVERLAPPED* pOverlapped)
|
uint32_t XamEnumerate(uint32_t hEnum, uint32_t dwFlags, void* pvBuffer, uint32_t cbBuffer, be<uint32_t>* pcItemsReturned, XXOVERLAPPED* pOverlapped)
|
||||||
{
|
{
|
||||||
auto* enumerator = GetKernelObject<XamEnumeratorBase>(hEnum);
|
auto* enumerator = GetKernelObject<XamEnumeratorBase>(hEnum);
|
||||||
const auto count = enumerator->Next(pvBuffer);
|
const auto count = enumerator->Next(pvBuffer);
|
||||||
|
|
@ -290,7 +290,7 @@ SWA_API uint32_t XamEnumerate(uint32_t hEnum, uint32_t dwFlags, void* pvBuffer,
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName, const XCONTENT_DATA* pContentData,
|
uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName, const XCONTENT_DATA* pContentData,
|
||||||
uint32_t dwContentFlags, be<uint32_t>* pdwDisposition, be<uint32_t>* pdwLicenseMask,
|
uint32_t dwContentFlags, be<uint32_t>* pdwDisposition, be<uint32_t>* pdwLicenseMask,
|
||||||
uint32_t dwFileCacheSize, uint64_t uliContentSize, PXXOVERLAPPED pOverlapped)
|
uint32_t dwFileCacheSize, uint64_t uliContentSize, PXXOVERLAPPED pOverlapped)
|
||||||
{
|
{
|
||||||
|
|
@ -359,13 +359,13 @@ SWA_API uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName
|
||||||
return ERROR_PATH_NOT_FOUND;
|
return ERROR_PATH_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamContentClose(const char* szRootName, XXOVERLAPPED* pOverlapped)
|
uint32_t XamContentClose(const char* szRootName, XXOVERLAPPED* pOverlapped)
|
||||||
{
|
{
|
||||||
gRootMap.erase(StringHash(szRootName));
|
gRootMap.erase(StringHash(szRootName));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamContentGetDeviceData(uint32_t DeviceID, XDEVICE_DATA* pDeviceData)
|
uint32_t XamContentGetDeviceData(uint32_t DeviceID, XDEVICE_DATA* pDeviceData)
|
||||||
{
|
{
|
||||||
pDeviceData->DeviceID = DeviceID;
|
pDeviceData->DeviceID = DeviceID;
|
||||||
pDeviceData->DeviceType = XCONTENTDEVICETYPE_HDD;
|
pDeviceData->DeviceType = XCONTENTDEVICETYPE_HDD;
|
||||||
|
|
@ -381,7 +381,7 @@ SWA_API uint32_t XamContentGetDeviceData(uint32_t DeviceID, XDEVICE_DATA* pDevic
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamInputGetCapabilities(uint32_t unk, uint32_t userIndex, uint32_t flags, XAMINPUT_CAPABILITIES* caps)
|
uint32_t XamInputGetCapabilities(uint32_t unk, uint32_t userIndex, uint32_t flags, XAMINPUT_CAPABILITIES* caps)
|
||||||
{
|
{
|
||||||
uint32_t result = hid::GetCapabilities(userIndex, caps);
|
uint32_t result = hid::GetCapabilities(userIndex, caps);
|
||||||
|
|
||||||
|
|
@ -400,7 +400,7 @@ SWA_API uint32_t XamInputGetCapabilities(uint32_t unk, uint32_t userIndex, uint3
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamInputGetState(uint32_t userIndex, uint32_t flags, XAMINPUT_STATE* state)
|
uint32_t XamInputGetState(uint32_t userIndex, uint32_t flags, XAMINPUT_STATE* state)
|
||||||
{
|
{
|
||||||
memset(state, 0, sizeof(*state));
|
memset(state, 0, sizeof(*state));
|
||||||
|
|
||||||
|
|
@ -464,7 +464,7 @@ SWA_API uint32_t XamInputGetState(uint32_t userIndex, uint32_t flags, XAMINPUT_S
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWA_API uint32_t XamInputSetState(uint32_t userIndex, uint32_t flags, XAMINPUT_VIBRATION* vibration)
|
uint32_t XamInputSetState(uint32_t userIndex, uint32_t flags, XAMINPUT_VIBRATION* vibration)
|
||||||
{
|
{
|
||||||
if (!hid::detail::IsInputDeviceController() || !Config::Vibration)
|
if (!hid::detail::IsInputDeviceController() || !Config::Vibration)
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <xbox.h>
|
#include <xbox.h>
|
||||||
|
|
||||||
#define MSGID(Area, Number) (uint32_t)((uint16_t)(Area) << 16 | (uint16_t)(Number))
|
#define MSGID(Area, Number) (uint32_t)((uint16_t)(Area) << 16 | (uint16_t)(Number))
|
||||||
#define MSG_AREA(msgid) (((msgid) >> 16) & 0xFFFF)
|
#define MSG_AREA(msgid) (((msgid) >> 16) & 0xFFFF)
|
||||||
#define MSG_NUMBER(msgid) ((msgid) & 0xFFFF)
|
#define MSG_NUMBER(msgid) ((msgid) & 0xFFFF)
|
||||||
|
|
||||||
XCONTENT_DATA XamMakeContent(uint32_t type, const std::string_view& name);
|
XCONTENT_DATA XamMakeContent(uint32_t type, const std::string_view& name);
|
||||||
void XamRegisterContent(const XCONTENT_DATA& data, const std::string_view& root);
|
void XamRegisterContent(const XCONTENT_DATA& data, const std::string_view& root);
|
||||||
|
|
@ -11,23 +11,23 @@ void XamRegisterContent(const XCONTENT_DATA& data, const std::string_view& root)
|
||||||
std::string_view XamGetRootPath(const std::string_view& root);
|
std::string_view XamGetRootPath(const std::string_view& root);
|
||||||
void XamRootCreate(const std::string_view& root, const std::string_view& path);
|
void XamRootCreate(const std::string_view& root, const std::string_view& path);
|
||||||
|
|
||||||
SWA_API uint32_t XamNotifyCreateListener(uint64_t qwAreas);
|
uint32_t XamNotifyCreateListener(uint64_t qwAreas);
|
||||||
SWA_API void XamNotifyEnqueueEvent(uint32_t dwId, uint32_t dwParam); // i made it the fuck up
|
void XamNotifyEnqueueEvent(uint32_t dwId, uint32_t dwParam); // i made it the fuck up
|
||||||
SWA_API bool XNotifyGetNext(uint32_t hNotification, uint32_t dwMsgFilter, be<uint32_t>* pdwId, be<uint32_t>* pParam);
|
bool XNotifyGetNext(uint32_t hNotification, uint32_t dwMsgFilter, be<uint32_t>* pdwId, be<uint32_t>* pParam);
|
||||||
|
|
||||||
SWA_API uint32_t XamShowMessageBoxUI(uint32_t dwUserIndex, be<uint16_t>* wszTitle, be<uint16_t>* wszText, uint32_t cButtons,
|
uint32_t XamShowMessageBoxUI(uint32_t dwUserIndex, be<uint16_t>* wszTitle, be<uint16_t>* wszText, uint32_t cButtons,
|
||||||
xpointer<be<uint16_t>>* pwszButtons, uint32_t dwFocusButton, uint32_t dwFlags, be<uint32_t>* pResult, XXOVERLAPPED* pOverlapped);
|
xpointer<be<uint16_t>>* pwszButtons, uint32_t dwFocusButton, uint32_t dwFlags, be<uint32_t>* pResult, XXOVERLAPPED* pOverlapped);
|
||||||
|
|
||||||
SWA_API uint32_t XamContentCreateEnumerator(uint32_t dwUserIndex, uint32_t DeviceID, uint32_t dwContentType,
|
uint32_t XamContentCreateEnumerator(uint32_t dwUserIndex, uint32_t DeviceID, uint32_t dwContentType,
|
||||||
uint32_t dwContentFlags, uint32_t cItem, be<uint32_t>* pcbBuffer, be<uint32_t>* phEnum);
|
uint32_t dwContentFlags, uint32_t cItem, be<uint32_t>* pcbBuffer, be<uint32_t>* phEnum);
|
||||||
SWA_API uint32_t XamEnumerate(uint32_t hEnum, uint32_t dwFlags, void* pvBuffer, uint32_t cbBuffer, be<uint32_t>* pcItemsReturned, XXOVERLAPPED* pOverlapped);
|
uint32_t XamEnumerate(uint32_t hEnum, uint32_t dwFlags, void* pvBuffer, uint32_t cbBuffer, be<uint32_t>* pcItemsReturned, XXOVERLAPPED* pOverlapped);
|
||||||
|
|
||||||
SWA_API uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName, const XCONTENT_DATA* pContentData,
|
uint32_t XamContentCreateEx(uint32_t dwUserIndex, const char* szRootName, const XCONTENT_DATA* pContentData,
|
||||||
uint32_t dwContentFlags, be<uint32_t>* pdwDisposition, be<uint32_t>* pdwLicenseMask,
|
uint32_t dwContentFlags, be<uint32_t>* pdwDisposition, be<uint32_t>* pdwLicenseMask,
|
||||||
uint32_t dwFileCacheSize, uint64_t uliContentSize, PXXOVERLAPPED pOverlapped);
|
uint32_t dwFileCacheSize, uint64_t uliContentSize, PXXOVERLAPPED pOverlapped);
|
||||||
SWA_API uint32_t XamContentGetDeviceData(uint32_t DeviceID, XDEVICE_DATA* pDeviceData);
|
uint32_t XamContentGetDeviceData(uint32_t DeviceID, XDEVICE_DATA* pDeviceData);
|
||||||
SWA_API uint32_t XamContentClose(const char* szRootName, XXOVERLAPPED* pOverlapped);
|
uint32_t XamContentClose(const char* szRootName, XXOVERLAPPED* pOverlapped);
|
||||||
|
|
||||||
SWA_API uint32_t XamInputGetCapabilities(uint32_t unk, uint32_t userIndex, uint32_t flags, XAMINPUT_CAPABILITIES* caps);
|
uint32_t XamInputGetCapabilities(uint32_t unk, uint32_t userIndex, uint32_t flags, XAMINPUT_CAPABILITIES* caps);
|
||||||
SWA_API uint32_t XamInputGetState(uint32_t userIndex, uint32_t flags, XAMINPUT_STATE* state);
|
uint32_t XamInputGetState(uint32_t userIndex, uint32_t flags, XAMINPUT_STATE* state);
|
||||||
SWA_API uint32_t XamInputSetState(uint32_t userIndex, uint32_t flags, XAMINPUT_VIBRATION* vibration);
|
uint32_t XamInputSetState(uint32_t userIndex, uint32_t flags, XAMINPUT_VIBRATION* vibration);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ bool DisableEvilControlTutorialMidAsmHook(PPCRegister& r4, PPCRegister& r5)
|
||||||
return r4.u32 == 1 && r5.u32 == 1;
|
return r4.u32 == 1 && r5.u32 == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DisableDLCIconMidAsmHook()
|
||||||
|
{
|
||||||
|
return Config::DisableDLCIcon;
|
||||||
|
}
|
||||||
|
|
||||||
void ToggleSubtitlesMidAsmHook(PPCRegister& r27)
|
void ToggleSubtitlesMidAsmHook(PPCRegister& r27)
|
||||||
{
|
{
|
||||||
auto pApplicationDocument = (SWA::CApplicationDocument*)g_memory.Translate(r27.u32);
|
auto pApplicationDocument = (SWA::CApplicationDocument*)g_memory.Translate(r27.u32);
|
||||||
|
|
@ -91,3 +96,13 @@ PPC_FUNC(sub_8305D5B8)
|
||||||
|
|
||||||
__imp__sub_8305D5B8(ctx, base);
|
__imp__sub_8305D5B8(ctx, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable auto save warning.
|
||||||
|
PPC_FUNC_IMPL(__imp__sub_82586698);
|
||||||
|
PPC_FUNC(sub_82586698)
|
||||||
|
{
|
||||||
|
if (Config::DisableAutoSaveWarning)
|
||||||
|
*(bool*)g_memory.Translate(0x83367BC2) = true;
|
||||||
|
|
||||||
|
__imp__sub_82586698(ctx, base);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ void Config::Load()
|
||||||
{
|
{
|
||||||
toml::parse_result toml;
|
toml::parse_result toml;
|
||||||
std::ifstream tomlStream(configPath);
|
std::ifstream tomlStream(configPath);
|
||||||
|
|
||||||
if (tomlStream.is_open())
|
if (tomlStream.is_open())
|
||||||
{
|
|
||||||
toml = toml::parse(tomlStream);
|
toml = toml::parse(tomlStream);
|
||||||
}
|
|
||||||
|
|
||||||
for (auto def : g_configDefinitions)
|
for (auto def : g_configDefinitions)
|
||||||
{
|
{
|
||||||
def->ReadValue(toml);
|
def->ReadValue(toml);
|
||||||
|
|
||||||
#if _DEBUG
|
#if _DEBUG
|
||||||
LOGFN_UTILITY("{} (0x{:X})", def->GetDefinition().c_str(), (intptr_t)def->GetValue());
|
LOGFN_UTILITY("{} (0x{:X})", def->GetDefinition().c_str(), (intptr_t)def->GetValue());
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -46,6 +46,9 @@ void Config::Save()
|
||||||
|
|
||||||
for (auto def : g_configDefinitions)
|
for (auto def : g_configDefinitions)
|
||||||
{
|
{
|
||||||
|
if (def->IsHidden())
|
||||||
|
continue;
|
||||||
|
|
||||||
auto isFirstSection = section.empty();
|
auto isFirstSection = section.empty();
|
||||||
auto isDefWithSection = section != def->GetSection();
|
auto isDefWithSection = section != def->GetSection();
|
||||||
auto tomlDef = def->GetDefinition(isDefWithSection);
|
auto tomlDef = def->GetDefinition(isDefWithSection);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ class IConfigDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~IConfigDef() = default;
|
virtual ~IConfigDef() = default;
|
||||||
|
virtual bool IsHidden() = 0;
|
||||||
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_view GetSection() const = 0;
|
virtual std::string_view GetSection() const = 0;
|
||||||
|
|
@ -29,6 +30,9 @@ public:
|
||||||
#define CONFIG_DEFINE(section, type, name, defaultValue) \
|
#define CONFIG_DEFINE(section, type, name, defaultValue) \
|
||||||
static inline ConfigDef<type> name{section, #name, defaultValue};
|
static inline ConfigDef<type> name{section, #name, defaultValue};
|
||||||
|
|
||||||
|
#define CONFIG_DEFINE_HIDDEN(section, type, name, defaultValue) \
|
||||||
|
static inline ConfigDef<type, true> name{section, #name, defaultValue};
|
||||||
|
|
||||||
#define CONFIG_DEFINE_LOCALISED(section, type, name, defaultValue) \
|
#define CONFIG_DEFINE_LOCALISED(section, type, name, defaultValue) \
|
||||||
static CONFIG_LOCALE g_##name##_locale; \
|
static CONFIG_LOCALE g_##name##_locale; \
|
||||||
static inline ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue};
|
static inline ConfigDef<type> name{section, #name, &g_##name##_locale, defaultValue};
|
||||||
|
|
@ -267,7 +271,7 @@ CONFIG_DEFINE_ENUM_TEMPLATE(EUIScaleMode)
|
||||||
{ "Center", EUIScaleMode::Centre }
|
{ "Center", EUIScaleMode::Centre }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T, bool isHidden = false>
|
||||||
class ConfigDef final : public IConfigDef
|
class ConfigDef final : public IConfigDef
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -279,9 +283,10 @@ public:
|
||||||
std::unordered_map<std::string, T>* EnumTemplate;
|
std::unordered_map<std::string, T>* EnumTemplate;
|
||||||
std::map<T, std::string> EnumTemplateReverse{};
|
std::map<T, std::string> EnumTemplateReverse{};
|
||||||
CONFIG_ENUM_LOCALE(T)* EnumLocale{};
|
CONFIG_ENUM_LOCALE(T)* EnumLocale{};
|
||||||
std::function<void(ConfigDef<T>*)> Callback;
|
std::function<void(ConfigDef<T, isHidden>*)> Callback;
|
||||||
std::function<void(ConfigDef<T>*)> LockCallback;
|
std::function<void(ConfigDef<T, isHidden>*)> LockCallback;
|
||||||
std::function<void(ConfigDef<T>*)> ApplyCallback;
|
std::function<void(ConfigDef<T, isHidden>*)> ApplyCallback;
|
||||||
|
bool IsLoadedFromConfig{};
|
||||||
|
|
||||||
// CONFIG_DEFINE
|
// CONFIG_DEFINE
|
||||||
ConfigDef(std::string section, std::string name, T defaultValue) : Section(section), Name(name), DefaultValue(defaultValue)
|
ConfigDef(std::string section, std::string name, T defaultValue) : Section(section), Name(name), DefaultValue(defaultValue)
|
||||||
|
|
@ -314,11 +319,16 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONFIG_DEFINE_CALLBACK
|
// CONFIG_DEFINE_CALLBACK
|
||||||
ConfigDef(std::string section, std::string name, T defaultValue, std::function<void(ConfigDef<T>*)> callback) : Section(section), Name(name), DefaultValue(defaultValue), Callback(callback)
|
ConfigDef(std::string section, std::string name, T defaultValue, std::function<void(ConfigDef<T, isHidden>*)> callback) : Section(section), Name(name), DefaultValue(defaultValue), Callback(callback)
|
||||||
{
|
{
|
||||||
g_configDefinitions.emplace_back(this);
|
g_configDefinitions.emplace_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsHidden() override
|
||||||
|
{
|
||||||
|
return isHidden;
|
||||||
|
}
|
||||||
|
|
||||||
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())
|
||||||
|
|
@ -331,8 +341,9 @@ public:
|
||||||
}
|
}
|
||||||
else if constexpr (std::is_enum_v<T>)
|
else if constexpr (std::is_enum_v<T>)
|
||||||
{
|
{
|
||||||
std::string value = section[Name].value_or(std::string());
|
auto value = section[Name].value_or(std::string());
|
||||||
auto it = EnumTemplate->find(value);
|
auto it = EnumTemplate->find(value);
|
||||||
|
|
||||||
if (it != EnumTemplate->end())
|
if (it != EnumTemplate->end())
|
||||||
{
|
{
|
||||||
Value = it->second;
|
Value = it->second;
|
||||||
|
|
@ -349,6 +360,8 @@ public:
|
||||||
|
|
||||||
if (Callback)
|
if (Callback)
|
||||||
Callback(this);
|
Callback(this);
|
||||||
|
|
||||||
|
IsLoadedFromConfig = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -650,12 +663,13 @@ public:
|
||||||
CONFIG_DEFINE_LOCALISED("Video", bool, XboxColorCorrection, false);
|
CONFIG_DEFINE_LOCALISED("Video", bool, XboxColorCorrection, false);
|
||||||
CONFIG_DEFINE_ENUM_LOCALISED("Video", EUIScaleMode, UIScaleMode, EUIScaleMode::Edge);
|
CONFIG_DEFINE_ENUM_LOCALISED("Video", EUIScaleMode, UIScaleMode, EUIScaleMode::Edge);
|
||||||
|
|
||||||
// TODO: remove these once the exports are implemented.
|
CONFIG_DEFINE_HIDDEN("Exports", bool, AllowCancellingUnleash, false);
|
||||||
CONFIG_DEFINE("Exports", bool, AllowCancellingUnleash, false);
|
CONFIG_DEFINE_HIDDEN("Exports", bool, DisableAutoSaveWarning, false);
|
||||||
CONFIG_DEFINE("Exports", bool, FixUnleashOutOfControlDrain, false);
|
CONFIG_DEFINE_HIDDEN("Exports", bool, DisableDLCIcon, false);
|
||||||
CONFIG_DEFINE("Exports", bool, HomingAttackOnBoost, true);
|
CONFIG_DEFINE_HIDDEN("Exports", bool, FixUnleashOutOfControlDrain, false);
|
||||||
CONFIG_DEFINE("Exports", bool, SaveScoreAtCheckpoints, false);
|
CONFIG_DEFINE_HIDDEN("Exports", bool, HomingAttackOnBoost, true);
|
||||||
CONFIG_DEFINE("Exports", bool, SkipIntroLogos, false);
|
CONFIG_DEFINE_HIDDEN("Exports", bool, SaveScoreAtCheckpoints, false);
|
||||||
|
CONFIG_DEFINE_HIDDEN("Exports", bool, SkipIntroLogos, false);
|
||||||
|
|
||||||
static std::filesystem::path GetConfigPath()
|
static std::filesystem::path GetConfigPath()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -585,3 +585,8 @@ jump_address_on_false = 0x82536140
|
||||||
name = "RemoveMoviePlayerLetterboxMidAsmHook"
|
name = "RemoveMoviePlayerLetterboxMidAsmHook"
|
||||||
address = 0x82B723A8
|
address = 0x82B723A8
|
||||||
jump_address = 0x82B723BC
|
jump_address = 0x82B723BC
|
||||||
|
|
||||||
|
[[midasm_hook]]
|
||||||
|
name = "DisableDLCIconMidAsmHook"
|
||||||
|
address = 0x825756B0
|
||||||
|
jump_address_on_true = 0x825756E0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue