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
|
|
|
|
2019-08-08 20:16:11 +00:00
|
|
|
#include "renderers/Renderer.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "GuiComponent.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
class TextureResource;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
#define NUM_RATING_STARS 5
|
|
|
|
|
|
|
|
// Used to visually display/edit some sort of "score" - e.g. 5/10, 3/5, etc.
|
|
|
|
// setSize(x, y) works a little differently than you might expect:
|
|
|
|
// * (0, y != 0) - x will be automatically calculated (5*y).
|
|
|
|
// * (x != 0, 0) - y will be automatically calculated (x/5).
|
2020-06-06 20:04:05 +00:00
|
|
|
// * (x != 0, y != 0) - you better be sure x = y*5.
|
2014-06-25 16:29:58 +00:00
|
|
|
class RatingComponent : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-07-15 15:44:27 +00:00
|
|
|
RatingComponent(Window* window, bool colorizeChanges = false);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::string getValue() const override;
|
|
|
|
// 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;
|
2020-06-25 17:52:38 +00:00
|
|
|
void render(const Transform4x4f& 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
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void setOpacity(unsigned char opacity) 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;
|
2020-11-08 12:03:45 +00:00
|
|
|
unsigned int getColorShift() const override { return mColorShift; };
|
2017-06-08 23:18:27 +00:00
|
|
|
|
2020-07-15 15:44:27 +00:00
|
|
|
void setOriginalColor(unsigned int color) override { mColorOriginalValue = color; };
|
|
|
|
void setChangedColor(unsigned int color) override { mColorChangedValue = color; };
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
virtual 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
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
private:
|
2020-06-21 12:25:28 +00:00
|
|
|
Vector2f mTargetSize;
|
2020-06-09 18:03:31 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void updateVertices();
|
|
|
|
void updateColors();
|
2014-06-25 16:29:58 +00:00
|
|
|
|
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
|