_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

icons.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2005 by Lutz Sammer
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __ICONS_H__
31 #define __ICONS_H__
32 
34 
35 #include "vec2i.h"
36 #include "color.h"
37 #include <string>
38 
39 /*----------------------------------------------------------------------------
40 -- Documentation
41 ----------------------------------------------------------------------------*/
42 
88 /*----------------------------------------------------------------------------
89 -- Defines
90 ----------------------------------------------------------------------------*/
91 
92 #define IconActive 1
93 #define IconClicked 2
94 #define IconSelected 4
95 #define IconDisabled 8
96 #define IconAutoCast 16
97 
98 /*----------------------------------------------------------------------------
99 -- Declarations
100 ----------------------------------------------------------------------------*/
101 
102 class CUnit;
103 class CGraphic;
104 class CPlayerColorGraphic;
105 class CPlayer;
106 class ButtonStyle;
107 
109 class CIcon
110 {
111 public:
112  CIcon(const std::string &ident);
113  ~CIcon();
114 
115  static CIcon *New(const std::string &ident);
116  static CIcon *Get(const std::string &ident);
117 
118  void Load();
119 
121  void DrawIcon(const PixelPos &pos, const int player = -1) const;
123  void DrawGrayscaleIcon(const PixelPos &pos, const int player = -1) const;
125  void DrawCooldownSpellIcon(const PixelPos &pos, const int percent) const;
127  void DrawUnitIcon(const ButtonStyle &style,
128  unsigned flags, const PixelPos &pos, const std::string &text, const int playerIndex = -1) const;
129  void DrawSingleSelectionIcon(const ButtonStyle &style,
130  unsigned flags, const PixelPos &pos, const std::string &text, const CUnit &unit) const;
131  void DrawGroupSelectionIcon(const ButtonStyle &style,
132  unsigned flags, const PixelPos &pos, const std::string &text, const CUnit &unit) const;
133  void DrawContainedIcon(const ButtonStyle &style,
134  unsigned flags, const PixelPos &pos, const std::string &text, const CUnit &unit) const;
135 
136  const std::string &GetIdent() const { return this->Ident; }
137 
139  void ClearExtraGraphics();
143 
144  void SetPaletteSwaps(std::vector<PaletteSwap> &newSwaps);
145 
146 public:
149  int Frame;
150 private:
151  std::string Ident;
152 
153  /*
154  * These following lists of icons are used to allow different icons for single and multi-selection as
155  * well as when the unit is contained in some container like a transport or a bunker.
156  * Additionally, these are lists, and the health percentage of the unit is mapped into this list. this
157  * way, units can have different (damaged) icons. all of these are optional, the default is to just use
158  * the graphic stored in the *G field above.
159  */
160  std::vector<CPlayerColorGraphic *> SingleSelectionG;
161  std::vector<CPlayerColorGraphic *> GroupSelectionG;
162  std::vector<CPlayerColorGraphic *> ContainedG;
163 
164  /*
165  * These following lists are used to map percentages of arbitrary unit variables (e.g. health, shield,
166  * mana, ...) to palette swaps in the selection icons.
167  */
168  std::vector<PaletteSwap> PaletteSwaps;
169 };
170 
173 {
174 public:
175  IconConfig() : Icon(NULL) {}
176 
177  bool LoadNoLog();
178  bool Load();
179 public:
180  std::string Name;
182 };
183 
184 /*----------------------------------------------------------------------------
185 -- Functions
186 ----------------------------------------------------------------------------*/
187 
188 extern void LoadIcons();
189 extern void CleanIcons();
190 
192 
193 #endif // !__ICONS_H__
CPlayer
Diplomacy states for CommandDiplomacy.
Definition: player.h:83
CIcon::DrawSingleSelectionIcon
void DrawSingleSelectionIcon(const ButtonStyle &style, unsigned flags, const PixelPos &pos, const std::string &text, const CUnit &unit) const
Definition: icons.cpp:233
IconConfig::Icon
CIcon * Icon
config icon name
Definition: icons.h:181
CIcon::DrawGroupSelectionIcon
void DrawGroupSelectionIcon(const ButtonStyle &style, unsigned flags, const PixelPos &pos, const std::string &text, const CUnit &unit) const
Definition: icons.cpp:239
IconConfig
Icon reference (used in config tables)
Definition: icons.h:172
CIcon::New
static CIcon * New(const std::string &ident)
Definition: icons.cpp:86
CIcon::DrawContainedIcon
void DrawContainedIcon(const ButtonStyle &style, unsigned flags, const PixelPos &pos, const std::string &text, const CUnit &unit) const
Definition: icons.cpp:245
vec2i.h
CIcon
Icon: rectangle image used in menus.
Definition: icons.h:109
CIcon::AddGroupSelectionGraphic
void AddGroupSelectionGraphic(CPlayerColorGraphic *g)
Definition: icons.cpp:263
CIcon::SetPaletteSwaps
void SetPaletteSwaps(std::vector< PaletteSwap > &newSwaps)
Definition: icons.cpp:273
Vec2T< int >
CleanIcons
void CleanIcons()
Load icons.
Definition: icons.cpp:403
IconConfig::LoadNoLog
bool LoadNoLog()
Definition: icons.cpp:363
CIcon::GScale
CPlayerColorGraphic * GScale
Graphic data.
Definition: icons.h:148
ButtonStyle
Definition: ui.h:104
CIcon::AddContainedGraphic
void AddContainedGraphic(CPlayerColorGraphic *g)
Definition: icons.cpp:268
CIcon::DrawIcon
void DrawIcon(const PixelPos &pos, const int player=-1) const
Draw icon.
Definition: icons.cpp:149
IconConfig::Name
std::string Name
Definition: icons.h:180
CIcon::CIcon
CIcon(const std::string &ident)
Map of ident to icon.
Definition: icons.cpp:64
CIcon::DrawUnitIcon
void DrawUnitIcon(const ButtonStyle &style, unsigned flags, const PixelPos &pos, const std::string &text, const int playerIndex=-1) const
Draw icon of a unit.
Definition: icons.cpp:289
CIcon::Load
void Load()
Definition: icons.cpp:112
CIcon::G
CPlayerColorGraphic * G
Definition: icons.h:147
CIcon::GetIdent
const std::string & GetIdent() const
Definition: icons.h:136
IconConfig::IconConfig
IconConfig()
Definition: icons.h:175
CIcon::DrawGrayscaleIcon
void DrawGrayscaleIcon(const PixelPos &pos, const int player=-1) const
Draw grayscale icon.
Definition: icons.cpp:163
CIcon::~CIcon
~CIcon()
Definition: icons.cpp:72
CIcon::DrawCooldownSpellIcon
void DrawCooldownSpellIcon(const PixelPos &pos, const int percent) const
Draw cooldown spell.
Definition: icons.cpp:180
IconConfig::Load
bool Load()
Definition: icons.cpp:376
color.h
CIcon::ClearExtraGraphics
void ClearExtraGraphics()
Modify the extra icon graphics.
Definition: icons.cpp:251
CIcon::Frame
int Frame
Icon when drawn grayscaled.
Definition: icons.h:149
CIcon::Get
static CIcon * Get(const std::string &ident)
Definition: icons.cpp:103
LoadIcons
void LoadIcons()
Definition: icons.cpp:390
CUnit
The big unit structure.
Definition: unit.h:135
CPlayerColorGraphic
Definition: video.h:202
CIcon::AddSingleSelectionGraphic
void AddSingleSelectionGraphic(CPlayerColorGraphic *g)
Definition: icons.cpp:258
CGraphic
Definition: video.h:91
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.