MenuHandler.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. #ifndef __MENUDATA_H__
  21. #define __MENUDATA_H__
  22. enum shellAreas_t {
  23. SHELL_AREA_INVALID = -1,
  24. SHELL_AREA_START,
  25. SHELL_AREA_ROOT,
  26. SHELL_AREA_DEV,
  27. SHELL_AREA_CAMPAIGN,
  28. SHELL_AREA_LOAD,
  29. SHELL_AREA_SAVE,
  30. SHELL_AREA_NEW_GAME,
  31. SHELL_AREA_GAME_OPTIONS,
  32. SHELL_AREA_SYSTEM_OPTIONS,
  33. SHELL_AREA_MULTIPLAYER,
  34. SHELL_AREA_GAME_LOBBY,
  35. SHELL_AREA_STEREOSCOPICS,
  36. SHELL_AREA_PARTY_LOBBY,
  37. SHELL_AREA_SETTINGS,
  38. SHELL_AREA_AUDIO,
  39. SHELL_AREA_VIDEO,
  40. SHELL_AREA_KEYBOARD,
  41. SHELL_AREA_CONTROLS,
  42. SHELL_AREA_CONTROLLER_LAYOUT,
  43. SHELL_AREA_GAMEPAD,
  44. SHELL_AREA_PAUSE,
  45. SHELL_AREA_LEADERBOARDS,
  46. SHELL_AREA_PLAYSTATION,
  47. SHELL_AREA_DIFFICULTY,
  48. SHELL_AREA_RESOLUTION,
  49. SHELL_AREA_MATCH_SETTINGS,
  50. SHELL_AREA_MODE_SELECT,
  51. SHELL_AREA_BROWSER,
  52. SHELL_AREA_CREDITS,
  53. SHELL_NUM_AREAS
  54. };
  55. enum shellState_t {
  56. SHELL_STATE_INVALID = -1,
  57. SHELL_STATE_PRESS_START,
  58. SHELL_STATE_IDLE,
  59. SHELL_STATE_PARTY_LOBBY,
  60. SHELL_STATE_GAME_LOBBY,
  61. SHELL_STATE_PAUSED,
  62. SHELL_STATE_CONNECTING,
  63. SHELL_STATE_SEARCHING,
  64. SHELL_STATE_LOADING,
  65. SHELL_STATE_BUSY,
  66. SHELL_STATE_IN_GAME
  67. };
  68. enum pdaAreas_t {
  69. PDA_AREA_INVALID = -1,
  70. PDA_AREA_USER_DATA,
  71. PDA_AREA_USER_EMAIL,
  72. PDA_AREA_VIDEO_DISKS,
  73. PDA_AREA_INVENTORY,
  74. PDA_NUM_AREAS
  75. };
  76. enum hudArea_t {
  77. HUD_AREA_INVALID = -1,
  78. HUD_AREA_PLAYING,
  79. HUD_NUM_AREAS
  80. };
  81. enum scoreboardArea_t {
  82. SCOREBOARD_AREA_INVALID = -1,
  83. SCOREBOARD_AREA_DEFAULT,
  84. SCOREBOARD_AREA_TEAM,
  85. SCOREBOARD_AREA_CTF,
  86. SCOREBOARD_NUM_AREAS
  87. };
  88. enum pdaHandlerWidgets_t {
  89. PDA_WIDGET_NAV_BAR,
  90. PDA_WIDGET_PDA_LIST,
  91. PDA_WIDGET_PDA_LIST_SCROLLBAR,
  92. PDA_WIDGET_CMD_BAR
  93. };
  94. enum scoreboardHandlerWidgets_t {
  95. SCOREBOARD_WIDGET_CMD_BAR,
  96. };
  97. enum menuSounds_t {
  98. GUI_SOUND_MUSIC,
  99. GUI_SOUND_SCROLL,
  100. GUI_SOUND_ADVANCE,
  101. GUI_SOUND_BACK,
  102. GUI_SOUND_BUILD_ON,
  103. GUI_SOUND_BUILD_OFF,
  104. GUI_SOUND_FOCUS,
  105. GUI_SOUND_ROLL_OVER,
  106. GUI_SOUND_ROLL_OUT,
  107. NUM_GUI_SOUNDS,
  108. };
  109. static const int MAX_SCREEN_AREAS = 32;
  110. static const int DEFAULT_REPEAT_TIME = 150;
  111. static const int WAIT_START_TIME_LONG = 30000;
  112. static const int WAIT_START_TIME_SHORT = 5000;
  113. struct actionRepeater_t {
  114. actionRepeater_t() :
  115. widget( NULL ),
  116. numRepetitions( 0 ),
  117. nextRepeatTime( 0 ),
  118. screenIndex( -1 ),
  119. repeatDelay( DEFAULT_REPEAT_TIME ),
  120. isActive( false ) {
  121. }
  122. idMenuWidget * widget;
  123. idWidgetEvent event;
  124. idWidgetAction action;
  125. int numRepetitions;
  126. int nextRepeatTime;
  127. int repeatDelay;
  128. int screenIndex;
  129. bool isActive;
  130. };
  131. class mpScoreboardInfo{
  132. public:
  133. mpScoreboardInfo() :
  134. voiceState( VOICECHAT_DISPLAY_NONE ),
  135. score( 0 ),
  136. wins( 0 ),
  137. ping( 0 ),
  138. team( -1 ),
  139. playerNum( 0 ) {
  140. }
  141. mpScoreboardInfo( const mpScoreboardInfo & src ) {
  142. voiceState = src.voiceState;
  143. score = src.score;
  144. wins = src.wins;
  145. ping = src.ping;
  146. spectateData = src.spectateData;
  147. name = src.name;
  148. team = src.team;
  149. playerNum = src.playerNum;
  150. }
  151. void operator=( const mpScoreboardInfo & src ) {
  152. voiceState = src.voiceState;
  153. score = src.score;
  154. wins = src.wins;
  155. ping = src.ping;
  156. spectateData = src.spectateData;
  157. name = src.name;
  158. team = src.team;
  159. playerNum = src.playerNum;
  160. }
  161. bool operator!=( const mpScoreboardInfo & otherInfo ) const {
  162. if ( otherInfo.score != score || otherInfo.wins != wins || otherInfo.ping != ping ||
  163. otherInfo.spectateData != spectateData || otherInfo.name != name || otherInfo.team != team ||
  164. otherInfo.playerNum != playerNum || otherInfo.voiceState != voiceState ) {
  165. return true;
  166. }
  167. return false;
  168. }
  169. bool operator==( const mpScoreboardInfo & otherInfo ) const {
  170. if ( otherInfo.score != score || otherInfo.wins != wins || otherInfo.ping != ping ||
  171. otherInfo.spectateData != spectateData || otherInfo.name != name || otherInfo.team != team ||
  172. otherInfo.playerNum != playerNum || otherInfo.voiceState != voiceState ) {
  173. return false;
  174. }
  175. return true;
  176. }
  177. voiceStateDisplay_t voiceState;
  178. int score;
  179. int wins;
  180. int ping;
  181. int team;
  182. int playerNum;
  183. idStr spectateData;
  184. idStr name;
  185. };
  186. /*
  187. ================================================
  188. idMenuHandler
  189. ================================================
  190. */
  191. class idMenuHandler {
  192. public:
  193. idMenuHandler();
  194. virtual ~idMenuHandler();
  195. virtual void Initialize( const char * swfFile, idSoundWorld * sw );
  196. virtual void Cleanup();
  197. virtual void Update();
  198. virtual void UpdateChildren();
  199. virtual void UpdateMenuDisplay( int menu );
  200. virtual bool HandleGuiEvent( const sysEvent_t * sev );
  201. virtual bool IsActive();
  202. virtual void ActivateMenu( bool show );
  203. virtual void TriggerMenu();
  204. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  205. virtual int ActiveScreen() { return activeScreen; }
  206. virtual int NextScreen() { return nextScreen; }
  207. virtual int MenuTransition() { return transition; }
  208. virtual idMenuScreen * GetMenuScreen( int index ) { return NULL; }
  209. virtual void SetNextScreen( int screen, int trans ) { nextScreen = screen; transition = trans; }
  210. virtual void StartWidgetActionRepeater( idMenuWidget * widget, const idWidgetAction & action, const idWidgetEvent & event );
  211. virtual void PumpWidgetActionRepeater();
  212. virtual void ClearWidgetActionRepeater();
  213. virtual idSWF * GetGUI() { return gui; }
  214. virtual void AddChild( idMenuWidget * widget );
  215. virtual idMenuWidget * GetChildFromIndex( int index );
  216. virtual int GetPlatform( bool realPlatform = false );
  217. virtual void PlaySound( menuSounds_t type, int channel = -1 );
  218. virtual void StopSound( int channel = SCHANNEL_ANY );
  219. idMenuWidget_CommandBar * GetCmdBar() { return cmdBar; }
  220. protected:
  221. bool scrollingMenu;
  222. int scrollCounter;
  223. int activeScreen;
  224. int nextScreen;
  225. int transition;
  226. int platform;
  227. idSWF * gui;
  228. actionRepeater_t actionRepeater;
  229. idMenuScreen * menuScreens[MAX_SCREEN_AREAS];
  230. idList< idMenuWidget *, TAG_IDLIB_LIST_MENU> children;
  231. idStaticList< idStr, NUM_GUI_SOUNDS > sounds;
  232. idMenuWidget_CommandBar * cmdBar;
  233. };
  234. /*
  235. ================================================
  236. lobbyPlayerInfo_t
  237. ================================================
  238. */
  239. struct lobbyPlayerInfo_t {
  240. lobbyPlayerInfo_t() :
  241. partyToken( 0 ),
  242. voiceState( VOICECHAT_DISPLAY_NONE ) {
  243. }
  244. idStr name;
  245. int partyToken;
  246. voiceStateDisplay_t voiceState;
  247. };
  248. /*
  249. ================================================
  250. idMenuHandler_Shell
  251. ================================================
  252. */
  253. class idMenuHandler_Shell : public idMenuHandler {
  254. public:
  255. idMenuHandler_Shell() :
  256. state( SHELL_STATE_INVALID ),
  257. nextState( SHELL_STATE_INVALID ),
  258. smallFrameShowing( false ),
  259. largeFrameShowing( false ),
  260. bgShowing( true ),
  261. nextPeerUpdateMs( 0 ),
  262. inGame( false ),
  263. waitForBinding( false ),
  264. waitBind( NULL ),
  265. newGameType( 0 ),
  266. menuBar( NULL ),
  267. pacifier( NULL ),
  268. showingIntro( false ),
  269. introGui( NULL ),
  270. doom3Intro( NULL ),
  271. roeIntro( NULL ),
  272. lmIntro( NULL ),
  273. typeSoundShader( NULL ),
  274. continueWaitForEnumerate( false ),
  275. gameComplete( false ),
  276. marsRotation( NULL ) {
  277. }
  278. virtual void Update();
  279. virtual void ActivateMenu( bool show );
  280. virtual void Initialize( const char * swfFile, idSoundWorld * sw );
  281. virtual void Cleanup();
  282. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  283. virtual idMenuScreen * GetMenuScreen( int index );
  284. virtual bool HandleGuiEvent( const sysEvent_t * sev );
  285. void UpdateSavedGames();
  286. void ShowSmallFrame( bool show );
  287. void ShowMPFrame( bool show );
  288. void ShowLogo( bool show );
  289. void SetShellState( shellState_t s ) { nextState = s; }
  290. bool IsSmallFrameShowing() { return smallFrameShowing; }
  291. void UpdateBGState();
  292. void GetMapName( int index, idStr & name );
  293. void GetModeName( int index, idStr & name );
  294. idMenuWidget * GetPacifier() { return pacifier; }
  295. idMenuWidget_MenuBar * GetMenuBar() { return menuBar; }
  296. bool IsPacifierVisible() const { return ( pacifier != NULL && pacifier->GetSprite() != NULL ) ? pacifier->GetSprite()->IsVisible() : false; }
  297. void ShowPacifier( const idStr & msg );
  298. void HidePacifier();
  299. void SetTimeRemaining( int time ) { timeRemaining = time; }
  300. int GetTimeRemaining() { return timeRemaining; }
  301. void SetNewGameType( int type ) { newGameType = type; }
  302. int GetNewGameType() { return newGameType; }
  303. void SetInGame( bool val ) { inGame = val; }
  304. bool GetInGame() { return inGame; }
  305. void HandleExitGameBtn();
  306. void SetupPCOptions();
  307. void SetWaitForBinding( const char * bind ) { waitForBinding = true; waitBind = bind; }
  308. void ClearWaitForBinding() { waitForBinding = false; }
  309. void UpdateLeaderboard( const idLeaderboardCallback * callback );
  310. void UpdateLobby( idMenuWidget_LobbyList * lobbyList );
  311. void ShowDoomIntro();
  312. void ShowROEIntro();
  313. void ShowLEIntro();
  314. void StartGame( int index );
  315. void SetContinueWaitForEnumerate( bool wait ) { continueWaitForEnumerate = wait; }
  316. void SetCanContinue( bool valid );
  317. void SetGameComplete() { gameComplete = true; }
  318. bool GetGameComplete() { return gameComplete; }
  319. private:
  320. shellState_t state;
  321. shellState_t nextState;
  322. bool smallFrameShowing;
  323. bool largeFrameShowing;
  324. bool bgShowing;
  325. bool waitForBinding;
  326. const char * waitBind;
  327. //idSysSignal deviceRequestedSignal;
  328. idList<const char *, TAG_IDLIB_LIST_MENU> mpGameModes;
  329. idList<mpMap_t, TAG_IDLIB_LIST_MENU> mpGameMaps;
  330. idMenuWidget_MenuBar * menuBar;
  331. idMenuWidget * pacifier;
  332. int timeRemaining;
  333. int nextPeerUpdateMs;
  334. int newGameType;
  335. bool inGame;
  336. bool showingIntro;
  337. bool continueWaitForEnumerate;
  338. bool gameComplete;
  339. idSWF * introGui;
  340. const idSoundShader * typeSoundShader;
  341. const idMaterial * doom3Intro;
  342. const idMaterial * roeIntro;
  343. const idMaterial * lmIntro;
  344. const idMaterial * marsRotation;
  345. idList< idStr, TAG_IDLIB_LIST_MENU> navOptions;
  346. };
  347. /*
  348. ================================================
  349. idMenuHandler_PDA
  350. ================================================
  351. */
  352. class idMenuHandler_PDA : public idMenuHandler {
  353. public:
  354. idMenuHandler_PDA() :
  355. audioLogPlaying( false ),
  356. videoPlaying( false ),
  357. audioFile( NULL ) {
  358. }
  359. virtual ~idMenuHandler_PDA();
  360. virtual void Update();
  361. virtual void ActivateMenu( bool show );
  362. virtual void TriggerMenu();
  363. virtual void Initialize( const char * swfFile, idSoundWorld * sw );
  364. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  365. virtual idMenuScreen * GetMenuScreen( int index );
  366. void UpdateAudioLogPlaying( bool playing );
  367. void UdpateVideoPlaying( bool playing );
  368. void ClearVideoPlaying() { videoPlaying = false; }
  369. bool PlayPDAAudioLog( int pdaIndex, int audioIndex );
  370. virtual void Cleanup();
  371. protected:
  372. bool audioLogPlaying;
  373. bool videoPlaying;
  374. idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > pdaNames;
  375. idList< idStr, TAG_IDLIB_LIST_MENU > navOptions;
  376. const idDeclAudio * audioFile;
  377. idMenuWidget_ScrollBar pdaScrollBar;
  378. idMenuWidget_DynamicList pdaList;
  379. idMenuWidget_NavBar navBar;
  380. idMenuWidget_CommandBar commandBarWidget;
  381. };
  382. /*
  383. ================================================
  384. idMenuHandler_PDA
  385. ================================================
  386. */
  387. class idMenuHandler_HUD : public idMenuHandler {
  388. public:
  389. idMenuHandler_HUD() :
  390. autoHideTip( true ),
  391. tipStartTime( 0 ),
  392. hiding( false ),
  393. radioMessage( false ) {
  394. }
  395. virtual void Update();
  396. virtual void ActivateMenu( bool show );
  397. virtual void Initialize( const char * swfFile, idSoundWorld * sw );
  398. virtual idMenuScreen * GetMenuScreen( int index );
  399. idMenuScreen_HUD * GetHud();
  400. void ShowTip( const char * title, const char * tip, bool autoHide );
  401. void HideTip();
  402. void SetRadioMessage( bool show ) { radioMessage = show; }
  403. protected:
  404. bool autoHideTip;
  405. int tipStartTime;
  406. bool hiding;
  407. bool radioMessage;
  408. };
  409. /*
  410. ================================================
  411. idMenuHandler_Scoreboard
  412. ================================================
  413. */
  414. class idMenuHandler_Scoreboard : public idMenuHandler {
  415. public:
  416. idMenuHandler_Scoreboard() :
  417. redScore( 0 ),
  418. blueScore( 0 ),
  419. activationScreen( SCOREBOARD_AREA_INVALID ) {
  420. }
  421. virtual void Update();
  422. virtual void TriggerMenu();
  423. virtual void ActivateMenu( bool show );
  424. virtual void Initialize( const char * swfFile, idSoundWorld * sw );
  425. virtual idMenuScreen * GetMenuScreen( int index );
  426. virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
  427. void AddPlayerInfo( int index, voiceStateDisplay_t voiceState, int team, idStr name, int score, int wins, int ping, idStr spectateData );
  428. void UpdateScoreboard( idList< mpScoreboardInfo > & data, idStr gameInfo );
  429. void UpdateVoiceStates();
  430. void UpdateSpectating( idStr spectate, idStr follow );
  431. void SetTeamScores( int r, int b );
  432. int GetNumPlayers( int team );
  433. void SetActivationScreen( int screen, int trans );
  434. void ViewPlayerProfile( int slot );
  435. void MutePlayer( int slot );
  436. void GetUserID( int slot, lobbyUserID_t & luid );
  437. void UpdateScoreboardSelection();
  438. protected:
  439. int redScore;
  440. int blueScore;
  441. int activationScreen;
  442. idList< mpScoreboardInfo > scoreboardInfo;
  443. idList< scoreboardInfo_t, TAG_IDLIB_LIST_MENU > redInfo;
  444. idList< scoreboardInfo_t, TAG_IDLIB_LIST_MENU> blueInfo;
  445. };
  446. #endif //__MENUDATA_H__