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

contenttype.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 1999-2012 by Lutz Sammer and Jimmy Salmon
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 __CONTENT_TYPE_H__
31 #define __CONTENT_TYPE_H__
32 
34 
35 #include "color.h"
36 #include "script.h"
37 #include "vec2i.h"
38 #include <vector>
39 
40 class CUnit;
41 class CFont;
42 class ConditionPanel;
43 
48 {
49 public:
50  CContentType() : Pos(0, 0), Condition(NULL) {}
51  virtual ~CContentType();
52 
54  virtual void Draw(const CUnit &unit, CFont *defaultfont) const = 0;
55 
56  virtual void Parse(lua_State *l) = 0;
57 
58 public:
61 };
62 
67 {
68 public:
69  CContentTypeText() : Text(NULL), Font(NULL), Centered(0), Index(-1),
70  Component(VariableValue), ShowName(0), Stat(0) {}
72  {
73  FreeStringDesc(Text);
74  delete Text;
75  }
76 
77  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
78  virtual void Parse(lua_State *l);
79 
80 private:
81  StringDesc *Text;
82  CFont *Font;
83  char Centered;
84  int Index;
85  EnumVariable Component;
86  char ShowName;
87  char Stat;
88 };
89 
94 {
95 public:
96  CContentTypeFormattedText() : Font(NULL), Centered(false),
97  Index(-1), Component(VariableValue) {}
99 
100  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
101  virtual void Parse(lua_State *l);
102 
103 private:
104  std::string Format;
105  CFont *Font;
106  bool Centered;
107  int Index;
108  EnumVariable Component;
109 };
110 
115 {
116 public:
117  CContentTypeFormattedText2() : Font(NULL), Centered(false),
118  Index1(-1), Component1(VariableValue), Index2(-1), Component2(VariableValue) {}
120 
121  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
122  virtual void Parse(lua_State *l);
123 
124 private:
125  std::string Format;
126  CFont *Font;
127  bool Centered;
128  int Index1;
129  EnumVariable Component1;
130  int Index2;
131  EnumVariable Component2;
132 };
133 
138 {
139 public:
140  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
141  virtual void Parse(lua_State *l);
142 
143 private:
144  EnumUnit UnitRef;
145  unsigned ButtonIcon:1;
146  unsigned SingleSelectionIcon:1;
147  unsigned GroupSelectionIcon:1;
148  unsigned TransportIcon:1;
149 };
150 
155 {
156 public:
157  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
158  virtual void Parse(lua_State *l);
159 
160 private:
161  std::string graphic;
162  int frame;
163 };
164 
169 {
170 public:
171  CContentTypeLifeBar() : Index(-1), ValueFunc(NULL), ValueMax(-1), Width(0), Height(0), hasBorder(1), colors(NULL), values(NULL) {}
173  {
174  FreeNumberDesc(ValueFunc);
175  delete[] colors;
176  delete[] values;
177  }
178 
179  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
180  virtual void Parse(lua_State *l);
181 
182 private:
183  int Index;
184  NumberDesc *ValueFunc;
185  int ValueMax;
186  int Width;
187  int Height;
188  IntColor hasBorder;
189  unsigned int *colors;
190  unsigned int *values;
191 };
192 
197 {
198 public:
199  CContentTypeCompleteBar() : varIndex(-1), width(0), height(0), hasBorder(false), colorIndex(-1) {}
200 
201  virtual void Draw(const CUnit &unit, CFont *defaultfont) const;
202  virtual void Parse(lua_State *l);
203 
204 private:
205  int varIndex;
206  int width;
207  int height;
208  bool hasBorder;
209  int colorIndex;
210 };
211 
212 
214 
215 #endif // __CONTENT_TYPE_H__
CContentTypeFormattedText2::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:180
CContentTypeCompleteBar::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:347
CContentTypeLifeBar::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:569
CContentTypeFormattedText2::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:442
CContentType
Definition: contenttype.h:47
CContentTypeFormattedText::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:416
ConditionPanel
Definition: ui.h:185
IntColor
uint32_t IntColor
Definition: color.h:37
CContentTypeGraphic::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:276
vec2i.h
VariableValue
@ VariableValue
Definition: script.h:159
CContentTypeFormattedText::~CContentTypeFormattedText
virtual ~CContentTypeFormattedText()
Definition: contenttype.h:98
CContentTypeCompleteBar::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:676
Vec2T< int >
CContentType::Parse
virtual void Parse(lua_State *l)=0
CContentTypeFormattedText2
Definition: contenttype.h:114
CContentTypeText::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:380
CContentTypeFormattedText::CContentTypeFormattedText
CContentTypeFormattedText()
Definition: contenttype.h:96
CContentType::Pos
PixelPos Pos
Definition: contenttype.h:59
CContentTypeText
Definition: contenttype.h:66
NumberDesc
Definition: script.h:206
CContentTypeLifeBar::CContentTypeLifeBar
CContentTypeLifeBar()
Definition: contenttype.h:171
CContentType::CContentType
CContentType()
Definition: contenttype.h:50
CContentTypeIcon::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:255
CContentTypeFormattedText2::~CContentTypeFormattedText2
virtual ~CContentTypeFormattedText2()
Definition: contenttype.h:119
CContentTypeGraphic
Definition: contenttype.h:154
CContentTypeFormattedText2::CContentTypeFormattedText2
CContentTypeFormattedText2()
Definition: contenttype.h:117
FreeNumberDesc
void FreeNumberDesc(NumberDesc *number)
Evaluate the string.
Definition: script.cpp:1224
CContentTypeText::CContentTypeText
CContentTypeText()
Definition: contenttype.h:69
StringDesc
Definition: script.h:259
EnumUnit
EnumUnit
Definition: script.h:170
CContentTypeGraphic::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:552
CContentTypeText::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:70
CContentTypeLifeBar::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:297
CContentTypeText::~CContentTypeText
virtual ~CContentTypeText()
Definition: contenttype.h:71
CContentTypeLifeBar::~CContentTypeLifeBar
virtual ~CContentTypeLifeBar()
Definition: contenttype.h:172
CContentTypeCompleteBar::CContentTypeCompleteBar
CContentTypeCompleteBar()
Definition: contenttype.h:199
CContentTypeIcon::Parse
virtual void Parse(lua_State *l)
Definition: contenttype.cpp:517
CContentTypeFormattedText::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const
Definition: contenttype.cpp:141
CContentTypeFormattedText
Definition: contenttype.h:93
CContentType::Condition
ConditionPanel * Condition
Coordinate where to display.
Definition: contenttype.h:60
script.h
CContentType::Draw
virtual void Draw(const CUnit &unit, CFont *defaultfont) const =0
Tell how show the variable Index.
CContentTypeIcon
Definition: contenttype.h:137
FreeStringDesc
void FreeStringDesc(StringDesc *s)
Free unit description content. (no pointer itself).
Definition: script.cpp:1294
UnitRef
unsigned short UnitRef
Definition: commands.h:129
EnumVariable
EnumVariable
Definition: script.h:158
CContentTypeLifeBar
Definition: contenttype.h:168
CContentTypeCompleteBar
Definition: contenttype.h:196
CUnit
The big unit structure.
Definition: unit.h:135
CContentType::~CContentType
virtual ~CContentType()
Definition: contenttype.cpp:59
CFont
Font definition.
Definition: font.h:73
(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.