DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

Common_dialog.cpp (42092B)


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