1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
// Copyright(C) 2006 Simon Howard
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "textscreen.h"
#include "execute.h"
#include "m_argv.h"
#include "m_config.h"
#include "m_controls.h"
#include "setup_icon.c"
#include "mode.h"
#include "compatibility.h"
#include "display.h"
#include "joystick.h"
#include "keyboard.h"
#include "mouse.h"
#include "multiplayer.h"
#include "sound.h"
static const int cheat_sequence[] =
{
KEY_UPARROW, KEY_UPARROW, KEY_DOWNARROW, KEY_DOWNARROW,
KEY_LEFTARROW, KEY_RIGHTARROW, KEY_LEFTARROW, KEY_RIGHTARROW,
'b', 'a', KEY_ENTER, 0
};
static unsigned int cheat_sequence_index = 0;
// I think these are good "sensible" defaults:
static void SensibleDefaults(void)
{
key_up = 'w';
key_down = 's';
key_strafeleft = 'a';
key_straferight = 'd';
key_jump = '/';
key_lookup = KEY_PGUP;
key_lookdown = KEY_PGDN;
key_lookcenter = KEY_HOME;
key_flyup = KEY_INS;
key_flydown = KEY_DEL;
key_flycenter = KEY_END;
key_prevweapon = ',';
key_nextweapon = '.';
key_invleft = '[';
key_invright = ']';
key_message_refresh = '\'';
key_mission = 'i'; // Strife keys
key_invpop = 'o';
key_invkey = 'p';
key_multi_msgplayer[0] = 'g';
key_multi_msgplayer[1] = 'h';
key_multi_msgplayer[2] = 'j';
key_multi_msgplayer[3] = 'k';
key_multi_msgplayer[4] = 'v';
key_multi_msgplayer[5] = 'b';
key_multi_msgplayer[6] = 'n';
key_multi_msgplayer[7] = 'm';
mousebprevweapon = 4; // Scroll wheel = weapon cycle
mousebnextweapon = 3;
snd_musicdevice = 3;
joybspeed = 29; // Always run
vanilla_savegame_limit = 0;
vanilla_keyboard_mapping = 0;
vanilla_demo_limit = 0;
graphical_startup = 0;
show_endoom = 0;
dclick_use = 0;
novert = 1;
}
static int MainMenuKeyPress(txt_window_t *window, int key, void *user_data)
{
if (key == cheat_sequence[cheat_sequence_index])
{
++cheat_sequence_index;
if (cheat_sequence[cheat_sequence_index] == 0)
{
SensibleDefaults();
cheat_sequence_index = 0;
window = TXT_MessageBox(NULL, " \x01 ");
return 1;
}
}
else
{
cheat_sequence_index = 0;
}
return 0;
}
static void DoQuit(void *widget, void *dosave)
{
if (dosave != NULL)
{
M_SaveDefaults();
}
exit(0);
}
static void QuitConfirm(void *unused1, void *unused2)
{
txt_window_t *window;
txt_label_t *label;
txt_button_t *yes_button;
txt_button_t *no_button;
window = TXT_NewWindow(NULL);
TXT_AddWidgets(window,
label = TXT_NewLabel("Exiting setup.\nSave settings?"),
TXT_NewStrut(24, 0),
yes_button = TXT_NewButton2(" Yes ", DoQuit, DoQuit),
no_button = TXT_NewButton2(" No ", DoQuit, NULL),
NULL);
TXT_SetWidgetAlign(label, TXT_HORIZ_CENTER);
TXT_SetWidgetAlign(yes_button, TXT_HORIZ_CENTER);
TXT_SetWidgetAlign(no_button, TXT_HORIZ_CENTER);
// Only an "abort" button in the middle.
TXT_SetWindowAction(window, TXT_HORIZ_LEFT, NULL);
TXT_SetWindowAction(window, TXT_HORIZ_CENTER,
TXT_NewWindowAbortAction(window));
TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL);
}
static void LaunchDoom(void *unused1, void *unused2)
{
execute_context_t *exec;
// Save configuration first
M_SaveDefaults();
// Shut down textscreen GUI
TXT_Shutdown();
// Launch Doom
exec = NewExecuteContext();
PassThroughArguments(exec);
ExecuteDoom(exec);
exit(0);
}
static txt_button_t *GetLaunchButton(void)
{
char *label;
switch (gamemission)
{
case doom:
label = "Save parameters and launch DOOM";
break;
case heretic:
label = "Save parameters and launch Heretic";
break;
case hexen:
label = "Save parameters and launch Hexen";
break;
case strife:
label = "Save parameters and launch STRIFE!";
break;
default:
label = "Save parameters and launch game";
break;
}
return TXT_NewButton2(label, LaunchDoom, NULL);
}
void MainMenu(void)
{
txt_window_t *window;
txt_window_action_t *quit_action;
txt_window_action_t *warp_action;
window = TXT_NewWindow("Main Menu");
TXT_AddWidgets(window,
TXT_NewButton2("Configure Display",
(TxtWidgetSignalFunc) ConfigDisplay, NULL),
TXT_NewButton2("Configure Sound",
(TxtWidgetSignalFunc) ConfigSound, NULL),
TXT_NewButton2("Configure Keyboard",
(TxtWidgetSignalFunc) ConfigKeyboard, NULL),
TXT_NewButton2("Configure Mouse",
(TxtWidgetSignalFunc) ConfigMouse, NULL),
TXT_NewButton2("Configure Joystick",
(TxtWidgetSignalFunc) ConfigJoystick, NULL),
NULL);
// The compatibility window is only appropriate for Doom/Strife.
if (gamemission == doom || gamemission == strife)
{
txt_button_t *button;
button = TXT_NewButton2("Compatibility",
(TxtWidgetSignalFunc) CompatibilitySettings,
NULL);
TXT_AddWidget(window, button);
}
TXT_AddWidgets(window,
GetLaunchButton(),
TXT_NewStrut(0, 1),
TXT_NewButton2("Start a Network Game",
(TxtWidgetSignalFunc) StartMultiGame, NULL),
TXT_NewButton2("Join a Network Game",
(TxtWidgetSignalFunc) JoinMultiGame, NULL),
TXT_NewButton2("Multiplayer Configuration",
(TxtWidgetSignalFunc) MultiplayerConfig, NULL),
NULL);
quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit");
warp_action = TXT_NewWindowAction(KEY_F1, "Warp");
TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL);
TXT_SignalConnect(warp_action, "pressed",
(TxtWidgetSignalFunc) WarpMenu, NULL);
TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action);
TXT_SetWindowAction(window, TXT_HORIZ_CENTER, warp_action);
TXT_SetKeyListener(window, MainMenuKeyPress, NULL);
}
//
// Initialize all configuration variables, load config file, etc
//
static void InitConfig(void)
{
M_SetConfigDir(NULL);
InitBindings();
SetChatMacroDefaults();
SetPlayerNameDefault();
M_LoadDefaults();
}
//
// Application icon
//
static void SetIcon(void)
{
SDL_Surface *surface;
Uint8 *mask;
int i;
// Generate the mask
mask = malloc(setup_icon_w * setup_icon_h / 8);
memset(mask, 0, setup_icon_w * setup_icon_h / 8);
for (i=0; i<setup_icon_w * setup_icon_h; ++i)
{
if (setup_icon_data[i * 3] != 0x00
|| setup_icon_data[i * 3 + 1] != 0x00
|| setup_icon_data[i * 3 + 2] != 0x00)
{
mask[i / 8] |= 1 << (7 - i % 8);
}
}
surface = SDL_CreateRGBSurfaceFrom(setup_icon_data,
setup_icon_w,
setup_icon_h,
24,
setup_icon_w * 3,
0xff << 0,
0xff << 8,
0xff << 16,
0);
SDL_WM_SetIcon(surface, mask);
SDL_FreeSurface(surface);
free(mask);
}
// Initialize the textscreen library.
static void InitTextscreen(void)
{
SetDisplayDriver();
if (!TXT_Init())
{
fprintf(stderr, "Failed to initialize GUI\n");
exit(-1);
}
TXT_SetDesktopTitle(PACKAGE_NAME " Setup ver " PACKAGE_VERSION);
SetIcon();
}
// Restart the textscreen library. Used when the video_driver variable
// is changed.
void RestartTextscreen(void)
{
TXT_Shutdown();
InitTextscreen();
}
//
// Initialize and run the textscreen GUI.
//
static void RunGUI(void)
{
InitTextscreen();
TXT_GUIMainLoop();
}
static void MissionSet(void)
{
InitConfig();
MainMenu();
}
void D_DoomMain(void)
{
SetupMission(MissionSet);
RunGUI();
}
|