the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 428 lines 12 kB view raw
1#include "stdafx.h" 2#include "UI.h" 3#include "UIScene_SettingsOptionsMenu.h" 4 5#if defined(_XBOX_ONE) 6#define _ENABLE_LANGUAGE_SELECT 7#endif 8 9int UIScene_SettingsOptionsMenu::m_iDifficultySettingA[4]= 10{ 11 IDS_DIFFICULTY_PEACEFUL, 12 IDS_DIFFICULTY_EASY, 13 IDS_DIFFICULTY_NORMAL, 14 IDS_DIFFICULTY_HARD 15}; 16 17int UIScene_SettingsOptionsMenu::m_iDifficultyTitleSettingA[4]= 18{ 19 IDS_DIFFICULTY_TITLE_PEACEFUL, 20 IDS_DIFFICULTY_TITLE_EASY, 21 IDS_DIFFICULTY_TITLE_NORMAL, 22 IDS_DIFFICULTY_TITLE_HARD 23}; 24 25UIScene_SettingsOptionsMenu::UIScene_SettingsOptionsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) 26{ 27 m_bNavigateToLanguageSelector = false; 28 29 // Setup all the Iggy references we need for this scene 30 initialiseMovie(); 31 32 m_bNotInGame=(Minecraft::GetInstance()->level==NULL); 33 34 m_checkboxViewBob.init(IDS_VIEW_BOBBING,eControl_ViewBob,(app.GetGameSettings(m_iPad,eGameSetting_ViewBob)!=0)); 35 m_checkboxShowHints.init(IDS_HINTS,eControl_ShowHints,(app.GetGameSettings(m_iPad,eGameSetting_Hints)!=0)); 36 m_checkboxShowTooltips.init(IDS_IN_GAME_TOOLTIPS,eControl_ShowTooltips,(app.GetGameSettings(m_iPad,eGameSetting_Tooltips)!=0)); 37 m_checkboxInGameGamertags.init(IDS_IN_GAME_GAMERTAGS,eControl_InGameGamertags,(app.GetGameSettings(m_iPad,eGameSetting_GamertagsVisible)!=0)); 38 39 // check if we should display the mash-up option 40 if(m_bNotInGame && app.GetMashupPackWorlds(m_iPad)!=0xFFFFFFFF) 41 { 42 // the mash-up option is needed 43 m_bMashUpWorldsUnhideOption=true; 44 m_checkboxMashupWorlds.init(IDS_UNHIDE_MASHUP_WORLDS,eControl_ShowMashUpWorlds,false); 45 } 46 else 47 { 48 //m_checkboxMashupWorlds.init(L"",eControl_ShowMashUpWorlds,false); 49 removeControl(&m_checkboxMashupWorlds, true); 50 m_bMashUpWorldsUnhideOption=false; 51 } 52 53 unsigned char ucValue=app.GetGameSettings(m_iPad,eGameSetting_Autosave); 54 55 wchar_t autosaveLabels[9][256]; 56 for(unsigned int i = 0; i < 9; ++i) 57 { 58 if(i==0) 59 { 60 swprintf( autosaveLabels[i], 256, L"%ls", app.GetString( IDS_SLIDER_AUTOSAVE_OFF )); 61 } 62 else 63 { 64 swprintf( autosaveLabels[i], 256, L"%ls: %d %ls", app.GetString( IDS_SLIDER_AUTOSAVE ),i*15, app.GetString( IDS_MINUTES )); 65 } 66 67 } 68 m_sliderAutosave.setAllPossibleLabels(9,autosaveLabels); 69 m_sliderAutosave.init(autosaveLabels[ucValue],eControl_Autosave,0,8,ucValue); 70 71#if defined(_XBOX_ONE) || defined(__ORBIS__) 72 removeControl(&m_sliderAutosave,true); 73#endif 74 75 ucValue = app.GetGameSettings(m_iPad,eGameSetting_Difficulty); 76 wchar_t difficultyLabels[4][256]; 77 for(unsigned int i = 0; i < 4; ++i) 78 { 79 swprintf( difficultyLabels[i], 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[i])); 80 } 81 m_sliderDifficulty.setAllPossibleLabels(4,difficultyLabels); 82 m_sliderDifficulty.init(difficultyLabels[ucValue],eControl_Difficulty,0,3,ucValue); 83 84 wstring wsText=app.GetString(m_iDifficultySettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)]); 85 EHTMLFontSize size = eHTMLSize_Normal; 86 if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) 87 { 88 size = eHTMLSize_Splitscreen; 89 } 90 wchar_t startTags[64]; 91 swprintf(startTags,64,L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White)); 92 wsText= startTags + wsText; 93 94 m_labelDifficultyText.init(wsText); 95 96 // If you are in-game, only the game host can change in-game gamertags, and you can't change difficulty 97 // only the primary player gets to change the autosave and difficulty settings 98 bool bRemoveDifficulty=false; 99 bool bRemoveAutosave=false; 100 bool bRemoveInGameGamertags=false; 101 102 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); 103 bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; 104 if(!bPrimaryPlayer) 105 { 106 bRemoveDifficulty=true; 107 bRemoveAutosave=true; 108 bRemoveInGameGamertags=true; 109 } 110 111 if(!bNotInGame) // in the game 112 { 113 bRemoveDifficulty=true; 114 if(!g_NetworkManager.IsHost()) 115 { 116 bRemoveAutosave=true; 117 bRemoveInGameGamertags=true; 118 } 119 } 120 if(bRemoveDifficulty) 121 { 122 m_labelDifficultyText.setVisible( false ); 123 removeControl(&m_sliderDifficulty, true); 124 } 125 126 if(bRemoveAutosave) 127 { 128 removeControl(&m_sliderAutosave, true); 129 } 130 131 if(bRemoveInGameGamertags) 132 { 133 removeControl(&m_checkboxInGameGamertags, true); 134 } 135 136 // 4J-JEV: Changing languages in-game will produce many a bug. 137 // MGH - disabled the language select for the patch build, we'll re-enable afterwards 138 // 4J Stu - Removed it with a preprocessor def as we turn this off in various places 139#ifdef _ENABLE_LANGUAGE_SELECT 140 if (app.GetGameStarted()) 141 { 142 removeControl( &m_buttonLanguageSelect, false ); 143 } 144 else 145 { 146 m_buttonLanguageSelect.init(IDS_LANGUAGE_SELECTOR, eControl_Languages); 147 } 148#else 149 removeControl( &m_buttonLanguageSelect, false ); 150#endif 151 152 doHorizontalResizeCheck(); 153 154 if(app.GetLocalPlayerCount()>1) 155 { 156#if TO_BE_IMPLEMENTED 157 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad); 158#endif 159 } 160 161 m_labelDifficultyText.disableReinitialisation(); 162} 163 164UIScene_SettingsOptionsMenu::~UIScene_SettingsOptionsMenu() 165{ 166} 167 168void UIScene_SettingsOptionsMenu::tick() 169{ 170 UIScene::tick(); 171 172 if (m_bNavigateToLanguageSelector) 173 { 174 m_bNavigateToLanguageSelector = false; 175 setGameSettings(); 176 ui.NavigateToScene(m_iPad, eUIScene_LanguageSelector); 177 } 178} 179 180wstring UIScene_SettingsOptionsMenu::getMoviePath() 181{ 182 if(app.GetLocalPlayerCount() > 1) 183 { 184 return L"SettingsOptionsMenuSplit"; 185 } 186 else 187 { 188 return L"SettingsOptionsMenu"; 189 } 190} 191 192void UIScene_SettingsOptionsMenu::updateTooltips() 193{ 194 ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); 195} 196 197void UIScene_SettingsOptionsMenu::updateComponents() 198{ 199 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); 200 if(bNotInGame) 201 { 202 m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); 203 m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true); 204 } 205 else 206 { 207 m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,false); 208 209 if( app.GetLocalPlayerCount() == 1 ) m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,RenderManager.IsHiDef()); 210 else m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false); 211 } 212} 213 214void UIScene_SettingsOptionsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) 215{ 216 ui.AnimateKeyPress(iPad, key, repeat, pressed, released); 217 switch(key) 218 { 219 case ACTION_MENU_CANCEL: 220 if(pressed) 221 { 222 setGameSettings(); 223 navigateBack(); 224 } 225 break; 226 case ACTION_MENU_OK: 227#ifdef __ORBIS__ 228 case ACTION_MENU_TOUCHPAD_PRESS: 229#endif 230 sendInputToMovie(key, repeat, pressed, released); 231 break; 232 case ACTION_MENU_UP: 233 case ACTION_MENU_DOWN: 234 case ACTION_MENU_LEFT: 235 case ACTION_MENU_RIGHT: 236 sendInputToMovie(key, repeat, pressed, released); 237 break; 238 } 239} 240 241void UIScene_SettingsOptionsMenu::handlePress(F64 controlId, F64 childId) 242{ 243 //CD - Added for audio 244 ui.PlayUISFX(eSFX_Press); 245 246 switch((int)controlId) 247 { 248 case eControl_Languages: 249 m_bNavigateToLanguageSelector = true; 250 break; 251 } 252} 253 254void UIScene_SettingsOptionsMenu::handleReload() 255{ 256 m_bNavigateToLanguageSelector = false; 257 258 m_checkboxViewBob.init(IDS_VIEW_BOBBING,eControl_ViewBob,(app.GetGameSettings(m_iPad,eGameSetting_ViewBob)!=0)); 259 m_checkboxShowHints.init(IDS_HINTS,eControl_ShowHints,(app.GetGameSettings(m_iPad,eGameSetting_Hints)!=0)); 260 m_checkboxShowTooltips.init(IDS_IN_GAME_TOOLTIPS,eControl_ShowTooltips,(app.GetGameSettings(m_iPad,eGameSetting_Tooltips)!=0)); 261 m_checkboxInGameGamertags.init(IDS_IN_GAME_GAMERTAGS,eControl_InGameGamertags,(app.GetGameSettings(m_iPad,eGameSetting_GamertagsVisible)!=0)); 262 263 // check if we should display the mash-up option 264 if(m_bNotInGame && app.GetMashupPackWorlds(m_iPad)!=0xFFFFFFFF) 265 { 266 // the mash-up option is needed 267 m_bMashUpWorldsUnhideOption=true; 268 } 269 else 270 { 271 //m_checkboxMashupWorlds.init(L"",eControl_ShowMashUpWorlds,false); 272 removeControl(&m_checkboxMashupWorlds, true); 273 m_bMashUpWorldsUnhideOption=false; 274 } 275 276 unsigned char ucValue=app.GetGameSettings(m_iPad,eGameSetting_Autosave); 277 278 wchar_t autosaveLabels[9][256]; 279 for(unsigned int i = 0; i < 9; ++i) 280 { 281 if(i==0) 282 { 283 swprintf( autosaveLabels[i], 256, L"%ls", app.GetString( IDS_SLIDER_AUTOSAVE_OFF )); 284 } 285 else 286 { 287 swprintf( autosaveLabels[i], 256, L"%ls: %d %ls", app.GetString( IDS_SLIDER_AUTOSAVE ),i*15, app.GetString( IDS_MINUTES )); 288 } 289 290 } 291 m_sliderAutosave.setAllPossibleLabels(9,autosaveLabels); 292 m_sliderAutosave.init(autosaveLabels[ucValue],eControl_Autosave,0,8,ucValue); 293 294#if defined(_XBOX_ONE) || defined(__ORBIS__) 295 removeControl(&m_sliderAutosave,true); 296#endif 297 298 ucValue = app.GetGameSettings(m_iPad,eGameSetting_Difficulty); 299 300 wchar_t difficultyLabels[4][256]; 301 for(unsigned int i = 0; i < 4; ++i) 302 { 303 swprintf( difficultyLabels[i], 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[i])); 304 } 305 m_sliderDifficulty.setAllPossibleLabels(4,difficultyLabels); 306 m_sliderDifficulty.init(difficultyLabels[ucValue],eControl_Difficulty,0,3,ucValue); 307 308 wstring wsText=app.GetString(m_iDifficultySettingA[app.GetGameSettings(m_iPad,eGameSetting_Difficulty)]); 309 EHTMLFontSize size = eHTMLSize_Normal; 310 if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) 311 { 312 size = eHTMLSize_Splitscreen; 313 } 314 wchar_t startTags[64]; 315 swprintf(startTags,64,L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White)); 316 wsText= startTags + wsText; 317 318 m_labelDifficultyText.init(wsText); 319 320 321 // If you are in-game, only the game host can change in-game gamertags, and you can't change difficulty 322 // only the primary player gets to change the autosave and difficulty settings 323 bool bRemoveDifficulty=false; 324 bool bRemoveAutosave=false; 325 bool bRemoveInGameGamertags=false; 326 327 bool bNotInGame=(Minecraft::GetInstance()->level==NULL); 328 bool bPrimaryPlayer = ProfileManager.GetPrimaryPad()==m_iPad; 329 if(!bPrimaryPlayer) 330 { 331 bRemoveDifficulty=true; 332 bRemoveAutosave=true; 333 bRemoveInGameGamertags=true; 334 } 335 336 if(!bNotInGame) // in the game 337 { 338 bRemoveDifficulty=true; 339 if(!g_NetworkManager.IsHost()) 340 { 341 bRemoveAutosave=true; 342 bRemoveInGameGamertags=true; 343 } 344 } 345 if(bRemoveDifficulty) 346 { 347 m_labelDifficultyText.setVisible( false ); 348 removeControl(&m_sliderDifficulty, true); 349 } 350 351 if(bRemoveAutosave) 352 { 353 removeControl(&m_sliderAutosave, true); 354 } 355 356 if(bRemoveInGameGamertags) 357 { 358 removeControl(&m_checkboxInGameGamertags, true); 359 } 360 361 // MGH - disabled the language select for the patch build, we'll re-enable afterwards 362 // 4J Stu - Removed it with a preprocessor def as we turn this off in various places 363#ifdef _ENABLE_LANGUAGE_SELECT 364 // 4J-JEV: Changing languages in-game will produce many a bug. 365 if (app.GetGameStarted()) 366 { 367 removeControl( &m_buttonLanguageSelect, false ); 368 } 369 else 370 { 371 } 372#else 373 removeControl( &m_buttonLanguageSelect, false ); 374#endif 375 376 doHorizontalResizeCheck(); 377} 378 379void UIScene_SettingsOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) 380{ 381 int value = (int)currentValue; 382 switch((int)sliderId) 383 { 384 case eControl_Autosave: 385 m_sliderAutosave.handleSliderMove(value); 386 387 app.SetGameSettings(m_iPad,eGameSetting_Autosave,value); 388 // Update the autosave timer 389 app.SetAutosaveTimerTime(); 390 391 break; 392 case eControl_Difficulty: 393 m_sliderDifficulty.handleSliderMove(value); 394 395 app.SetGameSettings(m_iPad,eGameSetting_Difficulty,value); 396 397 wstring wsText=app.GetString(m_iDifficultySettingA[value]); 398 EHTMLFontSize size = eHTMLSize_Normal; 399 if(!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) 400 { 401 size = eHTMLSize_Splitscreen; 402 } 403 wchar_t startTags[64]; 404 swprintf(startTags,64,L"<font color=\"#%08x\">",app.GetHTMLColour(eHTMLColor_White)); 405 wsText= startTags + wsText; 406 m_labelDifficultyText.setLabel(wsText.c_str()); 407 break; 408 } 409} 410 411void UIScene_SettingsOptionsMenu::setGameSettings() 412{ 413 // check the checkboxes 414 app.SetGameSettings(m_iPad,eGameSetting_ViewBob,m_checkboxViewBob.IsChecked()?1:0); 415 app.SetGameSettings(m_iPad,eGameSetting_GamertagsVisible,m_checkboxInGameGamertags.IsChecked()?1:0); 416 app.SetGameSettings(m_iPad,eGameSetting_Hints,m_checkboxShowHints.IsChecked()?1:0); 417 app.SetGameSettings(m_iPad,eGameSetting_Tooltips,m_checkboxShowTooltips.IsChecked()?1:0); 418 419 // the mashup option will only be shown if some worlds have been previously hidden 420 if(m_bMashUpWorldsUnhideOption && m_checkboxMashupWorlds.IsChecked()) 421 { 422 // unhide all worlds 423 app.EnableMashupPackWorlds(m_iPad); 424 } 425 426 // 4J-PB - don't action changes here or we might write to the profile on backing out here and then get a change in the settings all, and write again on backing out there 427 //app.CheckGameSettingsChanged(true,pInputData->UserIndex); 428}