ManaPlus
Public Member Functions | Private Member Functions | Static Private Member Functions
UserPalette Class Reference

#include <userpalette.h>

Inheritance diagram for UserPalette:
Palette ListModel

Public Member Functions

 UserPalette ()
 
 ~UserPalette ()
 
const ColorgetCommittedColor (const UserColorIdT type) const
 
const ColorgetTestColor (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 ColorgetColor (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 ColorgetColorWithAlpha (const UserColorIdT type)
 
- Public Member Functions inherited from Palette
const ColorgetCharColor (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< ColorElemColors
 
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
 

Detailed Description

Class controlling the game's color palette.

Definition at line 38 of file userpalette.h.

Constructor & Destructor Documentation

◆ UserPalette()

UserPalette::UserPalette ( )

Constructor

Definition at line 127 of file userpalette.cpp.

127  :
129  ListModel()
130 {
131  mColors[CAST_SIZE(UserColorId::BEING)] = ColorElem();
132  mColors[CAST_SIZE(UserColorId::PC)] = ColorElem();
133  mColors[CAST_SIZE(UserColorId::SELF)] = ColorElem();
134  mColors[CAST_SIZE(UserColorId::GM)] = ColorElem();
135  mColors[CAST_SIZE(UserColorId::NPC)] = ColorElem();
136  mColors[CAST_SIZE(UserColorId::MONSTER)] = ColorElem();
137 
139  // TRANSLATORS: palette label
140  _("Beings"));
142  0xffffff,
144  // TRANSLATORS: palette color
145  _("Being"),
148  0xb0ffb0,
150  // TRANSLATORS: palette color
151  _("Friend names"),
154  0xa00000,
156  // TRANSLATORS: palette color
157  _("Disregarded names"),
160  0xff0000,
162  // TRANSLATORS: palette color
163  _("Ignored names"),
166  0xff0000,
168  // TRANSLATORS: palette color
169  _("Erased names"),
172  0xff4040,
174  // TRANSLATORS: palette color
175  _("Enemy"),
178  0xffffff,
180  // TRANSLATORS: palette color
181  _("Other players names"),
184  0xff8040,
186  // TRANSLATORS: palette color
187  _("Own name"),
190  0x00ff00,
192  // TRANSLATORS: palette color
193  _("GM names"),
196  0xc8c8ff,
198  // TRANSLATORS: palette color
199  _("NPCs"),
202  0xff4040,
204  // TRANSLATORS: palette color
205  _("Monsters"),
208  0xffffff,
210  // TRANSLATORS: palette color
211  _("Pets"),
214  0xffffff,
216  // TRANSLATORS: palette color
217  _("Mercenary"),
220  0xffffff,
222  // TRANSLATORS: palette color
223  _("Homunculus"),
226  0xffffff,
228  // TRANSLATORS: palette color
229  _("Skill unit"),
232  0xff00d8,
234  // TRANSLATORS: palette color
235  _("Party members"),
238  0xff00d8,
240  // TRANSLATORS: palette color
241  _("Guild members"),
244  0x0000ff,
246  // TRANSLATORS: palette color
247  strprintf(_("Team %d"), 1),
250  0x00a020,
252  // TRANSLATORS: palette color
253  strprintf(_("Team %d"), 2),
256  0xffff20,
258  // TRANSLATORS: palette color
259  strprintf(_("Team %d"), 3),
262  // TRANSLATORS: palette label
263  _("Particles"));
265  0xffffff,
267  // TRANSLATORS: palette color
268  _("Particle effects"),
271  0x28dc28,
273  // TRANSLATORS: palette color
274  _("Pickup notification"),
277  0xffff00,
279  // TRANSLATORS: palette color
280  _("Exp notification"),
283  // TRANSLATORS: palette label
284  _("Hp bars"));
286  0x00ff00,
288  // TRANSLATORS: palette color
289  _("Player HP bar"), 50);
291  0xff0000,
293  // TRANSLATORS: palette color
294  _("Player HP bar (second color)"),
295  50);
297  0x00ff00,
299  // TRANSLATORS: palette color
300  _("Monster HP bar"),
301  50);
303  0xff0000,
305  // TRANSLATORS: palette color
306  _("Monster HP bar (second color)"),
307  50);
309  0x00ff00,
311  // TRANSLATORS: palette color
312  _("Homunculus HP bar"),
313  50);
315  0xff0000,
317  // TRANSLATORS: palette color
318  _("Homunculus HP bar (second color)"),
319  50);
321  0x00ff00,
323  // TRANSLATORS: palette color
324  _("Mercenary HP bar"),
325  50);
327  0xff0000,
329  // TRANSLATORS: palette color
330  _("Mercenary HP bar (second color)"),
331  50);
332 
334  0x00ff00,
336  // TRANSLATORS: palette color
337  _("Elemental HP bar"),
338  50);
340  0xff0000,
342  // TRANSLATORS: palette color
343  _("Elemental HP bar (second color)"),
344  50);
346  // TRANSLATORS: palette label
347  _("Hits"));
349  0x0064ff,
351  // TRANSLATORS: palette color
352  _("Player hits monster"),
355  0xff3232,
357  // TRANSLATORS: palette color
358  _("Monster hits player"),
361  0xff5050,
363  // TRANSLATORS: palette color
364  _("Other player hits local player"),
367  0xff0000,
369  // TRANSLATORS: palette color
370  _("Critical Hit"),
373  0x00ff00,
375  // TRANSLATORS: palette color
376  _("Local player hits monster"),
379  0xff0000,
381  // TRANSLATORS: palette color
382  _("Local player critical hit"),
385  0x00ffa6,
387  // TRANSLATORS: palette color
388  _("Local player miss"),
390  addColor(UserColorId::MISS, 0xffff00,
392  // TRANSLATORS: palette color
393  _("Misses"),
396  // TRANSLATORS: palette label
397  _("Tiles"));
399  0xC80000,
401  // TRANSLATORS: palette color
402  _("Portal highlight"),
405  0x0000C8,
407  // TRANSLATORS: palette color
408  _("Default collision highlight"),
409  64);
411  0xe0e0ff,
413  // TRANSLATORS: palette color
414  _("Air collision highlight"),
415  64);
417  0x2050e0,
419  // TRANSLATORS: palette color
420  _("Water collision highlight"),
421  64);
423  0x2050e0,
425  // TRANSLATORS: palette color
426  _("Monster collision highlight"),
427  64);
429  0xffff00,
431  // TRANSLATORS: palette color
432  _("Special ground collision highlight"),
433  20);
435  0x00D000,
437  // TRANSLATORS: palette color
438  _("Walkable highlight"),
439  255);
441  0x000000,
443  // TRANSLATORS: palette color
444  _("Tiles border"), 64);
446  // TRANSLATORS: palette label
447  _("Ranges"));
449  0xffffff,
451  // TRANSLATORS: palette color
452  _("Local player attack range"),
453  5);
455  0x0,
457  // TRANSLATORS: palette color
458  _("Local player attack range border"),
459  76);
461  0xff0000,
463  // TRANSLATORS: palette color
464  _("Monster attack range"),
465  20);
467  0x0,
469  // TRANSLATORS: palette color
470  _("Skill attack range border"),
471  76);
473  // TRANSLATORS: palette label
474  _("Other"));
476  0xffffff,
478  // TRANSLATORS: palette color
479  _("Floor item amount color"),
480  100);
482  0xffffff,
484  // TRANSLATORS: palette color
485  _("Home place"),
486  20);
488  0xffff00,
490  // TRANSLATORS: palette color
491  _("Home place border"),
492  200);
494  0x000000,
496  // TRANSLATORS: palette color
497  _("Road point"), 100);
498  commit(true);
499 }

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::~UserPalette ( )

Destructor

Definition at line 501 of file userpalette.cpp.

502 {
503  FOR_EACH (Colors::const_iterator, col, mColors)
504  {
505  if (col->grad == GradientType::LABEL)
506  continue;
507  const std::string &configName = ColorTypeNames[col->type];
508  config.setValue(configName + "Gradient",
509  CAST_S32(col->committedGrad));
510  config.setValue(configName + "Delay", col->delay);
511 
512  if (col->grad == GradientType::STATIC ||
513  col->grad == GradientType::PULSE)
514  {
515  char buffer[20];
516  snprintf(buffer, sizeof(buffer), "0x%06x", col->getRGB());
517  buffer[19] = 0;
518  config.setValue(configName, std::string(buffer));
519  }
520  }
521 }

References CAST_S32, ColorTypeNames, config, FOR_EACH, GradientType::LABEL, Palette::mColors, GradientType::PULSE, Configuration::setValue(), and GradientType::STATIC.

Member Function Documentation

◆ addColor()

void UserPalette::addColor ( const UserColorIdT  type,
const unsigned  rgb,
GradientTypeT  grad,
const std::string &  text,
int  delay 
)
private

Definition at line 615 of file userpalette.cpp.

620 {
621  const unsigned maxType = sizeof(ColorTypeNames)
622  / sizeof(ColorTypeNames[0]);
623 
624  if (CAST_U32(type) >= maxType)
625  return;
626 
627  const std::string &configName = ColorTypeNames[CAST_SIZE(type)];
628  char buffer[20];
629  snprintf(buffer, sizeof(buffer), "0x%06x", rgb);
630  buffer[19] = 0;
631 
632  const std::string rgbString = config.getValue(
633  configName, std::string(buffer));
634  unsigned int rgbValue = 0;
635  if (rgbString.length() == 8 && rgbString[0] == '0' && rgbString[1] == 'x')
636  rgbValue = atox(rgbString);
637  else
638  rgbValue = atoi(rgbString.c_str());
639  const Color &trueCol = Color(rgbValue);
640  grad = static_cast<GradientTypeT>(config.getValue(
641  configName + "Gradient",
642  CAST_S32(grad)));
643  delay = config.getValueInt(configName + "Delay", delay);
644  mColors[CAST_SIZE(type)].set(CAST_S32(type),
645  trueCol, grad, delay);
646  mColors[CAST_SIZE(type)].text = text;
647 
648  if (grad != GradientType::STATIC)
649  mGradVector.push_back(&mColors[CAST_SIZE(type)]);
650 }

References atox(), CAST_S32, CAST_SIZE, CAST_U32, ColorTypeNames, config, ConfigurationObject::getValue(), ConfigurationObject::getValueInt(), Palette::mColors, Palette::mGradVector, GradientType::STATIC, and SetupActionData::text.

Referenced by UserPalette().

◆ addLabel()

void UserPalette::addLabel ( const UserColorIdT  type,
const std::string &  text 
)
private

Definition at line 652 of file userpalette.cpp.

654 {
655  const unsigned maxType = sizeof(ColorTypeNames)
656  / sizeof(ColorTypeNames[0]);
657 
658  if (CAST_U32(type) >= maxType)
659  return;
660 
661 
662  mColors[CAST_SIZE(type)] = ColorElem();
663  const std::string str(" \342\200\225\342\200\225\342\200\225"
664  "\342\200\225\342\200\225 ");
665  mColors[CAST_SIZE(type)].grad = GradientType::LABEL;
666  mColors[CAST_SIZE(type)].text =
667  std::string(str).append(text).append(str);
668 }

References CAST_SIZE, CAST_U32, ColorTypeNames, GradientType::LABEL, Palette::mColors, and SetupActionData::text.

Referenced by UserPalette().

◆ commit() [1/2]

void UserPalette::commit ( )
inline

Commit the colors

Definition at line 132 of file userpalette.h.

133  { commit(false); }

Referenced by Setup_Colors::apply(), and UserPalette().

◆ commit() [2/2]

void UserPalette::commit ( const bool  commitNonStatic)
private

Commit the colors. Commit the non-static color values, if commitNonStatic is true. Only needed in the constructor.

Definition at line 569 of file userpalette.cpp.

570 {
571  FOR_EACH (Colors::iterator, i, mColors)
572  {
573  i->committedGrad = i->grad;
574  i->committedDelay = i->delay;
575  if (commitNonStatic || i->grad == GradientType::STATIC)
576  i->committedColor = i->color;
577  else if (i->grad == GradientType::PULSE)
578  i->committedColor = i->testColor;
579  }
580 }

References FOR_EACH, Palette::mColors, GradientType::PULSE, and GradientType::STATIC.

◆ getColor()

const Color& UserPalette::getColor ( UserColorIdT  type,
const unsigned int  alpha 
)
inline

Gets the color associated with the type. Sets the alpha channel before returning.

Parameters
typethe color type requested
alphaalpha channel to use
Returns
the requested color

Definition at line 159 of file userpalette.h.

162  {
163  if (CAST_SIZE(type) >= mColors.size())
164  {
165  logger->log("incorrect color request type: %d from %u",
166  CAST_S32(type),
167  CAST_U32(mColors.size()));
168  type = UserColorId::BEING;
169  }
170  Color* col = &mColors[CAST_SIZE(type)].color;
171  col->a = alpha;
172  return *col;
173  }

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().

◆ getColorTypeAt()

int UserPalette::getColorTypeAt ( const int  i)

Gets the ColorType used by the color for the element at index i in the current color model.

Parameters
ithe index of the color
Returns
the color type of the color with the given index

Definition at line 607 of file userpalette.cpp.

608 {
609  if (i < 0 || i >= getNumberOfElements())
610  return 0;
611 
612  return mColors[i].type;
613 }

References getNumberOfElements(), and Palette::mColors.

Referenced by Setup_Colors::cancel(), Setup_Colors::updateColor(), Setup_Colors::updateGradType(), and Setup_Colors::valueChanged().

◆ getColorWithAlpha()

const Color& UserPalette::getColorWithAlpha ( const UserColorIdT  type)
inline

◆ getCommittedColor()

const Color& UserPalette::getCommittedColor ( const UserColorIdT  type) const
inline

Gets the committed color associated with the specified type.

Parameters
typethe color type requested
Returns
the requested committed color

Definition at line 60 of file userpalette.h.

62  {
63  return mColors[CAST_SIZE(type)].committedColor;
64  }

References CAST_SIZE, and Palette::mColors.

Referenced by Setup_Colors::valueChanged().

◆ getConfigName()

std::string UserPalette::getConfigName ( const std::string &  typeName)
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

Parameters
typeNamestring to transform
Returns
the transformed string

Definition at line 104 of file userpalette.cpp.

105 {
106  std::string res("Color" + typeName);
107  size_t pos = 5;
108  for (size_t i = 0; i < typeName.length(); i++)
109  {
110  if (i == 0 || typeName[i] == '_')
111  {
112  if (i > 0)
113  i++;
114 
115  res[pos] = typeName[i];
116  }
117  else
118  {
119  res[pos] = CAST_S8(tolower(typeName[i]));
120  }
121  pos ++;
122  }
123  res.erase(pos, res.length() - pos);
124  return res;
125 }

References CAST_S8.

◆ getElementAt()

std::string UserPalette::getElementAt ( int  i)
virtual

Returns the name of the ith color.

Parameters
iindex of color interested in
Returns
the name of the color

Implements ListModel.

Definition at line 561 of file userpalette.cpp.

562 {
563  if (i < 0 || i >= getNumberOfElements())
564  return "";
565 
566  return mColors[i].text;
567 }

References getNumberOfElements(), and Palette::mColors.

◆ getGradientDelay()

int UserPalette::getGradientDelay ( const UserColorIdT  type) const
inline

Gets the gradient delay for the specified type.

Parameters
typethe color type of the color
Returns
the gradient delay of the color with the given index

Definition at line 195 of file userpalette.h.

197  { return mColors[CAST_SIZE(type)].delay; }

References CAST_SIZE, and Palette::mColors.

Referenced by Setup_Colors::cancel(), and Setup_Colors::valueChanged().

◆ getGradientType()

GradientTypeT UserPalette::getGradientType ( const UserColorIdT  type) const
inline

Gets the GradientType associated with the specified type.

Parameters
typethe color type of the color
Returns
the gradient type of the color with the given index

Definition at line 184 of file userpalette.h.

186  { return mColors[CAST_SIZE(type)].grad; }

References CAST_SIZE, and Palette::mColors.

Referenced by Setup_Colors::cancel(), Setup_Colors::updateGradType(), and Setup_Colors::valueChanged().

◆ getIdByChar()

int UserPalette::getIdByChar ( const signed char  c,
bool valid 
) const

Definition at line 670 of file userpalette.cpp.

671 {
672  const CharColors::const_iterator it = mCharColors.find(c);
673  if (it != mCharColors.end())
674  {
675  valid = true;
676  return (*it).second;
677  }
678 
679  valid = false;
680  return 0;
681 }

References Palette::mCharColors, and anonymous_namespace{libxml.cpp}::valid.

◆ getNumberOfElements()

int UserPalette::getNumberOfElements ( )
inlinevirtual

Returns the number of colors known.

Returns
the number of colors known

Implements ListModel.

Definition at line 117 of file userpalette.h.

118  { return CAST_S32(mColors.size()); }

References CAST_S32, and Palette::mColors.

Referenced by getColorTypeAt(), and getElementAt().

◆ getTestColor()

const Color& UserPalette::getTestColor ( const UserColorIdT  type) const
inline

Gets the test color associated with the specified type.

Parameters
typethe color type requested
Returns
the requested test color

Definition at line 73 of file userpalette.h.

75  { return mColors[CAST_SIZE(type)].testColor; }

References CAST_SIZE, and Palette::mColors.

Referenced by Setup_Colors::valueChanged().

◆ rollback()

void UserPalette::rollback ( )

Rollback the colors

Definition at line 582 of file userpalette.cpp.

583 {
584  FOR_EACH (Colors::iterator, i, mColors)
585  {
586  if (i->grad != i->committedGrad)
587  setGradient(static_cast<UserColorIdT>(i->type), i->committedGrad);
588 
589  const Color &committedColor = i->committedColor;
590  setGradientDelay(static_cast<UserColorIdT>(i->type),
591  i->committedDelay);
592  setColor(static_cast<UserColorIdT>(i->type),
593  committedColor.r,
594  committedColor.g,
595  committedColor.b);
596 
597  if (i->grad == GradientType::PULSE)
598  {
599  Color &testColor = i->testColor;
600  testColor.r = committedColor.r;
601  testColor.g = committedColor.g;
602  testColor.b = committedColor.b;
603  }
604  }
605 }

References Color::b, FOR_EACH, Color::g, Palette::mColors, GradientType::PULSE, Color::r, setColor(), setGradient(), and setGradientDelay().

Referenced by Setup_Colors::cancel().

◆ setColor()

void UserPalette::setColor ( const UserColorIdT  type,
const int  r,
const int  g,
const int  b 
)

Sets the color for the specified type.

Parameters
typecolor to be set
rred component
ggreen component
bblue component

Definition at line 523 of file userpalette.cpp.

527 {
528  Color &color = mColors[CAST_SIZE(type)].color;
529  color.r = r;
530  color.g = g;
531  color.b = b;
532 }

References Color::b, CAST_SIZE, Color::g, Palette::mColors, and Color::r.

Referenced by rollback(), and Setup_Colors::updateColor().

◆ setColorAt()

void UserPalette::setColorAt ( int  i,
int  r,
int  g,
int  b 
)
private

Define a color replacement.

Parameters
ithe index of the color to replace
rred component
ggreen component
bblue component

◆ setGradient()

void UserPalette::setGradient ( const UserColorIdT  type,
const GradientTypeT  grad 
)

Sets the gradient type for the specified color.

Parameters
gradgradient type to set

Definition at line 534 of file userpalette.cpp.

536 {
537  ColorElem *const elem = &mColors[CAST_SIZE(type)];
538 
539  if (elem->grad != GradientType::STATIC && grad == GradientType::STATIC)
540  {
541  const size_t sz = mGradVector.size();
542  for (size_t i = 0; i < sz; i++)
543  {
544  if (mGradVector[i] == elem)
545  {
546  mGradVector.erase(mGradVector.begin() + i);
547  break;
548  }
549  }
550  }
551  else if (elem->grad == GradientType::STATIC &&
552  grad != GradientType::STATIC)
553  {
554  mGradVector.push_back(elem);
555  }
556 
557  if (elem->grad != grad)
558  elem->grad = grad;
559 }

References CAST_SIZE, Palette::ColorElem::grad, Palette::mColors, Palette::mGradVector, and GradientType::STATIC.

Referenced by rollback(), and Setup_Colors::updateColor().

◆ setGradientDelay()

void UserPalette::setGradientDelay ( const UserColorIdT  type,
const int  delay 
)
inline

Definition at line 108 of file userpalette.h.

110  { mColors[CAST_SIZE(type)].delay = delay; }

References CAST_SIZE, and Palette::mColors.

Referenced by rollback(), and Setup_Colors::updateColor().

◆ setTestColor()

void UserPalette::setTestColor ( const UserColorIdT  type,
const Color color 
)
inline

Sets the test color associated with the specified type.

Parameters
typethe color type requested
colorthe color that should be tested

Definition at line 83 of file userpalette.h.

85  { mColors[CAST_SIZE(type)].testColor = color; }

References CAST_SIZE, and Palette::mColors.

Referenced by Setup_Colors::updateColor().


The documentation for this class was generated from the following files:
ConfigurationObject::getValue
std::string getValue(const std::string &key, const std::string &deflt) const
Definition: configuration.cpp:268
GRADIENT_DELAY
#define GRADIENT_DELAY
Definition: palette.h:38
UserColorId::TEAM3
@ TEAM3
Definition: usercolorid.h:52
UserColorId::MERC_HP
@ MERC_HP
Definition: usercolorid.h:64
UserColorId::HOME_PLACE_BORDER
@ HOME_PLACE_BORDER
Definition: usercolorid.h:94
CAST_SIZE
#define CAST_SIZE
Definition: cast.h:33
UserColorId::EXP_INFO
@ EXP_INFO
Definition: usercolorid.h:56
UserColorId::COLLISION_HIGHLIGHT
@ COLLISION_HIGHLIGHT
Definition: usercolorid.h:79
Color::r
unsigned int r
Definition: color.h:234
anonymous_namespace{libxml.cpp}::valid
bool valid
Definition: libxml.cpp:42
UserColorId::MONSTER_HP2
@ MONSTER_HP2
Definition: usercolorid.h:61
UserColorId::SKILL_ATTACK_RANGE
@ SKILL_ATTACK_RANGE
Definition: usercolorid.h:90
GradientType::PULSE
@ PULSE
Definition: gradienttype.h:32
UserColorId::LABEL_TILES
@ LABEL_TILES
Definition: usercolorid.h:77
UserColorId::IGNORED
@ IGNORED
Definition: usercolorid.h:36
UserColorId::ATTACK_RANGE
@ ATTACK_RANGE
Definition: usercolorid.h:87
Color::b
unsigned int b
Definition: color.h:244
UserColorId::PARTICLE
@ PARTICLE
Definition: usercolorid.h:54
UserColorId::LABEL_RANGES
@ LABEL_RANGES
Definition: usercolorid.h:86
GradientType::RAINBOW
@ RAINBOW
Definition: gradienttype.h:34
UserColorId::FLOOR_ITEM_TEXT
@ FLOOR_ITEM_TEXT
Definition: usercolorid.h:92
UserColorId::MERC_HP2
@ MERC_HP2
Definition: usercolorid.h:65
UserColorId::HIT_MONSTER_PLAYER
@ HIT_MONSTER_PLAYER
Definition: usercolorid.h:70
UserColorId::LABEL_HITS
@ LABEL_HITS
Definition: usercolorid.h:68
Palette::mCharColors
CharColors mCharColors
Definition: palette.h:154
UserPalette::setGradient
void setGradient(const UserColorIdT type, const GradientTypeT grad)
Definition: userpalette.cpp:534
UserColorId::PET
@ PET
Definition: usercolorid.h:44
UserColorIdT
UserColorId ::T UserColorIdT
Definition: usercolorid.h:98
UserColorId::HOMUNCULUS
@ HOMUNCULUS
Definition: usercolorid.h:46
UserColorId::TEAM2
@ TEAM2
Definition: usercolorid.h:51
UserPalette::addLabel
void addLabel(const UserColorIdT type, const std::string &text)
Definition: userpalette.cpp:652
CAST_U32
#define CAST_U32
Definition: cast.h:30
UserColorId::GM
@ GM
Definition: usercolorid.h:41
UserPalette::setGradientDelay
void setGradientDelay(const UserColorIdT type, const int delay)
Definition: userpalette.h:108
UserColorId::MONSTER_HP
@ MONSTER_HP
Definition: usercolorid.h:60
UserColorId::SELF
@ SELF
Definition: usercolorid.h:40
Palette::Palette
Palette(const int size)
Definition: palette.cpp:51
UserColorId::NPC
@ NPC
Definition: usercolorid.h:42
UserColorId::FRIEND
@ FRIEND
Definition: usercolorid.h:34
logger
Logger * logger
Definition: logger.cpp:88
UserColorId::ROAD_POINT
@ ROAD_POINT
Definition: usercolorid.h:95
Configuration::setValue
void setValue(const std::string &key, const std::string &value)
Definition: configuration.cpp:238
UserColorId::LABEL_PARTICLES
@ LABEL_PARTICLES
Definition: usercolorid.h:53
UserColorId::HIT_LOCAL_PLAYER_MISS
@ HIT_LOCAL_PLAYER_MISS
Definition: usercolorid.h:75
GradientType::STATIC
@ STATIC
Definition: gradienttype.h:31
Color::g
unsigned int g
Definition: color.h:239
Palette::mGradVector
std::vector< ColorElem * > mGradVector
Definition: palette.h:155
UserColorId::PLAYER_HP2
@ PLAYER_HP2
Definition: usercolorid.h:59
UserColorId::MERCENARY
@ MERCENARY
Definition: usercolorid.h:45
UserColorId::AIR_COLLISION_HIGHLIGHT
@ AIR_COLLISION_HIGHLIGHT
Definition: usercolorid.h:80
UserPalette::addColor
void addColor(const UserColorIdT type, const unsigned rgb, GradientTypeT grad, const std::string &text, int delay)
Definition: userpalette.cpp:615
UserColorId::HOME_PLACE
@ HOME_PLACE
Definition: usercolorid.h:93
ConfigurationObject::getValueInt
int getValueInt(const std::string &key, const int deflt) const
Definition: configuration.cpp:284
strprintf
std::string strprintf(const char *const format,...)
Definition: stringutils.cpp:99
UserColorId::HIT_PLAYER_PLAYER
@ HIT_PLAYER_PLAYER
Definition: usercolorid.h:71
UserColorId::SKILLUNIT
@ SKILLUNIT
Definition: usercolorid.h:47
CAST_S8
#define CAST_S8
Definition: cast.h:25
UserPalette::getNumberOfElements
int getNumberOfElements()
Definition: userpalette.h:117
ColorTypeNames
const std::string ColorTypeNames[static_cast< size_t >(UserColorId::USER_COLOR_LAST)]
Definition: userpalette.cpp:36
ListModel::ListModel
ListModel()
Definition: listmodel.h:81
UserColorId::PORTAL_HIGHLIGHT
@ PORTAL_HIGHLIGHT
Definition: usercolorid.h:78
UserColorId::ATTACK_RANGE_BORDER
@ ATTACK_RANGE_BORDER
Definition: usercolorid.h:88
UserColorId::WALKABLE_HIGHLIGHT
@ WALKABLE_HIGHLIGHT
Definition: usercolorid.h:84
UserColorId::MISS
@ MISS
Definition: usercolorid.h:76
GradientTypeT
GradientType ::T GradientTypeT
Definition: gradienttype.h:37
UserPalette::commit
void commit()
Definition: userpalette.h:132
UserColorId::PLAYER_HP
@ PLAYER_HP
Definition: usercolorid.h:58
UserColorId::USER_COLOR_LAST
@ USER_COLOR_LAST
Definition: usercolorid.h:96
config
Configuration config
Definition: configuration.cpp:51
UserColorId::HOMUN_HP2
@ HOMUN_HP2
Definition: usercolorid.h:63
atox
unsigned int atox(const std::string &str)
Definition: stringutils.cpp:77
Palette::mColors
Colors mColors
Definition: palette.h:153
UserColorId::GUILD
@ GUILD
Definition: usercolorid.h:49
UserPalette::setColor
void setColor(const UserColorIdT type, const int r, const int g, const int b)
Definition: userpalette.cpp:523
UserColorId::MONSTER_ATTACK_RANGE
@ MONSTER_ATTACK_RANGE
Definition: usercolorid.h:89
UserColorId::DISREGARDED
@ DISREGARDED
Definition: usercolorid.h:35
UserColorId::PICKUP_INFO
@ PICKUP_INFO
Definition: usercolorid.h:55
UserColorId::HIT_PLAYER_MONSTER
@ HIT_PLAYER_MONSTER
Definition: usercolorid.h:69
UserColorId::WATER_COLLISION_HIGHLIGHT
@ WATER_COLLISION_HIGHLIGHT
Definition: usercolorid.h:81
UserColorId::HOMUN_HP
@ HOMUN_HP
Definition: usercolorid.h:62
UserColorId::LABEL_BEING
@ LABEL_BEING
Definition: usercolorid.h:32
UserColorId::MONSTER_COLLISION_HIGHLIGHT
@ MONSTER_COLLISION_HIGHLIGHT
Definition: usercolorid.h:82
UserColorId::ENEMY
@ ENEMY
Definition: usercolorid.h:38
GradientType::LABEL
@ LABEL
Definition: gradienttype.h:35
UserColorId::PARTY
@ PARTY
Definition: usercolorid.h:48
CAST_S32
#define CAST_S32
Definition: cast.h:29
UserColorId::HIT_LOCAL_PLAYER_CRITICAL
@ HIT_LOCAL_PLAYER_CRITICAL
Definition: usercolorid.h:74
UserColorId::NET
@ NET
Definition: usercolorid.h:85
UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT
@ GROUNDTOP_COLLISION_HIGHLIGHT
Definition: usercolorid.h:83
UserColorId::LABEL_OTHER
@ LABEL_OTHER
Definition: usercolorid.h:91
UserColorId::HIT_CRITICAL
@ HIT_CRITICAL
Definition: usercolorid.h:72
UserColorId::MONSTER
@ MONSTER
Definition: usercolorid.h:43
_
#define _(s)
Definition: gettext.h:34
UserColorId::ELEMENTAL_HP2
@ ELEMENTAL_HP2
Definition: usercolorid.h:67
Color
Definition: color.h:74
UserColorId::ELEMENTAL_HP
@ ELEMENTAL_HP
Definition: usercolorid.h:66
UserColorId::HIT_LOCAL_PLAYER_MONSTER
@ HIT_LOCAL_PLAYER_MONSTER
Definition: usercolorid.h:73
Color::a
unsigned int a
Definition: color.h:250
Logger::log
void log(const char *const log_text,...)
Definition: logger.cpp:268
FOR_EACH
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
UserColorId::BEING
@ BEING
Definition: usercolorid.h:33
UserColorId::LABEL_HP
@ LABEL_HP
Definition: usercolorid.h:57
UserColorId::ERASED
@ ERASED
Definition: usercolorid.h:37
UserColorId::PC
@ PC
Definition: usercolorid.h:39
UserColorId::TEAM1
@ TEAM1
Definition: usercolorid.h:50