Improved the speed of the badges code.
Also made some other adjustments to the badges and flexbox logic.
|
@ -410,7 +410,7 @@ void DetailedGameListView::updateInfoPanel()
|
||||||
ss << (file->metadata.get("completed").compare("true") ? "" : "completed ");
|
ss << (file->metadata.get("completed").compare("true") ? "" : "completed ");
|
||||||
ss << (file->metadata.get("kidgame").compare("true") ? "" : "kidgame ");
|
ss << (file->metadata.get("kidgame").compare("true") ? "" : "kidgame ");
|
||||||
ss << (file->metadata.get("broken").compare("true") ? "" : "broken ");
|
ss << (file->metadata.get("broken").compare("true") ? "" : "broken ");
|
||||||
ss << (file->metadata.get("altemulator").compare("") ? "altemu " : "");
|
ss << (file->metadata.get("altemulator").compare("") ? "altemulator " : "");
|
||||||
std::string slots = ss.str();
|
std::string slots = ss.str();
|
||||||
if (!slots.empty())
|
if (!slots.empty())
|
||||||
slots.pop_back();
|
slots.pop_back();
|
||||||
|
|
|
@ -451,7 +451,7 @@ void VideoGameListView::updateInfoPanel()
|
||||||
ss << (file->metadata.get("completed").compare("true") ? "" : "completed ");
|
ss << (file->metadata.get("completed").compare("true") ? "" : "completed ");
|
||||||
ss << (file->metadata.get("kidgame").compare("true") ? "" : "kidgame ");
|
ss << (file->metadata.get("kidgame").compare("true") ? "" : "kidgame ");
|
||||||
ss << (file->metadata.get("broken").compare("true") ? "" : "broken ");
|
ss << (file->metadata.get("broken").compare("true") ? "" : "broken ");
|
||||||
ss << (file->metadata.get("altemulator").compare("") ? "altemu " : "");
|
ss << (file->metadata.get("altemulator").compare("") ? "altemulator " : "");
|
||||||
std::string slots = ss.str();
|
std::string slots = ss.str();
|
||||||
if (!slots.empty())
|
if (!slots.empty())
|
||||||
slots.pop_back();
|
slots.pop_back();
|
||||||
|
|
|
@ -20,30 +20,22 @@ std::vector<std::string> BadgesComponent::mSlots = {SLOT_FAVORITE, SLOT_COMPLETE
|
||||||
BadgesComponent::BadgesComponent(Window* window)
|
BadgesComponent::BadgesComponent(Window* window)
|
||||||
: FlexboxComponent(window)
|
: FlexboxComponent(window)
|
||||||
{
|
{
|
||||||
|
|
||||||
mBadgeIcons = std::map<std::string, std::string>();
|
|
||||||
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
||||||
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
|
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
|
||||||
mBadgeIcons[SLOT_KIDS] = ":/graphics/badge_kidgame.svg";
|
mBadgeIcons[SLOT_KIDS] = ":/graphics/badge_kidgame.svg";
|
||||||
mBadgeIcons[SLOT_BROKEN] = ":/graphics/badge_broken.svg";
|
mBadgeIcons[SLOT_BROKEN] = ":/graphics/badge_broken.svg";
|
||||||
mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR] = ":/graphics/badge_altemu.svg";
|
mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR] = ":/graphics/badge_altemulator.svg";
|
||||||
|
|
||||||
mImageComponents = std::map<std::string, ImageComponent>();
|
|
||||||
ImageComponent mImageFavorite = ImageComponent(window);
|
ImageComponent mImageFavorite = ImageComponent(window);
|
||||||
mImageFavorite.setImage(mBadgeIcons[SLOT_FAVORITE], false, true);
|
|
||||||
mImageComponents.insert({SLOT_FAVORITE, mImageFavorite});
|
mImageComponents.insert({SLOT_FAVORITE, mImageFavorite});
|
||||||
ImageComponent mImageCompleted = ImageComponent(window);
|
ImageComponent mImageCompleted = ImageComponent(window);
|
||||||
mImageCompleted.setImage(mBadgeIcons[SLOT_COMPLETED], false, true);
|
|
||||||
mImageComponents.insert({SLOT_COMPLETED, mImageCompleted});
|
mImageComponents.insert({SLOT_COMPLETED, mImageCompleted});
|
||||||
ImageComponent mImageKids = ImageComponent(window);
|
ImageComponent mImageKids = ImageComponent(window);
|
||||||
mImageKids.setImage(mBadgeIcons[SLOT_KIDS], false, true);
|
|
||||||
mImageComponents.insert({SLOT_KIDS, mImageKids});
|
mImageComponents.insert({SLOT_KIDS, mImageKids});
|
||||||
ImageComponent mImageBroken = ImageComponent(window);
|
ImageComponent mImageBroken = ImageComponent(window);
|
||||||
mImageBroken.setImage(mBadgeIcons[SLOT_BROKEN], false, true);
|
|
||||||
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
|
mImageComponents.insert({SLOT_BROKEN, mImageBroken});
|
||||||
ImageComponent mImageAltEmu = ImageComponent(window);
|
ImageComponent mImageAltEmulator = ImageComponent(window);
|
||||||
mImageAltEmu.setImage(mBadgeIcons[SLOT_ALTERNATIVE_EMULATOR], false, true);
|
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmulator});
|
||||||
mImageComponents.insert({SLOT_ALTERNATIVE_EMULATOR, mImageAltEmu});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BadgesComponent::~BadgesComponent()
|
BadgesComponent::~BadgesComponent()
|
||||||
|
@ -94,13 +86,14 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool imgChanged = false;
|
|
||||||
for (auto& slot : mSlots) {
|
for (auto& slot : mSlots) {
|
||||||
if (properties & PATH && elem->has(slot) &&
|
if (properties & PATH && elem->has(slot)) {
|
||||||
mBadgeIcons[slot] != elem->get<std::string>(slot)) {
|
|
||||||
mBadgeIcons[slot] = elem->get<std::string>(slot);
|
mBadgeIcons[slot] = elem->get<std::string>(slot);
|
||||||
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot], false, true);
|
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot]);
|
||||||
imgChanged = true;
|
}
|
||||||
|
else {
|
||||||
|
mImageComponents.find(slot)->second.setImage(mBadgeIcons[slot]);
|
||||||
|
std::string teststring;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,12 +116,5 @@ void BadgesComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
// Apply theme on the flexbox component parent.
|
// Apply theme on the flexbox component parent.
|
||||||
FlexboxComponent::applyTheme(theme, view, element, properties);
|
FlexboxComponent::applyTheme(theme, view, element, properties);
|
||||||
|
|
||||||
if (imgChanged)
|
onSizeChanged();
|
||||||
onSizeChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<HelpPrompt> BadgesComponent::getHelpPrompts()
|
|
||||||
{
|
|
||||||
std::vector<HelpPrompt> prompts;
|
|
||||||
return prompts;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
// Used by gamelist views.
|
// Used by gamelist views.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef ES_APP_COMPONENTS_BADGES_COMPONENT_H
|
#ifndef ES_CORE_COMPONENTS_BADGES_COMPONENT_H
|
||||||
#define ES_APP_COMPONENTS_BADGES_COMPONENT_H
|
#define ES_CORE_COMPONENTS_BADGES_COMPONENT_H
|
||||||
|
|
||||||
#include "FlexboxComponent.h"
|
#include "FlexboxComponent.h"
|
||||||
#include "GuiComponent.h"
|
#include "GuiComponent.h"
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
#define SLOT_COMPLETED "completed"
|
#define SLOT_COMPLETED "completed"
|
||||||
#define SLOT_KIDS "kidgame"
|
#define SLOT_KIDS "kidgame"
|
||||||
#define SLOT_BROKEN "broken"
|
#define SLOT_BROKEN "broken"
|
||||||
#define SLOT_ALTERNATIVE_EMULATOR "altemu"
|
#define SLOT_ALTERNATIVE_EMULATOR "altemulator"
|
||||||
|
|
||||||
class TextureResource;
|
class TextureResource;
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ public:
|
||||||
BadgesComponent(Window* window);
|
BadgesComponent(Window* window);
|
||||||
~BadgesComponent();
|
~BadgesComponent();
|
||||||
|
|
||||||
|
static std::shared_ptr<BadgesComponent>& getInstance();
|
||||||
|
|
||||||
std::string getValue() const override;
|
std::string getValue() const override;
|
||||||
// Should be a list of strings.
|
// Should be a list of strings.
|
||||||
void setValue(const std::string& value) override;
|
void setValue(const std::string& value) override;
|
||||||
|
@ -39,12 +41,10 @@ public:
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
unsigned int properties) override;
|
unsigned int properties) override;
|
||||||
|
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::vector<std::string> mSlots;
|
static std::vector<std::string> mSlots;
|
||||||
std::map<std::string, std::string> mBadgeIcons;
|
std::map<std::string, std::string> mBadgeIcons;
|
||||||
std::map<std::string, ImageComponent> mImageComponents;
|
std::map<std::string, ImageComponent> mImageComponents;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_COMPONENTS_BADGES_COMPONENT_H
|
#endif // ES_CORE_COMPONENTS_BADGES_COMPONENT_H
|
||||||
|
|
|
@ -71,8 +71,8 @@ void FlexboxComponent::computeLayout()
|
||||||
float anchorOriginY = 0;
|
float anchorOriginY = 0;
|
||||||
|
|
||||||
// Translation directions when placing items.
|
// Translation directions when placing items.
|
||||||
glm::vec2 directionLine = {1, 0};
|
glm::ivec2 directionLine = {1, 0};
|
||||||
glm::vec2 directionRow = {0, 1};
|
glm::ivec2 directionRow = {0, 1};
|
||||||
|
|
||||||
// Change direction.
|
// Change direction.
|
||||||
if (mDirection == DIRECTION_COLUMN) {
|
if (mDirection == DIRECTION_COLUMN) {
|
||||||
|
@ -89,6 +89,7 @@ void FlexboxComponent::computeLayout()
|
||||||
glm::vec2 newSize = {mItemWidth, oldSize.y * (mItemWidth / oldSize.x)};
|
glm::vec2 newSize = {mItemWidth, oldSize.y * (mItemWidth / oldSize.x)};
|
||||||
i->setSize(newSize);
|
i->setSize(newSize);
|
||||||
maxItemSize = {std::max(maxItemSize.x, newSize.x), std::max(maxItemSize.y, newSize.y)};
|
maxItemSize = {std::max(maxItemSize.x, newSize.x), std::max(maxItemSize.y, newSize.y)};
|
||||||
|
i->setResize(maxItemSize.x, maxItemSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pre-compute layout parameters.
|
// Pre-compute layout parameters.
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
// Used by gamelist views.
|
// Used by gamelist views.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef ES_APP_COMPONENTS_FLEXBOX_COMPONENT_H
|
#ifndef ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H
|
||||||
#define ES_APP_COMPONENTS_FLEXBOX_COMPONENT_H
|
#define ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H
|
||||||
|
|
||||||
#include "GuiComponent.h"
|
#include "GuiComponent.h"
|
||||||
#include "renderers/Renderer.h"
|
#include "renderers/Renderer.h"
|
||||||
|
@ -69,4 +69,4 @@ private:
|
||||||
bool mLayoutValid;
|
bool mLayoutValid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_COMPONENTS_FLEXBOX_COMPONENT_H
|
#endif // ES_CORE_COMPONENTS_FLEXBOX_COMPONENT_H
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="svg4842"
|
id="svg4842"
|
||||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||||
sodipodi:docname="badge_altemu.svg">
|
sodipodi:docname="badge_altemulator.svg">
|
||||||
<defs
|
<defs
|
||||||
id="defs4836" />
|
id="defs4836" />
|
||||||
<sodipodi:namedview
|
<sodipodi:namedview
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 24 KiB |
|
@ -243,16 +243,17 @@ based on: 'recalbox-multi' by the Recalbox community
|
||||||
<!-- flexbox properties -->
|
<!-- flexbox properties -->
|
||||||
<direction>row</direction>
|
<direction>row</direction>
|
||||||
<align>start</align>
|
<align>start</align>
|
||||||
<itemsPerLine>2</itemsPerLine>
|
<itemsPerLine>3</itemsPerLine>
|
||||||
<itemMargin>5 5</itemMargin>
|
<itemMargin>5 5</itemMargin>
|
||||||
<itemWidth>.035</itemWidth>
|
<itemWidth>.035</itemWidth>
|
||||||
|
|
||||||
<!-- badges properties -->
|
<!-- badges properties -->
|
||||||
<slots>favorite completed kidgame broken altemu</slots>
|
<slots>favorite completed kidgame broken altemulator</slots>
|
||||||
<customBadgeIcon badge="favorite">:/graphics/badge_favorite.svg</customBadgeIcon>
|
<customBadgeIcon badge="favorite">:/graphics/badge_favorite.svg</customBadgeIcon>
|
||||||
<customBadgeIcon badge="completed">:/graphics/badge_completed.svg</customBadgeIcon>
|
<customBadgeIcon badge="completed">:/graphics/badge_completed.svg</customBadgeIcon>
|
||||||
<customBadgeIcon badge="kidgame">:/graphics/badge_kidgame.svg</customBadgeIcon>
|
<customBadgeIcon badge="kidgame">:/graphics/badge_kidgame.svg</customBadgeIcon>
|
||||||
<customBadgeIcon badge="broken">:/graphics/badge_broken.svg</customBadgeIcon>
|
<customBadgeIcon badge="broken">:/graphics/badge_broken.svg</customBadgeIcon>
|
||||||
|
<customBadgeIcon badge="altemulator">:/graphics/badge_altemulator.svg</customBadgeIcon>
|
||||||
</badges>
|
</badges>
|
||||||
<!-- This block prevents additional elements from interfering when mixing layouts. -->
|
<!-- This block prevents additional elements from interfering when mixing layouts. -->
|
||||||
<image name="backframe4" extra="false"></image>
|
<image name="backframe4" extra="false"></image>
|
||||||
|
|