diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp | 519 |
1 files changed, 519 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp new file mode 100644 index 00000000..e70397d6 --- /dev/null +++ b/Minecraft.Client/Common/UI/UIScene_BeaconMenu.cpp @@ -0,0 +1,519 @@ +#include "stdafx.h" +#include "UI.h" +#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h" +#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h" +#include "..\..\Minecraft.h" +#include "UIScene_BeaconMenu.h" + +UIScene_BeaconMenu::UIScene_BeaconMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene_AbstractContainerMenu(iPad, parentLayer) +{ + // Setup all the Iggy references we need for this scene + initialiseMovie(); + + m_labelPrimary.init(IDS_CONTAINER_BEACON_PRIMARY_POWER); + m_labelSecondary.init(IDS_CONTAINER_BEACON_SECONDARY_POWER); + + m_buttonsPowers[eControl_Primary1].setVisible(false); + m_buttonsPowers[eControl_Primary2].setVisible(false); + m_buttonsPowers[eControl_Primary3].setVisible(false); + m_buttonsPowers[eControl_Primary4].setVisible(false); + m_buttonsPowers[eControl_Primary5].setVisible(false); + m_buttonsPowers[eControl_Secondary1].setVisible(false); + m_buttonsPowers[eControl_Secondary2].setVisible(false); + + BeaconScreenInput *initData = (BeaconScreenInput *)_initData; + + Minecraft *pMinecraft = Minecraft::GetInstance(); + if( pMinecraft->localgameModes[initData->iPad] != NULL ) + { + TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad]; + m_previousTutorialState = gameMode->getTutorial()->getCurrentState(); + gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Beacon_Menu, this); + } + + m_beacon = initData->beacon; + + BeaconMenu *menu = new BeaconMenu(initData->inventory, initData->beacon); + + Initialize( initData->iPad, menu, true, BeaconMenu::INV_SLOT_START, eSectionBeaconUsing, eSectionBeaconMax ); + + m_slotListActivator.addSlots(BeaconMenu::PAYMENT_SLOT, 1); + + m_slotListActivatorIcons.addSlots(m_menu->getSize(),4); + + //app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_BEACON); + + delete initData; +} + +wstring UIScene_BeaconMenu::getMoviePath() +{ + if(app.GetLocalPlayerCount() > 1) + { + return L"BeaconMenuSplit"; + } + else + { + return L"BeaconMenu"; + } +} + +void UIScene_BeaconMenu::handleReload() +{ + Initialize( m_iPad, m_menu, true, BeaconMenu::INV_SLOT_START, eSectionBeaconUsing, eSectionBeaconMax ); + + m_slotListActivator.addSlots(BeaconMenu::PAYMENT_SLOT, 1); + + m_slotListActivatorIcons.addSlots(m_menu->getSize(),4); +} + +void UIScene_BeaconMenu::tick() +{ + UIScene_AbstractContainerMenu::tick(); + + handleTick(); +} + +int UIScene_BeaconMenu::getSectionColumns(ESceneSection eSection) +{ + int cols = 0; + switch( eSection ) + { + case eSectionBeaconItem: + cols = 1; + break; + case eSectionBeaconInventory: + cols = 9; + break; + case eSectionBeaconUsing: + cols = 9; + break; + default: + assert( false ); + break; + }; + return cols; +} + +int UIScene_BeaconMenu::getSectionRows(ESceneSection eSection) +{ + int rows = 0; + switch( eSection ) + { + case eSectionBeaconItem: + rows = 1; + break; + case eSectionBeaconInventory: + rows = 3; + break; + case eSectionBeaconUsing: + rows = 1; + break; + default: + assert( false ); + break; + }; + return rows; +} + +void UIScene_BeaconMenu::GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition ) +{ + switch( eSection ) + { + case eSectionBeaconItem: + pPosition->x = m_slotListActivator.getXPos(); + pPosition->y = m_slotListActivator.getYPos(); + break; + case eSectionBeaconInventory: + pPosition->x = m_slotListInventory.getXPos(); + pPosition->y = m_slotListInventory.getYPos(); + break; + case eSectionBeaconUsing: + pPosition->x = m_slotListHotbar.getXPos(); + pPosition->y = m_slotListHotbar.getYPos(); + break; + + case eSectionBeaconPrimaryTierOneOne: + pPosition->x = m_buttonsPowers[eControl_Primary1].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary1].getYPos(); + break; + case eSectionBeaconPrimaryTierOneTwo: + pPosition->x = m_buttonsPowers[eControl_Primary2].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary2].getYPos(); + break; + case eSectionBeaconPrimaryTierTwoOne: + pPosition->x = m_buttonsPowers[eControl_Primary3].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary3].getYPos(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + pPosition->x = m_buttonsPowers[eControl_Primary4].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary4].getYPos(); + break; + case eSectionBeaconPrimaryTierThree: + pPosition->x = m_buttonsPowers[eControl_Primary5].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Primary5].getYPos(); + break; + case eSectionBeaconSecondaryOne: + pPosition->x = m_buttonsPowers[eControl_Secondary1].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Secondary1].getYPos(); + break; + case eSectionBeaconSecondaryTwo: + pPosition->x = m_buttonsPowers[eControl_Secondary2].getXPos(); + pPosition->y = m_buttonsPowers[eControl_Secondary2].getYPos(); + break; + case eSectionBeaconConfirm: + pPosition->x = m_buttonConfirm.getXPos(); + pPosition->y = m_buttonConfirm.getYPos(); + break; + default: + assert( false ); + break; + }; +} + +void UIScene_BeaconMenu::GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize ) +{ + UIVec2D sectionSize; + switch( eSection ) + { + case eSectionBeaconItem: + sectionSize.x = m_slotListActivator.getWidth(); + sectionSize.y = m_slotListActivator.getHeight(); + break; + case eSectionBeaconInventory: + sectionSize.x = m_slotListInventory.getWidth(); + sectionSize.y = m_slotListInventory.getHeight(); + break; + case eSectionBeaconUsing: + sectionSize.x = m_slotListHotbar.getWidth(); + sectionSize.y = m_slotListHotbar.getHeight(); + break; + + case eSectionBeaconPrimaryTierOneOne: + sectionSize.x = m_buttonsPowers[eControl_Primary1].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary1].getHeight(); + break; + case eSectionBeaconPrimaryTierOneTwo: + sectionSize.x = m_buttonsPowers[eControl_Primary2].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary2].getHeight(); + break; + case eSectionBeaconPrimaryTierTwoOne: + sectionSize.x = m_buttonsPowers[eControl_Primary3].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary3].getHeight(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + sectionSize.x = m_buttonsPowers[eControl_Primary4].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary4].getHeight(); + break; + case eSectionBeaconPrimaryTierThree: + sectionSize.x = m_buttonsPowers[eControl_Primary5].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Primary5].getHeight(); + break; + case eSectionBeaconSecondaryOne: + sectionSize.x = m_buttonsPowers[eControl_Secondary1].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Secondary1].getHeight(); + break; + case eSectionBeaconSecondaryTwo: + sectionSize.x = m_buttonsPowers[eControl_Secondary2].getWidth(); + sectionSize.y = m_buttonsPowers[eControl_Secondary2].getHeight(); + break; + case eSectionBeaconConfirm: + sectionSize.x = m_buttonConfirm.getWidth(); + sectionSize.y = m_buttonConfirm.getHeight(); + break; + default: + assert( false ); + break; + }; + + if(IsSectionSlotList(eSection)) + { + int rows = getSectionRows(eSection); + int cols = getSectionColumns(eSection); + + pSize->x = sectionSize.x/cols; + pSize->y = sectionSize.y/rows; + + int itemCol = iItemIndex % cols; + int itemRow = iItemIndex/cols; + + pPosition->x = itemCol * pSize->x; + pPosition->y = itemRow * pSize->y; + } + else + { + GetPositionOfSection(eSection, pPosition); + pSize->x = sectionSize.x; + pSize->y = sectionSize.y; + } +} + +void UIScene_BeaconMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int y) +{ + int cols = getSectionColumns(eSection); + + int index = (y * cols) + x; + + UIControl_SlotList *slotList = NULL; + switch( eSection ) + { + case eSectionBeaconItem: + slotList = &m_slotListActivator; + break; + case eSectionBeaconInventory: + slotList = &m_slotListInventory; + break; + case eSectionBeaconUsing: + slotList = &m_slotListHotbar; + break; + default: + assert( false ); + break; + }; + + slotList->setHighlightSlot(index); +} + +UIControl *UIScene_BeaconMenu::getSection(ESceneSection eSection) +{ + UIControl *control = NULL; + switch( eSection ) + { + case eSectionBeaconItem: + control = &m_slotListActivator; + break; + case eSectionBeaconInventory: + control = &m_slotListInventory; + break; + case eSectionBeaconUsing: + control = &m_slotListHotbar; + break; + + case eSectionBeaconPrimaryTierOneOne: + control = &m_buttonsPowers[eControl_Primary1]; + break; + case eSectionBeaconPrimaryTierOneTwo: + control = &m_buttonsPowers[eControl_Primary2]; + break; + case eSectionBeaconPrimaryTierTwoOne: + control = &m_buttonsPowers[eControl_Primary3]; + break; + case eSectionBeaconPrimaryTierTwoTwo: + control = &m_buttonsPowers[eControl_Primary4]; + break; + case eSectionBeaconPrimaryTierThree: + control = &m_buttonsPowers[eControl_Primary5]; + break; + case eSectionBeaconSecondaryOne: + control = &m_buttonsPowers[eControl_Secondary1]; + break; + case eSectionBeaconSecondaryTwo: + control = &m_buttonsPowers[eControl_Secondary2]; + break; + case eSectionBeaconConfirm: + control = &m_buttonConfirm; + break; + + default: + assert( false ); + break; + }; + return control; +} + +void UIScene_BeaconMenu::customDraw(IggyCustomDrawCallbackRegion *region) +{ + Minecraft *pMinecraft = Minecraft::GetInstance(); + if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return; + + shared_ptr<ItemInstance> item = nullptr; + int slotId = -1; + swscanf((wchar_t*)region->name,L"slot_%d",&slotId); + + if(slotId >= 0 && slotId >= m_menu->getSize() ) + { + int icon = slotId - m_menu->getSize(); + switch(icon) + { + case 0: + item = shared_ptr<ItemInstance>(new ItemInstance(Item::emerald) ); + break; + case 1: + item = shared_ptr<ItemInstance>(new ItemInstance(Item::diamond) ); + break; + case 2: + item = shared_ptr<ItemInstance>(new ItemInstance(Item::goldIngot) ); + break; + case 3: + item = shared_ptr<ItemInstance>(new ItemInstance(Item::ironIngot) ); + break; + default: + assert(false); + break; + }; + if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,item->isFoil(),true); + } + else + { + UIScene_AbstractContainerMenu::customDraw(region); + } +} + +void UIScene_BeaconMenu::SetConfirmButtonEnabled(bool enabled) +{ + m_buttonConfirm.SetButtonActive(enabled); +} + +void UIScene_BeaconMenu::AddPowerButton(int id, int icon, int tier, int count, bool active, bool selected) +{ + switch(tier) + { + case 0: + if(count == 0) + { + m_buttonsPowers[eControl_Primary1].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Primary1].setVisible(true); + } + else + { + m_buttonsPowers[eControl_Primary2].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Primary2].setVisible(true); + } + break; + case 1: + if(count == 0) + { + m_buttonsPowers[eControl_Primary3].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Primary3].setVisible(true); + } + else + { + m_buttonsPowers[eControl_Primary4].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Primary4].setVisible(true); + } + break; + case 2: + m_buttonsPowers[eControl_Primary5].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Primary5].setVisible(true); + break; + case 3: + if(count == 0) + { + m_buttonsPowers[eControl_Secondary1].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Secondary1].setVisible(true); + } + else + { + m_buttonsPowers[eControl_Secondary2].SetData(id, icon,active,selected); + m_buttonsPowers[eControl_Secondary2].setVisible(true); + } + break; + }; +} + +int UIScene_BeaconMenu::GetPowerButtonId(ESceneSection eSection) +{ + switch(eSection) + { + case eSectionBeaconPrimaryTierOneOne: + return m_buttonsPowers[eControl_Primary1].GetData(); + break; + case eSectionBeaconPrimaryTierOneTwo: + return m_buttonsPowers[eControl_Primary2].GetData(); + break; + case eSectionBeaconPrimaryTierTwoOne: + return m_buttonsPowers[eControl_Primary3].GetData(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + return m_buttonsPowers[eControl_Primary4].GetData(); + break; + case eSectionBeaconPrimaryTierThree: + return m_buttonsPowers[eControl_Primary5].GetData(); + break; + case eSectionBeaconSecondaryOne: + return m_buttonsPowers[eControl_Secondary1].GetData(); + break; + case eSectionBeaconSecondaryTwo: + return m_buttonsPowers[eControl_Secondary2].GetData(); + break; + }; + return 0; +} + +bool UIScene_BeaconMenu::IsPowerButtonSelected(ESceneSection eSection) +{ + switch(eSection) + { + case eSectionBeaconPrimaryTierOneOne: + return m_buttonsPowers[eControl_Primary1].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierOneTwo: + return m_buttonsPowers[eControl_Primary2].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierTwoOne: + return m_buttonsPowers[eControl_Primary3].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierTwoTwo: + return m_buttonsPowers[eControl_Primary4].IsButtonSelected(); + break; + case eSectionBeaconPrimaryTierThree: + return m_buttonsPowers[eControl_Primary5].IsButtonSelected(); + break; + case eSectionBeaconSecondaryOne: + return m_buttonsPowers[eControl_Secondary1].IsButtonSelected(); + break; + case eSectionBeaconSecondaryTwo: + return m_buttonsPowers[eControl_Secondary2].IsButtonSelected(); + break; + }; + return false; +} + +void UIScene_BeaconMenu::SetPowerButtonSelected(ESceneSection eSection) +{ + switch(eSection) + { + case eSectionBeaconPrimaryTierOneOne: + case eSectionBeaconPrimaryTierOneTwo: + case eSectionBeaconPrimaryTierTwoOne: + case eSectionBeaconPrimaryTierTwoTwo: + case eSectionBeaconPrimaryTierThree: + m_buttonsPowers[eControl_Primary1].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary2].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary3].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary4].SetButtonSelected(false); + m_buttonsPowers[eControl_Primary5].SetButtonSelected(false); + break; + case eSectionBeaconSecondaryOne: + case eSectionBeaconSecondaryTwo: + m_buttonsPowers[eControl_Secondary1].SetButtonSelected(false); + m_buttonsPowers[eControl_Secondary2].SetButtonSelected(false); + break; + }; + + + switch(eSection) + { + case eSectionBeaconPrimaryTierOneOne: + return m_buttonsPowers[eControl_Primary1].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierOneTwo: + return m_buttonsPowers[eControl_Primary2].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierTwoOne: + return m_buttonsPowers[eControl_Primary3].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierTwoTwo: + return m_buttonsPowers[eControl_Primary4].SetButtonSelected(true); + break; + case eSectionBeaconPrimaryTierThree: + return m_buttonsPowers[eControl_Primary5].SetButtonSelected(true); + break; + case eSectionBeaconSecondaryOne: + return m_buttonsPowers[eControl_Secondary1].SetButtonSelected(true); + break; + case eSectionBeaconSecondaryTwo: + return m_buttonsPowers[eControl_Secondary2].SetButtonSelected(true); + break; + }; +}
\ No newline at end of file |
