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 "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
3#include "..\..\Minecraft.h"
4#include "..\..\MultiplayerLocalPlayer.h"
5#include "IUIScene_EnchantingMenu.h"
6
7IUIScene_AbstractContainerMenu::ESceneSection IUIScene_EnchantingMenu::GetSectionAndSlotInDirection( IUIScene_AbstractContainerMenu::ESceneSection eSection, ETapState eTapDirection, int *piTargetX, int *piTargetY )
8{
9 IUIScene_AbstractContainerMenu::ESceneSection newSection = eSection;
10 int xOffset = 0;
11
12 // Find the new section if there is one
13 switch( eSection )
14 {
15 case eSectionEnchantInventory:
16 if(eTapDirection == eTapStateDown)
17 {
18 newSection = eSectionEnchantUsing;
19 }
20 else if(eTapDirection == eTapStateUp)
21 {
22 if( *piTargetX >= ENCHANT_SCENE_ENCHANT_BUTTONS_UP_OFFSET)
23 {
24 newSection = eSectionEnchantButton3;
25 }
26 else
27 {
28 newSection = eSectionEnchantSlot;
29 }
30 }
31 break;
32 case eSectionEnchantUsing:
33 if(eTapDirection == eTapStateDown)
34 {
35 if( *piTargetX >= ENCHANT_SCENE_ENCHANT_BUTTONS_UP_OFFSET)
36 {
37 newSection = eSectionEnchantButton1;
38 }
39 else
40 {
41 newSection = eSectionEnchantSlot;
42 }
43 }
44 else if(eTapDirection == eTapStateUp)
45 {
46 newSection = eSectionEnchantInventory;
47 }
48 break;
49 case eSectionEnchantSlot:
50 if(eTapDirection == eTapStateDown)
51 {
52 newSection = eSectionEnchantInventory;
53 xOffset = ENCHANT_SCENE_INGREDIENT_SLOT_DOWN_OFFSET;
54 }
55 else if(eTapDirection == eTapStateUp)
56 {
57 newSection = eSectionEnchantUsing;
58 xOffset = ENCHANT_SCENE_INGREDIENT_SLOT_DOWN_OFFSET;
59 }
60 else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
61 {
62 newSection = eSectionEnchantButton1;
63 }
64 break;
65 case eSectionEnchantButton1:
66 if(eTapDirection == eTapStateDown)
67 {
68 newSection = eSectionEnchantButton2;
69 }
70 else if(eTapDirection == eTapStateUp)
71 {
72 newSection = eSectionEnchantUsing;
73 xOffset = ENCHANT_SCENE_ENCHANT_BUTTONS_DOWN_OFFSET;
74 }
75 else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
76 {
77 newSection = eSectionEnchantSlot;
78 }
79 break;
80 case eSectionEnchantButton2:
81 if(eTapDirection == eTapStateDown)
82 {
83 newSection = eSectionEnchantButton3;
84 }
85 else if(eTapDirection == eTapStateUp)
86 {
87 newSection = eSectionEnchantButton1;
88 }
89 else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
90 {
91 newSection = eSectionEnchantSlot;
92 }
93 break;
94 case eSectionEnchantButton3:
95 if(eTapDirection == eTapStateDown)
96 {
97 newSection = eSectionEnchantInventory;
98 xOffset = ENCHANT_SCENE_ENCHANT_BUTTONS_DOWN_OFFSET;
99 }
100 else if(eTapDirection == eTapStateUp)
101 {
102 newSection = eSectionEnchantButton2;
103 }
104 else if(eTapDirection == eTapStateLeft || eTapDirection == eTapStateRight)
105 {
106 newSection = eSectionEnchantSlot;
107 }
108 break;
109 default:
110 assert( false );
111 break;
112 }
113
114 updateSlotPosition(eSection, newSection, eTapDirection, piTargetX, piTargetY, xOffset);
115
116 return newSection;
117}
118
119void IUIScene_EnchantingMenu::handleOtherClicked(int iPad, ESceneSection eSection, int buttonNum, bool quickKey)
120{
121 int index = -1;
122 // Old xui code
123#if 0
124 HXUIOBJ hFocusObject = GetFocus(iPad);
125 if(hFocusObject == m_enchant1->m_hObj) index = 0;
126 else if(hFocusObject == m_enchant2->m_hObj) index = 1;
127 else if(hFocusObject == m_enchant3->m_hObj) index = 2;
128#endif
129
130 switch(eSection)
131 {
132 case eSectionEnchantButton1:
133 index = 0;
134 break;
135 case eSectionEnchantButton2:
136 index = 1;
137 break;
138 case eSectionEnchantButton3:
139 index = 2;
140 break;
141 };
142 Minecraft *pMinecraft = Minecraft::GetInstance();
143 if (index >= 0 && m_menu->clickMenuButton(dynamic_pointer_cast<Player>(pMinecraft->localplayers[iPad]), index))
144 {
145 pMinecraft->localgameModes[iPad]->handleInventoryButtonClick(m_menu->containerId, index);
146 }
147}
148
149int IUIScene_EnchantingMenu::getSectionStartOffset(ESceneSection eSection)
150{
151 int offset = 0;
152 switch( eSection )
153 {
154 case eSectionEnchantSlot:
155 offset = 0;
156 break;
157 case eSectionEnchantInventory:
158 offset = 1;
159 break;
160 case eSectionEnchantUsing:
161 offset = 1 + 27;
162 break;
163 default:
164 assert( false );
165 break;
166 };
167 return offset;
168}
169
170bool IUIScene_EnchantingMenu::IsSectionSlotList( ESceneSection eSection )
171{
172 switch( eSection )
173 {
174 case eSectionEnchantInventory:
175 case eSectionEnchantUsing:
176 case eSectionEnchantSlot:
177 return true;
178 }
179 return false;
180}
181
182EnchantmentMenu *IUIScene_EnchantingMenu::getMenu()
183{
184 return (EnchantmentMenu *)m_menu;
185}