-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAcStatDialog.cpp
350 lines (280 loc) · 9.88 KB
/
AcStatDialog.cpp
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
/*************************************************************************************************\
*
* Filename: AcStatDialog.cpp
* Purpose: Implement CAcStatDialog class
* Version: 1.0
* Author: Gavin Clayton
*
* Last Updated: 29/08/2002
*
* Copyright 2002. Gavin Clayton. All Rights Reserved.
*
* If changes are made by you to this code, please log them below:
*
*
\*************************************************************************************************/
#include "stdafx.h"
#include "Daggerfall Explorer.h"
#include "AcStatDialog.h"
// CAcStatDialog dialog
IMPLEMENT_DYNAMIC(CAcStatDialog, CDialog)
CAcStatDialog::CAcStatDialog(CWnd* pParent /*=NULL*/)
: CDialog(CAcStatDialog::IDD, pParent)
{
m_pAlchemy = NULL;
}
CAcStatDialog::~CAcStatDialog()
{
m_pAlchemy = NULL;
}
void CAcStatDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_ACSTAT_TAB, m_ctrlAcStatTab);
DDX_Control(pDX, IDC_ACSTAT_LIST, m_ctrlAcStatList);
}
void CAcStatDialog::SetAlchemy( TAlchemy *pAlchemy )
{
// Validate
_ASSERT( pAlchemy );
m_pAlchemy = pAlchemy;
}
void CAcStatDialog::BuildList( int nTab )
{
// Clear all current information
m_ctrlAcStatList.DeleteAllItems();
// Clear all current columns
int nColumnCount = m_ctrlAcStatList.GetHeaderCtrl()->GetItemCount();
for (int i=0; i < nColumnCount; i++) {
m_ctrlAcStatList.DeleteColumn( 0 );
}
// Add category information
CString str;
int iItem = 0;
UINT nRes = NULL;
ACSTAT_TEXTURE acTexture;
ACSTAT_MESH acMesh;
switch ( nTab )
{
case STATTAB_GENERAL:
// Add columns
m_ctrlAcStatList.InsertColumn( STATCOL_GENERAL_ITEM, "Item", LVCFMT_LEFT, 145 );
m_ctrlAcStatList.InsertColumn( STATCOL_GENERAL_VALUE, "Value", LVCFMT_LEFT, 150 );
// Add property names
m_ctrlAcStatList.InsertItem( iItem++, "Build Number" );
m_ctrlAcStatList.InsertItem( iItem++, "Engine Status" );
m_ctrlAcStatList.InsertItem( iItem++, "Vertex Pipeline" );
m_ctrlAcStatList.InsertItem( iItem++, "Engine Time" );
m_ctrlAcStatList.InsertItem( iItem++, "Time Integrator" );
m_ctrlAcStatList.InsertItem( iItem++, "Average FPS" );
m_ctrlAcStatList.InsertItem( iItem++, "Texture Count" );
m_ctrlAcStatList.InsertItem( iItem++, "Mesh Count" );
m_ctrlAcStatList.InsertItem( iItem++, "Object Count" );
m_ctrlAcStatList.InsertItem( iItem++, "Sprite Count" );
m_ctrlAcStatList.InsertItem( iItem++, "Font Count" );
// Set "Build Number"
iItem = 0;
m_ctrlAcStatList.SetItemText( iItem++, 1, m_acGeneral.strBuildNumber );
// Set "Engine Status"
switch ( m_acGeneral.dwStatus )
{
case ACSTATUS_NOTCREATED:
str = "Not Created";
break;
case ACSTATUS_OPERATIONAL:
str = "Operational";
break;
case ACSTATUS_DEVICELOST:
str = "Device Lost";
break;
}
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Vertex Pipeline"
switch ( m_acGeneral.dwVertexPipeline )
{
case ACVPIPE_NONE:
str = "None";
break;
case ACVPIPE_PURE:
str = "Pure Device";
break;
case ACVPIPE_MIXED:
str = "Mixed";
break;
case ACVPIPE_SOFTWARE:
str = "Software";
break;
}
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Engine Time"
str.Format( "%u", m_acGeneral.dwEngineTime );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Last Time Integrator"
str.Format( "%.2f", m_acGeneral.fLastTI );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Average FPS"
str.Format( "%.2f", m_acGeneral.fAverageFPS );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Texture Count"
str.Format( "%u", m_acGeneral.dwTextureCount );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Mesh Count"
str.Format( "%u", m_acGeneral.dwMeshCount );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Object Count"
str.Format( "%u", m_acGeneral.dwObjectCount );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Sprite Count"
str.Format( "%u", m_acGeneral.dwSpriteCount );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// Set "Font Count"
str.Format( "%u", m_acGeneral.dwFontCount );
m_ctrlAcStatList.SetItemText( iItem++, 1, str );
// End General section
break;
case STATTAB_TEXTURES:
// Add columns
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_ALIAS, "Alias", LVCFMT_LEFT, 140 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_REFCOUNT, "Refs", LVCFMT_LEFT, 40 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_SOURCE, "Source Alias", LVCFMT_LEFT, 140 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_WIDTH, "Width", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_HEIGHT, "Height", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_DEPTH, "Bits", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_TILEX, "TileX", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_TILEY, "TileY", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_FRAMECOUNT, "Frames", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_TEXTURE_D3DTEXTURES, "D3D Textures", LVCFMT_LEFT, 80 );
// Enumerate all textures
iItem = 0;
nRes = NULL;
m_pAlchemy->GetTextureStatistics( &nRes, &acTexture );
while ( nRes ) {
// Insert item "Alias"
if ( acTexture.strAlias != "" )
str = acTexture.strAlias;
else
str.Format( "%u", acTexture.nHandle );
m_ctrlAcStatList.InsertItem( iItem, str );
// Set item "Refs"
str.Format( "%u", acTexture.dwRefCount );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_REFCOUNT, str );
// Set item "Source Alias"
if ( !acTexture.nSource )
str = "N/A";
else {
str.Format( "%u", acTexture.nSource );
}
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_SOURCE, str );
// Set item "Width"
str.Format( "%u", acTexture.dwWidth );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_WIDTH, str );
// Set item "Height"
str.Format( "%u", acTexture.dwHeight );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_HEIGHT, str );
// Set item "Bits"
str.Format( "%u", acTexture.dwBitDepth );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_DEPTH, str );
// Set item "TileX"
str.Format( "%u", acTexture.dwTileX );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_TILEX, str );
// Set item "TileY"
str.Format( "%u", acTexture.dwTileY );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_TILEY, str );
// Set item "Frames"
str.Format( "%u", acTexture.dwFrameCount );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_FRAMECOUNT, str );
// Set item "D3D Texture"
str.Format( "%u", acTexture.dwD3DTextures );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_TEXTURE_D3DTEXTURES, str );
// Get next texture
iItem++;
m_pAlchemy->GetTextureStatistics( &nRes, &acTexture );
}
// End Textures section
break;
case STATTAB_MESHES:
// Add columns
m_ctrlAcStatList.InsertColumn( STATCOL_MESH_ALIAS, "Alias", LVCFMT_LEFT, 140 );
m_ctrlAcStatList.InsertColumn( STATCOL_MESH_REFCOUNT, "Refs", LVCFMT_LEFT, 40 );
m_ctrlAcStatList.InsertColumn( STATCOL_MESH_VERTCOUNT, "Vertices", LVCFMT_LEFT, 60 );
m_ctrlAcStatList.InsertColumn( STATCOL_MESH_FACECOUNT, "Faces", LVCFMT_LEFT, 50 );
m_ctrlAcStatList.InsertColumn( STATCOL_MESH_TEXTURECOUNT, "Textures", LVCFMT_LEFT, 60 );
m_ctrlAcStatList.InsertColumn( STATCOL_MESH_TEXTUREALIAS, "Texture Alias List", LVCFMT_LEFT, 250 );
// Enumerate all meshes
iItem = 0;
nRes = NULL;
m_pAlchemy->GetMeshStatistics( &nRes, &acMesh );
while ( nRes ) {
// Insert item "Alias"
if ( acMesh.strAlias != "" )
str = acMesh.strAlias;
else
str.Format( "%u", acMesh.nHandle );
m_ctrlAcStatList.InsertItem( iItem, str );
// Set item "Refs"
str.Format( "%u", acMesh.dwRefCount );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_MESH_REFCOUNT, str );
// Set item "Vertices"
str.Format( "%u", acMesh.dwVertCount );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_MESH_VERTCOUNT, str );
// Set item "Faces"
str.Format( "%u", acMesh.dwFaceCount );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_MESH_FACECOUNT, str );
// Set item "Textures"
str.Format( "%u", acMesh.dwTextureCount );
m_ctrlAcStatList.SetItemText( iItem, STATCOL_MESH_TEXTURECOUNT, str );
// Set item "Texture Alias List"
m_ctrlAcStatList.SetItemText( iItem, STATCOL_MESH_TEXTUREALIAS, acMesh.strTextureAlias );
// Get next mesh
iItem++;
m_pAlchemy->GetMeshStatistics( &nRes, &acMesh );
}
// End Meshes section
break;
case STATTAB_OBJECTS:
break;
case STATTAB_SPRITES:
break;
case STATTAB_FONTS:
break;
}
}
BEGIN_MESSAGE_MAP(CAcStatDialog, CDialog)
ON_NOTIFY(TCN_SELCHANGE, IDC_ACSTAT_TAB, OnTcnSelchangeAcstatTab)
ON_WM_CREATE()
END_MESSAGE_MAP()
// CAcStatDialog message handlers
BOOL CAcStatDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// Set extended styles
m_ctrlAcStatList.SetExtendedStyle( LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_LABELTIP );
// Assert if Alchemy not set
_ASSERT( m_pAlchemy );
// Get general properties
m_pAlchemy->GetStatistics( &m_acGeneral );
// Prepare tabs
m_ctrlAcStatTab.InsertItem( STATTAB_GENERAL, "General" );
m_ctrlAcStatTab.InsertItem( STATTAB_TEXTURES, "Textures" );
m_ctrlAcStatTab.InsertItem( STATTAB_MESHES, "Meshes" );
//m_ctrlAcStatTab.InsertItem( STATTAB_OBJECTS, "Objects" );
//m_ctrlAcStatTab.InsertItem( STATTAB_SPRITES, "Sprites" );
//m_ctrlAcStatTab.InsertItem( STATTAB_FONTS, "Fonts" );
// Set default selection
m_ctrlAcStatTab.SetCurSel( STATTAB_GENERAL );
BuildList( STATTAB_GENERAL );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAcStatDialog::OnTcnSelchangeAcstatTab(NMHDR *pNMHDR, LRESULT *pResult)
{
// Build list based on selection
BuildList( m_ctrlAcStatTab.GetCurSel() );
*pResult = 0;
}
int CAcStatDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}