mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
make slots configurable by theme (fix)
This commit is contained in:
parent
593b6d94ee
commit
a928142d5b
|
@ -14,8 +14,8 @@
|
|||
#include "resources/TextureResource.h"
|
||||
|
||||
// Available slot definitions.
|
||||
const std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN,
|
||||
SLOT_ALTERNATIVE_EMULATOR};
|
||||
std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN,
|
||||
SLOT_ALTERNATIVE_EMULATOR};
|
||||
|
||||
BadgesComponent::BadgesComponent(Window *window)
|
||||
: FlexboxComponent(window) {
|
||||
|
@ -63,7 +63,7 @@ void BadgesComponent::setValue(const std::string &value) {
|
|||
if (!(temp == SLOT_FAVORITE || temp == SLOT_COMPLETED || temp == SLOT_KIDS ||
|
||||
temp == SLOT_BROKEN || temp == SLOT_ALTERNATIVE_EMULATOR))
|
||||
LOG(LogError) << "Badge slot '" << temp << "' is invalid.";
|
||||
else
|
||||
else if (std::find(mSlots.begin(), mSlots.end(), temp) != mSlots.end())
|
||||
mChildren.push_back(&mImageComponents.find(temp)->second);
|
||||
}
|
||||
}
|
||||
|
@ -101,8 +101,21 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
}
|
||||
}
|
||||
|
||||
if (elem->has("slots"))
|
||||
setValue(elem->get<std::string>("slots"));
|
||||
if (elem->has("slots")) {
|
||||
auto value = elem->get<std::string>("slots");
|
||||
mSlots = {};
|
||||
if (!value.empty()) {
|
||||
std::string temp;
|
||||
std::istringstream ss(value);
|
||||
while (std::getline(ss, temp, ' ')) {
|
||||
if (!(temp == SLOT_FAVORITE || temp == SLOT_COMPLETED || temp == SLOT_KIDS ||
|
||||
temp == SLOT_BROKEN || temp == SLOT_ALTERNATIVE_EMULATOR))
|
||||
LOG(LogError) << "Badge slot '" << temp << "' is invalid.";
|
||||
else
|
||||
mSlots.push_back(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply theme on the flexbox component parent.
|
||||
FlexboxComponent::applyTheme(theme, view, element, properties);
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
|
||||
private:
|
||||
static const std::vector<std::string> mSlots;
|
||||
static std::vector<std::string> mSlots;
|
||||
std::map<std::string, std::string> mBadgeIcons;
|
||||
std::map<std::string, ImageComponent> mImageComponents;
|
||||
};
|
||||
|
|
|
@ -248,7 +248,7 @@ based on: 'recalbox-multi' by the Recalbox community
|
|||
<itemWidth>.035</itemWidth>
|
||||
|
||||
<!-- badges properties -->
|
||||
<slots>favorite completed kidgame broken</slots>
|
||||
<slots>favorite completed kidgame broken altemu</slots>
|
||||
<customBadgeIcon badge="favorite">:/graphics/badge_favorite.svg</customBadgeIcon>
|
||||
<customBadgeIcon badge="completed">:/graphics/badge_completed.svg</customBadgeIcon>
|
||||
<customBadgeIcon badge="kidgame">:/graphics/badge_kidgame.svg</customBadgeIcon>
|
||||
|
|
Loading…
Reference in a new issue