Common_dialog.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 __COMMON_DIALOG_H__
  21. #define __COMMON_DIALOG_H__
  22. static const int MAX_DIALOGS = 4; // maximum dialogs that can be open at one time
  23. static const int PC_KEYBOARD_WAIT = 20000;
  24. /*
  25. ================================================
  26. Dialog box message types
  27. ================================================
  28. */
  29. enum gameDialogMessages_t {
  30. GDM_INVALID,
  31. GDM_SWAP_DISKS_TO1,
  32. GDM_SWAP_DISKS_TO2,
  33. GDM_SWAP_DISKS_TO3,
  34. GDM_NO_GAMER_PROFILE,
  35. GDM_PLAY_ONLINE_NO_PROFILE,
  36. GDM_LEADERBOARD_ONLINE_NO_PROFILE,
  37. GDM_NO_STORAGE_SELECTED,
  38. GDM_ONLINE_INCORRECT_PERMISSIONS,
  39. GDM_SP_QUIT_SAVE,
  40. GDM_SP_RESTART_SAVE,
  41. GDM_SP_SIGNIN_CHANGE,
  42. GDM_SERVER_NOT_AVAILABLE,
  43. GDM_CONNECTION_LOST_HOST,
  44. GDM_CONNECTION_LOST,
  45. GDM_OPPONENT_CONNECTION_LOST,
  46. GDM_HOST_CONNECTION_LOST,
  47. GDM_HOST_CONNECTION_LOST_STATS,
  48. GDM_FAILED_TO_LOAD_RANKINGS,
  49. GDM_HOST_QUIT,
  50. GDM_BECAME_HOST_PARTY, // Became host of party
  51. GDM_NEW_HOST_PARTY, // Someone else became host of party
  52. GDM_LOBBY_BECAME_HOST_GAME, // In lobby, you became game host
  53. GDM_LOBBY_NEW_HOST_GAME, // In lobby, new game host was chosen (not you)
  54. GDM_NEW_HOST_GAME, // Host left/DC'd, someone else is new host, unranked game
  55. GDM_NEW_HOST_GAME_STATS_DROPPED,// Host left/DC'd, someone else is new host, ranked game so stats were dropped
  56. GDM_BECAME_HOST_GAME, // Host left/DC'd, you became host, unranked game
  57. GDM_BECAME_HOST_GAME_STATS_DROPPED, // Host left/DC'd, you became host, ranked game so stats were dropped
  58. GDM_LOBBY_DISBANDED,
  59. GDM_LEAVE_WITH_PARTY,
  60. GDM_LEAVE_LOBBY_RET_MAIN,
  61. GDM_LEAVE_LOBBY_RET_NEW_PARTY,
  62. GDM_MIGRATING,
  63. GDM_OPPONENT_LEFT,
  64. GDM_NO_MATCHES_FOUND,
  65. GDM_INVALID_INVITE,
  66. GDM_KICKED,
  67. GDM_BANNED,
  68. GDM_SAVING,
  69. GDM_OVERWRITE_SAVE,
  70. GDM_LOAD_REQUEST,
  71. GDM_AUTOSAVE_DISABLED_STORAGE_REMOVED,
  72. GDM_STORAGE_INVALID,
  73. GDM_STORAGE_REMOVED,
  74. GDM_CONNECTING,
  75. GDM_REFRESHING,
  76. GDM_DELETE_SAVE,
  77. GDM_DELETING,
  78. GDM_BINDING_ALREDY_SET,
  79. GDM_CANNOT_BIND,
  80. GDM_OVERLAY_DISABLED,
  81. GDM_DIRECT_MAP_CHANGE,
  82. GDM_DELETE_AUTOSAVE,
  83. GDM_QUICK_SAVE,
  84. GDM_MULTI_RETRY,
  85. GDM_MULTI_SELF_DESTRUCT,
  86. GDM_MULTI_VDM_QUIT,
  87. GDM_MULTI_COOP_QUIT,
  88. GDM_LOADING_PROFILE,
  89. GDM_STORAGE_REQUIRED,
  90. GDM_INSUFFICENT_STORAGE_SPACE,
  91. GDM_PARTNER_LEFT,
  92. GDM_RESTORE_CORRUPT_SAVEGAME,
  93. GDM_UNRECOVERABLE_SAVEGAME,
  94. GDM_PROFILE_SAVE_ERROR,
  95. GDM_LOBBY_FULL,
  96. GDM_QUIT_GAME,
  97. GDM_CONNECTION_PROBLEMS,
  98. GDM_VOICE_RESTRICTED,
  99. GDM_LOAD_DAMAGED_FILE,
  100. GDM_MUST_SIGNIN,
  101. GDM_CONNECTION_LOST_NO_LEADERBOARD,
  102. GDM_SP_SIGNIN_CHANGE_POST,
  103. GDM_MIGRATING_WAITING,
  104. GDM_MIGRATING_RELAUNCHING,
  105. GDM_MIGRATING_FAILED_CONNECTION,
  106. GDM_MIGRATING_FAILED_CONNECTION_STATS,
  107. GDM_MIGRATING_FAILED_DISBANDED,
  108. GDM_MIGRATING_FAILED_DISBANDED_STATS,
  109. GDM_MIGRATING_FAILED_PARTNER_LEFT,
  110. GDM_HOST_RETURNED_TO_LOBBY,
  111. GDM_HOST_RETURNED_TO_LOBBY_STATS_DROPPED,
  112. GDM_FAILED_JOIN_LOCAL_SESSION,
  113. GDM_DELETE_CORRUPT_SAVEGAME,
  114. GDM_LEAVE_INCOMPLETE_INSTANCE,
  115. GDM_UNBIND_CONFIRM,
  116. GDM_BINDINGS_RESTORE,
  117. GDM_NEW_HOST,
  118. GDM_CONFIRM_VIDEO_CHANGES,
  119. GDM_UNABLE_TO_USE_SELECTED_STORAGE_DEVICE,
  120. GDM_ERROR_LOADING_SAVEGAME,
  121. GDM_ERROR_SAVING_SAVEGAME,
  122. GDM_DISCARD_CHANGES,
  123. GDM_LEAVE_LOBBY,
  124. GDM_LEAVE_LOBBY_AND_TEAM,
  125. GDM_CONTROLLER_DISCONNECTED_0,
  126. GDM_CONTROLLER_DISCONNECTED_1,
  127. GDM_CONTROLLER_DISCONNECTED_2,
  128. GDM_CONTROLLER_DISCONNECTED_3,
  129. GDM_CONTROLLER_DISCONNECTED_4,
  130. GDM_CONTROLLER_DISCONNECTED_5,
  131. GDM_CONTROLLER_DISCONNECTED_6,
  132. GDM_DLC_ERROR_REMOVED,
  133. GDM_DLC_ERROR_CORRUPT,
  134. GDM_DLC_ERROR_MISSING,
  135. GDM_DLC_ERROR_MISSING_GENERIC,
  136. GDM_DISC_SWAP,
  137. GDM_NEEDS_INSTALL,
  138. GDM_NO_SAVEGAMES_AVAILABLE,
  139. GDM_ERROR_JOIN_TWO_PROFILES_ONE_BOX,
  140. GDM_WARNING_PLAYING_COOP_SOLO,
  141. GDM_MULTI_COOP_QUIT_LOSE_LEADERBOARDS,
  142. GDM_CORRUPT_CONTINUE,
  143. GDM_MULTI_VDM_QUIT_LOSE_LEADERBOARDS,
  144. GDM_WARNING_PLAYING_VDM_SOLO,
  145. GDM_NO_GUEST_SUPPORT,
  146. GDM_DISC_SWAP_CONFIRMATION,
  147. GDM_ERROR_LOADING_PROFILE,
  148. GDM_CANNOT_INVITE_LOBBY_FULL,
  149. GDM_WARNING_FOR_NEW_DEVICE_ABOUT_TO_LOSE_PROGRESS,
  150. GDM_DISCONNECTED,
  151. GDM_INCOMPATIBLE_NEWER_SAVE,
  152. GDM_ACHIEVEMENTS_DISABLED_DUE_TO_CHEATING,
  153. GDM_INCOMPATIBLE_POINTER_SIZE,
  154. GDM_TEXTUREDETAIL_RESTARTREQUIRED,
  155. GDM_TEXTUREDETAIL_INSUFFICIENT_CPU,
  156. GDM_CHECKPOINT_SAVE,
  157. GDM_CALCULATING_BENCHMARK,
  158. GDM_DISPLAY_BENCHMARK,
  159. GDM_DISPLAY_CHANGE_FAILED,
  160. GDM_GPU_TRANSCODE_FAILED,
  161. GDM_OUT_OF_MEMORY,
  162. GDM_CORRUPT_PROFILE,
  163. GDM_PROFILE_TOO_OUT_OF_DATE_DEVELOPMENT_ONLY,
  164. GDM_SP_LOAD_SAVE,
  165. GDM_INSTALLING_TROPHIES,
  166. GDM_XBOX_DEPLOYMENT_TYPE_FAIL,
  167. GDM_SAVEGAME_WRONG_LANGUAGE,
  168. GDM_GAME_RESTART_REQUIRED,
  169. GDM_MAX
  170. };
  171. /*
  172. ================================================
  173. Dialog box types
  174. ================================================
  175. */
  176. enum dialogType_t {
  177. DIALOG_INVALID = -1,
  178. DIALOG_ACCEPT,
  179. DIALOG_CONTINUE,
  180. DIALOG_ACCEPT_CANCEL,
  181. DIALOG_YES_NO,
  182. DIALOG_CANCEL,
  183. DIALOG_WAIT,
  184. DIALOG_WAIT_BLACKOUT,
  185. DIALOG_WAIT_CANCEL,
  186. DIALOG_DYNAMIC,
  187. DIALOG_QUICK_SAVE,
  188. DIALOG_TIMER_ACCEPT_REVERT,
  189. DIALOG_CRAWL_SAVE,
  190. DIALOG_CONTINUE_LARGE,
  191. DIALOG_BENCHMARK,
  192. };
  193. /*
  194. ================================================
  195. idDialogInfo
  196. ================================================
  197. */
  198. class idDialogInfo {
  199. public:
  200. idDialogInfo() {
  201. msg = GDM_INVALID;
  202. type = DIALOG_ACCEPT;
  203. acceptCB = NULL;
  204. cancelCB = NULL;
  205. altCBOne = NULL;
  206. altCBTwo = NULL;
  207. showing = false;
  208. clear = false;
  209. waitClear = false;
  210. pause = false;
  211. startTime = 0;
  212. killTime = 0;
  213. leaveOnClear = false;
  214. renderDuringLoad = false;
  215. }
  216. gameDialogMessages_t msg;
  217. dialogType_t type;
  218. idSWFScriptFunction * acceptCB;
  219. idSWFScriptFunction * cancelCB;
  220. idSWFScriptFunction * altCBOne;
  221. idSWFScriptFunction * altCBTwo;
  222. bool showing;
  223. bool clear;
  224. bool waitClear;
  225. bool pause;
  226. bool forcePause;
  227. bool leaveOnClear;
  228. bool renderDuringLoad;
  229. int startTime;
  230. int killTime;
  231. idStrStatic< 256 > overrideMsg;
  232. idStrId txt1;
  233. idStrId txt2;
  234. idStrId txt3;
  235. idStrId txt4;
  236. };
  237. /*
  238. ================================================
  239. idLoadScreenInfo
  240. ================================================
  241. */
  242. class idLoadScreenInfo {
  243. public:
  244. idStr varName;
  245. idStr value;
  246. };
  247. /*
  248. ==============================================================
  249. Common Dialog
  250. ==============================================================
  251. */
  252. class idCommonDialog {
  253. public:
  254. void Init();
  255. void Render( bool loading );
  256. void Shutdown();
  257. void Restart();
  258. bool IsDialogPausing() { return dialogPause; }
  259. void ClearDialogs( bool forceClear = false );
  260. bool HasDialogMsg( gameDialogMessages_t msg, bool * isNowActive );
  261. void AddDialog( gameDialogMessages_t msg, dialogType_t type, idSWFScriptFunction * acceptCallback, idSWFScriptFunction * cancelCallback, bool pause, const char * location = NULL, int lineNumber = 0, bool leaveOnMapHeapReset = false, bool waitOnAtlas = false, bool renderDuringLoad = false );
  262. void AddDynamicDialog( gameDialogMessages_t msg, const idStaticList< idSWFScriptFunction *, 4 > & callbacks, const idStaticList< idStrId, 4 > & optionText, bool pause, idStrStatic< 256 > overrideMsg, bool leaveOnMapHeapReset = false, bool waitOnAtlas = false, bool renderDuringLoad = false );
  263. void AddDialogIntVal( const char * name, int val );
  264. bool IsDialogActive();
  265. void ClearDialog( gameDialogMessages_t msg, const char * location = NULL, int lineNumber = 0 );
  266. void ShowSaveIndicator( bool show );
  267. bool HasAnyActiveDialog() const { return ( messageList.Num() > 0 ) && ( !messageList[0].clear ); }
  268. void ClearAllDialogHack();
  269. idStr GetDialogMsg( gameDialogMessages_t msg, idStr & message, idStr & title );
  270. bool HandleDialogEvent( const sysEvent_t * sev );
  271. protected:
  272. void RemoveWaitDialogs();
  273. void ShowDialog( const idDialogInfo & info );
  274. void ShowNextDialog();
  275. void ActivateDialog( bool activate );
  276. void AddDialogInternal( idDialogInfo & info );
  277. void ReleaseCallBacks( int index );
  278. private:
  279. bool dialogPause;
  280. idSWF * dialog;
  281. idSWF * saveIndicator;
  282. bool dialogShowingSaveIndicatorRequested;
  283. int dialogShowingSaveIndicatorTimeRemaining;
  284. idStaticList< idDialogInfo, MAX_DIALOGS > messageList;
  285. idStaticList< idLoadScreenInfo, 16 > loadScreenInfo;
  286. int startSaveTime; // with stopSaveTime, useful to pass 360 TCR# 047. Need to keep the dialog on the screen for a minimum amount of time
  287. int stopSaveTime;
  288. bool dialogInUse; // this is to prevent an active msg getting lost during a map heap reset
  289. };
  290. #endif