aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/XUI/XUI_Ctrl_CraftIngredientSlot.cpp
blob: 46bcc9831cc81a6c5ee40aaf840163e647b29638 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include "stdafx.h"

#include "XUI_Ctrl_CraftIngredientSlot.h"
#include "..\..\..\Minecraft.World\net.minecraft.world.item.h"

//-----------------------------------------------------------------------------
//  CXuiCtrlMinecraftSlot class
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
CXuiCtrlCraftIngredientSlot::CXuiCtrlCraftIngredientSlot() 
{
	m_iID=0;
	m_Desc=nullptr;
	m_isFoil = false;
	m_isDirty = false;
	m_item = nullptr;
}



//-----------------------------------------------------------------------------
HRESULT CXuiCtrlCraftIngredientSlot::OnInit(XUIMessageInit* pInitData, BOOL& rfHandled)
{
	HRESULT hr=S_OK;
	
	return hr;
}
//-----------------------------------------------------------------------------
HRESULT CXuiCtrlCraftIngredientSlot::OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled)
{
	if( m_iID != 0 || m_item != nullptr )
	{
		pData->item = m_item;
		pData->iItemBitField = MAKE_SLOTDISPLAY_ITEM_BITMASK(m_iID,m_iAuxVal,m_isFoil);
		pData->iDataBitField = MAKE_SLOTDISPLAY_DATA_BITMASK(m_iPad, m_uiAlpha,m_bDecorations,m_iCount,m_iScale,0);
	}
	else
	{
		pData->iDataBitField = 0;
		pData->szPath = L"";
	}
	pData->bDirty = m_isDirty ? TRUE : FALSE;
	m_isDirty = false;

	bHandled = TRUE;
	return S_OK;
}

HRESULT CXuiCtrlCraftIngredientSlot::OnGetSourceText(XUIMessageGetSourceText *pGetSourceTextData,BOOL& bHandled)
{	
	pGetSourceTextData->szText=m_Desc;
	bHandled = TRUE;
	
	return S_OK;
}

void CXuiCtrlCraftIngredientSlot::SetRedBox(BOOL bVal)
{
	HRESULT hr=S_OK;

	HXUIOBJ hObj,hObjChild;
	hr=GetVisual(&hObj);
	XuiElementGetChildById(hObj,L"BoxRed",&hObjChild);
	XuiElementSetShow(hObjChild,bVal);
	XuiElementGetChildById(hObj,L"Exclaim",&hObjChild);
	XuiElementSetShow(hObjChild,bVal);
}

void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, int iId,int iAuxVal, int iCount, int iScale, unsigned int uiAlpha,bool bDecorations,bool isFoil, BOOL bShow)
{
	m_item = nullptr;
	m_iID=iId;
	m_iAuxVal=iAuxVal;
	
	// 4J Stu - For clocks and compasses we set the aux value to a special one that signals we should use a default texture
	// rather than the dynamic one for the player
	// not right... auxvals for diggables are damage values, can be a lot higher
	if( (m_iAuxVal & 0xFF) == 0xFF && !( iId == Item::clock_Id || iId == Item::compass_Id ) ) // 4J Stu - If the aux value is set to match any
		m_iAuxVal = 0;

	// if the count comes in as 0, make it 1
	m_iCount=iCount==0?1:iCount;
	m_iScale=iScale;
	m_uiAlpha=uiAlpha;
	m_bDecorations=bDecorations;
	m_isFoil = isFoil;

	m_iPad = iPad;
	m_isDirty = true;

	XuiElementSetShow(m_hObj,bShow);
}

void CXuiCtrlCraftIngredientSlot::SetIcon(int iPad, shared_ptr<ItemInstance> item, int iScale, unsigned int uiAlpha,bool bDecorations, BOOL bShow)
{
	if(item == nullptr) SetIcon(iPad, 0,0,0,0,0,false,false,bShow);
	else
	{
		m_item = item;
		m_iID = item->id;
		m_iScale = iScale;
		m_uiAlpha = uiAlpha;
		m_bDecorations = bDecorations;

		m_iPad = iPad;
		m_isDirty = true;

		XuiElementSetShow(m_hObj,bShow);
	}
}

void CXuiCtrlCraftIngredientSlot::SetDescription(LPCWSTR Desc)
{
	HRESULT hr=S_OK;

	HXUIOBJ hObj,hObjChild;
	hr=GetVisual(&hObj);
	XuiElementGetChildById(hObj,L"text_name",&hObjChild);
	XuiControlSetText(hObjChild,Desc);
	XuiElementSetShow(hObjChild,Desc==nullptr?FALSE:TRUE);
	m_Desc=Desc;
}