Skip to content

Commit 5c5f69c

Browse files
committed
Misc changes in EditorUtil
1 parent cea7c74 commit 5c5f69c

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

Editor/EditorUtil.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,24 @@ namespace RTEGUI {
88

99
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1010

11-
int EditorUtil::QuitMessageBox(const std::string &message, const HWND &windowHandle) {
11+
int EditorUtil::DisplayDialogBox(const std::string &message, const HWND &windowHandle) {
1212
int result = MessageBox(windowHandle, message.c_str(), "Cortex Command GUI Editor", MB_YESNOCANCEL);
1313

1414
if (result == IDNO) { return -1; }
1515
if (result == IDYES) { return 1; }
16-
return 0; // Cancel
16+
return 0;
1717
}
1818

1919
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2020

21-
bool EditorUtil::DisplayLoadGUIFile(std::string *filename, const HWND &windowHandle) {
21+
bool EditorUtil::DisplayLoadFileDialogBox(std::string &filename, const HWND &windowHandle) {
2222
OPENFILENAMEA dialogBox;
2323
std::string filenameToLoad(MAX_PATH, '\0'); // Make sure the string is initialized with the correct size and filled with null characters.
2424

2525
std::string currentDir(MAX_PATH, '\0');
2626
currentDir = std::filesystem::current_path().string();
2727

28-
// Initialize OPENFILENAME
29-
ZeroMemory(&dialogBox, sizeof(OPENFILENAME));
28+
ZeroMemory(&dialogBox, sizeof(OPENFILENAME)); // Initialize OPENFILENAME
3029
dialogBox.lStructSize = sizeof(OPENFILENAME);
3130
dialogBox.hInstance = nullptr;
3231
dialogBox.hwndOwner = windowHandle;
@@ -42,7 +41,7 @@ namespace RTEGUI {
4241
dialogBox.lpstrDefExt = "ini";
4342

4443
if (GetOpenFileName(&dialogBox)) {
45-
*filename = std::string(filenameToLoad.data());
44+
filename = std::string(filenameToLoad.data());
4645
std::filesystem::current_path(currentDir);
4746
return true;
4847
}
@@ -52,15 +51,14 @@ namespace RTEGUI {
5251

5352
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5453

55-
bool EditorUtil::DisplaySaveGUIFile(std::string *filename, const HWND &windowHandle) {
54+
bool EditorUtil::DisplaySaveFileDialogBox(std::string &filename, const HWND &windowHandle) {
5655
OPENFILENAMEA dialogBox;
5756
std::string filenameToSave(MAX_PATH, '\0'); // Make sure the string is initialized with the correct size and filled with null characters.
5857

5958
std::string currentDir(MAX_PATH, '\0');
6059
currentDir = std::filesystem::current_path().string();
6160

62-
// Initialize OPENFILENAME
63-
ZeroMemory(&dialogBox, sizeof(OPENFILENAME));
61+
ZeroMemory(&dialogBox, sizeof(OPENFILENAME)); // Initialize OPENFILENAME
6462
dialogBox.lStructSize = sizeof(OPENFILENAME);
6563
dialogBox.hInstance = nullptr;
6664
dialogBox.hwndOwner = windowHandle;
@@ -85,7 +83,7 @@ namespace RTEGUI {
8583
return false;
8684
}
8785
}
88-
*filename = filenameToSave;
86+
filename = filenameToSave;
8987
std::filesystem::current_path(currentDir);
9088
return true;
9189
}

Editor/EditorUtil.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,28 @@ namespace RTEGUI {
1515
public:
1616

1717
/// <summary>
18-
/// Display quit program OS dialog box.
18+
/// Display OS dialog box.
1919
/// </summary>
2020
/// <param name="message">Message to display in the dialog box.</param>
2121
/// <param name="windowHandle">The window handle of the editor process.</param>
22-
/// <returns>1 for quit & save, -1 for quit, no save, 0 for cancel.</returns>
23-
static int QuitMessageBox(const std::string &message, const HWND &windowHandle);
22+
/// <returns>1 for YES, -1 for NO or 0 for CANCEL.</returns>
23+
static int DisplayDialogBox(const std::string &message, const HWND &windowHandle);
2424

2525
/// <summary>
2626
/// Display load GUI file OS dialog box.
2727
/// </summary>
2828
/// <param name="filename">File name to load.</param>
2929
/// <param name="windowHandle">The window handle of the editor process.</param>
3030
/// <returns>True if a file was selected.</returns>
31-
static bool DisplayLoadGUIFile(std::string *filename, const HWND &windowHandle);
31+
static bool DisplayLoadFileDialogBox(std::string &filename, const HWND &windowHandle);
3232

3333
/// <summary>
3434
/// Display save GUI file OS dialog box.
3535
/// </summary>
3636
/// <param name="filename">File name to save.</param>
3737
/// <param name="windowHandle">The window handle of the editor process.</param>
3838
/// <returns>True if a file was selected.</returns>
39-
static bool DisplaySaveGUIFile(std::string *filename, const HWND &windowHandle);
39+
static bool DisplaySaveFileDialogBox(std::string &filename, const HWND &windowHandle);
4040
};
4141
}
4242
#endif

0 commit comments

Comments
 (0)