add alternative emulator badge

This commit is contained in:
Sophia Hadash 2021-09-26 22:26:47 +02:00
parent 87735cd915
commit 0587b220cc
4 changed files with 10 additions and 2 deletions

View file

@ -389,6 +389,7 @@ void DetailedGameListView::updateInfoPanel()
ss << (file->metadata.get("completed").compare("true") ? "" : "completed ");
ss << (file->metadata.get("kidgame").compare("true") ? "" : "kidgame ");
ss << (file->metadata.get("broken").compare("true") ? "" : "broken ");
ss << (file->metadata.get("altemulator").compare("") ? "altemu " : "");
std::string slots = ss.str();
if (!slots.empty())
slots.pop_back();

View file

@ -451,6 +451,7 @@ void VideoGameListView::updateInfoPanel()
ss << (file->metadata.get("completed").compare("true") ? "" : "completed ");
ss << (file->metadata.get("kidgame").compare("true") ? "" : "kidgame ");
ss << (file->metadata.get("broken").compare("true") ? "" : "broken ");
ss << (file->metadata.get("altemulator").compare("") ? "altemu " : "");
std::string slots = ss.str();
if (!slots.empty())
slots.pop_back();

View file

@ -14,7 +14,8 @@
#include "resources/TextureResource.h"
// Available slot definitions.
const std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN};
const std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN,
SLOT_ALTERNATIVE_EMULATOR};
std::map<std::string, std::string> BadgesComponent::mBadgeIcons = std::map<std::string, std::string>();
std::map<std::string, ImageComponent> BadgesComponent::mImageComponents = std::map<std::string, ImageComponent>();
@ -25,6 +26,7 @@ BadgesComponent::BadgesComponent(Window *window)
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
mBadgeIcons[SLOT_KIDS] = ":/graphics/badge_kidgame.svg";
mBadgeIcons[SLOT_BROKEN] = ":/graphics/badge_broken.svg";
mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR] = ":/graphics/badge_altemu.svg";
}
@ -42,6 +44,9 @@ BadgesComponent::BadgesComponent(Window *window)
ImageComponent mImageBroken = ImageComponent(window);
mImageBroken.setImage(mBadgeIcons[SLOT_BROKEN], false, true);
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
ImageComponent mImageAltEmu = ImageComponent(window);
mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true);
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
}
}
@ -54,7 +59,7 @@ void BadgesComponent::setValue(const std::string& value)
std::istringstream ss(value);
while (std::getline(ss, temp, ' ')) {
if (!(temp == SLOT_FAVORITE || temp == SLOT_COMPLETED || temp == SLOT_KIDS ||
temp == SLOT_BROKEN))
temp == SLOT_BROKEN || temp == SLOT_ALTERNATIVE_EMULATOR))
LOG(LogError) << "Badge slot '" << temp << "' is invalid.";
else
mChildren.push_back(&mImageComponents.find(temp)->second);

View file

@ -20,6 +20,7 @@
#define SLOT_COMPLETED "completed"
#define SLOT_KIDS "kidgame"
#define SLOT_BROKEN "broken"
#define SLOT_ALTERNATIVE_EMULATOR "altemu"
class TextureResource;