doom3-bfg/neo/d3xp/menus/MenuScreen_PDA_VideoDisks.cpp

371 lines
11 KiB
C++
Raw Normal View History

2012-11-26 18:58:24 +00:00
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
2012-11-26 18:58:24 +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
#include "../../idlib/precompiled.h"
2012-11-26 18:58:24 +00:00
#include "../Game_local.h"
static const int MAX_VIDEO_ITEMS = 5;
/*
========================
idMenuScreen_PDA_VideoDisks::Initialize
========================
*/
void idMenuScreen_PDA_VideoDisks::Initialize( idMenuHandler* data )
{
2012-11-26 18:58:24 +00:00
if( data != NULL )
{
2012-11-26 18:58:24 +00:00
menuGUI = data->GetGUI();
}
SetSpritePath( "menuVideo" );
2012-11-26 18:58:24 +00:00
videoDetails.SetSpritePath( GetSpritePath(), "info", "details" );
videoDetails.Initialize( data );
videoDetails.SetNoAutoFree( true );
2012-11-26 18:58:24 +00:00
scrollbar.SetSpritePath( GetSpritePath(), "info", "videoList", "scrollbar" );
scrollbar.Initialize( data );
scrollbar.SetNoAutoFree( true );
2012-11-26 18:58:24 +00:00
pdaVideoList.SetSpritePath( GetSpritePath(), "info", "videoList", "options" );
pdaVideoList.SetNumVisibleOptions( MAX_VIDEO_ITEMS );
pdaVideoList.SetWrappingAllowed( true );
pdaVideoList.SetNoAutoFree( true );
while( pdaVideoList.GetChildren().Num() < MAX_VIDEO_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_SELECT_PDA_VIDEO, pdaVideoList.GetChildren().Num() );
buttonWidget->RegisterEventObserver( &videoDetails );
buttonWidget->RegisterEventObserver( &scrollbar );
buttonWidget->Initialize( data );
pdaVideoList.AddChild( buttonWidget );
}
pdaVideoList.Initialize( data );
pdaVideoList.AddChild( &scrollbar );
AddChild( &pdaVideoList );
AddChild( &videoDetails );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new( TAG_SWF ) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_TAB_NEXT ).Set( new( TAG_SWF ) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_NEXT, WIDGET_EVENT_TAB_NEXT ) );
AddEventAction( WIDGET_EVENT_TAB_PREV ).Set( new( TAG_SWF ) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_PREV, WIDGET_EVENT_TAB_PREV ) );
2012-11-26 18:58:24 +00:00
idMenuScreen::Initialize( data );
}
/*
========================
idMenuScreen_PDA_VideoDisks::Update
========================
*/
void idMenuScreen_PDA_VideoDisks::Update()
{
2012-11-26 18:58:24 +00:00
idPlayer* player = gameLocal.GetLocalPlayer();
2012-11-26 18:58:24 +00:00
if( menuData != NULL )
{
idMenuWidget_CommandBar* cmdBar = dynamic_cast< idMenuWidget_CommandBar* const >( menuData->GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if( cmdBar != NULL )
{
2012-11-26 18:58:24 +00:00
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t* buttonInfo;
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if( menuData->GetPlatform() != 2 )
{
2012-11-26 18:58:24 +00:00
buttonInfo->label = "#str_01345";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_TAB );
buttonInfo->label = "";
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
if( player != NULL && player->GetInventory().videos.Num() > 0 )
{
if( player->GetVideoMaterial() == NULL )
{
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if( menuData->GetPlatform() != 2 )
{
2012-11-26 18:58:24 +00:00
buttonInfo->label = "#str_swf_play";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
else
{
2012-11-26 18:58:24 +00:00
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if( menuData->GetPlatform() != 2 )
{
2012-11-26 18:58:24 +00:00
buttonInfo->label = "#str_swf_stop";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
}
}
if( player != NULL )
{
2012-11-26 18:58:24 +00:00
//if ( pdaVideoList == NULL ) {
// idMenuScreen::Update();
// return;
//}
idSWFScriptObject& root = GetSWFObject()->GetRootObject();
2012-11-26 18:58:24 +00:00
int index = pdaVideoList.GetViewIndex();
const idDeclVideo* video = player->GetVideo( index );
if( video == NULL )
{
2012-11-26 18:58:24 +00:00
idMenuScreen::Update();
return;
}
if( player->GetVideoMaterial() != NULL )
{
2012-11-26 18:58:24 +00:00
// update video material
if( BindSprite( root ) && GetSprite() != NULL )
{
idSWFSpriteInstance* videoSprite = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "details", "video", "img" );
const idMaterial* mat = player->GetVideoMaterial();
if( videoSprite != NULL && mat != NULL )
{
2012-11-26 18:58:24 +00:00
videoSprite->SetMaterial( mat );
}
}
}
else
{
idSWFSpriteInstance* videoSprite = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "details", "video", "img" );
if( videoSprite != NULL )
{
2012-11-26 18:58:24 +00:00
videoSprite->SetMaterial( video->GetPreview() );
}
}
}
2012-11-26 18:58:24 +00:00
idMenuScreen::Update();
}
/*
========================
idMenuScreen_PDA_VideoDisks::ShowScreen
========================
*/
void idMenuScreen_PDA_VideoDisks::ShowScreen( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
videoItems.Clear();
idPlayer* player = gameLocal.GetLocalPlayer();
if( player != NULL )
{
2012-11-26 18:58:24 +00:00
int numVideos = player->GetInventory().videos.Num();
for( int i = 0; i < numVideos; ++i )
{
const idDeclVideo* video = player->GetVideo( i );
if( video != NULL )
{
2012-11-26 18:58:24 +00:00
idList< idStr > item;
item.Append( video->GetVideoName() );
videoItems.Append( item );
}
}
}
2012-11-26 18:58:24 +00:00
pdaVideoList.SetListData( videoItems );
2012-11-26 18:58:24 +00:00
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_VideoDisks::ToggleVideoDiskPlay
========================
*/
void idMenuScreen_PDA_VideoDisks::ToggleVideoDiskPlay()
{
2012-11-26 18:58:24 +00:00
idPlayer* player = gameLocal.GetLocalPlayer();
if( player == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
2012-11-26 18:58:24 +00:00
int index = pdaVideoList.GetViewIndex();
const idDeclVideo* video = player->GetVideo( index );
2012-11-26 18:58:24 +00:00
if( video == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
if( video == activeVideo )
{
2012-11-26 18:58:24 +00:00
player->EndVideoDisk();
activeVideo = NULL;
return;
}
2012-11-26 18:58:24 +00:00
activeVideo = video;
if( player->GetVideoMaterial() == NULL )
{
player->PlayVideoDisk( video );
}
else
{
2012-11-26 18:58:24 +00:00
player->EndVideoDisk();
}
}
/*
========================
idMenuScreen_PDA_VideoDisks::SelectedVideoToPlay
========================
*/
void idMenuScreen_PDA_VideoDisks::SelectedVideoToPlay( int index )
{
2012-11-26 18:58:24 +00:00
idPlayer* player = gameLocal.GetLocalPlayer();
if( player == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
player->EndVideoDisk();
if( menuData != NULL )
{
idMenuHandler_PDA* pdaHandler = dynamic_cast< idMenuHandler_PDA* const >( menuData );
2012-11-26 18:58:24 +00:00
pdaHandler->ClearVideoPlaying();
}
2012-11-26 18:58:24 +00:00
pdaVideoList.SetViewIndex( pdaVideoList.GetViewOffset() + index );
pdaVideoList.SetFocusIndex( index );
const idDeclVideo* video = player->GetVideo( pdaVideoList.GetViewOffset() + index );
if( video == NULL )
{
2012-11-26 18:58:24 +00:00
return;
}
if( video == activeVideo )
{
2012-11-26 18:58:24 +00:00
activeVideo = NULL;
return;
}
2012-11-26 18:58:24 +00:00
activeVideo = video;
player->PlayVideoDisk( video );
2012-11-26 18:58:24 +00:00
}
/*
========================
idMenuScreen_PDA_VideoDisks::HideScreen
========================
*/
void idMenuScreen_PDA_VideoDisks::HideScreen( const mainMenuTransition_t transitionType )
{
2012-11-26 18:58:24 +00:00
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_VideoDisks::HandleAction
========================
*/
bool idMenuScreen_PDA_VideoDisks::HandleAction( idWidgetAction& action, const idWidgetEvent& event, idMenuWidget* widget, bool forceHandled )
{
2012-11-26 18:58:24 +00:00
if( menuData == NULL )
{
2012-11-26 18:58:24 +00:00
return true;
}
if( menuData->ActiveScreen() != PDA_AREA_VIDEO_DISKS )
{
2012-11-26 18:58:24 +00:00
return false;
}
2012-11-26 18:58:24 +00:00
widgetAction_t actionType = action.GetType();
const idSWFParmList& parms = action.GetParms();
switch( actionType )
{
case WIDGET_ACTION_GO_BACK:
{
2012-11-26 18:58:24 +00:00
menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE );
return true;
2012-11-26 18:58:24 +00:00
}
case WIDGET_ACTION_START_REPEATER:
{
2012-11-26 18:58:24 +00:00
idWidgetAction repeatAction;
widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
assert( parms.Num() == 2 );
repeatAction.Set( repeatActionType, parms[ 1 ] );
if( menuData != NULL )
{
2012-11-26 18:58:24 +00:00
menuData->StartWidgetActionRepeater( widget, repeatAction, event );
}
return true;
}
case WIDGET_ACTION_STOP_REPEATER:
{
if( menuData != NULL )
{
2012-11-26 18:58:24 +00:00
menuData->ClearWidgetActionRepeater();
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED:
{
2012-11-26 18:58:24 +00:00
ToggleVideoDiskPlay();
Update();
return true;
}
}
2012-11-26 18:58:24 +00:00
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}