1
//------------------------------------------------------------------------
2
// MENU : Unix/FLTK Menu handling
3
//------------------------------------------------------------------------
5
// GL-Friendly Node Builder (C) 2000-2005 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
static boolean_g menu_want_to_quit;
28
static void menu_quit_CB(Fl_Widget *w, void *data)
30
menu_want_to_quit = TRUE;
33
static void menu_do_clear_log(Fl_Widget *w, void * data)
35
guix_win->text_box->ClearLog();
39
static void menu_do_exit(Fl_Widget *w, void * data)
41
guix_win->want_quit = TRUE;
46
//------------------------------------------------------------------------
48
static void menu_do_prefs(Fl_Widget *w, void * data)
50
guix_pref_win = new Guix_PrefWin();
52
// run the GUI until the user closes
53
while (! guix_pref_win->want_quit)
60
//------------------------------------------------------------------------
62
static const char *about_Info =
63
"By Andrew Apted (C) 2000-2005\n"
65
"Based on BSP 2.3 (C) 1998 Colin Reed, Lee Killough\n"
67
"Additional credits to...\n"
68
" Andy Baker & Marc Pullen, for invaluable help\n"
69
" Janis Legzdinsh, for fixing up Hexen support\n"
70
" Matt Fell, for the Doom Specs\n"
71
" Raphael Quinet, for DEU and the original idea\n"
72
" ... and everyone else who deserves it !\n"
74
"This program is free software, under the terms of\n"
75
"the GNU General Public License, and comes with\n"
76
"ABSOLUTELY NO WARRANTY.\n"
78
"Website: http://glbsp.sourceforge.net";
81
static void menu_do_about(Fl_Widget *w, void * data)
83
menu_want_to_quit = FALSE;
85
Fl_Window *ab_win = new Fl_Window(600, 340, "About glBSP");
89
ab_win->size_range(ab_win->w(), ab_win->h(), ab_win->w(), ab_win->h());
90
ab_win->position(guix_prefs.manual_x, guix_prefs.manual_y);
91
ab_win->callback((Fl_Callback *) menu_quit_CB);
93
// add the about image
94
Fl_Group *group = new Fl_Group(0, 0, 230, ab_win->h());
95
group->box(FL_FLAT_BOX);
96
group->color(FL_BLACK, FL_BLACK);
99
Fl_Box *box = new Fl_Box(20, 90, ABOUT_IMG_W+2, ABOUT_IMG_H+2);
100
box->image(about_image);
104
// nice big logo text
105
box = new Fl_Box(240, 5, 350, 50, "glBSPX " GLBSP_VER);
110
box = new Fl_Box(240, 60, 350, 270, about_Info);
111
box->align(FL_ALIGN_INSIDE | FL_ALIGN_LEFT | FL_ALIGN_TOP);
115
// finally add an "OK" button
116
Fl_Button *button = new Fl_Button(ab_win->w()-10-60, ab_win->h()-10-30,
118
button->callback((Fl_Callback *) menu_quit_CB);
124
// capture initial size
126
int init_x = ab_win->x();
127
int init_y = ab_win->y();
129
// run the GUI until the user closes
130
while (! menu_want_to_quit)
133
// check if the user moved/resized the window
134
if (ab_win->x() != init_x || ab_win->y() != init_y)
136
guix_prefs.manual_x = ab_win->x();
137
guix_prefs.manual_y = ab_win->y();
140
// this deletes all the child widgets too...
145
//------------------------------------------------------------------------
147
static void menu_do_manual(Fl_Widget *w, void * data)
149
guix_book_win = new Guix_Book();
151
guix_book_win->LoadPage(guix_prefs.manual_page);
153
// run the GUI until the user closes
154
while (! guix_book_win->want_quit)
156
guix_book_win->Update();
161
delete guix_book_win;
165
//------------------------------------------------------------------------
167
static void menu_do_license(Fl_Widget *w, void * data)
169
guix_lic_win = new Guix_License();
171
// run the GUI until the user closes
172
while (! guix_lic_win->want_quit)
181
//------------------------------------------------------------------------
183
static void menu_do_save_log(Fl_Widget *w, void * data)
185
char guess_name[512];
187
// compute the "guess" filename
189
if (! guix_info.output_file ||
190
! HelperFilenameValid(guix_info.output_file) ||
191
strlen(guix_info.output_file) > 500)
193
strcpy(guess_name, "glbsp.log");
197
strcpy(guess_name, HelperReplaceExt(guix_info.output_file, "log"));
205
choice = DialogQueryFilename(
206
"Please select the file to save the log into:",
207
& guix_prefs.save_log_file, guess_name);
212
if (!guix_prefs.save_log_file || guix_prefs.save_log_file[0] == 0)
214
DialogShowAndGetChoice(ALERT_TXT, skull_image,
215
"Please choose a Log filename.");
219
if (! HelperFilenameValid(guix_prefs.save_log_file))
222
"Invalid Log filename:\n"
226
"Please check the filename and try again.",
227
guix_prefs.save_log_file);
229
DialogShowAndGetChoice(ALERT_TXT, skull_image, buffer);
233
// check for missing extension
235
if (! HelperHasExt(guix_prefs.save_log_file))
237
if (guix_prefs.lack_ext_warn)
240
"The Log file you selected has no extension.\n"
242
"Do you want to add \".LOG\" and continue ?");
244
choice = DialogShowAndGetChoice(ALERT_TXT, skull_image,
245
buffer, "OK", "Re-Select", "Cancel");
247
if (choice < 0 || choice == 2)
256
char *new_log = HelperReplaceExt(guix_prefs.save_log_file, "log");
258
GlbspFree(guix_prefs.save_log_file);
259
guix_prefs.save_log_file = GlbspStrDup(new_log);
263
// check if file already exists...
265
if (guix_prefs.overwrite_warn &&
266
HelperFileExists(guix_prefs.save_log_file))
269
"Warning: the chosen Log file already exists:\n"
273
"Do you want to overwrite it ?",
274
guix_prefs.save_log_file);
276
choice = DialogShowAndGetChoice(ALERT_TXT, skull_image,
277
buffer, "OK", "Re-Select", "Cancel");
279
if (choice < 0 || choice == 2)
286
guix_win->text_box->SaveLog(guix_prefs.save_log_file);
292
//------------------------------------------------------------------------
295
#define FCAL (Fl_Callback *)
297
static Fl_Menu_Item menu_items[] =
299
{ "&File", 0, 0, 0, FL_SUBMENU },
300
{ "&Preferences...", 0, FCAL menu_do_prefs },
301
{ "&Save Log...", 0, FCAL menu_do_save_log },
303
{ "&Clear Log", 0, FCAL menu_do_clear_log },
305
{ "&Clear Log", 0, FCAL menu_do_clear_log, 0, FL_MENU_DIVIDER },
306
{ "E&xit", FL_ALT + 'q', FCAL menu_do_exit },
310
{ "&Help", 0, 0, 0, FL_SUBMENU },
311
{ "&About...", 0, FCAL menu_do_about },
312
{ "&License...", 0, FCAL menu_do_license },
313
{ "&Manual...", FL_F+1, FCAL menu_do_manual },
324
Fl_Sys_Menu_Bar * MenuCreate(int x, int y, int w, int h)
326
Fl_Sys_Menu_Bar *bar = new Fl_Sys_Menu_Bar(x, y, w, h);
327
bar->menu(menu_items);
331
Fl_Menu_Bar * MenuCreate(int x, int y, int w, int h)
333
Fl_Menu_Bar *bar = new Fl_Menu_Bar(x, y, w, h);
334
bar->menu(menu_items);