diff --git a/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.cpp index 5135da76..b0ec1b1f 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.cpp @@ -1,620 +1,111 @@ #include "stdafx.h" #include "UI.h" #include "UIScene_CreateBattleMenu.h" -#include "..\..\MinecraftServer.h" -#include "..\..\Minecraft.h" -#include "..\..\Options.h" -#include "..\..\TexturePackRepository.h" -#include "..\..\TexturePack.h" -#include "..\..\..\Minecraft.World\LevelSettings.h" -#include "..\..\..\Minecraft.World\StringHelpers.h" -#include "..\..\..\Minecraft.World\BiomeSource.h" -#include "..\..\..\Minecraft.World\IntCache.h" -#include "..\..\..\Minecraft.World\LevelType.h" -#include "..\..\DLCTexturePack.h" -#ifdef __PSVITA__ -#include "PSVita\Network\SQRNetworkManager_AdHoc_Vita.h" -#endif - -#ifdef _WINDOWS64 - -#include -#include "Xbox\Resource.h" -#endif - -#define GAME_CREATE_ONLINE_TIMER_ID 0 -#define GAME_CREATE_ONLINE_TIMER_TIME 100 - -int UIScene_CreateBattleMenu::m_iDifficultyTitleSettingA[] = +UIScene_CreateBattleMenu::UIScene_CreateBattleMenu(int iPad, void *initData, + UILayer *parentLayer) + : UIScene(iPad, parentLayer) { - IDS_DIFFICULTY_PEACEFUL, - IDS_DIFFICULTY_EASY, - IDS_DIFFICULTY_NORMAL, - IDS_DIFFICULTY_HARD -}; - -UIScene_CreateBattleMenu::UIScene_CreateBattleMenu(int iPad, void* initData, UILayer* parentLayer) : IUIScene_StartGame(iPad, parentLayer) -{ - // Setup Iggy UI - initialiseMovie(); + // Load the SWF and set up all mapped elements + initialiseMovie(); - m_iPad = iPad; - m_bIgnoreInput = false; - - // ---- Menu Title ---- - m_labelMenuTitle.init(L"Battle"); - - // ---- Multiplayer permissions ---- - m_bMultiplayerAllowed = ProfileManager.IsSignedInLive(m_iPad) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); - - bool bGameSetting_Online = (app.GetGameSettings(m_iPad, eGameSetting_Online) != 0); - m_MoreOptionsParams.bOnlineSettingChangedBySystem = false; - - // ---- Central Spawn Checkbox ---- - m_checkboxCentralSpawn.init(L"Central Spawn", eControl_CentralSpawn, TRUE); - - // ---- Online Game Checkbox ---- - bool bOnlineGame = FALSE; - - if (m_bMultiplayerAllowed) - { - bOnlineGame = bGameSetting_Online ? TRUE : FALSE; - - m_MoreOptionsParams.bOnlineGame = bOnlineGame; - - if (bOnlineGame) - { - m_MoreOptionsParams.bInviteOnly = - (app.GetGameSettings(m_iPad, eGameSetting_InviteOnly) != 0) ? TRUE : FALSE; - - m_MoreOptionsParams.bAllowFriendsOfFriends = - (app.GetGameSettings(m_iPad, eGameSetting_FriendsOfFriends) != 0) ? TRUE : FALSE; - } - else - { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; - } - } - else - { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; - - if (bGameSetting_Online) - m_MoreOptionsParams.bOnlineSettingChangedBySystem = true; - } - - m_checkboxOnline.SetEnable(true); - - if (ProfileManager.IsSignedInLive(m_iPad) == false) - m_checkboxOnline.SetEnable(false); - - if (m_MoreOptionsParams.bOnlineSettingChangedBySystem) - { - m_checkboxOnline.SetEnable(false); - bOnlineGame = false; - } - - m_checkboxOnline.init(L"Online Game", eControl_OnlineGame, bOnlineGame); - - // ---- Public Game Checkbox ---- - m_checkboxPublicGame.init(L"Public Game", eControl_PublicGame, TRUE); - - // ---- Allow Friends Of Friends Checkbox ---- - m_checkboxFriendsOfFriends.init(L"Allow Friends of Friends", eControl_FriendsOfFriends, TRUE); - - // ---- Invite Only Checkbox ---- - m_checkboxInviteOnly.init(L"Invite Only", eControl_InviteOnly, FALSE); - - // ---- Select Maps Button ---- - m_buttonSelectMaps.init(L"Select Maps", eControl_SelectMaps); - - // ---- Round Length Slider ---- - WCHAR tempString[128]; - swprintf(tempString, 128, L"Round Length: Normal"); - - m_sliderRoundLength.init(tempString, eControl_RoundLength, 0, 2, 1); - - // ---- Create Casual Button ---- - m_buttonCreateWorld.init(L"Create Casual", eControl_CreateCasual); - - // ---- Timer ---- - addTimer(GAME_CREATE_ONLINE_TIMER_ID, GAME_CREATE_ONLINE_TIMER_TIME); - - // ---- Telemetry ---- - TelemetryManager->RecordMenuShown(m_iPad, eUIScene_CreateWorldMenu, 0); -} - - - -UIScene_CreateBattleMenu::~UIScene_CreateBattleMenu() -{ -} - -void UIScene_CreateBattleMenu::updateTooltips() -{ - ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); -} - -void UIScene_CreateBattleMenu::updateComponents() -{ - m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true); - m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false); + // Initialize controls with labels and IDs + m_buttonOk.init(NULL, 0); + m_buttonCancel.init(NULL, 1); + m_checkOption.init(L"Central Spawn", 2, false); + m_checkPoint.init(L"Online Game", 3, false); + m_mariotomato.init(L"Public Game", 4, false); + m_sliderValue.init(L"Difficulty", 5, 0, 100, 50); + m_labelTitle.init(L"My Custom Menu"); + m_labelStatus.init(L"Ready"); } wstring UIScene_CreateBattleMenu::getMoviePath() { - return L"CreateWorldMenu"; + // Return the base SWF name (resolution suffix added automatically) + return L"UIScene_CreateBattleGame"; } -UIControl* UIScene_CreateBattleMenu::GetMainPanel() +void UIScene_CreateBattleMenu::handleReload() { - return &m_controlMainPanel; -} - -void UIScene_CreateBattleMenu::handleDestroy() -{ -#ifdef __PSVITA__ - app.DebugPrintf("missing InputManager.DestroyKeyboard on Vita !!!!!!\n"); -#endif - - // shut down the keyboard if it is displayed -#if ( defined __PS3__ || defined __ORBIS__ || defined _DURANGO) - InputManager.DestroyKeyboard(); -#endif -} - -void UIScene_CreateBattleMenu::tick() -{ - UIScene::tick(); - - - if(m_iSetTexturePackDescription >= 0 ) - { - UpdateTexturePackDescription( m_iSetTexturePackDescription ); - m_iSetTexturePackDescription = -1; - } - if(m_bShowTexturePackDescription) - { - slideLeft(); - m_texturePackDescDisplayed = true; - - m_bShowTexturePackDescription = false; - } - -#ifdef __ORBIS__ - // check the status of the PSPlus common dialog - switch (sceNpCommerceDialogUpdateStatus()) - { - case SCE_COMMON_DIALOG_STATUS_FINISHED: - { - SceNpCommerceDialogResult Result; - sceNpCommerceDialogGetResult(&Result); - sceNpCommerceDialogTerminate(); - - if(Result.authorized) - { - ProfileManager.PsPlusUpdate(ProfileManager.GetPrimaryPad(), &Result); - // they just became a PSPlus member - checkStateAndStartGame(); - } - else - { - // continue offline? - UINT uiIDA[1]; - uiIDA[0]=IDS_PRO_NOTONLINE_DECLINE; - - // Give the player a warning about the texture pack missing - ui.RequestAlertMessage(IDS_PLAY_OFFLINE,IDS_NO_PLAYSTATIONPLUS, uiIDA, 1, ProfileManager.GetPrimaryPad(),&UIScene_CreateBattleMenu::ContinueOffline,dynamic_cast(this)); - } - } - break; - default: - break; - } -#endif -} - -#ifdef __ORBIS__ -int UIScene_CreateBattleMenu::ContinueOffline(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - UIScene_CreateBattleMenu* pClass = (UIScene_CreateBattleMenu*)pParam; - - // results switched for this dialog - if(result==C4JStorage::EMessage_ResultAccept) - { - pClass->m_MoreOptionsParams.bOnlineGame=false; - pClass->checkStateAndStartGame(); - } - return 0; -} - -#endif - -#ifdef _WINDOWS64 -void UIScene_CreateBattleMenu::getDirectEditInputs(vector &inputs) -{ - inputs.push_back(&m_editWorldName); -} - -void UIScene_CreateBattleMenu::onDirectEditFinished(UIControl_TextInput *input, UIControl_TextInput::EDirectEditResult result) -{ - m_worldName = input->getEditBuffer(); - m_buttonCreateWorld.setEnable(!m_worldName.empty()); -} -#endif - -void UIScene_CreateBattleMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) -{ - if(m_bIgnoreInput) return; -#ifdef _WINDOWS64 - if (isDirectEditBlocking()) { handled = true; return; } -#endif - - ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released); - - switch(key) - { - case ACTION_MENU_CANCEL: - if(pressed) - { - navigateBack(); - handled = true; - } - break; - case ACTION_MENU_OK: -#ifdef __ORBIS__ - case ACTION_MENU_TOUCHPAD_PRESS: -#endif - - // 4J-JEV: Inform user why their game must be offline. -#if defined _XBOX_ONE - if ( pressed && controlHasFocus(m_checkboxOnline.getId()) && !m_checkboxOnline.IsEnabled() ) - { - UINT uiIDA[1] = { IDS_CONFIRM_OK }; - ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_XBOXLIVE_NOTIFICATION, uiIDA, 1, iPad); - } -#endif - - case ACTION_MENU_UP: - case ACTION_MENU_DOWN: - case ACTION_MENU_LEFT: - case ACTION_MENU_RIGHT: - case ACTION_MENU_OTHER_STICK_UP: - case ACTION_MENU_OTHER_STICK_DOWN: - sendInputToMovie(key, repeat, pressed, released); - - bool bOnlineGame = m_checkboxOnline.IsChecked(); - if (m_MoreOptionsParams.bOnlineGame != bOnlineGame) - { - m_MoreOptionsParams.bOnlineGame = bOnlineGame; - - if (!m_MoreOptionsParams.bOnlineGame) - { - m_MoreOptionsParams.bInviteOnly = false; - m_MoreOptionsParams.bAllowFriendsOfFriends = false; - } - } - - handled = true; - break; - } -} - -void UIScene_CreateBattleMenu::handlePress(F64 controlId, F64 childId) -{ - if(m_bIgnoreInput) return; -#ifdef _WINDOWS64 - if (isDirectEditBlocking()) return; -#endif - - //CD - Added for audio - ui.PlayUISFX(eSFX_Press); - - switch((int)controlId) - { - case eControl_EditWorldName: - { - m_bIgnoreInput=true; -#ifdef _WINDOWS64 - if (!g_KBMInput.IsKBMActive()) - { - UIKeyboardInitData kbData; - kbData.title = L"Host Mini Game"; - kbData.defaultText = m_editWorldName.getLabel(); - kbData.maxChars = 25; - kbData.callback = &UIScene_CreateBattleMenu::KeyboardCompleteWorldNameCallback; - kbData.lpParam = this; - ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); - } - else - { - m_bIgnoreInput = false; - m_editWorldName.beginDirectEdit(25); - } -#else - InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD),m_editWorldName.getLabel(),(DWORD)0,25,&UIScene_CreateBattleMenu::KeyboardCompleteWorldNameCallback,this,C_4JInput::EKeyboardMode_Default); -#endif - } - break; - case eControl_GameModeToggle: - switch(m_iGameModeId) - { - case 0: // Creative - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_CREATIVE)); - m_iGameModeId = GameType::CREATIVE->getId(); - m_bGameModeCreative = true; - break; - case 1: // Adventure - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_ADVENTURE)); - m_iGameModeId = GameType::ADVENTURE->getId(); - m_bGameModeCreative = false; - break; - case 2: // Survival - m_buttonGamemode.setLabel(app.GetString(IDS_GAMEMODE_SURVIVAL)); - m_iGameModeId = GameType::SURVIVAL->getId(); - m_bGameModeCreative = false; - }; - break; - case eControl_MoreOptions: - ui.NavigateToScene(m_iPad, eUIScene_LaunchMoreOptionsMenu, &m_MoreOptionsParams); - break; - case eControl_TexturePackList: - { - UpdateCurrentTexturePack((int)childId); - } - break; - case eControl_NewWorld: - { -#ifdef _DURANGO - if(m_MoreOptionsParams.bOnlineGame) - { - m_bIgnoreInput = true; - ProfileManager.CheckMultiplayerPrivileges(m_iPad, true, &checkPrivilegeCallback, this); - } - else -#endif - { - StartSharedLaunchFlow(); - } - break; - } - } -} - -#ifdef _DURANGO -void UIScene_CreateBattleMenu::checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad) -{ - UIScene_CreateBattleMenu* pClass = (UIScene_CreateBattleMenu*)lpParam; - - if(hasPrivilege) - { - pClass->StartSharedLaunchFlow(); - } - else - { - pClass->m_bIgnoreInput = false; - } -} -#endif - -void UIScene_CreateBattleMenu::StartSharedLaunchFlow() -{ - // Stubbed, as Create Battle Menu does not need it. - app.DebugPrintf("StartSharedLaunchFlow disabled\n"); -} - -void UIScene_CreateBattleMenu::handleSliderMove(F64 sliderId, F64 currentValue) -{ - WCHAR TempString[256]; - int value = (int)currentValue; - switch((int)sliderId) - { - case eControl_Difficulty: - m_sliderDifficulty.handleSliderMove(value); - - app.SetGameSettings(m_iPad,eGameSetting_Difficulty,value); - swprintf( (WCHAR *)TempString, 256, L"%ls: %ls", app.GetString( IDS_SLIDER_DIFFICULTY ),app.GetString(m_iDifficultyTitleSettingA[value])); - m_sliderDifficulty.setLabel(TempString); - break; - } -} - -void UIScene_CreateBattleMenu::handleTimerComplete(int id) -{ -#ifdef __PSVITA__ - // we cannot rebuild touch boxes in an iggy callback because it requires further iggy calls - if(m_bRebuildTouchBoxes) - { - GetMainPanel()->UpdateControl(); - ui.TouchBoxRebuild(this); - m_bRebuildTouchBoxes = false; - } -#endif - - switch(id) - { - case GAME_CREATE_ONLINE_TIMER_ID: - { - bool bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad); - - if(bMultiplayerAllowed != m_bMultiplayerAllowed) - { - if( bMultiplayerAllowed ) - { - bool bGameSetting_Online=(app.GetGameSettings(m_iPad,eGameSetting_Online)!=0); - m_MoreOptionsParams.bOnlineGame = bGameSetting_Online?TRUE:FALSE; - if(bGameSetting_Online) - { - m_MoreOptionsParams.bInviteOnly = (app.GetGameSettings(m_iPad,eGameSetting_InviteOnly)!=0)?TRUE:FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = (app.GetGameSettings(m_iPad,eGameSetting_FriendsOfFriends)!=0)?TRUE:FALSE; - } - else - { - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; - } - } - else - { - m_MoreOptionsParams.bOnlineGame = FALSE; - m_MoreOptionsParams.bInviteOnly = FALSE; - m_MoreOptionsParams.bAllowFriendsOfFriends = FALSE; - } - - m_checkboxOnline.SetEnable(bMultiplayerAllowed); - m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); - - m_bMultiplayerAllowed = bMultiplayerAllowed; - } - } - break; - // 4J-PB - Only Xbox will not have trial DLC patched into the game -#ifdef _XBOX - case CHECKFORAVAILABLETEXTUREPACKS_TIMER_ID: - { - // also check for any new texture packs info being available - // for each item in the mem list, check it's in the data list - - CXuiCtrl4JList::LIST_ITEM_INFO ListInfo; - // for each iConfig, check if the data is available, and add it to the List, then remove it from the viConfig - for(int i=0;i 0 && pbData) - { - DWORD dwImageBytes=0; - PBYTE pbImageData=NULL; - - app.GetFileFromTPD(eTPDFileType_Icon,pbData,dwBytes,&pbImageData,&dwImageBytes ); - ListInfo.fEnabled = TRUE; - ListInfo.iData = m_iConfigA[i]; - HRESULT hr=XuiCreateTextureBrushFromMemory(pbImageData,dwImageBytes,&ListInfo.hXuiBrush); - app.DebugPrintf("Adding texturepack %d from TPD\n",m_iConfigA[i]); - - m_pTexturePacksList->AddData(ListInfo); - - m_iConfigA[i]=-1; - } - } - } - } - break; -#endif - }; + // Re-initialize controls after a skin reload + m_buttonOk.init(NULL, 0); + m_buttonCancel.init(NULL, 1); + m_checkOption.init(L"Central Spawn", 2, false); + m_checkPoint.init(L"Online Game", 3, false); + m_mariotomato.init(L"Public Game", 4, false); + m_sliderValue.init(L"Amount", 5, 0, 100, 50); + m_labelTitle.init(L"My Custom Menu"); + m_labelStatus.init(L"Ready"); } void UIScene_CreateBattleMenu::handleGainFocus(bool navBack) { - if(navBack) - { - m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); - } + UIScene::handleGainFocus(navBack); + // Update state when we gain focus } -int UIScene_CreateBattleMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bool bRes) +void UIScene_CreateBattleMenu::updateTooltips() { - UIScene_CreateBattleMenu *pClass=(UIScene_CreateBattleMenu *)lpParam; - pClass->m_bIgnoreInput=false; - // 4J HEG - No reason to set value if keyboard was cancelled - if (bRes) - { - uint16_t pchText[128]; - ZeroMemory(pchText, 128 * sizeof(uint16_t) ); -#ifdef _WINDOWS64 - Win64_GetKeyboardText(pchText, 128); -#else - InputManager.GetText(pchText); -#endif - - if(pchText[0]!=0) - { - pClass->m_editWorldName.setLabel((wchar_t *)pchText); - pClass->m_worldName = (wchar_t *)pchText; - } - - pClass->m_buttonCreateWorld.setEnable( !pClass->m_worldName.empty() ); - } - return 0; + ui.SetTooltips(m_iPad, eToolTipExit); } -void UIScene_CreateBattleMenu::checkStateAndStartGame() +void UIScene_CreateBattleMenu::handleInput(int iPad, int key, bool repeat, + bool pressed, bool released, bool &handled) { - app.DebugPrintf("checkStateAndStartGame disabled\n"); -} + if (!pressed) return; -// Stubbed out, CreateBattleMenu repurposing soon? -void UIScene_CreateBattleMenu::CreateGame(UIScene_CreateBattleMenu* pClass, DWORD dwLocalUsersMask) -{ - app.DebugPrintf("CreateGame disabled\n"); -} - - -int UIScene_CreateBattleMenu::ConfirmCreateReturned(void* pParam, int iPad, C4JStorage::EMessageResult result) -{ - app.DebugPrintf("ConfirmCreateReturned disabled\n"); - return 0; -} - - -#ifdef __ORBIS__ -int UIScene_CreateBattleMenu::MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result) -{ - UIScene_CreateBattleMenu* pClass = (UIScene_CreateBattleMenu *)pParam; - pClass->m_bIgnoreInput = false; - - if(result==C4JStorage::EMessage_ResultAccept) + switch (key) { - SQRNetworkManager_Orbis::AttemptPSNSignIn(&UIScene_CreateBattleMenu::StartGame_SignInReturned, pClass, false, iPad); + case ACTION_MENU_B: + // B button: go back + navigateBack(); + handled = true; + break; + default: + // Let the SWF handle other input (focus navigation, button presses) + sendInputToMovie(key, repeat, pressed, released); + handled = true; + break; } - - return 0; } -// int UIScene_CreateBattleMenu::PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result) -// { -// int32_t iResult; -// UIScene_CreateBattleMenu *pClass = (UIScene_CreateBattleMenu *)pParam; -// -// // continue offline, or upsell PS Plus? -// if(result==C4JStorage::EMessage_ResultDecline) -// { -// // upsell psplus -// int32_t iResult=sceNpCommerceDialogInitialize(); -// -// SceNpCommerceDialogParam param; -// sceNpCommerceDialogParamInitialize(¶m); -// param.mode=SCE_NP_COMMERCE_DIALOG_MODE_PLUS; -// param.features = SCE_NP_PLUS_FEATURE_REALTIME_MULTIPLAY; -// param.userId = ProfileManager.getUserID(pClass->m_iPad); -// -// iResult=sceNpCommerceDialogOpen(¶m); -// } -// else if(result==C4JStorage::EMessage_ResultAccept) -// { -// // continue offline -// pClass->m_MoreOptionsParams.bOnlineGame=false; -// pClass->checkStateAndStartGame(); -// } -// -// pClass->m_bIgnoreInput=false; -// return 0; -// } -#endif - - -void UIScene_CreateBattleMenu::handleTouchBoxRebuild() +void UIScene_CreateBattleMenu::handlePress(F64 controlId, F64 childId) { - m_bRebuildTouchBoxes = true; + int id = (int)controlId; + switch (id) + { + case 0: // OK button + // Do your thing + m_labelStatus.setLabel(L"OK pressed!"); + ui.PlayUISFX(eSFX_Focus); + navigateBack(); + break; + case 1: // Cancel button + navigateBack(); + break; + } } + +void UIScene_CreateBattleMenu::handleCheckboxToggled(F64 controlId, bool selected) +{ + int id = (int)controlId; + if (id == 2) + { + // Feature checkbox was toggled + if (selected) + m_labelStatus.setLabel(L"Feature enabled"); + else + m_labelStatus.setLabel(L"Feature disabled"); + } +} + +void UIScene_CreateBattleMenu::handleSliderMove(F64 sliderId, F64 currentValue) +{ + int id = (int)sliderId; + if (id == 3) + { + int value = (int)currentValue; + m_labelStatus.setLabel(L"Value: " + to_wstring(value)); + } +} \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.h b/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.h index 25c20298..b0a2ae1e 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_CreateBattleMenu.h @@ -1,159 +1,47 @@ - -#pragma once - -#include "IUIScene_StartGame.h" - -class UIScene_CreateBattleMenu : public IUIScene_StartGame -{ -private: - - enum EControls - { - // --- original controls (keep so cpp compiles) --- - eControl_EditWorldName, - eControl_TexturePackList, - eControl_GameModeToggle, - eControl_Difficulty, - eControl_MoreOptions, - eControl_NewWorld, - eControl_OnlineGame, - - // --- new battle controls --- - eControl_CentralSpawn, - eControl_PublicGame, - eControl_FriendsOfFriends, - eControl_InviteOnly, - eControl_SelectMaps, - eControl_RoundLength, - eControl_CreateCasual - }; - - static int m_iDifficultyTitleSettingA[4]; - - // --- original variables (still required by cpp) --- - wstring m_worldName; - wstring m_seed; - - UIControl m_controlMainPanel; - UIControl_Label m_labelWorldName; - - UIControl_Button m_buttonGamemode; - UIControl_Button m_buttonMoreOptions; - UIControl_Button m_buttonCreateWorld; - - UIControl_TextInput m_editWorldName; - UIControl_Slider m_sliderDifficulty; - UIControl_CheckBox m_checkboxOnline; - - UIControl_BitmapIcon m_bitmapIcon; - UIControl_BitmapIcon m_bitmapComparison; - - bool m_bGameModeCreative; - int m_iGameModeId; - bool m_bMultiplayerAllowed; - DLCPack* m_pDLCPack; - bool m_bRebuildTouchBoxes; - - // --- new battle UI controls --- - UIControl_Label m_labelMenuTitle; - - UIControl_CheckBox m_checkboxCentralSpawn; - UIControl_CheckBox m_checkboxPublicGame; - UIControl_CheckBox m_checkboxFriendsOfFriends; - UIControl_CheckBox m_checkboxInviteOnly; - - UIControl_Button m_buttonSelectMaps; - UIControl_Button m_buttonCreateCasual; - - UIControl_Slider m_sliderRoundLength; - - UI_BEGIN_MAP_ELEMENTS_AND_NAMES(IUIScene_StartGame) - - UI_MAP_ELEMENT(m_controlMainPanel, "MainPanel") - - UI_BEGIN_MAP_CHILD_ELEMENTS(m_controlMainPanel) - - UI_MAP_ELEMENT(m_labelMenuTitle, "MenuTitle") - - // original UI bindings - UI_MAP_ELEMENT(m_labelWorldName, "WorldName") - UI_MAP_ELEMENT(m_editWorldName, "EditWorldName") - UI_MAP_ELEMENT(m_texturePackList, "TexturePackSelector") - UI_MAP_ELEMENT(m_buttonGamemode, "GameModeToggle") - UI_MAP_ELEMENT(m_checkboxOnline, "CheckboxOnline") - UI_MAP_ELEMENT(m_buttonMoreOptions, "MoreOptions") - UI_MAP_ELEMENT(m_buttonCreateWorld, "NewWorld") - UI_MAP_ELEMENT(m_sliderDifficulty, "Difficulty") - - // battle menu bindings - UI_MAP_ELEMENT(m_checkboxCentralSpawn, "CheckboxCentralSpawn") - UI_MAP_ELEMENT(m_checkboxPublicGame, "CheckboxPublicGame") - UI_MAP_ELEMENT(m_checkboxFriendsOfFriends, "CheckboxFriendsOfFriends") - UI_MAP_ELEMENT(m_checkboxInviteOnly, "CheckboxInviteOnly") - - UI_MAP_ELEMENT(m_buttonSelectMaps, "SelectMaps") - UI_MAP_ELEMENT(m_sliderRoundLength, "RoundLength") - UI_MAP_ELEMENT(m_buttonCreateCasual, "CreateCasual") - - UI_END_MAP_CHILD_ELEMENTS() - - UI_END_MAP_ELEMENTS_AND_NAMES() - -public: - - UIScene_CreateBattleMenu(int iPad, void* initData, UILayer* parentLayer); - virtual ~UIScene_CreateBattleMenu(); - - virtual void updateTooltips(); - virtual void updateComponents(); - - virtual EUIScene getSceneType() { return eUIScene_CreateWorldMenu; } - - virtual void handleDestroy(); - virtual void tick(); - - virtual UIControl* GetMainPanel(); - virtual void handleTouchBoxRebuild(); - -protected: - - virtual wstring getMoviePath(); - virtual void handleTimerComplete(int id); - virtual void handleGainFocus(bool navBack); - -public: - - virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool& handled); - -#ifdef _WINDOWS64 - virtual void getDirectEditInputs(vector& inputs); - virtual void onDirectEditFinished(UIControl_TextInput* input, UIControl_TextInput::EDirectEditResult result); -#endif - -private: - - void StartSharedLaunchFlow(); - bool IsLocalMultiplayerAvailable(); - -#ifdef _DURANGO - static void checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad); -#endif - -protected: - - static int KeyboardCompleteWorldNameCallback(LPVOID lpParam, const bool bRes); - void handlePress(F64 controlId, F64 childId); - void handleSliderMove(F64 sliderId, F64 currentValue); - - static void CreateGame(UIScene_CreateBattleMenu* pClass, DWORD dwLocalUsersMask); - static int ConfirmCreateReturned(void* pParam, int iPad, C4JStorage::EMessageResult result); - static int StartGame_SignInReturned(void* pParam, bool bContinue, int iPad); - static int MustSignInReturnedPSN(void* pParam, int iPad, C4JStorage::EMessageResult result); - -#ifdef __ORBIS__ - static int ContinueOffline(void* pParam, int iPad, C4JStorage::EMessageResult result); -#endif - - virtual void checkStateAndStartGame(); -}; - +#pragma once +#include "UIScene.h" + +class UIScene_CreateBattleMenu : public UIScene +{ +private: + UIControl_Button m_buttonOk; + UIControl_Button m_buttonCancel; + UIControl_CheckBox m_checkOption; + UIControl_CheckBox m_checkPoint; + UIControl_CheckBox m_mariotomato; + UIControl_Slider m_sliderValue; + UIControl_Label m_labelTitle; + UIControl_Label m_labelStatus; + + // Map Flash elements to C++ variables + UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene) + UI_MAP_ELEMENT(m_buttonOk, "Button1") + UI_MAP_ELEMENT(m_buttonCancel, "Button2") + UI_MAP_ELEMENT(m_checkOption, "CentralSpawn") + UI_MAP_ELEMENT(m_checkPoint, "OnlineGame") + UI_MAP_ELEMENT(m_mariotomato, "PublicGame") + UI_MAP_ELEMENT(m_sliderValue, "Difficulty") + UI_MAP_ELEMENT(m_labelTitle, "LabelTitle") + UI_MAP_ELEMENT(m_labelStatus, "LabelStatus") + UI_END_MAP_ELEMENTS_AND_NAMES() + +public: + UIScene_CreateBattleMenu(int iPad, void *initData, UILayer *parentLayer); + + virtual EUIScene getSceneType() { return eUIScene_CreateBattleMenu; } + +protected: + virtual wstring getMoviePath(); + virtual void handleReload(); + +public: + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, + bool released, bool &handled); + virtual void updateTooltips(); + +protected: + void handlePress(F64 controlId, F64 childId); + void handleCheckboxToggled(F64 controlId, bool selected); + void handleSliderMove(F64 sliderId, F64 currentValue); + void handleGainFocus(bool navBack); +}; \ No newline at end of file