2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#pragma hdrstop
|
2012-12-02 21:37:32 +00:00
|
|
|
#include "../../idlib/precompiled.h"
|
2012-11-26 18:58:24 +00:00
|
|
|
#include "../Game_local.h"
|
|
|
|
|
|
|
|
|
|
|
|
const static int NUM_LOAD_OPTIONS = 10;
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::Initialize
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::Initialize( idMenuHandler* data )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuScreen::Initialize( data );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( data != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuGUI = data->GetGUI();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
SetSpritePath( "menuLoad" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
saveInfo = new( TAG_SWF ) idMenuWidget_Shell_SaveInfo();
|
2012-11-26 18:58:24 +00:00
|
|
|
saveInfo->SetSpritePath( GetSpritePath(), "info", "details" );
|
|
|
|
saveInfo->Initialize( data );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
options = new( TAG_SWF ) idMenuWidget_DynamicList();
|
2012-11-26 18:58:24 +00:00
|
|
|
options->SetNumVisibleOptions( NUM_LOAD_OPTIONS );
|
|
|
|
options->SetSpritePath( GetSpritePath(), "info", "options" );
|
|
|
|
options->SetWrappingAllowed( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
while( options->GetChildren().Num() < NUM_LOAD_OPTIONS )
|
|
|
|
{
|
|
|
|
idMenuWidget_Button* const buttonWidget = new( TAG_SWF ) idMenuWidget_Button();
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
|
|
|
|
buttonWidget->RegisterEventObserver( saveInfo );
|
|
|
|
buttonWidget->Initialize( data );
|
|
|
|
options->AddChild( buttonWidget );
|
|
|
|
}
|
|
|
|
options->Initialize( data );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
AddChild( options );
|
|
|
|
AddChild( saveInfo );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
btnBack = new( TAG_SWF ) idMenuWidget_Button();
|
2012-11-26 18:58:24 +00:00
|
|
|
btnBack->Initialize( data );
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuHandler_Shell* handler = dynamic_cast< idMenuHandler_Shell* >( data );
|
|
|
|
if( handler != NULL && handler->GetInGame() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
btnBack->SetLabel( "#str_swf_pause_menu" );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
btnBack->SetLabel( "#str_swf_campaign" );
|
|
|
|
}
|
|
|
|
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
|
|
|
|
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
AddChild( btnBack );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
btnDelete = new idMenuWidget_Button();
|
|
|
|
btnDelete->Initialize( data );
|
|
|
|
btnDelete->SetLabel( "" );
|
|
|
|
btnDelete->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_JOY3_ON_PRESS );
|
|
|
|
btnDelete->SetSpritePath( GetSpritePath(), "info", "btnDelete" );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
AddChild( btnDelete );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
|
|
|
|
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::Update
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::Update()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
UpdateSaveEnumerations();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
|
|
|
|
if( BindSprite( root ) )
|
|
|
|
{
|
|
|
|
idSWFTextInstance* heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
|
|
|
|
if( heading != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
heading->SetText( "#str_02187" ); // LOAD GAME
|
|
|
|
heading->SetStrokeInfo( true, 0.75f, 1.75f );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idSWFSpriteInstance* gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
|
|
|
|
if( gradient != NULL && heading != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
gradient->SetXPos( heading->GetTextLength() );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( btnBack != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
btnBack->BindSprite( root );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuScreen::Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::UpdateSaveEnumerations
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::UpdateSaveEnumerations()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
const saveGameDetailsList_t& saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
|
2012-11-26 18:58:24 +00:00
|
|
|
sortedSaves = saveGameInfo;
|
|
|
|
sortedSaves.Sort( idSort_SavesByDate() );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( options != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > saveList;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( session->GetSaveGameManager().IsWorking() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idList< idStr > saveName;
|
|
|
|
saveName.Append( "#str_dlg_refreshing" );
|
|
|
|
saveList.Append( saveName );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( sortedSaves.Num() == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idList< idStr > saveName;
|
|
|
|
saveName.Append( "#str_no_saves_found" );
|
|
|
|
saveList.Append( saveName );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
saveList.SetNum( sortedSaves.Num() );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int slot = 0; slot < sortedSaves.Num(); ++slot )
|
|
|
|
{
|
|
|
|
idStr& slotSaveName = saveList[slot].Alloc();
|
|
|
|
const idSaveGameDetails& details = sortedSaves[slot];
|
|
|
|
if( details.damaged )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
slotSaveName = va( S_COLOR_RED "%s", idLocalization::GetString( "#str_swf_corrupt_file" ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( details.GetSaveVersion() > BUILD_NUMBER )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
slotSaveName = va( S_COLOR_RED "%s", idLocalization::GetString( "#str_swf_wrong_version" ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( details.slotName.Icmp( "autosave" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
slotSaveName.Append( S_COLOR_YELLOW );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( details.slotName.Icmp( "quick" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
slotSaveName.Append( S_COLOR_ORANGE );
|
|
|
|
}
|
|
|
|
slotSaveName.Append( details.GetMapName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
options->SetListData( saveList );
|
2012-11-26 18:58:24 +00:00
|
|
|
options->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( menuData != NULL )
|
|
|
|
{
|
|
|
|
idMenuWidget_CommandBar* cmdBar = menuData->GetCmdBar();
|
|
|
|
if( cmdBar != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cmdBar->ClearAllButtons();
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuWidget_CommandBar::buttonInfo_t* buttonInfo;
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuData->GetPlatform() != 2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonInfo->label = "#str_00395"; // BACK
|
|
|
|
}
|
|
|
|
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( sortedSaves.Num() > 0 && !session->GetSaveGameManager().IsWorking() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuData->GetPlatform() != 2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonInfo->label = "#str_02187"; // LOAD GAME
|
|
|
|
}
|
|
|
|
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuData->GetPlatform() != 2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonInfo->label = "#str_02315"; // DELETE GAME
|
|
|
|
}
|
|
|
|
buttonInfo->action.Set( WIDGET_ACTION_JOY3_ON_PRESS );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( btnDelete != NULL )
|
|
|
|
{
|
|
|
|
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
|
|
|
|
if( btnDelete->BindSprite( root ) )
|
|
|
|
{
|
|
|
|
if( menuData->GetPlatform() != 2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
btnDelete->SetLabel( "" );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
btnDelete->GetSprite()->SetVisible( true );
|
|
|
|
btnDelete->SetLabel( "#str_02315" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
btnDelete->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( btnDelete != NULL )
|
|
|
|
{
|
|
|
|
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
|
|
|
|
if( btnDelete->BindSprite( root ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
btnDelete->SetLabel( "" );
|
|
|
|
btnDelete->Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmdBar->Update();
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( saveInfo != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
saveInfo->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( options != NULL && options->GetTotalNumberOfOptions() > 0 && options->GetViewIndex() >= options->GetTotalNumberOfOptions() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
options->SetViewIndex( options->GetTotalNumberOfOptions() - 1 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( options->GetViewOffset() > options->GetViewIndex() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
options->SetViewOffset( options->GetViewIndex() );
|
|
|
|
}
|
|
|
|
options->SetFocusIndex( options->GetViewIndex() - options->GetViewOffset() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::ShowScreen
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::ShowScreen( const mainMenuTransition_t transitionType )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuScreen::ShowScreen( transitionType );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::HideScreen
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::HideScreen( const mainMenuTransition_t transitionType )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuScreen::HideScreen( transitionType );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::LoadDamagedGame
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::LoadDamagedGame( int index )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( index >= sortedSaves.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
class idSWFScriptFunction_LoadDamaged : public idSWFScriptFunction_RefCounted
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptFunction_LoadDamaged( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Load* _screen )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
msg = _msg;
|
|
|
|
accept = _accept;
|
|
|
|
index = _index;
|
|
|
|
screen = _screen;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Dialog().ClearDialog( msg );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( accept )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screen->DeleteGame( index );
|
|
|
|
}
|
|
|
|
return idSWFScriptVar();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
gameDialogMessages_t msg;
|
|
|
|
int index;
|
|
|
|
bool accept;
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuScreen_Shell_Load* screen;
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
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 ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
idStaticList< idStrId, 4 > optionText;
|
|
|
|
optionText.Append( idStrId( "#str_02315" ) ); // DELETE
|
|
|
|
optionText.Append( idStrId( "#STR_SWF_CANCEL" ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Dialog().AddDynamicDialog( GDM_LOAD_DAMAGED_FILE, callbacks, optionText, false, "" );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::LoadGame
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::LoadGame( int index )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuData == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( index < GetSortedSaves().Num() && GetSortedSaves()[index].damaged )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
LoadDamagedGame( index );
|
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
bool isDead = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player != NULL && player->health <= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
isDead = true;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuHandler_Shell* mgr = dynamic_cast< idMenuHandler_Shell* >( menuData );
|
|
|
|
if( mgr != NULL && mgr->GetInGame() && !isDead )
|
|
|
|
{
|
|
|
|
|
|
|
|
class idSWFScriptFunction_LoadDialog : public idSWFScriptFunction_RefCounted
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptFunction_LoadDialog( gameDialogMessages_t _msg, bool _accept, const char* _name )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
msg = _msg;
|
|
|
|
accept = _accept;
|
|
|
|
name = _name;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Dialog().ClearDialog( msg );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( accept && name != NULL )
|
|
|
|
{
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
cmdSystem->AppendCommandText( va( "loadgame %s\n", name ) );
|
|
|
|
}
|
|
|
|
return idSWFScriptVar();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
gameDialogMessages_t msg;
|
|
|
|
bool accept;
|
2012-11-28 15:47:07 +00:00
|
|
|
const char* name;
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( index < sortedSaves.Num() )
|
|
|
|
{
|
|
|
|
const idStr& name = sortedSaves[ index ].slotName;
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Dialog().AddDialog( GDM_SP_LOAD_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_LoadDialog( GDM_SP_LOAD_SAVE, true, name.c_str() ), new idSWFScriptFunction_LoadDialog( GDM_SP_LOAD_SAVE, false, name.c_str() ), false );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( index < sortedSaves.Num() )
|
|
|
|
{
|
|
|
|
const idStr& name = sortedSaves[ index ].slotName;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
cmdSystem->AppendCommandText( va( "loadgame %s\n", name.c_str() ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Save::DeleteGame
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuScreen_Shell_Load::DeleteGame( int index )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idSWFScriptFunction_DeleteGame : public idSWFScriptFunction_RefCounted
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptFunction_DeleteGame( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Load* _screen )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
msg = _msg;
|
|
|
|
accept = _accept;
|
|
|
|
index = _index;
|
|
|
|
screen = _screen;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Dialog().ClearDialog( msg );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( accept && screen != NULL )
|
|
|
|
{
|
|
|
|
if( index < screen->GetSortedSaves().Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
session->DeleteSaveGameSync( screen->GetSortedSaves()[ index ].slotName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return idSWFScriptVar();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
gameDialogMessages_t msg;
|
|
|
|
int index;
|
|
|
|
bool accept;
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuScreen_Shell_Load* screen;
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Dialog().AddDialog( GDM_DELETE_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_DeleteGame( GDM_DELETE_SAVE, true, index, this ), new idSWFScriptFunction_DeleteGame( GDM_DELETE_SAVE, false, index, this ), false );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuScreen_Shell_Load::HandleAction h
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idMenuScreen_Shell_Load::HandleAction( idWidgetAction& action, const idWidgetEvent& event, idMenuWidget* widget, bool forceHandled )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuData != NULL )
|
|
|
|
{
|
|
|
|
if( menuData->ActiveScreen() != SHELL_AREA_LOAD )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
widgetAction_t actionType = action.GetType();
|
2012-11-28 15:47:07 +00:00
|
|
|
const idSWFParmList& parms = action.GetParms();
|
|
|
|
switch( actionType )
|
|
|
|
{
|
|
|
|
case WIDGET_ACTION_JOY4_ON_PRESS:
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case WIDGET_ACTION_JOY3_ON_PRESS:
|
|
|
|
{
|
|
|
|
if( options == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int selectionIndex = options->GetViewIndex();
|
|
|
|
DeleteGame( selectionIndex );
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case WIDGET_ACTION_GO_BACK:
|
|
|
|
{
|
|
|
|
if( menuData != NULL )
|
|
|
|
{
|
|
|
|
if( game->IsInGame() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuData->SetNextScreen( SHELL_AREA_CAMPAIGN, MENU_TRANSITION_SIMPLE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case WIDGET_ACTION_PRESS_FOCUSED:
|
|
|
|
{
|
|
|
|
if( options == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( sortedSaves.Num() == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int selectionIndex = options->GetViewIndex();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( parms.Num() == 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
selectionIndex = parms[0].ToInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( selectionIndex != options->GetFocusIndex() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
|
|
|
|
options->SetFocusIndex( selectionIndex );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
LoadGame( options->GetViewOffset() + selectionIndex );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
LoadGame( options->GetViewIndex() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case WIDGET_ACTION_SCROLL_VERTICAL:
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
|
|
|
|
}
|