1
//------------------------------------------------------------------------
2
// MAIN : Unix/FLTK Main program
3
//------------------------------------------------------------------------
5
// GL-Friendly Node Builder (C) 2000-2007 Andrew Apted
7
// Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
9
// This program is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
//------------------------------------------------------------------------
21
// this includes everything we need
25
#define MY_TITLE ("glBSP Node Builder " GLBSP_VER)
30
nodebuildinfo_t guix_info;
32
volatile nodebuildcomms_t guix_comms;
34
const nodebuildfuncs_t guix_funcs =
43
GUI_DisplaySetBarLimit,
44
GUI_DisplaySetBarText,
49
// GUI-specific Globals
51
guix_preferences_t guix_prefs;
53
const guix_preferences_t default_guiprefs =
56
40, 20, // win_x, win_y
60
550, 520, // win_w, win_h;
62
120, 200, // progress_x, progress_y
63
90, 200, // dialog_x, dialog_y
64
80, 100, // other_x, other_y
66
20, 50, // manual_x, manual_y
67
610, 520, // manual_w, manual_h
70
TRUE, // overwrite_warn
71
TRUE, // same_file_warn
72
TRUE, // lack_ext_warn
77
/* ----- user information ----------------------------- */
80
static void ShowTitle(void)
84
"**** GLBSP Node Builder " GLBSP_VER " (C) 2007 Andrew Apted ****\n\n"
88
static void ShowInfo(void)
91
"This GL node builder was originally based on BSP 2.3, which was\n"
92
"created from the basic theory stated in DEU5 (OBJECTS.C)\n"
94
"Credits should go to :-\n"
95
" Andy Baker & Marc Pullen for their invaluable help\n"
96
" Janis Legzdinsh for fixing up Hexen support\n"
97
" Colin Reed & Lee Killough for creating the original BSP\n"
98
" Matt Fell for the Doom Specs\n"
99
" Raphael Quinet for DEU and the original idea\n"
100
" ... and everyone who helped with the original BSP.\n"
102
"This program is free software, under the terms of the GNU General\n"
103
"Public License, and comes with ABSOLUTELY NO WARRANTY. See the\n"
104
"accompanying documentation for more details.\n"
106
"Note: glBSPX is the GUI (graphical user interface) version.\n"
107
"Try plain \"glbsp\" if you want the command-line version.\n"
112
void MainSetDefaults(void)
114
// this is more messy than it was in C
115
memcpy((nodebuildinfo_t *) &guix_info, &default_buildinfo,
118
memcpy((nodebuildcomms_t *) &guix_comms, &default_buildcomms,
121
memcpy((guix_preferences_t *) &guix_prefs, &default_guiprefs,
124
// set default filename for saving the log
125
guix_prefs.save_log_file = GlbspStrDup("glbsp.log");
129
/* ----- main program ----------------------------- */
133
int main(int argc, char **argv)
136
(strcmp(argv[1], "/?") == 0 || strcmp(argv[1], "-h") == 0 ||
137
strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0 ||
138
strcmp(argv[1], "-HELP") == 0 || strcmp(argv[1], "--HELP") == 0))
148
if (first_arg < argc && (strncmp(argv[first_arg], "-psn", 4) == 0))
152
// set defaults, also initializes the nodebuildxxxx stuff
155
// read persistent data
156
CookieSetPath(argv[0]);
158
cookie_status_t cookie_ret = CookieReadAll();
160
// handle drag and drop: a single non-option argument
162
// NOTE: there is no support for giving options to glBSPX via the
163
// command line. Plain 'glbsp' should be used if this is desired.
164
// The difficult here lies in possible conflicts between given
165
// options and those already set from within the GUI. Plus we may
166
// want to handle a drag-n-drop of multiple files later on.
168
boolean_g unused_args = FALSE;
170
if (first_arg < argc && argv[first_arg][0] != '-')
172
GlbspFree(guix_info.input_file);
173
GlbspFree(guix_info.output_file);
175
guix_info.input_file = GlbspStrDup(argv[first_arg]);
177
// guess an output name too
179
guix_info.output_file = GlbspStrDup(
180
HelperGuessOutput(guix_info.input_file));
185
if (first_arg < argc)
189
// load icons for file chooser
190
Fl_File_Icon::load_system_icons();
192
guix_win = new Guix_MainWin(MY_TITLE);
203
case COOKIE_E_NO_FILE:
204
guix_win->text_box->AddMsg(
205
"** Missing INI file -- Using defaults **\n\n", FL_RED, TRUE);
208
case COOKIE_E_PARSE_ERRORS:
209
case COOKIE_E_CHECK_ERRORS:
210
guix_win->text_box->AddMsg(
211
"** Warning: Errors found in INI file **\n\n", FL_RED, TRUE);
216
guix_win->text_box->AddMsg(
217
"** Warning: Ignoring extra arguments to glBSPX **\n\n", FL_RED, TRUE);
219
// run the GUI until the user quits
220
while (! guix_win->want_quit)