blob: 76c0058dd6e0ff4588a81ab699b4f776561b8da3 (
plain) (
blame)
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef BASEMODELPANEL_H
#define BASEMODELPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui/IScheme.h>
#include <vgui_controls/ImagePanel.h>
#include <vgui_controls/EditablePanel.h>
#include "GameEventListener.h"
#include "KeyValues.h"
class C_SceneEntity;
class CModelPanelModel : public C_BaseFlex
{
public:
CModelPanelModel(){}
DECLARE_CLASS( CModelPanelModel, C_BaseFlex );
virtual bool IsMenuModel() const{ return true; }
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CModelPanelModelAnimation
{
public:
CModelPanelModelAnimation()
{
m_pszName = NULL;
m_pszSequence = NULL;
m_pszActivity = NULL;
m_pPoseParameters = NULL;
m_bDefault = false;
}
~CModelPanelModelAnimation()
{
if ( m_pszName && m_pszName[0] )
{
delete [] m_pszName;
m_pszName = NULL;
}
if ( m_pszSequence && m_pszSequence[0] )
{
delete [] m_pszSequence;
m_pszSequence = NULL;
}
if ( m_pszActivity && m_pszActivity[0] )
{
delete [] m_pszActivity;
m_pszActivity = NULL;
}
if ( m_pPoseParameters )
{
m_pPoseParameters->deleteThis();
m_pPoseParameters = NULL;
}
}
public:
const char *m_pszName;
const char *m_pszSequence;
const char *m_pszActivity;
KeyValues *m_pPoseParameters;
bool m_bDefault;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CModelPanelAttachedModelInfo
{
public:
CModelPanelAttachedModelInfo()
{
m_pszModelName = NULL;
m_nSkin = 0;
}
~CModelPanelAttachedModelInfo()
{
if ( m_pszModelName && m_pszModelName[0] )
{
delete [] m_pszModelName;
m_pszModelName = NULL;
}
}
public:
const char *m_pszModelName;
int m_nSkin;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CModelPanelModelInfo
{
public:
CModelPanelModelInfo()
{
m_pszModelName = NULL;
m_pszModelName_HWM = NULL;
m_nSkin = -1;
m_vecAbsAngles.Init();
m_vecOriginOffset.Init();
m_vecFramedOriginOffset.Init();
m_bUseSpotlight = false;
}
~CModelPanelModelInfo()
{
if ( m_pszModelName && m_pszModelName[0] )
{
delete [] m_pszModelName;
m_pszModelName = NULL;
}
if ( m_pszModelName_HWM && m_pszModelName_HWM[0] )
{
delete [] m_pszModelName_HWM;
m_pszModelName_HWM = NULL;
}
if ( m_pszVCD && m_pszVCD[0] )
{
delete [] m_pszVCD;
m_pszVCD = NULL;
}
m_Animations.PurgeAndDeleteElements();
m_AttachedModelsInfo.PurgeAndDeleteElements();
}
public:
const char *m_pszModelName;
const char *m_pszModelName_HWM;
int m_nSkin;
const char *m_pszVCD;
Vector m_vecAbsAngles;
Vector m_vecOriginOffset;
Vector2D m_vecViewportOffset;
Vector m_vecFramedOriginOffset;
bool m_bUseSpotlight;
CUtlVector<CModelPanelModelAnimation*> m_Animations;
CUtlVector<CModelPanelAttachedModelInfo*> m_AttachedModelsInfo;
};
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CModelPanel : public vgui::EditablePanel, public CGameEventListener
{
public:
DECLARE_CLASS_SIMPLE( CModelPanel, vgui::EditablePanel );
CModelPanel( vgui::Panel *parent, const char *name );
virtual ~CModelPanel();
virtual void Paint();
virtual void ApplySettings( KeyValues *inResourceData );
virtual void DeleteVCDData( void );
virtual void DeleteModelData( void );
virtual void SetFOV( int nFOV ){ m_nFOV = nFOV; }
virtual void SetPanelDirty( void ){ m_bPanelDirty = true; }
virtual bool SetSequence( const char *pszSequence );
MESSAGE_FUNC_PARAMS( OnAddAnimation, "AddAnimation", data );
MESSAGE_FUNC_PARAMS( OnSetAnimation, "SetAnimation", data );
void SetDefaultAnimation( const char *pszName );
void SwapModel( const char *pszName, const char *pszAttached = NULL );
virtual void ParseModelInfo( KeyValues *inResourceData );
void ClearAttachedModelInfos( void );
void CalculateFrameDistance( void );
void ZoomToFrameDistance( void );
void UpdateModel();
public: // IGameEventListener:
virtual void FireGameEvent( IGameEvent * event );
protected:
virtual void SetupModel( void );
virtual void SetupVCD( void );
virtual const char *GetModelName( void );
private:
void InitCubeMaps();
int FindAnimByName( const char *pszName );
void CalculateFrameDistanceInternal( const model_t *pModel );
public:
int m_nFOV;
float m_flFrameDistance;
bool m_bStartFramed;
CModelPanelModelInfo *m_pModelInfo;
CHandle<CModelPanelModel> m_hModel;
CUtlVector<CHandle<C_BaseAnimating> > m_AttachedModels;
CHandle<C_SceneEntity> m_hScene;
private:
bool m_bPanelDirty;
int m_iDefaultAnimation;
bool m_bAllowOffscreen;
CTextureReference m_DefaultEnvCubemap;
CTextureReference m_DefaultHDREnvCubemap;
};
#endif // BASEMODELPANEL_H
|