Mana
Loading...
Searching...
No Matches
userpalette.h
Go to the documentation of this file.
1/*
2 * Configurable text colors
3 * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
4 * Copyright (C) 2009 The Mana World Development Team
5 * Copyright (C) 2009-2012 The Mana Developers
6 *
7 * This file is part of The Mana Client.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#pragma once
24
25#include "gui/palette.h"
26
27#include <guichan/listmodel.hpp>
28
32class UserPalette : public Palette, public gcn::ListModel
33{
34 public:
36 enum {
56 };
57
59
60 ~UserPalette() override;
61
69 const gcn::Color &getCommittedColor(int type)
70 {
71 return mColors[type].committedColor;
72 }
73
81 const gcn::Color &getTestColor(int type)
82 {
83 return mColors[type].testColor;
84 }
85
92 void setTestColor(int type, const gcn::Color &color)
93 {
94 mColors[type].testColor = color;
95 }
96
105 void setColor(int type, int r, int g, int b);
106
112 void setGradient(int type, Palette::GradientType grad);
113
117 void setGradientDelay(int type, int delay)
118 { mColors[type].delay = delay; }
119
125 int getNumberOfElements() override { return mColors.size(); }
126
134 std::string getElementAt(int i) override;
135
139 void commit()
140 {
141 commit(false);
142 }
143
147 void rollback();
148
157 int getColorTypeAt(int i);
158
159 private:
168 void setColorAt(int i, int r, int g, int b);
169
174 void commit(bool commitNonStatic);
175
182 void addColor(int type, unsigned int rgb, GradientType grad,
183 const std::string &text, int delay = GRADIENT_DELAY);
184};
185
Class controlling the game's color palette.
Definition palette.h:42
std::vector< ColorElem > mColors
Vector containing the colors.
Definition palette.h:157
GradientType
Colors can be static or can alter over time.
Definition palette.h:53
Class controlling the game's color palette.
Definition userpalette.h:33
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
Definition userpalette.h:51
@ HIT_LOCAL_PLAYER_MISS
Definition userpalette.h:53
@ HIT_LOCAL_PLAYER_CRITICAL
Definition userpalette.h:52
std::string getElementAt(int i) override
Returns the name of the ith color.
void commit()
Commit the colors.
void setTestColor(int type, const gcn::Color &color)
Sets the test color associated with the specified type.
Definition userpalette.h:92
const gcn::Color & getCommittedColor(int type)
Gets the committed color associated with the specified type.
Definition userpalette.h:69
const gcn::Color & getTestColor(int type)
Gets the test color associated with the specified type.
Definition userpalette.h:81
void setGradientDelay(int type, int delay)
Sets the gradient delay for the specified color.
int getNumberOfElements() override
Returns the number of colors known.
~UserPalette() override
void addColor(int type, unsigned int rgb, GradientType grad, const std::string &text, int delay=GRADIENT_DELAY)
Initialise color.
void setColorAt(int i, int r, int g, int b)
Define a color replacement.
constexpr int GRADIENT_DELAY
Definition palette.h:36
UserPalette * userPalette
Definition client.cpp:103