Merge branch '63-add-badges-decals-e-g-for-favorites-completed-games-non-working-games-collections-and-folders' into 575-theme-add-a-modern-clean-switch-like-theme-as-an-official-theme-in-es-de-to-choose-from

This commit is contained in:
Sophia Hadash 2021-09-27 00:03:51 +02:00
commit 2bd3d03ca9
3 changed files with 16 additions and 7 deletions

View file

@ -20,8 +20,9 @@ class VideoComponent;
class VideoGameListView : public BasicGameListView
{
public:
VideoGameListView(Window* window, FileData* root);
virtual ~VideoGameListView();
VideoGameListView(Window *window, FileData *root);
virtual ~VideoGameListView() noexcept;
virtual void onShow() override;
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;

View file

@ -18,6 +18,7 @@ const std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_CO
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>();
std::vector<BadgesComponent *> BadgesComponent::mInstances = {};
BadgesComponent::BadgesComponent(Window *window)
: FlexboxComponent(window) {
@ -48,12 +49,19 @@ BadgesComponent::BadgesComponent(Window *window)
mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true);
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
}
mInstances.push_back(this);
}
BadgesComponent::~BadgesComponent() {
mChildren.clear();
mBadgeIcons.clear();
mImageComponents.clear();
BadgesComponent::~BadgesComponent() noexcept {
for (GuiComponent *c: mChildren)
c->clearChildren();
clearChildren();
mInstances.erase(std::remove(mInstances.begin(), mInstances.end(), this), mInstances.end());
if (mInstances.empty()) {
mBadgeIcons.clear();
mImageComponents.clear();
}
}

View file

@ -28,7 +28,6 @@ class BadgesComponent : public FlexboxComponent
{
public:
BadgesComponent(Window *window);
~BadgesComponent() noexcept;
std::string getValue() const override;
@ -46,6 +45,7 @@ private:
static const std::vector<std::string> mSlots;
static std::map<std::string, std::string> mBadgeIcons;
static std::map<std::string, ImageComponent> mImageComponents;
static std::vector<BadgesComponent *> mInstances;
};
#endif // ES_APP_COMPONENTS_BADGES_COMPONENT_H