Skip to content

Commit

Permalink
GUI: Simplify gui-icons.dat searching
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Nov 14, 2021
1 parent fb092a9 commit 72adc6b
Showing 1 changed file with 12 additions and 37 deletions.
49 changes: 12 additions & 37 deletions gui/gui-manager.cpp
Expand Up @@ -115,7 +115,7 @@ struct ArchiveMemberListBackComparator {
}
};
void GuiManager::initIconsSet() {
Common::Archive *dat;
Common::Archive *dat = nullptr;

if (ConfMan.hasKey("iconspath")) {
Common::FSDirectory *iconDir = new Common::FSDirectory(ConfMan.get("iconspath"));
Expand All @@ -139,53 +139,28 @@ void GuiManager::initIconsSet() {

const char fname[] = "gui-icons.dat";
Common::String path;
Common::FSNode *fs = nullptr;
Common::File *file = new Common::File;

if (ConfMan.hasKey("themepath")) {
path = normalizePath(ConfMan.get("themepath") + "/" + fname, '/');
if (ConfMan.hasKey("themepath"))
file->open(normalizePath(ConfMan.get("themepath") + "/" + fname, '/'));

fs = new Common::FSNode(path);
if (!fs->exists()) {
delete fs;
fs = nullptr;
}
}

if (!fs && ConfMan.hasKey("iconspath")) {
path = normalizePath(ConfMan.get("iconspath") + "/" + fname, '/');
if (!file->isOpen() && ConfMan.hasKey("iconspath"))
file->open(normalizePath(ConfMan.get("iconspath") + "/" + fname, '/'));

fs = new Common::FSNode(path);
if (!fs->exists()) {
delete fs;
fs = nullptr;
}
}
if (!file->isOpen())
file->open(fname);

if (!fs)
fs = new Common::FSNode(fname);

if (fs) {
dat = Common::makeZipArchive(*fs);
} else {
// We could be on Windows with gui-icons.dat file as an
// embedded resource. Try it.
Common::File *in = new Common::File;
in->open(fname);

if (in->isOpen())
dat = Common::makeZipArchive(in);
}
if (file->isOpen())
dat = Common::makeZipArchive(file);

if (!dat) {
warning("GUI: Could not find '%s'", path.c_str());
warning("GUI: Could not find '%s'", fname);
return;
}

_iconsSet.add(path, dat);
_iconsSet.add(path, dat, 0, false); // Do not autofree

debug(2, "GUI: Loaded icon file: %s", path.c_str());

delete fs;
}

void GuiManager::computeScaleFactor() {
Expand Down

0 comments on commit 72adc6b

Please sign in to comment.