MenuHandler_Shell.cpp (51513B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA. 25 26 =========================================================================== 27 */ 28 #pragma hdrstop 29 #include "../../idLib/precompiled.h" 30 #include "../Game_local.h" 31 32 33 extern idCVar g_demoMode; 34 35 static const int PEER_UPDATE_INTERVAL = 500; 36 static const int MAX_MENU_OPTIONS = 6; 37 38 void idMenuHandler_Shell::Update() { 39 40 //#if defined ( ID_360 ) 41 // if ( deviceRequestedSignal.Wait( 0 ) ) { 42 // // This clears the delete save dialog to catch the case of a delete confirmation for an old device after we've changed the device. 43 // common->Dialog().ClearDialog( GDM_DELETE_SAVE ); 44 // common->Dialog().ClearDialog( GDM_DELETE_CORRUPT_SAVEGAME ); 45 // common->Dialog().ClearDialog( GDM_RESTORE_CORRUPT_SAVEGAME ); 46 // common->Dialog().ClearDialog( GDM_LOAD_DAMAGED_FILE ); 47 // common->Dialog().ClearDialog( GDM_OVERWRITE_SAVE ); 48 // 49 // } 50 //#endif 51 52 if ( gui == NULL || !gui->IsActive() ) { 53 return; 54 } 55 56 if ( ( IsPacifierVisible() || common->Dialog().IsDialogActive() ) && actionRepeater.isActive ) { 57 ClearWidgetActionRepeater(); 58 } 59 60 if ( nextState != state ) { 61 62 if ( introGui != NULL && introGui->IsActive() ) { 63 gui->StopSound(); 64 showingIntro = false; 65 introGui->Activate( false ); 66 PlaySound( GUI_SOUND_MUSIC ); 67 } 68 69 if ( nextState == SHELL_STATE_PRESS_START ) { 70 HidePacifier(); 71 nextScreen = SHELL_AREA_START; 72 transition = MENU_TRANSITION_SIMPLE; 73 state = nextState; 74 if ( menuBar != NULL && gui != NULL ) { 75 menuBar->ClearSprite(); 76 } 77 } else if ( nextState == SHELL_STATE_IDLE ) { 78 HidePacifier(); 79 if ( nextScreen == SHELL_AREA_START || nextScreen == SHELL_AREA_PARTY_LOBBY || nextScreen == SHELL_AREA_GAME_LOBBY || nextScreen == SHELL_AREA_INVALID ) { 80 nextScreen = SHELL_AREA_ROOT; 81 } 82 83 if ( menuBar != NULL && gui != NULL ) { 84 idSWFScriptObject & root = gui->GetRootObject(); 85 menuBar->BindSprite( root ); 86 SetupPCOptions(); 87 } 88 transition = MENU_TRANSITION_SIMPLE; 89 state = nextState; 90 } else if ( nextState == SHELL_STATE_PARTY_LOBBY ) { 91 HidePacifier(); 92 nextScreen = SHELL_AREA_PARTY_LOBBY; 93 transition = MENU_TRANSITION_SIMPLE; 94 state = nextState; 95 } else if ( nextState == SHELL_STATE_GAME_LOBBY ) { 96 HidePacifier(); 97 if ( state != SHELL_STATE_IN_GAME ) { 98 timeRemaining = WAIT_START_TIME_LONG; 99 idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms(); 100 /*if ( MatchTypeIsPrivate( matchParameters.matchFlags ) && ActiveScreen() == SHELL_AREA_PARTY_LOBBY ) { 101 timeRemaining = 0; 102 session->StartMatch(); 103 state = SHELL_STATE_IN_GAME; 104 } else {*/ 105 nextScreen = SHELL_AREA_GAME_LOBBY; 106 transition = MENU_TRANSITION_SIMPLE; 107 //} 108 109 state = nextState; 110 } 111 } else if ( nextState == SHELL_STATE_PAUSED ) { 112 HidePacifier(); 113 transition = MENU_TRANSITION_SIMPLE; 114 115 if ( gameComplete ) { 116 nextScreen = SHELL_AREA_CREDITS; 117 } else { 118 nextScreen = SHELL_AREA_ROOT; 119 } 120 121 state = nextState; 122 } else if ( nextState == SHELL_STATE_CONNECTING ) { 123 ShowPacifier( "#str_dlg_connecting" ); 124 state = nextState; 125 } else if ( nextState == SHELL_STATE_SEARCHING ) { 126 ShowPacifier( "#str_online_mpstatus_searching" ); 127 state = nextState; 128 } 129 } 130 131 if ( activeScreen != nextScreen ) { 132 133 ClearWidgetActionRepeater(); 134 UpdateBGState(); 135 136 if ( nextScreen == SHELL_AREA_INVALID ) { 137 138 if ( activeScreen > SHELL_AREA_INVALID && activeScreen < SHELL_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) { 139 menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) ); 140 } 141 142 if ( cmdBar != NULL ) { 143 cmdBar->ClearAllButtons(); 144 cmdBar->Update(); 145 } 146 147 idSWFSpriteInstance * bg = gui->GetRootObject().GetNestedSprite( "pause_bg" ); 148 idSWFSpriteInstance * edging = gui->GetRootObject().GetNestedSprite( "_fullscreen" ); 149 150 if ( bg != NULL ) { 151 bg->PlayFrame( "rollOff" ); 152 } 153 154 if ( edging != NULL ) { 155 edging->PlayFrame( "rollOff" ); 156 } 157 158 } else { 159 160 if ( activeScreen > SHELL_AREA_INVALID && activeScreen < SHELL_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) { 161 menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) ); 162 } 163 164 if ( nextScreen > SHELL_AREA_INVALID && nextScreen < SHELL_NUM_AREAS && menuScreens[ nextScreen ] != NULL ) { 165 menuScreens[ nextScreen ]->UpdateCmds(); 166 menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>(transition) ); 167 } 168 } 169 170 transition = MENU_TRANSITION_INVALID; 171 activeScreen = nextScreen; 172 } 173 174 if ( cmdBar != NULL && cmdBar->GetSprite() ) { 175 if ( common->Dialog().IsDialogActive() ) { 176 cmdBar->GetSprite()->SetVisible( false ); 177 } else { 178 cmdBar->GetSprite()->SetVisible( true ); 179 } 180 } 181 182 idMenuHandler::Update(); 183 184 if ( activeScreen == nextScreen && activeScreen == SHELL_AREA_LEADERBOARDS ) { 185 idMenuScreen_Shell_Leaderboards * screen = dynamic_cast< idMenuScreen_Shell_Leaderboards * >( menuScreens[ SHELL_AREA_LEADERBOARDS ] ); 186 if ( screen != NULL ) { 187 screen->PumpLBCache(); 188 screen->RefreshLeaderboard(); 189 } 190 } else if ( activeScreen == nextScreen && activeScreen == SHELL_AREA_PARTY_LOBBY ) { 191 idMenuScreen_Shell_PartyLobby * screen = dynamic_cast< idMenuScreen_Shell_PartyLobby * >( menuScreens[ SHELL_AREA_PARTY_LOBBY ] ); 192 if ( screen != NULL ) { 193 screen->UpdateLobby(); 194 } 195 } else if ( activeScreen == nextScreen && activeScreen == SHELL_AREA_GAME_LOBBY ) { 196 if ( session->GetActingGameStateLobbyBase().IsHost() ) { 197 198 if ( timeRemaining <= 0 && state != SHELL_STATE_IN_GAME ) { 199 session->StartMatch(); 200 state = SHELL_STATE_IN_GAME; 201 } 202 203 idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms(); 204 if ( !MatchTypeIsPrivate( matchParameters.matchFlags ) ) { 205 if ( Sys_Milliseconds() >= nextPeerUpdateMs ) { 206 nextPeerUpdateMs = Sys_Milliseconds() + PEER_UPDATE_INTERVAL; 207 byte buffer[ 128 ]; 208 idBitMsg msg; 209 msg.InitWrite( buffer, sizeof( buffer ) ); 210 msg.WriteLong( timeRemaining ); 211 session->GetActingGameStateLobbyBase().SendReliable( GAME_RELIABLE_MESSAGE_LOBBY_COUNTDOWN, msg, false ); 212 } 213 } 214 } 215 216 idMenuScreen_Shell_GameLobby * screen = dynamic_cast< idMenuScreen_Shell_GameLobby * >( menuScreens[ SHELL_AREA_GAME_LOBBY ] ); 217 if ( screen != NULL ) { 218 screen->UpdateLobby(); 219 } 220 } 221 222 if ( introGui != NULL && introGui->IsActive() ) { 223 introGui->Render( renderSystem, Sys_Milliseconds() ); 224 } 225 226 if ( continueWaitForEnumerate ) { 227 if ( !session->GetSaveGameManager().IsWorking() ) { 228 continueWaitForEnumerate = false; 229 common->Dialog().ClearDialog( GDM_REFRESHING ); 230 idMenuScreen_Shell_Singleplayer * screen = dynamic_cast< idMenuScreen_Shell_Singleplayer * >( menuScreens[ SHELL_AREA_CAMPAIGN ] ); 231 if ( screen != NULL ) { 232 screen->ContinueGame(); 233 } 234 } 235 } 236 } 237 238 /* 239 ======================== 240 idMenuHandler_Shell::SetCanContinue 241 ======================== 242 */ 243 void idMenuHandler_Shell::SetCanContinue( bool valid ) { 244 245 idMenuScreen_Shell_Singleplayer * screen = dynamic_cast< idMenuScreen_Shell_Singleplayer * >( menuScreens[ SHELL_AREA_CAMPAIGN ] ); 246 if ( screen != NULL ) { 247 screen->SetCanContinue( valid ); 248 } 249 250 } 251 252 /* 253 ======================== 254 idMenuHandler_Shell::HandleGuiEvent 255 ======================== 256 */ 257 bool idMenuHandler_Shell::HandleGuiEvent( const sysEvent_t * sev ) { 258 259 if ( IsPacifierVisible() ) { 260 return true; 261 } 262 263 if ( showingIntro ) { 264 return true; 265 } 266 267 if ( waitForBinding ) { 268 269 if ( sev->evType == SE_KEY && sev->evValue2 == 1 ) { 270 271 if ( sev->evValue >= K_JOY_STICK1_UP && sev->evValue <= K_JOY_STICK2_RIGHT ) { 272 return true; 273 } 274 275 if ( sev->evValue == K_ESCAPE ) { 276 waitForBinding = false; 277 278 idMenuScreen_Shell_Bindings * bindScreen = dynamic_cast< idMenuScreen_Shell_Bindings * >( menuScreens[ SHELL_AREA_KEYBOARD ] ); 279 if ( bindScreen != NULL ) { 280 bindScreen->ToggleWait( false ); 281 bindScreen->Update(); 282 } 283 284 } else { 285 286 if ( idStr::Icmp( idKeyInput::GetBinding( sev->evValue ), "" ) == 0 ) { // no existing binding found 287 288 idKeyInput::SetBinding( sev->evValue, waitBind ); 289 290 idMenuScreen_Shell_Bindings * bindScreen = dynamic_cast< idMenuScreen_Shell_Bindings * >( menuScreens[ SHELL_AREA_KEYBOARD ] ); 291 if ( bindScreen != NULL ) { 292 bindScreen->SetBindingChanged( true ); 293 bindScreen->UpdateBindingDisplay(); 294 bindScreen->ToggleWait( false ); 295 bindScreen->Update(); 296 } 297 298 waitForBinding = false; 299 300 } else { // binding found prompt to change 301 302 const char * curBind = idKeyInput::GetBinding( sev->evValue ); 303 304 if ( idStr::Icmp( waitBind, curBind ) == 0 ) { 305 idKeyInput::SetBinding( sev->evValue, "" ); 306 idMenuScreen_Shell_Bindings * bindScreen = dynamic_cast< idMenuScreen_Shell_Bindings * >( menuScreens[ SHELL_AREA_KEYBOARD ] ); 307 if ( bindScreen != NULL ) { 308 bindScreen->SetBindingChanged( true ); 309 bindScreen->UpdateBindingDisplay(); 310 bindScreen->ToggleWait( false ); 311 bindScreen->Update(); 312 waitForBinding = false; 313 } 314 } else { 315 316 idMenuScreen_Shell_Bindings * bindScreen = dynamic_cast< idMenuScreen_Shell_Bindings * >( menuScreens[ SHELL_AREA_KEYBOARD ] ); 317 if ( bindScreen != NULL ) { 318 class idSWFScriptFunction_RebindKey : public idSWFScriptFunction_RefCounted { 319 public: 320 idSWFScriptFunction_RebindKey( idMenuScreen_Shell_Bindings * _menu, gameDialogMessages_t _msg, bool _accept, idMenuHandler_Shell * _mgr, int _key, const char * _bind ) { 321 menu = _menu; 322 msg = _msg; 323 accept = _accept; 324 mgr = _mgr; 325 key = _key; 326 bind = _bind; 327 } 328 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 329 common->Dialog().ClearDialog( msg ); 330 mgr->ClearWaitForBinding(); 331 menu->ToggleWait( false ); 332 if ( accept ) { 333 idKeyInput::SetBinding( key, bind ); 334 menu->SetBindingChanged( true ); 335 menu->UpdateBindingDisplay(); 336 menu->Update(); 337 } 338 return idSWFScriptVar(); 339 } 340 private: 341 idMenuScreen_Shell_Bindings * menu; 342 gameDialogMessages_t msg; 343 bool accept; 344 idMenuHandler_Shell * mgr; 345 int key; 346 const char * bind; 347 }; 348 349 common->Dialog().AddDialog( GDM_BINDING_ALREDY_SET, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_RebindKey( bindScreen, GDM_BINDING_ALREDY_SET, true, this, sev->evValue, waitBind ), new idSWFScriptFunction_RebindKey( bindScreen, GDM_BINDING_ALREDY_SET, false, this, sev->evValue, waitBind ), false ); 350 } 351 352 } 353 } 354 } 355 } 356 357 return true; 358 } 359 360 return idMenuHandler::HandleGuiEvent( sev ); 361 362 } 363 364 /* 365 ======================== 366 idMenuHandler_Shell::Initialize 367 ======================== 368 */ 369 void idMenuHandler_Shell::Initialize( const char * swfFile, idSoundWorld * sw ) { 370 idMenuHandler::Initialize( swfFile, sw ); 371 372 //--------------------- 373 // Initialize the menus 374 //--------------------- 375 #define BIND_SHELL_SCREEN( screenId, className, menuHandler ) \ 376 menuScreens[ (screenId) ] = new (TAG_SWF) className(); \ 377 menuScreens[ (screenId) ]->Initialize( menuHandler ); \ 378 menuScreens[ (screenId) ]->AddRef(); 379 380 for ( int i = 0; i < SHELL_NUM_AREAS; ++i ) { 381 menuScreens[ i ] = NULL; 382 } 383 384 // done for build game purposes so these get touched 385 delete new idSWF( "doomIntro", NULL ); 386 delete new idSWF( "roeIntro", NULL ); 387 delete new idSWF( "leIntro", NULL ); 388 389 if ( inGame ) { 390 BIND_SHELL_SCREEN( SHELL_AREA_ROOT, idMenuScreen_Shell_Pause, this ); 391 BIND_SHELL_SCREEN( SHELL_AREA_SETTINGS, idMenuScreen_Shell_Settings, this ); 392 BIND_SHELL_SCREEN( SHELL_AREA_LOAD, idMenuScreen_Shell_Load, this ); 393 BIND_SHELL_SCREEN( SHELL_AREA_SYSTEM_OPTIONS, idMenuScreen_Shell_SystemOptions, this ); 394 BIND_SHELL_SCREEN( SHELL_AREA_GAME_OPTIONS, idMenuScreen_Shell_GameOptions, this ); 395 BIND_SHELL_SCREEN( SHELL_AREA_SAVE, idMenuScreen_Shell_Save, this ); 396 BIND_SHELL_SCREEN( SHELL_AREA_STEREOSCOPICS, idMenuScreen_Shell_Stereoscopics, this ); 397 BIND_SHELL_SCREEN( SHELL_AREA_CONTROLS, idMenuScreen_Shell_Controls, this ); 398 BIND_SHELL_SCREEN( SHELL_AREA_KEYBOARD, idMenuScreen_Shell_Bindings, this ); 399 BIND_SHELL_SCREEN( SHELL_AREA_RESOLUTION, idMenuScreen_Shell_Resolution, this ); 400 BIND_SHELL_SCREEN( SHELL_AREA_CONTROLLER_LAYOUT, idMenuScreen_Shell_ControllerLayout, this ); 401 402 BIND_SHELL_SCREEN( SHELL_AREA_GAMEPAD, idMenuScreen_Shell_Gamepad, this ); 403 BIND_SHELL_SCREEN( SHELL_AREA_CREDITS, idMenuScreen_Shell_Credits, this ); 404 405 } else { 406 BIND_SHELL_SCREEN( SHELL_AREA_START, idMenuScreen_Shell_PressStart, this ); 407 BIND_SHELL_SCREEN( SHELL_AREA_ROOT, idMenuScreen_Shell_Root, this ); 408 BIND_SHELL_SCREEN( SHELL_AREA_CAMPAIGN, idMenuScreen_Shell_Singleplayer, this ); 409 BIND_SHELL_SCREEN( SHELL_AREA_SETTINGS, idMenuScreen_Shell_Settings, this ); 410 BIND_SHELL_SCREEN( SHELL_AREA_LOAD, idMenuScreen_Shell_Load, this ); 411 BIND_SHELL_SCREEN( SHELL_AREA_NEW_GAME, idMenuScreen_Shell_NewGame, this ); 412 BIND_SHELL_SCREEN( SHELL_AREA_SYSTEM_OPTIONS, idMenuScreen_Shell_SystemOptions, this ); 413 BIND_SHELL_SCREEN( SHELL_AREA_GAME_OPTIONS, idMenuScreen_Shell_GameOptions, this ); 414 BIND_SHELL_SCREEN( SHELL_AREA_PARTY_LOBBY, idMenuScreen_Shell_PartyLobby, this ); 415 BIND_SHELL_SCREEN( SHELL_AREA_GAME_LOBBY, idMenuScreen_Shell_GameLobby, this ); 416 BIND_SHELL_SCREEN( SHELL_AREA_STEREOSCOPICS, idMenuScreen_Shell_Stereoscopics, this ); 417 BIND_SHELL_SCREEN( SHELL_AREA_DIFFICULTY, idMenuScreen_Shell_Difficulty, this ); 418 BIND_SHELL_SCREEN( SHELL_AREA_CONTROLS, idMenuScreen_Shell_Controls, this ); 419 BIND_SHELL_SCREEN( SHELL_AREA_KEYBOARD, idMenuScreen_Shell_Bindings, this ); 420 BIND_SHELL_SCREEN( SHELL_AREA_RESOLUTION, idMenuScreen_Shell_Resolution, this ); 421 BIND_SHELL_SCREEN( SHELL_AREA_CONTROLLER_LAYOUT, idMenuScreen_Shell_ControllerLayout, this ); 422 BIND_SHELL_SCREEN( SHELL_AREA_DEV, idMenuScreen_Shell_Dev, this ); 423 BIND_SHELL_SCREEN( SHELL_AREA_LEADERBOARDS, idMenuScreen_Shell_Leaderboards, this ); 424 BIND_SHELL_SCREEN( SHELL_AREA_GAMEPAD, idMenuScreen_Shell_Gamepad, this ); 425 BIND_SHELL_SCREEN( SHELL_AREA_MATCH_SETTINGS, idMenuScreen_Shell_MatchSettings, this ); 426 BIND_SHELL_SCREEN( SHELL_AREA_MODE_SELECT, idMenuScreen_Shell_ModeSelect, this ); 427 BIND_SHELL_SCREEN( SHELL_AREA_BROWSER, idMenuScreen_Shell_GameBrowser, this ); 428 BIND_SHELL_SCREEN( SHELL_AREA_CREDITS, idMenuScreen_Shell_Credits, this ); 429 430 doom3Intro = declManager->FindMaterial( "gui/intro/introloop" ); 431 roeIntro = declManager->FindMaterial( "gui/intro/marsflyby" ); 432 433 //typeSoundShader = declManager->FindSound( "gui/teletype/print_text", true ); 434 typeSoundShader = declManager->FindSound( "gui/teletype/print_text", true ); 435 declManager->FindSound( "gui/doomintro", true ); 436 437 marsRotation = declManager->FindMaterial( "gui/shell/mars_rotation" ); 438 } 439 440 menuBar = new (TAG_SWF) idMenuWidget_MenuBar(); 441 menuBar->SetSpritePath( "pcBar" ); 442 menuBar->Initialize( this ); 443 menuBar->SetNumVisibleOptions( MAX_MENU_OPTIONS ); 444 menuBar->SetWrappingAllowed( true ); 445 menuBar->SetButtonSpacing( 45.0f ); 446 while ( menuBar->GetChildren().Num() < MAX_MENU_OPTIONS ) { 447 idMenuWidget_MenuButton * const navButton = new (TAG_SWF) idMenuWidget_MenuButton(); 448 idMenuScreen_Shell_Root * rootScreen = dynamic_cast< idMenuScreen_Shell_Root * >( menuScreens[ SHELL_AREA_ROOT ] ); 449 if ( rootScreen != NULL ) { 450 navButton->RegisterEventObserver( rootScreen->GetHelpWidget() ); 451 } 452 menuBar->AddChild( navButton ); 453 } 454 AddChild( menuBar ); 455 456 // 457 // command bar 458 // 459 cmdBar = new (TAG_SWF) idMenuWidget_CommandBar(); 460 cmdBar->SetAlignment( idMenuWidget_CommandBar::LEFT ); 461 cmdBar->SetSpritePath( "prompts" ); 462 cmdBar->Initialize( this ); 463 AddChild( cmdBar ); 464 465 pacifier = new ( TAG_SWF ) idMenuWidget(); 466 pacifier->SetSpritePath( "pacifier" ); 467 AddChild( pacifier ); 468 469 // precache sounds 470 // don't load gui music for the pause menu to save some memory 471 const idSoundShader * soundShader = NULL; 472 if ( !inGame ) { 473 soundShader = declManager->FindSound( "gui/menu_music", true ); 474 if ( soundShader != NULL ) { 475 sounds[ GUI_SOUND_MUSIC ] = soundShader->GetName(); 476 } 477 } else { 478 idStrStatic< MAX_OSPATH > shortMapName = gameLocal.GetMapFileName(); 479 shortMapName.StripFileExtension(); 480 shortMapName.StripLeading( "maps/" ); 481 shortMapName.StripLeading( "game/" ); 482 if ( ( shortMapName.Icmp( "le_hell_post" ) == 0 ) || ( shortMapName.Icmp( "hellhole" ) == 0 ) || ( shortMapName.Icmp( "hell" ) == 0 ) ) { 483 soundShader = declManager->FindSound( "hell_music_credits", true ); 484 if ( soundShader != NULL ) { 485 sounds[ GUI_SOUND_MUSIC ] = soundShader->GetName(); 486 } 487 } 488 } 489 490 soundShader = declManager->FindSound( "gui/list_scroll", true ); 491 if ( soundShader != NULL ) { 492 sounds[ GUI_SOUND_SCROLL ] = soundShader->GetName(); 493 } 494 soundShader = declManager->FindSound( "gui/btn_PDA_advance", true ); 495 if ( soundShader != NULL ) { 496 sounds[ GUI_SOUND_ADVANCE ] = soundShader->GetName(); 497 } 498 soundShader = declManager->FindSound( "gui/btn_PDA_back", true ); 499 if ( soundShader != NULL ) { 500 sounds[ GUI_SOUND_BACK ] = soundShader->GetName(); 501 } 502 soundShader = declManager->FindSound( "gui/menu_build_on", true ); 503 if ( soundShader != NULL ) { 504 sounds[ GUI_SOUND_BUILD_ON ] = soundShader->GetName(); 505 } 506 soundShader = declManager->FindSound( "gui/pda_next_tab", true ); 507 if ( soundShader != NULL ) { 508 sounds[ GUI_SOUND_BUILD_ON ] = soundShader->GetName(); 509 } 510 soundShader = declManager->FindSound( "gui/btn_set_focus", true ); 511 if ( soundShader != NULL ) { 512 sounds[ GUI_SOUND_FOCUS ] = soundShader->GetName(); 513 } 514 soundShader = declManager->FindSound( "gui/btn_roll_over", true ); 515 if ( soundShader != NULL ) { 516 sounds[ GUI_SOUND_ROLL_OVER ] = soundShader->GetName(); 517 } 518 soundShader = declManager->FindSound( "gui/btn_roll_out", true ); 519 if ( soundShader != NULL ) { 520 sounds[ GUI_SOUND_ROLL_OUT ] = soundShader->GetName(); 521 } 522 523 class idPauseGUIClose : public idSWFScriptFunction_RefCounted { 524 public: 525 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 526 gameLocal.Shell_Show( false ); 527 return idSWFScriptVar(); 528 } 529 }; 530 531 if ( gui != NULL ) { 532 gui->SetGlobal( "closeMenu", new idPauseGUIClose() ); 533 } 534 } 535 536 /* 537 ======================== 538 idMenuHandler_Shell::Cleanup 539 ======================== 540 */ 541 void idMenuHandler_Shell::Cleanup() { 542 idMenuHandler::Cleanup(); 543 544 delete introGui; 545 introGui = NULL; 546 } 547 548 /* 549 ======================== 550 idMenuHandler_Shell::ActivateMenu 551 ======================== 552 */ 553 void idMenuHandler_Shell::ActivateMenu( bool show ) { 554 555 if ( show && gui != NULL && gui->IsActive() ) { 556 return; 557 } else if ( !show && gui != NULL && !gui->IsActive() ) { 558 return; 559 } 560 561 562 if ( inGame ) { 563 idPlayer * player = gameLocal.GetLocalPlayer(); 564 if ( player != NULL ) { 565 if ( !show ) { 566 bool isDead = false; 567 if ( player->health <= 0 ) { 568 isDead = true; 569 } 570 571 if ( isDead && !common->IsMultiplayer() ) { 572 return; 573 } 574 } 575 } 576 } 577 578 idMenuHandler::ActivateMenu( show ); 579 if ( show ) { 580 581 if ( !inGame ) { 582 PlaySound( GUI_SOUND_MUSIC ); 583 584 if ( gui != NULL ) { 585 586 idSWFSpriteInstance * mars = gui->GetRootObject().GetNestedSprite( "mars" ); 587 if ( mars ) { 588 mars->stereoDepth = STEREO_DEPTH_TYPE_FAR; 589 590 idSWFSpriteInstance * planet = mars->GetScriptObject()->GetNestedSprite( "planet" ); 591 592 if ( marsRotation != NULL && planet != NULL ) { 593 const idMaterial * mat = marsRotation; 594 if ( mat != NULL ) { 595 int c = mat->GetNumStages(); 596 for ( int i = 0; i < c; i++ ) { 597 const shaderStage_t *stage = mat->GetStage( i ); 598 if ( stage != NULL && stage->texture.cinematic ) { 599 stage->texture.cinematic->ResetTime( Sys_Milliseconds() ); 600 } 601 } 602 } 603 604 planet->SetMaterial( mat ); 605 } 606 } 607 } 608 } 609 610 SetupPCOptions(); 611 612 if ( cmdBar != NULL ) { 613 cmdBar->ClearAllButtons(); 614 cmdBar->Update(); 615 } 616 617 } else { 618 ClearWidgetActionRepeater(); 619 nextScreen = SHELL_AREA_INVALID; 620 activeScreen = SHELL_AREA_INVALID; 621 nextState = SHELL_STATE_INVALID; 622 state = SHELL_STATE_INVALID; 623 smallFrameShowing = false; 624 largeFrameShowing = false; 625 bgShowing = true; 626 627 common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY ); 628 } 629 } 630 631 enum shellCommandsPC_t { 632 SHELL_CMD_DEMO0, 633 SHELL_CMD_DEMO1, 634 SHELL_CMD_DEV, 635 SHELL_CMD_CAMPAIGN, 636 SHELL_CMD_MULTIPLAYER, 637 SHELL_CMD_SETTINGS, 638 SHELL_CMD_CREDITS, 639 SHELL_CMD_QUIT 640 }; 641 642 /* 643 ======================== 644 idMenuHandler_Shell::SetPCOptionsVisible 645 ======================== 646 */ 647 void idMenuHandler_Shell::SetupPCOptions() { 648 649 if ( inGame ) { 650 return; 651 } 652 653 navOptions.Clear(); 654 655 if ( GetPlatform() == 2 && menuBar != NULL ) { 656 if ( g_demoMode.GetBool() ) { 657 navOptions.Append( "START DEMO" ); // START DEMO 658 if ( g_demoMode.GetInteger() == 2 ) { 659 navOptions.Append( "START PRESS DEMO" ); // START DEMO 660 } 661 navOptions.Append( "#str_swf_settings" ); // settings 662 navOptions.Append( "#str_swf_quit" ); // quit 663 664 idMenuWidget_MenuButton * buttonWidget = NULL; 665 int index = 0; 666 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 667 if ( buttonWidget != NULL ) { 668 buttonWidget->ClearEventActions(); 669 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_DEMO0, index ); 670 buttonWidget->SetDescription( "Launch the demo" ); 671 } 672 if ( g_demoMode.GetInteger() == 2 ) { 673 index++; 674 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 675 if ( buttonWidget != NULL ) { 676 buttonWidget->ClearEventActions(); 677 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_DEMO1, index ); 678 buttonWidget->SetDescription( "Launch the press Demo" ); 679 } 680 } 681 index++; 682 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 683 if ( buttonWidget != NULL ) { 684 buttonWidget->ClearEventActions(); 685 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_SETTINGS, index ); 686 buttonWidget->SetDescription( "#str_02206" ); 687 } 688 index++; 689 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 690 if ( buttonWidget != NULL ) { 691 buttonWidget->ClearEventActions(); 692 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_QUIT, index ); 693 buttonWidget->SetDescription( "#str_01976" ); 694 } 695 } else { 696 #if !defined ( ID_RETAIL ) 697 navOptions.Append( "DEV" ); // DEV 698 #endif 699 navOptions.Append( "#str_swf_campaign" ); // singleplayer 700 navOptions.Append( "#str_swf_multiplayer" ); // multiplayer 701 navOptions.Append( "#str_swf_settings" ); // settings 702 navOptions.Append( "#str_swf_credits" ); // credits 703 navOptions.Append( "#str_swf_quit" ); // quit 704 705 706 idMenuWidget_MenuButton * buttonWidget = NULL; 707 int index = 0; 708 #if !defined ( ID_RETAIL ) 709 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 710 if ( buttonWidget != NULL ) { 711 buttonWidget->ClearEventActions(); 712 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_DEV, index ); 713 buttonWidget->SetDescription( "View a list of maps available for play" ); 714 } 715 index++; 716 #endif 717 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 718 if ( buttonWidget != NULL ) { 719 buttonWidget->ClearEventActions(); 720 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_CAMPAIGN, index ); 721 buttonWidget->SetDescription( "#str_swf_campaign_desc" ); 722 } 723 index++; 724 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 725 if ( buttonWidget != NULL ) { 726 buttonWidget->ClearEventActions(); 727 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_MULTIPLAYER, index ); 728 buttonWidget->SetDescription( "#str_02215" ); 729 } 730 index++; 731 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 732 if ( buttonWidget != NULL ) { 733 buttonWidget->ClearEventActions(); 734 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_SETTINGS, index ); 735 buttonWidget->SetDescription( "#str_02206" ); 736 } 737 index++; 738 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 739 if ( buttonWidget != NULL ) { 740 buttonWidget->ClearEventActions(); 741 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_CREDITS, index ); 742 buttonWidget->SetDescription( "#str_02219" ); 743 } 744 index++; 745 buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( index ) ); 746 if ( buttonWidget != NULL ) { 747 buttonWidget->ClearEventActions(); 748 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, SHELL_CMD_QUIT, index ); 749 buttonWidget->SetDescription( "#str_01976" ); 750 } 751 } 752 } 753 754 if ( menuBar != NULL && gui != NULL ) { 755 idSWFScriptObject & root = gui->GetRootObject(); 756 if ( menuBar->BindSprite( root ) ) { 757 menuBar->GetSprite()->SetVisible( true ); 758 menuBar->SetListHeadings( navOptions ); 759 menuBar->Update(); 760 761 idMenuScreen_Shell_Root * menu = dynamic_cast< idMenuScreen_Shell_Root * >( menuScreens[ SHELL_AREA_ROOT ] ); 762 if ( menu != NULL ) { 763 const int activeIndex = menu->GetRootIndex(); 764 menuBar->SetViewIndex( activeIndex ); 765 menuBar->SetFocusIndex( activeIndex ); 766 } 767 768 } 769 } 770 } 771 772 /* 773 ======================== 774 idMenuHandler_Shell::HandleExitGameBtn 775 ======================== 776 */ 777 void idMenuHandler_Shell::HandleExitGameBtn() { 778 class idSWFScriptFunction_QuitDialog : public idSWFScriptFunction_RefCounted { 779 public: 780 idSWFScriptFunction_QuitDialog( gameDialogMessages_t _msg, int _accept ) { 781 msg = _msg; 782 accept = _accept; 783 } 784 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 785 common->Dialog().ClearDialog( msg ); 786 if ( accept == 1 ) { 787 common->Quit(); 788 } else if ( accept == -1 ) { 789 session->MoveToPressStart(); 790 } 791 return idSWFScriptVar(); 792 } 793 private: 794 gameDialogMessages_t msg; 795 int accept; 796 }; 797 798 idStaticList< idSWFScriptFunction *, 4 > callbacks; 799 idStaticList< idStrId, 4 > optionText; 800 callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 1 ) ); 801 callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 0 ) ); 802 callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, -1 ) ); 803 optionText.Append( idStrId( "#STR_SWF_ACCEPT" ) ); 804 optionText.Append( idStrId( "#STR_SWF_CANCEL" ) ); 805 optionText.Append( idStrId( "#str_swf_change_game" ) ); 806 807 common->Dialog().AddDynamicDialog( GDM_QUIT_GAME, callbacks, optionText, true, "" ); 808 } 809 810 /* 811 ======================== 812 idMenuHandler_Shell::HandleAction 813 ======================== 814 */ 815 bool idMenuHandler_Shell::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) { 816 817 if ( activeScreen == SHELL_AREA_INVALID ) { 818 return true; 819 } 820 821 widgetAction_t actionType = action.GetType(); 822 const idSWFParmList & parms = action.GetParms(); 823 824 if ( event.type == WIDGET_EVENT_COMMAND ) { 825 826 /*if ( activeScreen == SHELL_AREA_ROOT && navOptions.Num() > 0 ) { 827 return true; 828 }*/ 829 830 if ( menuScreens[ activeScreen ] != NULL && !forceHandled ) { 831 if ( menuScreens[ activeScreen ]->HandleAction( action, event, widget, true ) ) { 832 if ( actionType == WIDGET_ACTION_GO_BACK ) { 833 PlaySound( GUI_SOUND_BACK ); 834 } else { 835 PlaySound( GUI_SOUND_ADVANCE ); 836 } 837 return true; 838 } 839 } 840 } 841 842 switch ( actionType ) { 843 case WIDGET_ACTION_COMMAND: { 844 845 if ( parms.Num() < 2 ) { 846 return true; 847 } 848 849 int cmd = parms[0].ToInteger(); 850 851 if ( ( activeScreen == SHELL_AREA_GAME_LOBBY || activeScreen == SHELL_AREA_MATCH_SETTINGS ) && cmd != SHELL_CMD_QUIT && cmd != SHELL_CMD_MULTIPLAYER ) { 852 session->Cancel(); 853 session->Cancel(); 854 } else if ( ( activeScreen == SHELL_AREA_PARTY_LOBBY || activeScreen == SHELL_AREA_LEADERBOARDS || activeScreen == SHELL_AREA_BROWSER || activeScreen == SHELL_AREA_MODE_SELECT ) && cmd != SHELL_CMD_QUIT && cmd != SHELL_CMD_MULTIPLAYER ) { 855 session->Cancel(); 856 } 857 858 if ( cmd != SHELL_CMD_QUIT && ( nextScreen == SHELL_AREA_STEREOSCOPICS || nextScreen == SHELL_AREA_SYSTEM_OPTIONS || nextScreen == SHELL_AREA_GAME_OPTIONS || 859 nextScreen == SHELL_AREA_GAMEPAD || nextScreen == SHELL_AREA_MATCH_SETTINGS ) ) { 860 861 cvarSystem->SetModifiedFlags( CVAR_ARCHIVE ); 862 } 863 864 const int index = parms[1].ToInteger(); 865 menuBar->SetFocusIndex( index ); 866 menuBar->SetViewIndex( index ); 867 868 idMenuScreen_Shell_Root * menu = dynamic_cast< idMenuScreen_Shell_Root * >( menuScreens[ SHELL_AREA_ROOT ] ); 869 if ( menu != NULL ) { 870 menu->SetRootIndex( index ); 871 } 872 873 switch ( cmd ) { 874 case SHELL_CMD_DEMO0: { 875 cmdSystem->AppendCommandText( va( "devmap %s %d\n", "demo/enpro_e3_2012", 1 ) ); 876 break; 877 } 878 case SHELL_CMD_DEMO1: { 879 cmdSystem->AppendCommandText( va( "devmap %s %d\n", "game/le_hell", 2 ) ); 880 break; 881 } 882 case SHELL_CMD_DEV: { 883 nextScreen = SHELL_AREA_DEV; 884 transition = MENU_TRANSITION_SIMPLE; 885 break; 886 } 887 case SHELL_CMD_CAMPAIGN: { 888 nextScreen = SHELL_AREA_CAMPAIGN; 889 transition = MENU_TRANSITION_SIMPLE; 890 break; 891 } 892 case SHELL_CMD_MULTIPLAYER: { 893 idMatchParameters matchParameters; 894 matchParameters.matchFlags = DefaultPartyFlags; 895 session->CreatePartyLobby( matchParameters ); 896 break; 897 } 898 case SHELL_CMD_SETTINGS: { 899 nextScreen = SHELL_AREA_SETTINGS; 900 transition = MENU_TRANSITION_SIMPLE; 901 break; 902 } 903 case SHELL_CMD_CREDITS: { 904 nextScreen = SHELL_AREA_CREDITS; 905 transition = MENU_TRANSITION_SIMPLE; 906 break; 907 } 908 case SHELL_CMD_QUIT: { 909 HandleExitGameBtn(); 910 break; 911 } 912 } 913 914 return true; 915 } 916 } 917 918 return idMenuHandler::HandleAction( action, event, widget, forceHandled ); 919 } 920 921 /* 922 ======================== 923 idMenuHandler_Shell::GetMenuScreen 924 ======================== 925 */ 926 idMenuScreen * idMenuHandler_Shell::GetMenuScreen( int index ) { 927 928 if ( index < 0 || index >= SHELL_NUM_AREAS ) { 929 return NULL; 930 } 931 932 return menuScreens[ index ]; 933 } 934 935 /* 936 ======================== 937 idMenuHandler_Shell::ShowSmallFrame 938 ======================== 939 */ 940 void idMenuHandler_Shell::ShowSmallFrame( bool show ) { 941 942 if ( gui == NULL ) { 943 return; 944 } 945 946 idSWFSpriteInstance * smallFrame = gui->GetRootObject().GetNestedSprite( "smallFrame" ); 947 if ( smallFrame == NULL ) { 948 return; 949 } 950 951 smallFrame->stereoDepth = STEREO_DEPTH_TYPE_MID; 952 953 if ( show && !smallFrameShowing ) { 954 smallFrame->PlayFrame( "rollOn" ); 955 } else if ( !show && smallFrameShowing ) { 956 smallFrame->PlayFrame( "rollOff" ); 957 } 958 959 smallFrameShowing = show; 960 961 } 962 963 /* 964 ======================== 965 idMenuHandler_Shell::ShowMPFrame 966 ======================== 967 */ 968 void idMenuHandler_Shell::ShowMPFrame( bool show ) { 969 970 if ( gui == NULL ) { 971 return; 972 } 973 974 idSWFSpriteInstance * smallFrame = gui->GetRootObject().GetNestedSprite( "smallFrameMP" ); 975 if ( smallFrame == NULL ) { 976 return; 977 } 978 979 smallFrame->stereoDepth = STEREO_DEPTH_TYPE_MID; 980 981 if ( show && !largeFrameShowing ) { 982 smallFrame->PlayFrame( "rollOn" ); 983 } else if ( !show && largeFrameShowing ) { 984 smallFrame->PlayFrame( "rollOff" ); 985 } 986 987 largeFrameShowing = show; 988 989 } 990 991 /* 992 ======================== 993 idMenuHandler_Shell::ShowSmallFrame 994 ======================== 995 */ 996 void idMenuHandler_Shell::ShowLogo( bool show ) { 997 998 if ( gui == NULL ) { 999 return; 1000 } 1001 1002 if ( show == bgShowing ) { 1003 return; 1004 } 1005 1006 idSWFSpriteInstance * logo = gui->GetRootObject().GetNestedSprite( "logoInfo" ); 1007 idSWFSpriteInstance * bg = gui->GetRootObject().GetNestedSprite( "background" ); 1008 if ( logo != NULL && bg != NULL ) { 1009 1010 bg->stereoDepth = STEREO_DEPTH_TYPE_MID; 1011 1012 if ( show && !bgShowing ) { 1013 logo->PlayFrame( "rollOn" ); 1014 bg->PlayFrame( "rollOff" ); 1015 } else if ( !show && bgShowing ) { 1016 logo->PlayFrame( "rollOff" ); 1017 bg->PlayFrame( "rollOn" ); 1018 } 1019 } 1020 1021 bgShowing = show; 1022 1023 } 1024 1025 /* 1026 ======================== 1027 idMenuHandler_Shell::UpdateSavedGames 1028 ======================== 1029 */ 1030 void idMenuHandler_Shell::UpdateSavedGames() { 1031 if ( activeScreen == SHELL_AREA_LOAD ) { 1032 idMenuScreen_Shell_Load * screen = dynamic_cast< idMenuScreen_Shell_Load * >( menuScreens[ SHELL_AREA_LOAD ] ); 1033 if ( screen != NULL ) { 1034 screen->UpdateSaveEnumerations(); 1035 } 1036 } else if ( activeScreen == SHELL_AREA_SAVE ) { 1037 idMenuScreen_Shell_Save * screen = dynamic_cast< idMenuScreen_Shell_Save * >( menuScreens[ SHELL_AREA_SAVE ] ); 1038 if ( screen != NULL ) { 1039 screen->UpdateSaveEnumerations(); 1040 } 1041 } 1042 } 1043 1044 /* 1045 ======================== 1046 idMenuHandler_Shell::UpdateBGState 1047 ======================== 1048 */ 1049 void idMenuHandler_Shell::UpdateBGState() { 1050 1051 if ( smallFrameShowing ) { 1052 if ( nextScreen != SHELL_AREA_PLAYSTATION && nextScreen != SHELL_AREA_SETTINGS && nextScreen != SHELL_AREA_CAMPAIGN && nextScreen != SHELL_AREA_DEV ) { 1053 if ( nextScreen != SHELL_AREA_RESOLUTION && nextScreen != SHELL_AREA_GAMEPAD && nextScreen != SHELL_AREA_DIFFICULTY && nextScreen != SHELL_AREA_SYSTEM_OPTIONS && nextScreen != SHELL_AREA_GAME_OPTIONS && nextScreen != SHELL_AREA_NEW_GAME && nextScreen != SHELL_AREA_STEREOSCOPICS && 1054 nextScreen != SHELL_AREA_CONTROLS ) { 1055 ShowSmallFrame( false ); 1056 } 1057 } 1058 } else { 1059 if ( nextScreen == SHELL_AREA_RESOLUTION || nextScreen == SHELL_AREA_GAMEPAD || nextScreen == SHELL_AREA_PLAYSTATION || nextScreen == SHELL_AREA_SETTINGS || nextScreen == SHELL_AREA_CAMPAIGN || nextScreen == SHELL_AREA_CONTROLS || nextScreen == SHELL_AREA_DEV || nextScreen == SHELL_AREA_DIFFICULTY ) { 1060 ShowSmallFrame( true ); 1061 } 1062 } 1063 1064 if ( largeFrameShowing ) { 1065 if ( nextScreen != SHELL_AREA_PARTY_LOBBY && nextScreen != SHELL_AREA_GAME_LOBBY && nextScreen != SHELL_AREA_CONTROLLER_LAYOUT && nextScreen != SHELL_AREA_KEYBOARD && nextScreen != SHELL_AREA_LEADERBOARDS && nextScreen != SHELL_AREA_MATCH_SETTINGS && nextScreen != SHELL_AREA_MODE_SELECT && 1066 nextScreen != SHELL_AREA_BROWSER && nextScreen != SHELL_AREA_LOAD && nextScreen != SHELL_AREA_SAVE && nextScreen != SHELL_AREA_CREDITS ) { 1067 ShowMPFrame( false ); 1068 } 1069 } else { 1070 if ( nextScreen == SHELL_AREA_PARTY_LOBBY || nextScreen == SHELL_AREA_CONTROLLER_LAYOUT || nextScreen == SHELL_AREA_GAME_LOBBY || nextScreen == SHELL_AREA_KEYBOARD || nextScreen == SHELL_AREA_LEADERBOARDS || nextScreen == SHELL_AREA_MATCH_SETTINGS || nextScreen == SHELL_AREA_MODE_SELECT || 1071 nextScreen == SHELL_AREA_BROWSER || nextScreen == SHELL_AREA_LOAD || nextScreen == SHELL_AREA_SAVE || nextScreen == SHELL_AREA_CREDITS ) { 1072 ShowMPFrame( true ); 1073 } 1074 } 1075 1076 if ( smallFrameShowing || largeFrameShowing || nextScreen == SHELL_AREA_START ) { 1077 ShowLogo( false ); 1078 } else { 1079 ShowLogo( true ); 1080 } 1081 1082 } 1083 1084 /* 1085 ======================== 1086 idMenuHandler_Shell::UpdateLeaderboard 1087 ======================== 1088 */ 1089 void idMenuHandler_Shell::UpdateLeaderboard( const idLeaderboardCallback * callback ) { 1090 idMenuScreen_Shell_Leaderboards * screen = dynamic_cast< idMenuScreen_Shell_Leaderboards * >( menuScreens[ SHELL_AREA_LEADERBOARDS ] ); 1091 if ( screen != NULL ) { 1092 screen->UpdateLeaderboard( callback ); 1093 } 1094 } 1095 1096 /* 1097 ======================== 1098 idMenuManager_Shell::ShowPacifier 1099 ======================== 1100 */ 1101 void idMenuHandler_Shell::ShowPacifier( const idStr & msg ) { 1102 if ( GetPacifier() != NULL && gui != NULL ) { 1103 gui->SetGlobal( "paciferMessage", msg ); 1104 GetPacifier()->Show(); 1105 } 1106 } 1107 1108 /* 1109 ======================== 1110 idMenuManager_Shell::HidePacifier 1111 ======================== 1112 */ 1113 void idMenuHandler_Shell::HidePacifier() { 1114 if ( GetPacifier() != NULL ) { 1115 GetPacifier()->Hide(); 1116 } 1117 } 1118 1119 /* 1120 ======================== 1121 idMenuHandler_Shell::CopySettingsFromSession 1122 ======================== 1123 */ 1124 void idMenuHandler_Shell::UpdateLobby( idMenuWidget_LobbyList * lobbyList ) { 1125 1126 if ( lobbyList == NULL ) { 1127 return; 1128 } 1129 1130 idLobbyBase & lobby = session->GetActivePlatformLobbyBase(); 1131 const int numLobbyPlayers = lobby.GetNumLobbyUsers(); 1132 int maxPlayers = session->GetTitleStorageInt("MAX_PLAYERS_ALLOWED", 4 ); 1133 1134 idStaticList< lobbyPlayerInfo_t, MAX_PLAYERS > lobbyPlayers; 1135 for ( int i = 0; i < numLobbyPlayers; ++i ) { 1136 lobbyPlayerInfo_t * lobbyPlayer = lobbyPlayers.Alloc(); 1137 1138 lobbyUserID_t lobbyUserID = lobby.GetLobbyUserIdByOrdinal( i ); 1139 1140 if ( !lobbyUserID.IsValid() ) { 1141 continue; 1142 } 1143 1144 lobbyPlayer->name = lobby.GetLobbyUserName( lobbyUserID ); 1145 // Voice 1146 lobbyPlayer->voiceState = session->GetDisplayStateFromVoiceState( session->GetLobbyUserVoiceState( lobbyUserID ) ); 1147 } 1148 1149 1150 for ( int i = 0; i < maxPlayers; ++i ) { 1151 if ( i >= lobbyPlayers.Num() ) { 1152 lobbyList->SetEntryData( i, "", VOICECHAT_DISPLAY_NONE ); 1153 } else { 1154 lobbyPlayerInfo_t & lobbyPlayer = lobbyPlayers[ i ]; 1155 lobbyList->SetEntryData( i, lobbyPlayer.name, lobbyPlayer.voiceState ); 1156 } 1157 } 1158 1159 lobbyList->SetNumEntries( lobbyPlayers.Num() ); 1160 1161 } 1162 1163 /* 1164 ======================== 1165 idMenuHandler_Shell::StartGame 1166 ======================== 1167 */ 1168 void idMenuHandler_Shell::StartGame( int index ) { 1169 if ( index == 0 ) { 1170 cmdSystem->AppendCommandText( va( "map %s %d\n", "game/mars_city1", 0 ) ); 1171 } else if ( index == 1 ) { 1172 cmdSystem->AppendCommandText( va( "map %s %d\n", "game/erebus1", 1 ) ); 1173 } else if ( index == 2 ) { 1174 cmdSystem->AppendCommandText( va( "map %s %d\n", "game/le_enpro1", 2 ) ); 1175 } 1176 } 1177 1178 static const int NUM_DOOM_INTRO_LINES = 7; 1179 /* 1180 ======================== 1181 idMenuHandler_Shell::ShowIntroVideo 1182 ======================== 1183 */ 1184 void idMenuHandler_Shell::ShowDoomIntro() { 1185 1186 StopSound(); 1187 1188 showingIntro = true; 1189 1190 delete introGui; 1191 introGui = new idSWF( "doomIntro", common->MenuSW() ); 1192 1193 if ( introGui != NULL ) { 1194 const idMaterial * mat = doom3Intro; 1195 if ( mat != NULL ) { 1196 int c = mat->GetNumStages(); 1197 for ( int i = 0; i < c; i++ ) { 1198 const shaderStage_t *stage = mat->GetStage( i ); 1199 if ( stage != NULL && stage->texture.cinematic ) { 1200 stage->texture.cinematic->ResetTime( Sys_Milliseconds() ); 1201 } 1202 } 1203 } 1204 1205 introGui->Activate( true ); 1206 1207 int numTextFields = NUM_DOOM_INTRO_LINES; 1208 idStr textEntries[NUM_DOOM_INTRO_LINES] = { va( "%s %s", idLocalization::GetString("#str_04052"), idLocalization::GetString( "#str_04053" ) ), 1209 va( "%s %s", idLocalization::GetString("#str_04054"), idLocalization::GetString( "#str_04055" ) ), 1210 idLocalization::GetString( "#str_03012" ), 1211 idLocalization::GetString( "#str_04056" ), 1212 idLocalization::GetString( "#str_04057" ), 1213 va( "%s %s", idLocalization::GetString("#str_04058"), idLocalization::GetString( "#str_04059" ) ), 1214 va( "%s %s", idLocalization::GetString("#str_04060"), idLocalization::GetString( "#str_04061" ) ) }; 1215 1216 for ( int i = 0; i < numTextFields; ++i ) { 1217 1218 idSWFTextInstance * txtVal = introGui->GetRootObject().GetNestedText( va( "info%d", i ), "txtInfo", "txtVal" ); 1219 if ( txtVal != NULL ) { 1220 txtVal->SetText( textEntries[i] ); 1221 txtVal->SetStrokeInfo( true ); 1222 txtVal->renderMode = SWF_TEXT_RENDER_PARAGRAPH; 1223 txtVal->rndSpotsVisible = -1; 1224 txtVal->renderDelay = 50; 1225 txtVal->generatingText = false; 1226 if ( typeSoundShader != NULL ) { 1227 txtVal->soundClip = typeSoundShader->GetName(); 1228 } 1229 } 1230 1231 idSWFSpriteInstance * infoSprite = introGui->GetRootObject().GetNestedSprite( va( "info%d", i ) ); 1232 if ( infoSprite != NULL && txtVal != NULL ) { 1233 class idIntroTextUpdate : public idSWFScriptFunction_RefCounted { 1234 public: 1235 idIntroTextUpdate( idSWFTextInstance * _txtVal, int _numLines, int _nextIndex, idMenuHandler_Shell * _shell, idSWF * _gui ) { 1236 txtVal = _txtVal; 1237 generating = false; 1238 numLines = _numLines; 1239 nextIndex = _nextIndex; 1240 shell = _shell; 1241 gui = _gui; 1242 } 1243 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 1244 if ( thisObject->GetSprite() == NULL ) { 1245 return idSWFScriptVar(); 1246 } 1247 1248 if ( thisObject->GetSprite()->currentFrame == 1 ) { 1249 return idSWFScriptVar(); 1250 } 1251 1252 if ( txtVal == NULL ) { 1253 return idSWFScriptVar(); 1254 } 1255 1256 if ( !generating ) { 1257 generating = true; 1258 txtVal->triggerGenerate = true; 1259 } else if ( generating ) { 1260 if ( !txtVal->generatingText ) { 1261 float newYPos = thisObject->GetSprite()->GetYPos() - 1.5f; 1262 if ( newYPos <= 350.0f - ( numLines * 36.0f ) ) { 1263 if ( thisObject->GetSprite()->IsVisible() ) { 1264 thisObject->GetSprite()->SetVisible( false ); 1265 if ( nextIndex >= NUM_DOOM_INTRO_LINES ) { 1266 shell->StartGame( 0 ); 1267 } 1268 } 1269 } else if ( newYPos <= 665.0f - ( numLines * 36.0f ) ) { 1270 if ( nextIndex < NUM_DOOM_INTRO_LINES ) { 1271 idSWFSpriteInstance * nextInfo = gui->GetRootObject().GetNestedSprite( va( "info%d", nextIndex ) ); 1272 if ( nextInfo != NULL && nextInfo->GetCurrentFrame() != nextInfo->FindFrame( "active" ) ) { 1273 nextInfo->StopFrame( "active" ); 1274 } 1275 } 1276 1277 float alpha = 1.0f; 1278 if ( newYPos <= 450 ) { 1279 alpha = ( newYPos - 350.0f ) / 100.0f; 1280 } 1281 thisObject->GetSprite()->SetAlpha( alpha ); 1282 thisObject->GetSprite()->SetYPos( newYPos ); 1283 } else { 1284 thisObject->GetSprite()->SetYPos( newYPos ); 1285 thisObject->GetSprite()->SetAlpha( 1.0f ); 1286 } 1287 } 1288 } 1289 1290 return idSWFScriptVar(); 1291 } 1292 private: 1293 idSWFTextInstance * txtVal; 1294 idMenuHandler_Shell * shell; 1295 int numLines; 1296 int nextIndex; 1297 bool generating; 1298 idSWF * gui; 1299 }; 1300 1301 infoSprite->GetScriptObject()->Set( "onEnterFrame", new idIntroTextUpdate( txtVal, txtVal->CalcNumLines(), i + 1, this, introGui ) ); 1302 } 1303 } 1304 1305 class idIntroVOStart : public idSWFScriptFunction_RefCounted { 1306 public: 1307 idIntroVOStart( idSWF * gui ) { 1308 introGui = gui; 1309 } 1310 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 1311 if ( introGui != NULL ) { 1312 introGui->PlaySound( "gui/doomintro" ); 1313 } 1314 return idSWFScriptVar(); 1315 } 1316 private: 1317 idSWF * introGui; 1318 }; 1319 1320 if ( introGui != NULL ) { 1321 introGui->SetGlobal( "playVo", new idIntroVOStart( introGui ) ); 1322 } 1323 1324 idSWFSpriteInstance * img = introGui->GetRootObject().GetNestedSprite( "intro", "img" ); 1325 if ( img != NULL ) { 1326 if ( mat != NULL ) { 1327 img->SetMaterial( mat ); 1328 } 1329 } 1330 } 1331 } 1332 1333 static const int NUM_ROE_INTRO_LINES = 6; 1334 /* 1335 ======================== 1336 idMenuHandler_Shell::ShowROEIntro 1337 ======================== 1338 */ 1339 void idMenuHandler_Shell::ShowROEIntro() { 1340 1341 StopSound(); 1342 1343 showingIntro = true; 1344 1345 delete introGui; 1346 introGui = new idSWF( "roeIntro", common->MenuSW() ); 1347 1348 if ( introGui != NULL ) { 1349 const idMaterial * mat = roeIntro; 1350 if ( mat != NULL ) { 1351 int c = mat->GetNumStages(); 1352 for ( int i = 0; i < c; i++ ) { 1353 const shaderStage_t *stage = mat->GetStage( i ); 1354 if ( stage != NULL && stage->texture.cinematic ) { 1355 stage->texture.cinematic->ResetTime( Sys_Milliseconds() ); 1356 } 1357 } 1358 } 1359 1360 introGui->Activate( true ); 1361 1362 int numTextFields = NUM_ROE_INTRO_LINES; 1363 idStr textEntries[NUM_ROE_INTRO_LINES] = { 1364 idLocalization::GetString( "#str_00100870" ), 1365 idLocalization::GetString( "#str_00100854" ), 1366 idLocalization::GetString( "#str_00100879" ), 1367 idLocalization::GetString( "#str_00100855" ), 1368 idLocalization::GetString( "#str_00100890" ), 1369 idLocalization::GetString( "#str_00100856" ), 1370 }; 1371 1372 for ( int i = 0; i < numTextFields; ++i ) { 1373 1374 idSWFTextInstance * txtVal = introGui->GetRootObject().GetNestedText( va( "info%d", i ), "txtInfo", "txtVal" ); 1375 if ( txtVal != NULL ) { 1376 txtVal->SetText( textEntries[i] ); 1377 txtVal->SetStrokeInfo( true ); 1378 txtVal->renderMode = SWF_TEXT_RENDER_PARAGRAPH; 1379 txtVal->rndSpotsVisible = -1; 1380 txtVal->renderDelay = 40; 1381 txtVal->generatingText = false; 1382 if ( typeSoundShader != NULL ) { 1383 txtVal->soundClip = typeSoundShader->GetName(); 1384 } 1385 } 1386 1387 idSWFSpriteInstance * infoSprite = introGui->GetRootObject().GetNestedSprite( va( "info%d", i ) ); 1388 if ( infoSprite != NULL && txtVal != NULL ) { 1389 class idIntroTextUpdate : public idSWFScriptFunction_RefCounted { 1390 public: 1391 idIntroTextUpdate( idSWFTextInstance * _txtVal, int _numLines, int _nextIndex, idMenuHandler_Shell * _shell, idSWF * _gui ) { 1392 txtVal = _txtVal; 1393 generating = false; 1394 numLines = _numLines; 1395 nextIndex = _nextIndex; 1396 shell = _shell; 1397 gui = _gui; 1398 startFade = 0; 1399 } 1400 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 1401 if ( thisObject->GetSprite() == NULL ) { 1402 return idSWFScriptVar(); 1403 } 1404 1405 if ( thisObject->GetSprite()->currentFrame == 1 ) { 1406 return idSWFScriptVar(); 1407 } 1408 1409 if ( txtVal == NULL ) { 1410 return idSWFScriptVar(); 1411 } 1412 1413 if ( !generating ) { 1414 generating = true; 1415 txtVal->triggerGenerate = true; 1416 } else if ( generating ) { 1417 if ( !txtVal->generatingText && thisObject->GetSprite()->IsVisible() ) { 1418 if ( nextIndex % 2 != 0 ) { 1419 if ( nextIndex < NUM_ROE_INTRO_LINES ) { 1420 idSWFSpriteInstance * nextInfo = gui->GetRootObject().GetNestedSprite( va( "info%d", nextIndex ) ); 1421 if ( nextInfo != NULL && nextInfo->GetCurrentFrame() != nextInfo->FindFrame( "active" ) ) { 1422 nextInfo->StopFrame( "active" ); 1423 } else if ( nextInfo != NULL && nextInfo->IsVisible() ) { 1424 idSWFTextInstance * txtData = nextInfo->GetScriptObject()->GetNestedText( "txtInfo", "txtVal" ); 1425 if ( txtData != NULL && !txtData->generatingText ) { 1426 if ( startFade == 0 ) { 1427 startFade = Sys_Milliseconds(); 1428 } else { 1429 if ( Sys_Milliseconds() - startFade >= 3000 ) { 1430 nextInfo->SetVisible( false ); 1431 thisObject->GetSprite()->SetVisible( false ); 1432 1433 int nextDateIndex = ( nextIndex + 1 ); 1434 if ( nextDateIndex < NUM_ROE_INTRO_LINES ) { 1435 idSWFSpriteInstance * nextInfo = gui->GetRootObject().GetNestedSprite( va( "info%d", nextDateIndex ) ); 1436 if ( nextInfo != NULL && nextInfo->GetCurrentFrame() != nextInfo->FindFrame( "active" ) ) { 1437 nextInfo->StopFrame( "active" ); 1438 return idSWFScriptVar(); 1439 } 1440 } else { 1441 shell->StartGame( 1 ); 1442 return idSWFScriptVar(); 1443 } 1444 } else { 1445 float alpha = 1.0f - ( (float)( Sys_Milliseconds() - startFade ) / 3000.0f ); 1446 nextInfo->SetAlpha( alpha ); 1447 thisObject->GetSprite()->SetAlpha( alpha ); 1448 } 1449 } 1450 } 1451 } 1452 } 1453 } 1454 } 1455 } 1456 1457 return idSWFScriptVar(); 1458 } 1459 private: 1460 idSWFTextInstance * txtVal; 1461 idMenuHandler_Shell * shell; 1462 int numLines; 1463 int nextIndex; 1464 bool generating; 1465 idSWF * gui; 1466 int startFade; 1467 }; 1468 1469 infoSprite->GetScriptObject()->Set( "onEnterFrame", new idIntroTextUpdate( txtVal, txtVal->CalcNumLines(), i + 1, this, introGui ) ); 1470 } 1471 } 1472 1473 idSWFSpriteInstance * img = introGui->GetRootObject().GetNestedSprite( "intro", "img" ); 1474 if ( img != NULL ) { 1475 if ( mat != NULL ) { 1476 img->SetMaterial( mat ); 1477 } 1478 } 1479 } 1480 } 1481 1482 static const int NUM_LE_INTRO_LINES = 1; 1483 /* 1484 ======================== 1485 idMenuHandler_Shell::ShowLEIntro 1486 ======================== 1487 */ 1488 void idMenuHandler_Shell::ShowLEIntro() { 1489 1490 StopSound(); 1491 1492 showingIntro = true; 1493 1494 delete introGui; 1495 introGui = new idSWF( "leIntro", common->MenuSW() ); 1496 1497 if ( introGui != NULL ) { 1498 introGui->Activate( true ); 1499 1500 idStr textEntry = va( "%s\n%s\n%s", idLocalization::GetString( "#str_00200071" ), idLocalization::GetString( "#str_00200072" ), idLocalization::GetString( "#str_00200073" ) ); 1501 idSWFTextInstance * txtVal = introGui->GetRootObject().GetNestedText( "info0", "txtInfo", "txtVal" ); 1502 if ( txtVal != NULL ) { 1503 txtVal->SetText( textEntry ); 1504 txtVal->SetStrokeInfo( true ); 1505 txtVal->renderMode = SWF_TEXT_RENDER_PARAGRAPH; 1506 txtVal->rndSpotsVisible = -1; 1507 txtVal->renderDelay = 60; 1508 txtVal->generatingText = false; 1509 if ( typeSoundShader != NULL ) { 1510 txtVal->soundClip = typeSoundShader->GetName(); 1511 } 1512 } 1513 1514 idSWFSpriteInstance * infoSprite = introGui->GetRootObject().GetNestedSprite( "info0" ); 1515 if ( infoSprite != NULL ) { 1516 class idIntroTextUpdate : public idSWFScriptFunction_RefCounted { 1517 public: 1518 idIntroTextUpdate( idSWFTextInstance * _txtVal, idMenuHandler_Shell * _shell ) { 1519 txtVal = _txtVal; 1520 generating = false; 1521 shell = _shell; 1522 startFade = 0; 1523 } 1524 idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) { 1525 if ( thisObject->GetSprite() == NULL ) { 1526 return idSWFScriptVar(); 1527 } 1528 1529 if ( thisObject->GetSprite()->currentFrame == 1 ) { 1530 return idSWFScriptVar(); 1531 } 1532 1533 if ( txtVal == NULL ) { 1534 return idSWFScriptVar(); 1535 } 1536 1537 if ( !generating ) { 1538 generating = true; 1539 txtVal->triggerGenerate = true; 1540 } else if ( generating ) { 1541 if ( !txtVal->generatingText ) { 1542 if ( startFade == 0 ) { 1543 startFade = Sys_Milliseconds(); 1544 } else { 1545 float alpha = 1.0f - ( (float)( Sys_Milliseconds() - startFade ) / 3000.0f ); 1546 if ( alpha <= 0.0f ) { 1547 thisObject->GetSprite()->SetVisible( false ); 1548 shell->StartGame( 2 ); 1549 return idSWFScriptVar(); 1550 } 1551 thisObject->GetSprite()->SetAlpha( alpha ); 1552 } 1553 } 1554 } 1555 1556 return idSWFScriptVar(); 1557 } 1558 private: 1559 idSWFTextInstance * txtVal; 1560 idMenuHandler_Shell * shell; 1561 bool generating; 1562 int startFade; 1563 }; 1564 1565 infoSprite->GetScriptObject()->Set( "onEnterFrame", new idIntroTextUpdate( txtVal, this ) ); 1566 } 1567 } 1568 }