/*
========================
idMenuScreen_Shell_Root::HandleExitGameBtn
========================
*/
void idMenuScreen_Shell_Root::HandleExitGameBtn() {
	class idSWFScriptFunction_QuitDialog : public idSWFScriptFunction_RefCounted {
	public:
		idSWFScriptFunction_QuitDialog( gameDialogMessages_t _msg, int _accept ) {
			msg = _msg;
			accept = _accept;
		}
		idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
			common->Dialog().ClearDialog( msg );
			if ( accept == 1 ) {
				common->Quit();
			} else if ( accept == -1 ) {
				session->MoveToPressStart();
			}
			return idSWFScriptVar();
		}
	private:
		gameDialogMessages_t msg;
		int accept;
	};

	idStaticList< idSWFScriptFunction *, 4 > callbacks;
	idStaticList< idStrId, 4 > optionText;
	callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 1 ) );
	callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 0 ) );
	callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, -1 ) );
	optionText.Append( idStrId( "#STR_SWF_ACCEPT" ) );
	optionText.Append( idStrId( "#STR_SWF_CANCEL" ) );
	optionText.Append( idStrId( "#str_swf_change_game" ) );

	common->Dialog().AddDynamicDialog( GDM_QUIT_GAME, callbacks, optionText, true, "" );
}
/*
========================
idMenuScreen_Shell_Singleplayer::ContinueGame
========================
*/
void idMenuScreen_Shell_Singleplayer::ContinueGame() {
	const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
	saveGameDetailsList_t sortedSaves = saveGameInfo;
	sortedSaves.Sort( idSort_SavesByDate() );	
	if ( sortedSaves.Num() > 0 ) {
		if ( sortedSaves[0].damaged ) {
			class idSWFScriptFunction_ContinueDamaged : public idSWFScriptFunction_RefCounted {
			public:
				idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
					common->Dialog().ClearDialog( GDM_CORRUPT_CONTINUE );
					return idSWFScriptVar();
				}
			};

			idStaticList< idSWFScriptFunction *, 4 > callbacks;
			callbacks.Append( new (TAG_SWF) idSWFScriptFunction_ContinueDamaged() );
			idStaticList< idStrId, 4 > optionText;
			optionText.Append( idStrId( "#str_04339" ) );	// OK
			common->Dialog().AddDynamicDialog( GDM_CORRUPT_CONTINUE, callbacks, optionText, false, "" );
		} else {
			const idStr & name = sortedSaves[ 0 ].slotName;
			cmdSystem->AppendCommandText( va( "loadgame %s\n", name.c_str() ) );
		}
	}
}
/*
========================
idMenuScreen_Shell_SystemOptions::HideScreen
========================
*/
void idMenuScreen_Shell_SystemOptions::HideScreen( const mainMenuTransition_t transitionType )
{

	if( systemData.IsRestartRequired() )
	{
		class idSWFScriptFunction_Restart : public idSWFScriptFunction_RefCounted
		{
		public:
			idSWFScriptFunction_Restart( gameDialogMessages_t _msg, bool _restart )
			{
				msg = _msg;
				restart = _restart;
			}
			idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
			{
				common->Dialog().ClearDialog( msg );
				if( restart )
				{
					// DG: Sys_ReLaunch() doesn't need any options anymore
					//     (the old way would have been unnecessarily painful on POSIX systems)
					Sys_ReLaunch();
					// DG end
				}
				return idSWFScriptVar();
			}
		private:
			gameDialogMessages_t msg;
			bool restart;
		};
		idStaticList<idSWFScriptFunction*, 4> callbacks;
		idStaticList<idStrId, 4> optionText;
		callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, false ) );
		callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, true ) );
		optionText.Append( idStrId( "#str_00100113" ) ); // Continue
		optionText.Append( idStrId( "#str_02487" ) ); // Restart Now
		common->Dialog().AddDynamicDialog( GDM_GAME_RESTART_REQUIRED, callbacks, optionText, true, idStr() );
	}
	
	if( systemData.IsDataChanged() )
	{
		systemData.CommitData();
	}
	
	idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Load::LoadDamagedGame
========================
*/
void idMenuScreen_Shell_Load::LoadDamagedGame( int index )
{

	if( index >= sortedSaves.Num() )
	{
		return;
	}
	
	class idSWFScriptFunction_LoadDamaged : public idSWFScriptFunction_RefCounted
	{
	public:
		idSWFScriptFunction_LoadDamaged( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Load* _screen )
		{
			msg = _msg;
			accept = _accept;
			index = _index;
			screen = _screen;
		}
		idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
		{
			common->Dialog().ClearDialog( msg );
			if( accept )
			{
				screen->DeleteGame( index );
                screen->UpdateSavePreviews();
			}
			return idSWFScriptVar();
		}
	private:
		gameDialogMessages_t msg;
		int index;
		bool accept;
		idMenuScreen_Shell_Load* screen;
	};
	
	idStaticList< idSWFScriptFunction*, 4 > callbacks;
	callbacks.Append( new( TAG_SWF ) idSWFScriptFunction_LoadDamaged( GDM_LOAD_DAMAGED_FILE, true, index, this ) );
	callbacks.Append( new( TAG_SWF ) idSWFScriptFunction_LoadDamaged( GDM_LOAD_DAMAGED_FILE, false, index, this ) );
	idStaticList< idStrId, 4 > optionText;
	optionText.Append( idStrId( "#str_swf_load_delete" ) );	// DELETE
	optionText.Append( idStrId( "#STR_SWF_CANCEL" ) );
	
	common->Dialog().AddDynamicDialog( GDM_LOAD_DAMAGED_FILE, callbacks, optionText, false, "" );
}
/*
========================
idMenuScreen_Shell_SystemOptions::HideScreen
========================
*/
void idMenuScreen_Shell_SystemOptions::HideScreen( const mainMenuTransition_t transitionType ) {

    if ( systemData.IsRestartRequired() ) {
        class idSWFScriptFunction_Restart : public idSWFScriptFunction_RefCounted {
        public:
            idSWFScriptFunction_Restart( gameDialogMessages_t _msg, bool _restart ) {
                msg = _msg;
                restart = _restart;
            }
            idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
                common->Dialog().ClearDialog( msg );
                if ( restart ) {
                    idStr cmdLine = Sys_GetCmdLine();
                    if ( cmdLine.Find( "com_skipIntroVideos" ) < 0 ) {
                        cmdLine.Append( " +set com_skipIntroVideos 1" );
                    }
                    Sys_ReLaunch( (void*)cmdLine.c_str(), cmdLine.Length() );
                }
                return idSWFScriptVar();
            }
        private:
            gameDialogMessages_t msg;
            bool restart;
        };
        idStaticList<idSWFScriptFunction *, 4> callbacks;
        idStaticList<idStrId, 4> optionText;
        callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, false ) );
        callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, true ) );
        optionText.Append( idStrId( "#str_00100113" ) ); // Continue
        optionText.Append( idStrId( "#str_02487" ) ); // Restart Now
        common->Dialog().AddDynamicDialog( GDM_GAME_RESTART_REQUIRED, callbacks, optionText, true, idStr() );
    }

    if ( systemData.IsDataChanged() ) {
        systemData.CommitData();
    }

    idMenuScreen::HideScreen( transitionType );
}
Exemplo n.º 6
0
/*
========================
idSWFScriptVar::ToString
========================
*/
idStr idSWFScriptVar::ToString() const
{
	switch( type )
	{
		case SWF_VAR_STRINGID:
			return idStrId( value.i ).GetLocalizedString();
		case SWF_VAR_STRING:
			return *value.string;
		// RB begin
		case SWF_VAR_RESULT:
			return *value.string;
		// RB end
		
		case SWF_VAR_FLOAT:
			return va( "%g", value.f );
		case SWF_VAR_BOOL:
			return value.b ? "true" : "false";
		case SWF_VAR_INTEGER:
			return va( "%i", value.i );
			
		case SWF_VAR_NULL:
			return "[null]";
		case SWF_VAR_UNDEF:
			return "[undefined]";
		case SWF_VAR_OBJECT:
			return value.object->DefaultValue( true ).ToString();
		case SWF_VAR_FUNCTION:
			if( swf_debugShowAddress.GetBool() )
			{
				return va( "[function:%p]", value.function );
			}
			else
			{
				return "[function]";
			}
		default:
			assert( false );
			return "";
	}
}
Exemplo n.º 7
0
/*
===============
idCommonLocal::LoadGame
===============
*/
bool idCommonLocal::LoadGame( const char * saveName ) { 
	if ( IsMultiplayer() ) {
		common->Printf( "Can't load during net play.\n" );
		if ( wipeForced ) {
			ClearWipe();
		}
		return false;
	}

	if ( GetCurrentGame() != DOOM3_BFG ) {
		return false;
	}

	if ( session->GetSignInManager().GetMasterLocalUser() == NULL ) {
		return false;
	}
	if (mapSpawnData.savegameFile != NULL ) {
		return false;
	}

	bool found = false;
	const saveGameDetailsList_t & sgdl = session->GetSaveGameManager().GetEnumeratedSavegames();
	for ( int i = 0; i < sgdl.Num(); i++ ) {
		if ( sgdl[i].slotName == saveName ) {
			if ( sgdl[i].GetLanguage() != sys_lang.GetString() ) {
				idStaticList< idSWFScriptFunction *, 4 > callbacks;
				idStaticList< idStrId, 4 > optionText;
				optionText.Append( idStrId( "#str_swf_continue" ) );
				idStrStatic<256> langName = "#str_lang_" + sgdl[i].GetLanguage();
				idStrStatic<256> msg;
				msg.Format( idLocalization::GetString( "#str_dlg_wrong_language" ), idLocalization::GetString( langName ) );
				Dialog().AddDynamicDialog( GDM_SAVEGAME_WRONG_LANGUAGE, callbacks, optionText, true, msg, false, true );
				if ( wipeForced ) {
					ClearWipe();
				}
				return false;
			}
			found = true;
			break;
		}
	}
	if ( !found ) {
		common->Printf( "Could not find save '%s'\n", saveName );
		if ( wipeForced ) {
			ClearWipe();
		}
		return false;
	}

	mapSpawnData.savegameFile = &saveFile;
	mapSpawnData.stringTableFile = &stringsFile;

	saveFileEntryList_t files;
	files.Append( mapSpawnData.stringTableFile );
	files.Append( mapSpawnData.savegameFile );

	idStr slotName = saveName;
	ScrubSaveGameFileName( slotName );
	saveFile.Clear( false );
	stringsFile.Clear( false );

	saveGameHandle_t loadGameHandle = session->LoadGameSync( slotName, files );
	if ( loadGameHandle != 0 ) {
		return true;
	}
	mapSpawnData.savegameFile = NULL;
	if ( wipeForced ) {
		ClearWipe();
	}
	return false;
}
/*
========================
idMenuScreen_Shell_GameBrowser::OnServerListReady
========================
*/
void idMenuScreen_Shell_GameBrowser::OnServerListReady() {
	idMenuHandler_Shell * const mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );

	if ( mgr == NULL ) {
		return;
	}

	mgr->HidePacifier();

	idList< idPair< serverInfo_t, int > > servers;
	for ( int i = 0; i < session->NumServers(); ++i ) {
		const serverInfo_t * const server = session->ServerInfo( i );
		if ( server != NULL && server->joinable ) {
			idPair< serverInfo_t, int > & serverPair = servers.Alloc();
			serverPair.first = *server;
			serverPair.second = i;
		}
	}

	servers.SortWithTemplate( idSort_PlayerGamesList() );

	listWidget->ClearGames();
	for ( int i = 0; i < servers.Num(); ++i ) {
		idPair< serverInfo_t, int > & serverPair = servers[ i ];
		DescribeServer( serverPair.first, serverPair.second );
	}

	if ( servers.Num() > 0 ) {
		listWidget->Update();
		listWidget->SetViewOffset( 0 );
		listWidget->SetViewIndex( 0 );
		listWidget->SetFocusIndex( 0 );
	} else {
		listWidget->AddGame( "#str_swf_no_servers_found", idStrId(), idStr(), -1, 0, 0, false, false );
		listWidget->Update();
		listWidget->SetViewOffset( 0 );
		listWidget->SetViewIndex( 0 );
		listWidget->SetFocusIndex( 0 );
	}

	if ( mgr->GetCmdBar() != NULL ) {
		idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;

		mgr->GetCmdBar()->ClearAllButtons();

		if ( servers.Num() > 0 ) {
			buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
			if ( menuData->GetPlatform() != 2 ) {
				buttonInfo->label = "#STR_SWF_SELECT";
			}
			buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
		}

		buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
		if ( menuData->GetPlatform() != 2 ) {
			buttonInfo->label = "#str_00395";
		}
		buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );

		buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
		buttonInfo->label = "#str_02276";
		buttonInfo->action.Set( WIDGET_ACTION_COMMAND, BROWSER_COMMAND_REFRESH_SERVERS );

		if ( servers.Num() > 0 ) {
			buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY4 );
			buttonInfo->label = "#str_swf_view_profile";
			buttonInfo->action.Set( WIDGET_ACTION_COMMAND, BROWSER_COMMAND_SHOW_GAMERTAG );
		}

		mgr->GetCmdBar()->Update();
	}
}