the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2
3#include "..\..\..\Minecraft.World\AbstractContainerMenu.h"
4#include "..\..\..\Minecraft.World\Slot.h"
5#include "..\..\..\Minecraft.World\net.minecraft.world.inventory.h"
6#include "..\..\..\Minecraft.World\net.minecraft.world.level.dimension.h"
7
8//#include "..\..\..\Minecraft.World\net.minecraft.stats.h"
9#include "..\..\MultiplayerLocalPlayer.h"
10#include "..\..\Common\Tutorial\Tutorial.h"
11#include "..\..\Common\Tutorial\TutorialMode.h"
12#include "..\..\Common\Tutorial\TutorialEnum.h"
13#include "..\..\Minecraft.h"
14#include "XUI_Ctrl_SlotList.h"
15
16#include "XUI_Scene_Enchant.h"
17#include "XUI_Scene_Inventory.h"
18#include "XUI_Ctrl_EnchantButton.h"
19
20//--------------------------------------------------------------------------------------
21// Name: CXuiSceneEnchant::OnInit
22// Desc: Message handler for XM_INIT
23//--------------------------------------------------------------------------------------
24HRESULT CXuiSceneEnchant::OnInit( XUIMessageInit *pInitData, BOOL &bHandled )
25{
26 D3DXVECTOR3 vec;
27 MapChildControls();
28
29 XuiControlSetText(m_EnchantText,app.GetString(IDS_ENCHANT));
30
31 Minecraft *pMinecraft = Minecraft::GetInstance();
32
33 EnchantingScreenInput *initData = (EnchantingScreenInput *) pInitData->pvInitData;
34 m_iPad=initData->iPad;
35 m_bSplitscreen=initData->bSplitscreen;
36
37 // if we are in splitscreen, then we need to figure out if we want to move this scene
38
39 if(m_bSplitscreen)
40 {
41 app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad);
42 }
43
44#ifdef _XBOX
45 if( pMinecraft->localgameModes[m_iPad] != NULL )
46 {
47 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
48 m_previousTutorialState = gameMode->getTutorial()->getCurrentState();
49 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Enchanting_Menu, this);
50 }
51#endif
52
53 EnchantmentMenu *menu = new EnchantmentMenu(initData->inventory, initData->level, initData->x, initData->y, initData->z);
54
55 InitDataAssociations(initData->iPad, menu);
56
57 m_enchant1->SetEnable(FALSE);
58 m_enchant2->SetEnable(FALSE);
59 m_enchant3->SetEnable(FALSE);
60 m_enchant1->SetData(m_iPad, 0);
61 m_enchant2->SetData(m_iPad, 1);
62 m_enchant3->SetData(m_iPad, 2);
63
64 CXuiSceneAbstractContainer::Initialize( initData->iPad, menu, false, EnchantmentMenu::INV_SLOT_START, CXuiSceneAbstractContainer::eSectionEnchantUsing, CXuiSceneAbstractContainer::eSectionEnchantMax );
65
66 delete initData;
67
68 return S_OK;
69}
70
71HRESULT CXuiSceneEnchant::OnDestroy()
72{
73 Minecraft *pMinecraft = Minecraft::GetInstance();
74
75#ifdef _XBOX
76 if( pMinecraft->localgameModes[m_iPad] != NULL )
77 {
78 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
79 if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState);
80 }
81#endif
82
83 // 4J Stu - Fix for #11302 - TCR 001: Network Connectivity: Host crashed after being killed by the client while accessing a chest during burst packet loss.
84 // We need to make sure that we call closeContainer() anytime this menu is closed, even if it is forced to close by some other reason (like the player dying)
85 if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer();
86 return S_OK;
87}
88
89CXuiControl* CXuiSceneEnchant::GetSectionControl( ESceneSection eSection )
90{
91 switch( eSection )
92 {
93 case CXuiSceneAbstractContainer::eSectionEnchantInventory:
94 return (CXuiControl *)m_inventoryControl;
95 break;
96 case CXuiSceneAbstractContainer::eSectionEnchantUsing:
97 return (CXuiControl *)m_useRowControl;
98 break;
99 case CXuiSceneAbstractContainer::eSectionEnchantSlot:
100 return (CXuiControl *)m_ingredientControl;
101 break;
102 case eSectionEnchantButton1:
103 return m_enchant1;
104 break;
105 case eSectionEnchantButton2:
106 return m_enchant2;
107 break;
108 case eSectionEnchantButton3:
109 return m_enchant3;
110 break;
111 default:
112 assert( false );
113 break;
114 }
115 return NULL;
116}
117
118CXuiCtrlSlotList* CXuiSceneEnchant::GetSectionSlotList( ESceneSection eSection )
119{
120 switch( eSection )
121 {
122 case CXuiSceneAbstractContainer::eSectionEnchantInventory:
123 return m_inventoryControl;
124 break;
125 case CXuiSceneAbstractContainer::eSectionEnchantUsing:
126 return m_useRowControl;
127 break;
128 case CXuiSceneAbstractContainer::eSectionEnchantSlot:
129 return m_ingredientControl;
130 break;
131 default:
132 assert( false );
133 break;
134 }
135 return NULL;
136}
137
138// 4J Stu - Added to support auto-save. Need to re-associate on a navigate back
139void CXuiSceneEnchant::InitDataAssociations(int iPad, AbstractContainerMenu *menu, int startIndex /*= 0*/)
140{
141 m_ingredientControl->SetData( iPad, menu, 1, 1, EnchantmentMenu::INGREDIENT_SLOT );
142
143 CXuiSceneAbstractContainer::InitDataAssociations(iPad, menu, EnchantmentMenu::INV_SLOT_START);
144}