ManaPlus
|
#include <userpalette.h>
Public Member Functions | |
UserPalette () | |
~UserPalette () | |
const Color & | getCommittedColor (const UserColorIdT type) const |
const Color & | getTestColor (const UserColorIdT type) const |
void | setTestColor (const UserColorIdT type, const Color &color) |
void | setColor (const UserColorIdT type, const int r, const int g, const int b) |
void | setGradient (const UserColorIdT type, const GradientTypeT grad) |
void | setGradientDelay (const UserColorIdT type, const int delay) |
int | getNumberOfElements () |
std::string | getElementAt (int i) |
void | commit () |
void | rollback () |
int | getColorTypeAt (const int i) |
const Color & | getColor (UserColorIdT type, const unsigned int alpha) |
int | getIdByChar (const signed char c, bool &valid) const |
GradientTypeT | getGradientType (const UserColorIdT type) const |
int | getGradientDelay (const UserColorIdT type) const |
const Color & | getColorWithAlpha (const UserColorIdT type) |
Public Member Functions inherited from Palette | |
const Color & | getCharColor (const signed char c, bool &valid) const |
char | getColorChar (const int type) const |
Public Member Functions inherited from ListModel | |
ListModel () | |
virtual | ~ListModel () |
Private Member Functions | |
void | setColorAt (int i, int r, int g, int b) |
void | commit (const bool commitNonStatic) |
void | addColor (const UserColorIdT type, const unsigned rgb, GradientTypeT grad, const std::string &text, int delay) |
void | addLabel (const UserColorIdT type, const std::string &text) |
Static Private Member Functions | |
static std::string | getConfigName (const std::string &typeName) |
Additional Inherited Members | |
Static Public Member Functions inherited from Palette | |
static void | advanceGradients () |
Static Public Attributes inherited from Palette | |
static const Color | BLACK = Color(0, 0, 0, 255) |
Protected Types inherited from Palette | |
typedef std::set< Palette * > | Palettes |
typedef std::vector< ColorElem > | Colors |
typedef std::map< unsigned char, int > | CharColors |
Protected Member Functions inherited from Palette | |
Palette (const int size) | |
virtual | ~Palette () |
void | advanceGradient () |
Protected Attributes inherited from Palette | |
int | mRainbowTime |
Colors | mColors |
CharColors | mCharColors |
std::vector< ColorElem * > | mGradVector |
Static Protected Attributes inherited from Palette | |
static const Color | RAINBOW_COLORS [7] |
static const int | RAINBOW_COLOR_COUNT = 7 |
static Palettes | mInstances |
Class controlling the game's color palette.
Definition at line 39 of file userpalette.h.
UserPalette::UserPalette | ( | ) |
Constructor
Definition at line 128 of file userpalette.cpp.
References _, addColor(), addLabel(), UserColorId::AIR_COLLISION_HIGHLIGHT, UserColorId::ATTACK_RANGE, UserColorId::ATTACK_RANGE_BORDER, UserColorId::BEING, CAST_SIZE, UserColorId::COLLISION_HIGHLIGHT, commit(), UserColorId::DISREGARDED, UserColorId::ELEMENTAL_HP, UserColorId::ELEMENTAL_HP2, UserColorId::ENEMY, UserColorId::ERASED, UserColorId::EXP_INFO, UserColorId::FLOOR_ITEM_TEXT, UserColorId::FRIEND, UserColorId::GM, GRADIENT_DELAY, UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT, UserColorId::GUILD, UserColorId::HIT_CRITICAL, UserColorId::HIT_LOCAL_PLAYER_CRITICAL, UserColorId::HIT_LOCAL_PLAYER_MISS, UserColorId::HIT_LOCAL_PLAYER_MONSTER, UserColorId::HIT_MONSTER_PLAYER, UserColorId::HIT_PLAYER_MONSTER, UserColorId::HIT_PLAYER_PLAYER, UserColorId::HOME_PLACE, UserColorId::HOME_PLACE_BORDER, UserColorId::HOMUN_HP, UserColorId::HOMUN_HP2, UserColorId::HOMUNCULUS, UserColorId::IGNORED, UserColorId::LABEL_BEING, UserColorId::LABEL_HITS, UserColorId::LABEL_HP, UserColorId::LABEL_OTHER, UserColorId::LABEL_PARTICLES, UserColorId::LABEL_RANGES, UserColorId::LABEL_TILES, Palette::mColors, UserColorId::MERC_HP, UserColorId::MERC_HP2, UserColorId::MERCENARY, UserColorId::MISS, UserColorId::MONSTER, UserColorId::MONSTER_ATTACK_RANGE, UserColorId::MONSTER_COLLISION_HIGHLIGHT, UserColorId::MONSTER_HP, UserColorId::MONSTER_HP2, UserColorId::NET, UserColorId::NPC, UserColorId::PARTICLE, UserColorId::PARTY, UserColorId::PC, UserColorId::PET, UserColorId::PICKUP_INFO, UserColorId::PLAYER_HP, UserColorId::PLAYER_HP2, UserColorId::PORTAL_HIGHLIGHT, GradientType::RAINBOW, UserColorId::ROAD_POINT, UserColorId::SELF, UserColorId::SKILL_ATTACK_RANGE, UserColorId::SKILLUNIT, GradientType::STATIC, strprintf(), UserColorId::TEAM1, UserColorId::TEAM2, UserColorId::TEAM3, UserColorId::WALKABLE_HIGHLIGHT, and UserColorId::WATER_COLLISION_HIGHLIGHT.
UserPalette::~UserPalette | ( | ) |
Destructor
Definition at line 502 of file userpalette.cpp.
References CAST_S32, ColorTypeNames, config, FOR_EACH, GradientType::LABEL, Palette::mColors, GradientType::PULSE, Configuration::setValue(), and GradientType::STATIC.
|
private |
Definition at line 616 of file userpalette.cpp.
References atox(), CAST_S32, CAST_SIZE, CAST_U32, ColorTypeNames, config, ConfigurationObject::getValue(), ConfigurationObject::getValueInt(), Palette::mColors, Palette::mGradVector, and GradientType::STATIC.
Referenced by UserPalette().
|
private |
Definition at line 653 of file userpalette.cpp.
References CAST_SIZE, CAST_U32, ColorTypeNames, GradientType::LABEL, and Palette::mColors.
Referenced by UserPalette().
|
inline |
Commit the colors
Definition at line 133 of file userpalette.h.
Referenced by Setup_Colors::apply(), and UserPalette().
|
private |
Commit the colors. Commit the non-static color values, if commitNonStatic is true. Only needed in the constructor.
Definition at line 570 of file userpalette.cpp.
References FOR_EACH, Palette::mColors, GradientType::PULSE, and GradientType::STATIC.
|
inline |
Gets the color associated with the type. Sets the alpha channel before returning.
type | the color type requested |
alpha | alpha channel to use |
Definition at line 160 of file userpalette.h.
References Color::a, UserColorId::BEING, CAST_S32, CAST_SIZE, CAST_U32, Logger::log(), logger, and Palette::mColors.
Referenced by Setup_Colors::cancel(), FloorItem::draw(), MapItem::draw(), Minimap::draw2(), Being::drawPortalSpriteAt(), LocalPlayer::LocalPlayer(), LocalPlayer::logic(), Being::setDefaultNameColor(), Being::setSpeech(), Being::takeDamage(), Being::updateColors(), and Setup_Colors::valueChanged().
int UserPalette::getColorTypeAt | ( | const int | i | ) |
Gets the ColorType used by the color for the element at index i in the current color model.
i | the index of the color |
Definition at line 608 of file userpalette.cpp.
References getNumberOfElements(), and Palette::mColors.
Referenced by Setup_Colors::cancel(), Setup_Colors::updateColor(), Setup_Colors::updateGradType(), and Setup_Colors::valueChanged().
|
inline |
Definition at line 200 of file userpalette.h.
References Color::a, CAST_SIZE, CAST_U32, and Palette::mColors.
Referenced by CastingEffect::draw(), MapItem::draw(), Map::draw(), Map::drawCollision(), Being::drawElementalSpriteAt(), MapLayer::drawFringe(), Being::drawHomunculusSpriteAt(), Being::drawHpBar(), Being::drawMercenarySpriteAt(), and Being::drawMonsterSpriteAt().
|
inline |
Gets the committed color associated with the specified type.
type | the color type requested |
Definition at line 61 of file userpalette.h.
References CAST_SIZE, and Palette::mColors.
Referenced by Setup_Colors::valueChanged().
|
staticprivate |
Prefixes the given string with "Color", lowercases all letters but the first and all following a '_'. All '_'s will be removed.
E.g.: HIT_PLAYER_MONSTER -> HitPlayerMonster
typeName | string to transform |
Definition at line 105 of file userpalette.cpp.
References CAST_S8.
|
virtual |
Returns the name of the ith color.
i | index of color interested in |
Implements ListModel.
Definition at line 562 of file userpalette.cpp.
References getNumberOfElements(), and Palette::mColors.
|
inline |
Gets the gradient delay for the specified type.
type | the color type of the color |
Definition at line 196 of file userpalette.h.
References CAST_SIZE, and Palette::mColors.
Referenced by Setup_Colors::cancel(), and Setup_Colors::valueChanged().
|
inline |
Gets the GradientType associated with the specified type.
type | the color type of the color |
Definition at line 185 of file userpalette.h.
References CAST_SIZE, and Palette::mColors.
Referenced by Setup_Colors::cancel(), Setup_Colors::updateGradType(), and Setup_Colors::valueChanged().
int UserPalette::getIdByChar | ( | const signed char | c, |
bool & | valid | ||
) | const |
Definition at line 671 of file userpalette.cpp.
References Palette::mCharColors, and anonymous_namespace{libxml.cpp}::valid.
|
inlinevirtual |
Returns the number of colors known.
Implements ListModel.
Definition at line 118 of file userpalette.h.
References CAST_S32, and Palette::mColors.
Referenced by getColorTypeAt(), and getElementAt().
|
inline |
Gets the test color associated with the specified type.
type | the color type requested |
Definition at line 74 of file userpalette.h.
References CAST_SIZE, and Palette::mColors.
Referenced by Setup_Colors::valueChanged().
void UserPalette::rollback | ( | ) |
Rollback the colors
Definition at line 583 of file userpalette.cpp.
References Color::b, FOR_EACH, Color::g, Palette::mColors, GradientType::PULSE, Color::r, setColor(), setGradient(), and setGradientDelay().
Referenced by Setup_Colors::cancel().
void UserPalette::setColor | ( | const UserColorIdT | type, |
const int | r, | ||
const int | g, | ||
const int | b | ||
) |
Sets the color for the specified type.
type | color to be set |
r | red component |
g | green component |
b | blue component |
Definition at line 524 of file userpalette.cpp.
References Color::b, CAST_SIZE, Color::g, Palette::mColors, and Color::r.
Referenced by rollback(), and Setup_Colors::updateColor().
|
private |
Define a color replacement.
i | the index of the color to replace |
r | red component |
g | green component |
b | blue component |
void UserPalette::setGradient | ( | const UserColorIdT | type, |
const GradientTypeT | grad | ||
) |
Sets the gradient type for the specified color.
grad | gradient type to set |
Definition at line 535 of file userpalette.cpp.
References CAST_SIZE, Palette::ColorElem::grad, Palette::mColors, Palette::mGradVector, and GradientType::STATIC.
Referenced by rollback(), and Setup_Colors::updateColor().
|
inline |
Definition at line 109 of file userpalette.h.
References CAST_SIZE, and Palette::mColors.
Referenced by rollback(), and Setup_Colors::updateColor().
|
inline |
Sets the test color associated with the specified type.
type | the color type requested |
color | the color that should be tested |
Definition at line 84 of file userpalette.h.
References CAST_SIZE, and Palette::mColors.
Referenced by Setup_Colors::updateColor().