| 1 |
// ____ _ __ |
| 2 |
// / __ )____ _____ | | / /___ ___________ |
| 3 |
// / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ |
| 4 |
// / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) |
| 5 |
// /_____/\____/____/ |__/|__/\__,_/_/ /____/ |
| 6 |
// |
| 7 |
// A futuristic real-time strategy game. |
| 8 |
// This file is part of Bos Wars. |
| 9 |
// |
| 10 |
/**@name icons.h - The icons headerfile. */ |
| 11 |
// |
| 12 |
// (c) Copyright 1998-2007 by Lutz Sammer |
| 13 |
// |
| 14 |
// This program is free software; you can redistribute it and/or modify |
| 15 |
// it under the terms of the GNU General Public License as published by |
| 16 |
// the Free Software Foundation; only version 2 of the License. |
| 17 |
// |
| 18 |
// This program is distributed in the hope that it will be useful, |
| 19 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
// GNU General Public License for more details. |
| 22 |
// |
| 23 |
// You should have received a copy of the GNU General Public License |
| 24 |
// along with this program; if not, write to the Free Software |
| 25 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 26 |
// 02111-1307, USA. |
| 27 |
|
| 28 |
#ifndef __ICONS_H__ |
| 29 |
#define __ICONS_H__ |
| 30 |
|
| 31 |
//@{ |
| 32 |
|
| 33 |
#include <string> |
| 34 |
#include <map> |
| 35 |
|
| 36 |
/*---------------------------------------------------------------------------- |
| 37 |
-- Documentation |
| 38 |
----------------------------------------------------------------------------*/ |
| 39 |
|
| 40 |
/** |
| 41 |
** @class CIcon icons.h |
| 42 |
** |
| 43 |
** \#include "icons.h" |
| 44 |
** |
| 45 |
** This structure contains all informations about an icon. |
| 46 |
** |
| 47 |
** The icon structure members: |
| 48 |
** |
| 49 |
** CIcon::Ident |
| 50 |
** |
| 51 |
** Unique identifier of the icon, used to reference it in config |
| 52 |
** files and during startup. Don't use this in game, use instead |
| 53 |
** the pointer to this structure. |
| 54 |
** |
| 55 |
** CIcon::G |
| 56 |
** |
| 57 |
** Graphic image containing the loaded graphics. Loaded by |
| 58 |
** LoadIcons(). All icons belonging to the same icon file shares |
| 59 |
** this structure. |
| 60 |
** |
| 61 |
** CIcon::Frame |
| 62 |
** |
| 63 |
** Frame number in the graphic to display. |
| 64 |
*/ |
| 65 |
|
| 66 |
/** |
| 67 |
** @class IconConfig icons.h |
| 68 |
** |
| 69 |
** \#include "icons.h" |
| 70 |
** |
| 71 |
** This structure contains all configuration informations about an icon. |
| 72 |
** |
| 73 |
** IconConfig::Name |
| 74 |
** |
| 75 |
** Unique identifier of the icon, used to reference icons in config |
| 76 |
** files and during startup. The name is resolved during game |
| 77 |
** start and the pointer placed in the next field. |
| 78 |
** @see CIcon::Ident |
| 79 |
** |
| 80 |
** IconConfig::Icon |
| 81 |
** |
| 82 |
** Pointer to an icon. This pointer is resolved during game start. |
| 83 |
*/ |
| 84 |
|
| 85 |
/*---------------------------------------------------------------------------- |
| 86 |
-- Defines |
| 87 |
----------------------------------------------------------------------------*/ |
| 88 |
|
| 89 |
#define IconActive 1 /// cursor on icon |
| 90 |
#define IconClicked 2 /// mouse button down on icon |
| 91 |
#define IconSelected 4 /// this the selected icon |
| 92 |
#define IconDisabled 8 /// icon disabled |
| 93 |
#define IconAutoCast 16 /// auto cast icon |
| 94 |
|
| 95 |
/*---------------------------------------------------------------------------- |
| 96 |
-- Declarations |
| 97 |
----------------------------------------------------------------------------*/ |
| 98 |
|
| 99 |
class CGraphic; |
| 100 |
class CPlayer; |
| 101 |
class ButtonStyle; |
| 102 |
|
| 103 |
/// Icon: rectangle image used in menus |
| 104 |
class CIcon { |
| 105 |
public: |
| 106 |
CIcon(const std::string &ident); |
| 107 |
~CIcon(); |
| 108 |
|
| 109 |
static CIcon *New(const std::string &ident); |
| 110 |
static CIcon *Get(const std::string &ident); |
| 111 |
|
| 112 |
/// Draw icon |
| 113 |
void DrawIcon(const CPlayer *player, int x, int y) const; |
| 114 |
/// Draw icon of a unit |
| 115 |
void DrawUnitIcon(const CPlayer *player, ButtonStyle *style, |
| 116 |
unsigned flags, int x, int y, const std::string &text) const; |
| 117 |
|
| 118 |
inline const std::string &GetIdent() { return this->Ident; } |
| 119 |
|
| 120 |
CGraphic *G; /// Graphic data |
| 121 |
int Frame; /// Frame number in graphic |
| 122 |
private: |
| 123 |
std::string Ident; /// Icon identifier |
| 124 |
}; |
| 125 |
|
| 126 |
/// Icon reference (used in config tables) |
| 127 |
class IconConfig { |
| 128 |
public: |
| 129 |
IconConfig() : Icon(NULL) {} |
| 130 |
|
| 131 |
void Load(); |
| 132 |
|
| 133 |
std::string Name; /// config icon name |
| 134 |
CIcon *Icon; /// icon pointer to use to run time |
| 135 |
}; |
| 136 |
|
| 137 |
extern std::map<std::string, CIcon *> Icons; |
| 138 |
|
| 139 |
/*---------------------------------------------------------------------------- |
| 140 |
-- Functions |
| 141 |
----------------------------------------------------------------------------*/ |
| 142 |
|
| 143 |
extern void InitIcons(void); /// Init icons |
| 144 |
extern void LoadIcons(void); /// Load icons |
| 145 |
extern void CleanIcons(void); /// Cleanup icons |
| 146 |
|
| 147 |
/// Register CCL features |
| 148 |
extern void IconCclRegister(void); |
| 149 |
|
| 150 |
//@} |
| 151 |
|
| 152 |
#endif // !__ICONS_H__ |