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_FurnaceMenu.h"
7
8UIScene_FurnaceMenu::UIScene_FurnaceMenu(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 FurnaceScreenInput *initData = (FurnaceScreenInput *)_initData;
14 m_furnace = initData->furnace;
15
16 m_labelFurnace.init(m_furnace->getName());
17 m_labelIngredient.init(app.GetString(IDS_INGREDIENT));
18 m_labelFuel.init(app.GetString(IDS_FUEL));
19
20 m_progressFurnaceFire.init(L"",0,0,12,0);
21 m_progressFurnaceArrow.init(L"",0,0,24,0);
22
23 Minecraft *pMinecraft = Minecraft::GetInstance();
24 if( pMinecraft->localgameModes[initData->iPad] != NULL )
25 {
26 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad];
27 m_previousTutorialState = gameMode->getTutorial()->getCurrentState();
28 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Furnace_Menu, this);
29 }
30
31 FurnaceMenu* menu = new FurnaceMenu( initData->inventory, initData->furnace );
32
33 Initialize( initData->iPad, menu, true, FurnaceMenu::INV_SLOT_START, eSectionFurnaceUsing, eSectionFurnaceMax );
34
35 m_slotListFuel.addSlots(FurnaceMenu::FUEL_SLOT, 1);
36 m_slotListIngredient.addSlots(FurnaceMenu::INGREDIENT_SLOT, 1);
37 m_slotListResult.addSlots(FurnaceMenu::RESULT_SLOT, 1);
38
39 app.SetRichPresenceContext(m_iPad,CONTEXT_GAME_STATE_FORGING);
40
41 delete initData;
42}
43
44wstring UIScene_FurnaceMenu::getMoviePath()
45{
46 if(app.GetLocalPlayerCount() > 1)
47 {
48 return L"FurnaceMenuSplit";
49 }
50 else
51 {
52 return L"FurnaceMenu";
53 }
54}
55
56void UIScene_FurnaceMenu::handleReload()
57{
58 Initialize( m_iPad, m_menu, true, FurnaceMenu::INV_SLOT_START, eSectionFurnaceUsing, eSectionFurnaceMax );
59
60 m_slotListFuel.addSlots(FurnaceMenu::FUEL_SLOT, 1);
61 m_slotListIngredient.addSlots(FurnaceMenu::INGREDIENT_SLOT, 1);
62 m_slotListResult.addSlots(FurnaceMenu::RESULT_SLOT, 1);
63}
64
65void UIScene_FurnaceMenu::tick()
66{
67 m_progressFurnaceFire.setProgress( m_furnace->getLitProgress( 12 ) );
68 m_progressFurnaceArrow.setProgress( m_furnace->getBurnProgress( 24 ) );
69 UIScene_AbstractContainerMenu::tick();
70}
71
72int UIScene_FurnaceMenu::getSectionColumns(ESceneSection eSection)
73{
74 int cols = 0;
75 switch( eSection )
76 {
77 case eSectionFurnaceResult:
78 cols = 1;
79 break;
80 case eSectionFurnaceFuel:
81 cols = 1;
82 break;
83 case eSectionFurnaceIngredient:
84 cols = 1;
85 break;
86 case eSectionFurnaceInventory:
87 cols = 9;
88 break;
89 case eSectionFurnaceUsing:
90 cols = 9;
91 break;
92 default:
93 assert( false );
94 break;
95 }
96 return cols;
97}
98
99int UIScene_FurnaceMenu::getSectionRows(ESceneSection eSection)
100{
101 int rows = 0;
102 switch( eSection )
103 {
104 case eSectionFurnaceResult:
105 rows = 1;
106 break;
107 case eSectionFurnaceFuel:
108 rows = 1;
109 break;
110 case eSectionFurnaceIngredient:
111 rows = 1;
112 break;
113 case eSectionFurnaceInventory:
114 rows = 3;
115 break;
116 case eSectionFurnaceUsing:
117 rows = 1;
118 break;
119 default:
120 assert( false );
121 break;
122 }
123 return rows;
124}
125
126void UIScene_FurnaceMenu::GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition )
127{
128 switch( eSection )
129 {
130 case eSectionFurnaceResult:
131 pPosition->x = m_slotListResult.getXPos();
132 pPosition->y = m_slotListResult.getYPos();
133 break;
134 case eSectionFurnaceFuel:
135 pPosition->x = m_slotListFuel.getXPos();
136 pPosition->y = m_slotListFuel.getYPos();
137 break;
138 case eSectionFurnaceIngredient:
139 pPosition->x = m_slotListIngredient.getXPos();
140 pPosition->y = m_slotListIngredient.getYPos();
141 break;
142 case eSectionFurnaceInventory:
143 pPosition->x = m_slotListInventory.getXPos();
144 pPosition->y = m_slotListInventory.getYPos();
145 break;
146 case eSectionFurnaceUsing:
147 pPosition->x = m_slotListHotbar.getXPos();
148 pPosition->y = m_slotListHotbar.getYPos();
149 break;
150 default:
151 assert( false );
152 break;
153 }
154}
155
156void UIScene_FurnaceMenu::GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize )
157{
158 UIVec2D sectionSize;
159 switch( eSection )
160 {
161 case eSectionFurnaceResult:
162 sectionSize.x = m_slotListResult.getWidth();
163 sectionSize.y = m_slotListResult.getHeight();
164 break;
165 case eSectionFurnaceFuel:
166 sectionSize.x = m_slotListFuel.getWidth();
167 sectionSize.y = m_slotListFuel.getHeight();
168 break;
169 case eSectionFurnaceIngredient:
170 sectionSize.x = m_slotListIngredient.getWidth();
171 sectionSize.y = m_slotListIngredient.getHeight();
172 break;
173 case eSectionFurnaceInventory:
174 sectionSize.x = m_slotListInventory.getWidth();
175 sectionSize.y = m_slotListInventory.getHeight();
176 break;
177 case eSectionFurnaceUsing:
178 sectionSize.x = m_slotListHotbar.getWidth();
179 sectionSize.y = m_slotListHotbar.getHeight();
180 break;
181 default:
182 assert( false );
183 break;
184 }
185
186 int rows = getSectionRows(eSection);
187 int cols = getSectionColumns(eSection);
188
189 pSize->x = sectionSize.x/cols;
190 pSize->y = sectionSize.y/rows;
191
192 int itemCol = iItemIndex % cols;
193 int itemRow = iItemIndex/cols;
194
195 pPosition->x = itemCol * pSize->x;
196 pPosition->y = itemRow * pSize->y;
197}
198
199void UIScene_FurnaceMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int y)
200{
201 int cols = getSectionColumns(eSection);
202
203 int index = (y * cols) + x;
204
205 UIControl_SlotList *slotList = NULL;
206 switch( eSection )
207 {
208 case eSectionFurnaceResult:
209 slotList = &m_slotListResult;
210 break;
211 case eSectionFurnaceFuel:
212 slotList = &m_slotListFuel;
213 break;
214 case eSectionFurnaceIngredient:
215 slotList = &m_slotListIngredient;
216 break;
217 case eSectionFurnaceInventory:
218 slotList = &m_slotListInventory;
219 break;
220 case eSectionFurnaceUsing:
221 slotList = &m_slotListHotbar;
222 break;
223 default:
224 assert( false );
225 break;
226 }
227
228 slotList->setHighlightSlot(index);
229}
230
231UIControl *UIScene_FurnaceMenu::getSection(ESceneSection eSection)
232{
233 UIControl *control = NULL;
234 switch( eSection )
235 {
236 case eSectionFurnaceResult:
237 control = &m_slotListResult;
238 break;
239 case eSectionFurnaceFuel:
240 control = &m_slotListFuel;
241 break;
242 case eSectionFurnaceIngredient:
243 control = &m_slotListIngredient;
244 break;
245 case eSectionFurnaceInventory:
246 control = &m_slotListInventory;
247 break;
248 case eSectionFurnaceUsing:
249 control = &m_slotListHotbar;
250 break;
251 default:
252 assert( false );
253 break;
254 }
255 return control;
256}