MenuScreen_Shell_Settings.cpp 9.1 KB

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