MenuScreen_Shell_Dev.cpp (11461B)
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_DEV_OPTIONS = 8; 33 34 /* 35 ======================== 36 idMenuScreen_Shell_Dev::Initialize 37 ======================== 38 */ 39 void idMenuScreen_Shell_Dev::Initialize( idMenuHandler * data ) { 40 idMenuScreen::Initialize( data ); 41 42 if ( data != NULL ) { 43 menuGUI = data->GetGUI(); 44 } 45 46 SetSpritePath( "menuSettings" ); 47 48 options = new (TAG_SWF) idMenuWidget_DynamicList(); 49 options->SetNumVisibleOptions( NUM_DEV_OPTIONS ); 50 options->SetSpritePath( GetSpritePath(), "info", "options" ); 51 options->SetWrappingAllowed( true ); 52 53 while ( options->GetChildren().Num() < NUM_DEV_OPTIONS ) { 54 idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button(); 55 buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() ); 56 buttonWidget->Initialize( data ); 57 options->AddChild( buttonWidget ); 58 } 59 options->Initialize( data ); 60 61 AddChild( options ); 62 63 btnBack = new (TAG_SWF) idMenuWidget_Button(); 64 btnBack->Initialize( data ); 65 btnBack->SetLabel( "MAIN MENU" ); 66 btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" ); 67 btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK ); 68 69 AddChild( btnBack ); 70 71 SetupDevOptions(); 72 options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) ); 73 options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) ); 74 options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) ); 75 options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) ); 76 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 ) ); 77 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 ) ); 78 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 ) ); 79 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 ) ); 80 } 81 82 /* 83 ======================== 84 idMenuScreen_Shell_Dev::SetupDevOptions 85 ======================== 86 */ 87 void idMenuScreen_Shell_Dev::SetupDevOptions() { 88 89 devOptions.Clear(); 90 91 devOptions.Append( devOption_t( "game/mars_city1", "Mars City 1" ) ); 92 devOptions.Append( devOption_t( "game/mc_underground", "MC Underground" ) ); 93 devOptions.Append( devOption_t( "game/mars_city2", "Mars City 2" ) ); 94 devOptions.Append( devOption_t( "game/admin", "Admin" ) ); 95 devOptions.Append( devOption_t( "game/alphalabs1", "Alpha Labs 1" ) ); 96 devOptions.Append( devOption_t( "game/alphalabs2", "Alpha Labs 2" ) ); 97 devOptions.Append( devOption_t( "game/alphalabs3", "Alpha Labs 3" ) ); 98 devOptions.Append( devOption_t( "game/alphalabs4", "Alpha Labs 4" ) ); 99 devOptions.Append( devOption_t( "game/enpro", "Enpro" ) ); 100 devOptions.Append( devOption_t( "game/commoutside", "Comm outside" ) ); 101 devOptions.Append( devOption_t( "game/comm1", "Comm 1" ) ); 102 devOptions.Append( devOption_t( "game/recycling1", "Recycling 1" ) ); 103 devOptions.Append( devOption_t( "game/recycling2", "Recycling 2" ) ); 104 devOptions.Append( devOption_t( "game/monorail", "Monorail" ) ); 105 devOptions.Append( devOption_t( "game/delta1", "Delta Labs 1" ) ); 106 devOptions.Append( devOption_t( "game/delta2a", "Delta Labs 2a" ) ); 107 devOptions.Append( devOption_t( "game/delta2b", "Delta Labs 2b" ) ); 108 devOptions.Append( devOption_t( "game/delta3", "Delta Labs 3" ) ); 109 devOptions.Append( devOption_t( "game/delta4", "Delta Labs 4" ) ); 110 devOptions.Append( devOption_t( "game/hell1", "Hell 1" ) ); 111 devOptions.Append( devOption_t( "game/delta5", "Delta Labs 5" ) ); 112 devOptions.Append( devOption_t( "game/cpu", "CPU" ) ); 113 devOptions.Append( devOption_t( "game/cpuboss", "CPU Boss" ) ); 114 devOptions.Append( devOption_t( "game/site3", "Site 3" ) ); 115 devOptions.Append( devOption_t( "game/caverns1", "Caverns 1" ) ); 116 devOptions.Append( devOption_t( "game/caverns2", "Caverns 2" ) ); 117 devOptions.Append( devOption_t( "game/hellhole", "Hell Hole" ) ); 118 devOptions.Append( devOption_t( NULL, "-DOOM 3 Expansion-" ) ); 119 devOptions.Append( devOption_t( "game/erebus1", "Erebus 1" ) ); 120 devOptions.Append( devOption_t( "game/erebus2", "Erebus 2" ) ); 121 devOptions.Append( devOption_t( "game/erebus3", "Erebus 3" ) ); 122 devOptions.Append( devOption_t( "game/erebus4", "Erebus 4" ) ); 123 devOptions.Append( devOption_t( "game/erebus5", "Erebus 5" ) ); 124 devOptions.Append( devOption_t( "game/erebus6", "Erebus 6" ) ); 125 devOptions.Append( devOption_t( "game/phobos1", "Phobos 1" ) ); 126 devOptions.Append( devOption_t( "game/phobos2", "Phobos 2" ) ); 127 devOptions.Append( devOption_t( "game/phobos3", "Phobos 3" ) ); 128 devOptions.Append( devOption_t( "game/phobos4", "Phobos 4" ) ); 129 devOptions.Append( devOption_t( "game/deltax", "Delta X" ) ); 130 devOptions.Append( devOption_t( "game/hell", "Hell" ) ); 131 devOptions.Append( devOption_t( NULL, "-Lost Missions-" ) ); 132 devOptions.Append( devOption_t( "game/le_enpro1", "Enpro 1" ) ); 133 devOptions.Append( devOption_t( "game/le_enpro2", "Enpro 2" ) ); 134 devOptions.Append( devOption_t( "game/le_underground", "Undeground" ) ); 135 devOptions.Append( devOption_t( "game/le_underground2", "Undeground 2" ) ); 136 devOptions.Append( devOption_t( "game/le_exis1", "Exis 1" ) ); 137 devOptions.Append( devOption_t( "game/le_exis2", "Exis 2" ) ); 138 devOptions.Append( devOption_t( "game/le_hell", "Hell" ) ); 139 devOptions.Append( devOption_t( "game/le_hell_post", "Hell Post" ) ); 140 devOptions.Append( devOption_t( NULL, "-Test Maps-" ) ); 141 devOptions.Append( devOption_t( "game/pdas", "PDAs" ) ); 142 devOptions.Append( devOption_t( "testmaps/test_box", "Box" ) ); 143 144 idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions; 145 146 for ( int i = 0; i < devOptions.Num(); ++i ) { 147 idList< idStr > option; 148 option.Append( devOptions[ i ].name ); 149 menuOptions.Append( option ); 150 } 151 152 options->SetListData( menuOptions ); 153 } 154 155 /* 156 ======================== 157 idMenuScreen_Shell_Dev::Update 158 ======================== 159 */ 160 void idMenuScreen_Shell_Dev::Update() { 161 162 if ( menuData != NULL ) { 163 idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar(); 164 if ( cmdBar != NULL ) { 165 cmdBar->ClearAllButtons(); 166 idMenuWidget_CommandBar::buttonInfo_t * buttonInfo; 167 buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 ); 168 if ( menuData->GetPlatform() != 2 ) { 169 buttonInfo->label = "#str_00395"; 170 } 171 buttonInfo->action.Set( WIDGET_ACTION_GO_BACK ); 172 173 buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 ); 174 if ( menuData->GetPlatform() != 2 ) { 175 buttonInfo->label = "#str_SWF_SELECT"; 176 } 177 buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED ); 178 } 179 } 180 181 idSWFScriptObject & root = GetSWFObject()->GetRootObject(); 182 if ( BindSprite( root ) ) { 183 idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" ); 184 if ( heading != NULL ) { 185 heading->SetText( "DEV" ); 186 heading->SetStrokeInfo( true, 0.75f, 1.75f ); 187 } 188 189 idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" ); 190 if ( gradient != NULL && heading != NULL ) { 191 gradient->SetXPos( heading->GetTextLength() ); 192 } 193 } 194 195 if ( btnBack != NULL ) { 196 btnBack->BindSprite( root ); 197 } 198 199 idMenuScreen::Update(); 200 } 201 202 /* 203 ======================== 204 idMenuScreen_Shell_Dev::ShowScreen 205 ======================== 206 */ 207 void idMenuScreen_Shell_Dev::ShowScreen( const mainMenuTransition_t transitionType ) { 208 idMenuScreen::ShowScreen( transitionType ); 209 } 210 211 /* 212 ======================== 213 idMenuScreen_Shell_Dev::HideScreen 214 ======================== 215 */ 216 void idMenuScreen_Shell_Dev::HideScreen( const mainMenuTransition_t transitionType ) { 217 idMenuScreen::HideScreen( transitionType ); 218 } 219 220 /* 221 ======================== 222 idMenuScreen_Shell_Dev::HandleAction h 223 ======================== 224 */ 225 bool idMenuScreen_Shell_Dev::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) { 226 227 if ( menuData == NULL ) { 228 return true; 229 } 230 231 if ( menuData->ActiveScreen() != SHELL_AREA_DEV ) { 232 return false; 233 } 234 235 widgetAction_t actionType = action.GetType(); 236 const idSWFParmList & parms = action.GetParms(); 237 238 switch ( actionType ) { 239 case WIDGET_ACTION_GO_BACK: { 240 menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE ); 241 return true; 242 } 243 case WIDGET_ACTION_PRESS_FOCUSED: { 244 if ( options == NULL ) { 245 return true; 246 } 247 248 int selectionIndex = options->GetViewIndex(); 249 if ( parms.Num() == 1 ) { 250 selectionIndex = parms[0].ToInteger(); 251 } 252 253 if ( options->GetFocusIndex() != selectionIndex - options->GetViewOffset() ) { 254 options->SetFocusIndex( selectionIndex ); 255 options->SetViewIndex( options->GetViewOffset() + selectionIndex ); 256 } 257 258 int mapIndex = options->GetViewIndex(); 259 if ( ( mapIndex < devOptions.Num() ) && ( devOptions[ mapIndex ].map != NULL ) ) { 260 cmdSystem->AppendCommandText( va( "devmap %s\n", devOptions[ mapIndex ].map ) ); 261 } 262 263 return true; 264 } 265 } 266 267 return idMenuWidget::HandleAction( action, event, widget, forceHandled ); 268 }