src/tron/gMenus.cpp

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023 
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #include "gMenus.h"
00029 #include "ePlayer.h"
00030 #include "rScreen.h"
00031 #include "rTexture.h"
00032 #include "nConfig.h"
00033 #include "rConsole.h"
00034 #include "tToDo.h"
00035 #include "rGL.h"
00036 #include "eTimer.h"
00037 #include "eFloor.h"
00038 #include "rRender.h"
00039 #include "rModel.h"
00040 #include "gGame.h"
00041 #include "gCycle.h"
00042 #include "tRecorder.h"
00043 #include "rSysdep.h"
00044 
00045 #include <sstream>
00046 #include <set>
00047 
00048 static tConfItem<int>   tm0("TEXTURE_MODE_0",rTextureGroups::TextureMode[0]);
00049 static tConfItem<int>   tm1("TEXTURE_MODE_1",rTextureGroups::TextureMode[1]);
00050 static tConfItem<int>   tm2("TEXTURE_MODE_2",rTextureGroups::TextureMode[2]);
00051 static tConfItem<int>   tm3("TEXTURE_MODE_3",rTextureGroups::TextureMode[3]);
00052 
00053 uMenu sg_screenMenu("$display_settings_menu");
00054 
00055 static uMenuItemFunction defaul
00056 (&sg_screenMenu,"$graphics_load_defaults_text",
00057  "$graphics_load_defaults_help",
00058  &sr_LoadDefaultConfig);
00059 uMenu screen_menu_detail("$detail_settings_menu");
00060 uMenu screen_menu_tweaks("$performance_tweaks_menu");
00061 uMenu screen_menu_prefs("$preferences_menu");
00062 
00063 static void sg_ScreenModeMenu();
00064 
00065 static uMenuItemSubmenu smt(&sg_screenMenu,&screen_menu_tweaks,
00066                             "$performance_tweaks_menu_help");
00067 static uMenuItemSubmenu smd(&sg_screenMenu,&screen_menu_detail,
00068                             "$detail_settings_menu_help");
00069 static uMenuItemSubmenu smp(&sg_screenMenu,&screen_menu_prefs,
00070                             "$preferences_menu_help");
00071 static uMenuItemFunction smm(&sg_screenMenu,"$screen_mode_menu",
00072                              "$screen_mode_menu_help", sg_ScreenModeMenu );
00073 
00074 static tConfItemLine c_ext("GL_EXTENSIONS",gl_extensions);
00075 static tConfItemLine c_ver("GL_VERSION",gl_version);
00076 static tConfItemLine c_rEnd("GL_RENDERER",gl_renderer);
00077 static tConfItemLine c_vEnd("GL_VENDOR",gl_vendor);
00078 // static tConfItemLine a_ver("ARMAGETRON_VERSION",sn_programVersion);
00079 
00080 #ifndef DEDICATED
00081 static uMenuItemStringWithHistory::history_t &sg_consoleHistory() {
00082     static uMenuItemStringWithHistory::history_t instance("console_history.txt");
00083     return instance;
00084 }
00085 #endif
00086 
00087 static int sg_consoleHistoryMaxSize=100; // size of the console history
00088 static tSettingItem< int > sg_consoleHistoryMaxSizeConf("HISTORY_SIZE_CONSOLE",sg_consoleHistoryMaxSize);
00089 
00090 class ArmageTron_feature_menuitem: public uMenuItemSelection<int>{
00091     void NewChoice(uSelectItem<bool> *){};
00092     void NewChoice(char *,bool ){};
00093 public:
00094     ArmageTron_feature_menuitem(uMenu *m,char const * tit,char const * help,int &targ)
00095             :uMenuItemSelection<int>(m,tit,help,targ){
00096         uMenuItemSelection<int>::NewChoice(
00097             "$feature_disabled_text",
00098             "$feature_disabled_help",
00099             rFEAT_OFF);
00100         uMenuItemSelection<int>::NewChoice(
00101             "$feature_default_text",
00102             "$feature_default_help",
00103             rFEAT_DEFAULT);
00104         uMenuItemSelection<int>::NewChoice(
00105             "$feature_enabled_text",
00106             "$feature_enabled_help",
00107             rFEAT_ON);
00108     }
00109 
00110     ~ArmageTron_feature_menuitem(){};
00111 };
00112 
00113 
00114 class ArmageTron_texmode_menuitem: public uMenuItemSelection<int>{
00115     void NewChoice(uSelectItem<bool> *){};
00116     void NewChoice(char *,bool ){};
00117 public:
00118     ArmageTron_texmode_menuitem(uMenu *m,char const * tit,int &targ,
00119                                 bool font=false)
00120             :uMenuItemSelection<int>
00121     (m,tit,"$texture_menuitem_help",targ){
00122 
00123         if(!font)
00124             uMenuItemSelection<int>::NewChoice
00125             ("$texture_off_text","$texture_off_help",-1);
00126 #ifndef DEDICATED
00127         uMenuItemSelection<int>::NewChoice
00128         ("$texture_nearest_text","$texture_nearest_help",GL_NEAREST);
00129 
00130         uMenuItemSelection<int>::NewChoice
00131         ("$texture_bilinear_text","$texture_bilinear_help",GL_LINEAR);
00132 
00133         if(!font)
00134         {
00135             uMenuItemSelection<int>::NewChoice
00136             ("$texture_mipmap_nearest_text",
00137              "$texture_mipmap_nearest_help",
00138              GL_NEAREST_MIPMAP_NEAREST);
00139             uMenuItemSelection<int>::NewChoice
00140             ("$texture_mipmap_bilinear_text",
00141              "$texture_mipmap_bilinear_help",
00142              GL_LINEAR_MIPMAP_NEAREST);
00143             uMenuItemSelection<int>::NewChoice
00144             ("$texture_mipmap_trilinear_text",
00145              "$texture_mipmap_trilinear_help",
00146              GL_LINEAR_MIPMAP_LINEAR);
00147         }
00148     #endif
00149     }
00150 
00151     ~ArmageTron_texmode_menuitem(){};
00152 };
00153 
00154 static tConfItem<bool>    ab("ALPHA_BLEND",sr_alphaBlend);
00155 static tConfItem<bool>    ss("SMOOTH_SHADING",sr_smoothShading);
00156 static tConfItem<bool>    to("TEXT_OUT",sr_textOut);
00157 static tConfItem<bool>    fps("SHOW_FPS",sr_FPSOut);
00158 // tConfItem<> ("",&);
00159 static tConfItem<int> fm("FLOOR_MIRROR",sr_floorMirror);
00160 static tConfItem<int> fd("FLOOR_DETAIL",sr_floorDetail);
00161 static tConfItem<bool> hr("HIGH_RIM",sr_highRim);
00162 static tConfItem<bool> dt("DITHER",sr_dither);
00163 static tConfItem<bool> us("UPPER_SKY",sr_upperSky);
00164 static tConfItem<bool> ls("LOWER_SKY",sr_lowerSky);
00165 static tConfItem<bool> wos("SKY_WOBBLE",sr_skyWobble);
00166 static tConfItem<bool> ip("INFINITY_PLANE",sr_infinityPlane);
00167 
00168 extern bool sg_axesIndicator;
00169 
00170 static tConfItem<bool> lm("LAG_O_METER",sr_laggometer);
00171 static tConfItem<bool> ai("AXES_INDICATOR",sg_axesIndicator);
00172 static tConfItem<bool> po("PREDICT_OBJECTS",sr_predictObjects);
00173 static tConfItem<bool> t32("TEXTURES_HI",sr_texturesTruecolor);
00174 
00175 static tConfItem<bool> kwa("KEEP_WINDOW_ACTIVE",sr_keepWindowActive);
00176 #ifdef USE_HEADLIGHT
00177 static tConfItem<bool> chl("HEADLIGHT",headlights);
00178 #endif
00179 
00180 #ifndef SDL_OPENGL
00181 #ifndef DIRTY
00182 #define DIRTY
00183 #endif
00184 #endif
00185 
00186 bool operator < ( rScreenSize const & a, rScreenSize const & b )
00187 {
00188     return a.Compare(b) < 0;
00189 }
00190 
00191 class gResMenEntry
00192 {
00193     uMenuItemSelection<rScreenSize> res_men; // menu item
00194     std::set< rScreenSize > sizes;           // set of already added modes
00195 
00196     // adds a single custom screen resolution
00197     void NewChoice( rScreenSize const & size )
00198     {
00199         if ( sizes.find( size ) == sizes.end() )
00200         {
00201             sizes.insert(size);
00202         }
00203     }
00204 
00205     // adds a single predefined resolution
00206     void NewChoice( rResolution res )
00207     {
00208         rScreenSize size( res );
00209         NewChoice( size );
00210     }
00211 
00212 public:
00213     gResMenEntry( uMenu & screen_menu_mode, rScreenSize& res, const tOutput& text, const tOutput& help, bool addFixed )
00214             :res_men
00215             (&screen_menu_mode,
00216              text,
00217              help,
00218              res)
00219     {
00220 #ifndef DEDICATED
00221         // fetch valid screen modes from SDL
00222         SDL_Rect **modes;
00223         modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
00224 
00225         // Check is there are any modes available
00226         int i;
00227         if(modes == 0 || modes == (SDL_Rect **)-1)
00228         {
00229             // add all fixed resolutions
00230             for ( i = ArmageTron_Custom; i>=0; --i )
00231             {
00232                 NewChoice( rResolution(i) );
00233             }
00234         }
00235         else
00236         {
00237             // add custom resolution
00238             NewChoice( ArmageTron_Custom );
00239 
00240             // add desktop resolution
00241             if ( sr_DesktopScreensizeSupported() && !addFixed )
00242                 NewChoice( ArmageTron_Desktop );
00243 
00244             // the maximal allowed screen size
00245             rScreenSize maxSize(0,0);
00246 
00247             // fill in available modes (avoid duplicates)
00248             for(i=0;modes[i];++i)
00249             {
00250                 // add mode (if it's new)
00251                 rScreenSize size(modes[i]->w, modes[i]->h);
00252                 NewChoice( size );
00253                 if ( maxSize.width < size.width )
00254                     maxSize.width = size.width;
00255                 if ( maxSize.height < size.height )
00256                     maxSize.height = size.height;
00257             }
00258 
00259             // add fixed resolutions (as window sizes)
00260             if ( addFixed )
00261             {
00262                 for ( i = ArmageTron_Custom; i>=ArmageTron_Min; --i )
00263                 {
00264                     rScreenSize size( static_cast< rResolution >(i) );
00265 
00266                     // only add those that fit the maximal resolution
00267                     if ( maxSize.height >= size.height && maxSize.width >= size.width )
00268                         NewChoice( size );
00269                 }
00270             }
00271         }
00272 
00273         // insert sorted resolutions into menu
00274         for( std::set< rScreenSize >::iterator iter = sizes.begin(); iter != sizes.end(); ++iter )
00275             {
00276                 rScreenSize const & size = *iter;
00277 
00278                 std::stringstream s;
00279                 if ( size.width + size.height > 0 )
00280                     s << size.width << " x " << size.height;
00281                 else
00282                     s << tOutput("$screen_size_desktop");
00283 
00284                 res_men.NewChoice( s.str().c_str(), help, size );
00285             }
00286 
00287 #endif
00288     }
00289 };
00290 
00291 static void sg_ScreenModeMenu()
00292 {
00293     uMenu screen_menu_mode("$screen_mode_menu");
00294 
00295     uMenuItemFunction appl
00296     (&screen_menu_mode,
00297      "$screen_apply_changes_text",
00298      "$screen_apply_changes_help",
00299      &sr_ReinitDisplay);
00300 
00301     uMenuItemToggle kwa_t(
00302         &screen_menu_mode,
00303         "$screen_keep_window_active_text",
00304         "$screen_keep_window_active_help",
00305         sr_keepWindowActive);
00306 
00307     uMenuItemToggle ie_t
00308     (&screen_menu_mode,
00309      "$screen_check_errors_text",
00310      "$screen_check_errors_help",
00311      currentScreensetting.checkErrors);
00312 
00313 
00314 #ifdef SDL_OPENGL
00315 #ifdef DIRTY
00316     uMenuItemToggle sdl_t
00317     (&screen_menu_mode,
00318      "$screen_use_sdl_text",
00319      "$screen_use_sdl_help",
00320      currentScreensetting.useSDL);
00321 #endif // dirty
00322 
00323 #if SDL_VERSION_ATLEAST(1, 2, 10)
00324     uMenuItemSelection<rVSync> zvs_t
00325     (&screen_menu_mode,
00326      "$screen_vsync_text",
00327      "$screen_vsync_help",
00328      currentScreensetting.vSync);
00329 
00330     uSelectEntry<rVSync> zvs_on(zvs_t,"$screen_vsync_on_text","$screen_vsync_on_help",ArmageTron_VSync_On);
00331     uSelectEntry<rVSync> zvs_d(zvs_t,"$screen_vsync_default_text","$screen_vsync_default_help",ArmageTron_VSync_Default);
00332     uSelectEntry<rVSync> zvs_off(zvs_t,"$screen_vsync_off_text","$screen_vsync_off_help",ArmageTron_VSync_Off);
00333 #ifdef HAVE_GLEW
00334     uSelectEntry<rVSync> zvs_blur(zvs_t,"$screen_vsync_motionblur_text","$screen_vsync_motionblur_help",ArmageTron_VSync_MotionBlur);
00335 #endif // HAVE_GLEW
00336 #endif // SDL_GL_SWAP_CONTROL
00337 #endif // SDL_OPENGL
00338 
00339     uMenuItemToggle gm(
00340         &screen_menu_mode,
00341         "$screen_grab_mouse_text",
00342         "$screen_grab_mouse_help",
00343         su_mouseGrab);
00344 
00345     uMenuItemSelection<rColorDepth> zd_t
00346     (&screen_menu_mode,
00347      "$screen_zdepth_text",
00348      "$screen_zdepth_help",
00349      currentScreensetting.zDepth);
00350 
00351     uSelectEntry<rColorDepth> zd_16(zd_t,"$screen_zdepth_16_text","$screen_zdepth_16_help",ArmageTron_ColorDepth_16);
00352     uSelectEntry<rColorDepth> zd_d(zd_t,"$screen_zdepth_desk_text","$screen_zdepth_desk_help",ArmageTron_ColorDepth_Desktop);
00353     uSelectEntry<rColorDepth> zd_32(zd_t,"$screen_zdepth_32_text","$screen_zdepth_32_help",ArmageTron_ColorDepth_32);
00354 
00355     uMenuItemSelection<rColorDepth> cd_t
00356     (&screen_menu_mode,
00357      "$screen_colordepth_text",
00358      "$screen_colordepth_help",
00359      currentScreensetting.colorDepth);
00360 
00361     uSelectEntry<rColorDepth> cd_16(cd_t,"$screen_colordepth_16_text","$screen_colordepth_16_help",ArmageTron_ColorDepth_16);
00362     uSelectEntry<rColorDepth> cd_d(cd_t,"$screen_colordepth_desk_text","$screen_colordepth_desk_help",ArmageTron_ColorDepth_Desktop);
00363     uSelectEntry<rColorDepth> cd_32(cd_t,"$screen_colordepth_32_text","$screen_colordepth_32_help",ArmageTron_ColorDepth_32);
00364 
00365     uMenuItemToggle fs_t
00366     (&screen_menu_mode,
00367      "$screen_fullscreen_text",
00368      "$screen_fullscreen_help",
00369      currentScreensetting.fullscreen);
00370 
00371 
00372     gResMenEntry res( screen_menu_mode, currentScreensetting.res, "$screen_resolution_text", "$screen_resolution_help", false );
00373     gResMenEntry winsize( screen_menu_mode, currentScreensetting.windowSize, "$window_size_text", "$window_size_help", true );
00374 
00375     /*
00376     uMenuItemSelection<rResolution> res_men
00377     (&screen_menu_mode,
00378      "$screen_resolution_text",
00379      "$screen_resolution_help",
00380      currentScreensetting.res);
00381 
00382 
00383     uSelectEntry<rResolution> a(res_men,"320x200","",ArmageTron_320_200);
00384      static uSelectEntry<rResolution> b(res_men,"320x240","",ArmageTron_320_240);
00385     static uSelectEntry<rResolution> c(res_men,"400x300","",ArmageTron_400_300);
00386     static uSelectEntry<rResolution> d(res_men,"512x384","",ArmageTron_512_384);
00387     static uSelectEntry<rResolution> e(res_men,"640x480","",ArmageTron_640_480);
00388     static uSelectEntry<rResolution> f(res_men,"800x600","",ArmageTron_800_600);
00389     static uSelectEntry<rResolution> g(res_men,"1024x768","",ArmageTron_1024_768);
00390     static uSelectEntry<rResolution> h(res_men,"1280x1024","",ArmageTron_1280_1024);
00391     static uSelectEntry<rResolution> i(res_men,"1600x1200","",ArmageTron_1600_1200);
00392     static uSelectEntry<rResolution> j(res_men,"2048x1572","",ArmageTron_2048_1572);
00393     static uSelectEntry<rResolution> jj(res_men,
00394                                     "$screen_custom_text",
00395                                     "$screen_custom_help"
00396                                     ,ArmageTron_Custom);
00397     */
00398 
00399     screen_menu_mode.Enter();
00400 }
00401 
00402 
00403 static uMenuItemSelection<int> mfm
00404 (&screen_menu_detail,
00405  "$detail_floor_mirror_text",
00406  "$detail_floor_mirror_help",
00407  sr_floorMirror);
00408 static uSelectEntry<int> mfma(mfm,"$detail_floor_mirror_off_text","$detail_floor_mirror_off_help",rMIRROR_OFF);
00409 
00410 
00411 static uSelectEntry<int> mfmb(mfm,"$detail_floor_mirror_obj_text",
00412                               "$detail_floor_mirror_obj_help",
00413                               rMIRROR_OBJECTS);
00414 
00415 static uSelectEntry<int> mfmc(mfm,"$detail_floor_mirror_ow_text",
00416                               "$detail_floor_mirror_ow_help",
00417                               rMIRROR_WALLS);
00418 
00419 static uSelectEntry<int> mfme(mfm,"$detail_floor_mirror_ev_text","$detail_floor_mirror_ev_help",rMIRROR_ALL);
00420 
00421 static uMenuItemToggle fs_dither
00422 (&screen_menu_detail,"$detail_dither_text",
00423  "$detail_dither_help",
00424  sr_dither);
00425 
00426 static uMenuItemSelection<int> mfd
00427 (&screen_menu_detail,
00428  "$detail_floor_text",
00429  "$detail_floor_help",
00430  sr_floorDetail);
00431 
00432 static uSelectEntry<int> mfda(mfd,"$detail_floor_no_text",
00433                               "$detail_floor_no_help",
00434                               rFLOOR_OFF);
00435 static uSelectEntry<int> mfdb(mfd,"$detail_floor_grid_text",
00436                               "$detail_floor_grid_help",
00437                               rFLOOR_GRID);
00438 static uSelectEntry<int> mfdc(mfd,"$detail_floor_tex_text",
00439                               "$detail_floor_tex_help",
00440                               rFLOOR_TEXTURE);
00441 static uSelectEntry<int> mfdd(mfd,"$detail_floor_2tex_text",
00442                               "$detail_floor_2tex_help",
00443                               rFLOOR_TWOTEXTURE);
00444 
00445 static uMenuItemToggle  abm
00446 (&screen_menu_detail,"$detail_alpha_text",
00447  "$detail_alpha_help",
00448  sr_alphaBlend);
00449 
00450 static uMenuItemToggle  ssm
00451 (&screen_menu_detail,"$detail_smooth_text",
00452  "$detail_smooth_help",
00453  sr_smoothShading);
00454 
00455 extern bool crash_sparks;               // from gCycle.cpp
00456 extern bool white_sparks;               // from gSparks.cpp
00457 static tConfItem<bool> cs2("SPARKS",crash_sparks);
00458 static tConfItem<bool> wsp("WHITE_SPARKS",white_sparks);
00459 
00460 extern bool sg_crashExplosion;   // from gExplosion.cpp
00461 static tConfItem<bool> crexp("EXPLOSION",sg_crashExplosion);
00462 extern bool sg_crashExplosionHud;   // from gExplosion.cpp
00463 static tConfItem<bool> crexph("EXPLOSION_HUD",sg_crashExplosionHud);
00464 
00465 #ifndef DEDICATED
00466 //extern bool png_screenshot;           // from rSysdep.cpp
00467 //static tConfItem<bool> pns("PNG_SCREENSHOT",png_screenshot);
00468 #endif
00469 
00470 static uMenuItemToggle  t32b
00471 (&screen_menu_detail,"$detail_text_truecolor_text",
00472  "$detail_text_truecolor_help"
00473  ,sr_texturesTruecolor);
00474 
00475 
00476 static ArmageTron_texmode_menuitem tmm0(&screen_menu_detail,
00477                                         rTextureGroups::TextureGroupDescription[0],
00478                                         rTextureGroups::TextureMode[0]);
00479 
00480 static ArmageTron_texmode_menuitem tmm1(&screen_menu_detail,
00481                                         rTextureGroups::TextureGroupDescription[1],
00482                                         rTextureGroups::TextureMode[1]);
00483 
00484 static ArmageTron_texmode_menuitem tmm2(&screen_menu_detail,
00485                                         rTextureGroups::TextureGroupDescription[2],
00486                                         rTextureGroups::TextureMode[2]);
00487 
00488 static ArmageTron_texmode_menuitem tmm3(&screen_menu_detail,
00489                                         rTextureGroups::TextureGroupDescription[3],
00490                                         rTextureGroups::TextureMode[3],true);
00491 
00492 
00493 static uMenuItemToggle s2
00494 (&screen_menu_prefs,"$pref_highrim_text",
00495  "$pref_highrim_help",sr_highRim);
00496 
00497 static uMenuItemToggle us2
00498 (&screen_menu_prefs,"$pref_uppersky_text",
00499  "$pref_uppersky_help",
00500  sr_upperSky);
00501 
00502 static uMenuItemToggle ls2
00503 (&screen_menu_prefs,"$pref_lowersky_text",
00504  "$pref_lowersky_help",
00505  sr_lowerSky);
00506 
00507 uMenuItemToggle fps2
00508 (&screen_menu_prefs,"$misc_fps_text",
00509  "$misc_fps_help",sr_FPSOut);
00510 
00511 #ifdef USE_HEADLIGHT
00512 static uMenuItemToggle uchl(&screen_menu_prefs,"$pref_headlight_text","$pref_headlight_help",
00513                             headlights);
00514 #endif
00515 
00516 
00517 static uMenuItemToggle ws2
00518 (&screen_menu_prefs,"$pref_skymove_text",
00519  "$pref_skymove_help",
00520  sr_skyWobble);
00521 
00522 static uMenuItemToggle crexph2
00523 (&screen_menu_prefs,"$pref_explosion_hud_text",
00524  "$pref_explosion_hud_help",
00525  sg_crashExplosionHud);
00526 
00527 static uMenuItemToggle crexp2
00528 (&screen_menu_prefs,"$pref_explosion_text",
00529  "$pref_explosion_help",
00530  sg_crashExplosion);
00531 
00532 static uMenuItemToggle cs
00533 (&screen_menu_prefs,"$pref_sparks_text",
00534  "$pref_sparks_help",
00535  crash_sparks);
00536 
00537 static uMenuItemSelection<rDisplayListUsage> dl
00538 (&screen_menu_tweaks,"$tweaks_displaylists_text",
00539  "$tweaks_displaylists_help", sr_useDisplayLists);
00540 static uSelectEntry<rDisplayListUsage> dl_off(dl,"$tweaks_displaylists_off_text","$tweaks_displaylists_off_help",rDisplayList_Off);
00541 static uSelectEntry<rDisplayListUsage> dl_cac(dl,"$tweaks_displaylists_cac_text","$tweaks_displaylists_cac_help",rDisplayList_CAC);
00542 static uSelectEntry<rDisplayListUsage> dl_cae(dl,"$tweaks_displaylists_cae_text","$tweaks_displaylists_cae_help",rDisplayList_CAE);
00543 
00544 static uMenuItemToggle infp
00545 (&screen_menu_tweaks,"$tweaks_infinity_text",
00546  "$tweaks_infinity_help"
00547  ,sr_infinityPlane);
00548 
00549 uMenuItemSelection<rSysDep::rSwapMode> swapMode
00550 (&screen_menu_tweaks,
00551  "$swapmode_text",
00552  "$swapmode_help",
00553  rSysDep::swapMode_);
00554 
00555 static uSelectEntry<rSysDep::rSwapMode> swapMode_fastest(swapMode,"$swapmode_fastest_text","$swapmode_fastest_help",rSysDep::rSwap_Fastest);
00556 static uSelectEntry<rSysDep::rSwapMode> swapMode_glFlush(swapMode,"$swapmode_glflush_text","$swapmode_glflush_help",rSysDep::rSwap_glFlush);
00557 static uSelectEntry<rSysDep::rSwapMode> swapMode_glFinish(swapMode,"$swapmode_glfinish_text","$swapmode_glfinish_help",rSysDep::rSwap_glFinish);
00558 
00559 /*
00560 uMenuItemSelection<int> targetFPS
00561 (&screen_menu_tweaks,
00562  "$targetfps_text",
00563  "$targetfps_help",
00564 rSysDep::swapMode_);
00565 
00566 static uSelectEntry<rSysDep::rSwapMode> swapMode_150Hz(swapMode,"$swapmode_150hz_text","$swapmode_150hz_help",rSysDep::rSwap_150Hz);
00567 static uSelectEntry<rSysDep::rSwapMode> swapMode_100Hz(swapMode,"$swapmode_100hz_text","$swapmode_100hz_help",rSysDep::rSwap_100Hz);
00568 static uSelectEntry<rSysDep::rSwapMode> swapMode_80Hz(swapMode,"$swapmode_80hz_text","$swapmode_80hz_help",rSysDep::rSwap_80Hz);
00569 static uSelectEntry<rSysDep::rSwapMode> swapMode_60Hz(swapMode,"$swapmode_60hz_text","$swapmode_60hz_help",rSysDep::rSwap_60Hz);
00570 */
00571 
00572 tCONFIG_ENUM( rSysDep::rSwapMode );
00573 
00574 static tConfItem< rSysDep::rSwapMode > swapModeCI("SWAP_MODE", rSysDep::swapMode_ );
00575 
00576 static tConfItem<bool> WRAP("WRAP_MENU",uMenu::wrap);
00577 
00578 #ifndef DEDICATED
00579 
00580 class gAutoCompleterConsole : public uAutoCompleter {
00581 public:
00582     int Complete(tString &string, unsigned pos) {
00583         if(string.find_first_of(' ') == pos - 1) {
00584             tConfItemBase *cfg = tConfItemBase::FindConfigItem(string.substr(0, pos-1));
00585             if(cfg != 0) {
00586                 std::ostringstream toAdd("");
00587                 cfg->WriteVal(toAdd);
00588                 string << toAdd.str();
00589                 return string.size();
00590             }
00591         }
00592         //delegate
00593         return uAutoCompleter::Complete(string, pos);
00594     }
00595     gAutoCompleterConsole(std::deque<tString> &words) : uAutoCompleter(words) {}
00596 };
00597 
00599 class gMemuItemConsole: uMenuItemStringWithHistory{
00600 public:
00601     gMemuItemConsole(uMenu *M,tString &c, uAutoCompleter *completer); 
00602     virtual ~gMemuItemConsole(){}
00603     bool Event(SDL_Event &e);
00604 };
00605 
00609 gMemuItemConsole::gMemuItemConsole(uMenu *M,tString &c, uAutoCompleter *completer):
00610         uMenuItemStringWithHistory(M,"Con:","", c, 1024, sg_consoleHistory(), sg_consoleHistoryMaxSize, completer)
00611 {}
00612 
00613 
00614 bool gMemuItemConsole::Event(SDL_Event &e){
00615     if (e.type==SDL_KEYDOWN &&
00616             (e.key.keysym.sym==SDLK_KP_ENTER || e.key.keysym.sym==SDLK_RETURN)){
00617 
00618         con << tColoredString::ColorString(.5,.5,1) << " > " << *content << '\n';
00619 
00620         if ( tRecorder::IsPlayingBack() )
00621         {
00622             // the command was also recorded; better play it back,
00623             // or the playback gets out of sync
00624             tConfItemBase::LoadPlayback( false );
00625         }
00626         else
00627         {
00628             // pass the console command to the configuration system
00629             std::stringstream s(&((*content)[0]));
00630             tConfItemBase::LoadAll(s);
00631         }
00632 
00633         MyMenu()->Exit();
00634         return true;
00635     }
00636     else if (e.type==SDL_KEYDOWN &&
00637              uActionGlobal::IsBreakingGlobalBind(e.key.keysym.sym))
00638         return su_HandleEvent(e, true);
00639     else
00640         return uMenuItemStringWithHistory::Event(e);
00641 }
00642 
00643 void do_con(){
00644     se_ChatState( ePlayerNetID::ChatFlags_Console, true );
00645     sr_con.SetHeight(20,false);
00646     se_SetShowScoresAuto(false);
00647     tString c;
00648 
00649     uMenu con_menu("",false);
00650     std::deque<tString> commands;
00651     commands = tConfItemBase::GetCommands();
00652     gAutoCompleterConsole completer(commands);
00653     gMemuItemConsole s(&con_menu,c,&completer);
00654     con_menu.SetCenter(-.75);
00655     con_menu.SetBot(-2);
00656     con_menu.SetTop(-.7);
00657     con_menu.Enter();
00658 
00659     se_ChatState( ePlayerNetID::ChatFlags_Console, false );
00660 
00661     se_SetShowScoresAuto(true);
00662     sr_con.SetHeight(7,false);
00663 }
00664 #endif
00665 
00666 void sg_ConsoleInput(){
00667 #ifndef DEDICATED
00668     st_ToDo(&do_con);
00669 #endif
00670 }
00671 
00672 
00673 
00674 
00675 
00676 
00677 
00678 
00679 
00680 
00681 
00682 
00683 
00684 
00685 
00686 class ArmageTron_viewport_menuitem:public uMenuItemInt{
00687 public:
00688     ArmageTron_viewport_menuitem(uMenu *m):
00689             uMenuItemInt(m,"$viewport_menu_title",
00690                          "$viewport_menu_help",
00691                          rViewportConfiguration::next_conf_num,
00692                  0,rViewportConfiguration::s_viewportNumConfigurations-1){
00693         m->RequestSpaceBelow(.9);
00694     }
00695 
00696     virtual REAL SpaceRight(){return 1;}
00697 
00698     virtual void RenderBackground(){
00699         uMenuItem::RenderBackground();
00700 
00701         if (rViewportConfiguration::next_conf_num<0) rViewportConfiguration::next_conf_num=0;
00702         if (rViewportConfiguration::next_conf_num>=rViewportConfiguration::s_viewportNumConfigurations)
00703             rViewportConfiguration::next_conf_num=rViewportConfiguration::s_viewportNumConfigurations-1;
00704 
00705         tString  titles[MAX_VIEWPORTS];
00706 
00707         for(int i=MAX_VIEWPORTS-1;i>=0;i--)
00708             titles[i] << i+1;
00709 #ifndef DEDICATED
00710         rViewportConfiguration::DemonstrateViewport(titles);
00711 #endif
00712     }
00713 
00714     virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0){
00715         if (rViewportConfiguration::next_conf_num<0) rViewportConfiguration::next_conf_num=0;
00716         if (rViewportConfiguration::next_conf_num>=rViewportConfiguration::s_viewportNumConfigurations)
00717             rViewportConfiguration::next_conf_num=rViewportConfiguration::s_viewportNumConfigurations-1;
00718 
00719         tOutput disp;
00720 
00721         disp << "$viewport_conf_text";
00722         disp.AddSpace();
00723         disp << rViewportConfiguration::s_viewportConfigurationNames[rViewportConfiguration::next_conf_num];
00724         DisplayText(x-.02,y,disp,selected,alpha);
00725     }
00726 
00727 };
00728 
00729 
00730 
00731 class ArmageTronPlayer_to_viewport_menuitem:public uMenuItemInt{
00732     int    vp;
00733 public:
00734     ArmageTronPlayer_to_viewport_menuitem(uMenu *m,int v):
00735             uMenuItemInt(m,"",
00736                          "$viewport_assign_help",
00737                          s_newViewportBelongsToPlayer[v],
00738                  0,MAX_PLAYERS-1),vp(v){
00739         m->RequestSpaceBelow(.9);
00740     }
00741 
00742     virtual REAL SpaceRight(){return 1;}
00743 
00744     virtual void LeftRight(int x){
00745         rViewport::SetDirectionOfCorrection(vp,x);
00746         target=(target + MAX_PLAYERS + x) % MAX_PLAYERS;
00747     }
00748 
00749     virtual void RenderBackground(){
00750         rViewport::CorrectViewport(vp, MAX_PLAYERS);
00751 
00752         uMenuItem::RenderBackground();
00753 
00754         tString titles[MAX_VIEWPORTS];
00755         for(int i=MAX_VIEWPORTS-1;i>=0;i--){
00756             titles[i] << s_newViewportBelongsToPlayer[i]+1;
00757             titles[i] << " (";
00758             titles[i] << ePlayer::PlayerConfig(s_newViewportBelongsToPlayer[i])->Name();
00759             titles[i] << ")";
00760         }
00761 #ifndef DEDICATED
00762         rViewportConfiguration::DemonstrateViewport(titles);
00763 #endif
00764     }
00765 
00766     virtual void Render(REAL x,REAL y,REAL alpha=1,bool selected=0){
00767 
00768         tOutput disp;
00769 
00770         disp.SetTemplateParameter(1, vp +1);
00771         disp.SetTemplateParameter(2, s_newViewportBelongsToPlayer[vp]+1);
00772         disp.SetTemplateParameter(3, ePlayer::PlayerConfig(s_newViewportBelongsToPlayer[vp])->Name());
00773         disp << "$viewport_belongs_text";
00774 
00775         DisplayText(x-.02,y,disp,selected,alpha);
00776     }
00777 
00778 };
00779 
00780 #include "rSysdep.h"
00781 extern void Render(int);
00782 
00783 
00784 class ArmageTron_color_menuitem:public uMenuItemInt{
00785 protected:
00786     int *rgb;
00787     unsigned short me;
00788 public:
00789     ArmageTron_color_menuitem(uMenu *m,const char *tit,
00790                               const char *help, int *RGB,int Me)
00791             :uMenuItemInt(m,tit,help,RGB[Me],0,15),
00792     rgb(RGB),me(Me) {
00793         m->RequestSpaceBelow(.2);
00794     }
00795 
00796     ~ArmageTron_color_menuitem(){};
00797 
00798     virtual REAL SpaceRight(){return .2;}
00799 
00800 
00801     virtual void RenderBackground(){
00802         //    static int count=0;
00803         /*
00804         while(rgb[0]+rgb[1]+rgb[2]<13){
00805           if (rgb[count]<15)
00806         rgb[count]++;
00807           count++;
00808           if (count>2)
00809         count=0;
00810         }
00811         */
00812 #ifndef DEDICATED
00813         if (!sr_glOut)
00814             return;
00815         uMenuItem::RenderBackground();
00816         REAL r = rgb[0]/15.0;
00817         REAL g = rgb[1]/15.0;
00818         REAL b = rgb[2]/15.0;
00819         se_MakeColorValid(r, g, b, 1.0f);
00820         glColor3f(r, g, b);
00821         glRectf(.8,-.8,.98,-.98);
00822 #endif
00823     }
00824 
00825 };
00826 
00827 
00828 
00829 void sg_PlayerMenu(int Player){
00830     tOutput name;
00831     name.SetTemplateParameter(1, Player+1);
00832 
00833     name << "$player_menu_text";
00834 
00835 
00836     uMenu playerMenu(name);
00837 
00838     uMenu camera_menu("$player_camera_text");
00839     uMenu chat_menu("$player_chat_text");
00840     //  name.Clear();
00841     chat_menu.SetCenter(-.5);
00842 
00843     uMenuItemString *ic[MAX_INSTANT_CHAT];
00844 
00845     ePlayer *p = ePlayer::PlayerConfig(Player);
00846     if (!p)
00847         return;
00848 
00849     int i;
00850     for(i=MAX_INSTANT_CHAT-1;i>=0;i--){
00851         tOutput name;
00852         name.SetTemplateParameter(1, i+1);
00853         name << "$player_chat_chat";
00854         ic[i]=new uMenuItemString
00855               (&chat_menu,name,
00856                "$player_chat_chat_help",
00857                p->instantChatString[i], se_SpamMaxLen);
00858     }
00859 
00860     uMenuItemToggle al
00861     (&playerMenu,"$player_autologin_text",
00862      "$player_autologin_help",
00863      p->autoLogin);
00864 
00865     uMenuItemString gid(&playerMenu,
00866                       "$player_global_id_text",
00867                       "$player_global_id_help",
00868                       p->globalID, 400);
00869     gid.SetColorMode( rTextField::COLOR_IGNORE );
00870 
00871     uMenuItemToggle st
00872     (&playerMenu,"$player_stealth_text",
00873      "$player_stealth_help",
00874      p->stealth);
00875 
00876     uMenuItemToggle sp
00877     (&playerMenu,"$player_spectator_text",
00878      "$player_spectator_help",
00879      p->spectate);
00880 
00881     uMenuItemToggle pnt
00882     (&playerMenu,"$player_name_team_text",
00883      "$player_name_team_help",
00884      p->nameTeamAfterMe);
00885 
00886     uMenuItemInt npt
00887     (&playerMenu,"$player_num_per_team_text",
00888      "$player_num_per_team_help",
00889      p->favoriteNumberOfPlayersPerTeam, 1, 16, 1);
00890 
00891     ArmageTron_color_menuitem B(&playerMenu,"$player_blue_text",
00892                                 "$player_blue_help",
00893                                 p->rgb,2);
00894 
00895     ArmageTron_color_menuitem G(&playerMenu,"$player_green_text",
00896                                 "$player_green_help",
00897                                 p->rgb,1);
00898 
00899     ArmageTron_color_menuitem R(&playerMenu,"$player_red_text",
00900                                 "$player_red_help",
00901                                 p->rgb,0);
00902 
00903 
00904 
00905     uMenuItemSubmenu chm(&playerMenu,&chat_menu,
00906                          "$player_chat_chat_help");
00907 
00908     uMenuItemSubmenu cm(&playerMenu,&camera_menu,
00909                         "$player_camera_help");
00910 
00911     uMenuItemFunctionInt icc(&playerMenu,"$player_camera_input_text",
00912                              "$player_camera_input_help",
00913                              &su_InputConfigCamera,Player);
00914 
00915     uMenuItemFunctionInt inc(&playerMenu,"$player_input_text",
00916                              "$player_input_help",
00917                              &su_InputConfig,Player);
00918 
00919 
00920     camera_menu.SetCenter(.3);
00921 
00922     uMenuItemToggle cam_glance
00923     (&camera_menu,
00924      "$camera_smart_glance_custom_text",
00925      "$camera_smart_glance_custom_help",
00926      p->smartCustomGlance);
00927 
00928     uMenuItemToggle cis(&camera_menu,
00929                         "$player_camera_autoin_text",
00930                         "$player_camera_autoin_help",
00931                         p->autoSwitchIncam);
00932 
00933     uMenuItemToggle cim(&camera_menu,
00934                         "$player_camera_wobble_text",
00935                         "$player_camera_wobble_help",
00936                         p->wobbleIncam);
00937 
00938     uMenuItemToggle cic(&camera_menu,
00939                         "$player_camera_center_int_text",
00940                         "$player_camera_center_int_help",
00941                         p->centerIncamOnTurn);
00942 
00943     uMenuItemToggle al_s
00944     (&camera_menu,
00945      "$player_camera_smartcam_text",
00946      "$player_camera_smartcam_help",
00947      p->allowCam[CAMERA_SMART]);
00948 
00949     uMenuItemToggle al_f
00950     (&camera_menu,
00951      "$player_camera_fixed_text",
00952      "$player_camera_fixed_help",
00953      p->allowCam[CAMERA_FOLLOW]);
00954 
00955 
00956     uMenuItemToggle al_fr
00957     (&camera_menu,
00958      "$player_camera_free_text",
00959      "$player_camera_free_help",
00960      p->allowCam[CAMERA_FREE]);
00961 
00962     uMenuItemToggle al_c
00963     (&camera_menu,
00964      "$player_camera_custom_text",
00965      "$player_camera_custom_help",
00966      p->allowCam[CAMERA_CUSTOM]);
00967 
00968     uMenuItemToggle al_sc
00969     (&camera_menu,
00970      "$player_camera_server_custom_text",
00971      "$player_camera_server_custom_help",
00972      p->allowCam[CAMERA_SERVER_CUSTOM]);
00973 
00974     uMenuItemToggle al_i
00975     (&camera_menu,
00976      "$player_camera_incam_text",
00977      "$player_camera_incam_help",
00978      p->allowCam[CAMERA_IN]);
00979 
00980     uMenuItemToggle al_m
00981     (&camera_menu,
00982      "$player_camera_mercam_text",
00983      "$player_camera_mercam_help",
00984      p->allowCam[CAMERA_MER]);
00985 
00986     uMenuItemInt cam_fov
00987     (&camera_menu,
00988      "$player_camera_fov_text",
00989      "$player_camera_fov_help",
00990      p->startFOV,30,120,5);
00991 
00992     uMenuItemSelection<eCamMode> cam_s
00993     (&camera_menu,
00994      "$player_camera_initial_text",
00995      "$player_camera_initial_help",
00996      p->startCamera);
00997 
00998     cam_s.NewChoice("$player_camera_initial_scust_text","$player_camera_initial_scust_help",CAMERA_SERVER_CUSTOM);
00999     cam_s.NewChoice("$player_camera_initial_cust_text","$player_camera_initial_cust_help",CAMERA_CUSTOM);
01000     cam_s.NewChoice("$player_camera_initial_int_text","$player_camera_initial_int_help",CAMERA_IN);
01001     cam_s.NewChoice("$player_camera_initial_smrt_text","$player_camera_initial_smrt_help",CAMERA_SMART);
01002     cam_s.NewChoice("$player_camera_initial_ext_text","$player_camera_initial_ext_help",CAMERA_FOLLOW);
01003     cam_s.NewChoice("$player_camera_initial_free_text","$player_camera_initial_free_help",CAMERA_FREE);
01004     cam_s.NewChoice("$player_camera_initial_mer_text","$player_camera_initial_mer_help",CAMERA_MER);
01005 
01006     uMenuItemString tn(&playerMenu,
01007                        "$player_teamname_text",
01008                        "$player_teamname_help",
01009                        p->teamname, 16);
01010 
01011     uMenuItemString n(&playerMenu,
01012                       "$player_name_text",
01013                       "$player_name_help",
01014                       p->name, 16);
01015 
01016     playerMenu.Enter();
01017 
01018     for(i=MAX_INSTANT_CHAT-1; i>=0; i--)
01019         delete ic[i];
01020 
01021 
01022     // request network synchronisation if the server can handle it
01023     static nVersionFeature inGameRenames( 5 );
01024     if ( inGameRenames.Supported() )
01025     {
01026         ePlayerNetID::Update();
01027         ePlayer::SendAuthNames();
01028     }
01029 
01030     /*
01031     for (i=MAX_PLAYERS-1; i>=0; i--)
01032     {
01033         if (ePlayer::PlayerIsInGame(i))
01034         {
01035             ePlayer* p = ePlayer::PlayerConfig(i);
01036             if (p->netPlayer)
01037                 p->netPlayer->RequestSync();
01038         }
01039     }
01040     */
01041 }
01042 
01043 
01044 AA_VOIDFUNC viewport_menu_x;
01045 
01046 
01047 
01048 
01049 
01050 
01051 // from gGame.C
01052 //extern int pingCharity;
01053 
01054 
01055 void sg_PlayerMenu(){
01056     uMenu Player_men("$player_mainmenu_text");
01057 
01058 
01059     uMenuItemFunction vp_selec(&Player_men,
01060                                "$viewport_assign_text",
01061                                "$viewport_assign_help",
01062                                &viewport_menu_x);
01063 
01064     ArmageTron_viewport_menuitem vp(&Player_men);
01065     uMenuItemFunctionInt  *names[MAX_PLAYERS];
01066 
01067     int i;
01068 
01069     for(i=MAX_PLAYERS-1;i>=0;i--){
01070         tOutput title;
01071         title.SetTemplateParameter(1, i+1);
01072         title << "$player_menu_text";
01073 
01074         tOutput help;
01075         help.SetTemplateParameter(1, i+1);
01076         help << "$player_menu_help";
01077 
01078         names[i]=new uMenuItemFunctionInt(&Player_men,
01079                                           title,
01080                                           help,
01081                                           sg_PlayerMenu,i);
01082     }
01083 
01084 
01085     Player_men.Enter();
01086 
01087     //  ePlayerNetID::Update();
01088     for(i=MAX_VIEWPORTS-1;i>=0;i--){
01089         delete names[i];
01090     }
01091 }
01092 
01093 
01094 
01095 
01096 void viewport_menu_x(void){
01097     uMenu sg_PlayerMenu("$viewport_assign_text");
01098 
01099     ArmageTronPlayer_to_viewport_menuitem *select[MAX_VIEWPORTS];
01100 
01101     int i;
01102     for(i=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;i>=0;i--){
01103         select[i]=new ArmageTronPlayer_to_viewport_menuitem(&sg_PlayerMenu,i);
01104     }
01105 
01106     // ArmageTron_viewport_menuitem vp(&sg_PlayerMenu);
01107 
01108     sg_PlayerMenu.Enter();
01109 
01110     for(i=rViewportConfiguration::s_viewportConfigurations[rViewportConfiguration::next_conf_num]->num_viewports-1;i>=0;i--){
01111         delete select[i];
01112     }
01113 }
01114 
01115 
01116 static uActionGlobal con_input( "CONSOLE_INPUT" );
01117 
01118 
01119 static uActionGlobal screenshot( "SCREENSHOT" );
01120 
01121 static uActionGlobal togglefullscreen( "TOGGLE_FULLSCREEN" );
01122 
01123 static bool screenshot_func(REAL x){
01124     if (x>0){
01125 #ifndef DEDICATED
01126         sr_screenshotIsPlanned=true;
01127 #endif
01128     }
01129 
01130     return true;
01131 }
01132 
01133 static bool con_func(REAL x){
01134     if (x>0){
01135         sg_ConsoleInput();
01136     }
01137 
01138     return true;
01139 }
01140 
01141 static bool toggle_fullscreen_func( REAL x )
01142 {
01143 #ifndef DEDICATED
01144 #ifdef DEBUG
01145     // don't toggle fullscreen while playing back in debug mode, that's annoying
01146     if ( tRecorder::IsPlayingBack() )
01147         return true;
01148 #endif
01149 
01150     // only do anything if the application is active (work around odd bug)
01151     if ( x > 0 && ( SDL_GetAppState() & SDL_APPACTIVE ) )
01152     {
01153         currentScreensetting.fullscreen = !currentScreensetting.fullscreen;
01154         sr_ReinitDisplay();
01155     }
01156 #endif
01157 
01158     return true;
01159 }
01160 
01161 static uActionGlobalFunc gaf_ss(&screenshot,&screenshot_func, true );
01162 static uActionGlobalFunc gaf_md(&con_input,&con_func);
01163 static uActionGlobalFunc gaf_tf(&togglefullscreen,&toggle_fullscreen_func, true );

Generated on Sat Mar 15 22:56:08 2008 for Armagetron Advanced by  doxygen 1.5.4