mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Changed to ISO 8601 date format and tidied up the scraper search screen.
This commit is contained in:
parent
709e6b996e
commit
f5376defe0
|
@ -379,8 +379,10 @@ void GuiScraperSearch::updateInfoPane()
|
||||||
|
|
||||||
// Metadata.
|
// Metadata.
|
||||||
if (Settings::getInstance()->getBool("ScrapeRatings") &&
|
if (Settings::getInstance()->getBool("ScrapeRatings") &&
|
||||||
Settings::getInstance()->getString("Scraper") != "TheGamesDB")
|
Settings::getInstance()->getString("Scraper") != "TheGamesDB") {
|
||||||
mMD_Rating->setValue(Utils::String::toUpper(res.mdl.get("rating")));
|
mMD_Rating->setValue(Utils::String::toUpper(res.mdl.get("rating")));
|
||||||
|
mMD_Rating->setOpacity(255);
|
||||||
|
}
|
||||||
mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate")));
|
mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate")));
|
||||||
mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer")));
|
mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer")));
|
||||||
mMD_Publisher->setText(Utils::String::toUpper(res.mdl.get("publisher")));
|
mMD_Publisher->setText(Utils::String::toUpper(res.mdl.get("publisher")));
|
||||||
|
@ -395,9 +397,11 @@ void GuiScraperSearch::updateInfoPane()
|
||||||
|
|
||||||
// Metadata.
|
// Metadata.
|
||||||
if (Settings::getInstance()->getBool("ScrapeRatings") &&
|
if (Settings::getInstance()->getBool("ScrapeRatings") &&
|
||||||
Settings::getInstance()->getString("Scraper") != "TheGamesDB")
|
Settings::getInstance()->getString("Scraper") != "TheGamesDB") {
|
||||||
mMD_Rating->setValue("");
|
mMD_Rating->setValue("");
|
||||||
mMD_ReleaseDate->setValue("");
|
mMD_Rating->setOpacity(0);
|
||||||
|
}
|
||||||
|
mMD_ReleaseDate->setValue("99990101T000000");
|
||||||
mMD_Developer->setText("");
|
mMD_Developer->setText("");
|
||||||
mMD_Publisher->setText("");
|
mMD_Publisher->setText("");
|
||||||
mMD_Genre->setText("");
|
mMD_Genre->setText("");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// UIModeController.cpp
|
// UIModeController.cpp
|
||||||
//
|
//
|
||||||
// Handling of application user interface modes (full, kiosk and kid).
|
// Handling of application user interface modes (full, kiosk and kid).
|
||||||
// This includes switching the mode when the UI mode passkey was used.
|
// This includes switching the mode when the UI mode passkey is used.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "UIModeController.h"
|
#include "UIModeController.h"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// UIModeController.h
|
// UIModeController.h
|
||||||
//
|
//
|
||||||
// Handling of application user interface modes (full, kiosk and kid).
|
// Handling of application user interface modes (full, kiosk and kid).
|
||||||
// This includes switching the mode when the UI mode passkey was used.
|
// This includes switching the mode when the UI mode passkey is used.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ComponentGrid.cpp
|
// ComponentGrid.cpp
|
||||||
//
|
//
|
||||||
// Providing basic layout of other components in an X*Y grid.
|
// Provides basic layout of components in an X*Y grid.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "components/ComponentGrid.h"
|
#include "components/ComponentGrid.h"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// ComponentGrid.h
|
// ComponentGrid.h
|
||||||
//
|
//
|
||||||
// Providing basic layout of other components in an X*Y grid.
|
// Provides basic layout of components in an X*Y grid.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//
|
//
|
||||||
// DateTimeComponent.cpp
|
// DateTimeComponent.cpp
|
||||||
//
|
//
|
||||||
// Date and time component.
|
// Provides the date and time, in absolute (actual date) or relative
|
||||||
|
// (delta from current date and time) form.
|
||||||
|
// Used by the gamelist views.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "components/DateTimeComponent.h"
|
#include "components/DateTimeComponent.h"
|
||||||
|
@ -13,7 +15,8 @@
|
||||||
DateTimeComponent::DateTimeComponent(Window* window)
|
DateTimeComponent::DateTimeComponent(Window* window)
|
||||||
: TextComponent(window), mDisplayRelative(false)
|
: TextComponent(window), mDisplayRelative(false)
|
||||||
{
|
{
|
||||||
setFormat("%m/%d/%Y");
|
// ISO 8601 date format.
|
||||||
|
setFormat("%Y-%m-%d");
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTimeComponent::DateTimeComponent(
|
DateTimeComponent::DateTimeComponent(
|
||||||
|
@ -28,7 +31,8 @@ DateTimeComponent::DateTimeComponent(
|
||||||
: TextComponent(window, text, font, color, align, pos, size, bgcolor),
|
: TextComponent(window, text, font, color, align, pos, size, bgcolor),
|
||||||
mDisplayRelative(false)
|
mDisplayRelative(false)
|
||||||
{
|
{
|
||||||
setFormat("%m/%d/%Y");
|
// ISO 8601 date format.
|
||||||
|
setFormat("%Y-%m-%d");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTimeComponent::setValue(const std::string& val)
|
void DateTimeComponent::setValue(const std::string& val)
|
||||||
|
@ -95,7 +99,6 @@ void DateTimeComponent::render(const Transform4x4f& parentTrans)
|
||||||
TextComponent::render(parentTrans);
|
TextComponent::render(parentTrans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& view, const std::string& element, unsigned int properties)
|
const std::string& view, const std::string& element, unsigned int properties)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//
|
//
|
||||||
// DateTimeComponent.h
|
// DateTimeComponent.h
|
||||||
//
|
//
|
||||||
// Date and time component.
|
// Provides the date and time, in absolute (actual date) or relative
|
||||||
|
// (delta from current date and time) form.
|
||||||
|
// Used by the gamelist views.
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -13,7 +15,7 @@
|
||||||
|
|
||||||
class ThemeData;
|
class ThemeData;
|
||||||
|
|
||||||
// Used to display date times.
|
// Used to display date and time.
|
||||||
class DateTimeComponent : public TextComponent
|
class DateTimeComponent : public TextComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -63,15 +63,22 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
}
|
}
|
||||||
|
|
||||||
int incDir = 0;
|
int incDir = 0;
|
||||||
if (config->isMappedLike("up", input) || config->isMappedLike("leftshoulder", input))
|
if (config->isMappedLike("up", input) || config->isMappedLike("rightshoulder", input))
|
||||||
incDir = 1;
|
incDir = 1;
|
||||||
else if (config->isMappedLike("down", input) || config->isMappedLike("rightshoulder", input))
|
else if (config->isMappedLike("down", input) || config->isMappedLike("leftshoulder", input))
|
||||||
incDir = -1;
|
incDir = -1;
|
||||||
|
|
||||||
if (incDir != 0) {
|
if (incDir != 0) {
|
||||||
tm new_tm = mTime;
|
tm new_tm = mTime;
|
||||||
|
|
||||||
|
// ISO 8601 date format.
|
||||||
if (mEditIndex == 0) {
|
if (mEditIndex == 0) {
|
||||||
|
new_tm.tm_year += incDir;
|
||||||
|
|
||||||
|
if (new_tm.tm_year < 0)
|
||||||
|
new_tm.tm_year = 0;
|
||||||
|
}
|
||||||
|
else if (mEditIndex == 1) {
|
||||||
new_tm.tm_mon += incDir;
|
new_tm.tm_mon += incDir;
|
||||||
|
|
||||||
if (new_tm.tm_mon > 11)
|
if (new_tm.tm_mon > 11)
|
||||||
|
@ -80,7 +87,7 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
new_tm.tm_mon = 11;
|
new_tm.tm_mon = 11;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mEditIndex == 1) {
|
else if (mEditIndex == 2) {
|
||||||
const int days_in_month =
|
const int days_in_month =
|
||||||
Utils::Time::daysInMonth(new_tm.tm_year + 1900, new_tm.tm_mon + 1);
|
Utils::Time::daysInMonth(new_tm.tm_year + 1900, new_tm.tm_mon + 1);
|
||||||
new_tm.tm_mday += incDir;
|
new_tm.tm_mday += incDir;
|
||||||
|
@ -91,12 +98,6 @@ bool DateTimeEditComponent::input(InputConfig* config, Input input)
|
||||||
new_tm.tm_mday = days_in_month;
|
new_tm.tm_mday = days_in_month;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mEditIndex == 2) {
|
|
||||||
new_tm.tm_year += incDir;
|
|
||||||
|
|
||||||
if (new_tm.tm_year < 0)
|
|
||||||
new_tm.tm_year = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate day.
|
// Validate day.
|
||||||
const int days_in_month =
|
const int days_in_month =
|
||||||
|
@ -191,16 +192,21 @@ DateTimeEditComponent::DisplayMode DateTimeEditComponent::getCurrentDisplayMode(
|
||||||
|
|
||||||
std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
|
std::string DateTimeEditComponent::getDisplayString(DisplayMode mode) const
|
||||||
{
|
{
|
||||||
|
// ISO 8601 date format.
|
||||||
std::string fmt;
|
std::string fmt;
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DISP_DATE: {
|
case DISP_DATE: {
|
||||||
fmt = "%m/%d/%Y";
|
if (mTime.getTime() == 0)
|
||||||
|
// The extra blankspaces are for visual alignment.
|
||||||
|
return "unknown ";
|
||||||
|
fmt = "%Y-%m-%d";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DISP_DATE_TIME: {
|
case DISP_DATE_TIME: {
|
||||||
if (mTime.getTime() == 0)
|
if (mTime.getTime() == 0)
|
||||||
return "unknown";
|
// The extra blankspaces are for visual alignment.
|
||||||
fmt = "%m/%d/%Y %H:%M:%S";
|
return "unknown ";
|
||||||
|
fmt = "%Y-%m-%d %H:%M:%S";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DISP_RELATIVE_TO_NOW: {
|
case DISP_RELATIVE_TO_NOW: {
|
||||||
|
@ -243,8 +249,18 @@ std::shared_ptr<Font> DateTimeEditComponent::getFont() const
|
||||||
void DateTimeEditComponent::updateTextCache()
|
void DateTimeEditComponent::updateTextCache()
|
||||||
{
|
{
|
||||||
DisplayMode mode = getCurrentDisplayMode();
|
DisplayMode mode = getCurrentDisplayMode();
|
||||||
const std::string dispString = mUppercase ?
|
|
||||||
Utils::String::toUpper(getDisplayString(mode)) : getDisplayString(mode);
|
std::string dispString;
|
||||||
|
|
||||||
|
// Hack to set date string to blank instead of 'unknown'.
|
||||||
|
// The calling function simply needs to set this string using setValue().
|
||||||
|
if (mTime.getIsoString() == "99990101T000000") {
|
||||||
|
dispString = "";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dispString = mUppercase ? Utils::String::toUpper(getDisplayString(mode)) :
|
||||||
|
getDisplayString(mode);
|
||||||
|
}
|
||||||
std::shared_ptr<Font> font = getFont();
|
std::shared_ptr<Font> font = getFont();
|
||||||
mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor));
|
mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor));
|
||||||
|
|
||||||
|
@ -256,32 +272,35 @@ void DateTimeEditComponent::updateTextCache()
|
||||||
getParent()->onSizeChanged();
|
getParent()->onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dispString == "unknown " || dispString == "")
|
||||||
|
return;
|
||||||
|
|
||||||
// Set up cursor positions.
|
// Set up cursor positions.
|
||||||
mCursorBoxes.clear();
|
mCursorBoxes.clear();
|
||||||
|
|
||||||
if (dispString.empty() || mode == DISP_RELATIVE_TO_NOW)
|
if (dispString.empty() || mode == DISP_RELATIVE_TO_NOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Month.
|
// Year.
|
||||||
Vector2f start(0, 0);
|
Vector2f start(0, 0);
|
||||||
Vector2f end = font->sizeText(dispString.substr(0, 2));
|
Vector2f end = font->sizeText(dispString.substr(0, 4));
|
||||||
Vector2f diff = end - start;
|
Vector2f diff = end - start;
|
||||||
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1]));
|
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1]));
|
||||||
|
|
||||||
// Day.
|
// Month.
|
||||||
start[0] = font->sizeText(dispString.substr(0, 3)).x();
|
start[0] = font->sizeText(dispString.substr(0, 5)).x();
|
||||||
end = font->sizeText(dispString.substr(0, 5));
|
end = font->sizeText(dispString.substr(0, 7));
|
||||||
diff = end - start;
|
diff = end - start;
|
||||||
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1]));
|
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1]));
|
||||||
|
|
||||||
// Year.
|
// Day.
|
||||||
start[0] = font->sizeText(dispString.substr(0, 6)).x();
|
start[0] = font->sizeText(dispString.substr(0, 8)).x();
|
||||||
end = font->sizeText(dispString.substr(0, 10));
|
end = font->sizeText(dispString.substr(0, 10));
|
||||||
diff = end - start;
|
diff = end - start;
|
||||||
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1]));
|
mCursorBoxes.push_back(Vector4f(start[0], start[1], diff[0], diff[1]));
|
||||||
|
|
||||||
// The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but
|
// The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but
|
||||||
// nobody will use it anyway so it's not implemented.
|
// nobody will use it anyway so it's not worthwhile implementing.
|
||||||
}
|
}
|
||||||
|
|
||||||
void DateTimeEditComponent::setColor(unsigned int color)
|
void DateTimeEditComponent::setColor(unsigned int color)
|
||||||
|
|
|
@ -1,29 +1,38 @@
|
||||||
|
//
|
||||||
|
// RatingComponent.cpp
|
||||||
|
//
|
||||||
|
// Game rating icons.
|
||||||
|
// Used by gamelist views, metadata editor and scraper.
|
||||||
|
//
|
||||||
|
|
||||||
#include "components/RatingComponent.h"
|
#include "components/RatingComponent.h"
|
||||||
|
|
||||||
#include "resources/TextureResource.h"
|
#include "resources/TextureResource.h"
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
|
|
||||||
RatingComponent::RatingComponent(Window* window) : GuiComponent(window), mColorShift(0xFFFFFFFF), mUnfilledColor(0xFFFFFFFF)
|
RatingComponent::RatingComponent(Window* window) : GuiComponent(window),
|
||||||
|
mColorShift(0xFFFFFFFF), mUnfilledColor(0xFFFFFFFF)
|
||||||
{
|
{
|
||||||
mFilledTexture = TextureResource::get(":/star_filled.svg", true);
|
mFilledTexture = TextureResource::get(":/star_filled.svg", true);
|
||||||
mUnfilledTexture = TextureResource::get(":/star_unfilled.svg", true);
|
mUnfilledTexture = TextureResource::get(":/star_unfilled.svg", true);
|
||||||
mValue = 0.5f;
|
mValue = 0.5f;
|
||||||
mSize = Vector2f(64 * NUM_RATING_STARS, 64);
|
mSize = Vector2f(64 * NUM_RATING_STARS, 64);
|
||||||
|
mHideRatingComponent = false;
|
||||||
updateVertices();
|
updateVertices();
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatingComponent::setValue(const std::string& value)
|
void RatingComponent::setValue(const std::string& value)
|
||||||
{
|
{
|
||||||
if(value.empty())
|
if (value.empty()) {
|
||||||
{
|
|
||||||
mValue = 0.0f;
|
mValue = 0.0f;
|
||||||
}else{
|
}
|
||||||
// Round up to the closest .1 value, i.e. to the closest half-star
|
else {
|
||||||
|
// Round up to the closest .1 value, i.e. to the closest half-icon.
|
||||||
mValue = Math::ceilf(stof(value) / 0.1) / 10;
|
mValue = Math::ceilf(stof(value) / 0.1) / 10;
|
||||||
if(mValue > 1.0f)
|
if (mValue > 1.0f)
|
||||||
mValue = 1.0f;
|
mValue = 1.0f;
|
||||||
else if(mValue < 0.0f)
|
else if (mValue < 0.0f)
|
||||||
mValue = 0.0f;
|
mValue = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +41,8 @@ void RatingComponent::setValue(const std::string& value)
|
||||||
|
|
||||||
std::string RatingComponent::getValue() const
|
std::string RatingComponent::getValue() const
|
||||||
{
|
{
|
||||||
// do not use std::to_string here as it will use the current locale
|
// Do not use std::to_string here as it will use the current locale
|
||||||
// and that sometimes encodes decimals as commas
|
// and that sometimes encodes decimals as commas.
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << mValue;
|
ss << mValue;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
|
@ -41,6 +50,12 @@ std::string RatingComponent::getValue() const
|
||||||
|
|
||||||
void RatingComponent::setOpacity(unsigned char opacity)
|
void RatingComponent::setOpacity(unsigned char opacity)
|
||||||
{
|
{
|
||||||
|
// Completely hide component if opacity if set to zero.
|
||||||
|
if (opacity == 0)
|
||||||
|
mHideRatingComponent = true;
|
||||||
|
else
|
||||||
|
mHideRatingComponent = false;
|
||||||
|
|
||||||
mOpacity = opacity;
|
mOpacity = opacity;
|
||||||
mColorShift = (mColorShift >> 8 << 8) | mOpacity;
|
mColorShift = (mColorShift >> 8 << 8) | mOpacity;
|
||||||
updateColors();
|
updateColors();
|
||||||
|
@ -49,25 +64,24 @@ void RatingComponent::setOpacity(unsigned char opacity)
|
||||||
void RatingComponent::setColorShift(unsigned int color)
|
void RatingComponent::setColorShift(unsigned int color)
|
||||||
{
|
{
|
||||||
mColorShift = color;
|
mColorShift = color;
|
||||||
// Grab the opacity from the color shift because we may need to apply it if
|
// Grab the opacity from the color shift because we may need
|
||||||
// fading textures in
|
// to apply it if fading in textures.
|
||||||
mOpacity = color & 0xff;
|
mOpacity = color & 0xff;
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatingComponent::onSizeChanged()
|
void RatingComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
if(mSize.y() == 0)
|
if (mSize.y() == 0)
|
||||||
mSize[1] = mSize.x() / NUM_RATING_STARS;
|
mSize[1] = mSize.x() / NUM_RATING_STARS;
|
||||||
else if(mSize.x() == 0)
|
else if (mSize.x() == 0)
|
||||||
mSize[0] = mSize.y() * NUM_RATING_STARS;
|
mSize[0] = mSize.y() * NUM_RATING_STARS;
|
||||||
|
|
||||||
if(mSize.y() > 0)
|
if (mSize.y() > 0) {
|
||||||
{
|
|
||||||
size_t heightPx = (size_t)Math::round(mSize.y());
|
size_t heightPx = (size_t)Math::round(mSize.y());
|
||||||
if (mFilledTexture)
|
if (mFilledTexture)
|
||||||
mFilledTexture->rasterizeAt(heightPx, heightPx);
|
mFilledTexture->rasterizeAt(heightPx, heightPx);
|
||||||
if(mUnfilledTexture)
|
if (mUnfilledTexture)
|
||||||
mUnfilledTexture->rasterizeAt(heightPx, heightPx);
|
mUnfilledTexture->rasterizeAt(heightPx, heightPx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +91,7 @@ void RatingComponent::onSizeChanged()
|
||||||
void RatingComponent::updateVertices()
|
void RatingComponent::updateVertices()
|
||||||
{
|
{
|
||||||
const float numStars = NUM_RATING_STARS;
|
const float numStars = NUM_RATING_STARS;
|
||||||
const float h = getSize().y(); // is the same as a single star's width
|
const float h = getSize().y(); // Ss the same as a single star's width.
|
||||||
const float w = getSize().y() * mValue * numStars;
|
const float w = getSize().y() * mValue * numStars;
|
||||||
const float fw = getSize().y() * numStars;
|
const float fw = getSize().y() * numStars;
|
||||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||||
|
@ -92,16 +106,18 @@ void RatingComponent::updateVertices()
|
||||||
mVertices[6] = { { fw, 0.0f }, { numStars, 1.0f }, color };
|
mVertices[6] = { { fw, 0.0f }, { numStars, 1.0f }, color };
|
||||||
mVertices[7] = { { fw, h }, { numStars, 0.0f }, color };
|
mVertices[7] = { { fw, h }, { numStars, 0.0f }, color };
|
||||||
|
|
||||||
// round vertices
|
// Round vertices.
|
||||||
for(int i = 0; i < 8; ++i)
|
// Disabled as it caused subtle but strange rendering errors where
|
||||||
mVertices[i].pos.round();
|
// the icons changed size slightly when changing rating scores.
|
||||||
|
// for (int i = 0; i < 8; ++i)
|
||||||
|
// mVertices[i].pos.round();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatingComponent::updateColors()
|
void RatingComponent::updateColors()
|
||||||
{
|
{
|
||||||
const unsigned int color = Renderer::convertColor(mColorShift);
|
const unsigned int color = Renderer::convertColor(mColorShift);
|
||||||
|
|
||||||
for(int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
mVertices[i].col = color;
|
mVertices[i].col = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,15 +125,17 @@ void RatingComponent::render(const Transform4x4f& parentTrans)
|
||||||
{
|
{
|
||||||
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// If set to true, hide rating component.
|
||||||
|
if (mHideRatingComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
Transform4x4f trans = parentTrans * getTransform();
|
Transform4x4f trans = parentTrans * getTransform();
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mUnfilledTexture->bind())
|
if (mUnfilledTexture->bind()) {
|
||||||
{
|
if (mUnfilledColor != mColorShift) {
|
||||||
if (mUnfilledColor != mColorShift)
|
|
||||||
{
|
|
||||||
const unsigned int color = Renderer::convertColor(mUnfilledColor);
|
const unsigned int color = Renderer::convertColor(mUnfilledColor);
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
mVertices[i].col = color;
|
mVertices[i].col = color;
|
||||||
|
@ -130,22 +148,19 @@ void RatingComponent::render(const Transform4x4f& parentTrans)
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mFilledTexture->bind()) {
|
||||||
if (mFilledTexture->bind())
|
|
||||||
{
|
|
||||||
Renderer::drawTriangleStrips(&mVertices[0], 4);
|
Renderer::drawTriangleStrips(&mVertices[0], 4);
|
||||||
Renderer::bindTexture(0);
|
Renderer::bindTexture(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RatingComponent::input(InputConfig* config, Input input)
|
bool RatingComponent::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
if(config->isMappedTo("a", input) && input.value != 0)
|
if (config->isMappedTo("a", input) && input.value != 0) {
|
||||||
{
|
|
||||||
mValue += (1.f/2) / NUM_RATING_STARS;
|
mValue += (1.f/2) / NUM_RATING_STARS;
|
||||||
if(mValue > 1.05f)
|
if (mValue > 1.05f)
|
||||||
mValue = 0.0f;
|
mValue = 0.0f;
|
||||||
|
|
||||||
updateVertices();
|
updateVertices();
|
||||||
|
@ -154,30 +169,27 @@ bool RatingComponent::input(InputConfig* config, Input input)
|
||||||
return GuiComponent::input(config, input);
|
return GuiComponent::input(config, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatingComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties)
|
void RatingComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
const std::string& view, const std::string& element, unsigned int properties)
|
||||||
{
|
{
|
||||||
GuiComponent::applyTheme(theme, view, element, properties);
|
GuiComponent::applyTheme(theme, view, element, properties);
|
||||||
|
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "rating");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "rating");
|
||||||
if(!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool imgChanged = false;
|
bool imgChanged = false;
|
||||||
if(properties & PATH && elem->has("filledPath"))
|
if (properties & PATH && elem->has("filledPath")) {
|
||||||
{
|
|
||||||
mFilledTexture = TextureResource::get(elem->get<std::string>("filledPath"), true);
|
mFilledTexture = TextureResource::get(elem->get<std::string>("filledPath"), true);
|
||||||
imgChanged = true;
|
imgChanged = true;
|
||||||
}
|
}
|
||||||
if(properties & PATH && elem->has("unfilledPath"))
|
if (properties & PATH && elem->has("unfilledPath")) {
|
||||||
{
|
|
||||||
mUnfilledTexture = TextureResource::get(elem->get<std::string>("unfilledPath"), true);
|
mUnfilledTexture = TextureResource::get(elem->get<std::string>("unfilledPath"), true);
|
||||||
imgChanged = true;
|
imgChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties & COLOR)
|
if (properties & COLOR) {
|
||||||
{
|
|
||||||
if (elem->has("color"))
|
if (elem->has("color"))
|
||||||
setColorShift(elem->get<unsigned int>("color"));
|
setColorShift(elem->get<unsigned int>("color"));
|
||||||
|
|
||||||
|
@ -187,7 +199,7 @@ void RatingComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const
|
||||||
mUnfilledColor = mColorShift;
|
mUnfilledColor = mColorShift;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imgChanged)
|
if (imgChanged)
|
||||||
onSizeChanged();
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
//
|
||||||
|
// RatingComponent.h
|
||||||
|
//
|
||||||
|
// Game rating icons.
|
||||||
|
// Used by gamelist views, metadata editor and scraper.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_COMPONENTS_RATING_COMPONENT_H
|
#ifndef ES_APP_COMPONENTS_RATING_COMPONENT_H
|
||||||
#define ES_APP_COMPONENTS_RATING_COMPONENT_H
|
#define ES_APP_COMPONENTS_RATING_COMPONENT_H
|
||||||
|
@ -13,14 +20,15 @@ class TextureResource;
|
||||||
// setSize(x, y) works a little differently than you might expect:
|
// setSize(x, y) works a little differently than you might expect:
|
||||||
// * (0, y != 0) - x will be automatically calculated (5*y).
|
// * (0, y != 0) - x will be automatically calculated (5*y).
|
||||||
// * (x != 0, 0) - y will be automatically calculated (x/5).
|
// * (x != 0, 0) - y will be automatically calculated (x/5).
|
||||||
// * (x != 0, y != 0) - you better be sure x = y*5
|
// * (x != 0, y != 0) - you better be sure x = y*5.
|
||||||
class RatingComponent : public GuiComponent
|
class RatingComponent : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RatingComponent(Window* window);
|
RatingComponent(Window* window);
|
||||||
|
|
||||||
std::string getValue() const override;
|
std::string getValue() const override;
|
||||||
void setValue(const std::string& value) override; // Should be a normalized float (in the range [0..1]) - if it's not, it will be clamped.
|
// Should be a normalized float (in the range [0..1]) - if it's not, it will be clamped.
|
||||||
|
void setValue(const std::string& value) override;
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void render(const Transform4x4f& parentTrans);
|
void render(const Transform4x4f& parentTrans);
|
||||||
|
@ -32,7 +40,8 @@ public:
|
||||||
// Multiply all pixels in the image by this color when rendering.
|
// Multiply all pixels in the image by this color when rendering.
|
||||||
void setColorShift(unsigned int color);
|
void setColorShift(unsigned int color);
|
||||||
|
|
||||||
virtual void applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties) override;
|
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;
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
|
|
||||||
|
@ -46,6 +55,8 @@ private:
|
||||||
|
|
||||||
unsigned int mColorShift;
|
unsigned int mColorShift;
|
||||||
unsigned int mUnfilledColor;
|
unsigned int mUnfilledColor;
|
||||||
|
// If set to true, the rating component is hidden.
|
||||||
|
bool mHideRatingComponent;
|
||||||
|
|
||||||
std::shared_ptr<TextureResource> mFilledTexture;
|
std::shared_ptr<TextureResource> mFilledTexture;
|
||||||
std::shared_ptr<TextureResource> mUnfilledTexture;
|
std::shared_ptr<TextureResource> mUnfilledTexture;
|
||||||
|
|
Loading…
Reference in a new issue