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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Configuration utility
//
//===========================================================================//
#include <windows.h>
#include <io.h>
#include <stdio.h>
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <vgui/IVGui.h>
#include <vgui_controls/Panel.h>
#include "appframework/tier3app.h"
#include "inputsystem/iinputsystem.h"
#include "tier0/icommandline.h"
#include "filesystem_init.h"
#include "CMDRipperMain.h"
#include "isqlwrapper.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
#define MDRIPPER_MAIN_PATH_ID "MAIN"
#define MDRIPPER_WRITE_PATH "DEFAULT_WRITE_PATH"
CMDRipperMain *g_pMainFrame = 0;
ISQLWrapper *g_pSqlWrapper;
// Dummy window
static WNDCLASS staticWndclass = { NULL };
static ATOM staticWndclassAtom = 0;
static HWND staticHwnd = 0;
// List of our game configs, as read from the gameconfig.txt file
//CGameConfigManager g_ConfigManager;
//CUtlVector<CGameConfig *> g_Configs;
HANDLE g_dwChangeHandle = NULL;
//-----------------------------------------------------------------------------
// Purpose:
// Output : const char
//-----------------------------------------------------------------------------
const char *GetBaseDirectory( void )
{
static char path[MAX_PATH] = {0};
if ( path[0] == 0 )
{
GetModuleFileName( (HMODULE)GetAppInstance(), path, sizeof( path ) );
Q_StripLastDir( path, sizeof( path ) ); // Get rid of the filename.
Q_StripTrailingSlash( path );
}
return path;
}
//-----------------------------------------------------------------------------
// Purpose: Message handler for dummy app
//-----------------------------------------------------------------------------
static LRESULT CALLBACK messageProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
// See if we've gotten a VPROJECT change
if ( msg == WM_SETTINGCHANGE )
{
if ( g_pMainFrame != NULL )
{
// Reset the list and pop an error if they've chosen something we don't understand
//g_pMainFrame->PopulateConfigList();
}
}
return ::DefWindowProc(hwnd,msg,wparam,lparam);
}
//-----------------------------------------------------------------------------
// Purpose: Creates a dummy window that handles windows messages
//-----------------------------------------------------------------------------
void CreateMessageWindow( void )
{
// Make and register a very simple window class
memset(&staticWndclass, 0, sizeof(staticWndclass));
staticWndclass.style = 0;
staticWndclass.lpfnWndProc = messageProc;
staticWndclass.hInstance = GetModuleHandle(NULL);
staticWndclass.lpszClassName = "minidumpRipper_Window";
staticWndclassAtom = ::RegisterClass( &staticWndclass );
// Create an empty window just for message handling
staticHwnd = CreateWindowEx(0, "minidumpRipper_Window", "Hidden Window", 0, 0, 0, 1, 1, NULL, NULL, GetModuleHandle(NULL), NULL);
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ShutdownMessageWindow( void )
{
// Kill our windows instance
::DestroyWindow( staticHwnd );
::UnregisterClass("minidumpRipper_Window", ::GetModuleHandle(NULL));
}
//-----------------------------------------------------------------------------
// Purpose: Setup all our VGUI info
//-----------------------------------------------------------------------------
bool InitializeVGUI( void )
{
vgui::ivgui()->SetSleep(false);
// Init the surface
vgui::Panel *pPanel = new vgui::Panel( NULL, "TopPanel" );
pPanel->SetVisible(true);
vgui::surface()->SetEmbeddedPanel(pPanel->GetVPanel());
// load the scheme
vgui::scheme()->LoadSchemeFromFile( "resource/sourcescheme.res", NULL );
// localization
g_pVGuiLocalize->AddFile( "resource/platform_%language%.txt" );
g_pVGuiLocalize->AddFile( "resource/vgui_%language%.txt" );
g_pVGuiLocalize->AddFile( "mdmpRipper_english.txt" );
// Start vgui
vgui::ivgui()->Start();
// add our main window
g_pMainFrame = new CMDRipperMain( pPanel, "CMDRipperMain" );
// show main window
g_pMainFrame->MoveToCenterOfScreen();
g_pMainFrame->Activate();
g_pMainFrame->SetSizeable( true );
g_pMainFrame->SetMenuButtonVisible( true );
g_pSqlWrapper = g_pMainFrame->GetSqlWrapper();
return true;
}
//-----------------------------------------------------------------------------
// Purpose: Stop VGUI
//-----------------------------------------------------------------------------
void ShutdownVGUI( void )
{
delete g_pMainFrame;
}
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CMDRipperApp : public CVguiSteamApp
{
typedef CVguiSteamApp BaseClass;
public:
// Methods of IApplication
virtual bool Create();
virtual bool PreInit();
virtual int Main();
virtual void PostShutdown();
virtual void Destroy() {}
};
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CMDRipperApp );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CMDRipperApp::Create()
{
AppSystemInfo_t appSystems[] =
{
{ "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
{ "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
{ "", "" } // Required to terminate the list
};
return AddSystems( appSystems );
}
//-----------------------------------------------------------------------------
// Purpose: Entry point
//-----------------------------------------------------------------------------
bool CMDRipperApp::PreInit()
{
if ( !BaseClass::PreInit() )
return false;
// Create a window to capture messages
CreateMessageWindow();
FileSystem_SetErrorMode( FS_ERRORMODE_AUTO );
// We only want to use the gameinfo.txt that is in the bin\vconfig directory.
char dirName[MAX_PATH];
Q_strncpy( dirName, GetBaseDirectory(), sizeof( dirName ) );
Q_AppendSlash( dirName, sizeof( dirName ) );
Q_strncat( dirName, "minidumpRipper", sizeof( dirName ), COPY_ALL_CHARACTERS );
if ( !BaseClass::SetupSearchPaths( dirName, true, true ) )
{
::MessageBox( NULL, "Error", "Unable to initialize file system\n", MB_OK );
return false;
}
// the "base dir" so we can scan mod name
g_pFullFileSystem->AddSearchPath(GetBaseDirectory(), MDRIPPER_MAIN_PATH_ID);
// the main platform dir
g_pFullFileSystem->AddSearchPath("platform","PLATFORM", PATH_ADD_TO_HEAD);
g_pFullFileSystem->AddSearchPath(".\\minidumpRipper\\",MDRIPPER_WRITE_PATH, PATH_ADD_TO_HEAD);
return true;
}
void CMDRipperApp::PostShutdown()
{
// Stop our message window
ShutdownMessageWindow();
BaseClass::PostShutdown();
}
//-----------------------------------------------------------------------------
// Purpose: Entry point
//-----------------------------------------------------------------------------
int CMDRipperApp::Main()
{
// Run app frame loop
if ( !InitializeVGUI() )
return 0;
// Run the app
while (vgui::ivgui()->IsRunning())
{
Sleep( 10 );
vgui::ivgui()->RunFrame();
}
ShutdownVGUI();
return 1;
}
|