diff --git a/src/dialog.cpp b/src/dialog.cpp index c4016df..006ba7d 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -20,7 +20,7 @@ namespace dialog { SEvent event; bool has_event = false; - const char *filename = ""; + const char *filename = nullptr; void showFileOpen(IGUIEnvironment *env, s32 id, const char *caption, const char **filters, const int filter_count) @@ -52,14 +52,14 @@ namespace dialog } else { - filename = ""; + filename = nullptr; event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED; } window->remove(); has_event = true; } - catch (const std::exception& except) + catch (const std::exception &except) { std::cout << except.what() << std::endl; } @@ -570,7 +570,7 @@ bool TexturesDialog::OnEvent(const SEvent &event) } else if (event.GUIEvent.EventType == EGET_FILE_SELECTED) { - stringw fn = dialog::filename; + stringw fn = (dialog::filename) ? dialog::filename : ""; if (!fn.empty()) { s32 id = event.UserEvent.UserData1; diff --git a/src/dialog.h b/src/dialog.h index a71ee40..d8aac7f 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -7,32 +7,6 @@ using namespace scene; using namespace gui; using namespace video; -namespace dialog -{ - static const int model_filter_count = 19; - static const char *model_filters[] = { - "*.obj", "*.b3d", "*.x", "*.3ds", - "*.irr", "*.irrmesh", "*.md2", "*.md3", - "*.bsp", "*.mesh", "*.ms3d", "*.my3D", - "*.lwo", "*.xml", "*.dae", "*.dmf", - "*.oct", "*.csm", "*.stl" - }; - static const int texture_filter_count = 8; - static const char *texture_filters[] = { - "*.png", "*.jpg", "*.tga", "*.bmp", - "*.psd", "*.pcx", "*.ppm", "*.wal" - }; - extern const char *filename; - extern bool has_event; - extern SEvent event; - - void showFileOpen(IGUIEnvironment *env, s32 id, const char *caption, - const char **filters, const int filter_count); - - void fileOpen(IGUIEnvironment *env, s32 id, const char *caption, - const char **filters, const int filter_count); -} - enum { E_DIALOG_ID_ABOUT = 0x1000, @@ -69,6 +43,32 @@ enum E_BUTTON_ID_WIELD = 0x2030 }; +namespace dialog +{ + static const int model_filter_count = 19; + static const char *model_filters[] = { + "*.obj", "*.b3d", "*.x", "*.3ds", + "*.irr", "*.irrmesh", "*.md2", "*.md3", + "*.bsp", "*.mesh", "*.ms3d", "*.my3D", + "*.lwo", "*.xml", "*.dae", "*.dmf", + "*.oct", "*.csm", "*.stl" + }; + static const int texture_filter_count = 8; + static const char *texture_filters[] = { + "*.png", "*.jpg", "*.tga", "*.bmp", + "*.psd", "*.pcx", "*.ppm", "*.wal" + }; + extern const char *filename; + extern bool has_event; + extern SEvent event; + + void showFileOpen(IGUIEnvironment *env, s32 id, const char *caption, + const char **filters, const int filter_count); + + void fileOpen(IGUIEnvironment *env, s32 id, const char *caption, + const char **filters, const int filter_count); +} + class Config; class HyperlinkCtrl : public IGUIElement diff --git a/src/viewer.cpp b/src/viewer.cpp index ab1e7e7..cefd2a8 100644 --- a/src/viewer.cpp +++ b/src/viewer.cpp @@ -294,7 +294,7 @@ bool Viewer::OnEvent(const SEvent &event) } else if (event.GUIEvent.EventType == EGET_FILE_SELECTED) { - stringc fn = dialog::filename; + stringc fn = (dialog::filename) ? dialog::filename : ""; s32 id = event.UserEvent.UserData1; gui->setFocused(false); switch (id)