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 "..\..\LocalPlayer.h"
7#include "UIScene_FireworksMenu.h"
8
9UIScene_FireworksMenu::UIScene_FireworksMenu(int iPad, void *_initData, UILayer *parentLayer) : UIScene_AbstractContainerMenu(iPad, parentLayer)
10{
11 // Setup all the Iggy references we need for this scene
12 initialiseMovie();
13
14 FireworksScreenInput *initData = (FireworksScreenInput *)_initData;
15
16 m_labelFireworks.init(app.GetString(IDS_HOW_TO_PLAY_MENU_FIREWORKS));
17
18 Minecraft *pMinecraft = Minecraft::GetInstance();
19 if( pMinecraft->localgameModes[initData->iPad] != NULL )
20 {
21 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad];
22 m_previousTutorialState = gameMode->getTutorial()->getCurrentState();
23 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Fireworks_Menu, this);
24 }
25
26 FireworksMenu* menu = new FireworksMenu( initData->player->inventory, initData->player->level, initData->x, initData->y, initData->z );
27
28 Initialize( initData->iPad, menu, true, FireworksMenu::INV_SLOT_START, eSectionFireworksUsing, eSectionFireworksMax );
29
30 m_slotListResult.addSlots(FireworksMenu::RESULT_SLOT,1);
31 m_slotList3x3.addSlots(FireworksMenu::CRAFT_SLOT_START, 9);
32 ShowLargeCraftingGrid(true);
33
34 delete initData;
35}
36
37wstring UIScene_FireworksMenu::getMoviePath()
38{
39 if(app.GetLocalPlayerCount() > 1)
40 {
41 return L"FireworksMenuSplit";
42 }
43 else
44 {
45 return L"FireworksMenu";
46 }
47}
48
49void UIScene_FireworksMenu::handleReload()
50{
51 Initialize( m_iPad, m_menu, true, FireworksMenu::INV_SLOT_START, eSectionFireworksUsing, eSectionFireworksMax );
52
53 m_slotListResult.addSlots(FireworksMenu::RESULT_SLOT,1);
54 m_slotList3x3.addSlots(FireworksMenu::CRAFT_SLOT_START, 9);
55 ShowLargeCraftingGrid(true);
56}
57
58int UIScene_FireworksMenu::getSectionColumns(ESceneSection eSection)
59{
60 int cols = 0;
61 switch( eSection )
62 {
63 case eSectionFireworksIngredients:
64 cols = 3;
65 break;
66 case eSectionFireworksResult:
67 cols = 1;
68 break;
69 case eSectionFireworksInventory:
70 cols = 9;
71 break;
72 case eSectionFireworksUsing:
73 cols = 9;
74 break;
75 default:
76 assert( false );
77 break;
78 }
79 return cols;
80}
81
82int UIScene_FireworksMenu::getSectionRows(ESceneSection eSection)
83{
84 int rows = 0;
85 switch( eSection )
86 {
87 case eSectionFireworksIngredients:
88 rows = 3;
89 break;
90 case eSectionFireworksResult:
91 rows = 1;
92 break;
93 case eSectionFireworksInventory:
94 rows = 3;
95 break;
96 case eSectionFireworksUsing:
97 rows = 1;
98 break;
99 default:
100 assert( false );
101 break;
102 }
103 return rows;
104}
105
106void UIScene_FireworksMenu::GetPositionOfSection( ESceneSection eSection, UIVec2D* pPosition )
107{
108 switch( eSection )
109 {
110 case eSectionFireworksIngredients:
111 pPosition->x = m_slotList3x3.getXPos();
112 pPosition->y = m_slotList3x3.getYPos();
113 break;
114 case eSectionFireworksResult:
115 pPosition->x = m_slotListResult.getXPos();
116 pPosition->y = m_slotListResult.getYPos();
117 break;
118 case eSectionFireworksInventory:
119 pPosition->x = m_slotListInventory.getXPos();
120 pPosition->y = m_slotListInventory.getYPos();
121 break;
122 case eSectionFireworksUsing:
123 pPosition->x = m_slotListHotbar.getXPos();
124 pPosition->y = m_slotListHotbar.getYPos();
125 break;
126 default:
127 assert( false );
128 break;
129 }
130}
131
132void UIScene_FireworksMenu::GetItemScreenData( ESceneSection eSection, int iItemIndex, UIVec2D* pPosition, UIVec2D* pSize )
133{
134 UIVec2D sectionSize;
135 switch( eSection )
136 {
137 case eSectionFireworksIngredients:
138 sectionSize.x = m_slotList3x3.getWidth();
139 sectionSize.y = m_slotList3x3.getHeight();
140 break;
141 case eSectionFireworksResult:
142 sectionSize.x = m_slotListResult.getWidth();
143 sectionSize.y = m_slotListResult.getHeight();
144 break;
145 case eSectionFireworksInventory:
146 sectionSize.x = m_slotListInventory.getWidth();
147 sectionSize.y = m_slotListInventory.getHeight();
148 break;
149 case eSectionFireworksUsing:
150 sectionSize.x = m_slotListHotbar.getWidth();
151 sectionSize.y = m_slotListHotbar.getHeight();
152 break;
153 default:
154 assert( false );
155 break;
156 }
157
158 int rows = getSectionRows(eSection);
159 int cols = getSectionColumns(eSection);
160
161 pSize->x = sectionSize.x/cols;
162 pSize->y = sectionSize.y/rows;
163
164 int itemCol = iItemIndex % cols;
165 int itemRow = iItemIndex/cols;
166
167 pPosition->x = itemCol * pSize->x;
168 pPosition->y = itemRow * pSize->y;
169}
170
171void UIScene_FireworksMenu::setSectionSelectedSlot(ESceneSection eSection, int x, int y)
172{
173 int cols = getSectionColumns(eSection);
174
175 int index = (y * cols) + x;
176
177 UIControl_SlotList *slotList = NULL;
178 switch( eSection )
179 {
180 case eSectionFireworksIngredients:
181 slotList = &m_slotList3x3;
182 break;
183 case eSectionFireworksResult:
184 slotList = &m_slotListResult;
185 break;
186 case eSectionFireworksInventory:
187 slotList = &m_slotListInventory;
188 break;
189 case eSectionFireworksUsing:
190 slotList = &m_slotListHotbar;
191 break;
192 default:
193 assert( false );
194 break;
195 }
196 slotList->setHighlightSlot(index);
197}
198
199UIControl *UIScene_FireworksMenu::getSection(ESceneSection eSection)
200{
201 UIControl *control = NULL;
202 switch( eSection )
203 {
204 case eSectionFireworksIngredients:
205 control = &m_slotList3x3;
206 break;
207 case eSectionFireworksResult:
208 control = &m_slotListResult;
209 break;
210 case eSectionFireworksInventory:
211 control = &m_slotListInventory;
212 break;
213 case eSectionFireworksUsing:
214 control = &m_slotListHotbar;
215 break;
216 default:
217 assert( false );
218 break;
219 }
220 return control;
221}
222
223// bShow == true removes the 2x2 crafting grid and bShow == false removes the 3x3 crafting grid
224void UIScene_FireworksMenu::ShowLargeCraftingGrid(boolean bShow)
225{
226 app.DebugPrintf("ShowLargeCraftingGrid to %d\n", bShow);
227
228 IggyDataValue result;
229 IggyDataValue value[1];
230 value[0].type = IGGY_DATATYPE_boolean;
231 value[0].boolval = bShow;
232 IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcShowLargeCraftingGrid , 1 , value );
233}