diff --git a/Core/Config.cpp b/Core/Config.cpp index e2fd65cd88..d803a14c5a 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -653,6 +653,7 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("TrueColor", &g_Config.bTrueColor, true, true, true), ReportedConfigSetting("ReplaceTextures", &g_Config.bReplaceTextures, true, true, true), ReportedConfigSetting("SaveNewTextures", &g_Config.bSaveNewTextures, false, true, true), + ReportedConfigSetting("IgnoreTextureFilenames", &g_Config.bIgnoreTextureFilenames, true, true, false), ReportedConfigSetting("TexScalingLevel", &g_Config.iTexScalingLevel, 1, true, true), ReportedConfigSetting("TexScalingType", &g_Config.iTexScalingType, 0, true, true), diff --git a/Core/Config.h b/Core/Config.h index 24e7d98664..715800c79a 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -168,6 +168,7 @@ public: bool bTrueColor; bool bReplaceTextures; bool bSaveNewTextures; + bool bIgnoreTextureFilenames; int iTexScalingLevel; // 0 = auto, 1 = off, 2 = 2x, ..., 5 = 5x int iTexScalingType; // 0 = xBRZ, 1 = Hybrid bool bTexDeposterize; diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index c38eb58baa..1be43ebba2 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -22,11 +22,13 @@ #endif #include +#include "i18n/i18n.h" #include "ext/xxhash.h" #include "file/ini_file.h" #include "Common/ColorConv.h" #include "Common/FileUtil.h" #include "Core/Config.h" +#include "Core/Host.h" #include "Core/System.h" #include "Core/TextureReplacer.h" #include "Core/ELF/ParamSFO.h" @@ -112,19 +114,35 @@ bool TextureReplacer::LoadIni() { ERROR_LOG(G3D, "Unsupported texture replacement version %d, trying anyway", version); } + bool filenameWarning = false; if (ini.HasSection("hashes")) { auto hashes = ini.GetOrCreateSection("hashes")->ToMap(); // Format: hashname = filename.png + bool checkFilenames = g_Config.bSaveNewTextures && g_Config.bIgnoreTextureFilenames; for (const auto &item : hashes) { ReplacementAliasKey key(0, 0, 0); if (sscanf(item.first.c_str(), "%16llx%8x_%d", &key.cachekey, &key.hash, &key.level) >= 1) { aliases_[key] = item.second; + if (checkFilenames) { +#if PPSSPP_PLATFORM(WINDOWS) + // Uppercase probably means the filenames don't match. + // Avoiding an actual check of the filenames to avoid performance impact. + filenameWarning = filenameWarning || item.second.find_first_of("\\ABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos; +#else + filenameWarning = filenameWarning || item.second.find_first_of("\\:<>|?*") != std::string::npos; +#endif + } } else { ERROR_LOG(G3D, "Unsupported syntax under [hashes]: %s", item.first.c_str()); } } } + if (filenameWarning) { + I18NCategory *err = GetI18NCategory("Error"); + host->NotifyUserMessage(err->T("textures.ini filenames may not be cross-platform"), 6.0f); + } + if (ini.HasSection("hashranges")) { auto hashranges = ini.GetOrCreateSection("hashranges")->ToMap(); // Format: addr,w,h = newW,newH