mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-12-24 08:52:21 +00:00
mod_loader: implemented file logging (#392)
This commit is contained in:
parent
4f3144472a
commit
7a5cfe55f5
4 changed files with 24 additions and 4 deletions
|
|
@ -1,11 +1,12 @@
|
|||
#include <stdafx.h>
|
||||
#include "file_system.h"
|
||||
#include <cpu/guest_thread.h>
|
||||
#include <kernel/xam.h>
|
||||
#include <kernel/xdm.h>
|
||||
#include <kernel/function.h>
|
||||
#include <cpu/guest_thread.h>
|
||||
#include <os/logger.h>
|
||||
#include <mod/mod_loader.h>
|
||||
#include <os/logger.h>
|
||||
#include <user/config.h>
|
||||
#include <stdafx.h>
|
||||
|
||||
struct FileHandle : KernelObject
|
||||
{
|
||||
|
|
@ -365,8 +366,14 @@ std::filesystem::path FileSystem::ResolvePath(const std::string_view& path, bool
|
|||
if (checkForMods)
|
||||
{
|
||||
std::filesystem::path resolvedPath = ModLoader::ResolvePath(path);
|
||||
|
||||
if (!resolvedPath.empty())
|
||||
{
|
||||
if (ModLoader::s_isLogTypeConsole)
|
||||
LOGF_IMPL(Utility, "Mod Loader", "Loading file: \"{}\"", reinterpret_cast<const char*>(resolvedPath.u8string().c_str()));
|
||||
|
||||
return resolvedPath;
|
||||
}
|
||||
}
|
||||
|
||||
thread_local std::string builtPath;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,10 @@ void ModLoader::Init()
|
|||
}
|
||||
|
||||
if (configIni.getString("CPKREDIR", "LogType", std::string()) == "console")
|
||||
{
|
||||
os::process::ShowConsole();
|
||||
s_isLogTypeConsole = true;
|
||||
}
|
||||
|
||||
std::string modsDbIniFilePathU8 = configIni.getString("CPKREDIR", "ModsDbIni", "");
|
||||
if (modsDbIniFilePathU8.empty())
|
||||
|
|
@ -239,7 +242,7 @@ void ModLoader::Init()
|
|||
{
|
||||
if (def->GetName() == codes[i])
|
||||
{
|
||||
LOGFN("Loaded code: {}", codes[i]);
|
||||
LOGF_IMPL(Utility, "Mod Loader", "Loading code: \"{}\"", codes[i]);
|
||||
*(bool*)def->GetValue() = true;
|
||||
break;
|
||||
}
|
||||
|
|
@ -375,6 +378,9 @@ PPC_FUNC(sub_82E0D3E8)
|
|||
std::ifstream stream(filePath, std::ios::binary);
|
||||
if (stream.good())
|
||||
{
|
||||
if (ModLoader::s_isLogTypeConsole)
|
||||
LOGF_IMPL(Utility, "Mod Loader", "Loading file: \"{}\"", reinterpret_cast<const char*>(filePath.u8string().c_str()));
|
||||
|
||||
be<uint32_t> signature{};
|
||||
stream.read(reinterpret_cast<char*>(&signature), sizeof(signature));
|
||||
|
||||
|
|
@ -610,6 +616,9 @@ PPC_FUNC(sub_82E0B500)
|
|||
std::ifstream stream(arFilePath, std::ios::binary);
|
||||
if (stream.good())
|
||||
{
|
||||
if (ModLoader::s_isLogTypeConsole)
|
||||
LOGF_IMPL(Utility, "Mod Loader", "Loading file: \"{}\"", reinterpret_cast<const char*>(arFilePath.u8string().c_str()));
|
||||
|
||||
stream.seekg(0, std::ios::end);
|
||||
size_t arFileSize = stream.tellg();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
struct ModLoader
|
||||
{
|
||||
static inline bool s_isLogTypeConsole;
|
||||
|
||||
static inline std::filesystem::path s_saveFilePath;
|
||||
|
||||
static std::filesystem::path ResolvePath(std::string_view path);
|
||||
|
|
|
|||
|
|
@ -758,6 +758,8 @@ void Config::Load()
|
|||
|
||||
void Config::Save()
|
||||
{
|
||||
LOGN("Saving configuration...");
|
||||
|
||||
auto userPath = GetUserPath();
|
||||
|
||||
if (!std::filesystem::exists(userPath))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue