Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
6.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // vkeyedit.cpp : Defines the class behaviors for the application.
  9. //
  10. #include "stdafx.h"
  11. #include "vkeyedit.h"
  12. #include "MainFrm.h"
  13. #include "vkeyeditDoc.h"
  14. #include "vkeyeditView.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. IFileSystem *g_pFileSystem;
  21. static CSysModule *g_pFileSystemModule = 0;
  22. CreateInterfaceFn g_FileSystemFactory = 0;
  23. CreateInterfaceFn GetFileSystemFactory()
  24. {
  25. return g_FileSystemFactory;
  26. }
  27. //-----------------------------------------------------------------------------
  28. // Loads, unloads the file system DLL
  29. //-----------------------------------------------------------------------------
  30. bool FileSystem_LoadFileSystemModule( void )
  31. {
  32. char *sFileSystemModuleName = "filesystem_stdio.dll";
  33. g_pFileSystemModule = Sys_LoadModule( sFileSystemModuleName );
  34. Assert( g_pFileSystemModule );
  35. if( !g_pFileSystemModule )
  36. {
  37. Error( "Unable to load %s", sFileSystemModuleName );
  38. return false;
  39. }
  40. g_FileSystemFactory = Sys_GetFactory( g_pFileSystemModule );
  41. if( !g_FileSystemFactory )
  42. {
  43. Error( "Unable to get filesystem factory" );
  44. return false;
  45. }
  46. g_pFileSystem = ( IFileSystem * )g_FileSystemFactory( FILESYSTEM_INTERFACE_VERSION, NULL );
  47. Assert( g_pFileSystem );
  48. if( !g_pFileSystem )
  49. {
  50. Error( "Unable to get IFileSystem interface from filesystem factory" );
  51. return false;
  52. }
  53. return true;
  54. }
  55. void FileSystem_UnloadFileSystemModule( void )
  56. {
  57. if ( !g_pFileSystemModule )
  58. return;
  59. g_FileSystemFactory = NULL;
  60. Sys_UnloadModule( g_pFileSystemModule );
  61. g_pFileSystemModule = 0;
  62. }
  63. //-----------------------------------------------------------------------------
  64. // Initialize, shutdown the file system
  65. //-----------------------------------------------------------------------------
  66. bool FileSystem_Init( )
  67. {
  68. if ( !g_pFileSystem )
  69. return false;
  70. if ( g_pFileSystem->Init() != INIT_OK )
  71. return false;
  72. g_pFileSystem->AddSearchPath( "", "root");
  73. return true;
  74. }
  75. void FileSystem_Shutdown( void )
  76. {
  77. g_pFileSystem->Shutdown();
  78. }
  79. /////////////////////////////////////////////////////////////////////////////
  80. // CVkeyeditApp
  81. BEGIN_MESSAGE_MAP(CVkeyeditApp, CWinApp)
  82. //{{AFX_MSG_MAP(CVkeyeditApp)
  83. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  84. // NOTE - the ClassWizard will add and remove mapping macros here.
  85. // DO NOT EDIT what you see in these blocks of generated code!
  86. //}}AFX_MSG_MAP
  87. // Standard file based document commands
  88. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  89. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  90. // Standard print setup command
  91. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  92. END_MESSAGE_MAP()
  93. /////////////////////////////////////////////////////////////////////////////
  94. // CVkeyeditApp construction
  95. CVkeyeditApp::CVkeyeditApp()
  96. {
  97. // TODO: add construction code here,
  98. // Place all significant initialization in InitInstance
  99. // Start up the file system
  100. //
  101. }
  102. CVkeyeditApp::~CVkeyeditApp()
  103. {
  104. // FileSystem_Shutdown();
  105. }
  106. /////////////////////////////////////////////////////////////////////////////
  107. // The one and only CVkeyeditApp object
  108. CVkeyeditApp theApp;
  109. /////////////////////////////////////////////////////////////////////////////
  110. // CVkeyeditApp initialization
  111. BOOL CVkeyeditApp::InitInstance()
  112. {
  113. AfxEnableControlContainer();
  114. // Standard initialization
  115. // If you are not using these features and wish to reduce the size
  116. // of your final executable, you should remove from the following
  117. // the specific initialization routines you do not need.
  118. #ifdef _AFXDLL
  119. Enable3dControls(); // Call this when using MFC in a shared DLL
  120. #else
  121. Enable3dControlsStatic(); // Call this when linking to MFC statically
  122. #endif
  123. // Change the registry key under which our settings are stored.
  124. // TODO: You should modify this string to be something appropriate
  125. // such as the name of your company or organization.
  126. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  127. LoadStdProfileSettings(); // Load standard INI file options (including MRU)
  128. // Register the application's document templates. Document templates
  129. // serve as the connection between documents, frame windows and views.
  130. CSingleDocTemplate* pDocTemplate;
  131. pDocTemplate = new CSingleDocTemplate(
  132. IDR_MAINFRAME,
  133. RUNTIME_CLASS(CVkeyeditDoc),
  134. RUNTIME_CLASS(CMainFrame), // main SDI frame window
  135. RUNTIME_CLASS(CVkeyeditView));
  136. AddDocTemplate(pDocTemplate);
  137. FileSystem_LoadFileSystemModule();
  138. FileSystem_Init();
  139. // Parse command line for standard shell commands, DDE, file open
  140. CCommandLineInfo cmdInfo;
  141. ParseCommandLine(cmdInfo);
  142. // Dispatch commands specified on the command line
  143. if (!ProcessShellCommand(cmdInfo))
  144. return FALSE;
  145. // The one and only window has been initialized, so show and update it.
  146. m_pMainWnd->ShowWindow(SW_SHOW);
  147. m_pMainWnd->UpdateWindow();
  148. return TRUE;
  149. }
  150. /////////////////////////////////////////////////////////////////////////////
  151. // CAboutDlg dialog used for App About
  152. class CAboutDlg : public CDialog
  153. {
  154. public:
  155. CAboutDlg();
  156. // Dialog Data
  157. //{{AFX_DATA(CAboutDlg)
  158. enum { IDD = IDD_ABOUTBOX };
  159. //}}AFX_DATA
  160. // ClassWizard generated virtual function overrides
  161. //{{AFX_VIRTUAL(CAboutDlg)
  162. protected:
  163. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  164. //}}AFX_VIRTUAL
  165. // Implementation
  166. protected:
  167. //{{AFX_MSG(CAboutDlg)
  168. // No message handlers
  169. //}}AFX_MSG
  170. DECLARE_MESSAGE_MAP()
  171. };
  172. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  173. {
  174. //{{AFX_DATA_INIT(CAboutDlg)
  175. //}}AFX_DATA_INIT
  176. }
  177. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  178. {
  179. CDialog::DoDataExchange(pDX);
  180. //{{AFX_DATA_MAP(CAboutDlg)
  181. //}}AFX_DATA_MAP
  182. }
  183. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  184. //{{AFX_MSG_MAP(CAboutDlg)
  185. // No message handlers
  186. //}}AFX_MSG_MAP
  187. END_MESSAGE_MAP()
  188. // App command to run the dialog
  189. void CVkeyeditApp::OnAppAbout()
  190. {
  191. CAboutDlg aboutDlg;
  192. aboutDlg.DoModal();
  193. }
  194. /////////////////////////////////////////////////////////////////////////////
  195. // CVkeyeditApp message handlers
  196. int CVkeyeditApp::ExitInstance()
  197. {
  198. // TODO: Add your specialized code here and/or call the base class
  199. return CWinApp::ExitInstance();
  200. }