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
26 #include "libc_wince.h"
30 #include "textscreen.h"
34 #include "configfile.h"
37 #include "setup_icon.c"
39 #include "compatibility.h"
44 #include "multiplayer.h"
47 static void DoQuit(void *widget
, void *dosave
)
57 static void QuitConfirm(void *unused1
, void *unused2
)
61 txt_button_t
*yes_button
;
62 txt_button_t
*no_button
;
64 window
= TXT_NewWindow(NULL
);
66 TXT_AddWidgets(window
,
67 label
= TXT_NewLabel("Exiting setup.\nSave settings?"),
69 yes_button
= TXT_NewButton2(" Yes ", DoQuit
, DoQuit
),
70 no_button
= TXT_NewButton2(" No ", DoQuit
, NULL
),
73 TXT_SetWidgetAlign(label
, TXT_HORIZ_CENTER
);
74 TXT_SetWidgetAlign(yes_button
, TXT_HORIZ_CENTER
);
75 TXT_SetWidgetAlign(no_button
, TXT_HORIZ_CENTER
);
77 // Only an "abort" button in the middle.
78 TXT_SetWindowAction(window
, TXT_HORIZ_LEFT
, NULL
);
79 TXT_SetWindowAction(window
, TXT_HORIZ_CENTER
,
80 TXT_NewWindowAbortAction(window
));
81 TXT_SetWindowAction(window
, TXT_HORIZ_RIGHT
, NULL
);
84 static void LaunchDoom(void *unused1
, void *unused2
)
86 execute_context_t
*exec
;
88 // Save configuration first
92 // Shut down textscreen GUI
98 exec
= NewExecuteContext();
99 AddConfigParameters(exec
);
107 txt_window_t
*window
;
108 txt_window_action_t
*quit_action
;
110 window
= TXT_NewWindow("Main Menu");
112 TXT_AddWidgets(window
,
113 TXT_NewButton2("Configure Display",
114 (TxtWidgetSignalFunc
) ConfigDisplay
, NULL
),
115 TXT_NewButton2("Configure Joystick",
116 (TxtWidgetSignalFunc
) ConfigJoystick
, NULL
),
117 TXT_NewButton2("Configure Keyboard",
118 (TxtWidgetSignalFunc
) ConfigKeyboard
, NULL
),
119 TXT_NewButton2("Configure Mouse",
120 (TxtWidgetSignalFunc
) ConfigMouse
, NULL
),
121 TXT_NewButton2("Configure Sound",
122 (TxtWidgetSignalFunc
) ConfigSound
, NULL
),
123 TXT_NewButton2("Compatibility",
124 (TxtWidgetSignalFunc
) CompatibilitySettings
, NULL
),
125 TXT_NewButton2("Save parameters and launch DOOM", LaunchDoom
, NULL
),
127 TXT_NewButton2("Start a Network Game",
128 (TxtWidgetSignalFunc
) StartMultiGame
, NULL
),
129 TXT_NewButton2("Join a Network Game",
130 (TxtWidgetSignalFunc
) JoinMultiGame
, NULL
),
131 TXT_NewButton2("Multiplayer Configuration",
132 (TxtWidgetSignalFunc
) MultiplayerConfig
, NULL
),
135 quit_action
= TXT_NewWindowAction(KEY_ESCAPE
, "Quit");
136 TXT_SignalConnect(quit_action
, "pressed", QuitConfirm
, NULL
);
137 TXT_SetWindowAction(window
, TXT_HORIZ_LEFT
, quit_action
);
141 // Initialise all configuration variables, load config file, etc
144 static void InitConfig(void)
146 SetChatMacroDefaults();
147 SetPlayerNameDefault();
157 static void SetIcon(void)
159 SDL_Surface
*surface
;
165 mask
= malloc(setup_icon_w
* setup_icon_h
/ 8);
166 memset(mask
, 0, setup_icon_w
* setup_icon_h
/ 8);
168 for (i
=0; i
<setup_icon_w
* setup_icon_h
; ++i
)
170 if (setup_icon_data
[i
* 3] != 0x00
171 || setup_icon_data
[i
* 3 + 1] != 0x00
172 || setup_icon_data
[i
* 3 + 2] != 0x00)
174 mask
[i
/ 8] |= 1 << (7 - i
% 8);
179 surface
= SDL_CreateRGBSurfaceFrom(setup_icon_data
,
189 SDL_WM_SetIcon(surface
, mask
);
190 SDL_FreeSurface(surface
);
195 // Initialise and run the textscreen GUI.
198 static void RunGUI(void)
204 fprintf(stderr
, "Failed to initialise GUI\n");
208 TXT_SetDesktopTitle(PACKAGE_NAME
" Setup ver " PACKAGE_VERSION
);
216 int main(int argc
, char *argv
[])
223 // Windows CE has no environment, but SDL provides an implementation.
224 // Populate the environment with the values we normally find.
226 PopulateEnvironment();