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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#define NOWINRES
#define NOSERVICE
#define NOMCX
#define NOIME
#include <windows.h>
#undef MessageBox
#undef PostMessage
#include "stdafx.h"
#include "appframework/tier3app.h"
#include "tier2/tier2.h"
#include "inputsystem/iinputsystem.h"
#include "vgui_controls/controls.h"
// root panel
vgui::Panel *g_pMainPanel = NULL;
//-----------------------------------------------------------------------------
// Purpose: Adds in any search paths
//-----------------------------------------------------------------------------
void AddFileSystemSearchPaths(const char *pszExeName)
{
// search locally first
char pExeName[MAX_PATH];
if ( ::GetModuleFileName( ( HINSTANCE )GetModuleHandle( NULL ), pExeName, sizeof(pExeName) ) )
{
char pPlatform[MAX_PATH];
Q_StripFilename( pExeName );
Q_snprintf( pPlatform, sizeof(pPlatform), "%s\\..\\platform", pExeName );
g_pFullFileSystem->AddSearchPath( pExeName, "EXECUTABLE_PATH");
g_pFullFileSystem->AddSearchPath( pPlatform, "PLATFORM");
g_pFullFileSystem->AddSearchPath( pPlatform, "SKIN");
}
else
{
g_pFullFileSystem->AddSearchPath(".", "EXECUTABLE_PATH");
g_pFullFileSystem->AddSearchPath("../platform/", "PLATFORM");
g_pFullFileSystem->AddSearchPath("../platform/", "SKIN");
}
// add self as a pack file
// g_pFullFileSystem->AddPackFile(pszExeName, "PLATFORM");
}
//-----------------------------------------------------------------------------
// Purpose: Sets up the main vgui
//-----------------------------------------------------------------------------
bool InitializeVGui( )
{
// add in the search paths
AddFileSystemSearchPaths(NULL);
// Init the surface
g_pMainPanel = new vgui::Panel(NULL, NULL);
vgui::surface()->SetEmbeddedPanel( g_pMainPanel->GetVPanel() );
// load the scheme
g_pMainPanel->SetScheme( vgui::scheme()->LoadSchemeFromFile( "//PLATFORM/Resource/sourcescheme.res", "PLATFORM" ) );
// localization
g_pVGuiLocalize->AddFile( "Resource/platform_%language%.txt");
g_pVGuiLocalize->AddFile( "Resource/vgui_%language%.txt");
// configuration settings
vgui::system()->SetUserConfigFile( "vp4config.txt", "EXECUTABLE_PATH" );
// Start vgui
vgui::ivgui()->Start();
// finish setting up main panel
vgui::SETUP_PANEL( g_pMainPanel );
return true;
}
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
class CVP4App : public CVguiSteamApp
{
public:
// Methods of IApplication
virtual bool Create();
virtual int Main();
virtual void Destroy() {}
};
DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CVP4App );
//-----------------------------------------------------------------------------
// The application object
//-----------------------------------------------------------------------------
bool CVP4App::Create()
{
AppSystemInfo_t appSystems[] =
{
{ "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
{ "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
{ "p4lib.dll", P4_INTERFACE_VERSION },
{ "", "" } // Required to terminate the list
};
return AddSystems( appSystems );
}
//-----------------------------------------------------------------------------
// Purpose: program entrypoint
//-----------------------------------------------------------------------------
int CVP4App::Main()
{
if ( !InitializeVGui( ) )
{
::MessageBoxA( NULL, "Fatal Error: Could not initialize vgui.", "Steam - Fatal Error", MB_OK | MB_ICONERROR );
return 0;
}
// open the wizard
CVP4Dialog *dlg = SETUP_PANEL(new CVP4Dialog());
dlg->SetParent(g_pMainPanel);
dlg->Activate();
// run vgui
while (vgui::ivgui()->IsRunning())
{
vgui::ivgui()->RunFrame();
}
// save configuration
vgui::system()->SaveUserConfigFile();
// delete all the panels
delete g_pMainPanel;
return 0;
}
|