GUI: Added support for multiple icon archives

This commit is contained in:
Eugene Sandulenko 2021-11-12 16:14:19 +01:00
parent a5844fd8da
commit 1008f64d74
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -108,9 +108,32 @@ GuiManager::~GuiManager() {
delete _theme;
}
struct ArchiveMemberListBackComparator {
bool operator()(const Common::ArchiveMemberPtr &a, const Common::ArchiveMemberPtr &b) {
return a->getName() > b->getName();
}
};
void GuiManager::initIconsSet() {
Common::Archive *dat;
if (ConfMan.hasKey("iconspath")) {
Common::FSDirectory *iconDir = new Common::FSDirectory(ConfMan.get("iconspath"));
Common::ArchiveMemberList iconFiles;
iconDir->listMatchingMembers(iconFiles, "gui-icons*.dat");
Common::sort(iconFiles.begin(), iconFiles.end(), ArchiveMemberListBackComparator());
for (Common::ArchiveMemberList::iterator ic = iconFiles.begin(); ic != iconFiles.end(); ++ic) {
debug(2, "GUI: Loaded icon file: %s", (*ic)->getName().c_str());
dat = Common::makeZipArchive((*ic)->createReadStream());
if (dat) {
_iconsSet.add((*ic)->getName(), dat);
}
}
}
const char fname[] = "gui-icons.dat";
Common::String path;
Common::FSNode *fs = nullptr;
@ -147,6 +170,8 @@ void GuiManager::initIconsSet() {
_iconsSet.add(path, dat);
debug(2, "GUI: Loaded icon file: %s", path.c_str());
delete fs;
}