1 /////////////////////////////////////////
2 //
3 // OpenLieroX
4 //
5 // code under LGPL, based on JasonBs work,
6 // enhanced by Dark Charlie and Albert Zeyer
7 //
8 //
9 /////////////////////////////////////////
10
11
12 // Options
13 // Created 30/7/02
14 // Jason Boettcher
15
16
17 #include "LieroX.h"
18 #include "Sounds.h"
19 #include "Music.h"
20 #include "AuxLib.h"
21 #include "DeprecatedGUI/Graphics.h"
22 #include "DeprecatedGUI/Menu.h"
23 #include "GfxPrimitives.h"
24 #include "FindFile.h"
25 #include "StringUtils.h"
26 #include "DeprecatedGUI/CAnimation.h"
27 #include "DeprecatedGUI/CButton.h"
28 #include "DeprecatedGUI/CLabel.h"
29 #include "DeprecatedGUI/CCheckbox.h"
30 #include "DeprecatedGUI/CTextbox.h"
31 #include "DeprecatedGUI/CSlider.h"
32 #include "DeprecatedGUI/CLine.h"
33 #include "IpToCountryDB.h"
34 #include "ConversationLogger.h"
35
36
37 namespace DeprecatedGUI {
38
39 static CGuiLayout cOpt_Controls;
40 static CGuiLayout cOpt_System;
41 static CGuiLayout cOpt_Game;
42
43 bool bShowFloatingOptions = false;
44
45 enum { Static = -1 };
46
47 // Control id's
48 enum OptionsMode_t {
49 op_Controls=0,
50 op_Game,
51 op_System,
52 op_Back,
53 };
54
55 static OptionsMode_t OptionsMode = op_Controls;
56
57 enum {
58 os_Fullscreen = op_Back + 1,
59 os_ColourDepth,
60 os_SoundOn,
61 os_SoundVolume,
62 os_NetworkPort,
63 os_NetworkSpeed,
64 os_NetworkUploadBandwidth,
65 os_NetworkUploadBandwidthLabel,
66 os_NetworkUploadCheck,
67 os_UseIpToCountry,
68 os_HttpProxy,
69 os_ShowFPS,
70 os_OpenGL,
71 os_ShowPing,
72 os_LogConvos,
73 os_ScreenshotFormat,
74 os_MaxFPS,
75 os_Apply,
76 os_TestBandwidth,
77 os_TestAnimation,
78 os_ShowCountryFlags,
79 os_CheckForUpdates,
80 };
81
82 enum {
83 og_BloodAmount = op_Back + 1,
84 og_Shadows,
85 og_Particles,
86 og_OldSkoolRope,
87 og_AIDifficulty,
88 og_ShowWormHealth,
89 og_ColorizeNicks,
90 og_AutoTyping,
91 og_Antialiasing,
92 og_MouseAiming,
93 og_AllowMouseAiming,
94 og_MatchLogging,
95 og_AntilagMovementPrediction,
96 og_ScreenShaking,
97 og_DamagePopups,
98 og_ColorizeDamageByWorm,
99 og_TouchscreenTapCycleWeaponsBackwards,
100 og_TouchscreenSensitivity,
101 };
102
103 enum {
104 oc_Ply1_Up = op_Back + 1,
105 oc_Ply1_Down,
106 oc_Ply1_Left,
107 oc_Ply1_Right,
108 oc_Ply1_Shoot,
109 oc_Ply1_Jump,
110 oc_Ply1_Selweapon,
111 oc_Ply1_Rope,
112 oc_Ply1_Strafe,
113 oc_Ply1_Dig,
114
115 oc_Ply2_Up,
116 oc_Ply2_Down,
117 oc_Ply2_Left,
118 oc_Ply2_Right,
119 oc_Ply2_Shoot,
120 oc_Ply2_Jump,
121 oc_Ply2_Selweapon,
122 oc_Ply2_Rope,
123 oc_Ply2_Strafe,
124 oc_Ply2_Dig,
125
126 oc_Gen_Chat,
127 oc_Gen_Score,
128 oc_Gen_Health,
129 oc_Gen_CurSettings,
130 oc_Gen_TakeScreenshot,
131 oc_Gen_ViewportManager,
132 oc_Gen_SwitchMode,
133 oc_Gen_ToggleTopBar,
134 oc_Gen_TeamChat,
135 oc_Gen_IrcChat,
136 oc_Gen_ConsoleToggle,
137 };
138
139
140 static std::string InputNames[] = {
141 "Up",
142 "Down",
143 "Left",
144 "Right",
145 "Shoot",
146 "Jump",
147 "Select Weapon",
148 "Ninja Rope",
149 "Strafe",
150 "Dig"
151 };
152
153
154 static bool bSpeedTest = false;
155
Menu_OptionsAddTopButtons(CGuiLayout * layout)156 static void Menu_OptionsAddTopButtons(CGuiLayout * layout)
157 {
158 // Setup the top buttons
159 if (!getenv("ANDROID_TV"))
160 layout->Add( new CButton(BUT_CONTROLS, tMenu->bmpButtons), op_Controls, 180, 110, 100, 15);
161 layout->Add( new CButton(BUT_GAME, tMenu->bmpButtons), op_Game, getenv("ANDROID_TV") ? 180 : 310, 110, 50, 15);
162 layout->Add( new CButton(BUT_SYSTEM, tMenu->bmpButtons), op_System, 390, 110, 70, 15);
163 layout->Add( new CButton(BUT_BACK, tMenu->bmpButtons), op_Back, 40,440, 50,15);
164 }
165
166 ///////////////////
167 // Initialize the options
Menu_OptionsInitialize(bool floating)168 bool Menu_OptionsInitialize(bool floating)
169 {
170 bShowFloatingOptions = floating;
171 if (!bShowFloatingOptions)
172 tMenu->iMenuType = MNU_OPTIONS;
173 OptionsMode = getenv("ANDROID_TV") ? op_Game : op_Controls;
174 int i;
175 bSpeedTest = false;
176
177 // Create the buffer
178 DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
179 if (tMenu->tFrontendInfo.bPageBoxes)
180 Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
181 if (!bShowFloatingOptions)
182 Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_OPTIONS);
183
184 Menu_RedrawMouse(true);
185
186 cOpt_System.Shutdown();
187 cOpt_System.Initialize();
188 Menu_OptionsAddTopButtons(&cOpt_System);
189
190 cOpt_Controls.Shutdown();
191 cOpt_Controls.Initialize();
192 Menu_OptionsAddTopButtons(&cOpt_Controls);
193
194 cOpt_Game.Shutdown();
195 cOpt_Game.Initialize();
196 Menu_OptionsAddTopButtons(&cOpt_Game);
197
198 // Controls
199 cOpt_Controls.Add( new CLabel("Player Controls", tLX->clHeading), Static, 40, 150, 0,0);
200 cOpt_Controls.Add( new CLabel("Player 1",tLX->clSubHeading), Static, 163, 170, 0,0);
201 cOpt_Controls.Add( new CLabel("Player 2",tLX->clSubHeading), Static, 268, 170, 0,0);
202 cOpt_Controls.Add( new CLabel("General Controls", tLX->clHeading),Static, 390, 150, 0,0);
203
204 int y = 190;
205 for( i=0; i < sizeof(InputNames) / sizeof(InputNames[0]); i++, y+=25) {
206 cOpt_Controls.Add( new CLabel(InputNames[i],tLX->clNormalLabel), Static, 40, y, 0,0);
207
208 cOpt_Controls.Add( new CInputbox(SIN_UP+i, tLXOptions->sPlayerControls[0][SIN_UP+i], tMenu->bmpInputbox, InputNames[i]),
209 oc_Ply1_Up+i, 165, y, 50,17);
210 cOpt_Controls.Add( new CInputbox(SIN_UP+i, tLXOptions->sPlayerControls[1][SIN_UP+i], tMenu->bmpInputbox, InputNames[i]),
211 oc_Ply2_Up+i, 270, y, 50,17);
212
213 }
214
215 // General Controls
216 cOpt_Controls.Add( new CLabel("Chat", tLX->clNormalLabel), Static, 390, 190, 0,0);
217 cOpt_Controls.Add( new CInputbox(SIN_CHAT, tLXOptions->sGeneralControls[SIN_CHAT], tMenu->bmpInputbox, "Chat"),
218 oc_Gen_Chat, 525, 190, 50,17);
219
220 cOpt_Controls.Add( new CLabel("Scoreboard", tLX->clNormalLabel), Static, 390, 215, 0,0);
221 cOpt_Controls.Add( new CInputbox(SIN_SCORE, tLXOptions->sGeneralControls[SIN_SCORE], tMenu->bmpInputbox, "Scoreboard"),
222 oc_Gen_Score, 525, 215, 50,17);
223
224 cOpt_Controls.Add( new CLabel("Health Bar", tLX->clNormalLabel), Static, 390, 240, 0,0);
225 cOpt_Controls.Add( new CInputbox(SIN_HEALTH, tLXOptions->sGeneralControls[SIN_HEALTH], tMenu->bmpInputbox, "Health Bar"),
226 oc_Gen_Health, 525, 240, 50,17);
227
228 cOpt_Controls.Add( new CLabel("Current Settings", tLX->clNormalLabel), Static, 390, 265, 0,0);
229 cOpt_Controls.Add( new CInputbox(SIN_SETTINGS, tLXOptions->sGeneralControls[SIN_SETTINGS], tMenu->bmpInputbox, "Current Settings"),
230 oc_Gen_CurSettings, 525, 265, 50,17);
231
232 cOpt_Controls.Add( new CLabel("Take Screenshot", tLX->clNormalLabel), Static, 390, 290, 0,0);
233 cOpt_Controls.Add( new CInputbox(SIN_SCREENSHOTS, tLXOptions->sGeneralControls[SIN_SCREENSHOTS], tMenu->bmpInputbox, "Take Screenshot"),
234 oc_Gen_TakeScreenshot, 525, 290, 50,17);
235
236 cOpt_Controls.Add( new CLabel("Viewport Manager", tLX->clNormalLabel), Static, 390, 315, 0,0);
237 cOpt_Controls.Add( new CInputbox(SIN_VIEWPORTS, tLXOptions->sGeneralControls[SIN_VIEWPORTS], tMenu->bmpInputbox, "Viewport Manager"),
238 oc_Gen_ViewportManager, 525, 315, 50,17);
239
240 cOpt_Controls.Add( new CLabel("Switch Video Mode", tLX->clNormalLabel), Static, 390, 340, 0,0);
241 cOpt_Controls.Add( new CInputbox(SIN_SWITCHMODE, tLXOptions->sGeneralControls[SIN_SWITCHMODE], tMenu->bmpInputbox, "Switch Video Mode"),
242 oc_Gen_SwitchMode, 525, 340, 50,17);
243
244 cOpt_Controls.Add( new CLabel("Toggle Top Bar", tLX->clNormalLabel), Static, 390, 365, 0,0);
245 cOpt_Controls.Add( new CInputbox(SIN_TOGGLETOPBAR, tLXOptions->sGeneralControls[SIN_TOGGLETOPBAR], tMenu->bmpInputbox, "Toggle Top Bar"),
246 oc_Gen_ToggleTopBar, 525, 365, 50,17);
247
248 cOpt_Controls.Add( new CLabel("Teamchat", tLX->clNormalLabel), Static, 390, 390, 0,0);
249 cOpt_Controls.Add( new CInputbox(SIN_TEAMCHAT, tLXOptions->sGeneralControls[SIN_TEAMCHAT], tMenu->bmpInputbox, "Teamchat"),
250 oc_Gen_TeamChat, 525, 390, 50,17);
251
252 cOpt_Controls.Add( new CLabel("IRC chat window", tLX->clNormalLabel), Static, 390, 415, 0,0);
253 cOpt_Controls.Add( new CInputbox(SIN_IRCCHAT, tLXOptions->sGeneralControls[SIN_IRCCHAT], tMenu->bmpInputbox, "IRC chat"),
254 oc_Gen_IrcChat, 525, 415, 50,17);
255
256 cOpt_Controls.Add( new CLabel("Toggle console", tLX->clNormalLabel), Static, 390, 440, 0,0);
257 cOpt_Controls.Add( new CInputbox(SIN_CONSOLETOGGLE, tLXOptions->sGeneralControls[SIN_CONSOLETOGGLE], tMenu->bmpInputbox, "Console"),
258 oc_Gen_ConsoleToggle, 525, 440, 50,17);
259
260
261
262 // System
263 const Color lineCol = tLX->clLine; //tLX->clHeading.derived(0,0,0,-200);
264 const int starty = 130;
265 y = starty;
266 cOpt_System.Add( new CLabel("Video",tLX->clHeading), Static, 40, y, 0,0);
267 cOpt_System.Add( new CLine(0,0,0,0, lineCol), Static, 90, y + 8, 620 - 150, 0);
268 y += 20;
269 // Do not allow changing video mode during game, it is complicated
270 if (!bShowFloatingOptions) {
271 cOpt_System.Add( new CLabel("Fullscreen",tLX->clNormalLabel), Static, 60, y, 0,0);
272 cOpt_System.Add( new CLabel("Colour depth",tLX->clNormalLabel), Static, 175, y, 0,0);
273 cOpt_System.Add( new CLabel("Use OpenGL Rendering",tLX->clNormalLabel),Static, 440, y, 0,0);
274 }
275 cOpt_System.Add( new CCheckbox(tLXOptions->bFullscreen),os_Fullscreen, 140, y, 17,17);
276 cOpt_System.Add( new CCheckbox(tLXOptions->bOpenGL), os_OpenGL, 590, y, 17,17);
277
278 y += 20;
279 cOpt_System.Add( new CLabel("Audio",tLX->clHeading), Static, 40, y, 0,0);
280 cOpt_System.Add( new CLine(0,0,0,0, lineCol), Static, 90, y + 8, 620 - 150, 0);
281 y += 20;
282 cOpt_System.Add( new CLabel("Sound on",tLX->clNormalLabel), Static, 60, y, 0,0);
283 cOpt_System.Add( new CCheckbox(tLXOptions->bSoundOn), os_SoundOn, 170, y, 17,17);
284 cOpt_System.Add( new CLabel("Sound volume",tLX->clNormalLabel), Static, 330, y, 0,0);
285 cOpt_System.Add( new CSlider(100), os_SoundVolume, 435, y - 2, 110, 20); y += 25;
286
287 y += 20;
288 cOpt_System.Add( new CLabel("Network",tLX->clHeading), Static, 40, y, 0,0);
289 cOpt_System.Add( new CLine(0,0,0,0, lineCol), Static, 110, y + 8, 620 - 170, 0);
290 y += 20;
291 cOpt_System.Add( new CLabel("Network port",tLX->clNormalLabel), Static, 60, y, 0,0);
292 cOpt_System.Add( new CTextbox(), os_NetworkPort, 170, y - 2, 100,tLX->cFont.GetHeight());
293
294 cOpt_System.Add( new CLabel("Use IP To Country Database",tLX->clNormalLabel), Static, 330, y, 0,0);
295 cOpt_System.Add( new CCheckbox(tLXOptions->bUseIpToCountry), os_UseIpToCountry, 530,y,17,17); y += 30;
296
297 cOpt_System.Add( new CLabel("Network speed",tLX->clNormalLabel), Static, 60, y, 0,0);
298
299 cOpt_System.Add( new CLabel("Show country flags",tLX->clNormalLabel), Static, 330, y, 0,0);
300 cOpt_System.Add( new CCheckbox(tLXOptions->bShowCountryFlags), os_ShowCountryFlags, 530, y,17,17); y += 30;
301
302 cOpt_System.Add( new CLabel("HTTP proxy",tLX->clNormalLabel), Static, 60, y, 0,0);
303 cOpt_System.Add( new CTextbox(), os_HttpProxy, 170, y - 2, 130,tLX->cFont.GetHeight());
304
305 cOpt_System.Add( new CLabel("Check bandwidth sanity",tLX->clNormalLabel), Static, 330, y, 0,0);
306 cOpt_System.Add( new CCheckbox(tLXOptions->bCheckBandwidthSanity), os_NetworkUploadCheck, 530, y,17,17);
307 y += 25;
308
309 cOpt_System.Add( new CLabel("Server max upload bandwidth",tLX->clNormalLabel), os_NetworkUploadBandwidthLabel, 60, y, 0,0);
310 cOpt_System.Add( new CTextbox(), os_NetworkUploadBandwidth, 250, y - 2, 50,tLX->cFont.GetHeight());
311 cOpt_System.Add( new CButton(BUT_TEST, tMenu->bmpButtons), os_TestBandwidth, 327, y - 2, 30, 22);
312
313
314 y += 20;
315 cOpt_System.Add( new CLabel("Miscellanous",tLX->clHeading), Static, 40, y, 0,0);
316 cOpt_System.Add( new CLine(0,0,0,0, lineCol), Static, 130, y + 8, 620 - 200, 0);
317 y += 20;
318 cOpt_System.Add( new CLabel("Show FPS",tLX->clNormalLabel), Static, 60, y, 0,0);
319 cOpt_System.Add( new CCheckbox(tLXOptions->bShowFPS), os_ShowFPS, 200, y, 17,17);
320
321 cOpt_System.Add( new CLabel("Screenshot format",tLX->clNormalLabel),Static, 230,y, 0,0);
322 cOpt_System.Add( new CLabel("Max FPS",tLX->clNormalLabel),Static, 460,y, 0,0);
323 cOpt_System.Add( new CTextbox(), os_MaxFPS, 530, y - 2, 50,tLX->cFont.GetHeight());
324 y += 30;
325
326 cOpt_System.Add( new CLabel("Log Conversations",tLX->clNormalLabel),Static, 60, y, 0,0);
327 cOpt_System.Add( new CCheckbox(tLXOptions->bLogConvos), os_LogConvos, 200,y,17,17);
328 cOpt_System.Add( new CLabel("Check for updates",tLX->clNormalLabel),Static, 230, y, 0,0);
329 cOpt_System.Add( new CCheckbox(tLXOptions->bCheckForUpdates), os_CheckForUpdates, 365,y,17,17);
330 cOpt_System.Add( new CLabel("Show ping",tLX->clNormalLabel), Static, 460, y, 0,0);
331 cOpt_System.Add( new CCheckbox(tLXOptions->bShowPing), os_ShowPing, 530,y,17,17);
332
333
334 cOpt_System.SendMessage(os_NetworkPort,TXM_SETMAX,5,0);
335
336 cOpt_System.Add( new CButton(BUT_APPLY, tMenu->bmpButtons), os_Apply, 555,440, 60,15);
337
338 // Put the combo box after the other widgets to get around the problem with widget layering
339 cOpt_System.Add( new CCombobox(), os_NetworkSpeed, 170, starty + 155 - 3, 130,17);
340 cOpt_System.Add( new CCombobox(), os_ScreenshotFormat, 365, starty + 250 - 2, 70,17);
341 cOpt_System.Add( new CCombobox(), os_ColourDepth, 275, starty + 20, 145, 17);
342
343 // Set the values
344 CSlider *s = (CSlider *)cOpt_System.getWidget(os_SoundVolume);
345 s->setValue( tLXOptions->iSoundVolume );
346
347 CTextbox *t = (CTextbox *)cOpt_System.getWidget(os_NetworkPort);
348 t->setText( itoa(tLXOptions->iNetworkPort) );
349 t = (CTextbox *)(cOpt_System.getWidget(os_MaxFPS));
350 t->setText(itoa(tLXOptions->nMaxFPS));
351 t = (CTextbox *)(cOpt_System.getWidget(os_HttpProxy));
352 t->setText(tLXOptions->sHttpProxy);
353
354 // Network speed
355 for(i=0; i<3; i++)
356 cOpt_System.SendMessage(os_NetworkSpeed, CBS_ADDITEM, NetworkSpeedString((NetworkSpeed)i), i);
357
358 cOpt_System.SendMessage(os_NetworkSpeed, CBM_SETCURSEL, tLXOptions->iNetworkSpeed, 0);
359 cOpt_System.SendMessage(os_NetworkSpeed, CBM_SETCURINDEX, tLXOptions->iNetworkSpeed, 0);
360 ((CTextbox *)cOpt_System.getWidget( os_NetworkUploadBandwidth ))->setText( itoa(tLXOptions->iMaxUploadBandwidth) );
361 cOpt_System.getWidget( os_NetworkUploadBandwidth )->setEnabled( tLXOptions->iNetworkSpeed >= NST_LAN );
362 cOpt_System.getWidget( os_NetworkUploadBandwidthLabel )->setEnabled( tLXOptions->iNetworkSpeed >= NST_LAN );
363 cOpt_System.getWidget( os_TestBandwidth )->setEnabled( tLXOptions->iNetworkSpeed >= NST_LAN );
364
365 // Screenshot format
366 cOpt_System.SendMessage(os_ScreenshotFormat, CBS_ADDITEM, "Bmp", FMT_BMP);
367 cOpt_System.SendMessage(os_ScreenshotFormat, CBS_ADDITEM, "Png", FMT_PNG);
368 cOpt_System.SendMessage(os_ScreenshotFormat, CBS_ADDITEM, "Gif", FMT_GIF);
369 cOpt_System.SendMessage(os_ScreenshotFormat, CBS_ADDITEM, "Jpg", FMT_JPG);
370
371 cOpt_System.SendMessage(os_ScreenshotFormat, CBM_SETCURSEL, tLXOptions->iScreenshotFormat, 0);
372 cOpt_System.SendMessage(os_ScreenshotFormat, CBM_SETCURINDEX, tLXOptions->iScreenshotFormat, 0);
373
374 // Color depth
375 cOpt_System.SendMessage(os_ColourDepth, CBS_ADDITEM, "Automatic", 0);
376 cOpt_System.SendMessage(os_ColourDepth, CBS_ADDITEM, "High Color (16 bit)", 1);
377 cOpt_System.SendMessage(os_ColourDepth, CBS_ADDITEM, "True Color (24 bit)", 2);
378 cOpt_System.SendMessage(os_ColourDepth, CBS_ADDITEM, "True Color (32 bit)", 3);
379
380 switch (tLXOptions->iColourDepth) {
381 case 0: // Automatic
382 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURSEL, (DWORD)0, 0);
383 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURINDEX, (DWORD)0, 0);
384 break;
385 case 16: // 16 bit
386 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURSEL, (DWORD)1, 0);
387 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURINDEX, (DWORD)1, 0);
388 break;
389 case 24: // 24 bit
390 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURSEL, (DWORD)2, 0);
391 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURINDEX, (DWORD)2, 0);
392 break;
393 case 32: // 32 bit
394 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURSEL, (DWORD)3, 0);
395 cOpt_System.SendMessage(os_ColourDepth, CBM_SETCURINDEX, (DWORD)3, 0);
396 break;
397 }
398
399 // Do not allow changing video mode during game, it is complicated
400 if (bShowFloatingOptions) {
401 cOpt_System.getWidget(os_Fullscreen)->setEnabled(false);
402 cOpt_System.getWidget(os_ColourDepth)->setEnabled(false);
403 cOpt_System.getWidget(os_OpenGL)->setEnabled(false);
404 }
405
406 // Disable apply for now
407 cOpt_System.getWidget(os_Apply)->setEnabled(false);
408
409
410 // Game
411 cOpt_Game.Add( new CLabel("Blood Amount",tLX->clNormalLabel), Static, 40, 150, 0,0);
412 cOpt_Game.Add( new CSlider(5000), og_BloodAmount, 175, 147, 210, 20);
413 cOpt_Game.SendMessage( og_BloodAmount, SLM_SETVALUE, tLXOptions->iBloodAmount, 0);
414 cOpt_Game.Add( new CLabel("Shadows",tLX->clNormalLabel), Static, 40, 180, 0,0);
415 cOpt_Game.Add( new CCheckbox(tLXOptions->bShadows), og_Shadows, 280, 180, 17,17);
416 cOpt_Game.Add( new CLabel("Particles",tLX->clNormalLabel), Static, 40, 210, 0,0);
417 cOpt_Game.Add( new CCheckbox(tLXOptions->bParticles), og_Particles, 280, 210, 17,17);
418 cOpt_Game.Add( new CLabel("Classic Rope throw",tLX->clNormalLabel), Static, 40, 240, 0,0);
419 cOpt_Game.Add( new CCheckbox(tLXOptions->bOldSkoolRope),og_OldSkoolRope, 280, 240, 17,17);
420 //cOpt_Game.Add( new CLabel("Show worm's health",tLX->clNormalLabel), Static, 40, 270, 0,0);
421 //cOpt_Game.Add( new CCheckbox(tLXOptions->bShowHealth), og_ShowWormHealth, 280, 270, 17,17);
422 cOpt_Game.Add( new CLabel("Colorize nicks by teams",tLX->clNormalLabel), Static, 40, 270, 0,0);
423 cOpt_Game.Add( new CCheckbox(tLXOptions->bColorizeNicks),og_ColorizeNicks, 280, 270, 17,17);
424 cOpt_Game.Add( new CLabel("Start typing after any key press",tLX->clNormalLabel), Static, 40, 300, 0,0);
425 cOpt_Game.Add( new CCheckbox(tLXOptions->bAutoTyping),og_AutoTyping, 280, 300, 17,17);
426 cOpt_Game.Add( new CLabel("Use antialiasing (slow)",tLX->clNormalLabel), Static, 40, 330, 0,0);
427 cOpt_Game.Add( new CCheckbox(tLXOptions->bAntiAliasing),og_Antialiasing, 280, 330, 17,17);
428 //cOpt_Game.Add( new CLabel("AI Difficulty",tLX->clNormalLabel), Static, 40, 270, 0,0);
429 //cOpt_Game.Add( new CSlider(3), og_AIDifficulty, 175, 267, 100, 20);
430 /* cOpt_Game.Add( new CLabel("Enable mouse control (Player 1)",tLX->clNormalLabel), Static, 40, 420, 0,0);
431 cOpt_Game.Add( new CCheckbox(tLXOptions->bMouseAiming),og_MouseAiming, 280, 420, 17,17); */
432 cOpt_Game.Add( new CLabel("Log my game results",tLX->clNormalLabel), Static, 40, 390, 0,0);
433 cOpt_Game.Add( new CCheckbox(tLXOptions->bMatchLogging),og_MatchLogging, 280, 390, 17,17);
434
435 cOpt_Game.Add( new CLabel("Network antilag prediction",tLX->clNormalLabel), Static, 40, 360, 0,0);
436 cOpt_Game.Add( new CCheckbox(tLXOptions->bAntilagMovementPrediction),og_AntilagMovementPrediction, 280, 360, 17,17);
437
438 /* cOpt_Game.Add( new CLabel("Shake screen on explosions",tLX->clNormalLabel), Static, 330, 180, 0,0);
439 cOpt_Game.Add( new CCheckbox(tLXOptions->bScreenShaking), og_ScreenShaking, 550, 180, 17,17); */
440
441 cOpt_Game.Add( new CLabel("Damage popups above worms",tLX->clNormalLabel), Static, 330, 210, 0,0);
442 cOpt_Game.Add( new CCheckbox(tLXOptions->bDamagePopups), og_DamagePopups, 550, 210, 17,17);
443
444 cOpt_Game.Add( new CLabel("Colorize damage popups by worm",tLX->clNormalLabel), Static, 330, 240, 0,0);
445 cOpt_Game.Add( new CCheckbox(tLXOptions->bColorizeDamageByWorm), og_ColorizeDamageByWorm, 550, 240, 17,17);
446
447 #ifdef __ANDROID__
448 cOpt_Game.Add( new CLabel("Tapping cycles weapons backwards", tLX->clNormalLabel), Static, 330, 270, 0,0);
449 cOpt_Game.Add( new CCheckbox(tLXOptions->bTouchscreenTapCycleWeaponsBackwards), og_TouchscreenTapCycleWeaponsBackwards, 550, 270, 17,17);
450
451 cOpt_Game.Add( new CLabel("Touchscreen sensitivity", tLX->clNormalLabel), Static, 330, 300, 0,0);
452 cOpt_Game.Add( new CSlider(9), og_TouchscreenSensitivity, 470, 300, 100, 20);
453 cOpt_Game.SendMessage( og_TouchscreenSensitivity, SLM_SETVALUE, tLXOptions->iTouchscreenSensitivity, 0);
454 #endif
455
456 /*
457 cOpt_Game.Add( new CLabel("Allow mouse control (Server)",tLX->clNormalLabel), Static, 330, 360, 0,0);
458 cOpt_Game.Add( new CCheckbox(tLXOptions->bAllowMouseAiming),og_AllowMouseAiming, 550, 360, 17,17);
459
460 cOpt_Game.Add( new CLabel("Allow strafing (Server)",tLX->clNormalLabel), Static, 330, 390, 0,0);
461 cOpt_Game.Add( new CCheckbox(&tLXOptions->bAllowStrafing), Static, 550, 390, 17,17);
462 */
463
464 // TODO: Fix cSlider so it's value thing doesn't take up a square of 100x100 pixels.
465
466 // Set the values
467 //cOpt_Game.SendMessage( og_AIDifficulty, SLM_SETVALUE, tLXOptions->iAIDifficulty, 0);
468
469
470 return true;
471 }
472
Menu_FloatingOptionsInitialize()473 bool Menu_FloatingOptionsInitialize()
474 {
475 return Menu_OptionsInitialize(true);
476 }
477
478
Menu_StartWithSysOptionsMenu(void *)479 bool Menu_StartWithSysOptionsMenu(void*) {
480 iSkipStart = true;
481 Menu_OptionsInitialize();
482 OptionsMode = op_System;
483 return true;
484 }
485
486 ///////////////////
487 // Called when the upload speed test finishes
Menu_OptionsUpdateUpload(float speed)488 void Menu_OptionsUpdateUpload(float speed)
489 {
490 tLXOptions->iMaxUploadBandwidth = (int)speed / 2; // HINT: we set only a half of the maximum bandwidth not to block the line with upload only
491
492 // Get the textbox
493 CTextbox *txt = (CTextbox *)cOpt_System.getWidget(os_NetworkUploadBandwidth);
494 if (!txt)
495 return;
496
497 // Set the new value
498 txt->setText(itoa((int)speed));
499
500 // Set the network speed to LAN if appropriate
501 if (tLXOptions->iMaxUploadBandwidth >= 7500) {
502 tLXOptions->iNetworkSpeed = NST_LAN;
503 CCombobox *cmb = (CCombobox *)cOpt_System.getWidget(os_NetworkSpeed);
504 if (cmb)
505 cmb->setCurItem(cmb->getItem(NST_LAN));
506 }
507 }
508
Menu_OptionsProcessTopButtons(gui_event_t * ev)509 static bool Menu_OptionsProcessTopButtons(gui_event_t *ev)
510 {
511 if(ev) {
512 switch(ev->iControlID) {
513 // Back button
514 case op_Back:
515 if(ev->iEventMsg == BTN_CLICKED) {
516
517 // Shutdown & save
518 tLXOptions->SaveToDisc();
519 if (bShowFloatingOptions) {
520 Menu_FloatingOptionsShutdown();
521 } else {
522 Menu_OptionsShutdown();
523 // Leave
524 Menu_MainInitialize();
525 }
526 PlaySoundSample(sfxGeneral.smpClick);
527 return true;
528 }
529 break;
530
531 // Top buttons
532 case op_Controls:
533 case op_Game:
534 case op_System:
535 if(ev->iEventMsg == BTN_CLICKED) {
536 DrawImageAdv(VideoPostProcessor::videoSurface(), tMenu->bmpBuffer, 20,140, 20,140, 620,340);
537 OptionsMode = (OptionsMode_t) ev->iControlID;
538 PlaySoundSample(sfxGeneral.smpClick);
539 cOpt_Controls.FocusWidget(ev->iControlID);
540 cOpt_Game.FocusWidget(ev->iControlID);
541 cOpt_System.FocusWidget(ev->iControlID);
542 return true;
543 }
544 break;
545 }
546 }
547 return false;
548 }
549
550 ///////////////////
551 // Options main frame
Menu_OptionsFrame()552 void Menu_OptionsFrame()
553 {
554 gui_event_t *ev = NULL;
555 int val;
556
557 CCheckbox *c,*c2;
558
559 // Process the top buttons
560 SetGameCursor(CURSOR_ARROW); // Hack: button changed the cursor to hand, we need to change it back
561
562 if(OptionsMode == op_Controls) {
563
564 // Controls
565 ev = bSpeedTest ? NULL : cOpt_Controls.Process();
566 cOpt_Controls.Draw(VideoPostProcessor::videoSurface());
567
568 if (Menu_OptionsProcessTopButtons(ev))
569 return;
570
571 if(ev) {
572
573 if(ev->cWidget->getType() == wid_Inputbox) {
574
575 if(ev->iEventMsg == INB_MOUSEUP) {
576
577 int ply = 0;
578 if(ev->iControlID >= oc_Ply2_Up && ev->iControlID <= oc_Ply2_Strafe)
579 ply = 1;
580 if(ev->iControlID >= oc_Gen_Chat)
581 ply = -1;
582
583 // Get an input
584 CInputbox *b = (CInputbox *)ev->cWidget;
585 Menu_OptionsWaitInput(ply, b->getName(), b);
586
587 tLX->setupInputs(); // just resetup all
588 }
589 }
590 }
591 }
592
593
594 if(OptionsMode == op_Game) {
595
596 // Game
597 ev = bSpeedTest ? NULL : cOpt_Game.Process();
598 cOpt_Game.Draw(VideoPostProcessor::videoSurface());
599
600 if (Menu_OptionsProcessTopButtons(ev))
601 return;
602
603 val = cOpt_Game.SendMessage(og_BloodAmount, SLM_GETVALUE, (DWORD)0, 0);
604 //s = (CSlider *)cOpt_Game.getWidget(og_BloodAmount);
605 DrawImageAdv(VideoPostProcessor::videoSurface(), tMenu->bmpBuffer, 385,140, 385,140, 70,40);
606 tLX->cFont.Draw(VideoPostProcessor::videoSurface(),385, 148, tLX->clNormalLabel, itoa(val)+"%");
607
608 //val = cOpt_Game.SendMessage(og_AIDifficulty, SLM_GETVALUE, 0, 0);
609 //DrawImageAdv(VideoPostProcessor::videoSurface(), tMenu->bmpBuffer, 285,260, 285,260, 100,50);
610 //tLX->cFont.Draw(VideoPostProcessor::videoSurface(),285, 268, tLX->clNormalLabel,Difficulties[val]);
611
612
613
614 if(ev) {
615
616 switch(ev->iControlID) {
617
618 // Blood amount
619 case og_BloodAmount:
620 if(ev->iEventMsg == SLD_CHANGE) {
621 val = cOpt_Game.SendMessage(og_BloodAmount, SLM_GETVALUE, (DWORD)0, 0);
622 tLXOptions->iBloodAmount = val;
623 }
624 break;
625
626 // Shadows
627 case og_Shadows:
628 if(ev->iEventMsg == CHK_CHANGED) {
629 c = (CCheckbox *)cOpt_Game.getWidget(og_Shadows);
630 tLXOptions->bShadows = c->getValue();
631 }
632 break;
633
634 // Particles
635 case og_Particles:
636 if(ev->iEventMsg == CHK_CHANGED) {
637 c = (CCheckbox *)cOpt_Game.getWidget(og_Particles);
638 tLXOptions->bParticles = c->getValue();
639 }
640 break;
641
642 // AI Difficulty
643 /*case og_AIDifficulty:
644 if(ev->iEventMsg == SLD_CHANGE) {
645 val = cOpt_Game.SendMessage(og_AIDifficulty, SLM_GETVALUE, 0, 0);
646 tLXOptions->iAIDifficulty = val;
647 }
648 break;*/
649
650 // Old skool rope throw
651 case og_OldSkoolRope:
652 if(ev->iEventMsg == CHK_CHANGED) {
653 tLXOptions->bOldSkoolRope = cOpt_Game.SendMessage(og_OldSkoolRope,CKM_GETCHECK,(DWORD)0,0) != 0;
654 }
655 break;
656
657 // Show the worm's health below name
658 /* case og_ShowWormHealth:
659 if(ev->iEventMsg == CHK_CHANGED)
660 tLXOptions->iShowHealth = cOpt_Game.SendMessage(og_ShowWormHealth, CKM_GETCHECK, (DWORD)0, 0);
661 break;*/
662
663 // TDM nick colorizing
664 case og_ColorizeNicks:
665 if(ev->iEventMsg == CHK_CHANGED)
666 tLXOptions->bColorizeNicks = cOpt_Game.SendMessage(og_ColorizeNicks, CKM_GETCHECK, (DWORD)0, 0) != 0;
667 break;
668
669 // Auto typing
670 case og_AutoTyping:
671 if(ev->iEventMsg == CHK_CHANGED)
672 tLXOptions->bAutoTyping = cOpt_Game.SendMessage(og_AutoTyping, CKM_GETCHECK, (DWORD)0, 0) != 0;
673 break;
674
675 // Antialiasing
676 case og_Antialiasing:
677 if(ev->iEventMsg == CHK_CHANGED)
678 tLXOptions->bAntiAliasing = cOpt_Game.SendMessage(og_Antialiasing, CKM_GETCHECK, (DWORD)0, 0) != 0;
679 break;
680
681 // Mouse aiming
682 case og_MouseAiming:
683 if(ev->iEventMsg == CHK_CHANGED)
684 tLXOptions->bMouseAiming = cOpt_Game.SendMessage(og_MouseAiming, CKM_GETCHECK, (DWORD)0, 0) != 0;
685 break;
686 /*
687 case og_AllowMouseAiming:
688 if(ev->iEventMsg == CHK_CHANGED)
689 tLXOptions->bAllowMouseAiming = cOpt_Game.SendMessage(og_AllowMouseAiming, CKM_GETCHECK, (DWORD)0, 0) != 0;
690 break;
691 */
692
693 // Match logging
694 case og_MatchLogging:
695 if(ev->iEventMsg == CHK_CHANGED)
696 tLXOptions->bMatchLogging = cOpt_Game.SendMessage(og_MatchLogging, CKM_GETCHECK, (DWORD)0, 0) != 0;
697 break;
698
699 case og_AntilagMovementPrediction:
700 if(ev->iEventMsg == CHK_CHANGED)
701 tLXOptions->bAntilagMovementPrediction = cOpt_Game.SendMessage(og_AntilagMovementPrediction, CKM_GETCHECK, (DWORD)0, 0) != 0;
702 break;
703
704 /* case og_ScreenShaking:
705 if(ev->iEventMsg == CHK_CHANGED)
706 tLXOptions->bScreenShaking = cOpt_Game.SendMessage(og_ScreenShaking, CKM_GETCHECK, (DWORD)0, 0) != 0;
707 break; */
708
709 case og_DamagePopups:
710 if(ev->iEventMsg == CHK_CHANGED)
711 tLXOptions->bDamagePopups = cOpt_Game.SendMessage(og_DamagePopups, CKM_GETCHECK, (DWORD)0, 0) != 0;
712 break;
713
714 case og_ColorizeDamageByWorm:
715 if(ev->iEventMsg == CHK_CHANGED)
716 tLXOptions->bColorizeDamageByWorm = cOpt_Game.SendMessage(og_ColorizeDamageByWorm, CKM_GETCHECK, (DWORD)0, 0) != 0;
717 break;
718
719 case og_TouchscreenTapCycleWeaponsBackwards:
720 if(ev->iEventMsg == CHK_CHANGED)
721 tLXOptions->bTouchscreenTapCycleWeaponsBackwards = cOpt_Game.SendMessage(og_TouchscreenTapCycleWeaponsBackwards, CKM_GETCHECK, (DWORD)0, 0) != 0;
722 break;
723
724 case og_TouchscreenSensitivity:
725 if(ev->iEventMsg == SLD_CHANGE) {
726 val = cOpt_Game.SendMessage(og_TouchscreenSensitivity, SLM_GETVALUE, (DWORD)0, 0);
727 tLXOptions->iTouchscreenSensitivity = val;
728 }
729 break;
730
731 }
732 }
733
734 }
735
736
737 // Process the different pages
738 if(OptionsMode == op_System) {
739
740 // Fullscreen value
741 c = (CCheckbox *)cOpt_System.getWidget(os_Fullscreen);
742 bool fullscr = c->getValue();
743 // OpenGL accel value
744 c2 = (CCheckbox *)cOpt_System.getWidget(os_OpenGL);
745 bool opengl = c2->getValue () != 0;
746 // Color depth
747 int cdepth = ((CCombobox *)cOpt_System.getWidget(os_ColourDepth))->getSelectedIndex();
748 switch (cdepth) {
749 case 0: cdepth = 0; break;
750 case 1: cdepth = 16; break;
751 case 2: cdepth = 24; break;
752 case 3: cdepth = 32; break;
753 default: cdepth = 16;
754 }
755
756 // FIXME: WARNING! If OpenGL acceleration is not supported,
757 // this could lead to a crash!
758
759
760 // System
761 ev = bSpeedTest ? NULL : cOpt_System.Process();
762 cOpt_System.Draw(VideoPostProcessor::videoSurface());
763
764 if (Menu_OptionsProcessTopButtons(ev))
765 return;
766
767 if(ev) {
768
769 switch(ev->iControlID) {
770
771 // Apply
772 case os_Apply:
773 if(ev->iEventMsg == BTN_CLICKED) {
774
775 bool restart = (tLXOptions->bOpenGL != opengl) || (tLXOptions->iColourDepth != cdepth);
776
777 // Set to fullscreen / OpenGL / change colour depth
778 tLXOptions->bFullscreen = fullscr;
779 tLXOptions->bOpenGL = opengl;
780 tLXOptions->iColourDepth = cdepth;
781
782 PlaySoundSample(sfxGeneral.smpClick);
783
784 if(restart) {
785 // HINT: after changing ogl or bpp, if the user changes some other gfx setting like fullscreen, there are mess ups of course
786 // to workaround the problems, we simply restart the game here
787 tMenu->bMenuRunning = false; // quit
788 Menu_OptionsShutdown(); // cleanup for this menu
789 bRestartGameAfterQuit = true; // set restart-flag
790 startFunction = &Menu_StartWithSysOptionsMenu; // set function which loads this menu after start
791 return;
792
793 } else {
794 // Set the new video mode
795 doSetVideoModeInMainThread();
796
797 Menu_RedrawMouse(true);
798 EnableSystemMouseCursor(false);
799 }
800 }
801 break;
802
803 // Sound on/off
804 case os_SoundOn:
805 if(ev->iEventMsg == CHK_CHANGED) {
806
807 bool old = tLXOptions->bSoundOn;
808
809 c = (CCheckbox *)cOpt_System.getWidget(os_SoundOn);
810 tLXOptions->bSoundOn = c->getValue();
811
812 if(old != tLXOptions->bSoundOn) {
813 if(tLXOptions->bSoundOn)
814 StartSoundSystem();
815 else
816 StopSoundSystem();
817 }
818 }
819 break;
820
821 // Sound volume
822 case os_SoundVolume:
823 if(ev->iEventMsg == SLD_CHANGE) {
824 CSlider *s = (CSlider *)cOpt_System.getWidget(os_SoundVolume);
825 tLXOptions->iSoundVolume = s->getValue();
826
827 SetSoundVolume( tLXOptions->iSoundVolume );
828 }
829 break;
830
831 // Show FPS
832 case os_ShowFPS:
833 if(ev->iEventMsg == CHK_CHANGED)
834 tLXOptions->bShowFPS = cOpt_System.SendMessage(os_ShowFPS, CKM_GETCHECK, (DWORD)0, 0) != 0;
835 break;
836
837 // Logging
838 case os_LogConvos:
839 if(ev->iEventMsg == CHK_CHANGED) {
840 tLXOptions->bLogConvos = cOpt_System.SendMessage(os_LogConvos, CKM_GETCHECK, (DWORD)0, 0) != 0;
841 if (convoLogger) {
842 if (tLXOptions->bLogConvos)
843 convoLogger->startLogging();
844 else
845 convoLogger->endLogging();
846 }
847 }
848 break;
849
850 // Show ping
851 case os_ShowPing:
852 if(ev->iEventMsg == CHK_CHANGED)
853 tLXOptions->bShowPing = cOpt_System.SendMessage(os_ShowPing, CKM_GETCHECK, (DWORD)0, 0) != 0;
854 break;
855
856 // Use Ip To Country
857 case os_UseIpToCountry:
858 if(ev->iEventMsg == CHK_CHANGED) {
859 tLXOptions->bUseIpToCountry = cOpt_System.SendMessage(os_UseIpToCountry, CKM_GETCHECK, (DWORD)0, 0) != 0;
860 if (tLXOptions->bUseIpToCountry && !tIpToCountryDB->Loaded()) {
861 tIpToCountryDB->LoadDBFile(IP_TO_COUNTRY_FILE);
862 }
863 }
864 break;
865
866 case os_ShowCountryFlags:
867 if(ev->iEventMsg == CHK_CHANGED) {
868 tLXOptions->bShowCountryFlags = cOpt_System.SendMessage(os_ShowCountryFlags, CKM_GETCHECK, (DWORD)0, 0) != 0;
869 }
870 break;
871
872 // Test bandwidth
873 case os_TestBandwidth: {
874 if (ev->iEventMsg == BTN_CLICKED) {
875 bSpeedTest = true;
876 Menu_SpeedTest_Initialize();
877 }
878 } break;
879
880 case os_CheckForUpdates:
881 if(ev->iEventMsg == CHK_CHANGED) {
882 tLXOptions->bCheckForUpdates = cOpt_System.SendMessage(os_CheckForUpdates, CKM_GETCHECK, (DWORD)0, 0) != 0;
883 }
884 break;
885
886 case os_MaxFPS:
887 if(ev->iEventMsg == TXT_CHANGE) {
888 bool fail = false;
889 CTextbox *t = (CTextbox *)cOpt_System.getWidget(os_MaxFPS);
890 tLXOptions->nMaxFPS = from_string<int>(t->getText(), fail);
891 tLXOptions->nMaxFPS = fail ? 95 : MAX(5, tLXOptions->nMaxFPS);
892 //t->setText(itoa(tLXOptions->nMaxFPS));
893 }
894 break;
895 }
896 }
897
898
899 // Get the values
900 CTextbox *t = (CTextbox *)cOpt_System.getWidget(os_NetworkPort);
901 tLXOptions->iNetworkPort = atoi(t->getText());
902 t = (CTextbox *)cOpt_System.getWidget(os_HttpProxy);
903 tLXOptions->sHttpProxy = t->getText();
904
905 tLXOptions->iNetworkSpeed = cOpt_System.SendMessage(os_NetworkSpeed, CBM_GETCURINDEX,(DWORD)0,0);
906 tLXOptions->bCheckBandwidthSanity = cOpt_System.SendMessage(os_NetworkUploadCheck, CKM_GETCHECK, (DWORD)0, 0) != 0;
907
908 cOpt_System.getWidget( os_NetworkUploadBandwidth )->setEnabled( tLXOptions->iNetworkSpeed >= NST_LAN );
909 cOpt_System.getWidget( os_NetworkUploadBandwidthLabel )->setEnabled( tLXOptions->iNetworkSpeed >= NST_LAN );
910 cOpt_System.getWidget( os_TestBandwidth )->setEnabled( tLXOptions->iNetworkSpeed >= NST_LAN );
911 if( cOpt_System.getWidget( os_NetworkUploadBandwidth )->getEnabled() )
912 tLXOptions->iMaxUploadBandwidth = atoi( ((CTextbox *)cOpt_System.getWidget( os_NetworkUploadBandwidth ))->getText().c_str() );
913 if( tLXOptions->iMaxUploadBandwidth <= 0 )
914 tLXOptions->iMaxUploadBandwidth = 50000;
915
916 tLXOptions->iScreenshotFormat = cOpt_System.SendMessage(os_ScreenshotFormat, CBM_GETCURINDEX,(DWORD)0,0);
917
918 // FPS and fullscreen
919 t = (CTextbox *)cOpt_System.getWidget(os_MaxFPS);
920
921 if(cdepth != tLXOptions->iColourDepth || opengl != tLXOptions->bOpenGL || fullscr != tLXOptions->bFullscreen) {
922 cOpt_System.getWidget(os_Apply)->setEnabled(true);
923 cOpt_System.getWidget(os_Apply)->Draw( VideoPostProcessor::videoSurface() );
924 } else {
925 cOpt_System.getWidget(os_Apply)->setEnabled(false);
926 cOpt_System.getWidget(os_Apply)->redrawBuffer();
927 }
928 }
929
930 // Process the speed test window
931 if (bSpeedTest) {
932 if (Menu_SpeedTest_Frame()) {
933 // Finished
934 Menu_OptionsUpdateUpload(Menu_SpeedTest_GetSpeed());
935 Menu_SpeedTest_Shutdown();
936 bSpeedTest = false;
937 }
938 }
939
940
941 // Draw the mouse
942 DrawCursor(VideoPostProcessor::videoSurface());
943 }
944
Menu_FloatingOptionsFrame()945 void Menu_FloatingOptionsFrame()
946 {
947 static const int x = 30;
948 static const int y = 20;
949 static const int w = 565;
950 static const int h = 450;
951
952 // Redraw background image
953 DrawImageAdv(VideoPostProcessor::videoSurface(), tMenu->bmpMainBack_common, x, y, x, y, w, h);
954 Menu_DrawBox(VideoPostProcessor::videoSurface(), x, y, x + w, y + h);
955 Menu_DrawSubTitle(VideoPostProcessor::videoSurface(), SUB_OPTIONS);
956
957 Menu_OptionsFrame();
958 }
959
960 ///////////////////
961 // Process an input box waiting thing
962 // ply=-1 : general ; ply>=0 : normal player
Menu_OptionsWaitInput(int ply,const std::string & name,CInputbox * b)963 void Menu_OptionsWaitInput(int ply, const std::string& name, CInputbox *b)
964 {
965 keyboard_t *kb = GetKeyboard();
966 mouse_t *Mouse = GetMouse();
967
968 // Draw the back buffer
969 cOpt_Controls.Draw(tMenu->bmpBuffer.get());
970
971 Menu_DrawBox(tMenu->bmpBuffer.get(), 210, 170, 430, 310);
972 //DrawImageAdv(tMenu->bmpBuffer, tMenu->bmpMainBack, 212,172, 212,172, 217,137);
973 DrawRectFill(tMenu->bmpBuffer.get(), 212,172,429,309,tLX->clDialogBackground);
974
975 tLX->cFont.DrawCentre(tMenu->bmpBuffer.get(),320,180,Color(128,200,255),"Input for:");
976 tLX->cFont.DrawCentre(tMenu->bmpBuffer.get(),320,205,Color(255,255,255),name);
977
978 tLX->cFont.DrawCentre(tMenu->bmpBuffer.get(),320,270,Color(255,255,255),"Press any key/mouse");
979 tLX->cFont.DrawCentre(tMenu->bmpBuffer.get(),320,285,Color(128,128,128),"(Escape to cancel)");
980
981 Menu_RedrawMouse(true);
982
983 Mouse->Up = 0;
984 Mouse->Down = 0;
985
986 ProcessEvents();
987 SetGameCursor(CURSOR_ARROW);
988 CInput::InitJoysticksTemp();
989 ProcessEvents(); // drop all current events in queue
990 while(!tLX->bQuitGame) {
991 Menu_RedrawMouse(true);
992
993 DrawCursor(VideoPostProcessor::videoSurface());
994
995 // Escape quits the wait for user input
996 // TODO: make this event-based (don't check GetKeyboard() directly)
997 if(kb->KeyUp[SDLK_ESCAPE])
998 break;
999
1000 std::string tmp;
1001 if(CInput::Wait(tmp)) {
1002 b->setText(tmp);
1003 break;
1004 }
1005
1006 doVideoFrameInMainThread();
1007 CapFPS();
1008 WaitForNextEvent();
1009 }
1010 CInput::UnInitJoysticksTemp();
1011
1012 // Change the options
1013 if(ply >= 0) {
1014 tLXOptions->sPlayerControls[ply][b->getValue()] = b->getText();
1015 } else
1016 tLXOptions->sGeneralControls[b->getValue()] = b->getText();
1017
1018 // Disable quick weapon selection keys if they collide with other keys
1019 for( uint ply1 = 0; ply1 < tLXOptions->sPlayerControls.size(); ply1 ++ )
1020 {
1021 for( int key1 = SIN_WEAPON1; key1 <= SIN_WEAPON5; key1 ++ )
1022 {
1023 for( uint ply2 = 0; ply2 < tLXOptions->sPlayerControls.size(); ply2 ++ )
1024 for( int key2 = SIN_UP; key2 < SIN_WEAPON1; key2 ++ )
1025 if( tLXOptions->sPlayerControls[ply1][key1] ==
1026 tLXOptions->sPlayerControls[ply2][key2] )
1027 tLXOptions->sPlayerControls[ply1][key1] = "";
1028
1029 for( int key2 = SIN_CHAT; key2 < __SIN_GENERAL_BOTTOM; key2 ++ )
1030 if( tLXOptions->sPlayerControls[ply1][key1] ==
1031 tLXOptions->sGeneralControls[key2] )
1032 tLXOptions->sPlayerControls[ply1][key1] = "";
1033 }
1034 }
1035
1036
1037 Mouse->Down = 0;
1038 Mouse->Up = 0;
1039
1040 DrawImage(tMenu->bmpBuffer.get(),tMenu->bmpMainBack_common,0,0);
1041 if (tMenu->tFrontendInfo.bPageBoxes)
1042 Menu_DrawBox(tMenu->bmpBuffer.get(), 15,130, 625, 465);
1043 if (!bShowFloatingOptions)
1044 Menu_DrawSubTitle(tMenu->bmpBuffer.get(),SUB_OPTIONS);
1045
1046 Menu_RedrawMouse(true);
1047 }
1048
Menu_FloatingOptionsWaitInput(int ply,const std::string & name,CInputbox * b)1049 void Menu_FloatingOptionsWaitInput(int ply, const std::string& name, CInputbox *b)
1050 {
1051 DrawImage(tMenu->bmpBuffer.get(), VideoPostProcessor::videoSurface(), 0, 0);
1052 Menu_OptionsWaitInput(ply, name, b);
1053 Menu_redrawBufferRect(0, 0, VideoPostProcessor::get()->screenWidth(), VideoPostProcessor::get()->screenHeight());
1054 }
1055
1056 ///////////////////
1057 // Shutdown the options menu
Menu_OptionsShutdown()1058 void Menu_OptionsShutdown()
1059 {
1060 cOpt_Controls.Shutdown();
1061 cOpt_System.Shutdown();
1062 cOpt_Game.Shutdown();
1063
1064 if (bSpeedTest)
1065 Menu_SpeedTest_Shutdown();
1066 }
1067
Menu_FloatingOptionsShutdown()1068 void Menu_FloatingOptionsShutdown()
1069 {
1070 Menu_OptionsShutdown();
1071 bShowFloatingOptions = false;
1072 }
1073
1074 }; // namespace DeprecatedGUI
1075