FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
TF2-Source-Code/tf2_src/appframework/WinApp.cpp at master · sr2echa/TF2-Source-Code · GitHub
sr2echa
/
TF2-Source-Code
Public
Notifications
You must be signed in to change notification settings
Fork
22
Star
81
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
TF2-Source-Code
/
tf2_src
/
appframework
/
WinApp.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
248 lines (205 loc) · 7.35 KB
Breadcrumbs
TF2-Source-Code
/
tf2_src
/
appframework
/
WinApp.cpp
Copy path
File metadata and controls
248 lines (205 loc) · 7.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
========= Copyright Valve Corporation, All rights reserved. ============//
//
//
Purpose: An application framework
//
//
=============================================================================//
#
ifdef
POSIX
#
error
#
else
#
if
defined( _WIN32 ) && !defined( _X360 )
#
include
<
windows.h
>
#
endif
#
include
"
appframework/appframework.h
"
#
include
"
tier0/dbg.h
"
#
include
"
tier0/icommandline.h
"
#
include
"
interface.h
"
#
include
"
filesystem.h
"
#
include
"
appframework/iappsystemgroup.h
"
#
include
"
filesystem_init.h
"
#
include
"
vstdlib/cvar.h
"
#
include
"
xbox/xbox_console.h
"
//
NOTE: This has to be the last file included!
#
include
"
tier0/memdbgon.h
"
//
-----------------------------------------------------------------------------
//
Globals...
//
-----------------------------------------------------------------------------
HINSTANCE
s_HInstance;
//
static CSimpleWindowsLoggingListener s_SimpleWindowsLoggingListener;
//
static CSimpleLoggingListener s_SimpleLoggingListener;
//
ILoggingListener *g_pDefaultLoggingListener = &s_SimpleLoggingListener;
//
-----------------------------------------------------------------------------
//
HACK: Since I don't want to refit vgui yet...
//
-----------------------------------------------------------------------------
void
*
GetAppInstance
()
{
return
s_HInstance;
}
//
-----------------------------------------------------------------------------
//
Sets the application instance, should only be used if you're not calling AppMain.
//
-----------------------------------------------------------------------------
void
SetAppInstance
(
void
* hInstance )
{
s_HInstance = (
HINSTANCE
)hInstance;
}
//
-----------------------------------------------------------------------------
//
Specific 360 environment setup.
//
-----------------------------------------------------------------------------
#
if
defined( _X360 )
bool
SetupEnvironment360
()
{
CommandLine
()->
CreateCmdLine
(
GetCommandLine
() );
if
( !
CommandLine
()->
FindParm
(
"
-game
"
) && !
CommandLine
()->
FindParm
(
"
-vproject
"
) )
{
//
add the default game name due to lack of vproject environment
CommandLine
()->
AppendParm
(
"
-game
"
,
"
hl2
"
);
}
//
success
return
true
;
}
#
endif
//
-----------------------------------------------------------------------------
//
Version of AppMain used by windows applications
//
-----------------------------------------------------------------------------
int
AppMain
(
void
* hInstance,
void
* hPrevInstance,
const
char
* lpCmdLine,
int
nCmdShow, CAppSystemGroup *pAppSystemGroup )
{
Assert
( pAppSystemGroup );
//
g_pDefaultLoggingListener = &s_SimpleWindowsLoggingListener;
s_HInstance = (
HINSTANCE
)hInstance;
#
if
!defined( _X360 )
CommandLine
()->
CreateCmdLine
( ::
GetCommandLine
() );
#
else
SetupEnvironment360
();
#
endif
return
pAppSystemGroup->
Run
();
}
//
-----------------------------------------------------------------------------
//
Version of AppMain used by console applications
//
-----------------------------------------------------------------------------
int
AppMain
(
int
argc,
char
**argv, CAppSystemGroup *pAppSystemGroup )
{
Assert
( pAppSystemGroup );
//
g_pDefaultLoggingListener = &s_SimpleLoggingListener;
s_HInstance =
NULL
;
#
if
!defined( _X360 )
CommandLine
()->
CreateCmdLine
( argc, argv );
#
else
SetupEnvironment360
();
#
endif
return
pAppSystemGroup->
Run
();
}
//
-----------------------------------------------------------------------------
//
Used to startup/shutdown the application
//
-----------------------------------------------------------------------------
int
AppStartup
(
void
* hInstance,
void
* hPrevInstance,
const
char
* lpCmdLine,
int
nCmdShow, CAppSystemGroup *pAppSystemGroup )
{
Assert
( pAppSystemGroup );
//
g_pDefaultLoggingListener = &s_SimpleWindowsLoggingListener;
s_HInstance = (
HINSTANCE
)hInstance;
#
if
!defined( _X360 )
CommandLine
()->
CreateCmdLine
( ::
GetCommandLine
() );
#
else
SetupEnvironment360
();
#
endif
return
pAppSystemGroup->
Startup
();
}
int
AppStartup
(
int
argc,
char
**argv, CAppSystemGroup *pAppSystemGroup )
{
Assert
( pAppSystemGroup );
//
g_pDefaultLoggingListener = &s_SimpleLoggingListener;
s_HInstance =
NULL
;
#
if
!defined( _X360 )
CommandLine
()->
CreateCmdLine
( argc, argv );
#
else
SetupEnvironment360
();
#
endif
return
pAppSystemGroup->
Startup
();
}
void
AppShutdown
( CAppSystemGroup *pAppSystemGroup )
{
Assert
( pAppSystemGroup );
pAppSystemGroup->
Shutdown
();
}
//
-----------------------------------------------------------------------------
//
//
Default implementation of an application meant to be run using Steam
//
//
-----------------------------------------------------------------------------
//
-----------------------------------------------------------------------------
//
Constructor
//
-----------------------------------------------------------------------------
CSteamApplication::CSteamApplication
( CSteamAppSystemGroup *pAppSystemGroup )
{
m_pChildAppSystemGroup = pAppSystemGroup;
m_pFileSystem =
NULL
;
m_bSteam =
false
;
}
//
-----------------------------------------------------------------------------
//
Create necessary interfaces
//
-----------------------------------------------------------------------------
bool
CSteamApplication::Create
()
{
FileSystem_SetErrorMode
(
FS_ERRORMODE_AUTO
);
char
pFileSystemDLL[
MAX_PATH
];
if
(
FileSystem_GetFileSystemDLLName
( pFileSystemDLL,
MAX_PATH
, m_bSteam ) !=
FS_OK
)
return
false
;
//
Add in the cvar factory
AppModule_t cvarModule =
LoadModule
(
VStdLib_GetICVarFactory
() );
AddSystem
( cvarModule,
CVAR_INTERFACE_VERSION
);
AppModule_t fileSystemModule =
LoadModule
( pFileSystemDLL );
m_pFileSystem = (IFileSystem*)
AddSystem
( fileSystemModule,
FILESYSTEM_INTERFACE_VERSION
);
if
( !m_pFileSystem )
{
Error
(
"
Unable to load %s
"
, pFileSystemDLL );
return
false
;
}
return
true
;
}
//
-----------------------------------------------------------------------------
//
The file system pointer is invalid at this point
//
-----------------------------------------------------------------------------
void
CSteamApplication::Destroy
()
{
m_pFileSystem =
NULL
;
}
//
-----------------------------------------------------------------------------
//
Pre-init, shutdown
//
-----------------------------------------------------------------------------
bool
CSteamApplication::PreInit
()
{
return
true
;
}
void
CSteamApplication::PostShutdown
()
{
}
//
-----------------------------------------------------------------------------
//
Run steam main loop
//
-----------------------------------------------------------------------------
int
CSteamApplication::Main
()
{
//
Now that Steam is loaded, we can load up main libraries through steam
if
(
FileSystem_SetBasePaths
( m_pFileSystem ) !=
FS_OK
)
return
0
;
m_pChildAppSystemGroup->
Setup
( m_pFileSystem,
this
);
return
m_pChildAppSystemGroup->
Run
();
}
//
-----------------------------------------------------------------------------
//
Use this version in cases where you can't control the main loop and
//
expect to be ticked
//
-----------------------------------------------------------------------------
int
CSteamApplication::Startup
()
{
int
nRetVal =
BaseClass::Startup
();
if
(
GetErrorStage
() !=
NONE
)
return
nRetVal;
if
(
FileSystem_SetBasePaths
( m_pFileSystem ) !=
FS_OK
)
return
0
;
//
Now that Steam is loaded, we can load up main libraries through steam
m_pChildAppSystemGroup->
Setup
( m_pFileSystem,
this
);
return
m_pChildAppSystemGroup->
Startup
();
}
void
CSteamApplication::Shutdown
()
{
m_pChildAppSystemGroup->
Shutdown
();
BaseClass::Shutdown
();
}
#
endif
Back
|
FazBrowse Home
|
New Git URL