mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Theme: Avoid checking the ui_atlas multiple times
This commit is contained in:
parent
4e9e767e41
commit
98780ba603
2 changed files with 19 additions and 6 deletions
|
@ -56,6 +56,7 @@ public:
|
|||
|
||||
// Filter support is optional but nice to have
|
||||
virtual bool GetFileInfo(const char *path, File::FileInfo *info) = 0;
|
||||
|
||||
virtual std::string toString() const = 0;
|
||||
};
|
||||
|
||||
|
@ -72,6 +73,12 @@ public:
|
|||
bool GetFileInfo(const char *filename, File::FileInfo *fileInfo);
|
||||
bool GetFileListing(const char *path, std::vector<File::FileInfo> *listing, const char *filter = nullptr) override;
|
||||
|
||||
// Shortcut for cleaner code
|
||||
bool Exists(const char *path) {
|
||||
File::FileInfo info{};
|
||||
return GetFileInfo(path, &info);
|
||||
}
|
||||
|
||||
private:
|
||||
struct VFSEntry {
|
||||
const char *prefix;
|
||||
|
|
18
UI/Theme.cpp
18
UI/Theme.cpp
|
@ -140,14 +140,20 @@ static void LoadThemeInfo(const std::vector<Path> &directories) {
|
|||
std::string tmpPath;
|
||||
section.Get("UIAtlas", &tmpPath, "");
|
||||
if (!tmpPath.empty()) {
|
||||
tmpPath = (path / tmpPath).ToString();
|
||||
|
||||
File::FileInfo tmpInfo;
|
||||
if (g_VFS.GetFileInfo((tmpPath + ".meta").c_str(), &tmpInfo) && g_VFS.GetFileInfo((tmpPath + ".zim").c_str(), &tmpInfo)) {
|
||||
info.sUIAtlas = tmpPath;
|
||||
if (tmpPath == "../ui_atlas") {
|
||||
// Do nothing.
|
||||
} else {
|
||||
// WARNING: Note that the below appears to be entirely broken. ..-navigation doesn't work on zip VFS.
|
||||
INFO_LOG(Log::System, "Checking %s", tmpPath.c_str());
|
||||
tmpPath = (path / tmpPath).ToString();
|
||||
if (g_VFS.Exists((tmpPath + ".meta").c_str()) && g_VFS.Exists((tmpPath + ".zim").c_str())) {
|
||||
// INFO_LOG(Log::System, "%s exists", tmpPath.c_str());
|
||||
info.sUIAtlas = tmpPath;
|
||||
} else {
|
||||
INFO_LOG(Log::System, "%s.meta/zim doesn't exist, not overriding atlas", tmpPath.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appendTheme(info);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue