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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//===========================================================================//
#ifdef _WIN32
#include <windows.h>
#include <direct.h>
// includes for the VGUI version
#include <vgui_controls/Panel.h>
#include <vgui_controls/Controls.h>
#include <vgui/ISystem.h>
#include <vgui/IVGui.h>
#include <vgui/IPanel.h>
#include "filesystem.h"
#include <vgui/ILocalize.h>
#include <vgui/IScheme.h>
#include <vgui/ISurface.h>
#include <IVGuiModule.h>
#include "vgui/MainPanel.h"
#include "IAdminServer.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
static CMainPanel *g_pMainPanel = NULL; // the main panel to show
static CSysModule *g_hAdminServerModule;
IAdminServer *g_pAdminServer = NULL;
static IVGuiModule *g_pAdminVGuiModule = NULL;
void* DedicatedFactory(const char *pName, int *pReturnCode);
//-----------------------------------------------------------------------------
// Purpose: Starts up the VGUI system and loads the base panel
//-----------------------------------------------------------------------------
int StartVGUI( CreateInterfaceFn dedicatedFactory )
{
// the "base dir" so we can scan mod name
g_pFullFileSystem->AddSearchPath(".", "MAIN");
// the main platform dir
g_pFullFileSystem->AddSearchPath( "platform", "PLATFORM", PATH_ADD_TO_HEAD);
vgui::ivgui()->SetSleep(false);
// find our configuration directory
char szConfigDir[512];
const char *steamPath = getenv("SteamInstallPath");
if (steamPath)
{
// put the config dir directly under steam
Q_snprintf(szConfigDir, sizeof(szConfigDir), "%s/config", steamPath);
}
else
{
// we're not running steam, so just put the config dir under the platform
Q_strncpy( szConfigDir, "platform/config", sizeof(szConfigDir));
}
g_pFullFileSystem->CreateDirHierarchy("config", "PLATFORM");
g_pFullFileSystem->AddSearchPath(szConfigDir, "CONFIG", PATH_ADD_TO_HEAD);
// initialize the user configuration file
vgui::system()->SetUserConfigFile("DedicatedServerDialogConfig.vdf", "CONFIG");
// Init the surface
g_pMainPanel = new CMainPanel( );
g_pMainPanel->SetVisible(true);
vgui::surface()->SetEmbeddedPanel(g_pMainPanel->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( "Admin/server_%language%.txt" );
// Start vgui
vgui::ivgui()->Start();
// load the module
g_pFullFileSystem->GetLocalCopy("bin/AdminServer.dll");
g_hAdminServerModule = g_pFullFileSystem->LoadModule("AdminServer");
Assert(g_hAdminServerModule != NULL);
CreateInterfaceFn adminFactory = NULL;
if (!g_hAdminServerModule)
{
vgui::ivgui()->DPrintf2("Admin Error: module version (Admin/AdminServer.dll, %s) invalid, not loading\n", IMANAGESERVER_INTERFACE_VERSION );
}
else
{
// make sure we get the right version
adminFactory = Sys_GetFactory(g_hAdminServerModule);
g_pAdminServer = (IAdminServer *)adminFactory(ADMINSERVER_INTERFACE_VERSION, NULL);
g_pAdminVGuiModule = (IVGuiModule *)adminFactory("VGuiModuleAdminServer001", NULL);
Assert(g_pAdminServer != NULL);
Assert(g_pAdminVGuiModule != NULL);
if (!g_pAdminServer || !g_pAdminVGuiModule)
{
vgui::ivgui()->DPrintf2("Admin Error: module version (Admin/AdminServer.dll, %s) invalid, not loading\n", IMANAGESERVER_INTERFACE_VERSION );
}
}
// finish initializing admin module
g_pAdminVGuiModule->Initialize( &dedicatedFactory, 1 );
g_pAdminVGuiModule->PostInitialize(&adminFactory, 1);
g_pAdminVGuiModule->SetParent( g_pMainPanel->GetVPanel() );
// finish setting up main panel
g_pMainPanel->Initialize( );
g_pMainPanel->Open();
return 0;
}
//-----------------------------------------------------------------------------
// Purpose: Shuts down the VGUI system
//-----------------------------------------------------------------------------
void StopVGUI()
{
SetEvent(g_pMainPanel->GetShutdownHandle());
delete g_pMainPanel;
g_pMainPanel = NULL;
if (g_hAdminServerModule)
{
g_pAdminVGuiModule->Shutdown( );
Sys_UnloadModule(g_hAdminServerModule);
}
}
//-----------------------------------------------------------------------------
// Purpose: Run a single VGUI frame
//-----------------------------------------------------------------------------
void RunVGUIFrame()
{
vgui::ivgui()->RunFrame();
}
bool VGUIIsStopping()
{
return g_pMainPanel->Stopping();
}
bool VGUIIsRunning()
{
return vgui::ivgui()->IsRunning();
}
bool VGUIIsInConfig()
{
return g_pMainPanel->IsInConfig();
}
void VGUIFinishedConfig()
{
Assert( g_pMainPanel );
if(g_pMainPanel) // engine is loaded, pass the message on
{
SetEvent(g_pMainPanel->GetShutdownHandle());
}
}
void VGUIPrintf( const char *msg )
{
if ( !g_pMainPanel || VGUIIsInConfig() || VGUIIsStopping() )
{
OutputDebugStringA( msg );
}
else if ( g_pMainPanel )
{
g_pMainPanel->AddConsoleText( msg );
}
}
#endif // _WIN32
|