Something went wrong. Try again.
the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
Something went wrong. Try again.
15 kB · 519 lines
C++
at main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519#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; };}