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