mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
fix the startup slowdown
This commit is contained in:
parent
f962a22e11
commit
edc761c4f9
|
@ -13,32 +13,37 @@
|
|||
#include "ThemeData.h"
|
||||
#include "resources/TextureResource.h"
|
||||
|
||||
BadgesComponent::BadgesComponent(Window* window)
|
||||
: FlexboxComponent(window)
|
||||
{
|
||||
// Define the slots.
|
||||
mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN};
|
||||
// Available slot definitions.
|
||||
const std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDS, SLOT_BROKEN};
|
||||
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>();
|
||||
|
||||
BadgesComponent::BadgesComponent(Window *window)
|
||||
: FlexboxComponent(window) {
|
||||
if (mBadgeIcons.empty()) {
|
||||
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
||||
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
|
||||
mBadgeIcons[SLOT_KIDS] = ":/graphics/badge_kidgame.svg";
|
||||
mBadgeIcons[SLOT_BROKEN] = ":/graphics/badge_broken.svg";
|
||||
}
|
||||
|
||||
mBadgeIcons = std::map<std::string, std::string>();
|
||||
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
||||
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
|
||||
mBadgeIcons[SLOT_KIDS] = ":/graphics/badge_kidgame.svg";
|
||||
mBadgeIcons[SLOT_BROKEN] = ":/graphics/badge_broken.svg";
|
||||
|
||||
// Create the child ImageComponent for every badge.
|
||||
mImageComponents = std::map<std::string, ImageComponent>();
|
||||
ImageComponent mImageFavorite = ImageComponent(window);
|
||||
mImageFavorite.setImage(mBadgeIcons[SLOT_FAVORITE], false, false);
|
||||
mImageComponents.insert({SLOT_FAVORITE, mImageFavorite});
|
||||
ImageComponent mImageCompleted = ImageComponent(window);
|
||||
mImageCompleted.setImage(mBadgeIcons[SLOT_COMPLETED], false, false);
|
||||
mImageComponents.insert({SLOT_COMPLETED, mImageCompleted});
|
||||
ImageComponent mImageKids = ImageComponent(window);
|
||||
mImageKids.setImage(mBadgeIcons[SLOT_KIDS], false, false);
|
||||
mImageComponents.insert({SLOT_KIDS, mImageKids});
|
||||
ImageComponent mImageBroken = ImageComponent(window);
|
||||
mImageBroken.setImage(mBadgeIcons[SLOT_BROKEN], false, false);
|
||||
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
|
||||
if (mImageComponents.empty()) {
|
||||
ImageComponent mImageFavorite = ImageComponent(window);
|
||||
mImageFavorite.setImage(mBadgeIcons[SLOT_FAVORITE], false, true);
|
||||
mImageComponents.insert({SLOT_FAVORITE, mImageFavorite});
|
||||
ImageComponent mImageCompleted = ImageComponent(window);
|
||||
mImageCompleted.setImage(mBadgeIcons[SLOT_COMPLETED], false, true);
|
||||
mImageComponents.insert({SLOT_COMPLETED, mImageCompleted});
|
||||
ImageComponent mImageKids = ImageComponent(window);
|
||||
mImageKids.setImage(mBadgeIcons[SLOT_KIDS], false, true);
|
||||
mImageComponents.insert({SLOT_KIDS, mImageKids});
|
||||
ImageComponent mImageBroken = ImageComponent(window);
|
||||
mImageBroken.setImage(mBadgeIcons[SLOT_BROKEN], false, true);
|
||||
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BadgesComponent::setValue(const std::string& value)
|
||||
|
@ -84,7 +89,7 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
for (auto& slot : mSlots) {
|
||||
if (properties & PATH && elem->has(slot)) {
|
||||
mBadgeIcons[slot] = elem->get<std::string>(slot);
|
||||
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot]);
|
||||
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot], false, true);
|
||||
imgChanged = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,19 +30,19 @@ public:
|
|||
|
||||
std::string getValue() const override;
|
||||
// Should be a list of strings.
|
||||
void setValue(const std::string& value) override;
|
||||
void setValue(const std::string &value) override;
|
||||
|
||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||
const std::string& view,
|
||||
const std::string& element,
|
||||
virtual void applyTheme(const std::shared_ptr<ThemeData> &theme,
|
||||
const std::string &view,
|
||||
const std::string &element,
|
||||
unsigned int properties) override;
|
||||
|
||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
|
||||
private:
|
||||
std::vector<std::string> mSlots;
|
||||
std::map<std::string, std::string> mBadgeIcons;
|
||||
std::map<std::string, ImageComponent> mImageComponents;
|
||||
static const std::vector<std::string> mSlots;
|
||||
static std::map<std::string, std::string> mBadgeIcons;
|
||||
static std::map<std::string, ImageComponent> mImageComponents;
|
||||
};
|
||||
|
||||
#endif // ES_APP_COMPONENTS_BADGES_COMPONENT_H
|
||||
|
|
Loading…
Reference in a new issue