Skip to content

Commit abd878c

Browse files
committed
Cleanup, qualifiers, namespace changes, project settings
1 parent 023ec37 commit abd878c

File tree

8 files changed

+154
-202
lines changed

8 files changed

+154
-202
lines changed

Editor/GUIEditorApp.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using namespace RTE;
2828

2929

30+
namespace GUI {
3031
AllegroScreen *g_Screen;
3132
AllegroInput *g_Input;
3233

@@ -282,7 +283,7 @@ bool GUIEditorApp::Update(void)
282283
// Add a control
283284
if (Event.GetControl()->GetName().substr(0, 2).compare("C_") == 0)
284285
{
285-
string Class = ((GUIButton *)Event.GetControl())->GetText();
286+
std::string Class = ((GUIButton *)Event.GetControl())->GetText();
286287
GUIControl *Parent = m_pRootControl;
287288

288289
// Is the focused control a container?
@@ -293,7 +294,7 @@ bool GUIEditorApp::Update(void)
293294
}
294295

295296
// Find a suitable control name
296-
string Name = GenerateControlName(Class/*.substr(2)*/);
297+
std::string Name = GenerateControlName(Class/*.substr(2)*/);
297298

298299
if (Parent)
299300
{
@@ -427,7 +428,7 @@ void GUIEditorApp::OnQuitButton(void)
427428

428429
void GUIEditorApp::OnLoadButton(bool addControls)
429430
{
430-
string strFilename;
431+
std::string strFilename;
431432
if (GUIEditorLib::DisplayLoadGUIFile(&strFilename))
432433
{
433434
m_pControlManager->Load(strFilename, addControls);
@@ -462,7 +463,7 @@ void GUIEditorApp::OnLoadButton(bool addControls)
462463

463464
void GUIEditorApp::OnSaveAsButton(void)
464465
{
465-
string strFilename;
466+
std::string strFilename;
466467
if (GUIEditorLib::DisplaySaveGUIFile(&strFilename))
467468
{
468469
// Move the root object to the origin before saving
@@ -683,9 +684,9 @@ void GUIEditorApp::UpdateActiveBoxList(void)
683684
m_pActiveBoxList->ClearList();
684685

685686
// Go through all the top-level (directly under root) controls and add only the ControlBoxs to the list here
686-
vector<GUIControl *> *pControls = m_pControlManager->GetControlList();
687+
std::vector<GUIControl *> *pControls = m_pControlManager->GetControlList();
687688
GUICollectionBox *pBox = 0;
688-
for (vector<GUIControl *>::iterator itr = pControls->begin(); itr != pControls->end(); itr++)
689+
for (std::vector<GUIControl *>::iterator itr = pControls->begin(); itr != pControls->end(); itr++)
689690
{
690691
// Look for CollectionBoxes with the root control as parent
691692
if ((pBox = dynamic_cast<GUICollectionBox *>(*itr)) && pBox->GetParent() == m_pRootControl)
@@ -720,8 +721,8 @@ GUIControl * GUIEditorApp::ControlUnderMouse(GUIControl *Parent, int MouseX, int
720721
return NULL;
721722

722723
// Check children
723-
vector<GUIControl *> *List = Parent->GetChildren();
724-
vector<GUIControl *>::reverse_iterator it;
724+
std::vector<GUIControl *> *List = Parent->GetChildren();
725+
std::vector<GUIControl *>::reverse_iterator it;
725726

726727
assert(List);
727728

@@ -966,7 +967,7 @@ std::string GUIEditorApp::GenerateControlName(std::string strControlType)
966967
// 10,000 should be enough
967968
for (int i=1; i<10000; i++)
968969
{
969-
string Name = strControlType;
970+
std::string Name = strControlType;
970971

971972
// Use a lower case version of the string
972973
for (int s=0; s<Name.size(); s++)
@@ -975,8 +976,8 @@ std::string GUIEditorApp::GenerateControlName(std::string strControlType)
975976
Name.append(itoa(i, buf, 10));
976977

977978
// Check if this name exists
978-
vector<GUIControl *> *ControlList = m_pControlManager->GetControlList();
979-
vector<GUIControl *>::iterator it;
979+
std::vector<GUIControl *> *ControlList = m_pControlManager->GetControlList();
980+
std::vector<GUIControl *>::iterator it;
980981

981982
bool Found = false;
982983

@@ -1020,4 +1021,5 @@ int GUIEditorApp::ProcessSnapCoord(int Position)
10201021
}
10211022

10221023
return Position;
1024+
}
10231025
}

Editor/GUIEditorApp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "GUI.h"
1414
#include "GUIPropertyPage.h"
1515
#include "GUIListBox.h"
16-
using namespace RTE;
1716

1817

1918
//////////////////////////////////////////////////////////////////////////////////////////
@@ -23,6 +22,8 @@ using namespace RTE;
2322
// Parent(s): None.
2423
// Class history: 02/07/2009 GUIEditorApp Created.
2524

25+
namespace GUI {
26+
2627

2728
class GUIEditorApp
2829
{
@@ -263,7 +264,7 @@ class GUIEditorApp
263264
int m_nGridSize;
264265

265266
};
266-
267+
}
267268

268269

269270
#endif // File

Editor/GUIEditorLib.cpp

Lines changed: 89 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,107 @@
1-
//////////////////////////////////////////////////////////////////////////////////////////
2-
// File: GUIEditorLib.h
3-
//////////////////////////////////////////////////////////////////////////////////////////
4-
// Description: GUI Editor Library Functions
5-
// Project: GUI Library
6-
// Author(s): Jason Boettcher
7-
1+
#include "GUIEditorLib.h"
82

93
#include <Windows.h>
104
#include <commdlg.h>
115
#include <direct.h>
12-
#include "GUIEditorLib.h"
13-
14-
15-
HINSTANCE g_hInstance = 0;
16-
HWND g_hWnd = 0;
17-
18-
19-
//////////////////////////////////////////////////////////////////////////////////////////
20-
// Method: QuitMessageBox
21-
//////////////////////////////////////////////////////////////////////////////////////////
22-
// Description: Call quit messagebox
23-
// Returns: 1 for quit & save, -1 for quit, no save, 0 for cancel
24-
25-
int GUIEditorLib::QuitMessageBox(string strMessage, string strTitle)
26-
{
27-
int nRetCode = MessageBoxA(g_hWnd, strMessage.c_str(), strTitle.c_str(), MB_YESNOCANCEL);
28-
29-
if(nRetCode == IDNO)
30-
return -1;
31-
if(nRetCode == IDYES)
32-
return 1;
33-
34-
return 0; // Cancel
35-
}
366

7+
namespace GUI {
378

38-
//////////////////////////////////////////////////////////////////////////////////////////
39-
// Method: DisplayLoadGUIFile
40-
//////////////////////////////////////////////////////////////////////////////////////////
41-
// Description: Display load gui file OS dialog box
9+
HINSTANCE g_hInstance = 0;
10+
HWND g_hWnd = 0;
4211

43-
bool GUIEditorLib::DisplayLoadGUIFile(string *strFilename)
44-
{
45-
OPENFILENAMEA ofn; // common dialog box structure
46-
char szFile[260]; // File name
12+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4713

48-
// Save the current working directory
49-
char szCurrentDir[_MAX_PATH];
50-
_getcwd(szCurrentDir,_MAX_PATH);
14+
int GUIEditorLib::QuitMessageBox(std::string strMessage, std::string strTitle) {
15+
int nRetCode = MessageBoxA(g_hWnd, strMessage.c_str(), strTitle.c_str(), MB_YESNOCANCEL);
5116

52-
// Clear the filename (otherwise it won't work)
53-
memset(szFile, 0, sizeof(szFile));
54-
55-
// Initialize OPENFILENAME
56-
ZeroMemory(&ofn, sizeof(OPENFILENAME));
57-
ofn.lStructSize = sizeof(OPENFILENAME);
58-
ofn.hInstance = g_hInstance;
59-
ofn.hwndOwner = g_hWnd;
60-
ofn.lpstrFile = szFile;
61-
ofn.nMaxFile = sizeof(szFile);
62-
ofn.lpstrFilter = "GUI Files (*.ini)\0*.ini\0All Files\0*.*";
63-
ofn.nFilterIndex = 1;
64-
ofn.lpstrFileTitle = NULL;
65-
ofn.nMaxFileTitle = 0;
66-
ofn.lpstrTitle = "Open";
67-
ofn.lpstrInitialDir = szCurrentDir;
68-
ofn.Flags = OFN_PATHMUSTEXIST;
69-
ofn.lpstrDefExt = "ini";
70-
71-
if(GetOpenFileNameA(&ofn)) {
17+
if (nRetCode == IDNO) { return -1; }
18+
if (nRetCode == IDYES) { return 1; }
19+
return 0; // Cancel
20+
}
7221

73-
*strFilename = string(szFile);
22+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
23+
24+
bool GUIEditorLib::DisplayLoadGUIFile(std::string *strFilename) {
25+
OPENFILENAMEA ofn; // common dialog box structure
26+
char szFile[260]; // File name
27+
28+
// Save the current working directory
29+
char szCurrentDir[_MAX_PATH];
30+
_getcwd(szCurrentDir, _MAX_PATH);
31+
32+
// Clear the filename (otherwise it won't work)
33+
memset(szFile, 0, sizeof(szFile));
34+
35+
// Initialize OPENFILENAME
36+
ZeroMemory(&ofn, sizeof(OPENFILENAME));
37+
ofn.lStructSize = sizeof(OPENFILENAME);
38+
ofn.hInstance = g_hInstance;
39+
ofn.hwndOwner = g_hWnd;
40+
ofn.lpstrFile = szFile;
41+
ofn.nMaxFile = sizeof(szFile);
42+
ofn.lpstrFilter = "GUI Files (*.ini)\0*.ini\0All Files\0*.*";
43+
ofn.nFilterIndex = 1;
44+
ofn.lpstrFileTitle = NULL;
45+
ofn.nMaxFileTitle = 0;
46+
ofn.lpstrTitle = "Open";
47+
ofn.lpstrInitialDir = szCurrentDir;
48+
ofn.Flags = OFN_PATHMUSTEXIST;
49+
ofn.lpstrDefExt = "ini";
50+
51+
if (GetOpenFileNameA(&ofn)) {
52+
*strFilename = std::string(szFile);
53+
_chdir(szCurrentDir);
54+
return true;
55+
}
7456
_chdir(szCurrentDir);
75-
76-
return true;
57+
return false;
7758
}
7859

79-
_chdir(szCurrentDir);
80-
return false;
81-
}
82-
83-
84-
//////////////////////////////////////////////////////////////////////////////////////////
85-
// Method: DisplaySaveGUIFile
86-
//////////////////////////////////////////////////////////////////////////////////////////
87-
// Description: Display save gui file OS dialog box
88-
89-
bool GUIEditorLib::DisplaySaveGUIFile(string *strFilename)
90-
{
91-
OPENFILENAMEA ofn; // common dialog box structure
92-
char szFile[260]; // File name
93-
94-
// Save the current working directory
95-
char szCurrentDir[_MAX_PATH];
96-
_getcwd(szCurrentDir,_MAX_PATH);
97-
98-
// Clear the filename (otherwise it won't work)
99-
memset(szFile, 0, sizeof(szFile));
100-
101-
// Initialize OPENFILENAME
102-
ZeroMemory(&ofn, sizeof(OPENFILENAME));
103-
ofn.lStructSize = sizeof(OPENFILENAME);
104-
ofn.hInstance = g_hInstance;
105-
ofn.hwndOwner = g_hWnd;
106-
ofn.lpstrFile = szFile;
107-
ofn.nMaxFile = sizeof(szFile);
108-
ofn.lpstrFilter = "GUI Files (*.ini)\0*.ini\0All Files\0*.*";
109-
ofn.nFilterIndex = 1;
110-
ofn.lpstrFileTitle = NULL;
111-
ofn.nMaxFileTitle = 0;
112-
ofn.lpstrTitle = "Save As";
113-
ofn.lpstrInitialDir = szCurrentDir;
114-
ofn.Flags = OFN_PATHMUSTEXIST;
115-
ofn.lpstrDefExt = "ini";
116-
117-
if(GetSaveFileNameA(&ofn)) {
118-
119-
// Check if the file exists
120-
FILE *fp = fopen(szFile,"rt");
121-
if( fp ) {
122-
fclose(fp);
123-
if(MessageBoxA(g_hWnd, "File Exists\nOverwrite it?", "Confirmation",MB_YESNO) == IDNO) {
124-
_chdir(szCurrentDir);
125-
return false;
60+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
61+
62+
bool GUIEditorLib::DisplaySaveGUIFile(std::string *strFilename) {
63+
OPENFILENAMEA ofn; // common dialog box structure
64+
char szFile[260]; // File name
65+
66+
// Save the current working directory
67+
char szCurrentDir[_MAX_PATH];
68+
_getcwd(szCurrentDir, _MAX_PATH);
69+
70+
// Clear the filename (otherwise it won't work)
71+
memset(szFile, 0, sizeof(szFile));
72+
73+
// Initialize OPENFILENAME
74+
ZeroMemory(&ofn, sizeof(OPENFILENAME));
75+
ofn.lStructSize = sizeof(OPENFILENAME);
76+
ofn.hInstance = g_hInstance;
77+
ofn.hwndOwner = g_hWnd;
78+
ofn.lpstrFile = szFile;
79+
ofn.nMaxFile = sizeof(szFile);
80+
ofn.lpstrFilter = "GUI Files (*.ini)\0*.ini\0All Files\0*.*";
81+
ofn.nFilterIndex = 1;
82+
ofn.lpstrFileTitle = NULL;
83+
ofn.nMaxFileTitle = 0;
84+
ofn.lpstrTitle = "Save As";
85+
ofn.lpstrInitialDir = szCurrentDir;
86+
ofn.Flags = OFN_PATHMUSTEXIST;
87+
ofn.lpstrDefExt = "ini";
88+
89+
if (GetSaveFileNameA(&ofn)) {
90+
// Check if the file exists
91+
FILE *fp = fopen(szFile, "rt");
92+
if (fp) {
93+
fclose(fp);
94+
if (MessageBoxA(g_hWnd, "File Exists\nOverwrite it?", "Confirmation", MB_YESNO) == IDNO) {
95+
_chdir(szCurrentDir);
96+
return false;
97+
}
12698
}
99+
*strFilename = std::string(szFile);
100+
_chdir(szCurrentDir);
101+
return true;
127102
}
128-
*strFilename = string(szFile);
103+
// Restore the current working directory
129104
_chdir(szCurrentDir);
130-
131-
return true;
105+
return false;
132106
}
133-
134-
// Restore the current working directory
135-
_chdir(szCurrentDir);
136-
137-
return false;
138107
}

0 commit comments

Comments
 (0)