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-22 15:18:19 +00:00
|
|
|
#include "precompiled.h"
|
2012-11-26 18:58:24 +00:00
|
|
|
#include "../Game_local.h"
|
|
|
|
|
|
|
|
static const int MAX_PDA_ITEMS = 15;
|
|
|
|
static const int MAX_NAV_OPTIONS = 4;
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::Update
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_PDA::Update()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( gui == NULL || !gui->IsActive() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( activeScreen != nextScreen )
|
|
|
|
{
|
|
|
|
|
|
|
|
if( nextScreen == PDA_AREA_INVALID )
|
|
|
|
{
|
|
|
|
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>( transition ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuWidget_CommandBar* cmdBar = dynamic_cast< idMenuWidget_CommandBar* >( GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
|
|
|
|
if( cmdBar != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cmdBar->ClearAllButtons();
|
|
|
|
cmdBar->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idSWFSpriteInstance* menu = gui->GetRootObject().GetNestedSprite( "navBar" );
|
|
|
|
idSWFSpriteInstance* bg = gui->GetRootObject().GetNestedSprite( "background" );
|
|
|
|
idSWFSpriteInstance* edging = gui->GetRootObject().GetNestedSprite( "_fullScreen" );
|
|
|
|
|
|
|
|
if( menu != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menu->PlayFrame( "rollOff" );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( bg != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bg->PlayFrame( "rollOff" );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( edging != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
edging->PlayFrame( "rollOff" );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( activeScreen > PDA_AREA_INVALID && activeScreen < PDA_NUM_AREAS && menuScreens[ activeScreen ] != NULL )
|
|
|
|
{
|
|
|
|
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>( transition ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( nextScreen > PDA_AREA_INVALID && nextScreen < PDA_NUM_AREAS && menuScreens[ nextScreen ] != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuScreens[ nextScreen ]->UpdateCmds();
|
2012-11-28 15:47:07 +00:00
|
|
|
menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>( transition ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
transition = MENU_TRANSITION_INVALID;
|
|
|
|
activeScreen = nextScreen;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player != NULL )
|
|
|
|
{
|
|
|
|
if( activeScreen == PDA_AREA_USER_DATA )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bool isPlaying = player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO );
|
|
|
|
UpdateAudioLogPlaying( isPlaying );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( activeScreen == PDA_AREA_VIDEO_DISKS )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bool isPlaying = player->IsSoundChannelPlaying( SND_CHANNEL_PDA_VIDEO );
|
|
|
|
UdpateVideoPlaying( isPlaying );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuHandler::Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idMenuHandler::TriggerMenu
|
|
|
|
================================================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_PDA::TriggerMenu()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = PDA_AREA_USER_DATA;
|
|
|
|
transition = MENU_TRANSITION_FORCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::ActivateMenu
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_PDA::ActivateMenu( bool show )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuHandler::ActivateMenu( show );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( show )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// Add names to pda
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
pdaNames.Clear();
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int j = 0; j < player->GetInventory().pdas.Num(); j++ )
|
|
|
|
{
|
|
|
|
const idDeclPDA* pda = player->GetInventory().pdas[ j ];
|
2012-11-26 18:58:24 +00:00
|
|
|
idList< idStr > names;
|
2012-11-28 15:47:07 +00:00
|
|
|
names.Append( pda->GetPdaName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
pdaNames.Append( names );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
idMenuWidget_DynamicList* pdaList = dynamic_cast< idMenuWidget_DynamicList* >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
|
|
|
|
if( pdaList != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
pdaList->SetListData( pdaNames );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
navOptions.Clear();
|
|
|
|
navOptions.Append( idLocalization::GetString( "#str_04190" ) );
|
|
|
|
navOptions.Append( idLocalization::GetString( "#str_01442" ) );
|
|
|
|
navOptions.Append( idLocalization::GetString( "#str_01440" ) );
|
|
|
|
navOptions.Append( idLocalization::GetString( "#str_01414" ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuWidget_NavBar* navBar = dynamic_cast< idMenuWidget_NavBar* >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
|
|
|
|
if( navBar != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
navBar->SetListHeadings( navOptions );
|
2012-11-28 15:47:07 +00:00
|
|
|
navBar->SetFocusIndex( 0 );
|
2012-11-26 18:58:24 +00:00
|
|
|
navBar->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idMenuWidget_CommandBar* cmdBar = dynamic_cast< idMenuWidget_CommandBar* >( GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
|
|
|
|
if( cmdBar != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cmdBar->ClearAllButtons();
|
|
|
|
cmdBar->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = PDA_AREA_INVALID;
|
|
|
|
activeScreen = PDA_AREA_INVALID;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::Initialize
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_PDA::Initialize( const char* swfFile, idSoundWorld* sw )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuHandler::Initialize( swfFile, sw );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
//---------------------
|
|
|
|
// Initialize the menus
|
|
|
|
//---------------------
|
|
|
|
#define BIND_PDA_SCREEN( screenId, className, menuHandler ) \
|
|
|
|
menuScreens[ (screenId) ] = new (TAG_SWF) className(); \
|
|
|
|
menuScreens[ (screenId) ]->Initialize( menuHandler ); \
|
|
|
|
menuScreens[ (screenId) ]->AddRef(); \
|
|
|
|
menuScreens[ (screenId) ]->SetNoAutoFree( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < PDA_NUM_AREAS; ++i )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuScreens[ i ] = NULL;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
BIND_PDA_SCREEN( PDA_AREA_USER_DATA, idMenuScreen_PDA_UserData, this );
|
|
|
|
BIND_PDA_SCREEN( PDA_AREA_USER_EMAIL, idMenuScreen_PDA_UserEmails, this );
|
|
|
|
BIND_PDA_SCREEN( PDA_AREA_VIDEO_DISKS, idMenuScreen_PDA_VideoDisks, this );
|
|
|
|
BIND_PDA_SCREEN( PDA_AREA_INVENTORY, idMenuScreen_PDA_Inventory, this );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
pdaScrollBar.SetSpritePath( "pda_persons", "info", "scrollbar" );
|
|
|
|
pdaScrollBar.Initialize( this );
|
|
|
|
pdaScrollBar.SetNoAutoFree( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
pdaList.SetSpritePath( "pda_persons", "info", "list" );
|
|
|
|
pdaList.SetNumVisibleOptions( MAX_PDA_ITEMS );
|
|
|
|
pdaList.SetWrappingAllowed( true );
|
|
|
|
pdaList.SetNoAutoFree( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
while( pdaList.GetChildren().Num() < MAX_PDA_ITEMS )
|
|
|
|
{
|
|
|
|
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_PDA_SELECT_USER, pdaList.GetChildren().Num() );
|
|
|
|
buttonWidget->Initialize( this );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuScreens[ PDA_AREA_USER_DATA ] != NULL )
|
|
|
|
{
|
|
|
|
idMenuScreen_PDA_UserData* userDataScreen = dynamic_cast< idMenuScreen_PDA_UserData* >( menuScreens[ PDA_AREA_USER_DATA ] );
|
|
|
|
if( userDataScreen != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonWidget->RegisterEventObserver( userDataScreen->GetUserData() );
|
|
|
|
buttonWidget->RegisterEventObserver( userDataScreen->GetObjective() );
|
|
|
|
buttonWidget->RegisterEventObserver( userDataScreen->GetAudioFiles() );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuScreens[ PDA_AREA_USER_EMAIL ] != NULL )
|
|
|
|
{
|
|
|
|
idMenuScreen_PDA_UserEmails* userEmailScreen = dynamic_cast< idMenuScreen_PDA_UserEmails* >( menuScreens[ PDA_AREA_USER_EMAIL ] );
|
|
|
|
if( userEmailScreen != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
buttonWidget->RegisterEventObserver( &userEmailScreen->GetInbox() );
|
|
|
|
buttonWidget->RegisterEventObserver( userEmailScreen );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
buttonWidget->RegisterEventObserver( &pdaScrollBar );
|
|
|
|
pdaList.AddChild( buttonWidget );
|
|
|
|
}
|
|
|
|
pdaList.AddChild( &pdaScrollBar );
|
|
|
|
pdaList.Initialize( this );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
navBar.SetSpritePath( "navBar", "options" );
|
|
|
|
navBar.Initialize( this );
|
|
|
|
navBar.SetNumVisibleOptions( MAX_NAV_OPTIONS );
|
|
|
|
navBar.SetWrappingAllowed( true );
|
|
|
|
navBar.SetButtonSpacing( 20.0f, 25.0f, 75.0f );
|
|
|
|
navBar.SetInitialXPos( 40.0f );
|
|
|
|
navBar.SetNoAutoFree( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int count = 0; count < ( MAX_NAV_OPTIONS * 2 - 1 ); ++count )
|
|
|
|
{
|
|
|
|
idMenuWidget_NavButton* const navButton = new( TAG_SWF ) idMenuWidget_NavButton();
|
|
|
|
|
|
|
|
if( count < MAX_NAV_OPTIONS - 1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, count );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( count < ( ( MAX_NAV_OPTIONS - 1 ) * 2 ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int index = ( count - ( MAX_NAV_OPTIONS - 1 ) ) + 1;
|
|
|
|
navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, index );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, -1 );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
navBar.AddChild( navButton );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
//
|
|
|
|
// command bar
|
|
|
|
//
|
|
|
|
commandBarWidget.SetAlignment( idMenuWidget_CommandBar::LEFT );
|
|
|
|
commandBarWidget.SetSpritePath( "prompts" );
|
|
|
|
commandBarWidget.Initialize( this );
|
|
|
|
commandBarWidget.SetNoAutoFree( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
AddChild( &navBar );
|
|
|
|
AddChild( &pdaList );
|
|
|
|
AddChild( &pdaScrollBar );
|
|
|
|
AddChild( &commandBarWidget );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
|
|
|
|
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
menuScreens[ PDA_AREA_USER_DATA ]->RegisterEventObserver( &pdaList );
|
|
|
|
menuScreens[ PDA_AREA_USER_EMAIL ]->RegisterEventObserver( &pdaList );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player != NULL )
|
|
|
|
{
|
|
|
|
|
|
|
|
for( int j = 0; j < MAX_WEAPONS; j++ )
|
|
|
|
{
|
|
|
|
const char* weaponDefName = va( "def_weapon%d", j );
|
|
|
|
const char* weap = player->spawnArgs.GetString( weaponDefName );
|
2012-12-11 22:48:55 +00:00
|
|
|
if( weap != NULL && *weap != '\0' )
|
2012-11-28 15:47:07 +00:00
|
|
|
{
|
|
|
|
const idDeclEntityDef* weaponDef = gameLocal.FindEntityDef( weap, false );
|
|
|
|
if( weaponDef != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
declManager->FindMaterial( weaponDef->dict.GetString( "pdaIcon" ) );
|
|
|
|
declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
class idPDAGGUIClose : public idSWFScriptFunction_RefCounted
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
idSWFScriptVar Call( idSWFScriptObject* thisObject, const idSWFParmList& parms )
|
|
|
|
{
|
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
player->TogglePDA();
|
|
|
|
}
|
|
|
|
return idSWFScriptVar();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if( gui != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
gui->SetGlobal( "closePDA", new idPDAGGUIClose() );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// precache sounds
|
|
|
|
// don't load gui music for the pause menu to save some memory
|
2012-11-28 15:47:07 +00:00
|
|
|
const idSoundShader* soundShader = NULL;
|
2012-11-26 18:58:24 +00:00
|
|
|
soundShader = declManager->FindSound( "gui/list_scroll", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_SCROLL ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/btn_PDA_advance", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_ADVANCE ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/btn_PDA_back", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_BACK ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/pda_next_tab", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_BUILD_ON ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/pda_prev_tab", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_BUILD_OFF ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/btn_set_focus", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_FOCUS ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/btn_roll_over", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_ROLL_OVER ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
soundShader = declManager->FindSound( "gui/btn_roll_out", true );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( soundShader != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sounds[ GUI_SOUND_ROLL_OUT ] = soundShader->GetName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::HandleAction
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idMenuHandler_PDA::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( activeScreen == PDA_AREA_INVALID )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
widgetAction_t actionType = action.GetType();
|
2012-11-28 15:47:07 +00:00
|
|
|
const idSWFParmList& parms = action.GetParms();
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( event.type == WIDGET_EVENT_COMMAND )
|
|
|
|
{
|
|
|
|
if( menuScreens[ activeScreen ] != NULL && !forceHandled )
|
|
|
|
{
|
|
|
|
if( menuScreens[ activeScreen ]->HandleAction( action, event, widget, true ) )
|
|
|
|
{
|
|
|
|
if( actionType == WIDGET_ACTION_GO_BACK )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
PlaySound( GUI_SOUND_BACK );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
PlaySound( GUI_SOUND_ADVANCE );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
switch( actionType )
|
|
|
|
{
|
|
|
|
case WIDGET_ACTION_PDA_SELECT_USER:
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int index = parms[0].ToInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuWidget_DynamicList* pdaList = dynamic_cast< idMenuWidget_DynamicList* >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
|
|
|
|
if( pdaList != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
pdaList->SetViewIndex( pdaList->GetViewOffset() + index );
|
|
|
|
pdaList->SetFocusIndex( index );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
case WIDGET_ACTION_SCROLL_TAB:
|
|
|
|
{
|
|
|
|
|
|
|
|
if( transition != MENU_TRANSITION_INVALID )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
int delta = parms[0].ToInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuWidget_NavBar* navBar = dynamic_cast< idMenuWidget_NavBar* >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
|
|
|
|
if( navBar != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int focused = navBar->GetFocusIndex();
|
|
|
|
focused += delta;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( focused < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
focused = navBar->GetNumVisibleOptions() - 1;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( focused >= navBar->GetNumVisibleOptions() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
focused = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
navBar->SetViewIndex( focused );
|
|
|
|
navBar->SetFocusIndex( focused, true );
|
|
|
|
navBar->Update();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = activeScreen + delta;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( nextScreen < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = PDA_NUM_AREAS - 1;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( nextScreen == PDA_NUM_AREAS )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( delta < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
transition = MENU_TRANSITION_BACK;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
transition = MENU_TRANSITION_ADVANCE;
|
|
|
|
}
|
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_PDA_SELECT_NAV:
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int index = parms[0].ToInteger();
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( index == -1 && activeScreen == PDA_AREA_USER_EMAIL )
|
|
|
|
{
|
|
|
|
idMenuScreen_PDA_UserEmails* screen = dynamic_cast< idMenuScreen_PDA_UserEmails* const >( menuScreens[ PDA_AREA_USER_EMAIL ] );
|
|
|
|
if( screen )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screen->ShowEmail( false );
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// click on the current nav tab
|
2012-11-28 15:47:07 +00:00
|
|
|
if( index == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idMenuWidget_NavBar* navBar = dynamic_cast< idMenuWidget_NavBar* >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
|
|
|
|
if( navBar != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
navBar->SetViewIndex( navBar->GetViewOffset() + index );
|
|
|
|
navBar->SetFocusIndex( index, true );
|
|
|
|
navBar->Update();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( index < activeScreen )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = index;
|
|
|
|
transition = MENU_TRANSITION_BACK;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( index > activeScreen )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
nextScreen = index;
|
|
|
|
transition = MENU_TRANSITION_ADVANCE;
|
|
|
|
}
|
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_SELECT_PDA_AUDIO:
|
|
|
|
{
|
|
|
|
if( activeScreen == PDA_AREA_USER_DATA )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int index = parms[0].ToInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuWidget_DynamicList* pdaList = dynamic_cast< idMenuWidget_DynamicList* >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
bool change = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( pdaList != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int pdaIndex = pdaList->GetViewIndex();
|
|
|
|
change = PlayPDAAudioLog( pdaIndex, index );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( change )
|
|
|
|
{
|
|
|
|
if( widget->GetParent() != NULL )
|
|
|
|
{
|
|
|
|
idMenuWidget_DynamicList* audioList = dynamic_cast< idMenuWidget_DynamicList* >( widget->GetParent() );
|
2012-11-26 18:58:24 +00:00
|
|
|
int index = parms[0].ToInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( audioList != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
audioList->SetFocusIndex( index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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_SELECT_PDA_VIDEO:
|
|
|
|
{
|
|
|
|
if( activeScreen == PDA_AREA_VIDEO_DISKS )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int index = parms[0].ToInteger();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( menuScreens[ PDA_AREA_VIDEO_DISKS ] != NULL )
|
|
|
|
{
|
|
|
|
idMenuScreen_PDA_VideoDisks* screen = dynamic_cast< idMenuScreen_PDA_VideoDisks* const >( menuScreens[ PDA_AREA_VIDEO_DISKS ] );
|
|
|
|
if( screen != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screen->SelectedVideoToPlay( index );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return idMenuHandler::HandleAction( action, event, widget, forceHandled );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::PlayPDAAudioLog
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idMenuHandler_PDA::PlayPDAAudioLog( int pdaIndex, int audioIndex )
|
|
|
|
{
|
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player != NULL )
|
|
|
|
{
|
|
|
|
const idDeclPDA* pda = player->GetInventory().pdas[ pdaIndex ];
|
|
|
|
if( pda != NULL && pda->GetNumAudios() > audioIndex )
|
|
|
|
{
|
|
|
|
const idDeclAudio* aud = pda->GetAudioByIndex( audioIndex );
|
|
|
|
|
|
|
|
if( audioFile == aud )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
player->EndAudioLog();
|
|
|
|
return true;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( aud != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
audioFile = aud;
|
|
|
|
player->EndAudioLog();
|
|
|
|
player->PlayAudioLog( aud->GetWave() );
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::GetMenuScreen
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuScreen* idMenuHandler_PDA::GetMenuScreen( int index )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( index < 0 || index >= PDA_NUM_AREAS )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return menuScreens[ index ];
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::GetMenuScreen
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_PDA::UpdateAudioLogPlaying( bool playing )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( playing != audioLogPlaying && activeScreen == PDA_AREA_USER_DATA && menuScreens[ activeScreen ] != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuScreens[ activeScreen ]->Update();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
audioLogPlaying = playing;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !playing )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
audioFile = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_PDA::GetMenuScreen
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_PDA::UdpateVideoPlaying( bool playing )
|
|
|
|
{
|
|
|
|
|
|
|
|
if( playing != videoPlaying )
|
|
|
|
{
|
|
|
|
if( activeScreen == PDA_AREA_VIDEO_DISKS && menuScreens[ activeScreen ] != NULL )
|
|
|
|
{
|
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( !playing )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
player->EndVideoDisk();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idMenuScreen_PDA_VideoDisks* screen = dynamic_cast< idMenuScreen_PDA_VideoDisks* const >( menuScreens[ PDA_AREA_VIDEO_DISKS ] );
|
|
|
|
if( screen != NULL )
|
|
|
|
{
|
|
|
|
if( !playing )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screen->ClearActiveVideo();
|
|
|
|
}
|
|
|
|
screen->Update();
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
videoPlaying = playing;
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idMenuHandler_PDA::Cleanup
|
|
|
|
================================================
|
|
|
|
*/
|
|
|
|
void idMenuHandler_PDA::Cleanup()
|
|
|
|
{
|
|
|
|
idMenuHandler::Cleanup();
|
|
|
|
for( int index = 0; index < MAX_SCREEN_AREAS; ++index )
|
|
|
|
{
|
|
|
|
delete menuScreens[ index ];
|
|
|
|
menuScreens[ index ] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
/*
|
|
|
|
================================================
|
|
|
|
idMenuHandler_PDA::~idMenuHandler_PDA
|
|
|
|
================================================
|
|
|
|
*/
|
|
|
|
idMenuHandler_PDA::~idMenuHandler_PDA()
|
|
|
|
{
|
|
|
|
pdaScrollBar.Cleanup();
|
|
|
|
pdaList.Cleanup();
|
|
|
|
navBar.Cleanup();
|
|
|
|
commandBarWidget.Cleanup();
|
|
|
|
Cleanup();
|
2012-12-11 22:48:55 +00:00
|
|
|
}
|