Mana
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Theme Class Reference

#include <theme.h>

Inheritance diagram for Theme:
EventListener

Public Types

enum  ThemePalette {
  TEXT , BLACK , RED , GREEN ,
  BLUE , ORANGE , YELLOW , PINK ,
  PURPLE , GRAY , BROWN , CARET ,
  SHADOW , OUTLINE , PARTY_TAB , WHISPER_TAB ,
  BACKGROUND , HIGHLIGHT , HIGHLIGHT_TEXT , TAB_FLASH ,
  SHOP_WARNING , ITEM_EQUIPPED , CHAT , OLDCHAT ,
  AWAYCHAT , BUBBLE_TEXT , GM , GLOBAL ,
  PLAYER , WHISPER , IS , PARTY ,
  GUILD , SERVER , LOGGER , HYPERLINK ,
  UNKNOWN_ITEM , GENERIC , HEAD , USABLE ,
  TORSO , ONEHAND , LEGS , FEET ,
  TWOHAND , SHIELD , RING , NECKLACE ,
  ARMS , AMMO , SERVER_VERSION_NOT_SUPPORTED , THEME_COLORS_END
}
 
enum  ProgressPalette {
  PROG_DEFAULT , PROG_HP , PROG_MP , PROG_NO_MP ,
  PROG_EXP , PROG_INVY_SLOTS , PROG_WEIGHT , PROG_JOB ,
  THEME_PROG_END
}
 

Public Member Functions

 Theme (const ThemeInfo &themeInfo)
 
 ~Theme () override
 
const std::string & getThemePath () const
 
std::string resolvePath (const std::string &path) const
 Returns the patch to the given GUI resource relative to the theme or, if it isn't in the theme, relative to 'graphics/gui'.
 
const PalettegetPalette (size_t index) const
 
const gcn::Color & getColor (int type) const
 Returns a color from the default palette (0).
 
void drawSkin (Graphics *graphics, SkinType type, const WidgetState &state) const
 
void drawProgressBar (Graphics *graphics, const gcn::Rectangle &area, const gcn::Color &color, float progress, const std::string &text=std::string(), ProgressPalette progressType=ProgressPalette::THEME_PROG_END) const
 
const SkingetSkin (SkinType skinType) const
 
const ImagegetIcon (const std::string &name) const
 
int getGuiAlpha () const
 Get the current GUI alpha value.
 
float getMinimumOpacity () const
 Get the minimum opacity allowed to skins.
 
void setMinimumOpacity (float minimumOpacity)
 Set the minimum opacity allowed to skins.
 
void event (Event::Channel channel, const Event &event) override
 
- Public Member Functions inherited from EventListener
virtual ~EventListener ()
 
void listen (Event::Channel channel)
 
void ignore (Event::Channel channel)
 

Static Public Member Functions

static std::string prepareThemePath ()
 
static std::vector< ThemeInfogetAvailableThemes ()
 
static ResourceRef< ImagegetImageFromTheme (const std::string &path)
 
static const gcn::Color & getThemeColor (int type)
 Gets the color associated with the type in the default palette (0).
 
static gcn::Color getProgressColor (int type, float progress)
 
static std::optional< int > getColorIdForChar (char c)
 Returns the color ID associated with a character, if it exists.
 

Private Member Functions

void updateAlpha ()
 Updates the alpha values of all of the skins and images.
 
ResourceRef< ImagegetImage (const std::string &path) const
 
bool readTheme (const ThemeInfo &themeInfo)
 
void readSkinNode (XML::Node node)
 
void readSkinStateNode (XML::Node node, Skin &skin) const
 
void readSkinStateImgNode (XML::Node node, SkinState &state) const
 
void readIconNode (XML::Node node)
 
void readPaletteNode (XML::Node node)
 
void readProgressBarNode (XML::Node node)
 

Private Attributes

std::string mThemePath
 
std::map< SkinType, SkinmSkins
 
std::map< std::string, Image * > mIcons
 
float mMinimumOpacity = 0.0f
 Tells if the current skins opacity should not get less than the given value.
 
float mAlpha = 1.0
 
std::vector< PalettemPalettes
 
std::array< std::unique_ptr< DyePalette >, THEME_PROG_ENDmProgressColors
 
std::array< std::optional< TextFormat >, THEME_PROG_ENDmProgressTextFormats
 

Detailed Description

Definition at line 195 of file theme.h.

Member Enumeration Documentation

◆ ProgressPalette

Enumerator
PROG_DEFAULT 
PROG_HP 
PROG_MP 
PROG_NO_MP 
PROG_EXP 
PROG_INVY_SLOTS 
PROG_WEIGHT 
PROG_JOB 
THEME_PROG_END 

Definition at line 268 of file theme.h.

◆ ThemePalette

Enumerator
TEXT 
BLACK 
RED 
GREEN 
BLUE 
ORANGE 
YELLOW 
PINK 
PURPLE 
GRAY 
BROWN 
CARET 
SHADOW 
OUTLINE 
PARTY_TAB 
WHISPER_TAB 
BACKGROUND 
HIGHLIGHT 
HIGHLIGHT_TEXT 
TAB_FLASH 
SHOP_WARNING 
ITEM_EQUIPPED 
CHAT 
OLDCHAT 
AWAYCHAT 
BUBBLE_TEXT 
GM 
GLOBAL 
PLAYER 
WHISPER 
IS 
PARTY 
GUILD 
SERVER 
LOGGER 
HYPERLINK 
UNKNOWN_ITEM 
GENERIC 
HEAD 
USABLE 
TORSO 
ONEHAND 
LEGS 
FEET 
TWOHAND 
SHIELD 
RING 
NECKLACE 
ARMS 
AMMO 
SERVER_VERSION_NOT_SUPPORTED 
THEME_COLORS_END 

Definition at line 213 of file theme.h.

Constructor & Destructor Documentation

◆ Theme()

Theme::Theme ( const ThemeInfo themeInfo)

Definition at line 228 of file theme.cpp.

◆ ~Theme()

Theme::~Theme ( )
override

Definition at line 244 of file theme.cpp.

Member Function Documentation

◆ drawProgressBar()

void Theme::drawProgressBar ( Graphics graphics,
const gcn::Rectangle &  area,
const gcn::Color &  color,
float  progress,
const std::string &  text = std::string(),
ProgressPalette  progressType = ProgressPalette::THEME_PROG_END 
) const

Definition at line 378 of file theme.cpp.

◆ drawSkin()

void Theme::drawSkin ( Graphics graphics,
SkinType  type,
const WidgetState state 
) const

Definition at line 373 of file theme.cpp.

◆ event()

void Theme::event ( Event::Channel  channel,
const Event event 
)
overridevirtual

Implements EventListener.

Definition at line 471 of file theme.cpp.

◆ getAvailableThemes()

std::vector< ThemeInfo > Theme::getAvailableThemes ( )
static

Definition at line 265 of file theme.cpp.

◆ getColor()

const gcn::Color & Theme::getColor ( int  type) const

Returns a color from the default palette (0).

Definition at line 333 of file theme.cpp.

◆ getColorIdForChar()

std::optional< int > Theme::getColorIdForChar ( char  c)
static

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

Returns no value if the character is not found.

Parameters
ccharacter requested
Returns
the requested color or none

Definition at line 338 of file theme.cpp.

◆ getGuiAlpha()

int Theme::getGuiAlpha ( ) const
inline

Get the current GUI alpha value.

Definition at line 321 of file theme.h.

◆ getIcon()

const Image * Theme::getIcon ( const std::string &  name) const

Definition at line 441 of file theme.cpp.

◆ getImage()

ResourceRef< Image > Theme::getImage ( const std::string &  path) const
private

Definition at line 303 of file theme.cpp.

◆ getImageFromTheme()

ResourceRef< Image > Theme::getImageFromTheme ( const std::string &  path)
static

Definition at line 308 of file theme.cpp.

◆ getMinimumOpacity()

float Theme::getMinimumOpacity ( ) const
inline

Get the minimum opacity allowed to skins.

Definition at line 326 of file theme.h.

◆ getPalette()

const Palette & Theme::getPalette ( size_t  index) const

Definition at line 328 of file theme.cpp.

◆ getProgressColor()

gcn::Color Theme::getProgressColor ( int  type,
float  progress 
)
static

Definition at line 318 of file theme.cpp.

◆ getSkin()

const Skin & Theme::getSkin ( SkinType  skinType) const

Definition at line 434 of file theme.cpp.

◆ getThemeColor()

const gcn::Color & Theme::getThemeColor ( int  type)
static

Gets the color associated with the type in the default palette (0).

Parameters
typethe color type requested
Returns
the requested color

Definition at line 313 of file theme.cpp.

◆ getThemePath()

const std::string & Theme::getThemePath ( ) const
inline

Definition at line 204 of file theme.h.

◆ prepareThemePath()

std::string Theme::prepareThemePath ( )
static

Definition at line 250 of file theme.cpp.

◆ readIconNode()

void Theme::readIconNode ( XML::Node  node)
private

Definition at line 739 of file theme.cpp.

◆ readPaletteNode()

void Theme::readPaletteNode ( XML::Node  node)
private

Definition at line 878 of file theme.cpp.

◆ readProgressBarNode()

void Theme::readProgressBarNode ( XML::Node  node)
private

Definition at line 918 of file theme.cpp.

◆ readSkinNode()

void Theme::readSkinNode ( XML::Node  node)
private

Definition at line 562 of file theme.cpp.

◆ readSkinStateImgNode()

void Theme::readSkinStateImgNode ( XML::Node  node,
SkinState state 
) const
private

Definition at line 648 of file theme.cpp.

◆ readSkinStateNode()

void Theme::readSkinStateNode ( XML::Node  node,
Skin skin 
) const
private

Definition at line 605 of file theme.cpp.

◆ readTheme()

bool Theme::readTheme ( const ThemeInfo themeInfo)
private

Definition at line 493 of file theme.cpp.

◆ resolvePath()

std::string Theme::resolvePath ( const std::string &  path) const

Returns the patch to the given GUI resource relative to the theme or, if it isn't in the theme, relative to 'graphics/gui'.

Definition at line 284 of file theme.cpp.

◆ setMinimumOpacity()

void Theme::setMinimumOpacity ( float  minimumOpacity)

Set the minimum opacity allowed to skins.

Set a negative value to free the minimum allowed.

Definition at line 450 of file theme.cpp.

◆ updateAlpha()

void Theme::updateAlpha ( )
private

Updates the alpha values of all of the skins and images.

Definition at line 459 of file theme.cpp.

Member Data Documentation

◆ mAlpha

float Theme::mAlpha = 1.0
private

Definition at line 361 of file theme.h.

◆ mIcons

std::map<std::string, Image *> Theme::mIcons
private

Definition at line 354 of file theme.h.

◆ mMinimumOpacity

float Theme::mMinimumOpacity = 0.0f
private

Tells if the current skins opacity should not get less than the given value.

Definition at line 360 of file theme.h.

◆ mPalettes

std::vector<Palette> Theme::mPalettes
private

Definition at line 363 of file theme.h.

◆ mProgressColors

std::array<std::unique_ptr<DyePalette>, THEME_PROG_END> Theme::mProgressColors
private

Definition at line 364 of file theme.h.

◆ mProgressTextFormats

std::array<std::optional<TextFormat>, THEME_PROG_END> Theme::mProgressTextFormats
private

Definition at line 365 of file theme.h.

◆ mSkins

std::map<SkinType, Skin> Theme::mSkins
private

Definition at line 353 of file theme.h.

◆ mThemePath

std::string Theme::mThemePath
private

Definition at line 352 of file theme.h.


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