mirror of
https://github.com/esuo1198/TaikoArcadeLoader.git
synced 2026-09-29 02:08:06 +03:00
TestMode Value lifecycle control
This commit is contained in:
@@ -98,6 +98,11 @@ LogMessageHandler (const char *function, const char *codeFile, const int codeLin
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
bool
|
||||
EnableLogging (LogLevel messageLevel) {
|
||||
return loggerInstance != nullptr && messageLevel <= loggerInstance->logLevel;
|
||||
}
|
||||
|
||||
void
|
||||
CleanupLogger () {
|
||||
if (loggerInstance != nullptr) {
|
||||
|
||||
@@ -35,6 +35,8 @@ void InitializeLogger (LogLevel level, bool logToFile);
|
||||
void LogMessageHandler (const char *function, const char *codeFile, int codeLine, LogLevel messageLevel, const char *format, ...);
|
||||
void LogMessageHandler (const char *function, const char *codeFile, int codeLine, LogLevel messageLevel, const wchar_t *format, ...);
|
||||
|
||||
bool EnableLogging (LogLevel level);
|
||||
|
||||
/* *
|
||||
* Logs a message with file and line information, if the log level permits.
|
||||
*
|
||||
@@ -44,12 +46,14 @@ template <typename... Args>
|
||||
struct LogMessage {
|
||||
LogMessage (const LogLevel level, const std::string_view format, Args &&...args,
|
||||
const std::source_location &loc = std::source_location::current ()) {
|
||||
if (!EnableLogging (level)) return;
|
||||
std::string formatted_message = std::vformat(std::string(format), std::make_format_args(args...));
|
||||
LogMessageHandler (loc.function_name (), loc.file_name (), loc.line (), level, formatted_message.c_str ());
|
||||
}
|
||||
|
||||
LogMessage (const LogLevel level, const std::wstring_view format, Args &&...args,
|
||||
const std::source_location &loc = std::source_location::current ()) {
|
||||
if (!EnableLogging (level)) return;
|
||||
std::wstring formatted_message = std::vformat(std::wstring(format), std::make_wformat_args(args...));
|
||||
LogMessageHandler (loc.function_name (), loc.file_name (), loc.line (), level, formatted_message.c_str ());
|
||||
}
|
||||
|
||||
@@ -257,10 +257,15 @@ FAST_HOOK_DYNAMIC (char, SceneTestModeLoading, u64 a1, u64 a2, u64 a3) {
|
||||
|
||||
FAST_HOOK_DYNAMIC (char, SceneTestModeFinalize, u64 a1, u64 a2, u64 a3) {
|
||||
char result = originalSceneTestModeFinalize.fastcall<char> (a1, a2, a3);
|
||||
for (auto value : values) { value->Reset (); value->Read (); }
|
||||
std::thread ([](){for (auto value : values) { value->Reset (); value->Read (); }}).detach ();
|
||||
return result;
|
||||
}
|
||||
|
||||
FAST_HOOK_DYNAMIC (void, SceneFirstInitialize, u64 a1, u64 a2, u64 a3) {
|
||||
std::thread ([](){for (auto value : values) { value->Reset (); value->Read (); }}).detach ();
|
||||
originalSceneFirstInitialize.fastcall<char *> (a1, a2, a3);
|
||||
}
|
||||
|
||||
FAST_HOOK_DYNAMIC (void, TestModeSetMenuHook, u64 testModeLibrary, const wchar_t *lFileName) {
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
const auto originalFileName = std::wstring (lFileName);
|
||||
@@ -477,6 +482,7 @@ Init () {
|
||||
case GameVersion::JPN39: {
|
||||
INSTALL_FAST_HOOK_DYNAMIC (SceneTestModeLoading, ASLR (0x1404793D0));
|
||||
INSTALL_FAST_HOOK_DYNAMIC (SceneTestModeFinalize, ASLR (0x140479600));
|
||||
INSTALL_FAST_HOOK_DYNAMIC (SceneFirstInitialize, ASLR (0x1404574B0));
|
||||
originalDeviceInitialize = L"DeviceInitialize.xml";
|
||||
if (Language::CnFontPatches () && std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\DeviceInitialize_china.xml")) {
|
||||
usingDeviceInitialize = L"DeviceInitialize_china.xml";
|
||||
@@ -517,6 +523,7 @@ SetupAccessor (const u64 appAccessor, const RefTestModeMain refTestMode) {
|
||||
LogMessage (LogLevel::DEBUG, "TestMode setup!");
|
||||
TestMode::appAccessor = appAccessor;
|
||||
TestMode::refTestMode = refTestMode;
|
||||
// std::thread ([](){for (auto value : values) { value->Reset (); value->Read (); }}).detach ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user