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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Defines the application object.
//
//===========================================================================//
#ifndef HAMMER_H
#define HAMMER_H
#ifdef _WIN32
#pragma once
#endif
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#include "RunCommands.h"
#include "IHammer.h"
#include "tier1/utlmap.h"
#include "tier3/tier3dm.h"
//-----------------------------------------------------------------------------
// Forward declarations...
//-----------------------------------------------------------------------------
class CMapDoc;
class IStudioRender;
class IBaseFileSystem;
class IEngineAPI;
class IMDLCache;
class CGameConfig;
//
// Values for retrieving specific directories using GetDirectory.
//
enum DirIndex_t
{
DIR_PROGRAM, // The editor install directory.
DIR_PREFABS, // The directory for prefabs.
DIR_GAME_EXE, // The location of the game executable.
DIR_MOD, // The location of the mod currently being worked on.
DIR_GAME, // The location of the base game currently being worked on.
DIR_MATERIALS, // The location of the mod's materials.
DIR_AUTOSAVE // The location of autosave files.
};
// combines a list of commands & a name:
class CCommandSequence
{
public:
CCommandArray m_Commands;
char m_szName[128];
};
class CHammerDocTemplate : public CMultiDocTemplate
{
public:
CHammerDocTemplate( UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass ) :
CMultiDocTemplate( nIDResource, pDocClass, pFrameClass, pViewClass )
{
}
virtual CDocument *OpenDocumentFile( LPCTSTR lpszPathName, BOOL bMakeVisible = TRUE );
virtual void CloseAllDocuments( BOOL bEndSession );
virtual void InitialUpdateFrame( CFrameWnd* pFrame, CDocument* pDoc, BOOL bMakeVisible = TRUE );
void UpdateInstanceMap( CMapDoc *pInstanceMapDoc );
};
void AppRegisterPostInitFn( void (*)() );
void AppRegisterMessageLoopFn( void (*)() );
void AppRegisterMessagePretranslateFn( void (*)( MSG * ) );
void AppRegisterPreShutdownFn( void (*)() );
class CHammer : public CWinApp, public CTier3AppSystem< IHammer >
{
typedef CTier3AppSystem< IHammer > BaseClass;
public:
CHammer(void);
virtual ~CHammer(void);
// Methods of IAppSystem
virtual bool Connect( CreateInterfaceFn factory );
virtual void Disconnect();
virtual void *QueryInterface( const char *pInterfaceName );
virtual InitReturnVal_t Init();
virtual void Shutdown();
// Methods of IHammer
virtual bool HammerPreTranslateMessage( MSG * pMsg );
virtual bool HammerIsIdleMessage( MSG * pMsg );
virtual bool HammerOnIdle( long count );
virtual void RunFrame();
virtual int MainLoop();
virtual const char *GetDefaultMod();
virtual const char *GetDefaultGame();
virtual RequestRetval_t RequestNewConfig();
virtual const char *GetDefaultModFullPath();
virtual bool InitSessionGameConfig(const char *szGame);
virtual BOOL PreTranslateMessage(MSG *pMsg);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CHammer)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
virtual CDocument* OpenDocumentFile(LPCTSTR lpszFileName);
virtual BOOL OnIdle(LONG lCount);
virtual int Run(void);
//}}AFX_VIRTUAL
void GetDirectory(DirIndex_t dir, char *p);
void SetDirectory(DirIndex_t dir, const char *p);
COLORREF GetProfileColor(const char *pszSection, const char *pszKey, int r, int g, int b);
void OnActivateApp(bool bActive);
bool IsActiveApp();
void BeginImportWCSettings();
void BeginImportVHESettings();
void EndImportSettings();
void BeginClosing();
bool IsClosing();
void Enable3DRender(bool bEnable);
void ReleaseVideoMemory();
void SuppressVideoAllocation( bool bSuppress );
bool CanAllocateVideo() const;
void Help(const char *pszTopic);
CGameConfig *PromptForGameConfig();
void OpenURL(const char *pszURL, HWND hwnd);
void OpenURL(UINT nID, HWND hwnd);
// list of "command arrays" for compiling files:
CTypedPtrArray<CPtrArray,CCommandSequence*> m_CmdSequences;
void SaveSequences();
void LoadSequences();
void Autosave();
void LoadLastGoodSave();
void ResetAutosaveTimer();
bool VerifyAutosaveDirectory( char *szAutosaveDir = 0 ) const;
int GetNextAutosaveNumber( CUtlMap<FILETIME, WIN32_FIND_DATA, int> *pFileMap, DWORD *pdwTotalDirSize, const CString * ) const;
// When in lighting preview, it will avoid rendering frames.
// This forces it to render the next frame.
void SetForceRenderNextFrame();
bool GetForceRenderNextFrame();
static void SetIsNewDocumentVisible( bool bIsVisible );
static bool IsNewDocumentVisible( void );
CHammerDocTemplate *pMapDocTemplate;
CHammerDocTemplate *pManifestDocTemplate;
//{{AFX_MSG(CHammer)
afx_msg void OnAppAbout();
afx_msg void OnFileOpen();
afx_msg void OnFileNew();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
protected:
// These execute inside a minidump handler.
static int StaticHammerInternalInit( void *pParam );
InitReturnVal_t HammerInternalInit();
static int StaticInternalMainLoop( void *pParam );
int InternalMainLoop();
static bool m_bIsNewDocumentVisible;
// Check for 16-bit color or higher.
bool Check16BitColor();
void UpdateLighting(CMapDoc *pDoc);
bool m_bClosing; // The user has initiated app shutdown.
bool m_bActiveApp;
bool m_SuppressVideoAllocation;
bool m_bForceRenderNextFrame;
char m_szAppDir[MAX_PATH];
char m_szAutosaveDir[MAX_PATH];
};
#define APP() ((CHammer *)AfxGetApp())
//-----------------------------------------------------------------------------
// Global interfaces...
//-----------------------------------------------------------------------------
extern IBaseFileSystem *g_pFileSystem;
extern IEngineAPI *g_pEngineAPI;
extern CreateInterfaceFn g_Factory;
bool IsRunningInEngine();
// event update system - lets you check for events such as gemoetry modification for updating stuff.
void SignalUpdate(int ev); // EVTYPE_xx
int GetUpdateCounter(int ev); // return timestamp
float GetUpdateTime(int ev); // return floating point time event was signalled
void SignalGlobalUpdate(void); // flag ALL events, such as on map load
#define EVTYPE_FACE_CHANGED 0
#define EVTYPE_LIGHTING_CHANGED 1
#define EVTYPE_BITMAP_RECEIVED_FROM_LPREVIEW 2
extern bool g_bHDR; // should we act like we're in hdr mode?
extern int g_nBitmapGenerationCounter;
#endif // HAMMER_H
|