From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp | 232 ++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp (limited to 'Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp') diff --git a/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp b/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp new file mode 100644 index 00000000..14046f20 --- /dev/null +++ b/Minecraft.Client/Common/XUI/XUI_HowToPlayMenu.cpp @@ -0,0 +1,232 @@ +#include "stdafx.h" + +#include +#include "..\XUI\XUI_HowToPlayMenu.h" +#include "..\XUI\XUI_HelpHowToPlay.h" + +// strings for buttons in the list +unsigned int CScene_HowToPlayMenu::m_uiHTPButtonNameA[]= +{ + IDS_HOW_TO_PLAY_MENU_WHATSNEW, // eHTPButton_WhatsNew + IDS_HOW_TO_PLAY_MENU_BASICS, // eHTPButton_Basics, + IDS_HOW_TO_PLAY_MENU_MULTIPLAYER, // eHTPButton_Multiplayer + IDS_HOW_TO_PLAY_MENU_HUD, // eHTPButton_Hud, + IDS_HOW_TO_PLAY_MENU_CREATIVE, // eHTPButton_Creative, + IDS_HOW_TO_PLAY_MENU_INVENTORY, // eHTPButton_Inventory, + IDS_HOW_TO_PLAY_MENU_CHESTS, // eHTPButton_Chest, + IDS_HOW_TO_PLAY_MENU_CRAFTING, // eHTPButton_Crafting, + IDS_HOW_TO_PLAY_MENU_FURNACE, // eHTPButton_Furnace, + IDS_HOW_TO_PLAY_MENU_DISPENSER, // eHTPButton_Dispenser, + + IDS_HOW_TO_PLAY_MENU_BREWING, // eHTPButton_Brewing, + IDS_HOW_TO_PLAY_MENU_ENCHANTMENT, // eHTPButton_Enchantment, + IDS_HOW_TO_PLAY_MENU_ANVIL, + IDS_HOW_TO_PLAY_MENU_FARMANIMALS, // eHTPButton_Breeding, + IDS_HOW_TO_PLAY_MENU_BREEDANIMALS, // eHTPButton_Breeding, + IDS_HOW_TO_PLAY_MENU_TRADING, + + IDS_HOW_TO_PLAY_MENU_NETHERPORTAL, // eHTPButton_NetherPortal, + IDS_HOW_TO_PLAY_MENU_THEEND, // eHTPButton_TheEnd, + IDS_HOW_TO_PLAY_MENU_SOCIALMEDIA, // eHTPButton_SocialMedia, + IDS_HOW_TO_PLAY_MENU_BANLIST, // eHTPButton_BanningLevels, + IDS_HOW_TO_PLAY_MENU_HOSTOPTIONS, // eHTPButton_HostOptions, +}; + +// mapping the buttons to a scene value +unsigned int CScene_HowToPlayMenu::m_uiHTPSceneA[]= +{ + eHowToPlay_WhatsNew, + eHowToPlay_Basics, + eHowToPlay_Multiplayer, + eHowToPlay_HUD, + eHowToPlay_Creative, + eHowToPlay_Inventory, + eHowToPlay_Chest, + eHowToPlay_InventoryCrafting, + eHowToPlay_Furnace, + eHowToPlay_Dispenser, + + eHowToPlay_Brewing, + eHowToPlay_Enchantment, + eHowToPlay_Anvil, + eHowToPlay_FarmingAnimals, + eHowToPlay_Breeding, + eHowToPlay_Trading, + + eHowToPlay_NetherPortal, + eHowToPlay_TheEnd, + eHowToPlay_SocialMedia, + eHowToPlay_BanList, + eHowToPlay_HostOptions, +}; + +//---------------------------------------------------------------------------------- +// Performs initialization tasks - retrieves controls. +//---------------------------------------------------------------------------------- +HRESULT CScene_HowToPlayMenu::OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) +{ + m_iPad = *(int *)pInitData->pvInitData; + // if we're not in the game, we need to use basescene 0 + bool bNotInGame=(Minecraft::GetInstance()->level==NULL); + bool bSplitscreen= app.GetLocalPlayerCount()>1; + m_ButtonList=NULL; + + //MapChildControls(); + + //m_iButtons=0; + if(bSplitscreen) + { + app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad, false); + } + + // 4J-PB - changing all versions to use a list of buttons, since we're adding some + // We're going to use a list of buttons here + CXuiElement e = m_hObj; + HRESULT hr = e.GetChildById(L"HowToListButtons", &m_ButtonList); + m_iButtons=eHTPButton_Max; + for(int i=0;ibItemData ) + { + if( pGetSourceTextData->iItem < (int)eHTPButton_Max ) + { + pGetSourceTextData->szText = app.GetString(m_uiHTPButtonNameA[pGetSourceTextData->iItem]);//m_Buttons[pGetSourceTextData->iItem].GetText(); + pGetSourceTextData->bDisplay = TRUE; + + bHandled = TRUE; + } + } + return S_OK; +} + +HRESULT CScene_HowToPlayMenu::OnGetItemCountAll(XUIMessageGetItemCount *pGetItemCountData, BOOL& bHandled) +{ + pGetItemCountData->cItems = m_iButtons; + bHandled = TRUE; + return S_OK; +} + + +HRESULT CScene_HowToPlayMenu::OnNotifySelChanged(HXUIOBJ hObjSource, XUINotifySelChanged *pNotifySelChangedData, BOOL& bHandled) +{ + // In a list, we need to play the 'focus' sound ourselves + if((pNotifySelChangedData->iOldItem!=-1) && m_ButtonList && (hObjSource==m_ButtonList.m_hObj)) + { + CXuiSceneBase::PlayUISFX(eSFX_Focus); + } + + return S_OK; +} +//---------------------------------------------------------------------------------- +// Handler for the button press message. +//---------------------------------------------------------------------------------- +HRESULT CScene_HowToPlayMenu::OnNotifyPressEx(HXUIOBJ hObjPressed, XUINotifyPress* pNotifyPressData, BOOL& rfHandled) +{ + // This assumes all buttons can only be pressed with the A button + ui.AnimateKeyPress(pNotifyPressData->UserIndex, VK_PAD_A); + unsigned int uiInitData; + unsigned int uiButtonCounter=0; + + // 4J-PB - now using a list for all resolutions + //if((!RenderManager.IsHiDef() && !RenderManager.IsWidescreen()) || app.GetLocalPlayerCount()>1) + { + if(hObjPressed==m_ButtonList && m_ButtonList.TreeHasFocus() && (m_ButtonList.GetItemCount() > 0) && (m_ButtonList.GetCurSel() < (int)eHTPButton_Max) ) + { + uiButtonCounter=m_ButtonList.GetCurSel(); + } + } + /*else + { + while((uiButtonCounter1) + { + app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlay, ( void* )( uiInitData ) ); + } + else + { + app.NavigateToScene(pNotifyPressData->UserIndex,eUIScene_HowToPlay, ( void* )( uiInitData ) ); + } + + rfHandled=TRUE; + return S_OK; +} + +HRESULT CScene_HowToPlayMenu::OnKeyDown(XUIMessageInput* pInputData, BOOL& rfHandled) +{ + ui.AnimateKeyPress(pInputData->UserIndex, pInputData->dwKeyCode); + + switch(pInputData->dwKeyCode) + { + + case VK_PAD_B: + case VK_ESCAPE: + app.NavigateBack(pInputData->UserIndex); + rfHandled = TRUE; + + break; + } + + return S_OK; +} + +HRESULT CScene_HowToPlayMenu::OnNavReturn(HXUIOBJ hObj,BOOL& rfHandled) +{ + ui.SetTooltips( m_iPad, IDS_TOOLTIPS_SELECT,IDS_TOOLTIPS_BACK); + + return S_OK; +} + +HRESULT CScene_HowToPlayMenu::OnCustomMessage_Splitscreenplayer(bool bJoining, BOOL& bHandled) +{ + bHandled=true; + return app.AdjustSplitscreenScene_PlayerChanged(m_hObj,&m_OriginalPosition,m_iPad,bJoining,false); +} -- cgit v1.2.3