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"
|
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
|
|
|
|
|
|
|
#define NUM_RATING_STARS 5
|
|
|
|
|
|
|
|
class RatingComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2022-01-19 17:01:54 +00:00
|
|
|
RatingComponent(bool colorizeChanges = 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;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-02-11 21:10:25 +00:00
|
|
|
void setOpacity(float opacity) override;
|
2022-03-21 19:35:24 +00:00
|
|
|
void setDimming(float dimming) override;
|
2017-06-08 23:18:27 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Multiply all pixels in the image by this color when rendering.
|
2020-06-25 17:52:38 +00:00
|
|
|
void setColorShift(unsigned int color) override;
|
2021-07-07 18:31:46 +00:00
|
|
|
unsigned int getColorShift() const override { return mColorShift; }
|
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:
|
2020-06-21 12:25:28 +00:00
|
|
|
void updateVertices();
|
|
|
|
void updateColors();
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2022-03-14 18:51:48 +00:00
|
|
|
Renderer* mRenderer;
|
2020-06-21 12:25:28 +00:00
|
|
|
float mValue;
|
2020-07-15 15:44:27 +00:00
|
|
|
int mOriginalValue;
|
|
|
|
unsigned int mColorOriginalValue;
|
|
|
|
unsigned int mColorChangedValue;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
Renderer::Vertex mVertices[8];
|
2017-06-08 23:18:27 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
unsigned int mColorShift;
|
|
|
|
unsigned int mColorShiftEnd;
|
|
|
|
unsigned int mUnfilledColor;
|
2017-06-08 23:18:27 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::shared_ptr<TextureResource> mFilledTexture;
|
|
|
|
std::shared_ptr<TextureResource> mUnfilledTexture;
|
2020-07-15 15:44:27 +00:00
|
|
|
|
|
|
|
bool mColorizeChanges;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#endif // ES_APP_COMPONENTS_RATING_COMPONENT_H
|