mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Fixed an issue where using a text rating without a rating element in the gamelist view would crash the application.
This commit is contained in:
parent
ed0837824e
commit
2e3ac5bf0e
|
@ -698,7 +698,7 @@ void GamelistView::updateInfoPanel(const CursorState& state)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (metadata == "rating") {
|
if (metadata == "rating") {
|
||||||
text->setValue(mRatingComponents.front()->getRatingValue());
|
text->setValue(RatingComponent::getRatingValue(file->metadata.get("rating")));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (metadata == "controller") {
|
else if (metadata == "controller") {
|
||||||
|
@ -717,7 +717,7 @@ void GamelistView::updateInfoPanel(const CursorState& state)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (metadata == "rating") {
|
if (metadata == "rating") {
|
||||||
text->setValue(mRatingComponents.front()->getRatingValue());
|
text->setValue(RatingComponent::getRatingValue(file->metadata.get("rating")));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (metadata == "controller") {
|
else if (metadata == "controller") {
|
||||||
|
|
|
@ -76,10 +76,10 @@ std::string RatingComponent::getValue() const
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RatingComponent::getRatingValue() const
|
std::string RatingComponent::getRatingValue(const std::string& rating)
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << mValue * NUM_RATING_STARS;
|
ss << (std::round(stof(rating) / 0.1f) / 10.0f) * NUM_RATING_STARS;
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ public:
|
||||||
RatingComponent(bool colorizeChanges = false);
|
RatingComponent(bool colorizeChanges = false);
|
||||||
|
|
||||||
std::string getValue() const override;
|
std::string getValue() const override;
|
||||||
std::string getRatingValue() const;
|
// Returns a rating value between 0 and 5 as a string.
|
||||||
|
static std::string getRatingValue(const std::string& rating);
|
||||||
// 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;
|
void setValue(const std::string& value) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue