aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/XUI/XUI_Ctrl_SlotItemCtrlBase.h
blob: 2fd217494bd308eae1f47a4a1b33ce51317a687c (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
#pragma once
using namespace std;

class Slot;
class ItemInstance;

#include "XUI_CustomMessages.h"

class SlotControlUserDataContainer
{
public:
	SlotControlUserDataContainer() : slot( NULL ), hProgressBar( NULL ), m_iPad( -1 ), m_fAlpha(1.0f) {};
	Slot* slot;
	HXUIOBJ hProgressBar;
	float m_fAlpha;
	int m_iPad;
};

// The base class for all controls with the "ItemButton" visual
// This could be a list item or just a button.
// We need this class to be able to easily access all the parts of the visual

class CXuiCtrlSlotItemCtrlBase
{
private:
	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	BOOL	m_bSkipDefaultNavigation;

public:
	// We define a lot of functions as virtual. These should be implemented to call the protected version by
	// passing in the HXUIOBJ of the control as the first parameter. We do not have access to that normally
	// due to the inheritance structure	
	virtual HRESULT OnInit( XUIMessageInit* pInitData, BOOL& bHandled ) = 0;
	
	virtual HRESULT OnDestroy() = 0;

	virtual HRESULT OnCustomMessage_GetSlotItem(CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled) = 0;

	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	virtual HRESULT OnControlNavigate(XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled) = 0;

	virtual HRESULT OnKeyDown(XUIMessageInput *pInputData, BOOL& bHandled) = 0;

	void SetSlot( HXUIOBJ hObj, Slot* slot );
	void SetAlpha( HXUIOBJ hObj, float fAlpha );
	void SetUserIndex( HXUIOBJ hObj, int iPad );

	bool isEmpty( HXUIOBJ hObj );

	wstring GetItemDescription( HXUIOBJ hObj, vector<wstring> &unformattedStrings );

	shared_ptr<ItemInstance> getItemInstance( HXUIOBJ hObj );
	Slot *getSlot( HXUIOBJ hObj );

	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	int	 GetObjectCount( HXUIOBJ hObj );

	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	void	SetSkipsDefaultNavigation( BOOL bSkipDefaultNavigation )			{ m_bSkipDefaultNavigation = bSkipDefaultNavigation; }

	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	int		GetEmptyStackSpace( HXUIOBJ hObj );		// Returns number of items that can still be stacked into this slot.

	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	bool	IsSameItemAs( HXUIOBJ hThisObj, HXUIOBJ hOtherObj );

protected:	
	HRESULT OnInit( HXUIOBJ hObj, XUIMessageInit* pInitData, BOOL& bHandled );
	
	HRESULT OnDestroy( HXUIOBJ hObj );

	HRESULT OnCustomMessage_GetSlotItem(HXUIOBJ hObj, CustomMessage_GetSlotItem_Struct *pData, BOOL& bHandled);

	// 4J WESTY : Pointer Prototype : Added to support prototype only.
	HRESULT OnControlNavigate(HXUIOBJ hObj, XUIMessageControlNavigate *pControlNavigateData, BOOL& bHandled);

	HRESULT OnKeyDown(HXUIOBJ hObj, XUIMessageInput *pInputData, BOOL& bHandled);
};