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\DispenserTileEntity.h"
4#include "..\..\..\Minecraft.World\TrapMenu.h"
5#include "..\..\MultiplayerLocalPlayer.h"
6#include "XUI_Ctrl_SlotList.h"
7#include "XUI_Scene_Trap.h"
8#include "..\..\Common\Tutorial\Tutorial.h"
9#include "..\..\Common\Tutorial\TutorialMode.h"
10#include "..\..\Common\Tutorial\TutorialEnum.h"
11
12//--------------------------------------------------------------------------------------
13// Name: CXuiSceneTrap::OnInit
14// Desc: Message handler for XM_INIT
15//--------------------------------------------------------------------------------------
16HRESULT CXuiSceneTrap::OnInit( XUIMessageInit* pInitData, BOOL& bHandled )
17{
18 D3DXVECTOR3 vec;
19 MapChildControls();
20
21 XuiControlSetText(m_DispenserText,app.GetString(IDS_DISPENSER));
22
23 Minecraft *pMinecraft = Minecraft::GetInstance();
24
25 TrapScreenInput* initData = (TrapScreenInput*)pInitData->pvInitData;
26 m_iPad=initData->iPad;
27 m_bSplitscreen=initData->bSplitscreen;
28
29#ifdef _XBOX
30 if( pMinecraft->localgameModes[initData->iPad] != NULL )
31 {
32 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[initData->iPad];
33 m_previousTutorialState = gameMode->getTutorial()->getCurrentState();
34 gameMode->getTutorial()->changeTutorialState(e_Tutorial_State_Trap_Menu, this);
35 }
36#endif
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 TrapMenu* menu = new TrapMenu( initData->inventory, initData->trap );
45
46 InitDataAssociations(initData->iPad, menu);
47
48 CXuiSceneAbstractContainer::Initialize( initData->iPad, menu, true, initData->trap->getContainerSize(), eSectionTrapUsing, eSectionTrapMax );
49
50 delete initData;
51
52 return S_OK;
53}
54
55HRESULT CXuiSceneTrap::OnDestroy()
56{
57 Minecraft *pMinecraft = Minecraft::GetInstance();
58
59#ifdef _XBOX
60 if( pMinecraft->localgameModes[m_iPad] != NULL )
61 {
62 TutorialMode *gameMode = (TutorialMode *)pMinecraft->localgameModes[m_iPad];
63 if(gameMode != NULL) gameMode->getTutorial()->changeTutorialState(m_previousTutorialState);
64 }
65#endif
66
67 // 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.
68 // 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)
69 if(Minecraft::GetInstance()->localplayers[m_iPad] != NULL) Minecraft::GetInstance()->localplayers[m_iPad]->closeContainer();
70 return S_OK;
71}
72
73CXuiControl* CXuiSceneTrap::GetSectionControl( ESceneSection eSection )
74{
75 switch( eSection )
76 {
77 case eSectionTrapTrap:
78 return (CXuiControl *)m_trapControl;
79 break;
80 case eSectionTrapInventory:
81 return (CXuiControl *)m_inventoryControl;
82 break;
83 case eSectionTrapUsing:
84 return (CXuiControl *)m_useRowControl;
85 break;
86 default:
87 assert( false );
88 break;
89 }
90 return NULL;
91}
92
93CXuiCtrlSlotList* CXuiSceneTrap::GetSectionSlotList( ESceneSection eSection )
94{
95 switch( eSection )
96 {
97 case eSectionTrapTrap:
98 return m_trapControl;
99 break;
100 case eSectionTrapInventory:
101 return m_inventoryControl;
102 break;
103 case eSectionTrapUsing:
104 return m_useRowControl;
105 break;
106 default:
107 assert( false );
108 break;
109 }
110 return NULL;
111}
112
113// 4J Stu - Added to support auto-save. Need to re-associate on a navigate back
114void CXuiSceneTrap::InitDataAssociations(int iPad, AbstractContainerMenu *menu, int startIndex /*= 0*/)
115{
116 int containerSize = menu->getSize() - (27 + 9);
117
118 // TODO Inventory dimensions need defined as constants
119 m_trapControl->SetData( iPad, menu, 3, 3, 0 );
120
121 CXuiSceneAbstractContainer::InitDataAssociations(iPad, menu, containerSize);
122}