30static constexpr const char *ColorTypeNames[] = {
45 "HitLocalPlayerMonster",
46 "HitLocalPlayerCritical",
73 _(
"Other Player Hits Monster"));
77 _(
"Local Player Hits Monster"));
79 _(
"Local Player Critical Hit"));
81 _(
"Local Player Miss"));
93 auto &configColor =
config.
colors[ColorTypeNames[color.type]];
95 configColor.gradient = color.committedGrad;
98 configColor.delay = color.delay;
101 configColor.color =
strprintf(
"0x%06x", color.getRGB());
131 if (elem->
grad != grad)
150 color.committedGrad = color.grad;
151 color.committedDelay = color.delay;
152 if (commitNonStatic || color.grad ==
STATIC)
154 color.committedColor = color.color;
156 else if (color.grad ==
PULSE)
158 color.committedColor = color.testColor;
167 if (color.grad != color.committedGrad)
172 setColor(color.type, color.committedColor.r,
173 color.committedColor.g, color.committedColor.b);
174 if (color.grad ==
PULSE)
176 color.testColor.r = color.committedColor.r;
177 color.testColor.g = color.committedColor.g;
178 color.testColor.b = color.committedColor.b;
194 const std::string &text,
int delay)
196 auto colorIt =
config.
colors.find(ColorTypeNames[type]);
199 const UserColor &userColor = colorIt->second;
205 mColors[type].set(type, gcn::Color(rgb), grad, delay);
Class controlling the game's color palette.
std::vector< ColorElem * > mGradVector
std::vector< ColorElem > mColors
Vector containing the colors.
GradientType
Colors can be static or can alter over time.
void setColor(int type, int r, int g, int b)
Sets the color for the specified type.
void rollback()
Rollback the colors.
void setGradient(int type, Palette::GradientType grad)
Sets the gradient type for the specified color.
int getColorTypeAt(int i)
Gets the ColorType used by the color for the element at index i in the current color model.
@ HIT_LOCAL_PLAYER_MONSTER
@ HIT_LOCAL_PLAYER_CRITICAL
std::string getElementAt(int i) override
Returns the name of the ith color.
void commit()
Commit the colors.
void setGradientDelay(int type, int delay)
Sets the gradient delay for the specified color.
int getNumberOfElements() override
Returns the number of colors known.
void addColor(int type, unsigned int rgb, GradientType grad, const std::string &text, int delay=GRADIENT_DELAY)
Initialise color.
Config config
Global settings (config.xml)
constexpr int GRADIENT_DELAY
unsigned int atox(const std::string &str)
Converts an ascii hexidecimal string to an integer.
std::string strprintf(char const *format,...)
A safe version of sprintf that returns a std::string of the result.
std::map< std::string, UserColor > colors
std::optional< int > delay