the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "UI.h"
3#include "..\..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h"
4#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
5#include "..\..\Minecraft.h"
6#include "UIScene_HopperMenu.h"
7
8UIScene_HopperMenu::UIScene_HopperMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene_AbstractContainerMenu(iPad, parentLayer)
9{
10 // Setup all the Iggy references we need for this scene
11 initialiseMovie();
12
13 HopperScreenInput *initData = (HopperScreenInput *)_initData;
14
15 m_labelDispenser.init(initData->hopper->getName());
16
17 Minecraft *pMinecraft = Minecraft::GetInstance();
18 if( pMinecraft->localgameModes[initData->iPad] != NULL )
19 {
20 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad];
21 m_previousTutorialState = gameMode->getTutorial()->getCurrentState();
22 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Hopper_Menu, this);
23 }
24
25 HopperMenu* menu = new HopperMenu( initData->inventory, initData->hopper );
26
27 m_containerSize = initData->hopper->getContainerSize();
28 Initialize( initData->iPad, menu, true, m_containerSize, eSectionHopperUsing, eSectionHopperMax );
29
30 m_slotListTrap.addSlots(0, 9);
31
32 delete initData;
33}
34
35wstring UIScene_HopperMenu::getMoviePath()
36{
37 if(app.GetLocalPlayerCount() > 1)
38 {
39 return L"HopperMenuSplit";
40 }
41 else
42 {
43 return L"HopperMenu";
44 }
45}
46
47void UIScene_HopperMenu::handleReload()
48{
49 Initialize( m_iPad, m_menu, true, m_containerSize, eSectionHopperUsing, eSectionHopperMax );
50
51 m_slotListTrap.addSlots(0, 9);
52}
53
54int UIScene_HopperMenu::getSectionColumns(ESceneSection eSection)
55{
56 int cols = 0;
57 switch( eSection )
58 {
59 case eSectionHopperContents:
60 cols = 5;
61 break;
62 case eSectionHopperInventory:
63 cols = 9;
64 break;
65 case eSectionHopperUsing:
66 cols = 9;
67 break;
68 default:
69 assert( false );
70 break;
71 }
72 return cols;
73}
74
75int UIScene_HopperMenu::getSectionRows(ESceneSection eSection)
76{
77 int rows = 0;
78 switch( eSection )
79 {
80 case eSectionHopperContents:
81 rows = 1;
82 break;
83 case eSectionHopperInventory:
84 rows = 3;
85 break;
86 case eSectionHopperUsing:
87 rows = 1;
88 break;
89 default:
90 assert( false );
91 break;
92 }
93 return rows;
94}
95
96void UIScene_HopperMenu::GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition )
97{
98 switch( eSection )
99 {
100 case eSectionHopperContents:
101 pPosition->x = m_slotListTrap.getXPos();
102 pPosition->y = m_slotListTrap.getYPos();
103 break;
104 case eSectionHopperInventory:
105 pPosition->x = m_slotListInventory.getXPos();
106 pPosition->y = m_slotListInventory.getYPos();
107 break;
108 case eSectionHopperUsing:
109 pPosition->x = m_slotListHotbar.getXPos();
110 pPosition->y = m_slotListHotbar.getYPos();
111 break;
112 default:
113 assert( false );
114 break;
115 }
116}
117
118void UIScene_HopperMenu::GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize )
119{
120 UIVec2D sectionSize;
121 switch( eSection )
122 {
123 case eSectionHopperContents:
124 sectionSize.x = m_slotListTrap.getWidth();
125 sectionSize.y = m_slotListTrap.getHeight();
126 break;
127 case eSectionHopperInventory:
128 sectionSize.x = m_slotListInventory.getWidth();
129 sectionSize.y = m_slotListInventory.getHeight();
130 break;
131 case eSectionHopperUsing:
132 sectionSize.x = m_slotListHotbar.getWidth();
133 sectionSize.y = m_slotListHotbar.getHeight();
134 break;
135 default:
136 assert( false );
137 break;
138 }
139
140 int rows = getSectionRows(eSection);
141 int cols = getSectionColumns(eSection);
142
143 pSize->x = sectionSize.x/cols;
144 pSize->y = sectionSize.y/rows;
145
146 int itemCol = iItemIndex % cols;
147 int itemRow = iItemIndex/cols;
148
149 pPosition->x = itemCol * pSize->x;
150 pPosition->y = itemRow * pSize->y;
151}
152
153void UIScene_HopperMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int y)
154{
155 int cols = getSectionColumns(eSection);
156
157 int index = (y * cols) + x;
158
159 UIControl_SlotList *slotList = NULL;
160 switch( eSection )
161 {
162 case eSectionHopperContents:
163 slotList = &m_slotListTrap;
164 break;
165 case eSectionHopperInventory:
166 slotList = &m_slotListInventory;
167 break;
168 case eSectionHopperUsing:
169 slotList = &m_slotListHotbar;
170 break;
171 default:
172 assert( false );
173 break;
174 }
175 slotList->setHighlightSlot(index);
176}
177
178UIControl *UIScene_HopperMenu::getSection(ESceneSection eSection)
179{
180 UIControl *control = NULL;
181 switch( eSection )
182 {
183 case eSectionHopperContents:
184 control = &m_slotListTrap;
185 break;
186 case eSectionHopperInventory:
187 control = &m_slotListInventory;
188 break;
189 case eSectionHopperUsing:
190 control = &m_slotListHotbar;
191 break;
192 default:
193 assert( false );
194 break;
195 }
196 return control;
197}