mirror of https://github.com/Poikilos/SAM-Viewer
Improve tiny file dialog integration code
parent
730f15058f
commit
c3c18147c9
|
@ -20,7 +20,7 @@ namespace dialog
|
||||||
{
|
{
|
||||||
SEvent event;
|
SEvent event;
|
||||||
bool has_event = false;
|
bool has_event = false;
|
||||||
const char *filename = "";
|
const char *filename = nullptr;
|
||||||
|
|
||||||
void showFileOpen(IGUIEnvironment *env, s32 id, const char *caption,
|
void showFileOpen(IGUIEnvironment *env, s32 id, const char *caption,
|
||||||
const char **filters, const int filter_count)
|
const char **filters, const int filter_count)
|
||||||
|
@ -52,14 +52,14 @@ namespace dialog
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
filename = "";
|
filename = nullptr;
|
||||||
event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED;
|
event.GUIEvent.EventType = EGET_FILE_CHOOSE_DIALOG_CANCELLED;
|
||||||
}
|
}
|
||||||
window->remove();
|
window->remove();
|
||||||
has_event = true;
|
has_event = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& except)
|
catch (const std::exception &except)
|
||||||
{
|
{
|
||||||
std::cout << except.what() << std::endl;
|
std::cout << except.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -570,7 +570,7 @@ bool TexturesDialog::OnEvent(const SEvent &event)
|
||||||
}
|
}
|
||||||
else if (event.GUIEvent.EventType == EGET_FILE_SELECTED)
|
else if (event.GUIEvent.EventType == EGET_FILE_SELECTED)
|
||||||
{
|
{
|
||||||
stringw fn = dialog::filename;
|
stringw fn = (dialog::filename) ? dialog::filename : "";
|
||||||
if (!fn.empty())
|
if (!fn.empty())
|
||||||
{
|
{
|
||||||
s32 id = event.UserEvent.UserData1;
|
s32 id = event.UserEvent.UserData1;
|
||||||
|
|
52
src/dialog.h
52
src/dialog.h
|
@ -7,32 +7,6 @@ using namespace scene;
|
||||||
using namespace gui;
|
using namespace gui;
|
||||||
using namespace video;
|
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
|
enum
|
||||||
{
|
{
|
||||||
E_DIALOG_ID_ABOUT = 0x1000,
|
E_DIALOG_ID_ABOUT = 0x1000,
|
||||||
|
@ -69,6 +43,32 @@ enum
|
||||||
E_BUTTON_ID_WIELD = 0x2030
|
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 Config;
|
||||||
|
|
||||||
class HyperlinkCtrl : public IGUIElement
|
class HyperlinkCtrl : public IGUIElement
|
||||||
|
|
|
@ -294,7 +294,7 @@ bool Viewer::OnEvent(const SEvent &event)
|
||||||
}
|
}
|
||||||
else if (event.GUIEvent.EventType == EGET_FILE_SELECTED)
|
else if (event.GUIEvent.EventType == EGET_FILE_SELECTED)
|
||||||
{
|
{
|
||||||
stringc fn = dialog::filename;
|
stringc fn = (dialog::filename) ? dialog::filename : "";
|
||||||
s32 id = event.UserEvent.UserData1;
|
s32 id = event.UserEvent.UserData1;
|
||||||
gui->setFocused(false);
|
gui->setFocused(false);
|
||||||
switch (id)
|
switch (id)
|
||||||
|
|
Loading…
Reference in New Issue