Permalink
Browse files

Replacement: Show a warning for bad texture names.

  • Loading branch information...
unknownbrackets committed Oct 1, 2018
1 parent 8b62354 commit efc6510569bf43b000c82038f87f7ae480cd80e0
Showing with 20 additions and 0 deletions.
  1. +1 −0 Core/Config.cpp
  2. +1 −0 Core/Config.h
  3. +18 −0 Core/TextureReplacer.cpp
View
@@ -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),
View
@@ -168,6 +168,7 @@ struct Config {
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;
View
@@ -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

0 comments on commit efc6510

Please sign in to comment.