Skip to content

Commit 05740fe

Browse files
committed
Get latest GUI sources from RTE
Correct some paths Replace some custom methods/macros with std variants
1 parent 333ac60 commit 05740fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1699
-1351
lines changed

Editor/GUIEditorApp.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "AllegroInput.h"
1010
#include "AllegroBitmap.h"
1111

12+
#include "RTEError.h"
13+
1214
namespace RTE {
1315

1416
volatile bool g_Quit;
@@ -826,8 +828,8 @@ void GUIEditorApp::CalculateHandleResize(int MouseX, int MouseY, int *X, int *Y,
826828
CtrlHeight += Diff;
827829
}
828830

829-
CtrlWidth = MAX(CtrlWidth, MinSize);
830-
CtrlHeight = MAX(CtrlHeight, MinSize);
831+
CtrlWidth = std::max(CtrlWidth, MinSize);
832+
CtrlHeight = std::max(CtrlHeight, MinSize);
831833

832834
*X = CtrlX;
833835
*Y = CtrlY;

GUI/GUI.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "GUI.h"
2+
3+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4+
5+
void SetRect(GUIRect *pRect, int left, int top, int right, int bottom) {
6+
pRect->left = left;
7+
pRect->top = top;
8+
pRect->right = right;
9+
pRect->bottom = bottom;
10+
}

GUI/GUI.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
#ifndef _GUI_
22
#define _GUI_
33

4+
#pragma region Rectangle Structure
45
/// <summary>
5-
/// Main header file for the GUI library.
6-
/// Original Author: Jason Boettcher
7-
8-
/// www.shplorb.com/~jackal
6+
/// The GUIRect structure defines a rectangle by the coordinates of its upper-left and lower-right corners.
97
/// </summary>
8+
struct GUIRect { long left; long top; long right; long bottom; };
109

11-
#include "GUIUtil.h"
12-
#include "GUIInterface.h"
10+
/// <summary>
11+
/// Sets the bounds of a GUIRect.
12+
/// </summary>
13+
/// <param name="pRect">Pointer to the GUIRect.</param>
14+
/// <param name="left">Position of top left corner on X axis.</param>
15+
/// <param name="top">Position of top left corner on Y axis.</param>
16+
/// <param name="right">Position of bottom right corner on X axis.</param>
17+
/// <param name="bottom">Position of bottom right corner on Y axis.</param>
18+
void SetRect(GUIRect *pRect, int left, int top, int right, int bottom);
19+
#pragma endregion
20+
21+
//#include "RTETools.h"
22+
23+
#include "Interface.h"
1324
#include "GUIProperties.h"
1425
#include "GUIInput.h"
1526
#include "GUIFont.h"
1627
#include "GUISkin.h"
1728
#include "GUIPanel.h"
1829
#include "GUIManager.h"
30+
#include "GUIUtil.h"
1931
#include "GUIControl.h"
2032
#include "GUIEvent.h"
2133
#include "GUIControlFactory.h"

GUI/GUIBanner.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
namespace RTE {
1818

19-
std::map<std::string, GUIBanner::FontChar *> GUIBanner::m_sFontCache;
20-
std::map<std::string, int> GUIBanner::m_sCharCapCache;
19+
map<string, GUIBanner::FontChar *> GUIBanner::m_sFontCache;
20+
map<string, int> GUIBanner::m_sCharCapCache;
2121

2222

2323
//////////////////////////////////////////////////////////////////////////////////////////
@@ -59,20 +59,19 @@ GUIBanner::GUIBanner()
5959
bool GUIBanner::Create(const std::string fontFilePath, const std::string fontBlurFilePath, int bitDepth)
6060
{
6161
// Package the font bitmap paths o they are more easily processed below
62-
std::string filePaths[2] = {fontFilePath, fontBlurFilePath};
62+
string filePaths[2] = {fontFilePath, fontBlurFilePath};
6363

6464
// Now process them and extract the character data from each
6565
ContentFile fontFile;
66-
std::map<std::string, FontChar *>::iterator fontItr;
67-
std::map<std::string, int>::iterator indexItr;
66+
map<string, FontChar *>::iterator fontItr;
67+
map<string, int>::iterator indexItr;
6868
int y, dotColor;
6969
for (int mode = REGULAR; mode < FONTMODECOUNT; ++mode)
7070
{
7171
// Load the font images
7272
fontFile.SetDataPath(filePaths[mode].c_str());
7373
m_pFontImage[mode] = fontFile.GetAsBitmap(bitDepth == 8 ? COLORCONV_REDUCE_TO_256 : COLORCONV_8_TO_32);
74-
//RTEAssert(m_pFontImage[mode], "Couldn't load font bitmap for banner font from this file:\n" + fontFilePath);
75-
assert(m_pFontImage[mode]);
74+
RTEAssert(m_pFontImage[mode], "Couldn't load font bitmap for banner font from this file:\n" + fontFilePath);
7675

7776
// Check the color key to be the same color as the Bottom-Right hand corner pixel
7877
int keyColor = getpixel(m_pFontImage[mode], m_pFontImage[mode]->w - 1, m_pFontImage[mode]->h - 1);
@@ -158,7 +157,7 @@ bool GUIBanner::Create(const std::string fontFilePath, const std::string fontBlu
158157
{
159158
int Pixel = getpixel(m_pFontImage[mode], i, j);
160159
if (Pixel != dotColor && Pixel != keyColor)
161-
Height = MAX(Height, j - y);
160+
Height = std::max(Height, j - y);
162161
}
163162
}
164163

@@ -183,14 +182,14 @@ bool GUIBanner::Create(const std::string fontFilePath, const std::string fontBlu
183182

184183
// Add the calculated charIndexcap to the cache so we can use it in other banner instances
185184
// that use the same font bitmap files.
186-
m_sCharCapCache.insert(std::pair<std::string, int>(filePaths[mode], m_CharIndexCap));
185+
m_sCharCapCache.insert(pair<string, int>(filePaths[mode], m_CharIndexCap));
187186
// Also add the now calculated font char data to the cache
188187
// Allocate a dynamic array to throw into the map.. probably until app close
189188
FontChar *aNewCache = new FontChar[MAXBANNERFONTCHARS];
190189
// Copy the font data into the cache
191190
memcpy(aNewCache, m_aaFontChars[mode], sizeof(FontChar) * MAXBANNERFONTCHARS);
192191
// Now put it into the cache map
193-
m_sFontCache.insert(std::pair<std::string, FontChar *>(filePaths[mode], aNewCache));
192+
m_sFontCache.insert(pair<string, FontChar *>(filePaths[mode], aNewCache));
194193
}
195194

196195
return true;
@@ -229,7 +228,7 @@ int GUIBanner::SpaceBetween(const FlyingChar &first, FontMode firstMode, const F
229228
//////////////////////////////////////////////////////////////////////////////////////////
230229
// Description: Starts the display animation of a text string in this banner's font.
231230

232-
void GUIBanner::ShowText(const std::string text, AnimMode mode, long duration, Vector targetSize, float yOnTarget, int flySpeed, int flySpacing)
231+
void GUIBanner::ShowText(const string text, AnimMode mode, long duration, Vector targetSize, float yOnTarget, int flySpeed, int flySpacing)
233232
{
234233
m_BannerText = text;
235234
m_AnimMode = mode;
@@ -250,7 +249,7 @@ void GUIBanner::ShowText(const std::string text, AnimMode mode, long duration, V
250249
// The showing position for the first character
251250
int showPosX = (m_TargetSize.m_X / 2) - (CalculateWidth(text, REGULAR) / 2);
252251
int whichChar = 0;
253-
for (std::string::const_iterator tItr = text.begin(); tItr != text.end(); ++tItr)
252+
for (string::const_iterator tItr = text.begin(); tItr != text.end(); ++tItr)
254253
{
255254
whichChar++;
256255
// Create the flying character entry
@@ -324,8 +323,8 @@ void GUIBanner::Update()
324323
int flyDirection = m_AnimMode == FLYBYLEFTWARD ? -1 : 1;
325324
int whichChar = 0;
326325
// Go through every character, updating their positions and states
327-
std::list<FlyingChar>::iterator prevItr = m_BannerChars.end();
328-
for (std::list<FlyingChar>::iterator cItr = m_BannerChars.begin(); cItr != m_BannerChars.end(); ++cItr)
326+
list<FlyingChar>::iterator prevItr = m_BannerChars.end();
327+
for (list<FlyingChar>::iterator cItr = m_BannerChars.begin(); cItr != m_BannerChars.end(); ++cItr)
329328
{
330329
whichChar++;
331330
// Start off each character's motion at the appropriate order and timing
@@ -419,7 +418,7 @@ void GUIBanner::Draw(BITMAP *pTargetBitmap)
419418
// Go through every character in the banner, drawing the ones that are showing
420419
unsigned char c;
421420
int mode, charWidth, offX, offY;
422-
for (std::list<FlyingChar>::iterator cItr = m_BannerChars.begin(); cItr != m_BannerChars.end(); ++cItr)
421+
for (list<FlyingChar>::iterator cItr = m_BannerChars.begin(); cItr != m_BannerChars.end(); ++cItr)
423422
{
424423
// Only draw anything if the character is even visible
425424
if ((*cItr).m_MoveState >= SHOWING && (*cItr).m_MoveState <= HIDING)

GUI/GUIBanner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
#include "Vector.h"
1515
#include "Timer.h"
16+
#include "allegro.h"
1617

1718
struct BITMAP;
1819

1920
#define MAXBANNERFONTCHARS 256
2021

21-
using namespace RTE;
2222
namespace RTE
2323
{
2424

GUI/GUIButton.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void GUIButton::BuildBitmap(void)
147147
m_DrawBitmap = m_Skin->CreateBitmap(m_Width, m_Height*3);
148148

149149
// Pre-cache the font
150-
std::string Filename;
150+
string Filename;
151151
m_Skin->GetValue("Button_Up", "Font", &Filename);
152152
m_Skin->GetValue("Button_Up", "FontColor", &m_FontColor);
153153
m_Skin->GetValue("Button_Up", "FontShadow", &m_FontShadow);
@@ -367,7 +367,7 @@ void GUIButton::StoreProperties(void)
367367
//////////////////////////////////////////////////////////////////////////////////////////
368368
// Description: Sets the text.
369369

370-
void GUIButton::SetText(const std::string Text)
370+
void GUIButton::SetText(const string Text)
371371
{
372372
m_Text = Text;
373373

@@ -380,7 +380,7 @@ void GUIButton::SetText(const std::string Text)
380380
//////////////////////////////////////////////////////////////////////////////////////////
381381
// Description: Gets the text.
382382

383-
std::string GUIButton::GetText(void)
383+
string GUIButton::GetText(void)
384384
{
385385
return m_Text;
386386
}

GUI/GUIButton.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GUIButton :
5757
// Description: Called when the control has been created.
5858
// Arguments: Name, Position.
5959

60-
void Create(const std::string Name, int X, int Y, int Width = -1, int Height = -1);
60+
void Create(const std::string Name, int X, int Y, int Width = -1, int Height = -1) override;
6161

6262

6363
//////////////////////////////////////////////////////////////////////////////////////////
@@ -66,7 +66,7 @@ class GUIButton :
6666
// Description: Called when the control has been destroyed.
6767
// Arguments: None.
6868

69-
void Destroy(void);
69+
void Destroy() override;
7070

7171

7272
//////////////////////////////////////////////////////////////////////////////////////////
@@ -75,7 +75,7 @@ class GUIButton :
7575
// Description: Called when the control has been created.
7676
// Arguments: Properties.
7777

78-
void Create(GUIProperties *Props);
78+
void Create(GUIProperties *Props) override;
7979

8080

8181
//////////////////////////////////////////////////////////////////////////////////////////
@@ -84,7 +84,7 @@ class GUIButton :
8484
// Description: Called when the skin has been changed.
8585
// Arguments: New skin pointer.
8686

87-
void ChangeSkin(GUISkin *Skin);
87+
void ChangeSkin(GUISkin *Skin) override;
8888

8989

9090
//////////////////////////////////////////////////////////////////////////////////////////
@@ -93,7 +93,7 @@ class GUIButton :
9393
// Description: Draws the panel
9494
// Arguments: Screen class
9595

96-
void Draw(GUIScreen *Screen);
96+
void Draw(GUIScreen *Screen) override;
9797

9898

9999
//////////////////////////////////////////////////////////////////////////////////////////
@@ -102,7 +102,7 @@ class GUIButton :
102102
// Description: Called when the mouse goes down on the panel
103103
// Arguments: Mouse Position, Mouse Buttons, Modifier.
104104

105-
void OnMouseDown(int X, int Y, int Buttons, int Modifier);
105+
void OnMouseDown(int X, int Y, int Buttons, int Modifier) override;
106106

107107

108108
//////////////////////////////////////////////////////////////////////////////////////////
@@ -111,7 +111,7 @@ class GUIButton :
111111
// Description: Called when the mouse goes up on the panel
112112
// Arguments: Mouse Position, Mouse Buttons, Modifier.
113113

114-
void OnMouseUp(int X, int Y, int Buttons, int Modifier);
114+
void OnMouseUp(int X, int Y, int Buttons, int Modifier) override;
115115

116116

117117
//////////////////////////////////////////////////////////////////////////////////////////
@@ -120,7 +120,7 @@ class GUIButton :
120120
// Description: Called when the mouse moves (over the panel, or when captured).
121121
// Arguments: Mouse Position, Mouse Buttons, Modifier.
122122

123-
void OnMouseMove(int X, int Y, int Buttons, int Modifier);
123+
void OnMouseMove(int X, int Y, int Buttons, int Modifier) override;
124124

125125

126126
//////////////////////////////////////////////////////////////////////////////////////////
@@ -129,7 +129,7 @@ class GUIButton :
129129
// Description: Called when the mouse enters the panel.
130130
// Arguments: Mouse Position, Mouse Buttons, Modifier.
131131

132-
void OnMouseEnter(int X, int Y, int Buttons, int Modifier);
132+
void OnMouseEnter(int X, int Y, int Buttons, int Modifier) override;
133133

134134

135135
//////////////////////////////////////////////////////////////////////////////////////////
@@ -138,7 +138,7 @@ class GUIButton :
138138
// Description: Called when the mouse leaves the panel.
139139
// Arguments: Mouse Position, Mouse Buttons, Modifier.
140140

141-
void OnMouseLeave(int X, int Y, int Buttons, int Modifier);
141+
void OnMouseLeave(int X, int Y, int Buttons, int Modifier) override;
142142

143143

144144
//////////////////////////////////////////////////////////////////////////////////////////
@@ -147,7 +147,7 @@ class GUIButton :
147147
// Description: Called when a key goes down.
148148
// Arguments: KeyCode, Modifier.
149149

150-
virtual void OnKeyDown(int KeyCode, int Modifier);
150+
void OnKeyDown(int KeyCode, int Modifier) override;
151151

152152

153153
//////////////////////////////////////////////////////////////////////////////////////////
@@ -157,7 +157,7 @@ class GUIButton :
157157
// Arguments: None.
158158
// Returns: 0 if the control does not have a panel, otherwise the topmost panel.
159159

160-
GUIPanel *GetPanel(void);
160+
GUIPanel * GetPanel() override;
161161

162162

163163
//////////////////////////////////////////////////////////////////////////////////////////
@@ -166,7 +166,7 @@ class GUIButton :
166166
// Description: Returns a string representing the control's ID
167167
// Arguments: None.
168168

169-
static std::string GetControlID(void) { return "BUTTON"; };
169+
static std::string GetControlID() { return "BUTTON"; };
170170

171171

172172
//////////////////////////////////////////////////////////////////////////////////////////
@@ -175,7 +175,7 @@ class GUIButton :
175175
// Description: Gets the rectangle of the control.
176176
// Arguments: Position, Size.
177177

178-
void GetControlRect(int *X, int *Y, int *Width, int *Height);
178+
void GetControlRect(int *X, int *Y, int *Width, int *Height) override;
179179

180180

181181
//////////////////////////////////////////////////////////////////////////////////////////
@@ -184,7 +184,7 @@ class GUIButton :
184184
// Description: Gets the control to store the values into properties.
185185
// Arguments: None.
186186

187-
void StoreProperties(void);
187+
void StoreProperties() override;
188188

189189

190190
//////////////////////////////////////////////////////////////////////////////////////////
@@ -193,7 +193,7 @@ class GUIButton :
193193
// Description: Called when the control needs to be moved.
194194
// Arguments: New position.
195195

196-
void Move(int X, int Y);
196+
void Move(int X, int Y) override;
197197

198198

199199
//////////////////////////////////////////////////////////////////////////////////////////
@@ -202,7 +202,7 @@ class GUIButton :
202202
// Description: Called when the control needs to be resized.
203203
// Arguments: New size.
204204

205-
void Resize(int Width, int Height);
205+
void Resize(int Width, int Height) override;
206206

207207

208208
//////////////////////////////////////////////////////////////////////////////////////////
@@ -229,7 +229,7 @@ class GUIButton :
229229
// Description: Gets the text.
230230
// Arguments: None.
231231

232-
std::string GetText(void);
232+
std::string GetText();
233233

234234

235235
//////////////////////////////////////////////////////////////////////////////////////////
@@ -238,7 +238,7 @@ class GUIButton :
238238
// Description: Applies new properties to the control.
239239
// Arguments: GUIProperties.
240240

241-
void ApplyProperties(GUIProperties *Props);
241+
void ApplyProperties(GUIProperties *Props) override;
242242

243243

244244
//////////////////////////////////////////////////////////////////////////////////////////
@@ -253,7 +253,7 @@ class GUIButton :
253253
// Description: Create the button bitmap to draw.
254254
// Arguments: None.
255255

256-
void BuildBitmap(void);
256+
void BuildBitmap();
257257

258258

259259
// Members

0 commit comments

Comments
 (0)