Skip to content

Commit

Permalink
Fixed|UI: Check for and show icons in PK3s as well
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Dec 4, 2018
1 parent becd98a commit 4b2230c
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions doomsday/apps/client/src/ui/dialogs/packageinfodialog.cpp
Expand Up @@ -198,12 +198,11 @@ DENG_GUI_PIMPL(PackageInfoDialog)
icon->setBehavior(ContentClipping, false);
}

void useIconFile(String const &packagePath)
bool useIconFromPackage(const String &packagePath)
{
try
{
static StringList const imageExts({".jpg", ".jpeg", ".png"});
foreach (String ext, imageExts)
for (const auto *ext : {".jpg", ".jpeg", ".png"})
{
String const imgPath = packagePath / "icon" + ext;
if (ImageFile const *img = FS::tryLocate<ImageFile const>(imgPath))
Expand All @@ -216,15 +215,23 @@ DENG_GUI_PIMPL(PackageInfoDialog)
" is too large (max 512x512)");
}
setPackageIcon(iconImage);
return;
return true;
}
}
}
catch (Error const &er)
{
LOG_RES_WARNING("Failed to use package icon image: %s") << er.asText();
}
useDefaultIcon();
return false;
}

void useIconFile(String const &packagePath)
{
if (!useIconFromPackage(packagePath))
{
useDefaultIcon();
}
}

bool setup(File const *file)
Expand Down Expand Up @@ -253,9 +260,12 @@ DENG_GUI_PIMPL(PackageInfoDialog)
format = bundle->formatAsText().upperFirstChar();
compatibleGame = bundle->guessCompatibleGame();

if (!useGameTitlePicture())
if (!useIconFromPackage(file->path()))
{
useDefaultIcon();
if (!useGameTitlePicture())
{
useDefaultIcon();
}
}

if (bundle->format() == DataBundle::Collection)
Expand Down

0 comments on commit 4b2230c

Please sign in to comment.