MenuScreen_Shell_Dev.cpp 11 KB

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