1
//------------------------------------------------------------------------
3
//------------------------------------------------------------------------
5
// GL-Node Viewer (C) 2004-2007 Andrew Apted
7
// This program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public License
9
// as published by the Free Software Foundation; either version 2
10
// of the License, or (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
//------------------------------------------------------------------------
19
// this includes everything we need
23
#define GUI_PrintMsg printf
26
static bool inited_FLTK = false;
28
static int main_result = 0;
31
static void ShowTitle(void)
35
"**** " PROG_NAME " (C) 2007 Andrew Apted ****\n\n"
39
static void ShowInfo(void)
47
void MainSetDefaults(void)
55
fl_message_font(FL_HELVETICA, 16);
57
Fl_File_Icon::load_system_icons();
62
static void DisplayError(const char *str, ...)
71
vsprintf(buffer, str, args);
74
fl_alert("%s", buffer);
79
vfprintf(stderr, str, args);
82
fprintf(stderr, "\n");
88
//------------------------------------------------------------------------
90
//------------------------------------------------------------------------
92
int main(int argc, char **argv)
99
ArgvInit(argc, (const char **)argv);
101
InitDebug(ArgvFind(0, "debug") >= 0);
104
if (ArgvFind('?', NULL) >= 0 || ArgvFind('h', "help") >= 0)
113
// set defaults, also initializes the nodebuildxxxx stuff
116
const char *filename = "data/doom2.wad";
118
if (arg_count > 0 && ! ArgvIsOption(0))
119
filename = arg_list[0];
123
int idx = ArgvFind(0, "file", ¶ms);
125
if (idx >= 0 && params >= 1)
126
filename = arg_list[idx + 1];
129
if (CheckExtension(filename, "gwa"))
130
FatalError("Main file must be a normal WAD (not GWA).\n");
132
the_wad = wad_c::Load(filename);
134
FatalError("Unable to read WAD file: %s\n", filename);
136
const char *gwa_name = ReplaceExtension(filename, "gwa");
138
if (FileExists(gwa_name))
140
the_gwa = wad_c::Load(gwa_name);
142
FatalError("Unable to read GWA file: %s\n", gwa_name);
145
const char *level_name = NULL;
148
int idx = ArgvFind(0, "warp", ¶ms);
150
if (idx >= 0 && params >= 1)
151
level_name = arg_list[idx + 1];
155
level_name = the_wad->FirstLevelName();
158
FatalError("Unable to find ANY level in WAD.\n");
165
int idx = ArgvFind(0, "path", ¶ms);
167
if (idx >= 0 && params >= 1)
168
path = path_c::ReadFile(arg_list[idx + 1]);
171
LoadLevel(level_name);
173
guix_win = new Guix_MainWin(PROG_NAME);
176
guix_win->grid->SetPath(path);
178
double lx, ly, hx, hy;
179
LevelGetBounds(&lx, &ly, &hx, &hy);
180
guix_win->grid->FitBBox(lx, ly, hx, hy);
182
guix_win->info->SetMap(level_name);
183
guix_win->info->SetNodes("GL"); // FIXME: node version
185
guix_win->info->SetNodeIndex(lev_nodes.num - 1);
187
// run the GUI until the user quits
188
while (! guix_win->want_quit)
191
catch (const char * err)
193
DisplayError("%s", err);
195
catch (assert_fail_c err)
197
DisplayError("Sorry, an internal error occurred:\n%s", err.GetMessage());
201
DisplayError("An unknown problem occurred (UI code)");