Palette Class Reference

#include <palette.h>

List of all members.


Detailed Description

Class controlling the game's color palette.

Definition at line 51 of file palette.h.


Public Types

enum  GradientType { STATIC, PULSE, SPECTRUM, RAINBOW }
 Colors can be static or can alter over time. More...

Public Member Functions

 TEXTENUM (ColorType, COLOR_TYPE)
 Palette ()
 Constructor.
 ~Palette ()
 Destructor.
const gcn::Color & getColor (char c, bool &valid)
 Returns the color associated with a character, if it exists.
const gcn::Color & getColor (ColorType type, int alpha=255)
 Gets the color associated with the type.
const gcn::Color & getCommittedColor (ColorType type)
 Gets the committed color associated with the specified type.
const gcn::Color & getTestColor (ColorType type)
 Gets the test color associated with the specified type.
void setTestColor (ColorType type, gcn::Color color)
 Sets the test color associated with the specified type.
GradientType getGradientType (ColorType type)
 Gets the GradientType associated with the specified type.
int getGradientDelay (ColorType type)
 Gets the gradient delay for the specified type.
char getColorChar (ColorType type)
 Get the character used by the specified color.
void setColor (ColorType type, int r, int g, int b)
 Sets the color for the specified type.
void setGradient (ColorType type, GradientType grad)
 Sets the gradient type for the specified color.
void setGradientDelay (ColorType type, int delay)
 Sets the gradient delay for the specified color.
int getNumberOfElements ()
 Returns the number of colors known.
std::string getElementAt (int i)
 Returns the name of the ith color.
ColorType getColorTypeAt (int i)
 Gets the ColorType used by the color for the element at index i in the current color model.
void commit ()
 Commit the colors.
void rollback ()
 Rollback the colors.
void advanceGradient ()
 Updates all colors, that are non-static.

Private Types

typedef std::vector< ColorElemColVector

Private Member Functions

void setColorAt (int i, int r, int g, int b)
 Define a color replacement.
void commit (bool commitNonStatic)
 Commit the colors.
void addColor (ColorType type, int rgb, GradientType grad, const std::string &text, char c=0, int delay=GRADIENT_DELAY)
 Initialise color.

Static Private Member Functions

static std::string getConfigName (const std::string &typeName)
 Prefixes the given string with "Color", lowercases all letters but the first and all following a '_'.

Private Attributes

int mRainbowTime
 Time tick, that gradient-type colors were updated the last time.
ColVector mColVector
 Vector containing the colors.
std::vector< ColorElem * > mGradVector

Static Private Attributes

static const gcn::Color BLACK = gcn::Color(0, 0, 0)
 Black Color Constant.
static const gcn::Color RAINBOW_COLORS []
 Colors used for the rainbow gradient.
static const int RAINBOW_COLOR_COUNT = 7
 Number of Elemets of RAINBOW_COLORS.

Classes

struct  ColorElem

Member Typedef Documentation

typedef std::vector<ColorElem> Palette::ColVector [private]

Definition at line 351 of file palette.h.


Member Enumeration Documentation

Colors can be static or can alter over time.

Enumerator:
STATIC 
PULSE 
SPECTRUM 
RAINBOW 

Definition at line 110 of file palette.h.


Constructor & Destructor Documentation

Palette::Palette (  ) 

Constructor.

Definition at line 76 of file palette.cpp.

Palette::~Palette (  ) 

Destructor.

Definition at line 142 of file palette.cpp.


Member Function Documentation

Palette::TEXTENUM ( ColorType  ,
COLOR_TYPE   
)

const gcn::Color & Palette::getColor ( char  c,
bool &  valid 
)

Returns the color associated with a character, if it exists.

Returns Palette::BLACK if the character is not found.

Parameters:
c character requested
valid indicate whether character is known
Returns:
the requested color or Palette::BLACK

Definition at line 159 of file palette.cpp.

const gcn::Color& Palette::getColor ( ColorType  type,
int  alpha = 255 
) [inline]

Gets the color associated with the type.

Sets the alpha channel before returning.

Parameters:
type the color type requested
alpha alpha channel to use
Returns:
the requested color

Definition at line 147 of file palette.h.

const gcn::Color& Palette::getCommittedColor ( ColorType  type  )  [inline]

Gets the committed color associated with the specified type.

Parameters:
type the color type requested
Returns:
the requested committed color

Definition at line 161 of file palette.h.

const gcn::Color& Palette::getTestColor ( ColorType  type  )  [inline]

Gets the test color associated with the specified type.

Parameters:
type the color type requested
Returns:
the requested test color

Definition at line 173 of file palette.h.

void Palette::setTestColor ( ColorType  type,
gcn::Color  color 
) [inline]

Sets the test color associated with the specified type.

Parameters:
type the color type requested
color the color that should be tested

Definition at line 184 of file palette.h.

GradientType Palette::getGradientType ( ColorType  type  )  [inline]

Gets the GradientType associated with the specified type.

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

Definition at line 196 of file palette.h.

int Palette::getGradientDelay ( ColorType  type  )  [inline]

Gets the gradient delay for the specified type.

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

Definition at line 208 of file palette.h.

char Palette::getColorChar ( ColorType  type  )  [inline]

Get the character used by the specified color.

Parameters:
type the color type of the color
Returns:
the color char of the color with the given index

Definition at line 218 of file palette.h.

void Palette::setColor ( ColorType  type,
int  r,
int  g,
int  b 
)

Sets the color for the specified type.

Parameters:
type color to be set
r red component
g green component
b blue component

Definition at line 174 of file palette.cpp.

void Palette::setGradient ( ColorType  type,
GradientType  grad 
)

Sets the gradient type for the specified color.

Parameters:
grad gradient type to set

Definition at line 181 of file palette.cpp.

void Palette::setGradientDelay ( ColorType  type,
int  delay 
) [inline]

Sets the gradient delay for the specified color.

Parameters:
grad gradient type to set

Definition at line 245 of file palette.h.

int Palette::getNumberOfElements (  )  [inline]

Returns the number of colors known.

Returns:
the number of colors known

Definition at line 253 of file palette.h.

std::string Palette::getElementAt ( int  i  ) 

Returns the name of the ith color.

Parameters:
i index of color interested in
Returns:
the name of the color

Definition at line 206 of file palette.cpp.

Palette::ColorType Palette::getColorTypeAt ( int  i  ) 

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

Parameters:
i the index of the color
Returns:
the color type of the color with the given index

Definition at line 215 of file palette.cpp.

void Palette::commit (  )  [inline]

Commit the colors.

Definition at line 277 of file palette.h.

void Palette::rollback (  ) 

Rollback the colors.

Definition at line 242 of file palette.cpp.

void Palette::advanceGradient (  ) 

Updates all colors, that are non-static.

Definition at line 277 of file palette.cpp.

void Palette::setColorAt ( int  i,
int  r,
int  g,
int  b 
) [private]

Define a color replacement.

Parameters:
i the index of the color to replace
r red component
g green component
b blue component

void Palette::commit ( bool  commitNonStatic  )  [private]

Commit the colors.

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

Definition at line 224 of file palette.cpp.

void Palette::addColor ( ColorType  type,
int  rgb,
GradientType  grad,
const std::string &  text,
char  c = 0,
int  delay = GRADIENT_DELAY 
) [private]

Initialise color.

Parameters:
c character that needs initialising
rgb default color if not found in config
text identifier of color

std::string Palette::getConfigName ( const std::string &  typeName  )  [static, private]

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:
typeName string to transform
Returns:
the transformed string

Definition at line 49 of file palette.cpp.


Member Data Documentation

const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0) [static, private]

Black Color Constant.

Definition at line 294 of file palette.h.

const gcn::Color Palette::RAINBOW_COLORS [static, private]

Initial value:

 {
    gcn::Color(255, 0, 0),
    gcn::Color(255, 153, 0),
    gcn::Color(255, 255, 0),
    gcn::Color(0, 153, 0),
    gcn::Color(0, 204, 204),
    gcn::Color(51, 0, 153),
    gcn::Color(153, 0, 153)
}
Colors used for the rainbow gradient.

Definition at line 297 of file palette.h.

const int Palette::RAINBOW_COLOR_COUNT = 7 [static, private]

Number of Elemets of RAINBOW_COLORS.

Definition at line 298 of file palette.h.

int Palette::mRainbowTime [private]

Time tick, that gradient-type colors were updated the last time.

Definition at line 300 of file palette.h.

Vector containing the colors.

Definition at line 353 of file palette.h.

std::vector<ColorElem*> Palette::mGradVector [private]

Definition at line 354 of file palette.h.


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:43 2009 for The Mana World by  doxygen 1.5.5