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

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
popup.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 2012 by Joris Dauphin
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 __POPUP_H__
31 #define __POPUP_H__
32 
34 
35 #include "script.h"
36 #include "color.h"
37 #include "vec2i.h"
38 #include <vector>
39 #include <string>
40 
41 /*----------------------------------------------------------------------------
42 -- Declarations
43 ----------------------------------------------------------------------------*/
44 
45 class ButtonAction;
46 class CFont;
47 class CPopup;
48 
49 #define MARGIN_X 4
50 #define MARGIN_Y 2
51 
53 {
54 public:
56  ButtonAction(-1), BoolFlags(NULL), Variables(NULL) {}
58  {
59  delete[] BoolFlags;
60  delete[] Variables;
61  }
62 
63  bool HasHint;
67  std::string ButtonValue;
68 
69  char *BoolFlags;
70  char *Variables;
71 };
72 
74 {
75 public:
78  Wrap(true), Condition(NULL) {}
79  virtual ~CPopupContentType() { delete Condition; }
80 
82  virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const = 0;
84  virtual int GetWidth(const ButtonAction &button, int *Costs) const = 0;
86  virtual int GetHeight(const ButtonAction &button, int *Costs) const = 0;
87 
88  virtual void Parse(lua_State *l) = 0;
89 
90  static CPopupContentType *ParsePopupContent(lua_State *l);
91 
92 public:
94 
95  int MarginX;
96  int MarginY;
98  bool Wrap;
99 protected:
100  std::string TextColor;
101  std::string HighlightColor;
102 public:
104 };
105 
110 };
111 
113 {
114 public:
115  CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(NULL) {}
117 
118  virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
119 
120  virtual int GetWidth(const ButtonAction &button, int *Costs) const;
121  virtual int GetHeight(const ButtonAction &button, int *Costs) const;
122 
123  virtual void Parse(lua_State *l);
124 
125 private:
126  int InfoType;
127  unsigned int MaxWidth;
128  CFont *Font;
129 };
130 
132 {
133 public:
134  CPopupContentTypeText() : MaxWidth(0), Font(NULL) {}
136 
137  virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
138 
139  virtual int GetWidth(const ButtonAction &button, int *Costs) const;
140  virtual int GetHeight(const ButtonAction &button, int *Costs) const;
141 
142  virtual void Parse(lua_State *l);
143 
144 private:
145  std::string Text;
146  unsigned int MaxWidth;
147  CFont *Font;
148 };
149 
151 {
152 public:
153  CPopupContentTypeCosts() : Font(NULL), Centered(0) {}
155 
156  virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
157 
158  virtual int GetWidth(const ButtonAction &button, int *Costs) const;
159  virtual int GetHeight(const ButtonAction &button, int *Costs) const;
160 
161  virtual void Parse(lua_State *l);
162 
163 private:
164  CFont *Font;
165  char Centered;
166 };
167 
169 {
170 public:
173 
174  virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
175 
176  virtual int GetWidth(const ButtonAction &button, int *Costs) const;
177  virtual int GetHeight(const ButtonAction &button, int *Costs) const;
178 
179  virtual void Parse(lua_State *l);
180 
181 private:
182  IntColor Color;
183  unsigned int Width;
184  unsigned int Height;
185 };
186 
188 {
189 public:
190  CPopupContentTypeVariable() : Text(NULL), Font(NULL), Centered(0), Index(-1) {}
192  {
193  FreeStringDesc(Text);
194  delete Text;
195  }
196 
197  virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const;
198 
199  virtual int GetWidth(const ButtonAction &button, int *Costs) const;
200  virtual int GetHeight(const ButtonAction &button, int *Costs) const;
201 
202  virtual void Parse(lua_State *l);
203 
204 private:
205  StringDesc *Text;
206  CFont *Font;
207  char Centered;
208  int Index;
209 };
210 
211 class CPopup
212 {
213 public:
214  CPopup();
215  ~CPopup();
216 
217  std::vector<CPopupContentType *> Contents;
218  std::string Ident;
219  int MarginX;
220  int MarginY;
221  int MinWidth;
222  int MinHeight;
226 };
227 
228 
230 
231 #endif // !__UI_H__
virtual void Parse(lua_State *l)
Definition: popup.cpp:424
std::string HighlightColor
Color used for plain text in content.
Definition: popup.h:101
int MinHeight
Minimal width covered by popup.
Definition: popup.h:222
Definition: popup.h:187
virtual int GetHeight(const ButtonAction &button, int *Costs) const
Get the content's height.
Definition: popup.cpp:383
virtual int GetWidth(const ButtonAction &button, int *Costs) const
Get the content's width.
Definition: popup.cpp:160
virtual ~CPopupContentTypeVariable()
Definition: popup.h:191
virtual ~CPopupContentType()
Definition: popup.h:79
bool Wrap
Minimal size covered by content type.
Definition: popup.h:98
IntColor BorderColor
Color used for popup's background.
Definition: popup.h:225
CFont * DefaultFont
Minimal height covered by popup.
Definition: popup.h:223
virtual void Parse(lua_State *l)
Definition: popup.cpp:135
CPopup()
Definition: popup.cpp:612
CPopupContentTypeButtonInfo()
Definition: popup.h:115
virtual int GetHeight(const ButtonAction &button, int *Costs) const
Get the content's height.
Definition: popup.cpp:262
virtual int GetWidth(const ButtonAction &button, int *Costs) const
Get the content's width.
Definition: popup.cpp:49
char * Variables
array of condition about user flags.
Definition: popup.h:70
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
Tell how show the variable Index.
Definition: popup.cpp:348
~PopupConditionPanel()
Definition: popup.h:57
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
Tell how show the variable Index.
Definition: popup.cpp:187
int ButtonAction
check if button has dependencies or restrictions.
Definition: popup.h:66
virtual ~CPopupContentTypeCosts()
Definition: popup.h:154
virtual void Parse(lua_State *l)
Definition: popup.cpp:315
Definition: popup.h:73
PopupConditionPanel * Condition
Color used for highlighted letters.
Definition: popup.h:103
std::vector< CPopupContentType * > Contents
Definition: popup.h:217
bool HasDependencies
check if button has description.
Definition: popup.h:65
virtual ~CPopupContentTypeButtonInfo()
Definition: popup.h:116
Definition: popup.h:112
virtual void Parse(lua_State *l)
Definition: popup.cpp:203
CPopupContentTypeLine()
Definition: popup.cpp:333
virtual int GetHeight(const ButtonAction &button, int *Costs) const
Get the content's height.
Definition: popup.cpp:343
char * BoolFlags
value used in ValueStr field of button
Definition: popup.h:69
Definition: popup.h:52
PixelSize minSize
Upper and lower margin height.
Definition: popup.h:97
Action of button.
Definition: interface.h:87
int MarginY
Left and right margin width.
Definition: popup.h:96
bool HasHint
Definition: popup.h:63
CPopupContentTypeText()
Definition: popup.h:134
CPopupContentType()
Definition: popup.h:76
Font definition.
Definition: font.h:73
int MarginX
Ident of the popup.
Definition: popup.h:219
PopupConditionPanel()
Definition: popup.h:55
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
Tell how show the variable Index.
Definition: popup.cpp:104
CPopupContentTypeCosts()
Definition: popup.h:153
virtual int GetWidth(const ButtonAction &button, int *Costs) const
Get the content's width.
Definition: popup.cpp:374
int MarginY
Left and right margin width.
Definition: popup.h:220
Definition: popup.h:150
IntColor BackgroundColor
Default font for content.
Definition: popup.h:224
Definition: script.h:258
virtual int GetHeight(const ButtonAction &button, int *Costs) const
Get the content's height.
Definition: popup.cpp:78
std::string TextColor
If true, the next content will be placed on the next "line".
Definition: popup.h:100
virtual int GetWidth(const ButtonAction &button, int *Costs) const
Get the content's width.
Definition: popup.cpp:338
bool HasDescription
check if button has hint.
Definition: popup.h:64
virtual ~CPopupContentTypeText()
Definition: popup.h:135
Definition: popup.h:131
CPopupContentTypeVariable()
Definition: popup.h:190
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const =0
Tell how show the variable Index.
virtual void Parse(lua_State *l)=0
std::string ButtonValue
action type of button
Definition: popup.h:67
virtual int GetHeight(const ButtonAction &button, int *Costs) const
Get the content's height.
Definition: popup.cpp:176
std::string Ident
Array of contents to display.
Definition: popup.h:218
virtual ~CPopupContentTypeLine()
Definition: popup.h:172
virtual int GetHeight(const ButtonAction &button, int *Costs) const =0
Get the content's height.
Definition: png2stratagus.cpp:57
Definition: popup.h:168
~CPopup()
Definition: popup.cpp:617
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
Tell how show the variable Index.
Definition: popup.cpp:275
uint32_t IntColor
Definition: color.h:74
virtual int GetWidth(const ButtonAction &button, int *Costs) const =0
Get the content's width.
PixelPos pos
Definition: popup.h:93
static CPopupContentType * ParsePopupContent(lua_State *l)
Definition: popup.cpp:547
virtual void Draw(int x, int y, const CPopup &popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const
Tell how show the variable Index.
Definition: popup.cpp:389
Definition: popup.h:211
int MinWidth
Upper and lower margin height.
Definition: popup.h:221
void FreeStringDesc(StringDesc *s)
Free unit description content. (no pointer itself).
Definition: script.cpp:1229
virtual int GetWidth(const ButtonAction &button, int *Costs) const
Get the content's width.
Definition: popup.cpp:221
virtual void Parse(lua_State *l)
Definition: popup.cpp:354
int MarginX
position to draw.
Definition: popup.h:95
(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.