1 /*
2
3 *************************************************************************
4
5 ArmageTron -- Just another Tron Lightcycle Game in 3D.
6 Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
7
8 **************************************************************************
9
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 ***************************************************************************
25
26 */
27
28 #include "gMenus.h"
29 #include "ePlayer.h"
30 #include "rScreen.h"
31 #include "nConfig.h"
32 #include "rConsole.h"
33 #include "tToDo.h"
34 #include "rGL.h"
35 #include "eTimer.h"
36 #include "eFloor.h"
37 #include "rRender.h"
38 #include "rModel.h"
39 #include "gGame.h"
40 #include "gCycle.h"
41 #include "gHud.h"
42 #include "tRecorder.h"
43 #include "rSysdep.h"
44
45 #include <sstream>
46 #include <set>
47
48 static tConfItem<int> tm0("TEXTURE_MODE_0",rTextureGroups::TextureMode[0]);
49 static tConfItem<int> tm1("TEXTURE_MODE_1",rTextureGroups::TextureMode[1]);
50 static tConfItem<int> tm2("TEXTURE_MODE_2",rTextureGroups::TextureMode[2]);
51 static tConfItem<int> tm3("TEXTURE_MODE_3",rTextureGroups::TextureMode[3]);
52
53 uMenu sg_screenMenu("$display_settings_menu");
54
55 static uMenuItemFunction defaul
56 (&sg_screenMenu,"$graphics_load_defaults_text",
57 "$graphics_load_defaults_help",
58 &sr_LoadDefaultConfig);
59 uMenu screen_menu_detail("$detail_settings_menu");
60 uMenu screen_menu_tweaks("$performance_tweaks_menu");
61 uMenu screen_menu_prefs("$preferences_menu");
62 uMenu hud_prefs("$hud_menu");
63
64 static void sg_ScreenModeMenu();
65
66 static uMenuItemSubmenu smt(&sg_screenMenu,&screen_menu_tweaks,
67 "$performance_tweaks_menu_help");
68 static uMenuItemSubmenu smd(&sg_screenMenu,&screen_menu_detail,
69 "$detail_settings_menu_help");
70 static uMenuItemSubmenu smp(&sg_screenMenu,&screen_menu_prefs,
71 "$preferences_menu_help");
72 static uMenuItemFunction smm(&sg_screenMenu,"$screen_mode_menu",
73 "$screen_mode_menu_help", sg_ScreenModeMenu );
74
75 static uMenuItemSubmenu huds(&screen_menu_prefs,&hud_prefs,
76 "$hud_menu_help");
77
78
79 static tConfItemLine c_ext("GL_EXTENSIONS",gl_extensions);
80 static tConfItemLine c_ver("GL_VERSION",gl_version);
81 static tConfItemLine c_rEnd("GL_RENDERER",gl_renderer);
82 static tConfItemLine c_vEnd("GL_VENDOR",gl_vendor);
83 // static tConfItemLine a_ver("ARMAGETRON_VERSION",sn_programVersion);
84
85 static std::deque<tString> sg_consoleHistory; // global since the class doesn't live beyond the execution of the command
86 static int sg_consoleHistoryMaxSize=10; // size of the console history
87 static tSettingItem< int > sg_consoleHistoryMaxSizeConf("HISTORY_SIZE_CONSOLE",sg_consoleHistoryMaxSize);
88
89 class ArmageTron_feature_menuitem: public uMenuItemSelection<int>{
NewChoice(uSelectItem<bool> *)90 void NewChoice(uSelectItem<bool> *){}
NewChoice(char *,bool)91 void NewChoice(char *,bool ){}
92 public:
ArmageTron_feature_menuitem(uMenu * m,char const * tit,char const * help,int & targ)93 ArmageTron_feature_menuitem(uMenu *m,char const * tit,char const * help,int &targ)
94 :uMenuItemSelection<int>(m,tit,help,targ){
95 uMenuItemSelection<int>::NewChoice(
96 "$feature_disabled_text",
97 "$feature_disabled_help",
98 rFEAT_OFF);
99 uMenuItemSelection<int>::NewChoice(
100 "$feature_default_text",
101 "$feature_default_help",
102 rFEAT_DEFAULT);
103 uMenuItemSelection<int>::NewChoice(
104 "$feature_enabled_text",
105 "$feature_enabled_help",
106 rFEAT_ON);
107 }
108
~ArmageTron_feature_menuitem()109 ~ArmageTron_feature_menuitem(){}
110 };
111
112
113 class ArmageTron_texmode_menuitem: public uMenuItemSelection<int>{
NewChoice(uSelectItem<bool> *)114 void NewChoice(uSelectItem<bool> *){}
NewChoice(char *,bool)115 void NewChoice(char *,bool ){}
116 public:
ArmageTron_texmode_menuitem(uMenu * m,char const * tit,int & targ,bool font=false)117 ArmageTron_texmode_menuitem(uMenu *m,char const * tit,int &targ,
118 bool font=false)
119 :uMenuItemSelection<int>
120 (m,tit,"$texture_menuitem_help",targ){
121
122 if(!font)
123 uMenuItemSelection<int>::NewChoice
124 ("$texture_off_text","$texture_off_help",-1);
125 #ifndef DEDICATED
126 uMenuItemSelection<int>::NewChoice
127 ("$texture_nearest_text","$texture_nearest_help",GL_NEAREST);
128
129 uMenuItemSelection<int>::NewChoice
130 ("$texture_bilinear_text","$texture_bilinear_help",GL_LINEAR);
131
132 if(!font)
133 {
134 uMenuItemSelection<int>::NewChoice
135 ("$texture_mipmap_nearest_text",
136 "$texture_mipmap_nearest_help",
137 GL_NEAREST_MIPMAP_NEAREST);
138 uMenuItemSelection<int>::NewChoice
139 ("$texture_mipmap_bilinear_text",
140 "$texture_mipmap_bilinear_help",
141 GL_LINEAR_MIPMAP_NEAREST);
142 uMenuItemSelection<int>::NewChoice
143 ("$texture_mipmap_trilinear_text",
144 "$texture_mipmap_trilinear_help",
145 GL_LINEAR_MIPMAP_LINEAR);
146 }
147 #endif
148 }
149
~ArmageTron_texmode_menuitem()150 ~ArmageTron_texmode_menuitem(){}
151 };
152
153 static tConfItem<bool> ab("ALPHA_BLEND",sr_alphaBlend);
154 static tConfItem<bool> ss("SMOOTH_SHADING",sr_smoothShading);
155 static tConfItem<bool> to("TEXT_OUT",sr_textOut);
156 static tConfItem<bool> fps("SHOW_FPS",sr_FPSOut);
157 // tConfItem<> ("",&);
158 static tConfItem<int> fm("FLOOR_MIRROR",sr_floorMirror);
159 static tConfItem<int> fd("FLOOR_DETAIL",sr_floorDetail);
160 static tConfItem<bool> hr("HIGH_RIM",sr_highRim);
161 static tConfItem<bool> dt("DITHER",sr_dither);
162 static tConfItem<bool> us("UPPER_SKY",sr_upperSky);
163 static tConfItem<bool> ls("LOWER_SKY",sr_lowerSky);
164 static tConfItem<bool> wos("SKY_WOBBLE",sr_skyWobble);
165 static tConfItem<bool> ip("INFINITY_PLANE",sr_infinityPlane);
166
167 extern bool sg_axesIndicator;
168
169 static tConfItem<bool> lm("LAG_O_METER",sr_laggometer);
170 static tConfItem<bool> ai("AXES_INDICATOR",sg_axesIndicator);
171 static tConfItem<bool> po("PREDICT_OBJECTS",sr_predictObjects);
172 static tConfItem<bool> t32("TEXTURES_HI",sr_texturesTruecolor);
173
174 static tConfItem<bool> kwa("KEEP_WINDOW_ACTIVE",sr_keepWindowActive);
175 #ifdef USE_HEADLIGHT
176 static tConfItem<bool> chl("HEADLIGHT",headlights);
177 #endif
178
179 #ifndef SDL_OPENGL
180 #ifndef DIRTY
181 #define DIRTY
182 #endif
183 #endif
184
operator <(rScreenSize const & a,rScreenSize const & b)185 bool operator < ( rScreenSize const & a, rScreenSize const & b )
186 {
187 return a.Compare(b) < 0;
188 }
189
190 class gResMenEntry
191 {
192 uMenuItemSelection<rScreenSize> res_men; // menu item
193 std::set< rScreenSize > sizes; // set of already added modes
194
195 // adds a single custom screen resolution
NewChoice(rScreenSize const & size)196 void NewChoice( rScreenSize const & size )
197 {
198 if ( sizes.find( size ) == sizes.end() )
199 {
200 sizes.insert(size);
201 }
202 }
203
204 // adds a single predefined resolution
NewChoice(rResolution res)205 void NewChoice( rResolution res )
206 {
207 rScreenSize size( res );
208 NewChoice( size );
209 }
210
211 public:
gResMenEntry(uMenu & screen_menu_mode,rScreenSize & res,const tOutput & text,const tOutput & help,bool addFixed)212 gResMenEntry( uMenu & screen_menu_mode, rScreenSize& res, const tOutput& text, const tOutput& help, bool addFixed )
213 :res_men
214 (&screen_menu_mode,
215 text,
216 help,
217 res)
218 {
219 #ifndef DEDICATED
220 // fetch valid screen modes from SDL
221 SDL_Rect **modes;
222 modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
223
224 // Check is there are any modes available
225 int i;
226 if(modes == 0 || modes == (SDL_Rect **)-1)
227 {
228 // add all fixed resolutions
229 for ( i = ArmageTron_Custom; i>=0; --i )
230 {
231 NewChoice( rResolution(i) );
232 }
233 }
234 else
235 {
236 // add custom resolution
237 NewChoice( ArmageTron_Custom );
238
239 // add desktop resolution
240 if ( sr_DesktopScreensizeSupported() && !addFixed )
241 NewChoice( ArmageTron_Desktop );
242
243 // the maximal allowed screen size
244 rScreenSize maxSize(0,0);
245
246 // fill in available modes (avoid duplicates)
247 for(i=0;modes[i];++i)
248 {
249 // add mode (if it's new)
250 rScreenSize size(modes[i]->w, modes[i]->h);
251 NewChoice( size );
252 if ( maxSize.width < size.width )
253 maxSize.width = size.width;
254 if ( maxSize.height < size.height )
255 maxSize.height = size.height;
256 }
257
258 // add fixed resolutions (as window sizes)
259 if ( addFixed )
260 {
261 for ( i = ArmageTron_Custom; i>=ArmageTron_Min; --i )
262 {
263 rScreenSize size( static_cast< rResolution >(i) );
264
265 // only add those that fit the maximal resolution
266 if ( maxSize.height >= size.height && maxSize.width >= size.width )
267 NewChoice( size );
268 }
269 }
270 }
271
272 // insert sorted resolutions into menu
273 for( std::set< rScreenSize >::iterator iter = sizes.begin(); iter != sizes.end(); ++iter )
274 {
275 rScreenSize const & size = *iter;
276
277 std::stringstream s;
278 if ( size.width + size.height > 0 )
279 s << size.width << " x " << size.height;
280 else
281 s << tOutput("$screen_size_desktop");
282
283 res_men.NewChoice( s.str().c_str(), help, size );
284 }
285
286 #endif
287 }
288 };
289
sg_ScreenModeMenu()290 static void sg_ScreenModeMenu()
291 {
292 uMenu screen_menu_mode("$screen_mode_menu");
293
294 uMenuItemFunction appl
295 (&screen_menu_mode,
296 "$screen_apply_changes_text",
297 "$screen_apply_changes_help",
298 &sr_ReinitDisplay);
299
300 uMenuItemToggle kwa_t(
301 &screen_menu_mode,
302 "$screen_keep_window_active_text",
303 "$screen_keep_window_active_help",
304 sr_keepWindowActive);
305
306 uMenuItemToggle ie_t
307 (&screen_menu_mode,
308 "$screen_check_errors_text",
309 "$screen_check_errors_help",
310 currentScreensetting.checkErrors);
311
312
313 #ifdef SDL_OPENGL
314 #ifdef DIRTY
315 uMenuItemToggle sdl_t
316 (&screen_menu_mode,
317 "$screen_use_sdl_text",
318 "$screen_use_sdl_help",
319 currentScreensetting.useSDL);
320 #endif
321 #endif
322
323 uMenuItemToggle gm(
324 &screen_menu_mode,
325 "$screen_grab_mouse_text",
326 "$screen_grab_mouse_help",
327 su_mouseGrab);
328
329 uMenuItemSelection<rColorDepth> zd_t
330 (&screen_menu_mode,
331 "$screen_zdepth_text",
332 "$screen_zdepth_help",
333 currentScreensetting.zDepth);
334
335 uSelectEntry<rColorDepth> zd_16(zd_t,"$screen_zdepth_16_text","$screen_zdepth_16_help",ArmageTron_ColorDepth_16);
336 uSelectEntry<rColorDepth> zd_d(zd_t,"$screen_zdepth_desk_text","$screen_zdepth_desk_help",ArmageTron_ColorDepth_Desktop);
337 uSelectEntry<rColorDepth> zd_32(zd_t,"$screen_zdepth_32_text","$screen_zdepth_32_help",ArmageTron_ColorDepth_32);
338
339 uMenuItemSelection<rColorDepth> cd_t
340 (&screen_menu_mode,
341 "$screen_colordepth_text",
342 "$screen_colordepth_help",
343 currentScreensetting.colorDepth);
344
345 uSelectEntry<rColorDepth> cd_16(cd_t,"$screen_colordepth_16_text","$screen_colordepth_16_help",ArmageTron_ColorDepth_16);
346 uSelectEntry<rColorDepth> cd_d(cd_t,"$screen_colordepth_desk_text","$screen_colordepth_desk_help",ArmageTron_ColorDepth_Desktop);
347 uSelectEntry<rColorDepth> cd_32(cd_t,"$screen_colordepth_32_text","$screen_colordepth_32_help",ArmageTron_ColorDepth_32);
348
349 uMenuItemToggle fs_t
350 (&screen_menu_mode,
351 "$screen_fullscreen_text",
352 "$screen_fullscreen_help",
353 currentScreensetting.fullscreen);
354
355
356 gResMenEntry res( screen_menu_mode, currentScreensetting.res, "$screen_resolution_text", "$screen_resolution_help", false );
357 gResMenEntry winsize( screen_menu_mode, currentScreensetting.windowSize, "$window_size_text", "$window_size_help", true );
358
359 /*
360 uMenuItemSelection<rResolution> res_men
361 (&screen_menu_mode,
362 "$screen_resolution_text",
363 "$screen_resolution_help",
364 currentScreensetting.res);
365
366
367 uSelectEntry<rResolution> a(res_men,"320x200","",ArmageTron_320_200);
368 static uSelectEntry<rResolution> b(res_men,"320x240","",ArmageTron_320_240);
369 static uSelectEntry<rResolution> c(res_men,"400x300","",ArmageTron_400_300);
370 static uSelectEntry<rResolution> d(res_men,"512x384","",ArmageTron_512_384);
371 static uSelectEntry<rResolution> e(res_men,"640x480","",ArmageTron_640_480);
372 static uSelectEntry<rResolution> f(res_men,"800x600","",ArmageTron_800_600);
373 static uSelectEntry<rResolution> g(res_men,"1024x768","",ArmageTron_1024_768);
374 static uSelectEntry<rResolution> h(res_men,"1280x1024","",ArmageTron_1280_1024);
375 static uSelectEntry<rResolution> i(res_men,"1600x1200","",ArmageTron_1600_1200);
376 static uSelectEntry<rResolution> j(res_men,"2048x1572","",ArmageTron_2048_1572);
377 static uSelectEntry<rResolution> jj(res_men,
378 "$screen_custom_text",
379 "$screen_custom_help"
380 ,ArmageTron_Custom);
381 */
382
383 screen_menu_mode.Enter();
384 }
385
386
387 static uMenuItemSelection<int> mfm
388 (&screen_menu_detail,
389 "$detail_floor_mirror_text",
390 "$detail_floor_mirror_help",
391 sr_floorMirror);
392 static uSelectEntry<int> mfma(mfm,"$detail_floor_mirror_off_text","$detail_floor_mirror_off_help",rMIRROR_OFF);
393
394
395 static uSelectEntry<int> mfmb(mfm,"$detail_floor_mirror_obj_text",
396 "$detail_floor_mirror_obj_help",
397 rMIRROR_OBJECTS);
398
399 static uSelectEntry<int> mfmc(mfm,"$detail_floor_mirror_ow_text",
400 "$detail_floor_mirror_ow_help",
401 rMIRROR_WALLS);
402
403 static uSelectEntry<int> mfme(mfm,"$detail_floor_mirror_ev_text","$detail_floor_mirror_ev_help",rMIRROR_ALL);
404
405 static uMenuItemToggle fs_dither
406 (&screen_menu_detail,"$detail_dither_text",
407 "$detail_dither_help",
408 sr_dither);
409
410 static uMenuItemSelection<int> mfd
411 (&screen_menu_detail,
412 "$detail_floor_text",
413 "$detail_floor_help",
414 sr_floorDetail);
415
416 static uSelectEntry<int> mfda(mfd,"$detail_floor_no_text",
417 "$detail_floor_no_help",
418 rFLOOR_OFF);
419 static uSelectEntry<int> mfdb(mfd,"$detail_floor_grid_text",
420 "$detail_floor_grid_help",
421 rFLOOR_GRID);
422 static uSelectEntry<int> mfdc(mfd,"$detail_floor_tex_text",
423 "$detail_floor_tex_help",
424 rFLOOR_TEXTURE);
425 static uSelectEntry<int> mfdd(mfd,"$detail_floor_2tex_text",
426 "$detail_floor_2tex_help",
427 rFLOOR_TWOTEXTURE);
428
429 static uMenuItemToggle abm
430 (&screen_menu_detail,"$detail_alpha_text",
431 "$detail_alpha_help",
432 sr_alphaBlend);
433
434 static uMenuItemToggle ssm
435 (&screen_menu_detail,"$detail_smooth_text",
436 "$detail_smooth_help",
437 sr_smoothShading);
438
439 extern bool crash_sparks; // from gCycle.cpp
440 extern bool white_sparks; // from gSparks.cpp
441 static tConfItem<bool> cs2("SPARKS",crash_sparks);
442 static tConfItem<bool> wsp("WHITE_SPARKS",white_sparks);
443
444 extern bool sg_crashExplosion; // from gExplosion.cpp
445 static tConfItem<bool> crexp("EXPLOSION",sg_crashExplosion);
446
447 #ifndef DEDICATED
448 //extern bool png_screenshot; // from rSysdep.cpp
449 //static tConfItem<bool> pns("PNG_SCREENSHOT",png_screenshot);
450 #endif
451
452 static uMenuItemToggle t32b
453 (&screen_menu_detail,"$detail_text_truecolor_text",
454 "$detail_text_truecolor_help"
455 ,sr_texturesTruecolor);
456
457
458 static ArmageTron_texmode_menuitem tmm0(&screen_menu_detail,
459 rTextureGroups::TextureGroupDescription[0],
460 rTextureGroups::TextureMode[0]);
461
462 static ArmageTron_texmode_menuitem tmm1(&screen_menu_detail,
463 rTextureGroups::TextureGroupDescription[1],
464 rTextureGroups::TextureMode[1]);
465
466 static ArmageTron_texmode_menuitem tmm2(&screen_menu_detail,
467 rTextureGroups::TextureGroupDescription[2],
468 rTextureGroups::TextureMode[2]);
469
470 static ArmageTron_texmode_menuitem tmm3(&screen_menu_detail,
471 rTextureGroups::TextureGroupDescription[3],
472 rTextureGroups::TextureMode[3],true);
473
474
475 static uMenuItemToggle s2
476 (&screen_menu_prefs,"$pref_highrim_text",
477 "$pref_highrim_help",sr_highRim);
478
479 static uMenuItemToggle us2
480 (&screen_menu_prefs,"$pref_uppersky_text",
481 "$pref_uppersky_help",
482 sr_upperSky);
483
484 static uMenuItemToggle ls2
485 (&screen_menu_prefs,"$pref_lowersky_text",
486 "$pref_lowersky_help",
487 sr_lowerSky);
488
489 uMenuItemToggle fps2
490 (&screen_menu_prefs,"$misc_fps_text",
491 "$misc_fps_help",sr_FPSOut);
492
493 #ifdef USE_HEADLIGHT
494 static uMenuItemToggle uchl(&screen_menu_prefs,"$pref_headlight_text","$pref_headlight_help",
495 headlights);
496 #endif
497
498
499 static uMenuItemToggle ws2
500 (&screen_menu_prefs,"$pref_skymove_text",
501 "$pref_skymove_help",
502 sr_skyWobble);
503
504 static uMenuItemToggle crexp2
505 (&screen_menu_prefs,"$pref_explosion_text",
506 "$pref_explosion_help",
507 sg_crashExplosion);
508
509 static uMenuItemToggle cs
510 (&screen_menu_prefs,"$pref_sparks_text",
511 "$pref_sparks_help",
512 crash_sparks);
513
514 static uMenuItemSelection<rDisplayListUsage> dl
515 (&screen_menu_tweaks,"$tweaks_displaylists_text",
516 "$tweaks_displaylists_help", sr_useDisplayLists);
517 static uSelectEntry<rDisplayListUsage> dl_off(dl,"$tweaks_displaylists_off_text","$tweaks_displaylists_off_help",rDisplayList_Off);
518 static uSelectEntry<rDisplayListUsage> dl_cac(dl,"$tweaks_displaylists_cac_text","$tweaks_displaylists_cac_help",rDisplayList_CAC);
519 static uSelectEntry<rDisplayListUsage> dl_cae(dl,"$tweaks_displaylists_cae_text","$tweaks_displaylists_cae_help",rDisplayList_CAE);
520
521 static uMenuItemToggle infp
522 (&screen_menu_tweaks,"$tweaks_infinity_text",
523 "$tweaks_infinity_help"
524 ,sr_infinityPlane);
525
526 uMenuItemSelection<rSysDep::rSwapMode> swapMode
527 (&screen_menu_tweaks,
528 "$swapmode_text",
529 "$swapmode_help",
530 rSysDep::swapMode_);
531
532 static uSelectEntry<rSysDep::rSwapMode> swapMode_fastest(swapMode,"$swapmode_fastest_text","$swapmode_fastest_help",rSysDep::rSwap_Fastest);
533 static uSelectEntry<rSysDep::rSwapMode> swapMode_glFlush(swapMode,"$swapmode_glflush_text","$swapmode_glflush_help",rSysDep::rSwap_glFlush);
534 static uSelectEntry<rSysDep::rSwapMode> swapMode_glFinish(swapMode,"$swapmode_glfinish_text","$swapmode_glfinish_help",rSysDep::rSwap_glFinish);
535
536 /*
537 uMenuItemSelection<int> targetFPS
538 (&screen_menu_tweaks,
539 "$targetfps_text",
540 "$targetfps_help",
541 rSysDep::swapMode_);
542
543 static uSelectEntry<rSysDep::rSwapMode> swapMode_150Hz(swapMode,"$swapmode_150hz_text","$swapmode_150hz_help",rSysDep::rSwap_150Hz);
544 static uSelectEntry<rSysDep::rSwapMode> swapMode_100Hz(swapMode,"$swapmode_100hz_text","$swapmode_100hz_help",rSysDep::rSwap_100Hz);
545 static uSelectEntry<rSysDep::rSwapMode> swapMode_80Hz(swapMode,"$swapmode_80hz_text","$swapmode_80hz_help",rSysDep::rSwap_80Hz);
546 static uSelectEntry<rSysDep::rSwapMode> swapMode_60Hz(swapMode,"$swapmode_60hz_text","$swapmode_60hz_help",rSysDep::rSwap_60Hz);
547 */
548
549 tCONFIG_ENUM( rSysDep::rSwapMode );
550
551 static tConfItem< rSysDep::rSwapMode > swapModeCI("SWAP_MODE", rSysDep::swapMode_ );
552
553 static tConfItem<REAL> sgs("SPEED_GAUGE_SIZE",subby_SpeedGaugeSize);
554 static tConfItem<REAL> sgx("SPEED_GAUGE_LOCX",subby_SpeedGaugeLocX);
555 static tConfItem<REAL> sgy("SPEED_GAUGE_LOCY",subby_SpeedGaugeLocY);
556
557 static tConfItem<REAL> bgs("BRAKE_GAUGE_SIZE",subby_BrakeGaugeSize);
558 static tConfItem<REAL> bgx("BRAKE_GAUGE_LOCX",subby_BrakeGaugeLocX);
559 static tConfItem<REAL> bgy("BRAKE_GAUGE_LOCY",subby_BrakeGaugeLocY);
560
561 static tConfItem<REAL> rgs("RUBBER_GAUGE_SIZE",subby_RubberGaugeSize);
562 static tConfItem<REAL> rgx("RUBBER_GAUGE_LOCX",subby_RubberGaugeLocX);
563 static tConfItem<REAL> rgy("RUBBER_GAUGE_LOCY",subby_RubberGaugeLocY);
564
565 static tConfItem<bool> showh("SHOW_HUD",subby_ShowHUD);
566 static tConfItem<bool> showf("SHOW_FASTEST",subby_ShowSpeedFastest);
567 static tConfItem<bool> shows("SHOW_SCORE",subby_ShowScore);
568 static tConfItem<bool> showae("SHOW_ALIVE",subby_ShowAlivePeople);
569 static tConfItem<bool> showp("SHOW_PING",subby_ShowPing);
570 static tConfItem<bool> showsm("SHOW_SPEED",subby_ShowSpeedMeter);
571 static tConfItem<bool> showbm("SHOW_BRAKE",subby_ShowBrakeMeter);
572 static tConfItem<bool> showrm("SHOW_RUBBER",subby_ShowRubberMeter);
573 static tConfItem<bool> showtim("SHOW_TIME",showTime);
574 static tConfItem<bool> show24("SHOW_TIME_24",show24hour);
575
576 static tConfItem<REAL> scorex("SCORE_LOCX",subby_ScoreLocX);
577 static tConfItem<REAL> scorey("SCORE_LOCY",subby_ScoreLocY);
578 static tConfItem<REAL> scores("SCORE_SIZE",subby_ScoreSize);
579
580 static tConfItem<REAL> fastx("FASTEST_LOCX",subby_FastestLocX);
581 static tConfItem<REAL> fasty("FASTEST_LOCY",subby_FastestLocY);
582 static tConfItem<REAL> fasts("FASTEST_SIZE",subby_FastestSize);
583
584 static tConfItem<REAL> aex("ALIVE_LOCX",subby_AlivePeopleLocX);
585 static tConfItem<REAL> aey("ALIVE_LOCY",subby_AlivePeopleLocY);
586 static tConfItem<REAL> aes("ALIVE_SIZE",subby_AlivePeopleSize);
587
588 static tConfItem<REAL> px("PING_LOCX",subby_PingLocX);
589 static tConfItem<REAL> py("PING_LOCY",subby_PingLocY);
590 static tConfItem<REAL> ps("PING_SIZE",subby_PingSize);
591
592 uMenuItemToggle hud3
593 (&hud_prefs,"$pref_showfastest_text",
594 "$pref_showfastest_help",subby_ShowSpeedFastest);
595
596 uMenuItemToggle mud4
597 (&hud_prefs,"$pref_showscore_text",
598 "$pref_showscore_help",subby_ShowScore);
599
600 uMenuItemToggle hud5
601 (&hud_prefs,"$pref_showenemies_text",
602 "$pref_showenemies_help",subby_ShowAlivePeople);
603
604 uMenuItemToggle hud6
605 (&hud_prefs,"$pref_showping_text",
606 "$pref_showping_help",subby_ShowPing);
607
608 uMenuItemToggle hud7
609 (&hud_prefs,"$pref_showspeed_text",
610 "$pref_showspeed_help",subby_ShowSpeedMeter);
611
612 uMenuItemToggle hud8
613 (&hud_prefs,"$pref_showbrake_text",
614 "$pref_showbrake_help",subby_ShowBrakeMeter);
615
616 uMenuItemToggle hud9
617 (&hud_prefs,"$pref_showrubber_text",
618 "$pref_showrubber_help",subby_ShowRubberMeter);
619
620 uMenuItemToggle hud10
621 (&hud_prefs,"$pref_showtime_text",
622 "$pref_showtime_help",showTime);
623
624 uMenuItemToggle hud11
625 (&hud_prefs,"$pref_show24hour_text",
626 "$pref_show24hour_help",show24hour);
627
628 uMenuItemToggle hud2
629 (&hud_prefs,"$pref_showhud_text",
630 "$pref_showhud_help",subby_ShowHUD);
631
632
633
634 static tConfItem<bool> WRAP("WRAP_MENU",uMenu::wrap);
635
636
637
638 #ifndef DEDICATED
639
640 class gMemuItemConsole: uMenuItemStringWithHistory{
641 public:
gMemuItemConsole(uMenu * M,tString & c)642 gMemuItemConsole(uMenu *M,tString &c):
643 uMenuItemStringWithHistory(M,"Con:","", c, 1024, sg_consoleHistory, sg_consoleHistoryMaxSize) {}
644
~gMemuItemConsole()645 virtual ~gMemuItemConsole(){}
646
647 //virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0);
648
Event(SDL_Event & e)649 virtual bool Event(SDL_Event &e){
650 if (e.type==SDL_KEYDOWN &&
651 (e.key.keysym.sym==SDLK_KP_ENTER || e.key.keysym.sym==SDLK_RETURN)){
652
653 con << tColoredString::ColorString(.5,.5,1) << " > " << *content << '\n';
654
655 // direct commands are executed at owner level
656 tCurrentAccessLevel level( tAccessLevel_Owner, true );
657
658 // pass the console command to the configuration system
659 std::stringstream s(&((*content)[0]));
660 tConfItemBase::LoadAll( s, false );
661
662 MyMenu()->Exit();
663 return true;
664 }
665 else if (e.type==SDL_KEYDOWN &&
666 uActionGlobal::IsBreakingGlobalBind(e.key.keysym.sym))
667 return su_HandleEvent(e, true);
668 else
669 return uMenuItemStringWithHistory::Event(e);
670 }
671 };
672
do_con()673 void do_con(){
674 se_ChatState( ePlayerNetID::ChatFlags_Console, true );
675 sr_con.SetHeight(20,false);
676 se_SetShowScoresAuto(false);
677 tString c;
678
679 uMenu con_menu("",false);
680 gMemuItemConsole s(&con_menu,c);
681 con_menu.SetCenter(-.75);
682 con_menu.SetBot(-2);
683 con_menu.SetTop(-.7);
684 con_menu.Enter();
685
686 se_ChatState( ePlayerNetID::ChatFlags_Console, false );
687
688 se_SetShowScoresAuto(true);
689 sr_con.SetHeight(7,false);
690 }
691 #endif
692
sg_ConsoleInput()693 void sg_ConsoleInput(){
694 #ifndef DEDICATED
695 st_ToDo(&do_con);
696 #endif
697 }
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713 class ArmageTron_viewport_menuitem:public uMenuItemInt{
714 public:
ArmageTron_viewport_menuitem(uMenu * m)715 ArmageTron_viewport_menuitem(uMenu *m):
716 uMenuItemInt(m,"$viewport_menu_title",
717 "$viewport_menu_help",
718 rViewportConfiguration::next_conf_num,
719 0,rViewportConfiguration::s_viewportNumConfigurations-1){
720 m->RequestSpaceBelow(.9);
721 }
722
SpaceRight()723 virtual REAL SpaceRight(){return 1;}
724
RenderBackground()725 virtual void RenderBackground(){
726 uMenuItem::RenderBackground();
727
728 if (rViewportConfiguration::next_conf_num<0) rViewportConfiguration::next_conf_num=0;
729 if (rViewportConfiguration::next_conf_num>=rViewportConfiguration::s_viewportNumConfigurations)
730 rViewportConfiguration::next_conf_num=rViewportConfiguration::s_viewportNumConfigurations-1;
731
732 tString titles[MAX_VIEWPORTS];
733
734 for(int i=MAX_VIEWPORTS-1;i>=0;i--)
735 titles[i] << i+1;
736 #ifndef DEDICATED
737 rViewportConfiguration::DemonstrateViewport(titles);
738 #endif
739 }
740
Render(REAL x,REAL y,REAL alpha=1,bool selected=0)741 virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0){
742 if (rViewportConfiguration::next_conf_num<0) rViewportConfiguration::next_conf_num=0;
743 if (rViewportConfiguration::next_conf_num>=rViewportConfiguration::s_viewportNumConfigurations)
744 rViewportConfiguration::next_conf_num=rViewportConfiguration::s_viewportNumConfigurations-1;
745
746 tOutput disp;
747
748 disp << "$viewport_conf_text";
749 disp.AddSpace();
750 disp << rViewportConfiguration::s_viewportConfigurationNames[rViewportConfiguration::next_conf_num];
751 DisplayText(x-.02,y,disp,selected,alpha);
752 }
753
754 };
755
756
757
758 class ArmageTronPlayer_to_viewport_menuitem:public uMenuItemInt{
759 int vp;
760 public:
ArmageTronPlayer_to_viewport_menuitem(uMenu * m,int v)761 ArmageTronPlayer_to_viewport_menuitem(uMenu *m,int v):
762 uMenuItemInt(m,"",
763 "$viewport_assign_help",
764 s_newViewportBelongsToPlayer[v],
765 0,MAX_PLAYERS-1),vp(v){
766 m->RequestSpaceBelow(.9);
767 }
768
SpaceRight()769 virtual REAL SpaceRight(){return 1;}
770
LeftRight(int x)771 virtual void LeftRight(int x){
772 rViewport::SetDirectionOfCorrection(vp,x);
773 target=(target + MAX_PLAYERS + x) % MAX_PLAYERS;
774 }
775
RenderBackground()776 virtual void RenderBackground(){
777 rViewport::CorrectViewport(vp, MAX_PLAYERS);
778
779 uMenuItem::RenderBackground();
780
781 tString titles[MAX_VIEWPORTS];
782 for(int i=MAX_VIEWPORTS-1;i>=0;i--){
783 titles[i] << s_newViewportBelongsToPlayer[i]+1;
784 titles[i] << " (";
785 titles[i] << ePlayer::PlayerConfig(s_newViewportBelongsToPlayer[i])->Name();
786 titles[i] << ")";
787 }
788 #ifndef DEDICATED
789 rViewportConfiguration::DemonstrateViewport(titles);
790 #endif
791 }
792
Render(REAL x,REAL y,REAL alpha=1,bool selected=0)793 virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0){
794
795 tOutput disp;
796
797 disp.SetTemplateParameter(1, vp +1);
798 disp.SetTemplateParameter(2, s_newViewportBelongsToPlayer[vp]+1);
799 disp.SetTemplateParameter(3, ePlayer::PlayerConfig(s_newViewportBelongsToPlayer[vp])->Name());
800 disp << "$viewport_belongs_text";
801
802 DisplayText(x-.02,y,disp,selected,alpha);
803 }
804
805 };
806
807 #include "rSysdep.h"
808 extern void Render(int);
809
810
811 class ArmageTron_color_menuitem:public uMenuItemInt{
812 protected:
813 int *rgb;
814 unsigned short me;
815 public:
ArmageTron_color_menuitem(uMenu * m,const char * tit,const char * help,int * RGB,int Me)816 ArmageTron_color_menuitem(uMenu *m,const char *tit,
817 const char *help, int *RGB,int Me)
818 :uMenuItemInt(m,tit,help,RGB[Me],0,15),
819 rgb(RGB),me(Me) {
820 m->RequestSpaceBelow(.2);
821 }
822
~ArmageTron_color_menuitem()823 ~ArmageTron_color_menuitem(){}
824
SpaceRight()825 virtual REAL SpaceRight(){return .2;}
826
827
RenderBackground()828 virtual void RenderBackground(){
829 // static int count=0;
830 /*
831 while(rgb[0]+rgb[1]+rgb[2]<13){
832 if (rgb[count]<15)
833 rgb[count]++;
834 count++;
835 if (count>2)
836 count=0;
837 }
838 */
839 #ifndef DEDICATED
840 if (!sr_glOut)
841 return;
842 uMenuItem::RenderBackground();
843 REAL r = rgb[0]/15.0;
844 REAL g = rgb[1]/15.0;
845 REAL b = rgb[2]/15.0;
846 se_MakeColorValid(r, g, b, 1.0f);
847 glColor3f(r, g, b);
848 glRectf(.8,-.8,.98,-.98);
849 #endif
850 }
851
852 };
853
854
855
sg_PlayerMenu(int Player)856 void sg_PlayerMenu(int Player){
857 tOutput name;
858 name.SetTemplateParameter(1, Player+1);
859
860 name << "$player_menu_text";
861
862
863 uMenu playerMenu(name);
864
865 uMenu camera_menu("$player_camera_text");
866 uMenu chat_menu("$player_chat_text");
867 // name.Clear();
868 chat_menu.SetCenter(-.5);
869
870 uMenuItemString *ic[MAX_INSTANT_CHAT];
871
872 ePlayer *p = ePlayer::PlayerConfig(Player);
873 if (!p)
874 return;
875
876 int i;
877 for(i=MAX_INSTANT_CHAT-1;i>=0;i--){
878 tOutput name;
879 name.SetTemplateParameter(1, i+1);
880 name << "$player_chat_chat";
881 ic[i]=new uMenuItemString
882 (&chat_menu,name,
883 "$player_chat_chat_help",
884 p->instantChatString[i], se_SpamMaxLen);
885 }
886
887 uMenuItemToggle al
888 (&playerMenu,"$player_autologin_text",
889 "$player_autologin_help",
890 p->autoLogin);
891
892 uMenuItemString gid(&playerMenu,
893 "$player_global_id_text",
894 "$player_global_id_help",
895 p->globalID, 400);
896 gid.SetColorMode( rTextField::COLOR_IGNORE );
897
898 uMenuItemToggle st
899 (&playerMenu,"$player_stealth_text",
900 "$player_stealth_help",
901 p->stealth);
902
903 uMenuItemToggle sp
904 (&playerMenu,"$player_spectator_text",
905 "$player_spectator_help",
906 p->spectate);
907
908 uMenuItemToggle pnt
909 (&playerMenu,"$player_name_team_text",
910 "$player_name_team_help",
911 p->nameTeamAfterMe);
912
913 uMenuItemInt npt
914 (&playerMenu,"$player_num_per_team_text",
915 "$player_num_per_team_help",
916 p->favoriteNumberOfPlayersPerTeam, 1, 16, 1);
917
918 ArmageTron_color_menuitem B(&playerMenu,"$player_blue_text",
919 "$player_blue_help",
920 p->rgb,2);
921
922 ArmageTron_color_menuitem G(&playerMenu,"$player_green_text",
923 "$player_green_help",
924 p->rgb,1);
925
926 ArmageTron_color_menuitem R(&playerMenu,"$player_red_text",
927 "$player_red_help",
928 p->rgb,0);
929
930
931
932 uMenuItemSubmenu chm(&playerMenu,&chat_menu,
933 "$player_chat_chat_help");
934
935 uMenuItemSubmenu cm(&playerMenu,&camera_menu,
936 "$player_camera_help");
937
938 uMenuItemFunctionInt icc(&playerMenu,"$player_camera_input_text",
939 "$player_camera_input_help",
940 &su_InputConfigCamera,Player);
941
942 uMenuItemFunctionInt inc(&playerMenu,"$player_input_text",
943 "$player_input_help",
944 &su_InputConfig,Player);
945
946
947 camera_menu.SetCenter(.3);
948
949 uMenuItemToggle cam_glance
950 (&camera_menu,
951 "$camera_smart_glance_custom_text",
952 "$camera_smart_glance_custom_help",
953 p->smartCustomGlance);
954
955 uMenuItemToggle cis(&camera_menu,
956 "$player_camera_autoin_text",
957 "$player_camera_autoin_help",
958 p->autoSwitchIncam);
959
960 uMenuItemToggle cim(&camera_menu,
961 "$player_camera_wobble_text",
962 "$player_camera_wobble_help",
963 p->wobbleIncam);
964
965 uMenuItemToggle cic(&camera_menu,
966 "$player_camera_center_int_text",
967 "$player_camera_center_int_help",
968 p->centerIncamOnTurn);
969
970 uMenuItemToggle al_s
971 (&camera_menu,
972 "$player_camera_smartcam_text",
973 "$player_camera_smartcam_help",
974 p->allowCam[CAMERA_SMART]);
975
976 uMenuItemToggle al_f
977 (&camera_menu,
978 "$player_camera_fixed_text",
979 "$player_camera_fixed_help",
980 p->allowCam[CAMERA_FOLLOW]);
981
982
983 uMenuItemToggle al_fr
984 (&camera_menu,
985 "$player_camera_free_text",
986 "$player_camera_free_help",
987 p->allowCam[CAMERA_FREE]);
988
989 uMenuItemToggle al_c
990 (&camera_menu,
991 "$player_camera_custom_text",
992 "$player_camera_custom_help",
993 p->allowCam[CAMERA_CUSTOM]);
994
995 uMenuItemToggle al_sc
996 (&camera_menu,
997 "$player_camera_server_custom_text",
998 "$player_camera_server_custom_help",
999 p->allowCam[CAMERA_SERVER_CUSTOM]);
1000
1001 uMenuItemToggle al_i
1002 (&camera_menu,
1003 "$player_camera_incam_text",
1004 "$player_camera_incam_help",
1005 p->allowCam[CAMERA_IN]);
1006
1007
1008 uMenuItemInt cam_fov
1009 (&camera_menu,
1010 "$player_camera_fov_text",
1011 "$player_camera_fov_help",
1012 p->startFOV,30,120,5);
1013
1014 uMenuItemSelection<eCamMode> cam_s
1015 (&camera_menu,
1016 "$player_camera_initial_text",
1017 "$player_camera_initial_help",
1018 p->startCamera);
1019
1020 cam_s.NewChoice("$player_camera_initial_scust_text","$player_camera_initial_scust_help",CAMERA_SERVER_CUSTOM);
1021 cam_s.NewChoice("$player_camera_initial_cust_text","$player_camera_initial_cust_help",CAMERA_CUSTOM);
1022 cam_s.NewChoice("$player_camera_initial_int_text","$player_camera_initial_int_help",CAMERA_IN);
1023 cam_s.NewChoice("$player_camera_initial_smrt_text","$player_camera_initial_smrt_help",CAMERA_SMART);
1024 cam_s.NewChoice("$player_camera_initial_ext_text","$player_camera_initial_ext_help",CAMERA_FOLLOW);
1025 cam_s.NewChoice("$player_camera_initial_free_text","$player_camera_initial_free_help",CAMERA_FREE);
1026
1027 uMenuItemString n(&playerMenu,
1028 "$player_name_text",
1029 "$player_name_help",
1030 p->name, 16);
1031
1032 playerMenu.Enter();
1033
1034 for(i=MAX_INSTANT_CHAT-1; i>=0; i--)
1035 delete ic[i];
1036
1037
1038 // request network synchronisation if the server can handle it
1039 static nVersionFeature inGameRenames( 5 );
1040 if ( inGameRenames.Supported() )
1041 {
1042 ePlayerNetID::Update();
1043 ePlayer::SendAuthNames();
1044 }
1045
1046 /*
1047 for (i=MAX_PLAYERS-1; i>=0; i--)
1048 {
1049 if (ePlayer::PlayerIsInGame(i))
1050 {
1051 ePlayer* p = ePlayer::PlayerConfig(i);
1052 if (p->netPlayer)
1053 p->netPlayer->RequestSync();
1054 }
1055 }
1056 */
1057 }
1058
1059
1060 VOIDFUNC viewport_menu_x;
1061
1062
1063
1064
1065
1066
1067 // from gGame.C
1068 //extern int pingCharity;
1069
1070
sg_PlayerMenu()1071 void sg_PlayerMenu(){
1072 uMenu Player_men("$player_mainmenu_text");
1073
1074
1075 uMenuItemFunction vp_selec(&Player_men,
1076 "$viewport_assign_text",
1077 "$viewport_assign_help",
1078 &viewport_menu_x);
1079
1080 ArmageTron_viewport_menuitem vp(&Player_men);
1081 uMenuItemFunctionInt *names[MAX_PLAYERS];
1082
1083 int i;
1084
1085 for(i=MAX_PLAYERS-1;i>=0;i--){
1086 tOutput title;
1087 title.SetTemplateParameter(1, i+1);
1088 title << "$player_menu_text";
1089
1090 tOutput help;
1091 help.SetTemplateParameter(1, i+1);
1092 help << "$player_menu_help";
1093
1094 names[i]=new uMenuItemFunctionInt(&Player_men,
1095 title,
1096 help,
1097 sg_PlayerMenu,i);
1098 }
1099
1100
1101 Player_men.Enter();
1102
1103 // ePlayerNetID::Update();
1104 for(i=MAX_VIEWPORTS-1;i>=0;i--){
1105 delete names[i];
1106 }
1107 }
1108
1109
1110
1111
viewport_menu_x(void)1112 void viewport_menu_x(void){
1113 uMenu sg_PlayerMenu("$viewport_assign_text");
1114
1115 ArmageTronPlayer_to_viewport_menuitem *select[MAX_VIEWPORTS];
1116
1117 int i;
1118 for(i=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;i>=0;i--){
1119 select[i]=new ArmageTronPlayer_to_viewport_menuitem(&sg_PlayerMenu,i);
1120 }
1121
1122 // ArmageTron_viewport_menuitem vp(&sg_PlayerMenu);
1123
1124 sg_PlayerMenu.Enter();
1125
1126 for(i=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;i>=0;i--){
1127 delete select[i];
1128 }
1129 }
1130
1131
1132 static uActionGlobal con_input( "CONSOLE_INPUT" );
1133
1134
1135 static uActionGlobal screenshot( "SCREENSHOT" );
1136
1137 static uActionGlobal togglefullscreen( "TOGGLE_FULLSCREEN" );
1138
screenshot_func(REAL x)1139 static bool screenshot_func(REAL x){
1140 if (x>0){
1141 #ifndef DEDICATED
1142 sr_screenshotIsPlanned=true;
1143 #endif
1144 }
1145
1146 return true;
1147 }
1148
con_func(REAL x)1149 static bool con_func(REAL x){
1150 if (x>0){
1151 sg_ConsoleInput();
1152 }
1153
1154 return true;
1155 }
1156
toggle_fullscreen_func(REAL x)1157 static bool toggle_fullscreen_func( REAL x )
1158 {
1159 #ifndef DEDICATED
1160 #ifdef DEBUG
1161 // don't toggle fullscreen while playing back in debug mode, that's annoying
1162 if ( tRecorder::IsPlayingBack() )
1163 return true;
1164 #endif
1165
1166 // only do anything if the application is active (work around odd bug)
1167 if ( x > 0 && ( SDL_GetAppState() & SDL_APPACTIVE ) )
1168 {
1169 currentScreensetting.fullscreen = !currentScreensetting.fullscreen;
1170 sr_ReinitDisplay();
1171 }
1172 #endif
1173
1174 return true;
1175 }
1176
1177 static uActionGlobalFunc gaf_ss(&screenshot,&screenshot_func, true );
1178 static uActionGlobalFunc gaf_md(&con_input,&con_func);
1179 static uActionGlobalFunc gaf_tf(&togglefullscreen,&toggle_fullscreen_func, true );
1180