2020-09-21 17:17:34 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-06 20:04:05 +00:00
|
|
|
//
|
2020-09-21 17:17:34 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// RatingComponent.h
|
2020-06-06 20:04:05 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Game rating icons.
|
|
|
|
// Used by gamelist views, metadata editor and scraper.
|
2020-06-06 20:04:05 +00:00
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_APP_COMPONENTS_RATING_COMPONENT_H
|
|
|
|
#define ES_APP_COMPONENTS_RATING_COMPONENT_H
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
#include "GuiComponent.h"
|
2022-08-28 18:11:20 +00:00
|
|
|
#include "components/ImageComponent.h"
|
2021-07-07 18:31:46 +00:00
|
|
|
#include "renderers/Renderer.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
class TextureResource;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-08-28 18:11:20 +00:00
|
|
|
#define NUM_RATING_STARS 5.0f
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
class RatingComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2022-09-03 19:43:36 +00:00
|
|
|
RatingComponent(bool colorizeChanges = false, bool linearInterpolation = false);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string getValue() const override;
|
2022-06-06 20:28:24 +00:00
|
|
|
// Returns a rating value between 0 and 5 as a string.
|
|
|
|
static std::string getRatingValue(const std::string& rating);
|
2020-06-21 12:25:28 +00:00
|
|
|
// 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;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
bool input(InputConfig* config, Input input) override;
|
2021-08-15 17:30:31 +00:00
|
|
|
void render(const glm::mat4& parentTrans) override;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void onSizeChanged() override;
|
2022-03-21 19:35:24 +00:00
|
|
|
void setDimming(float dimming) override;
|
2023-05-07 20:56:24 +00:00
|
|
|
unsigned int getColorShift() const override { return mIconFilled.getColorShift(); }
|
|
|
|
void setColorShift(unsigned int color) override { mIconFilled.setColorShift(color); }
|
2017-06-08 23:18:27 +00:00
|
|
|
|
2021-07-07 18:31:46 +00:00
|
|
|
void setOriginalColor(unsigned int color) override { mColorOriginalValue = color; }
|
|
|
|
void setChangedColor(unsigned int color) override { mColorChangedValue = color; }
|
2020-07-15 15:44:27 +00:00
|
|
|
|
2022-01-18 16:40:47 +00:00
|
|
|
void applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|
|
|
const std::string& view,
|
|
|
|
const std::string& element,
|
|
|
|
unsigned int properties) override;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-01-18 16:40:47 +00:00
|
|
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
private:
|
2022-03-14 18:51:48 +00:00
|
|
|
Renderer* mRenderer;
|
2022-08-28 18:11:20 +00:00
|
|
|
ImageComponent mIconFilled;
|
|
|
|
ImageComponent mIconUnfilled;
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
float mValue;
|
2022-09-01 15:40:29 +00:00
|
|
|
float mImageRatio;
|
2020-07-15 15:44:27 +00:00
|
|
|
int mOriginalValue;
|
2022-08-28 18:11:20 +00:00
|
|
|
|
2020-07-15 15:44:27 +00:00
|
|
|
unsigned int mColorOriginalValue;
|
|
|
|
unsigned int mColorChangedValue;
|
|
|
|
|
|
|
|
bool mColorizeChanges;
|
2022-09-01 15:40:29 +00:00
|
|
|
bool mOverlay;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#endif // ES_APP_COMPONENTS_RATING_COMPONENT_H
|