~ubuntu-branches/ubuntu/trusty/glbsp/trusty

« back to all changes in this revision

Viewing changes to gui/main.cc

  • Committer: Bazaar Package Importer
  • Author(s): Darren Salt
  • Date: 2008-01-30 13:33:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130133349-kgojg33vyiu8xbvp
Tags: 2.24-1
* New upstream release.
* Bumped the lib soname and the library package name due to one silly
  little binary incompatibility caused by changes in an exported struct.
  (Safe; nothing else currently in the archive has ever used libglbsp2.)
* Removed my patches since they're all applied upstream.
* Updated the list of documentation files.
* Build-time changes:
  - Switched from dh_movefiles to dh_install.
  - Updated my makefile to cope with upstream changes.
  - Corrected for debian-rules-ignores-make-clean-error.
  - Corrected for substvar-source-version-is-deprecated.
  - Link libglbsp, rather than glbsp, with libm and libz.
* Fixed shlibdeps. (Closes: #460387)
* Bumped standards version to 3.7.3 (no other changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------
 
2
// MAIN : Unix/FLTK Main program
 
3
//------------------------------------------------------------------------
 
4
//
 
5
//  GL-Friendly Node Builder (C) 2000-2007 Andrew Apted
 
6
//
 
7
//  Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
 
8
//
 
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.
 
13
//
 
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.
 
18
//
 
19
//------------------------------------------------------------------------
 
20
 
 
21
// this includes everything we need
 
22
#include "local.h"
 
23
 
 
24
 
 
25
#define MY_TITLE  ("glBSP Node Builder " GLBSP_VER)
 
26
 
 
27
 
 
28
// Node building info
 
29
 
 
30
nodebuildinfo_t guix_info;
 
31
 
 
32
volatile nodebuildcomms_t guix_comms;
 
33
 
 
34
const nodebuildfuncs_t guix_funcs =
 
35
{
 
36
  GUI_FatalError,
 
37
  GUI_PrintMsg,
 
38
  GUI_Ticker,
 
39
 
 
40
  GUI_DisplayOpen,
 
41
  GUI_DisplaySetTitle,
 
42
  GUI_DisplaySetBar,
 
43
  GUI_DisplaySetBarLimit,
 
44
  GUI_DisplaySetBarText,
 
45
  GUI_DisplayClose
 
46
};
 
47
 
 
48
 
 
49
// GUI-specific Globals
 
50
 
 
51
guix_preferences_t guix_prefs;
 
52
 
 
53
const guix_preferences_t default_guiprefs =
 
54
{
 
55
#ifdef WIN32
 
56
  40,  20,     // win_x, win_y
 
57
#else
 
58
  40,  50,
 
59
#endif
 
60
  550, 520,    // win_w, win_h;
 
61
 
 
62
  120, 200,    // progress_x, progress_y
 
63
  90, 200,     // dialog_x, dialog_y
 
64
  80, 100,     // other_x, other_y
 
65
 
 
66
  20, 50,      // manual_x, manual_y
 
67
  610, 520,    // manual_w, manual_h
 
68
  0,           // manual_page
 
69
 
 
70
  TRUE,        // overwrite_warn
 
71
  TRUE,        // same_file_warn
 
72
  TRUE,        // lack_ext_warn
 
73
  NULL         // save_log_file
 
74
};
 
75
 
 
76
 
 
77
/* ----- user information ----------------------------- */
 
78
 
 
79
 
 
80
static void ShowTitle(void)
 
81
{
 
82
  GUI_PrintMsg(
 
83
    "\n"
 
84
    "**** GLBSP Node Builder " GLBSP_VER " (C) 2007 Andrew Apted ****\n\n"
 
85
  );
 
86
}
 
87
 
 
88
static void ShowInfo(void)
 
89
{
 
90
  GUI_PrintMsg(
 
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"
 
93
    "\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"
 
101
    "\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"
 
105
    "\n"
 
106
    "Note: glBSPX is the GUI (graphical user interface) version.\n"
 
107
    "Try plain \"glbsp\" if you want the command-line version.\n"
 
108
  );
 
109
}
 
110
 
 
111
 
 
112
void MainSetDefaults(void)
 
113
{
 
114
  // this is more messy than it was in C
 
115
  memcpy((nodebuildinfo_t  *) &guix_info,  &default_buildinfo,  
 
116
      sizeof(guix_info));
 
117
 
 
118
  memcpy((nodebuildcomms_t *) &guix_comms, &default_buildcomms, 
 
119
      sizeof(guix_comms));
 
120
 
 
121
  memcpy((guix_preferences_t *) &guix_prefs, &default_guiprefs,
 
122
      sizeof(guix_prefs));
 
123
 
 
124
  // set default filename for saving the log
 
125
  guix_prefs.save_log_file = GlbspStrDup("glbsp.log");
 
126
}
 
127
 
 
128
 
 
129
/* ----- main program ----------------------------- */
 
130
 
 
131
 
 
132
 
 
133
int main(int argc, char **argv)
 
134
{
 
135
  if (argc > 1 &&
 
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))
 
139
  {
 
140
    ShowTitle();
 
141
    ShowInfo();
 
142
    exit(1);
 
143
  }
 
144
 
 
145
  int first_arg = 1;
 
146
 
 
147
#ifdef MACOSX
 
148
  if (first_arg < argc && (strncmp(argv[first_arg], "-psn", 4) == 0))
 
149
    first_arg++;
 
150
#endif
 
151
 
 
152
  // set defaults, also initializes the nodebuildxxxx stuff
 
153
  MainSetDefaults();
 
154
 
 
155
  // read persistent data
 
156
  CookieSetPath(argv[0]);
 
157
 
 
158
  cookie_status_t cookie_ret = CookieReadAll();
 
159
 
 
160
  // handle drag and drop: a single non-option argument
 
161
  //
 
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.
 
167
  //
 
168
  boolean_g unused_args = FALSE;
 
169
 
 
170
  if (first_arg < argc && argv[first_arg][0] != '-')
 
171
  {
 
172
    GlbspFree(guix_info.input_file);
 
173
    GlbspFree(guix_info.output_file);
 
174
 
 
175
    guix_info.input_file = GlbspStrDup(argv[first_arg]);
 
176
 
 
177
    // guess an output name too
 
178
    
 
179
    guix_info.output_file = GlbspStrDup(
 
180
        HelperGuessOutput(guix_info.input_file));
 
181
 
 
182
    first_arg++;
 
183
  }
 
184
 
 
185
  if (first_arg < argc)
 
186
    unused_args = TRUE;
 
187
 
 
188
 
 
189
  // load icons for file chooser
 
190
  Fl_File_Icon::load_system_icons();
 
191
 
 
192
  guix_win = new Guix_MainWin(MY_TITLE);
 
193
   
 
194
  DialogLoadImages();
 
195
 
 
196
  ShowTitle();
 
197
 
 
198
  switch (cookie_ret)
 
199
  {
 
200
    case COOKIE_E_OK:
 
201
      break;
 
202
 
 
203
    case COOKIE_E_NO_FILE:
 
204
      guix_win->text_box->AddMsg(
 
205
          "** Missing INI file -- Using defaults **\n\n", FL_RED, TRUE);
 
206
      break;
 
207
 
 
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);
 
212
      break;
 
213
  }
 
214
 
 
215
  if (unused_args)
 
216
    guix_win->text_box->AddMsg(
 
217
        "** Warning: Ignoring extra arguments to glBSPX **\n\n", FL_RED, TRUE);
 
218
 
 
219
  // run the GUI until the user quits
 
220
  while (! guix_win->want_quit)
 
221
    Fl::wait();
 
222
 
 
223
  delete guix_win;
 
224
  guix_win = NULL;
 
225
 
 
226
  CookieWriteAll();
 
227
 
 
228
  DialogFreeImages();
 
229
 
 
230
  return 0;
 
231
}
 
232