Common_dialog.cpp 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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. #include "../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include "Common_dialog.h"
  23. idCVar popupDialog_debug( "popupDialog_debug", "0", CVAR_BOOL | CVAR_ARCHIVE, "display debug spam" );
  24. extern idCVar g_demoMode;
  25. static const char * dialogStateToString[ GDM_MAX + 1 ] = {
  26. ASSERT_ENUM_STRING( GDM_INVALID, 0 ),
  27. ASSERT_ENUM_STRING( GDM_SWAP_DISKS_TO1, 1 ),
  28. ASSERT_ENUM_STRING( GDM_SWAP_DISKS_TO2, 2 ),
  29. ASSERT_ENUM_STRING( GDM_SWAP_DISKS_TO3, 3 ),
  30. ASSERT_ENUM_STRING( GDM_NO_GAMER_PROFILE, 4 ),
  31. ASSERT_ENUM_STRING( GDM_PLAY_ONLINE_NO_PROFILE, 5 ),
  32. ASSERT_ENUM_STRING( GDM_LEADERBOARD_ONLINE_NO_PROFILE, 6 ),
  33. ASSERT_ENUM_STRING( GDM_NO_STORAGE_SELECTED, 7 ),
  34. ASSERT_ENUM_STRING( GDM_ONLINE_INCORRECT_PERMISSIONS, 8 ),
  35. ASSERT_ENUM_STRING( GDM_SP_QUIT_SAVE, 9 ),
  36. ASSERT_ENUM_STRING( GDM_SP_RESTART_SAVE, 10 ),
  37. ASSERT_ENUM_STRING( GDM_SP_SIGNIN_CHANGE, 11 ),
  38. ASSERT_ENUM_STRING( GDM_SERVER_NOT_AVAILABLE, 12 ),
  39. ASSERT_ENUM_STRING( GDM_CONNECTION_LOST_HOST, 13 ),
  40. ASSERT_ENUM_STRING( GDM_CONNECTION_LOST, 14 ),
  41. ASSERT_ENUM_STRING( GDM_OPPONENT_CONNECTION_LOST, 15 ),
  42. ASSERT_ENUM_STRING( GDM_HOST_CONNECTION_LOST, 16 ),
  43. ASSERT_ENUM_STRING( GDM_HOST_CONNECTION_LOST_STATS, 17 ),
  44. ASSERT_ENUM_STRING( GDM_FAILED_TO_LOAD_RANKINGS, 18 ),
  45. ASSERT_ENUM_STRING( GDM_HOST_QUIT, 19 ),
  46. ASSERT_ENUM_STRING( GDM_BECAME_HOST_PARTY, 20 ),
  47. ASSERT_ENUM_STRING( GDM_NEW_HOST_PARTY, 21 ),
  48. ASSERT_ENUM_STRING( GDM_LOBBY_BECAME_HOST_GAME, 22 ),
  49. ASSERT_ENUM_STRING( GDM_LOBBY_NEW_HOST_GAME, 23 ),
  50. ASSERT_ENUM_STRING( GDM_NEW_HOST_GAME, 24 ),
  51. ASSERT_ENUM_STRING( GDM_NEW_HOST_GAME_STATS_DROPPED, 25 ),
  52. ASSERT_ENUM_STRING( GDM_BECAME_HOST_GAME, 26 ),
  53. ASSERT_ENUM_STRING( GDM_BECAME_HOST_GAME_STATS_DROPPED, 27 ),
  54. ASSERT_ENUM_STRING( GDM_LOBBY_DISBANDED, 28 ),
  55. ASSERT_ENUM_STRING( GDM_LEAVE_WITH_PARTY, 29 ),
  56. ASSERT_ENUM_STRING( GDM_LEAVE_LOBBY_RET_MAIN, 30 ),
  57. ASSERT_ENUM_STRING( GDM_LEAVE_LOBBY_RET_NEW_PARTY, 31 ),
  58. ASSERT_ENUM_STRING( GDM_MIGRATING, 32 ),
  59. ASSERT_ENUM_STRING( GDM_OPPONENT_LEFT, 33 ),
  60. ASSERT_ENUM_STRING( GDM_NO_MATCHES_FOUND, 34 ),
  61. ASSERT_ENUM_STRING( GDM_INVALID_INVITE, 35 ),
  62. ASSERT_ENUM_STRING( GDM_KICKED, 36 ),
  63. ASSERT_ENUM_STRING( GDM_BANNED, 37 ),
  64. ASSERT_ENUM_STRING( GDM_SAVING, 38 ),
  65. ASSERT_ENUM_STRING( GDM_OVERWRITE_SAVE, 39 ),
  66. ASSERT_ENUM_STRING( GDM_LOAD_REQUEST, 40 ),
  67. ASSERT_ENUM_STRING( GDM_AUTOSAVE_DISABLED_STORAGE_REMOVED, 41 ),
  68. ASSERT_ENUM_STRING( GDM_STORAGE_INVALID, 42 ),
  69. ASSERT_ENUM_STRING( GDM_STORAGE_REMOVED, 43 ),
  70. ASSERT_ENUM_STRING( GDM_CONNECTING, 44 ),
  71. ASSERT_ENUM_STRING( GDM_REFRESHING, 45 ),
  72. ASSERT_ENUM_STRING( GDM_DELETE_SAVE, 46 ),
  73. ASSERT_ENUM_STRING( GDM_DELETING, 47 ),
  74. ASSERT_ENUM_STRING( GDM_BINDING_ALREDY_SET, 48 ),
  75. ASSERT_ENUM_STRING( GDM_CANNOT_BIND, 49 ),
  76. ASSERT_ENUM_STRING( GDM_OVERLAY_DISABLED, 50 ),
  77. ASSERT_ENUM_STRING( GDM_DIRECT_MAP_CHANGE, 51 ),
  78. ASSERT_ENUM_STRING( GDM_DELETE_AUTOSAVE, 52 ),
  79. ASSERT_ENUM_STRING( GDM_QUICK_SAVE, 53 ),
  80. ASSERT_ENUM_STRING( GDM_MULTI_RETRY, 54 ),
  81. ASSERT_ENUM_STRING( GDM_MULTI_SELF_DESTRUCT, 55 ),
  82. ASSERT_ENUM_STRING( GDM_MULTI_VDM_QUIT, 56 ),
  83. ASSERT_ENUM_STRING( GDM_MULTI_COOP_QUIT, 57 ),
  84. ASSERT_ENUM_STRING( GDM_LOADING_PROFILE, 58 ),
  85. ASSERT_ENUM_STRING( GDM_STORAGE_REQUIRED, 59 ),
  86. ASSERT_ENUM_STRING( GDM_INSUFFICENT_STORAGE_SPACE, 60 ),
  87. ASSERT_ENUM_STRING( GDM_PARTNER_LEFT, 61 ),
  88. ASSERT_ENUM_STRING( GDM_RESTORE_CORRUPT_SAVEGAME, 62 ),
  89. ASSERT_ENUM_STRING( GDM_UNRECOVERABLE_SAVEGAME, 63 ),
  90. ASSERT_ENUM_STRING( GDM_PROFILE_SAVE_ERROR, 64 ),
  91. ASSERT_ENUM_STRING( GDM_LOBBY_FULL, 65 ),
  92. ASSERT_ENUM_STRING( GDM_QUIT_GAME, 66 ),
  93. ASSERT_ENUM_STRING( GDM_CONNECTION_PROBLEMS, 67 ),
  94. ASSERT_ENUM_STRING( GDM_VOICE_RESTRICTED, 68 ),
  95. ASSERT_ENUM_STRING( GDM_LOAD_DAMAGED_FILE, 69 ),
  96. ASSERT_ENUM_STRING( GDM_MUST_SIGNIN, 70 ),
  97. ASSERT_ENUM_STRING( GDM_CONNECTION_LOST_NO_LEADERBOARD, 71 ),
  98. ASSERT_ENUM_STRING( GDM_SP_SIGNIN_CHANGE_POST, 72 ),
  99. ASSERT_ENUM_STRING( GDM_MIGRATING_WAITING, 73 ),
  100. ASSERT_ENUM_STRING( GDM_MIGRATING_RELAUNCHING, 74 ),
  101. ASSERT_ENUM_STRING( GDM_MIGRATING_FAILED_CONNECTION, 75 ),
  102. ASSERT_ENUM_STRING( GDM_MIGRATING_FAILED_CONNECTION_STATS, 76 ),
  103. ASSERT_ENUM_STRING( GDM_MIGRATING_FAILED_DISBANDED, 77 ),
  104. ASSERT_ENUM_STRING( GDM_MIGRATING_FAILED_DISBANDED_STATS, 78 ),
  105. ASSERT_ENUM_STRING( GDM_MIGRATING_FAILED_PARTNER_LEFT, 79 ),
  106. ASSERT_ENUM_STRING( GDM_HOST_RETURNED_TO_LOBBY, 80 ),
  107. ASSERT_ENUM_STRING( GDM_HOST_RETURNED_TO_LOBBY_STATS_DROPPED, 81 ),
  108. ASSERT_ENUM_STRING( GDM_FAILED_JOIN_LOCAL_SESSION, 82 ),
  109. ASSERT_ENUM_STRING( GDM_DELETE_CORRUPT_SAVEGAME, 83 ),
  110. ASSERT_ENUM_STRING( GDM_LEAVE_INCOMPLETE_INSTANCE, 84 ),
  111. ASSERT_ENUM_STRING( GDM_UNBIND_CONFIRM, 85 ),
  112. ASSERT_ENUM_STRING( GDM_BINDINGS_RESTORE, 86 ),
  113. ASSERT_ENUM_STRING( GDM_NEW_HOST, 87 ),
  114. ASSERT_ENUM_STRING( GDM_CONFIRM_VIDEO_CHANGES, 88 ),
  115. ASSERT_ENUM_STRING( GDM_UNABLE_TO_USE_SELECTED_STORAGE_DEVICE, 89 ),
  116. ASSERT_ENUM_STRING( GDM_ERROR_LOADING_SAVEGAME, 90 ),
  117. ASSERT_ENUM_STRING( GDM_ERROR_SAVING_SAVEGAME, 91 ),
  118. ASSERT_ENUM_STRING( GDM_DISCARD_CHANGES, 92 ),
  119. ASSERT_ENUM_STRING( GDM_LEAVE_LOBBY, 93 ),
  120. ASSERT_ENUM_STRING( GDM_LEAVE_LOBBY_AND_TEAM, 94 ),
  121. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_0, 95 ),
  122. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_1, 96 ),
  123. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_2, 97 ),
  124. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_3, 98 ),
  125. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_4, 99 ),
  126. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_5, 100 ),
  127. ASSERT_ENUM_STRING( GDM_CONTROLLER_DISCONNECTED_6, 101 ),
  128. ASSERT_ENUM_STRING( GDM_DLC_ERROR_REMOVED, 102 ),
  129. ASSERT_ENUM_STRING( GDM_DLC_ERROR_CORRUPT, 103 ),
  130. ASSERT_ENUM_STRING( GDM_DLC_ERROR_MISSING, 104 ),
  131. ASSERT_ENUM_STRING( GDM_DLC_ERROR_MISSING_GENERIC, 105 ),
  132. ASSERT_ENUM_STRING( GDM_DISC_SWAP, 106 ),
  133. ASSERT_ENUM_STRING( GDM_NEEDS_INSTALL, 107 ),
  134. ASSERT_ENUM_STRING( GDM_NO_SAVEGAMES_AVAILABLE, 108 ),
  135. ASSERT_ENUM_STRING( GDM_ERROR_JOIN_TWO_PROFILES_ONE_BOX, 109 ),
  136. ASSERT_ENUM_STRING( GDM_WARNING_PLAYING_COOP_SOLO, 110 ),
  137. ASSERT_ENUM_STRING( GDM_MULTI_COOP_QUIT_LOSE_LEADERBOARDS, 111 ),
  138. ASSERT_ENUM_STRING( GDM_CORRUPT_CONTINUE, 112 ),
  139. ASSERT_ENUM_STRING( GDM_MULTI_VDM_QUIT_LOSE_LEADERBOARDS, 113 ),
  140. ASSERT_ENUM_STRING( GDM_WARNING_PLAYING_VDM_SOLO, 114 ),
  141. ASSERT_ENUM_STRING( GDM_NO_GUEST_SUPPORT, 115 ),
  142. ASSERT_ENUM_STRING( GDM_DISC_SWAP_CONFIRMATION, 116 ),
  143. ASSERT_ENUM_STRING( GDM_ERROR_LOADING_PROFILE, 117 ),
  144. ASSERT_ENUM_STRING( GDM_CANNOT_INVITE_LOBBY_FULL, 118 ),
  145. ASSERT_ENUM_STRING( GDM_WARNING_FOR_NEW_DEVICE_ABOUT_TO_LOSE_PROGRESS, 119 ),
  146. ASSERT_ENUM_STRING( GDM_DISCONNECTED, 120 ),
  147. ASSERT_ENUM_STRING( GDM_INCOMPATIBLE_NEWER_SAVE, 121 ),
  148. ASSERT_ENUM_STRING( GDM_ACHIEVEMENTS_DISABLED_DUE_TO_CHEATING, 122 ),
  149. ASSERT_ENUM_STRING( GDM_INCOMPATIBLE_POINTER_SIZE, 123 ),
  150. ASSERT_ENUM_STRING( GDM_TEXTUREDETAIL_RESTARTREQUIRED, 124 ),
  151. ASSERT_ENUM_STRING( GDM_TEXTUREDETAIL_INSUFFICIENT_CPU, 125 ),
  152. ASSERT_ENUM_STRING( GDM_CHECKPOINT_SAVE, 126 ),
  153. ASSERT_ENUM_STRING( GDM_CALCULATING_BENCHMARK, 127 ),
  154. ASSERT_ENUM_STRING( GDM_DISPLAY_BENCHMARK, 128 ),
  155. ASSERT_ENUM_STRING( GDM_DISPLAY_CHANGE_FAILED, 129 ),
  156. ASSERT_ENUM_STRING( GDM_GPU_TRANSCODE_FAILED, 130 ),
  157. ASSERT_ENUM_STRING( GDM_OUT_OF_MEMORY, 131 ),
  158. ASSERT_ENUM_STRING( GDM_CORRUPT_PROFILE, 132 ),
  159. ASSERT_ENUM_STRING( GDM_PROFILE_TOO_OUT_OF_DATE_DEVELOPMENT_ONLY, 133 ),
  160. ASSERT_ENUM_STRING( GDM_SP_LOAD_SAVE, 134 ),
  161. ASSERT_ENUM_STRING( GDM_INSTALLING_TROPHIES, 135 ),
  162. ASSERT_ENUM_STRING( GDM_XBOX_DEPLOYMENT_TYPE_FAIL, 136 ),
  163. ASSERT_ENUM_STRING( GDM_SAVEGAME_WRONG_LANGUAGE, 137 ),
  164. ASSERT_ENUM_STRING( GDM_GAME_RESTART_REQUIRED, 138 ),
  165. ASSERT_ENUM_STRING( GDM_MAX, 139 )
  166. };
  167. idCVar dialog_saveClearLevel( "dialog_saveClearLevel", "1000", CVAR_INTEGER, "Time required to show long message" );
  168. /*
  169. ========================
  170. bool DialogMsgShouldWait
  171. There are a few dialog types that should pause so the user has the ability to read what's going on
  172. ========================
  173. */
  174. bool DialogMsgShouldWait( gameDialogMessages_t msg ) {
  175. switch ( msg ) {
  176. case GDM_SAVING:
  177. case GDM_QUICK_SAVE:
  178. case GDM_LOADING_PROFILE:
  179. case GDM_INSTALLING_TROPHIES:
  180. case GDM_REFRESHING:
  181. return true;
  182. default:
  183. return false;
  184. }
  185. }
  186. /*
  187. ================================================
  188. idCommonDialog::ClearDialogs
  189. ================================================
  190. */
  191. void idCommonDialog::ClearDialogs( bool forceClear ) {
  192. bool topMessageCleared = false;
  193. for ( int index = 0; index < messageList.Num(); ++index ) {
  194. if ( !messageList[index].leaveOnClear || forceClear ) {
  195. ReleaseCallBacks( index );
  196. messageList.RemoveIndex( index );
  197. if ( index == 0 ) {
  198. topMessageCleared = true;
  199. }
  200. index--;
  201. }
  202. }
  203. if ( topMessageCleared ) {
  204. ActivateDialog( false );
  205. }
  206. }
  207. /*
  208. ================================================
  209. idCommonDialog::AddDialogIntVal
  210. ================================================
  211. */
  212. void idCommonDialog::AddDialogIntVal( const char * name, int val ) {
  213. if ( dialog != NULL ) {
  214. dialog->SetGlobal( name, val );
  215. }
  216. }
  217. /*
  218. ================================================
  219. idCommonDialog::AddDialog
  220. ================================================
  221. */
  222. void idCommonDialog::AddDialog( gameDialogMessages_t msg, dialogType_t type, idSWFScriptFunction * acceptCallback,
  223. idSWFScriptFunction * cancelCallback, bool pause, const char * location, int lineNumber,
  224. bool leaveOnMapHeapReset, bool waitOnAtlas, bool renderDuringLoad ) {
  225. idKeyInput::ClearStates();
  226. // TODO_D3_PORT:
  227. //sys->ClearEvents();
  228. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s] msg: %s, pause: %d from: %s:%d\n", __FUNCTION__, dialogStateToString[msg], pause, location == NULL ? "NULL" : location, lineNumber );
  229. if ( dialog == NULL ) {
  230. return;
  231. }
  232. idDialogInfo info;
  233. info.msg = msg;
  234. info.type = type;
  235. info.acceptCB = acceptCallback;
  236. info.cancelCB = cancelCallback;
  237. info.clear = false;
  238. info.pause = pause;
  239. info.startTime = Sys_Milliseconds();
  240. info.killTime = 0;
  241. info.leaveOnClear = leaveOnMapHeapReset;
  242. info.renderDuringLoad = renderDuringLoad;
  243. AddDialogInternal( info );
  244. }
  245. /*
  246. ========================
  247. idCommonDialog::AddDynamicDialog
  248. ========================
  249. */
  250. void idCommonDialog::AddDynamicDialog( gameDialogMessages_t msg, const idStaticList< idSWFScriptFunction *, 4 > & callbacks,
  251. const idStaticList< idStrId, 4 > & optionText, bool pause, idStrStatic< 256 > overrideMsg,
  252. bool leaveOnMapHeapReset, bool waitOnAtlas, bool renderDuringLoad ) {
  253. if ( dialog == NULL ) {
  254. return;
  255. }
  256. idDialogInfo info;
  257. info.msg = msg;
  258. info.overrideMsg = overrideMsg;
  259. info.type = DIALOG_DYNAMIC;
  260. info.pause = pause;
  261. info.leaveOnClear = leaveOnMapHeapReset;
  262. info.acceptCB = 0 < callbacks.Num() ? callbacks[0] : NULL;
  263. info.cancelCB = 1 < callbacks.Num() ? callbacks[1] : NULL;
  264. info.altCBOne = 2 < callbacks.Num() ? callbacks[2] : NULL;
  265. info.altCBTwo = 3 < callbacks.Num() ? callbacks[3] : NULL;
  266. info.txt1 = 0 < optionText.Num() ? optionText[0] : idStrId();
  267. info.txt2 = 1 < optionText.Num() ? optionText[1] : idStrId();
  268. info.txt3 = 2 < optionText.Num() ? optionText[2] : idStrId();
  269. info.txt4 = 3 < optionText.Num() ? optionText[3] : idStrId();
  270. info.renderDuringLoad = renderDuringLoad;
  271. info.clear = false;
  272. info.startTime = Sys_Milliseconds();
  273. info.killTime = 0;
  274. AddDialogInternal( info );
  275. }
  276. /*
  277. ========================
  278. idCommonDialog::AddDialogInternal
  279. ========================
  280. */
  281. void idCommonDialog::AddDialogInternal( idDialogInfo & info ) {
  282. // don't add the dialog if it's already in the list, we never want to show a duplicate dialog
  283. if ( HasDialogMsg( info.msg, NULL ) ) {
  284. return;
  285. }
  286. // Remove the delete confirmation if we remove the device and ask for a storage confirmation
  287. if ( info.msg == GDM_STORAGE_REQUIRED ) {
  288. if ( HasDialogMsg( GDM_DELETE_SAVE, NULL ) ) {
  289. ClearDialog( GDM_DELETE_SAVE, NULL, 0 );
  290. }
  291. if ( HasDialogMsg( GDM_DELETE_AUTOSAVE, NULL ) ) {
  292. ClearDialog( GDM_DELETE_AUTOSAVE, NULL, 0 );
  293. }
  294. if ( HasDialogMsg( GDM_LOAD_DAMAGED_FILE, NULL ) ) {
  295. ClearDialog( GDM_LOAD_DAMAGED_FILE, NULL, 0 );
  296. }
  297. }
  298. if ( info.acceptCB != NULL ) {
  299. info.acceptCB->AddRef();
  300. }
  301. if ( info.cancelCB != NULL ) {
  302. info.cancelCB->AddRef();
  303. }
  304. if ( info.altCBOne != NULL ) {
  305. info.altCBOne->AddRef();
  306. }
  307. if ( info.altCBTwo != NULL ) {
  308. info.altCBTwo->AddRef();
  309. }
  310. if ( messageList.Num() == 0 ) {
  311. messageList.Append( info );
  312. } else {
  313. // attempting to add another one beyond our set max. take off the oldest
  314. // one from the list in order to not crash, but this really isn't a good
  315. // thing to be happening...
  316. if ( !verify( messageList.Num() < MAX_DIALOGS ) ) {
  317. messageList.RemoveIndex( MAX_DIALOGS - 1 );
  318. }
  319. if ( messageList.Num() > 0 ) {
  320. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s] msg: %s new dialog added over old\n", __FUNCTION__, dialogStateToString[info.msg] );
  321. dialog->Activate( false );
  322. messageList.Insert( info, 0 );
  323. }
  324. }
  325. if ( info.type == DIALOG_QUICK_SAVE || info.type == DIALOG_CRAWL_SAVE || messageList[0].msg == GDM_CALCULATING_BENCHMARK ) {
  326. ShowNextDialog();
  327. }
  328. }
  329. /*
  330. ========================
  331. idCommonDialog::ActivateDialog
  332. ========================
  333. */
  334. void idCommonDialog::ActivateDialog( bool activate ) {
  335. dialogInUse = activate;
  336. if ( dialog != NULL ) {
  337. dialog->Activate( activate );
  338. }
  339. }
  340. /*
  341. ================================================
  342. idCommonDialog::ShowDialog
  343. ================================================
  344. */
  345. void idCommonDialog::ShowDialog( const idDialogInfo & info ) {
  346. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s] msg: %s, m.clear = %d, m.waitClear = %d, m.killTime = %d\n",
  347. __FUNCTION__, dialogStateToString[info.msg], info.clear, info.waitClear, info.killTime );
  348. // here instead of add dialog to make sure we meet the TCR, otherwise it has a chance to be visible for less than 1 second
  349. if ( DialogMsgShouldWait( info.msg ) && !dialogInUse ) {
  350. startSaveTime = Sys_Milliseconds();
  351. stopSaveTime = 0;
  352. }
  353. if ( IsDialogActive() ) {
  354. dialog->Activate( false );
  355. }
  356. idStr message, title;
  357. GetDialogMsg( info.msg, message, title );
  358. dialog->SetGlobal( "titleVal", title );
  359. if ( info.overrideMsg.IsEmpty() ) {
  360. dialog->SetGlobal( "messageInfo", message );
  361. } else {
  362. dialog->SetGlobal( "messageInfo", info.overrideMsg );
  363. }
  364. dialog->SetGlobal( "Infotype", info.type );
  365. if ( info.acceptCB == NULL && ( info.type != DIALOG_WAIT && info.type != DIALOG_WAIT_BLACKOUT ) ) {
  366. class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted {
  367. public:
  368. idSWFScriptFunction_Accept( gameDialogMessages_t _msg ) {
  369. msg = _msg;
  370. }
  371. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  372. common->Dialog().ClearDialog( msg );
  373. return idSWFScriptVar();
  374. }
  375. private:
  376. gameDialogMessages_t msg;
  377. };
  378. dialog->SetGlobal( "acceptCallBack", new (TAG_SWF) idSWFScriptFunction_Accept( info.msg ) );
  379. } else {
  380. dialog->SetGlobal( "acceptCallBack", info.acceptCB );
  381. }
  382. dialog->SetGlobal( "cancelCallBack", info.cancelCB );
  383. dialog->SetGlobal( "altCBOne", info.altCBOne );
  384. dialog->SetGlobal( "altCBTwo", info.altCBTwo );
  385. dialog->SetGlobal( "opt1Txt", info.txt1.GetLocalizedString() );
  386. dialog->SetGlobal( "opt2Txt", info.txt2.GetLocalizedString() );
  387. dialog->SetGlobal( "opt3Txt", info.txt3.GetLocalizedString() );
  388. dialog->SetGlobal( "opt4Txt", info.txt4.GetLocalizedString() );
  389. ActivateDialog( true );
  390. }
  391. /*
  392. ================================================
  393. idCommonDialog::ShowNextDialog
  394. ================================================
  395. */
  396. void idCommonDialog::ShowNextDialog() {
  397. for ( int index = 0; index < messageList.Num(); ++index ) {
  398. if ( !messageList[index].clear ) {
  399. idDialogInfo info = messageList[index];
  400. ShowDialog( info );
  401. break;
  402. }
  403. }
  404. }
  405. /*
  406. ================================================
  407. idCommonDialog::ShowSaveIndicator
  408. ================================================
  409. */
  410. void idCommonDialog::ShowSaveIndicator( bool show ) {
  411. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s]\n", __FUNCTION__ );
  412. if ( show ) {
  413. idStr msg = idStrId( "#str_dlg_pc_saving" ).GetLocalizedString();
  414. common->Dialog().AddDialog( GDM_SAVING, DIALOG_WAIT, NULL, NULL, true, "", 0, false, true, true );
  415. } else {
  416. common->Dialog().ClearDialog( GDM_SAVING );
  417. }
  418. }
  419. /*
  420. ========================
  421. idCommonDialog::RemoveSaveDialog
  422. From TCR# 047
  423. Games must display a message during storage writes for the following conditions and the respective amount of time:
  424. - Writes longer than one second require the standard message be displayed for three seconds.
  425. - Writes longer than three seconds require the standard message be displayed for the length of the write.
  426. - Writes that last one second or less require the shorter message be displayed for one second or the standard message for three seconds.
  427. ========================
  428. */
  429. void idCommonDialog::RemoveWaitDialogs() {
  430. bool topMessageCleared = false;
  431. for ( int index = 0; index < messageList.Num(); ++index ) {
  432. if ( DialogMsgShouldWait( messageList[index].msg ) ) {
  433. if ( Sys_Milliseconds() >= messageList[index].killTime && messageList[index].waitClear ) {
  434. messageList[index].clear = true;
  435. messageList[index].waitClear = false;
  436. if ( index == 0 ) {
  437. topMessageCleared = true;
  438. }
  439. }
  440. }
  441. }
  442. if ( topMessageCleared && messageList.Num() > 0 ) {
  443. ActivateDialog( false );
  444. }
  445. }
  446. /*
  447. ================================================
  448. idCommonDialog::ClearAllDialogHack
  449. ================================================
  450. */
  451. void idCommonDialog::ClearAllDialogHack() {
  452. for ( int index = 0; index < messageList.Num(); ++index ) {
  453. messageList[index].clear = true;
  454. messageList[index].waitClear = false;
  455. }
  456. }
  457. /*
  458. ================================================
  459. idCommonDialog::HasDialogMsg
  460. ================================================
  461. */
  462. bool idCommonDialog::HasDialogMsg( gameDialogMessages_t msg, bool * isNowActive ) {
  463. for ( int index = 0; index < messageList.Num(); ++index ) {
  464. idDialogInfo & info = messageList[index];
  465. if ( info.msg == msg && !info.clear ) {
  466. if ( isNowActive != NULL ) {
  467. *isNowActive = ( index == 0 );
  468. }
  469. return true;
  470. }
  471. }
  472. if ( isNowActive != NULL ) {
  473. *isNowActive = false;
  474. }
  475. return false;
  476. }
  477. /*
  478. ================================================
  479. idCommonDialog::ClearDialog
  480. ================================================
  481. */
  482. void idCommonDialog::ClearDialog( gameDialogMessages_t msg, const char * location, int lineNumber ) {
  483. bool topMessageCleared = false;
  484. for ( int index = 0; index < messageList.Num(); ++index ) {
  485. idDialogInfo & info = messageList[index];
  486. if ( info.msg == msg && !info.clear ) {
  487. if ( DialogMsgShouldWait( info.msg ) ) {
  488. // you can have 2 saving dialogs simultaneously, if you clear back-to-back, we need to let the 2nd dialog
  489. // get the clear message
  490. if ( messageList[index].waitClear ) {
  491. continue;
  492. }
  493. int timeShown = Sys_Milliseconds() - messageList[index].startTime;
  494. // for the time being always use the long saves
  495. if ( timeShown < dialog_saveClearLevel.GetInteger() ) {
  496. messageList[index].killTime = Sys_Milliseconds() + ( dialog_saveClearLevel.GetInteger() - timeShown );
  497. messageList[index].waitClear = true;
  498. } else {
  499. messageList[index].clear = true;
  500. if ( index == 0 ) {
  501. topMessageCleared = true;
  502. }
  503. }
  504. } else {
  505. messageList[index].clear = true;
  506. if ( index == 0 ) {
  507. topMessageCleared = true;
  508. }
  509. }
  510. assert( info.msg >= GDM_INVALID && info.msg < GDM_MAX ); // not sure why /analyze complains about this
  511. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s] msg: %s, from: %s:%d, topMessageCleared = %d, m.clear = %d, m.waitClear = %d, m.killTime = %d\n",
  512. __FUNCTION__, dialogStateToString[info.msg], location == NULL ? "NULL" : location, lineNumber,
  513. topMessageCleared, messageList[index].clear,
  514. messageList[index].waitClear, messageList[index].killTime );
  515. break;
  516. }
  517. }
  518. if ( topMessageCleared && messageList.Num() > 0 ) {
  519. ActivateDialog( false );
  520. }
  521. }
  522. /*
  523. ================================================
  524. idCommonDialog::ReleaseCallBacks
  525. ================================================
  526. */
  527. void idCommonDialog::ReleaseCallBacks( int index ) {
  528. if ( index < messageList.Num() ) {
  529. if ( messageList[index].acceptCB != NULL ) {
  530. messageList[index].acceptCB->Release();
  531. messageList[index].acceptCB = NULL;
  532. }
  533. if ( messageList[index].cancelCB != NULL ) {
  534. messageList[index].cancelCB->Release();
  535. messageList[index].cancelCB = NULL;
  536. }
  537. if ( messageList[index].altCBOne != NULL ) {
  538. messageList[index].altCBOne->Release();
  539. messageList[index].altCBOne = NULL;
  540. }
  541. if ( messageList[index].altCBTwo != NULL ) {
  542. messageList[index].altCBTwo->Release();
  543. messageList[index].altCBTwo = NULL;
  544. }
  545. }
  546. }
  547. /*
  548. ================================================
  549. idCommonDialog::Render
  550. ================================================
  551. */
  552. void idCommonDialog::Render( bool loading ) {
  553. dialogPause = false;
  554. if ( dialog == NULL ) {
  555. return;
  556. }
  557. RemoveWaitDialogs();
  558. bool pauseCheck = false;
  559. for ( int index = 0; index < messageList.Num(); ++index ) {
  560. if ( messageList[index].clear ) {
  561. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s] removing %s\n", __FUNCTION__, dialogStateToString[messageList[index].msg] );
  562. ReleaseCallBacks( index );
  563. messageList.RemoveIndex( index );
  564. index--;
  565. } else {
  566. if ( messageList[index].pause && !pauseCheck ) {
  567. pauseCheck = true;
  568. }
  569. }
  570. }
  571. dialogPause = pauseCheck;
  572. if ( messageList.Num() > 0 && !dialog->IsActive() ) {
  573. ShowNextDialog();
  574. }
  575. if ( messageList.Num() == 0 && dialog->IsActive() ) {
  576. dialog->Activate( false );
  577. }
  578. // Decrement the time remaining on the save indicator or turn it off
  579. if ( !dialogShowingSaveIndicatorRequested && saveIndicator->IsActive() ) {
  580. ShowSaveIndicator( false );
  581. }
  582. if ( messageList.Num() > 0 && messageList[0].type == DIALOG_TIMER_ACCEPT_REVERT ) {
  583. int startTime = messageList[0].startTime;
  584. int endTime = startTime + PC_KEYBOARD_WAIT;
  585. int timeRemaining = ( endTime - Sys_Milliseconds() ) / 1000;
  586. if ( timeRemaining <= 0 ) {
  587. if ( messageList[0].cancelCB != NULL ) {
  588. idSWFParmList parms;
  589. messageList[0].cancelCB->Call( NULL, parms );
  590. }
  591. messageList[0].clear = true;
  592. } else {
  593. idStrId txtTime = idStrId( "#str_time_remaining" );
  594. dialog->SetGlobal( "countdownInfo", va( txtTime.GetLocalizedString(), timeRemaining ) );
  595. }
  596. }
  597. if ( messageList.Num() > 0 && loading && ( messageList[0].renderDuringLoad == false ) ) {
  598. return;
  599. }
  600. if ( dialog->IsActive() ) {
  601. dialog->Render( renderSystem, Sys_Microseconds() );
  602. }
  603. if ( saveIndicator != NULL && saveIndicator->IsActive() ) {
  604. saveIndicator->Render( renderSystem, Sys_Microseconds() );
  605. }
  606. }
  607. /*
  608. ================================================
  609. idCommonDialog::Init
  610. ================================================
  611. */
  612. void idCommonDialog::Init() {
  613. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s]\n", __FUNCTION__ );
  614. Shutdown();
  615. dialog = new (TAG_SWF) idSWF( "dialog" );
  616. saveIndicator = new (TAG_SWF) idSWF( "save_indicator" );
  617. #define BIND_DIALOG_CONSTANT( x ) dialog->SetGlobal( #x, x )
  618. if ( dialog != NULL ) {
  619. BIND_DIALOG_CONSTANT( DIALOG_ACCEPT );
  620. BIND_DIALOG_CONSTANT( DIALOG_CONTINUE );
  621. BIND_DIALOG_CONSTANT( DIALOG_ACCEPT_CANCEL );
  622. BIND_DIALOG_CONSTANT( DIALOG_YES_NO );
  623. BIND_DIALOG_CONSTANT( DIALOG_CANCEL );
  624. BIND_DIALOG_CONSTANT( DIALOG_WAIT );
  625. BIND_DIALOG_CONSTANT( DIALOG_WAIT_BLACKOUT );
  626. BIND_DIALOG_CONSTANT( DIALOG_WAIT_CANCEL );
  627. BIND_DIALOG_CONSTANT( DIALOG_DYNAMIC );
  628. BIND_DIALOG_CONSTANT( DIALOG_QUICK_SAVE );
  629. BIND_DIALOG_CONSTANT( DIALOG_TIMER_ACCEPT_REVERT );
  630. BIND_DIALOG_CONSTANT( DIALOG_CRAWL_SAVE );
  631. BIND_DIALOG_CONSTANT( DIALOG_CONTINUE_LARGE );
  632. BIND_DIALOG_CONSTANT( DIALOG_BENCHMARK );
  633. }
  634. }
  635. /*
  636. ================================================
  637. idCommonDialog::Shutdown
  638. ================================================
  639. */
  640. void idCommonDialog::Shutdown() {
  641. idLib::PrintfIf( popupDialog_debug.GetBool(), "[%s]\n", __FUNCTION__ );
  642. ClearDialogs();
  643. delete dialog;
  644. dialog = NULL;
  645. delete saveIndicator;
  646. saveIndicator = NULL;
  647. }
  648. /*
  649. ========================
  650. idCommonDialog::Restart
  651. ========================
  652. */
  653. void idCommonDialog::Restart() {
  654. Shutdown();
  655. Init();
  656. }
  657. /*
  658. ================================================
  659. idCommonDialog::GetDialogMsg
  660. ================================================
  661. */
  662. idStr idCommonDialog::GetDialogMsg( gameDialogMessages_t msg, idStr & message, idStr & title ) {
  663. message = "#str_dlg_pc_";
  664. switch ( msg ) {
  665. case GDM_SWAP_DISKS_TO1: {
  666. message.Append( "switch_disc_to_1" );
  667. break;
  668. }
  669. case GDM_SWAP_DISKS_TO2: {
  670. message.Append( "switch_disc_to_2" );
  671. break;
  672. }
  673. case GDM_SWAP_DISKS_TO3: {
  674. message.Append( "switch_disc_to_3" );
  675. break;
  676. }
  677. case GDM_NO_GAMER_PROFILE: {
  678. message.Append( "signin_request" );
  679. break;
  680. }
  681. case GDM_PLAY_ONLINE_NO_PROFILE: {
  682. message.Append( "online_signin_request" );
  683. break;
  684. }
  685. case GDM_LEADERBOARD_ONLINE_NO_PROFILE: {
  686. message.Append( "online_signing_request_leaderboards" );
  687. break;
  688. }
  689. case GDM_NO_STORAGE_SELECTED: {
  690. message.Append( "storage_device_selection_request" );
  691. break;
  692. }
  693. case GDM_ONLINE_INCORRECT_PERMISSIONS: {
  694. message.Append( "incorrect_online_permissions" );
  695. break;
  696. }
  697. case GDM_SP_QUIT_SAVE: {
  698. title = idLocalization::GetString( "#str_04215" );
  699. title.ToUpper();
  700. if ( g_demoMode.GetBool() ) {
  701. message = "#str_04145";
  702. } else {
  703. message = "#str_dlg_quit_progress_lost";
  704. }
  705. break;
  706. }
  707. case GDM_SP_LOAD_SAVE: {
  708. title = idLocalization::GetString( "#str_02187" );
  709. title.ToUpper();
  710. message = "#str_dlg_360_load_request";
  711. break;
  712. }
  713. case GDM_SP_RESTART_SAVE: {
  714. title = idLocalization::GetString( "#str_04271" );
  715. title.ToUpper();
  716. message = "#str_dlg_restart_progress_lost";
  717. break;
  718. }
  719. case GDM_SP_SIGNIN_CHANGE: {
  720. message = "#str_dlg_signin_changed";
  721. break;
  722. }
  723. case GDM_SERVER_NOT_AVAILABLE: {
  724. message.Append( "game_server_unavailable" );
  725. break;
  726. }
  727. case GDM_CONNECTION_LOST_HOST: {
  728. message = "#str_dlg_opponent_connection_lost_ranking_not_counted";
  729. break;
  730. }
  731. case GDM_CONNECTION_LOST: {
  732. message.Append( "online_connection_lost_main_menu_return" );
  733. break;
  734. }
  735. case GDM_OPPONENT_CONNECTION_LOST: {
  736. message = "#str_dlg_opponent_connection_lost";
  737. break;
  738. }
  739. case GDM_HOST_CONNECTION_LOST: {
  740. message = "#str_dlg_host_connection_lost";
  741. break;
  742. }
  743. case GDM_HOST_CONNECTION_LOST_STATS: {
  744. message = "#str_dlg_host_connection_lost_ranking_not_counted";
  745. break;
  746. }
  747. case GDM_FAILED_TO_LOAD_RANKINGS: {
  748. message = "#str_dlg_ranking_load_failed";
  749. break;
  750. }
  751. case GDM_HOST_QUIT: {
  752. message = "#str_dlg_host_quit";
  753. break;
  754. }
  755. case GDM_OPPONENT_LEFT: {
  756. message = "#str_dlg_opponent_left";
  757. break;
  758. }
  759. case GDM_PARTNER_LEFT: {
  760. message = "#str_dlg_partner_left";
  761. break;
  762. }
  763. case GDM_NO_MATCHES_FOUND: {
  764. message = "#str_dlg_matches_not_found";
  765. break;
  766. }
  767. case GDM_INVALID_INVITE: {
  768. message = "#str_dlg_invalid_game";
  769. break;
  770. }
  771. case GDM_KICKED: {
  772. message = "#str_dlg_kicked";
  773. break;
  774. }
  775. case GDM_BANNED: {
  776. message = "#str_dlg_banned";
  777. break;
  778. }
  779. case GDM_SAVING: {
  780. title = "#str_save_dialog_heading";
  781. message.Append( "saving" );
  782. break;
  783. }
  784. case GDM_QUICK_SAVE: {
  785. title = "#str_save_dialog_heading";
  786. message.Append( "saving" );
  787. //message = "#STR_SWF_SAVING";
  788. break;
  789. }
  790. case GDM_OVERWRITE_SAVE: {
  791. title = "#str_02306";
  792. message = "#str_dlg_overwrite_save";
  793. break;
  794. }
  795. case GDM_LOAD_REQUEST: {
  796. message.Append( "load_request" );
  797. break;
  798. }
  799. case GDM_AUTOSAVE_DISABLED_STORAGE_REMOVED: {
  800. message.Append( "storage_removed_autosave_disabled" );
  801. break;
  802. }
  803. case GDM_STORAGE_INVALID: {
  804. message.Append( "storage_not_available" );
  805. break;
  806. }
  807. case GDM_CONNECTING: {
  808. message = "#str_dlg_connecting";
  809. break;
  810. }
  811. case GDM_REFRESHING: {
  812. title = "#str_01694";
  813. message = "#str_dlg_refreshing";
  814. break;
  815. }
  816. case GDM_DELETE_SAVE: {
  817. title = "#str_02313";
  818. message.Append( "delete_save" );
  819. break;
  820. }
  821. case GDM_DELETING: {
  822. message.Append( "deleting" );
  823. break;
  824. }
  825. case GDM_BINDING_ALREDY_SET: {
  826. message.Append( "bind_exists" );
  827. break;
  828. }
  829. case GDM_CANNOT_BIND: {
  830. message.Append( "cannont_bind" );
  831. break;
  832. }
  833. case GDM_OVERLAY_DISABLED: {
  834. message.Append( "overlay_disabled" );
  835. break;
  836. }
  837. case GDM_BECAME_HOST_PARTY: {
  838. message = "#str_dlg_became_host_party";
  839. break;
  840. }
  841. case GDM_NEW_HOST_PARTY: {
  842. message = "#str_dlg_new_host_party";
  843. break;
  844. }
  845. case GDM_LOBBY_BECAME_HOST_GAME: {
  846. message = "#str_dlg_lobby_became_host_game";
  847. break;
  848. }
  849. case GDM_LOBBY_NEW_HOST_GAME: {
  850. message.Append( "lobby_new_host_game" );
  851. break;
  852. }
  853. case GDM_NEW_HOST_GAME: {
  854. message = "#str_dlg_new_host_game";
  855. break;
  856. }
  857. case GDM_NEW_HOST_GAME_STATS_DROPPED: {
  858. message = "#str_dlg_new_host_game_stats_dropped";
  859. break;
  860. }
  861. case GDM_BECAME_HOST_GAME: {
  862. message.Append( "became_host_game" );
  863. break;
  864. }
  865. case GDM_BECAME_HOST_GAME_STATS_DROPPED: {
  866. message = "#str_dlg_became_host_game_stats_dropped";
  867. break;
  868. }
  869. case GDM_LOBBY_DISBANDED: {
  870. message.Append( "lobby_disbanded" );
  871. break;
  872. }
  873. case GDM_LEAVE_WITH_PARTY: {
  874. message = "#str_dlg_leave_with_party";
  875. break;
  876. }
  877. case GDM_LEAVE_LOBBY_RET_MAIN: {
  878. message.Append( "leave_lobby_ret_main" );
  879. break;
  880. }
  881. case GDM_LEAVE_LOBBY_RET_NEW_PARTY: {
  882. message.Append( "leave_lobby_ret_new_party" );
  883. break;
  884. }
  885. case GDM_MIGRATING: {
  886. message = "#str_online_host_migration";
  887. break;
  888. }
  889. case GDM_MIGRATING_WAITING: {
  890. message = "#str_online_host_migration_waiting";
  891. break;
  892. }
  893. case GDM_MIGRATING_RELAUNCHING: {
  894. message = "#str_online_host_migration_relaunching";
  895. break;
  896. }
  897. case GDM_DIRECT_MAP_CHANGE: {
  898. message = "#str_dlg_direct_map_change";
  899. break;
  900. }
  901. case GDM_DELETE_AUTOSAVE: {
  902. message.Append( "delete_autosave" );
  903. break;
  904. }
  905. case GDM_MULTI_RETRY: {
  906. message = "#str_online_confirm_retry";
  907. break;
  908. }
  909. case GDM_MULTI_SELF_DESTRUCT: {
  910. message = "#str_online_confirm_suicide";
  911. break;
  912. }
  913. case GDM_MULTI_VDM_QUIT: {
  914. message = "#str_online_confirm_quit_generic";
  915. break;
  916. }
  917. case GDM_MULTI_COOP_QUIT: {
  918. message = "#str_online_confirm_coop_quit_game_generic";
  919. break;
  920. }
  921. case GDM_LOADING_PROFILE: {
  922. message = "#str_dlg_loading_profile";
  923. title = "#str_dlg_updating_profile";
  924. break;
  925. }
  926. case GDM_STORAGE_REQUIRED: {
  927. message.Append( "storage_required" );
  928. break;
  929. }
  930. case GDM_INSUFFICENT_STORAGE_SPACE: {
  931. message = "#str_dlg_insufficient_space";
  932. break;
  933. }
  934. case GDM_RESTORE_CORRUPT_SAVEGAME: {
  935. message = "#str_dlg_restore_corrupt_savegame";
  936. break;
  937. }
  938. case GDM_UNRECOVERABLE_SAVEGAME: {
  939. message = "#str_dlg_unrecoverable_savegame";
  940. break;
  941. }
  942. case GDM_PROFILE_SAVE_ERROR: {
  943. message.Append( "profile_save_error" );
  944. break;
  945. }
  946. case GDM_LOBBY_FULL: {
  947. message.Append( "lobby_full" );
  948. break;
  949. }
  950. case GDM_QUIT_GAME: {
  951. title = "#str_01975"; // EXIT GAME
  952. message = "#str_dlg_confirm_quit";
  953. break;
  954. }
  955. case GDM_CONNECTION_PROBLEMS: {
  956. message = "#str_online_connection_problems";
  957. break;
  958. }
  959. case GDM_VOICE_RESTRICTED: {
  960. message.Append( "voice_restricted" );
  961. break;
  962. }
  963. case GDM_MUST_SIGNIN: {
  964. message.Append( "must_signin" );
  965. break;
  966. }
  967. case GDM_LOAD_DAMAGED_FILE: {
  968. message = "#str_dlg_corrupt_save_file";
  969. break;
  970. }
  971. case GDM_DLC_ERROR_REMOVED: {
  972. message.Append( "dlc_error_content_removed" );
  973. break;
  974. }
  975. case GDM_DLC_ERROR_CORRUPT: {
  976. message.Append( "dlc_error_content_corrupt" );
  977. break;
  978. }
  979. case GDM_DLC_ERROR_MISSING: {
  980. message.Append( "dlc_error_content_missing" );
  981. break;
  982. }
  983. case GDM_DLC_ERROR_MISSING_GENERIC: {
  984. message.Append( "dlc_error_content_missing_generic" );
  985. break;
  986. }
  987. case GDM_CONNECTION_LOST_NO_LEADERBOARD: {
  988. message.Append( "online_connection_lost_no_leaderboard" );
  989. break;
  990. }
  991. case GDM_SP_SIGNIN_CHANGE_POST: {
  992. message.Append( "signin_changed_post" );
  993. break;
  994. }
  995. case GDM_MIGRATING_FAILED_CONNECTION: {
  996. message = "#str_online_host_migration_failed";
  997. break;
  998. }
  999. case GDM_MIGRATING_FAILED_CONNECTION_STATS: {
  1000. message = "#str_online_host_migration_failed_stats";
  1001. break;
  1002. }
  1003. case GDM_MIGRATING_FAILED_DISBANDED: {
  1004. message = "#str_online_host_migration_failed_disbanded";
  1005. break;
  1006. }
  1007. case GDM_MIGRATING_FAILED_DISBANDED_STATS: {
  1008. message = "#str_online_host_migration_failed_disbanded_stats";
  1009. break;
  1010. }
  1011. case GDM_MIGRATING_FAILED_PARTNER_LEFT: {
  1012. message = "#str_online_host_migration_failed_partner_left";
  1013. break;
  1014. }
  1015. case GDM_FAILED_JOIN_LOCAL_SESSION: {
  1016. message = "#str_dlg_failed_join_local_session";
  1017. break;
  1018. }
  1019. case GDM_DELETE_CORRUPT_SAVEGAME:
  1020. message = "#str_dlg_delete_corrupt_savegame";
  1021. break;
  1022. case GDM_LEAVE_INCOMPLETE_INSTANCE:
  1023. message = "#str_dlg_leave_incomplete_instance";
  1024. break;
  1025. case GDM_UNBIND_CONFIRM:
  1026. message = "#str_dlg_bind_unbind";
  1027. break;
  1028. case GDM_BINDINGS_RESTORE:
  1029. message = "#str_dlg_bind_restore";
  1030. break;
  1031. case GDM_HOST_RETURNED_TO_LOBBY: {
  1032. message.Append( "host_quit_to_lobby" );
  1033. break;
  1034. }
  1035. case GDM_HOST_RETURNED_TO_LOBBY_STATS_DROPPED: {
  1036. message.Append( "host_quit_to_lobby_stats_dropped" );
  1037. break;
  1038. }
  1039. case GDM_NEW_HOST: {
  1040. message.Append( "new_host" );
  1041. break;
  1042. }
  1043. case GDM_DISC_SWAP: {
  1044. message = "#str_dlg_disc_swap";
  1045. break;
  1046. }
  1047. case GDM_NO_SAVEGAMES_AVAILABLE: {
  1048. message = "#str_dlg_no_savegames_available";
  1049. break;
  1050. }
  1051. case GDM_CONFIRM_VIDEO_CHANGES: {
  1052. message = "#str_dlg_confirm_display_changes";
  1053. break;
  1054. }
  1055. case GDM_UNABLE_TO_USE_SELECTED_STORAGE_DEVICE: {
  1056. message.Append( "unable_to_use_selected_storage_device" );
  1057. break;
  1058. }
  1059. case GDM_ERROR_LOADING_SAVEGAME: {
  1060. message = "#str_dlg_error_loading_savegame";
  1061. break;
  1062. }
  1063. case GDM_ERROR_SAVING_SAVEGAME: {
  1064. message = "#str_dlg_error_saving_savegame";
  1065. break;
  1066. }
  1067. case GDM_DISCARD_CHANGES: {
  1068. message = "#str_dlg_confirm_discard";
  1069. break;
  1070. }
  1071. case GDM_LEAVE_LOBBY: {
  1072. message = "#str_online_leave_game_lobby_alt_02";
  1073. break;
  1074. }
  1075. case GDM_LEAVE_LOBBY_AND_TEAM: {
  1076. message = "#str_online_party_leave_game";
  1077. break;
  1078. }
  1079. case GDM_CONTROLLER_DISCONNECTED_0:
  1080. case GDM_CONTROLLER_DISCONNECTED_1:
  1081. case GDM_CONTROLLER_DISCONNECTED_2:
  1082. case GDM_CONTROLLER_DISCONNECTED_3:
  1083. case GDM_CONTROLLER_DISCONNECTED_4:
  1084. case GDM_CONTROLLER_DISCONNECTED_5:
  1085. case GDM_CONTROLLER_DISCONNECTED_6:{
  1086. message = "#str_dlg_reconnect_controller";
  1087. break;
  1088. }
  1089. case GDM_NEEDS_INSTALL: {
  1090. message = "#str_dlg_game_install_message";
  1091. break;
  1092. }
  1093. case GDM_ERROR_JOIN_TWO_PROFILES_ONE_BOX: {
  1094. message.Append( "online_join_error_two_profiles_one_box" );
  1095. break;
  1096. }
  1097. case GDM_WARNING_PLAYING_COOP_SOLO: {
  1098. message = "#str_online_lotw_solo_warning_alt_05";
  1099. break;
  1100. }
  1101. case GDM_MULTI_COOP_QUIT_LOSE_LEADERBOARDS: {
  1102. message = "#str_online_confirm_coop_quit_game";
  1103. break;
  1104. }
  1105. case GDM_CORRUPT_CONTINUE: {
  1106. message = "#str_corrupt_save_load";
  1107. break;
  1108. }
  1109. case GDM_MULTI_VDM_QUIT_LOSE_LEADERBOARDS: {
  1110. message = "#str_online_confirm_quit_game";
  1111. break;
  1112. }
  1113. case GDM_WARNING_PLAYING_VDM_SOLO: {
  1114. message = "#str_online_cr_custom_game_no_stats";
  1115. break;
  1116. }
  1117. case GDM_NO_GUEST_SUPPORT: {
  1118. message = "#str_dlg_ps3_incorrect_online_permissions";
  1119. break;
  1120. }
  1121. case GDM_DISC_SWAP_CONFIRMATION: {
  1122. message = "#str_dlg_disc_swap_confirmation";
  1123. break;
  1124. }
  1125. case GDM_ERROR_LOADING_PROFILE: {
  1126. message.Append( "error_loading_profile" );
  1127. break;
  1128. }
  1129. case GDM_CANNOT_INVITE_LOBBY_FULL: {
  1130. message = "#str_online_join_error_full";
  1131. break;
  1132. }
  1133. case GDM_WARNING_FOR_NEW_DEVICE_ABOUT_TO_LOSE_PROGRESS: {
  1134. message = "#str_dlg_360_new_device_selected";
  1135. break;
  1136. }
  1137. case GDM_DISCONNECTED: {
  1138. message = "#str_online_connection_error_03";
  1139. break;
  1140. }
  1141. case GDM_INCOMPATIBLE_NEWER_SAVE: {
  1142. message = "#str_dlg_newer_incompatible_savegame";
  1143. break;
  1144. }
  1145. case GDM_ACHIEVEMENTS_DISABLED_DUE_TO_CHEATING: {
  1146. message = "#str_dlg_achievements_disabled_due_to_cheating";
  1147. break;
  1148. }
  1149. case GDM_INCOMPATIBLE_POINTER_SIZE: {
  1150. message = "#str_dlg_pointer_size_mismatch";
  1151. break;
  1152. }
  1153. case GDM_TEXTUREDETAIL_RESTARTREQUIRED: {
  1154. message = "#str_swf_texture_restart";
  1155. break;
  1156. }
  1157. case GDM_TEXTUREDETAIL_INSUFFICIENT_CPU: {
  1158. message = "#str_swf_insufficient_cores";
  1159. break;
  1160. }
  1161. case GDM_CALCULATING_BENCHMARK: {
  1162. message = "#str_swf_calc_benchmark";
  1163. break;
  1164. }
  1165. case GDM_DISPLAY_BENCHMARK: {
  1166. message = "BENCHMARK SCORE = ";
  1167. break;
  1168. }
  1169. case GDM_DISPLAY_CHANGE_FAILED: {
  1170. message = "#str_swf_display_changes_failed";
  1171. break;
  1172. }
  1173. case GDM_GPU_TRANSCODE_FAILED: {
  1174. message = "#str_swf_gpu_transcode_failed";
  1175. break;
  1176. }
  1177. case GDM_OUT_OF_MEMORY: {
  1178. message = "#str_swf_failed_level_load";
  1179. break;
  1180. }
  1181. case GDM_CORRUPT_PROFILE: {
  1182. message = "#str_dlg_corrupt_profile";
  1183. break;
  1184. }
  1185. case GDM_PROFILE_TOO_OUT_OF_DATE_DEVELOPMENT_ONLY: {
  1186. message = "#str_dlg_profile_too_out_of_date_development_only";
  1187. break;
  1188. }
  1189. case GDM_INSTALLING_TROPHIES: {
  1190. title = "#str_dlg_ps3_trophy_install_heading";
  1191. message = "#str_dlg_ps3_trophy_installing";
  1192. break;
  1193. }
  1194. case GDM_XBOX_DEPLOYMENT_TYPE_FAIL: {
  1195. message = "#str_dlg_360_installed_continue";
  1196. break;
  1197. }
  1198. case GDM_GAME_RESTART_REQUIRED: {
  1199. message = "#str_dlg_game_restart_required";
  1200. break;
  1201. }
  1202. default: {
  1203. message = "MESSAGE TYPE NOT DEFINED";
  1204. break;
  1205. }
  1206. }
  1207. return message;
  1208. }
  1209. /*
  1210. ================================================
  1211. idCommonDialog::HandleDialogEvent
  1212. ================================================
  1213. */
  1214. bool idCommonDialog::HandleDialogEvent( const sysEvent_t * sev ) {
  1215. if ( dialog != NULL && dialog->IsLoaded() && dialog->IsActive() ) {
  1216. if ( saveIndicator->IsActive() ) {
  1217. return false;
  1218. } else {
  1219. if ( dialog->HandleEvent( sev ) ) {
  1220. idKeyInput::ClearStates();
  1221. // TODO_D3_PORT
  1222. //sys->ClearEvents();
  1223. }
  1224. }
  1225. return true;
  1226. }
  1227. return false;
  1228. }
  1229. /*
  1230. ================================================
  1231. idCommonDialog::IsDialogActive
  1232. ================================================
  1233. */
  1234. bool idCommonDialog::IsDialogActive() {
  1235. if ( dialog != NULL ) {
  1236. return dialog->IsActive();
  1237. }
  1238. return false;
  1239. }
  1240. CONSOLE_COMMAND( commonDialogClear, "clears all dialogs that may be hung", 0 ) {
  1241. common->Dialog().ClearAllDialogHack();
  1242. }
  1243. CONSOLE_COMMAND( testShowDialog, "show a dialog", 0 ) {
  1244. int dialogId = atoi( args.Argv( 1 ) );
  1245. common->Dialog().AddDialog( (gameDialogMessages_t)dialogId, DIALOG_ACCEPT, NULL, NULL, false );
  1246. }
  1247. CONSOLE_COMMAND( testShowDynamicDialog, "show a dynamic dialog", 0 ) {
  1248. class idSWFScriptFunction_Continue : public idSWFScriptFunction_RefCounted {
  1249. public:
  1250. idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
  1251. common->Dialog().ClearDialog( GDM_INSUFFICENT_STORAGE_SPACE );
  1252. return idSWFScriptVar();
  1253. }
  1254. };
  1255. idStaticList< idSWFScriptFunction *, 4 > callbacks;
  1256. idStaticList< idStrId, 4 > optionText;
  1257. callbacks.Append( new (TAG_SWF) idSWFScriptFunction_Continue() );
  1258. optionText.Append( idStrId( "#str_swf_continue" ) );
  1259. // build custom space required string
  1260. // #str_dlg_space_required ~= "There is insufficient storage available. Please free %s and try again."
  1261. idStr format = idStrId( "#str_dlg_space_required" ).GetLocalizedString();
  1262. idStr size;
  1263. int requiredSpaceInBytes = 150000;
  1264. if ( requiredSpaceInBytes > ( 1024 * 1024 ) ) {
  1265. size = va( "%.1f MB", (float) requiredSpaceInBytes / ( 1024.0f * 1024.0f ) );
  1266. } else {
  1267. size = va( "%.0f KB", (float) requiredSpaceInBytes / 1024.0f );
  1268. }
  1269. idStr msg = va( format.c_str(), size.c_str() );
  1270. common->Dialog().AddDynamicDialog( GDM_INSUFFICENT_STORAGE_SPACE, callbacks, optionText, true, msg );
  1271. }
  1272. CONSOLE_COMMAND( testShowDialogBug, "show a dynamic dialog", 0 ) {
  1273. common->Dialog().ShowSaveIndicator( true );
  1274. common->Dialog().ShowSaveIndicator( false );
  1275. // This locks the game because it thinks it's paused because we're passing in pause = true but the
  1276. // dialog isn't ever added because of the abuse of dialog->isActive when the save indicator is shown.
  1277. int dialogId = atoi( args.Argv( 1 ) );
  1278. common->Dialog().AddDialog( (gameDialogMessages_t)dialogId, DIALOG_ACCEPT, NULL, NULL, true );
  1279. }