aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/XUI/XUI_Ctrl_MinecraftSkinPreview.h
blob: 22f4991b237efdab8bc29688dbf6005955ac2a73 (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
#pragma once

#include <string>
#include <XuiApp.h>
#include "..\..\Textures.h"
//#include "..\..\Xbox\DLC\DLCSkinFile.h"
#include "..\..\Model.h"

using namespace std;

class EntityRenderer;

//-----------------------------------------------------------------------------
//  CXuiCtrlMinecraftSkinPreview class
//-----------------------------------------------------------------------------
class CXuiCtrlMinecraftSkinPreview : public CXuiControlImpl
{
private:
	static const int LOOK_LEFT_EXTENT = 45;
	static const int LOOK_RIGHT_EXTENT = -45;

	static const int CHANGING_SKIN_FRAMES = 15;

	enum ESkinPreviewAnimations
	{
		e_SkinPreviewAnimation_Walking,
		e_SkinPreviewAnimation_Sneaking,
		e_SkinPreviewAnimation_Attacking,

		e_SkinPreviewAnimation_Count,
	};
public:
	enum ESkinPreviewFacing
	{
		e_SkinPreviewFacing_Forward,
		e_SkinPreviewFacing_Left,
		e_SkinPreviewFacing_Right,
	};
public:
	XUI_IMPLEMENT_CLASS(CXuiCtrlMinecraftSkinPreview, L"CXuiCtrlMinecraftSkinPreview", XUI_CLASS_LABEL)

	CXuiCtrlMinecraftSkinPreview();
	virtual ~CXuiCtrlMinecraftSkinPreview() { };

	void SetTexture(const wstring &url, TEXTURE_NAME backupTexture = TN_MOB_CHAR);
	void SetCapeTexture(const wstring &url) { m_capeTextureUrl = url; }
	void ResetRotation() { m_xRot = 0; m_yRot = 0; }
	void IncrementYRotation() { m_yRot = (m_yRot+4); if(m_yRot >= 180) m_yRot = -180; }
	void DecrementYRotation() { m_yRot = (m_yRot-4); if(m_yRot <= -180) m_yRot = 180; }
	void IncrementXRotation() { m_xRot = (m_xRot+2); if(m_xRot > 22) m_xRot = 22; }
	void DecrementXRotation() { m_xRot = (m_xRot-2); if(m_xRot < -22) m_xRot = -22; }
	void SetAutoRotate(bool autoRotate) { m_bAutoRotate = autoRotate; }
	void SetFacing(ESkinPreviewFacing facing, bool bAnimate = false);

	void CycleNextAnimation();
	void CyclePreviousAnimation();

	bool m_incXRot, m_decXRot;
	bool m_incYRot, m_decYRot;

protected:

	XUI_BEGIN_MSG_MAP()
		XUI_ON_XM_INIT(OnInit)
		XUI_ON_XM_RENDER(OnRender)
	XUI_END_MSG_MAP()

	HRESULT OnInit(XUIMessageInit* pInitData, BOOL& rfHandled);
	HRESULT OnRender(XUIMessageRender *pRenderData, BOOL &rfHandled);

private:
	void render(EntityRenderer *renderer, double x, double y, double z, float rot, float a);
	bool bindTexture(const wstring& urlTexture, int backupTexture);
	bool bindTexture(const wstring& urlTexture, const wstring& backupTexture);

	BOOL m_bDirty;
	float m_fScale,m_fAlpha;

	wstring m_customTextureUrl;
	TEXTURE_NAME m_backupTexture;
	wstring m_capeTextureUrl;
	unsigned int m_uiAnimOverrideBitmask;

	float m_fScreenWidth,m_fScreenHeight;
	float m_fRawWidth,m_fRawHeight;

	int m_yRot,m_xRot;
	
	float m_bobTick;

	float m_walkAnimSpeedO;
	float m_walkAnimSpeed;
	float m_walkAnimPos;

	bool m_bAutoRotate, m_bRotatingLeft;
	BYTE m_rotateTick;
	float m_fTargetRotation, m_fOriginalRotation;
	int m_framesAnimatingRotation;
	bool m_bAnimatingToFacing;

	float m_swingTime;

	ESkinPreviewAnimations m_currentAnimation;
	//vector<Model::SKIN_BOX *> *m_pvAdditionalBoxes;
	vector<ModelPart *> *m_pvAdditionalModelParts;
};