MenuHandler_Shell.cpp 50 KB

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