mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15: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;
|
||||
|
||||
if (metadata == "rating") {
|
||||
text->setValue(mRatingComponents.front()->getRatingValue());
|
||||
text->setValue(RatingComponent::getRatingValue(file->metadata.get("rating")));
|
||||
continue;
|
||||
}
|
||||
else if (metadata == "controller") {
|
||||
|
@ -717,7 +717,7 @@ void GamelistView::updateInfoPanel(const CursorState& state)
|
|||
continue;
|
||||
|
||||
if (metadata == "rating") {
|
||||
text->setValue(mRatingComponents.front()->getRatingValue());
|
||||
text->setValue(RatingComponent::getRatingValue(file->metadata.get("rating")));
|
||||
continue;
|
||||
}
|
||||
else if (metadata == "controller") {
|
||||
|
|
|
@ -76,10 +76,10 @@ std::string RatingComponent::getValue() const
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
std::string RatingComponent::getRatingValue() const
|
||||
std::string RatingComponent::getRatingValue(const std::string& rating)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << mValue * NUM_RATING_STARS;
|
||||
ss << (std::round(stof(rating) / 0.1f) / 10.0f) * NUM_RATING_STARS;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,8 @@ public:
|
|||
RatingComponent(bool colorizeChanges = false);
|
||||
|
||||
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.
|
||||
void setValue(const std::string& value) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue