DOOM-3-BFG

DOOM 3 BFG Edition
Log | Files | Refs

MenuScreen_Shell_Playstation.cpp (8032B)


      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 #pragma hdrstop
     29 #include "../../idLib/precompiled.h"
     30 #include "../Game_local.h"
     31 
     32 const static int NUM_SETTING_OPTIONS = 8;
     33 /*
     34 ========================
     35 idMenuScreen_Shell_Playstation::Initialize
     36 ========================
     37 */
     38 void idMenuScreen_Shell_Playstation::Initialize( idMenuHandler * data ) {
     39 	idMenuScreen::Initialize( data );
     40 
     41 	if ( data != NULL ) {
     42 		menuGUI = data->GetGUI();
     43 	}
     44 
     45 	SetSpritePath( "menuPlaystation" );
     46 
     47 	options = new (TAG_SWF) idMenuWidget_DynamicList();
     48 	idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;	
     49 	idList< idStr > option;
     50 	option.Append( "#str_swf_friends" );	// FRIENDS
     51 	menuOptions.Append( option );
     52 	option.Clear();
     53 	option.Append( "#str_swf_check_for_invites" );	// CHECK FOR INVITES
     54 	menuOptions.Append( option );
     55 	options->SetListData( menuOptions );
     56 	options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
     57 	options->SetSpritePath( GetSpritePath(), "info", "options" );
     58 	options->SetWrappingAllowed( true );
     59 
     60 	while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
     61 		idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
     62 		buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
     63 		buttonWidget->Initialize( data );
     64 		options->AddChild( buttonWidget );
     65 	}
     66 	options->Initialize( data );
     67 
     68 	AddChild( options );
     69 
     70 	btnBack = new (TAG_SWF) idMenuWidget_Button();
     71 	btnBack->Initialize( data );	
     72 	idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( data );
     73 	if ( handler != NULL && handler->GetInGame() ) {
     74 		btnBack->SetLabel( "#str_swf_pause_menu" );
     75 	} else {
     76 		btnBack->SetLabel( "#str_02305" );
     77 	}
     78 	btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
     79 	btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
     80 
     81 	AddChild( btnBack );
     82 
     83 	options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
     84 	options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
     85 	options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
     86 	options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
     87 	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 ) );
     88 	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 ) );
     89 	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 ) );
     90 	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 ) );
     91 }
     92 
     93 /*
     94 ========================
     95 idMenuScreen_Shell_Playstation::Update
     96 ========================
     97 */
     98 void idMenuScreen_Shell_Playstation::Update() {
     99 
    100 	if ( menuData != NULL ) {
    101 		idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
    102 		if ( cmdBar != NULL ) {
    103 			cmdBar->ClearAllButtons();
    104 			idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
    105 			buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
    106 			if ( menuData->GetPlatform() != 2 ) {
    107 				buttonInfo->label = "#str_00395";
    108 			}
    109 			buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
    110 
    111 			buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
    112 			if ( menuData->GetPlatform() != 2 ) {
    113 				buttonInfo->label = "#str_SWF_SELECT";
    114 			}
    115 			buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
    116 		}		
    117 	}
    118 
    119 	idSWFScriptObject & root = GetSWFObject()->GetRootObject();
    120 	if ( BindSprite( root ) ) {
    121 		idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
    122 		if ( heading != NULL ) {
    123 			heading->SetText( "#str_swf_playstation" );
    124 			heading->SetStrokeInfo( true, 0.75f, 1.75f );
    125 		}
    126 
    127 		idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
    128 		if ( gradient != NULL && heading != NULL ) {
    129 			gradient->SetXPos( heading->GetTextLength() );
    130 		}
    131 	}
    132 
    133 	if ( btnBack != NULL ) {
    134 		btnBack->BindSprite( root );
    135 	}
    136 
    137 	idMenuScreen::Update();
    138 }
    139 
    140 /*
    141 ========================
    142 idMenuScreen_Shell_Playstation::ShowScreen
    143 ========================
    144 */
    145 void idMenuScreen_Shell_Playstation::ShowScreen( const mainMenuTransition_t transitionType ) {
    146 	idMenuScreen::ShowScreen( transitionType );
    147 }
    148 
    149 /*
    150 ========================
    151 idMenuScreen_Shell_Playstation::HideScreen
    152 ========================
    153 */
    154 void idMenuScreen_Shell_Playstation::HideScreen( const mainMenuTransition_t transitionType ) {
    155 	idMenuScreen::HideScreen( transitionType );
    156 }
    157 
    158 /*
    159 ========================
    160 idMenuScreen_Shell_Playstation::HandleAction h
    161 ========================
    162 */
    163 bool idMenuScreen_Shell_Playstation::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
    164 
    165 	if ( menuData == NULL ) {
    166 		return true;
    167 	}
    168 
    169 	if ( menuData->ActiveScreen() != SHELL_AREA_PLAYSTATION ) {
    170 		return false;
    171 	}
    172 
    173 	widgetAction_t actionType = action.GetType();
    174 	const idSWFParmList & parms = action.GetParms();
    175 
    176 	switch ( actionType ) {
    177 		case WIDGET_ACTION_GO_BACK: {
    178 			menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
    179 			return true;
    180 		}
    181 		case WIDGET_ACTION_PRESS_FOCUSED: {
    182 			if ( options == NULL ) {
    183 				return true;
    184 			}
    185 
    186 			int selectionIndex = options->GetViewIndex();
    187 			if ( parms.Num() == 1 ) {
    188 				selectionIndex = parms[0].ToInteger();
    189 			}	
    190 
    191 			if ( options->GetFocusIndex() != selectionIndex ) {
    192 				options->SetFocusIndex( selectionIndex );
    193 				options->SetViewIndex( options->GetViewOffset() + selectionIndex );
    194 			}
    195 
    196 			if ( selectionIndex == 0 ) {
    197 
    198 
    199 			} else if ( selectionIndex == 1 ) { 
    200 			}
    201 
    202 			return true;
    203 		}
    204 	}
    205 
    206 	return idMenuWidget::HandleAction( action, event, widget, forceHandled );
    207 }