MenuScreen_Shell_Playstation.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. 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.
  17. 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.
  18. ===========================================================================
  19. */
  20. #pragma hdrstop
  21. #include "../../idLib/precompiled.h"
  22. #include "../Game_local.h"
  23. const static int NUM_SETTING_OPTIONS = 8;
  24. /*
  25. ========================
  26. idMenuScreen_Shell_Playstation::Initialize
  27. ========================
  28. */
  29. void idMenuScreen_Shell_Playstation::Initialize( idMenuHandler * data ) {
  30. idMenuScreen::Initialize( data );
  31. if ( data != NULL ) {
  32. menuGUI = data->GetGUI();
  33. }
  34. SetSpritePath( "menuPlaystation" );
  35. options = new (TAG_SWF) idMenuWidget_DynamicList();
  36. idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
  37. idList< idStr > option;
  38. option.Append( "#str_swf_friends" ); // FRIENDS
  39. menuOptions.Append( option );
  40. option.Clear();
  41. option.Append( "#str_swf_check_for_invites" ); // CHECK FOR INVITES
  42. menuOptions.Append( option );
  43. options->SetListData( menuOptions );
  44. options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
  45. options->SetSpritePath( GetSpritePath(), "info", "options" );
  46. options->SetWrappingAllowed( true );
  47. while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
  48. idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
  49. buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
  50. buttonWidget->Initialize( data );
  51. options->AddChild( buttonWidget );
  52. }
  53. options->Initialize( data );
  54. AddChild( options );
  55. btnBack = new (TAG_SWF) idMenuWidget_Button();
  56. btnBack->Initialize( data );
  57. idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( data );
  58. if ( handler != NULL && handler->GetInGame() ) {
  59. btnBack->SetLabel( "#str_swf_pause_menu" );
  60. } else {
  61. btnBack->SetLabel( "#str_02305" );
  62. }
  63. btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
  64. btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
  65. AddChild( btnBack );
  66. options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
  67. options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
  68. options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
  69. options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
  70. 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 ) );
  71. 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 ) );
  72. 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 ) );
  73. 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 ) );
  74. }
  75. /*
  76. ========================
  77. idMenuScreen_Shell_Playstation::Update
  78. ========================
  79. */
  80. void idMenuScreen_Shell_Playstation::Update() {
  81. if ( menuData != NULL ) {
  82. idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
  83. if ( cmdBar != NULL ) {
  84. cmdBar->ClearAllButtons();
  85. idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
  86. buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
  87. if ( menuData->GetPlatform() != 2 ) {
  88. buttonInfo->label = "#str_00395";
  89. }
  90. buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
  91. buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
  92. if ( menuData->GetPlatform() != 2 ) {
  93. buttonInfo->label = "#str_SWF_SELECT";
  94. }
  95. buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
  96. }
  97. }
  98. idSWFScriptObject & root = GetSWFObject()->GetRootObject();
  99. if ( BindSprite( root ) ) {
  100. idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
  101. if ( heading != NULL ) {
  102. heading->SetText( "#str_swf_playstation" );
  103. heading->SetStrokeInfo( true, 0.75f, 1.75f );
  104. }
  105. idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
  106. if ( gradient != NULL && heading != NULL ) {
  107. gradient->SetXPos( heading->GetTextLength() );
  108. }
  109. }
  110. if ( btnBack != NULL ) {
  111. btnBack->BindSprite( root );
  112. }
  113. idMenuScreen::Update();
  114. }
  115. /*
  116. ========================
  117. idMenuScreen_Shell_Playstation::ShowScreen
  118. ========================
  119. */
  120. void idMenuScreen_Shell_Playstation::ShowScreen( const mainMenuTransition_t transitionType ) {
  121. idMenuScreen::ShowScreen( transitionType );
  122. }
  123. /*
  124. ========================
  125. idMenuScreen_Shell_Playstation::HideScreen
  126. ========================
  127. */
  128. void idMenuScreen_Shell_Playstation::HideScreen( const mainMenuTransition_t transitionType ) {
  129. idMenuScreen::HideScreen( transitionType );
  130. }
  131. /*
  132. ========================
  133. idMenuScreen_Shell_Playstation::HandleAction h
  134. ========================
  135. */
  136. bool idMenuScreen_Shell_Playstation::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
  137. if ( menuData == NULL ) {
  138. return true;
  139. }
  140. if ( menuData->ActiveScreen() != SHELL_AREA_PLAYSTATION ) {
  141. return false;
  142. }
  143. widgetAction_t actionType = action.GetType();
  144. const idSWFParmList & parms = action.GetParms();
  145. switch ( actionType ) {
  146. case WIDGET_ACTION_GO_BACK: {
  147. menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
  148. return true;
  149. }
  150. case WIDGET_ACTION_PRESS_FOCUSED: {
  151. if ( options == NULL ) {
  152. return true;
  153. }
  154. int selectionIndex = options->GetViewIndex();
  155. if ( parms.Num() == 1 ) {
  156. selectionIndex = parms[0].ToInteger();
  157. }
  158. if ( options->GetFocusIndex() != selectionIndex ) {
  159. options->SetFocusIndex( selectionIndex );
  160. options->SetViewIndex( options->GetViewOffset() + selectionIndex );
  161. }
  162. if ( selectionIndex == 0 ) {
  163. } else if ( selectionIndex == 1 ) {
  164. }
  165. return true;
  166. }
  167. }
  168. return idMenuWidget::HandleAction( action, event, widget, forceHandled );
  169. }