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 "XUI_Ctrl_CraftIngredientSlot.h"
4#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"
5
6//-----------------------------------------------------------------------------
7// CXuiCtrlMinecraftSlot class
8//-----------------------------------------------------------------------------
9
10//-----------------------------------------------------------------------------
11CXuiCtrlCraftIngredientSlot::CXuiCtrlCraftIngredientSlot()
12{
13 m_iID=0;
14 m_Desc=NULL;
15 m_isFoil = false;
16 m_isDirty = false;
17 m_item = nullptr;
18}
19
20
21
22//-----------------------------------------------------------------------------
23HRESULT CXuiCtrlCraftIngredientSlot::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
24{
25 HRESULT hr=S_OK;
26
27 return hr;
28}
29//-----------------------------------------------------------------------------
30HRESULT CXuiCtrlCraftIngredientSlot::OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled)
31{
32 if( m_iID != 0 || m_item != NULL )
33 {
34 pData->item = m_item;
35 pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(m_iID,m_iAuxVal,m_isFoil);
36 pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(m_iPad, m_uiAlpha,m_bDecorations,m_iCount,m_iScale,0);
37 }
38 else
39 {
40 pData->iDataBitField = 0;
41 pData->szPath = L"";
42 }
43 pData->bDirty = m_isDirty ? TRUE : FALSE;
44 m_isDirty = false;
45
46 bHandled = TRUE;
47 return S_OK;
48}
49
50HRESULT CXuiCtrlCraftIngredientSlot::OnGetSourceText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
51{
52 pGetSourceTextData->szText=m_Desc;
53 bHandled = TRUE;
54
55 return S_OK;
56}
57
58void CXuiCtrlCraftIngredientSlot::SetRedBox(BOOL bVal)
59{
60 HRESULT hr=S_OK;
61
62 HXUIOBJ hObj,hObjChild;
63 hr=GetVisual(&hObj);
64 XuiElementGetChildById(hObj,L"BoxRed",&hObjChild);
65 XuiElementSetShow(hObjChild,bVal);
66 XuiElementGetChildById(hObj,L"Exclaim",&hObjChild);
67 XuiElementSetShow(hObjChild,bVal);
68}
69
70void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool isFoil, BOOL bShow)
71{
72 m_item = nullptr;
73 m_iID=iId;
74 m_iAuxVal=iAuxVal;
75
76 // 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture
77 // rather than the dynamic one for the player
78 // not right... auxvals for diggables are damage values, can be a lot higher
79 if( (m_iAuxVal & 0xFF) == 0xFF && !( iId == Item::clock_Id || iId == Item::compass_Id ) ) // 4J Stu - If the aux value is set to match any
80 m_iAuxVal = 0;
81
82 // if the count comes in as 0, make it 1
83 m_iCount=iCount==0?1:iCount;
84 m_iScale=iScale;
85 m_uiAlpha=uiAlpha;
86 m_bDecorations=bDecorations;
87 m_isFoil = isFoil;
88
89 m_iPad = iPad;
90 m_isDirty = true;
91
92 XuiElementSetShow(m_hObj,bShow);
93}
94
95void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, shared_ptr<ItemInstance> item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow)
96{
97 if(item == NULL) SetIcon(iPad, 0,0,0,0,0,false,false,bShow);
98 else
99 {
100 m_item = item;
101 m_iID = item->id;
102 m_iScale = iScale;
103 m_uiAlpha = uiAlpha;
104 m_bDecorations = bDecorations;
105
106 m_iPad = iPad;
107 m_isDirty = true;
108
109 XuiElementSetShow(m_hObj,bShow);
110 }
111}
112
113void CXuiCtrlCraftIngredientSlot::SetDescription(LPCWSTR Desc)
114{
115 HRESULT hr=S_OK;
116
117 HXUIOBJ hObj,hObjChild;
118 hr=GetVisual(&hObj);
119 XuiElementGetChildById(hObj,L"text_name",&hObjChild);
120 XuiControlSetText(hObjChild,Desc);
121 XuiElementSetShow(hObjChild,Desc==NULL?FALSE:TRUE);
122 m_Desc=Desc;
123}