diff options
Diffstat (limited to 'src/gui/palette.h')
-rw-r--r-- | src/gui/palette.h | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/src/gui/palette.h b/src/gui/palette.h index 145a93ac..268b9fc6 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -27,8 +27,9 @@ #include <guichan/color.hpp> #include <cstdlib> -#include <string> +#include <optional> #include <set> +#include <string> #include <vector> // Default Gradient Delay @@ -40,8 +41,13 @@ constexpr int GRADIENT_DELAY = 40; class Palette { public: - /** Black Color Constant */ - static const gcn::Color BLACK; + Palette(int size); + Palette(const Palette &) = delete; + Palette(Palette &&); + ~Palette(); + + Palette &operator=(const Palette &) = delete; + Palette &operator=(Palette &&); /** Colors can be static or can alter over time. */ enum GradientType { @@ -51,62 +57,49 @@ class Palette RAINBOW }; - /** - * Returns the color associated with a character, if it exists. Returns - * Palette::BLACK if the character is not found. - * - * @param c character requested - * @param valid indicate whether character is known - * - * @return the requested color or Palette::BLACK - */ - const gcn::Color &getColor(char c, bool &valid); + void setColor(int type, + const gcn::Color &color, + const std::optional<gcn::Color> &outlineColor, + GradientType grad, + int delay); /** - * Gets the color associated with the type. Sets the alpha channel - * before returning. + * Gets the color associated with the type. * * @param type the color type requested - * @param alpha alpha channel to use - * * @return the requested color */ - const gcn::Color &getColor(int type, int alpha = 255) + const gcn::Color &getColor(int type) const { - gcn::Color &col = mColors[type].color; - col.a = alpha; - return col; + return mColors[type].color; } /** - * Gets the GradientType associated with the specified type. + * Gets the optional outline color associated with the type. * - * @param type the color type of the color - * - * @return the gradient type of the color with the given index + * @param type the color type requested + * @return the requested outline color, if any */ - GradientType getGradientType(int type) const + const std::optional<gcn::Color> &getOutlineColor(int type) const { - return mColors[type].grad; + return mColors[type].outlineColor; } /** - * Get the character used by the specified color. + * Gets the GradientType associated with the specified type. * * @param type the color type of the color - * - * @return the color char of the color with the given index + * @return the gradient type of the color with the given index */ - char getColorChar(int type) const + GradientType getGradientType(int type) const { - return mColors[type].ch; + return mColors[type].grad; } /** * Gets the gradient delay for the specified type. * * @param type the color type of the color - * * @return the gradient delay of the color with the given index */ int getGradientDelay(int type) const @@ -128,10 +121,6 @@ class Palette using Palettes = std::set<Palette *>; static Palettes mInstances; - Palette(int size); - - ~Palette(); - void advanceGradient(int advance); struct ColorElem @@ -140,8 +129,8 @@ class Palette gcn::Color color; gcn::Color testColor; gcn::Color committedColor; + std::optional<gcn::Color> outlineColor; std::string text; - char ch; GradientType grad; GradientType committedGrad; int gradientIndex; |