mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added color marking to GuiMetaDataEd for newly scraped data.
This commit is contained in:
parent
4a38271f6a
commit
4c67dae788
|
@ -295,6 +295,14 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
|||
// Update the list with the scraped metadata values.
|
||||
for (unsigned int i = 0; i < mEditors.size(); i++) {
|
||||
const std::string& key = mMetaDataDecl.at(i).key;
|
||||
if (mEditors.at(i)->getValue() != metadata->get(key)) {
|
||||
if (key == "rating") {
|
||||
mEditors.at(i)->setColorShift(0xDD2222FF);
|
||||
}
|
||||
else {
|
||||
mEditors.at(i)->setColor(0x994444FF);
|
||||
}
|
||||
}
|
||||
mEditors.at(i)->setValue(metadata->get(key));
|
||||
}
|
||||
|
||||
|
|
|
@ -269,6 +269,11 @@ void GuiComponent::setColorShift(unsigned int color)
|
|||
mColorShiftEnd = color;
|
||||
}
|
||||
|
||||
unsigned int GuiComponent::getColor() const
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
const Transform4x4f& GuiComponent::getTransform()
|
||||
{
|
||||
mTransform = Transform4x4f::Identity();
|
||||
|
|
|
@ -132,6 +132,7 @@ public:
|
|||
virtual void setOpacity(unsigned char opacity);
|
||||
virtual void setColor(unsigned int color);
|
||||
virtual void setColorShift(unsigned int color);
|
||||
virtual unsigned int getColor() const;
|
||||
|
||||
const Transform4x4f& getTransform();
|
||||
|
||||
|
|
|
@ -176,8 +176,39 @@ void ComponentList::render(const Transform4x4f& parentTrans)
|
|||
auto& entry = mEntries.at(i);
|
||||
drawAll = !mFocused || i != (unsigned int)mCursor;
|
||||
for (auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); it++) {
|
||||
if (drawAll || it->invert_when_selected)
|
||||
if (drawAll || it->invert_when_selected) {
|
||||
// For the row where the cursor is at, we want to remove any hue from the
|
||||
// font color before inverting, as it would otherwise lead to an ugly
|
||||
// inverted color (e.g. red text inverting to a green hue).
|
||||
if (i == mCursor && it->component->getValue() != "" ) {
|
||||
// Check if the text color is neutral.
|
||||
unsigned int origColor = it->component->getColor();
|
||||
unsigned char byteRed = origColor >> 24 & 0xFF;
|
||||
unsigned char byteGreen = origColor >> 16 & 0xFF;
|
||||
unsigned char byteBlue = origColor >> 8 & 0xFF;
|
||||
// If it's neutral, just proceed with normal rendering.
|
||||
if (byteRed == byteGreen && byteGreen == byteBlue) {
|
||||
it->component->render(trans);
|
||||
}
|
||||
else {
|
||||
// If there is a hue, average the brightness values to make
|
||||
// an equivalent gray value before inverting the text.
|
||||
// This is not the proper way to do a BW conversion as the RGB values
|
||||
// should not be evenly distributed, but it's definitely good enough
|
||||
// for this situation.
|
||||
unsigned char byteAverage = (byteRed + byteGreen + byteBlue) / 3;
|
||||
unsigned int averageColor = byteAverage << 24 | byteAverage << 16 |
|
||||
byteAverage << 8 | 0xFF;
|
||||
it->component->setColor(averageColor);
|
||||
it->component->render(trans);
|
||||
// Revert to the original color after rendering.
|
||||
it->component->setColor(origColor);
|
||||
}
|
||||
}
|
||||
else {
|
||||
it->component->render(trans);
|
||||
}
|
||||
}
|
||||
else
|
||||
drawAfterCursor.push_back(it->component.get());
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
void update(int deltaTime) override;
|
||||
unsigned int getColor() const override { return mColor; };
|
||||
void render(const Transform4x4f& parentTrans) override;
|
||||
void onSizeChanged() override;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
void setBackgroundColor(unsigned int color);
|
||||
void setRenderBackground(bool render);
|
||||
|
||||
unsigned int getColor() const override { return mColor; };
|
||||
void render(const Transform4x4f& parentTrans) override;
|
||||
|
||||
std::string getValue() const override;
|
||||
|
|
Loading…
Reference in a new issue