-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDaggerfall Explorer.h
414 lines (363 loc) · 11.8 KB
/
Daggerfall Explorer.h
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/*************************************************************************************************\
*
* Filename: DaggerfallExplorer.h
* Purpose: Define CDaggerfallExplorerApp class
* Version: 0.90
* 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:
*
*
\*************************************************************************************************/
#if !defined(AFX_DAGGERFALLEXPLORER_H__62D08791_7699_4947_9740_8F102F21CE2D__INCLUDED_)
#define AFX_DAGGERFALLEXPLORER_H__62D08791_7699_4947_9740_8F102F21CE2D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "ChildView.h"
#include "ArenaBar.h"
#include "LogDialog.h"
#include "DaggerTool.h"
#include "PropertiesBar.h"
#include "MainFrm.h"
#include "resource.h" // main symbols
// Defines
#define DE_CACHETEXTURE_WIDTH 256
#define DE_CACHETEXTURE_HEIGHT 256
#define DE_CACHETEXTURE_PITCH 768
#define DE_CACHETEXTURE_BYTES 196608
#define DE_START_TERRAIN TERRAIN_TEMPERATE
#define DE_START_OBJECT 5557 // Shedungent
#define DE_START_BLOCK 835 // Testing
//#define DE_START_BLOCK 267 // Castle Wayrest
//#define DE_START_BLOCK 577 // Castle Sentinel
//#define DE_START_BLOCK ? // Castle Daggerfall
#define DE_START_DRAW OBJDRAW_TEXTURED
#define DEOBJECT_STARTPOS D3DXVECTOR3( 0.0f, 0.0f, 1800.0f )
#define DEBLOCK_STARTPOSOBJECT D3DXVECTOR3( -37.5f, -350.0f, 4900.0f )
#define DEBLOCK_STARTPOSCAMERA D3DXVECTOR3( 0.0f, -900.0f, 4200.0f )
#define DECAMERA_STARTPOS D3DXVECTOR( 0.0f, 0.0f, 0.0f )
#define DECOLOUR_SPRITE D3DXCOLOR( 1.0f, 1.0f, 1.0f, 1.0f )
#define DECOLOUR_SELECTEDSPRITE D3DXCOLOR( 1.0f, 0.0f, 1.0f, 1.0f )
// Timer type enum
enum
{
DETIMER_STEPBITMAPS,
DETIMER_POLLKEYBOARD,
};
// Node Types - All types of nodes possible in the tree view
typedef enum _tagNodeType
{
NT_NONE,
NT_BASICROOT,
NT_LOCALEROOT,
NT_PLACEROOT,
NT_DUNGEONROOT,
NT_ARCH3D,
NT_BLOCKS,
NT_SUBBLOCKS,
NT_TEXTUREARCHIVE,
NT_IMGFILE,
NT_CIFFILE,
NT_SKYFILE,
NTGENERIC_BITMAP,
NTGENERIC_OBJECT,
} NODETYPE;
// Mouse modes - Actions that can be assigned to the view
enum
{
MOUSEMODE_OBJECT,
MOUSEMODE_CAMERA,
};
// Render modes - How an object will be drawn
enum
{
OBJDRAW_PUREFACES,
OBJDRAW_WIREFRAME,
OBJDRAW_SOLID,
OBJDRAW_TEXTURED,
};
// Object properties - for generic bitmaps
enum {
BMPPROP_FILENAME,
BMPPROP_DESCRIPTION,
BMPPROP_RECORDCOUNT,
};
// Object properties - for 3D objects
enum {
OBJPROP_OBJECT,
OBJPROP_OBJECTID,
OBJPROP_OBJECTVERSION,
OBJPROP_FACECOUNT,
OBJPROP_SELFACE,
OBJPROP_POINTCOUNT,
OBJPROP_CORNERCOUNT,
OBJPROP_CORNERPOINTS,
OBJPROP_ARCHIVE,
OBJPROP_TEXTUREDIM,
OBJPROP_UVPAIRS,
};
// Block properties - for block objects
enum {
BLKPROP_OBJECT,
BLKPROP_FILENAME,
BLKPROP_NUMRECORDS1,
BLKPROP_OUTSIDE_NUM3DOBJECTS,
BLKPROP_OUTSIDE_NUMFLATOBJECTS,
BLKPROP_OUTSIDE_NUMPEOPLE,
BLKPROP_OUTSIDE_NUMDOORS,
BLKPROP_INSIDE_NUM3DOBJECTS,
BLKPROP_INSIDE_NUMFLATOBJECTS,
BLKPROP_INSIDE_NUMPEOPLE,
BLKPROP_INSIDE_NUMDOORS,
};
// Stores a single face during triangulation
typedef struct _WIREFACE {
TString strTexture;
DWORD dwVertCount;
OBJVERTEX verts[64];
} WIREFACE;
// Stores a combine texture object during texture cache operations
typedef struct _DFTEXTURECACHE
{
_DFTEXTURECACHE() {
UINT nTexture = ACNULL;
cx = maxWidth = cy = 0;
memset( pBits, 0, DE_CACHETEXTURE_BYTES );
}
TString strName; // Name of this texture in the store
int cx; // Position of current column
int maxWidth; // Maximum width of this column
int cy; // Height of current column
char pBits[DE_CACHETEXTURE_BYTES]; // R8G8B8 texture bits for this combine texture
RECT rctTexture; // Rect of this texture
TLinkedList<RECT> oaSubset; // List of rectangles to reference subset of surface
} DFTEXTURECACHE, *LPDFTEXTURECACHE;
// Reference a combine texture object and an offset
typedef struct _DFTEXTUREREF
{
UINT nTexture; // Reference for texture in cache table
UINT nSubset; // Reference for subset of texture in cache table
} DFTEXTUREREF, *LPDFTEXTUREREF;
/////////////////////////////////////////////////////////////////////////////
// CDaggerfallExplorerApp:
// See Daggerfall Explorer.cpp for the implementation of this class
//
class CDaggerfallExplorerApp : public CWinApp
{
public:
CDaggerfallExplorerApp();
virtual ~CDaggerfallExplorerApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDaggerfallExplorerApp)
public:
virtual BOOL InitInstance();
virtual BOOL OnIdle(LONG lCount);
virtual int ExitInstance();
//}}AFX_VIRTUAL
// Implementation
public:
//{{AFX_MSG(CDaggerfallExplorerApp)
afx_msg void OnAppAbout();
afx_msg void OnFileOpenArena2();
afx_msg void OnFileCloseArena2();
afx_msg void OnUpdateFileCloseArena2(CCmdUI* pCmdUI);
afx_msg void OnObjectPrevious();
afx_msg void OnUpdateObjectPrevious(CCmdUI* pCmdUI);
afx_msg void OnObjectNext();
afx_msg void OnUpdateObjectNext(CCmdUI* pCmdUI);
afx_msg void OnObjectGoto();
afx_msg void OnUpdateObjectGoto(CCmdUI* pCmdUI);
afx_msg void OnObjectPureFaces();
afx_msg void OnUpdateObjectPureFaces(CCmdUI* pCmdUI);
afx_msg void OnObjectWireframe();
afx_msg void OnUpdateObjectWireframe(CCmdUI* pCmdUI);
afx_msg void OnObjectSolid();
afx_msg void OnUpdateObjectSolid(CCmdUI* pCmdUI);
afx_msg void OnObjectTextured();
afx_msg void OnUpdateObjectTextured(CCmdUI* pCmdUI);
afx_msg void OnBitmapAnimation();
afx_msg void OnObjectFaceNextFace();
afx_msg void OnUpdateObjectFaceNextFace(CCmdUI* pCmdUI);
afx_msg void OnObjectFacePreviousFace();
afx_msg void OnUpdateObjectFacePreviousFace(CCmdUI* pCmdUI);
afx_msg void OnBitmapZoomIn();
afx_msg void OnUpdateBitmapZoomIn(CCmdUI* pCmdUI);
afx_msg void OnBitmapZoomOut();
afx_msg void OnUpdateBitmapZoomOut(CCmdUI* pCmdUI);
afx_msg void OnObjectFaceGotoFace();
afx_msg void OnUpdateObjectFaceGotoFace(CCmdUI* pCmdUI);
afx_msg void OnPlayUVEditor();
afx_msg void OnUpdatePlayUVEditor(CCmdUI* pCmdUI);
afx_msg void OnViewArenaView();
afx_msg void OnUpdateViewArenaView(CCmdUI* pCmdUI);
afx_msg void OnViewPropertiesView();
afx_msg void OnUpdateViewPropertiesView(CCmdUI* pCmdUI);
afx_msg void OnViewLogView();
afx_msg void OnUpdateViewLogView(CCmdUI* pCmdUI);
afx_msg void OnBitmapToggleAnimation();
afx_msg void OnUpdateBitmapToggleAnimation(CCmdUI* pCmdUI);
afx_msg void OnUpdateBitmapAnimation(CCmdUI* pCmdUI);
afx_msg void OnToolsAlchemyStatistics();
afx_msg void OnUpdateObjectCamera(CCmdUI *pCmdUI);
afx_msg void OnTerrainDesert();
afx_msg void OnUpdateTerrainDesert(CCmdUI *pCmdUI);
afx_msg void OnTerrainMountain();
afx_msg void OnUpdateTerrainMountain(CCmdUI *pCmdUI);
afx_msg void OnTerrainTemperate();
afx_msg void OnUpdateTerrainTemperate(CCmdUI *pCmdUI);
afx_msg void OnTerrainSwamp();
afx_msg void OnUpdateTerrainSwamp(CCmdUI *pCmdUI);
afx_msg void OnTerrainNormal();
afx_msg void OnUpdateTerrainNormal(CCmdUI *pCmdUI);
afx_msg void OnTerrainWinter();
afx_msg void OnUpdateTerrainWinter(CCmdUI *pCmdUI);
afx_msg void OnTerrainRain();
afx_msg void OnUpdateTerrainRain(CCmdUI *pCmdUI);
afx_msg void OnViewObjectmode();
afx_msg void OnUpdateViewObjectmode(CCmdUI *pCmdUI);
afx_msg void OnViewCameramode();
afx_msg void OnUpdateViewCameramode(CCmdUI *pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public: // methods
void HandleMouseMessages( const MSG* pMsg, int x, int y );
void HandleChildMessage( LPNMHDR pnmh );
void OnDrawMediaView();
void OnSizeMediaView( int cx, int cy );
void OnScrollMediaView( int nBar, UINT nSBCode, UINT nPos );
void OnStepBitmaps();
void OnPollKeyboard();
void OnLMouseDrag( int x, int y );
void OnRMouseDrag( int x, int y );
private: // methods
BOOL FailInitApp();
BOOL BuildMediaView( BOOL bReset = FALSE );
BOOL DrawMediaView();
BOOL InitialiseViews();
void OnSelectNode( UINT hNode );
void SelectSprite( int x, int y );
BOOL BuildTextureArchiveNode();
BOOL BuildIMGNode();
BOOL BuildCIFNode();
BOOL BuildRCINode();
BOOL BuildLocaleNode();
BOOL BuildMesh( long nObject, TFlexibleMesh* pMeshOut );
BOOL BuildBlockGroundMesh( LPRMBFLD_SMALLMAPDATA pMap, TFlexibleMesh* pMeshOut );
BOOL BuildObjectView( BOOL bResetObject = FALSE );
BOOL BuildBlockView( BOOL bResetObject = FALSE );
BOOL BuildBlockObjects( LPRMBFLD pFLD );
BOOL BuildInsideBlockObject( LPRMBFLD pFLD );
BOOL BuildPropertyView();
BOOL SetPropertyView();
BOOL CacheTextureArchive( LPCSTR pszName );
BOOL CacheIMGImage( LPCSTR pszName );
BOOL CacheCIFArchive( LPCSTR pszName );
BOOL CacheSkyArchive( LPCSTR pszName );
BOOL FormatSpritePage();
BOOL SetPageScrollers();
BOOL InitialiseMeshObject( TFlexibleMesh* pMesh,DWORD dwVertCount = 0, DWORD dwFaceCount = 0 );
BOOL CacheDFTextureCombine( LPCSTR pszName, long nArchive, long nRecord, LPRECT pRectOut, TString& strCacheNameOut );
BOOL CacheDFTextureVerbose( LPCSTR pszName, long nArchive, long nRecord, LPRECT pRectOut );
BOOL CommitDFTextures();
void ReleaseDFTextures();
BOOL ApplyRegion( long *pArchive );
void ResetObject();
void ResetCamera();
void AutoBlockTests();
public: // objects
TLog m_Log;
private: // objects
TAlchemy m_Alchemy;
CChildView* m_pMediaView;
CArenaBar* m_pArenaBar;
CLogDialog* m_pLogDlg;
CPropertiesBar* m_pPropertiesBar;
CLogBar* m_pLogBar;
CMainFrame* m_pFrame;
CDaggerTool m_DaggerTool;
TFlexibleMesh m_meshView;
private: // data
UINT m_nLastLogEntry;
BOOL m_bTextureArchiveNodeBuilt;
BOOL m_bIMGRootNodeBuilt;
BOOL m_bCIFRootNodeBuilt;
BOOL m_bLocaleRootNodeBuilt;
UINT m_nSelectedSprite;
UINT m_nAutomapSprite;
UINT m_nViewActor;
UINT m_nDefaultFont;
IMG_IMAGEDESC m_idCurIMG;
HTREEITEM m_hTexturesRootNode;
HTREEITEM m_hIMGRootNode;
HTREEITEM m_hCIFRootNode;
HTREEITEM m_hRCIRootNode;
HTREEITEM m_hSkyRootNode;
HTREEITEM m_h3DObjectsRootNode;
HTREEITEM m_hBlocksRootNode;
HTREEITEM m_hLocaleRootNode;
UINT m_nCurNode;
long m_nCurArch3DObject;
long m_nCurBlockObject;
long m_nCurSubBlockObject;
long m_nSubBlockObjectCount;
long m_nCurFace;
DWORD m_dwMouseMode;
DWORD m_dwDrawMode;
DWORD m_dwCurNodeType;
DWORD m_dwCurNodeGeneric;
float m_fBitmapScale;
BOOL m_bSupressAnimateBitmaps;
BOOL m_bLockView;
BOOL m_bViewInterior;
BOOL m_bDrawGround;
BOOL m_bDrawAllBlocks;
int m_nLastMouseX;
int m_nLastMouseY;
int m_nScrollX;
int m_nScrollY;
int m_nPageWidth;
int m_nPageHeight;
BOOL m_bAnimateBitmaps;
DWORD m_dwBitmapFPS;
CString m_strCurTextureArchive;
TString m_strStartDirectory;
UINT_PTR m_nAnimTimer;
UINT_PTR m_nKeyTimer;
UINT m_nLastDFTextureCache;
TLinkedList<DFTEXTURECACHE> m_oaDFTextureCache;
THashArray<DFTEXTUREREF, 97> m_haDFTextureCacheIndexCombine;
THashArray<DFTEXTUREREF, 97> m_haDFTextureCacheIndexVerbose;
TStaticArray<CPropTreeItem*> m_oaPropCache;
DWORD m_dwTerrain;
DWORD m_dwWeather;
char m_kbState[256];
public:
afx_msg void OnViewReset();
afx_msg void OnUpdateViewReset(CCmdUI *pCmdUI);
afx_msg void OnObjectPreviousBlock();
afx_msg void OnUpdateObjectPreviousBlock(CCmdUI *pCmdUI);
afx_msg void OnObjectNextBlock();
afx_msg void OnUpdateObjectNextBlock(CCmdUI *pCmdUI);
afx_msg void OnViewAllblocks();
afx_msg void OnUpdateViewAllblocks(CCmdUI *pCmdUI);
afx_msg void OnViewGroundplane();
afx_msg void OnUpdateViewGroundplane(CCmdUI *pCmdUI);
afx_msg void OnViewInterior();
afx_msg void OnUpdateViewInterior(CCmdUI *pCmdUI);
afx_msg void OnTerrainNone();
afx_msg void OnUpdateTerrainNone(CCmdUI *pCmdUI);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_DAGGERFALLEXPLORER_H__62D08791_7699_4947_9740_8F102F21CE2D__INCLUDED_)