MenuHandler_PDA.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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. static const int MAX_PDA_ITEMS = 15;
  24. static const int MAX_NAV_OPTIONS = 4;
  25. /*
  26. ========================
  27. idMenuHandler_PDA::Update
  28. ========================
  29. */
  30. void idMenuHandler_PDA::Update() {
  31. if ( gui == NULL || !gui->IsActive() ) {
  32. return;
  33. }
  34. if ( activeScreen != nextScreen ) {
  35. if ( nextScreen == PDA_AREA_INVALID ) {
  36. menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
  37. idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * >( GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
  38. if ( cmdBar != NULL ) {
  39. cmdBar->ClearAllButtons();
  40. cmdBar->Update();
  41. }
  42. idSWFSpriteInstance * menu = gui->GetRootObject().GetNestedSprite( "navBar" );
  43. idSWFSpriteInstance * bg = gui->GetRootObject().GetNestedSprite( "background" );
  44. idSWFSpriteInstance * edging = gui->GetRootObject().GetNestedSprite( "_fullScreen" );
  45. if ( menu != NULL ) {
  46. menu->PlayFrame( "rollOff" );
  47. }
  48. if ( bg != NULL ) {
  49. bg->PlayFrame( "rollOff" );
  50. }
  51. if ( edging != NULL ) {
  52. edging->PlayFrame( "rollOff" );
  53. }
  54. } else {
  55. if ( activeScreen > PDA_AREA_INVALID && activeScreen < PDA_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) {
  56. menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
  57. }
  58. if ( nextScreen > PDA_AREA_INVALID && nextScreen < PDA_NUM_AREAS && menuScreens[ nextScreen ] != NULL ) {
  59. menuScreens[ nextScreen ]->UpdateCmds();
  60. menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>(transition) );
  61. }
  62. }
  63. transition = MENU_TRANSITION_INVALID;
  64. activeScreen = nextScreen;
  65. }
  66. idPlayer * player = gameLocal.GetLocalPlayer();
  67. if ( player != NULL ) {
  68. if ( activeScreen == PDA_AREA_USER_DATA ) {
  69. bool isPlaying = player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO );
  70. UpdateAudioLogPlaying( isPlaying );
  71. }
  72. if ( activeScreen == PDA_AREA_VIDEO_DISKS ) {
  73. bool isPlaying = player->IsSoundChannelPlaying( SND_CHANNEL_PDA_VIDEO );
  74. UdpateVideoPlaying( isPlaying );
  75. }
  76. }
  77. idMenuHandler::Update();
  78. }
  79. /*
  80. ================================================
  81. idMenuHandler::TriggerMenu
  82. ================================================
  83. */
  84. void idMenuHandler_PDA::TriggerMenu() {
  85. nextScreen = PDA_AREA_USER_DATA;
  86. transition = MENU_TRANSITION_FORCE;
  87. }
  88. /*
  89. ========================
  90. idMenuHandler_PDA::ActivateMenu
  91. ========================
  92. */
  93. void idMenuHandler_PDA::ActivateMenu( bool show ) {
  94. idMenuHandler::ActivateMenu( show );
  95. if ( show ) {
  96. // Add names to pda
  97. idPlayer * player = gameLocal.GetLocalPlayer();
  98. if ( player == NULL ) {
  99. return;
  100. }
  101. pdaNames.Clear();
  102. for ( int j = 0; j < player->GetInventory().pdas.Num(); j++ ) {
  103. const idDeclPDA * pda = player->GetInventory().pdas[ j ];
  104. idList< idStr > names;
  105. names.Append( pda->GetPdaName() );
  106. pdaNames.Append( names );
  107. }
  108. idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
  109. if ( pdaList != NULL ) {
  110. pdaList->SetListData( pdaNames );
  111. }
  112. navOptions.Clear();
  113. navOptions.Append( idLocalization::GetString( "#str_04190" ) );
  114. navOptions.Append( idLocalization::GetString( "#str_01442" ) );
  115. navOptions.Append( idLocalization::GetString( "#str_01440" ) );
  116. navOptions.Append( idLocalization::GetString( "#str_01414" ) );
  117. idMenuWidget_NavBar * navBar = dynamic_cast< idMenuWidget_NavBar * >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
  118. if ( navBar != NULL ) {
  119. navBar->SetListHeadings( navOptions );
  120. navBar->SetFocusIndex( 0 );
  121. navBar->Update();
  122. }
  123. idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * >( GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
  124. if ( cmdBar != NULL ) {
  125. cmdBar->ClearAllButtons();
  126. cmdBar->Update();
  127. }
  128. } else {
  129. nextScreen = PDA_AREA_INVALID;
  130. activeScreen = PDA_AREA_INVALID;
  131. }
  132. }
  133. /*
  134. ========================
  135. idMenuHandler_PDA::Initialize
  136. ========================
  137. */
  138. void idMenuHandler_PDA::Initialize( const char * swfFile, idSoundWorld * sw ) {
  139. idMenuHandler::Initialize( swfFile, sw );
  140. //---------------------
  141. // Initialize the menus
  142. //---------------------
  143. #define BIND_PDA_SCREEN( screenId, className, menuHandler ) \
  144. menuScreens[ (screenId) ] = new (TAG_SWF) className(); \
  145. menuScreens[ (screenId) ]->Initialize( menuHandler ); \
  146. menuScreens[ (screenId) ]->AddRef(); \
  147. menuScreens[ (screenId) ]->SetNoAutoFree( true );
  148. for ( int i = 0; i < PDA_NUM_AREAS; ++i ) {
  149. menuScreens[ i ] = NULL;
  150. }
  151. BIND_PDA_SCREEN( PDA_AREA_USER_DATA, idMenuScreen_PDA_UserData, this );
  152. BIND_PDA_SCREEN( PDA_AREA_USER_EMAIL, idMenuScreen_PDA_UserEmails, this );
  153. BIND_PDA_SCREEN( PDA_AREA_VIDEO_DISKS, idMenuScreen_PDA_VideoDisks, this );
  154. BIND_PDA_SCREEN( PDA_AREA_INVENTORY, idMenuScreen_PDA_Inventory, this );
  155. pdaScrollBar.SetSpritePath( "pda_persons", "info", "scrollbar" );
  156. pdaScrollBar.Initialize( this );
  157. pdaScrollBar.SetNoAutoFree( true );
  158. pdaList.SetSpritePath( "pda_persons", "info", "list" );
  159. pdaList.SetNumVisibleOptions( MAX_PDA_ITEMS );
  160. pdaList.SetWrappingAllowed( true );
  161. pdaList.SetNoAutoFree( true );
  162. while ( pdaList.GetChildren().Num() < MAX_PDA_ITEMS ) {
  163. idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
  164. buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_USER, pdaList.GetChildren().Num() );
  165. buttonWidget->Initialize( this );
  166. if ( menuScreens[ PDA_AREA_USER_DATA ] != NULL ) {
  167. idMenuScreen_PDA_UserData * userDataScreen = dynamic_cast< idMenuScreen_PDA_UserData * >( menuScreens[ PDA_AREA_USER_DATA ] );
  168. if ( userDataScreen != NULL ) {
  169. buttonWidget->RegisterEventObserver( userDataScreen->GetUserData() );
  170. buttonWidget->RegisterEventObserver( userDataScreen->GetObjective() );
  171. buttonWidget->RegisterEventObserver( userDataScreen->GetAudioFiles() );
  172. }
  173. }
  174. if ( menuScreens[ PDA_AREA_USER_EMAIL ] != NULL ) {
  175. idMenuScreen_PDA_UserEmails * userEmailScreen = dynamic_cast< idMenuScreen_PDA_UserEmails * >( menuScreens[ PDA_AREA_USER_EMAIL ] );
  176. if ( userEmailScreen != NULL ) {
  177. buttonWidget->RegisterEventObserver( &userEmailScreen->GetInbox() );
  178. buttonWidget->RegisterEventObserver( userEmailScreen );
  179. }
  180. }
  181. buttonWidget->RegisterEventObserver( &pdaScrollBar );
  182. pdaList.AddChild( buttonWidget );
  183. }
  184. pdaList.AddChild( &pdaScrollBar );
  185. pdaList.Initialize( this );
  186. navBar.SetSpritePath( "navBar", "options" );
  187. navBar.Initialize( this );
  188. navBar.SetNumVisibleOptions( MAX_NAV_OPTIONS );
  189. navBar.SetWrappingAllowed( true );
  190. navBar.SetButtonSpacing( 20.0f, 25.0f, 75.0f );
  191. navBar.SetInitialXPos( 40.0f );
  192. navBar.SetNoAutoFree( true );
  193. for ( int count = 0; count < ( MAX_NAV_OPTIONS * 2 - 1 ); ++count ) {
  194. idMenuWidget_NavButton * const navButton = new (TAG_SWF) idMenuWidget_NavButton();
  195. if ( count < MAX_NAV_OPTIONS - 1 ) {
  196. navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, count );
  197. } else if ( count < ( ( MAX_NAV_OPTIONS - 1 ) * 2 ) ) {
  198. int index = ( count - ( MAX_NAV_OPTIONS - 1 ) ) + 1;
  199. navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, index );
  200. } else {
  201. navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, -1 );
  202. }
  203. navBar.AddChild( navButton );
  204. }
  205. //
  206. // command bar
  207. //
  208. commandBarWidget.SetAlignment( idMenuWidget_CommandBar::LEFT );
  209. commandBarWidget.SetSpritePath( "prompts" );
  210. commandBarWidget.Initialize( this );
  211. commandBarWidget.SetNoAutoFree( true );
  212. AddChild( &navBar );
  213. AddChild( &pdaList );
  214. AddChild( &pdaScrollBar );
  215. AddChild( &commandBarWidget );
  216. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
  217. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
  218. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
  219. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
  220. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
  221. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
  222. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
  223. pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
  224. menuScreens[ PDA_AREA_USER_DATA ]->RegisterEventObserver( &pdaList );
  225. menuScreens[ PDA_AREA_USER_EMAIL ]->RegisterEventObserver( &pdaList );
  226. idPlayer * player = gameLocal.GetLocalPlayer();
  227. if ( player != NULL ) {
  228. for ( int j = 0; j < MAX_WEAPONS; j++ ) {
  229. const char * weaponDefName = va( "def_weapon%d", j );
  230. const char *weap = player->spawnArgs.GetString( weaponDefName );
  231. if ( weap != NULL && *weap != NULL ) {
  232. const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
  233. if ( weaponDef != NULL ) {
  234. declManager->FindMaterial( weaponDef->dict.GetString( "pdaIcon" ) );
  235. declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ) );
  236. }
  237. }
  238. }
  239. }
  240. class idPDAGGUIClose : public idSWFScriptFunction_RefCounted {
  241. public:
  242. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  243. idPlayer * player = gameLocal.GetLocalPlayer();
  244. if ( player != NULL ) {
  245. player->TogglePDA();
  246. }
  247. return idSWFScriptVar();
  248. }
  249. };
  250. if ( gui != NULL ) {
  251. gui->SetGlobal( "closePDA", new idPDAGGUIClose() );
  252. }
  253. // precache sounds
  254. // don't load gui music for the pause menu to save some memory
  255. const idSoundShader * soundShader = NULL;
  256. soundShader = declManager->FindSound( "gui/list_scroll", true );
  257. if ( soundShader != NULL ) {
  258. sounds[ GUI_SOUND_SCROLL ] = soundShader->GetName();
  259. }
  260. soundShader = declManager->FindSound( "gui/btn_PDA_advance", true );
  261. if ( soundShader != NULL ) {
  262. sounds[ GUI_SOUND_ADVANCE ] = soundShader->GetName();
  263. }
  264. soundShader = declManager->FindSound( "gui/btn_PDA_back", true );
  265. if ( soundShader != NULL ) {
  266. sounds[ GUI_SOUND_BACK ] = soundShader->GetName();
  267. }
  268. soundShader = declManager->FindSound( "gui/pda_next_tab", true );
  269. if ( soundShader != NULL ) {
  270. sounds[ GUI_SOUND_BUILD_ON ] = soundShader->GetName();
  271. }
  272. soundShader = declManager->FindSound( "gui/pda_prev_tab", true );
  273. if ( soundShader != NULL ) {
  274. sounds[ GUI_SOUND_BUILD_OFF ] = soundShader->GetName();
  275. }
  276. soundShader = declManager->FindSound( "gui/btn_set_focus", true );
  277. if ( soundShader != NULL ) {
  278. sounds[ GUI_SOUND_FOCUS ] = soundShader->GetName();
  279. }
  280. soundShader = declManager->FindSound( "gui/btn_roll_over", true );
  281. if ( soundShader != NULL ) {
  282. sounds[ GUI_SOUND_ROLL_OVER ] = soundShader->GetName();
  283. }
  284. soundShader = declManager->FindSound( "gui/btn_roll_out", true );
  285. if ( soundShader != NULL ) {
  286. sounds[ GUI_SOUND_ROLL_OUT ] = soundShader->GetName();
  287. }
  288. }
  289. /*
  290. ========================
  291. idMenuHandler_PDA::HandleAction
  292. ========================
  293. */
  294. bool idMenuHandler_PDA::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
  295. if ( activeScreen == PDA_AREA_INVALID ) {
  296. return true;
  297. }
  298. widgetAction_t actionType = action.GetType();
  299. const idSWFParmList & parms = action.GetParms();
  300. if ( event.type == WIDGET_EVENT_COMMAND ) {
  301. if ( menuScreens[ activeScreen ] != NULL && !forceHandled ) {
  302. if ( menuScreens[ activeScreen ]->HandleAction( action, event, widget, true ) ) {
  303. if ( actionType == WIDGET_ACTION_GO_BACK ) {
  304. PlaySound( GUI_SOUND_BACK );
  305. } else {
  306. PlaySound( GUI_SOUND_ADVANCE );
  307. }
  308. return true;
  309. }
  310. }
  311. }
  312. switch ( actionType ) {
  313. case WIDGET_ACTION_PDA_SELECT_USER: {
  314. int index = parms[0].ToInteger();
  315. idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
  316. if ( pdaList != NULL ) {
  317. pdaList->SetViewIndex( pdaList->GetViewOffset() + index );
  318. pdaList->SetFocusIndex( index );
  319. }
  320. return true;
  321. }
  322. case WIDGET_ACTION_SCROLL_TAB: {
  323. if ( transition != MENU_TRANSITION_INVALID ) {
  324. return true;
  325. }
  326. int delta = parms[0].ToInteger();
  327. idMenuWidget_NavBar * navBar = dynamic_cast< idMenuWidget_NavBar * >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
  328. if ( navBar != NULL ) {
  329. int focused = navBar->GetFocusIndex();
  330. focused += delta;
  331. if ( focused < 0 ) {
  332. focused = navBar->GetNumVisibleOptions() - 1;
  333. } else if ( focused >= navBar->GetNumVisibleOptions() ) {
  334. focused = 0;
  335. }
  336. navBar->SetViewIndex( focused );
  337. navBar->SetFocusIndex( focused, true );
  338. navBar->Update();
  339. nextScreen = activeScreen + delta;
  340. if ( nextScreen < 0 ) {
  341. nextScreen = PDA_NUM_AREAS - 1;
  342. } else if ( nextScreen == PDA_NUM_AREAS ) {
  343. nextScreen = 0;
  344. }
  345. if ( delta < 0 ) {
  346. transition = MENU_TRANSITION_BACK;
  347. } else {
  348. transition = MENU_TRANSITION_ADVANCE;
  349. }
  350. }
  351. return true;
  352. }
  353. case WIDGET_ACTION_PDA_SELECT_NAV: {
  354. int index = parms[0].ToInteger();
  355. if ( index == -1 && activeScreen == PDA_AREA_USER_EMAIL ) {
  356. idMenuScreen_PDA_UserEmails * screen = dynamic_cast< idMenuScreen_PDA_UserEmails * const >( menuScreens[ PDA_AREA_USER_EMAIL ] );
  357. if ( screen ) {
  358. screen->ShowEmail( false );
  359. }
  360. return true;
  361. }
  362. // click on the current nav tab
  363. if ( index == -1 ) {
  364. return true;
  365. }
  366. idMenuWidget_NavBar * navBar = dynamic_cast< idMenuWidget_NavBar * >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
  367. if ( navBar != NULL ) {
  368. navBar->SetViewIndex( navBar->GetViewOffset() + index );
  369. navBar->SetFocusIndex( index, true );
  370. navBar->Update();
  371. if ( index < activeScreen ) {
  372. nextScreen = index;
  373. transition = MENU_TRANSITION_BACK;
  374. } else if ( index > activeScreen ) {
  375. nextScreen = index;
  376. transition = MENU_TRANSITION_ADVANCE;
  377. }
  378. }
  379. return true;
  380. }
  381. case WIDGET_ACTION_SELECT_PDA_AUDIO: {
  382. if ( activeScreen == PDA_AREA_USER_DATA ) {
  383. int index = parms[0].ToInteger();
  384. idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
  385. bool change = false;
  386. if ( pdaList != NULL ) {
  387. int pdaIndex = pdaList->GetViewIndex();
  388. change = PlayPDAAudioLog( pdaIndex, index );
  389. }
  390. if ( change ) {
  391. if ( widget->GetParent() != NULL ) {
  392. idMenuWidget_DynamicList * audioList = dynamic_cast< idMenuWidget_DynamicList * >( widget->GetParent() );
  393. int index = parms[0].ToInteger();
  394. if ( audioList != NULL ) {
  395. audioList->SetFocusIndex( index );
  396. }
  397. }
  398. }
  399. }
  400. return true;
  401. }
  402. case WIDGET_ACTION_SELECT_PDA_VIDEO: {
  403. if ( activeScreen == PDA_AREA_VIDEO_DISKS ) {
  404. int index = parms[0].ToInteger();
  405. if ( menuScreens[ PDA_AREA_VIDEO_DISKS ] != NULL ) {
  406. idMenuScreen_PDA_VideoDisks * screen = dynamic_cast< idMenuScreen_PDA_VideoDisks * const >( menuScreens[ PDA_AREA_VIDEO_DISKS ] );
  407. if ( screen != NULL ) {
  408. screen->SelectedVideoToPlay( index );
  409. }
  410. }
  411. }
  412. return true;
  413. }
  414. }
  415. return idMenuHandler::HandleAction( action, event, widget, forceHandled );
  416. }
  417. /*
  418. ========================
  419. idMenuHandler_PDA::PlayPDAAudioLog
  420. ========================
  421. */
  422. bool idMenuHandler_PDA::PlayPDAAudioLog( int pdaIndex, int audioIndex ) {
  423. idPlayer * player = gameLocal.GetLocalPlayer();
  424. if ( player != NULL ) {
  425. const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
  426. if ( pda != NULL && pda->GetNumAudios() > audioIndex ) {
  427. const idDeclAudio *aud = pda->GetAudioByIndex( audioIndex );
  428. if ( audioFile == aud ) {
  429. player->EndAudioLog();
  430. return true;
  431. } else if ( aud != NULL ) {
  432. audioFile = aud;
  433. player->EndAudioLog();
  434. player->PlayAudioLog( aud->GetWave() );
  435. return true;
  436. }
  437. }
  438. }
  439. return false;
  440. }
  441. /*
  442. ========================
  443. idMenuHandler_PDA::GetMenuScreen
  444. ========================
  445. */
  446. idMenuScreen * idMenuHandler_PDA::GetMenuScreen( int index ) {
  447. if ( index < 0 || index >= PDA_NUM_AREAS ) {
  448. return NULL;
  449. }
  450. return menuScreens[ index ];
  451. }
  452. /*
  453. ========================
  454. idMenuHandler_PDA::GetMenuScreen
  455. ========================
  456. */
  457. void idMenuHandler_PDA::UpdateAudioLogPlaying( bool playing ) {
  458. if ( playing != audioLogPlaying && activeScreen == PDA_AREA_USER_DATA && menuScreens[ activeScreen ] != NULL ) {
  459. menuScreens[ activeScreen ]->Update();
  460. }
  461. audioLogPlaying = playing;
  462. if ( !playing ) {
  463. audioFile = NULL;
  464. }
  465. }
  466. /*
  467. ========================
  468. idMenuHandler_PDA::GetMenuScreen
  469. ========================
  470. */
  471. void idMenuHandler_PDA::UdpateVideoPlaying( bool playing ) {
  472. if ( playing != videoPlaying ) {
  473. if ( activeScreen == PDA_AREA_VIDEO_DISKS && menuScreens[ activeScreen ] != NULL ) {
  474. idPlayer * player = gameLocal.GetLocalPlayer();
  475. if ( !playing ) {
  476. player->EndVideoDisk();
  477. }
  478. idMenuScreen_PDA_VideoDisks * screen = dynamic_cast< idMenuScreen_PDA_VideoDisks * const >( menuScreens[ PDA_AREA_VIDEO_DISKS ] );
  479. if ( screen != NULL ) {
  480. if ( !playing ) {
  481. screen->ClearActiveVideo();
  482. }
  483. screen->Update();
  484. }
  485. }
  486. videoPlaying = playing;
  487. }
  488. }
  489. /*
  490. ================================================
  491. idMenuHandler_PDA::Cleanup
  492. ================================================
  493. */
  494. void idMenuHandler_PDA::Cleanup() {
  495. idMenuHandler::Cleanup();
  496. for ( int index = 0; index < MAX_SCREEN_AREAS; ++index ) {
  497. delete menuScreens[ index ];
  498. menuScreens[ index ] = NULL;
  499. }
  500. }
  501. /*
  502. ================================================
  503. idMenuHandler_PDA::~idMenuHandler_PDA
  504. ================================================
  505. */
  506. idMenuHandler_PDA::~idMenuHandler_PDA() {
  507. pdaScrollBar.Cleanup();
  508. pdaList.Cleanup();
  509. navBar.Cleanup();
  510. commandBarWidget.Cleanup();
  511. Cleanup();
  512. }