Replacement: Show a warning for bad texture names.

This commit is contained in:
Unknown W. Brackets 2018-09-30 17:55:51 -07:00
parent 8b62354df6
commit efc6510569
3 changed files with 20 additions and 0 deletions

View file

@ -22,11 +22,13 @@
#endif
#include <algorithm>
#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