Page MenuHomeWildfire Games
Paste P119

Allow the window icon to be cached
ActivePublic

Authored by Itms on May 1 2018, 8:15 PM.
Index: binaries/data/mods/mod/art/textures/icons/textures.xml
===================================================================
--- binaries/data/mods/mod/art/textures/icons/textures.xml (nonexistent)
+++ binaries/data/mods/mod/art/textures/icons/textures.xml (working copy)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Textures>
+ <File pattern="*" mipmap="false" alpha="transparency"/>
+</Textures>
Index: source/ps/VideoMode.cpp
===================================================================
--- source/ps/VideoMode.cpp (revision 21808)
+++ source/ps/VideoMode.cpp (working copy)
@@ -27,6 +27,8 @@
#include "lib/external_libraries/libsdl.h"
#include "lib/sysdep/gfx.h"
#include "lib/tex/tex.h"
+#include "maths/MD5.h"
+#include "ps/CacheLoader.h"
#include "ps/CConsole.h"
#include "ps/CLogger.h"
#include "ps/ConfigDB.h"
@@ -500,11 +502,33 @@
void CVideoMode::SetWindowIcon()
{
+ CCacheLoader cacheLoader(g_VFS, L".dds");
+ // We are using the cache in case the icon is in an archive, else we just use the source
+ // file, so the file version and initial hash are just arbitrary.
+ MD5 hash;
+ u32 version = 1;
+
+ VfsPath sourcePath = L"art/textures/icons/window.png";
+ VfsPath loadPath;
+ Status ret = cacheLoader.TryLoadingCached(sourcePath, hash, version, loadPath);
+
+ VfsPath iconPath;
+ if (ret == INFO::OK)
+ iconPath = loadPath;
+ else if (ret == INFO::SKIPPED)
+ iconPath = sourcePath;
+ else
+ {
+ ENSURE(ret < 0);
+ LOGWARNING("Window icon not found.");
+ return;
+ }
+
std::shared_ptr<u8> iconFile;
size_t iconFileSize;
- if (g_VFS->LoadFile("art/textures/icons/window.png", iconFile, iconFileSize) != INFO::OK)
+ if (g_VFS->LoadFile(iconPath, iconFile, iconFileSize) != INFO::OK)
{
- LOGWARNING("Window icon not found.");
+ LOGERROR("Cannot load file for the window icon.");
return;
}

Event Timeline

Itms created this paste.May 1 2018, 8:15 PM
Itms created this object with visibility "Public (No Login Required)".