1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
4 // Copyright(C) 2006 Simon Howard
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 #include "textscreen.h"
28 #include "configfile.h"
31 #include "setup_icon.c"
33 #include "compatibility.h"
38 #include "multiplayer.h"
41 static void DoQuit(void *widget
, void *dosave
)
51 static void QuitConfirm(void *unused1
, void *unused2
)
55 txt_button_t
*yes_button
;
56 txt_button_t
*no_button
;
58 window
= TXT_NewWindow(NULL
);
60 TXT_AddWidgets(window
,
61 label
= TXT_NewLabel("Exiting setup.\nSave settings?"),
63 yes_button
= TXT_NewButton2(" Yes ", DoQuit
, DoQuit
),
64 no_button
= TXT_NewButton2(" No ", DoQuit
, NULL
),
67 TXT_SetWidgetAlign(label
, TXT_HORIZ_CENTER
);
68 TXT_SetWidgetAlign(yes_button
, TXT_HORIZ_CENTER
);
69 TXT_SetWidgetAlign(no_button
, TXT_HORIZ_CENTER
);
71 // Only an "abort" button in the middle.
72 TXT_SetWindowAction(window
, TXT_HORIZ_LEFT
, NULL
);
73 TXT_SetWindowAction(window
, TXT_HORIZ_CENTER
,
74 TXT_NewWindowAbortAction(window
));
75 TXT_SetWindowAction(window
, TXT_HORIZ_RIGHT
, NULL
);
78 static void LaunchDoom(void *unused1
, void *unused2
)
80 execute_context_t
*exec
;
82 // Save configuration first
86 // Shut down textscreen GUI
92 exec
= NewExecuteContext();
93 AddConfigParameters(exec
);
101 txt_window_t
*window
;
102 txt_window_action_t
*quit_action
;
104 window
= TXT_NewWindow("Main Menu");
106 TXT_AddWidgets(window
,
107 TXT_NewButton2("Configure Display",
108 (TxtWidgetSignalFunc
) ConfigDisplay
, NULL
),
109 TXT_NewButton2("Configure Joystick",
110 (TxtWidgetSignalFunc
) ConfigJoystick
, NULL
),
111 TXT_NewButton2("Configure Keyboard",
112 (TxtWidgetSignalFunc
) ConfigKeyboard
, NULL
),
113 TXT_NewButton2("Configure Mouse",
114 (TxtWidgetSignalFunc
) ConfigMouse
, NULL
),
115 TXT_NewButton2("Configure Sound",
116 (TxtWidgetSignalFunc
) ConfigSound
, NULL
),
117 TXT_NewButton2("Compatibility",
118 (TxtWidgetSignalFunc
) CompatibilitySettings
, NULL
),
119 TXT_NewButton2("Save parameters and launch DOOM", LaunchDoom
, NULL
),
121 TXT_NewButton2("Start a Network Game",
122 (TxtWidgetSignalFunc
) StartMultiGame
, NULL
),
123 TXT_NewButton2("Join a Network Game",
124 (TxtWidgetSignalFunc
) JoinMultiGame
, NULL
),
125 TXT_NewButton2("Multiplayer Configuration",
126 (TxtWidgetSignalFunc
) MultiplayerConfig
, NULL
),
129 quit_action
= TXT_NewWindowAction(KEY_ESCAPE
, "Quit");
130 TXT_SignalConnect(quit_action
, "pressed", QuitConfirm
, NULL
);
131 TXT_SetWindowAction(window
, TXT_HORIZ_LEFT
, quit_action
);
135 // Initialise all configuration variables, load config file, etc
138 static void InitConfig(void)
140 SetChatMacroDefaults();
141 SetPlayerNameDefault();
151 static void SetIcon(void)
153 SDL_Surface
*surface
;
159 mask
= malloc(setup_icon_w
* setup_icon_h
/ 8);
160 memset(mask
, 0, setup_icon_w
* setup_icon_h
/ 8);
162 for (i
=0; i
<setup_icon_w
* setup_icon_h
; ++i
)
164 if (setup_icon_data
[i
* 3] != 0x00
165 || setup_icon_data
[i
* 3 + 1] != 0x00
166 || setup_icon_data
[i
* 3 + 2] != 0x00)
168 mask
[i
/ 8] |= 1 << (7 - i
% 8);
173 surface
= SDL_CreateRGBSurfaceFrom(setup_icon_data
,
183 SDL_WM_SetIcon(surface
, mask
);
184 SDL_FreeSurface(surface
);
189 // Initialise and run the textscreen GUI.
192 static void RunGUI(void)
198 fprintf(stderr
, "Failed to initialise GUI\n");
202 TXT_SetDesktopTitle(PACKAGE_NAME
" Setup ver " PACKAGE_VERSION
);
210 int main(int argc
, char *argv
[])