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.

217 lines
7.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // CONFIG.CPP
  4. //
  5. // Configuration Dialog
  6. //=====================================================================================//
  7. #include "vxconsole.h"
  8. CHAR g_xboxTargetName[MAX_XBOXNAMELEN];
  9. char g_localPath[MAX_PATH];
  10. char g_targetPath[MAX_PATH];
  11. BOOL g_clsOnConnect;
  12. BOOL g_loadSymbolsOnConnect;
  13. char g_xexTargetPath[MAX_PATH];
  14. BOOL g_alwaysAutoConnect;
  15. BOOL g_startMinimized;
  16. char g_installPath[MAX_PATH];
  17. BOOL g_captureDebugSpew_StartupState;
  18. //-----------------------------------------------------------------------------
  19. // ConfigDlg_LoadConfig
  20. //
  21. //-----------------------------------------------------------------------------
  22. void ConfigDlg_LoadConfig()
  23. {
  24. // get our config
  25. Sys_GetRegistryString( "xboxName", g_xboxTargetName, "", sizeof( g_xboxTargetName ) );
  26. Sys_GetRegistryString( "localPath", g_localPath, "u:\\dev\\game", sizeof( g_localPath ) );
  27. Sys_GetRegistryString( "targetPath", g_targetPath, "e:\\valve", sizeof( g_targetPath ) );
  28. Sys_GetRegistryString( "installPath", g_installPath, "\\\\fileserver\\user\\xbox\\xbox_orange", sizeof( g_installPath ) );
  29. Sys_GetRegistryInteger( "clearOnConnect", true, g_clsOnConnect );
  30. Sys_GetRegistryInteger( "loadSymbolsOnConnect", false, g_loadSymbolsOnConnect );
  31. Sys_GetRegistryInteger( "alwaysAutoConnect", false, g_alwaysAutoConnect );
  32. Sys_GetRegistryInteger( "startMinimized", false, g_startMinimized );
  33. Sys_GetRegistryInteger( "captureDebugSpew", true, g_captureDebugSpew_StartupState );
  34. }
  35. //-----------------------------------------------------------------------------
  36. // ConfigDlg_SaveConfig
  37. //
  38. //-----------------------------------------------------------------------------
  39. void ConfigDlg_SaveConfig()
  40. {
  41. // save config
  42. Sys_SetRegistryString( "xboxName", g_xboxTargetName );
  43. Sys_SetRegistryString( "localPath", g_localPath );
  44. Sys_SetRegistryString( "targetPath", g_targetPath );
  45. Sys_SetRegistryString( "installPath", g_installPath );
  46. Sys_SetRegistryInteger( "clearOnConnect", g_clsOnConnect );
  47. Sys_SetRegistryInteger( "loadSymbolsOnConnect", g_loadSymbolsOnConnect );
  48. Sys_SetRegistryInteger( "alwaysAutoConnect", g_alwaysAutoConnect );
  49. Sys_SetRegistryInteger( "startMinimized", g_startMinimized );
  50. Sys_SetRegistryInteger( "captureDebugSpew", g_captureDebugSpew_StartupState );
  51. // update
  52. SetMainWindowTitle();
  53. }
  54. //-----------------------------------------------------------------------------
  55. // ConfigDlg_Setup
  56. //
  57. //-----------------------------------------------------------------------------
  58. void ConfigDlg_Setup( HWND hWnd )
  59. {
  60. SetDlgItemText( hWnd,IDC_CONFIG_XBOXNAME, g_xboxTargetName );
  61. SetDlgItemText( hWnd,IDC_CONFIG_LOCALPATH, g_localPath );
  62. SetDlgItemText( hWnd,IDC_CONFIG_TARGETPATH, g_targetPath );
  63. SetDlgItemText( hWnd,IDC_CONFIG_INSTALLPATH, g_installPath );
  64. EnableWindow( GetDlgItem( hWnd, IDC_CONFIG_PING ), strlen( g_xboxTargetName ) > 0 );
  65. CheckDlgButton( hWnd, IDC_CONFIG_CLEARONCONNECT, g_clsOnConnect ? BST_CHECKED : BST_UNCHECKED );
  66. CheckDlgButton( hWnd, IDC_CONFIG_ALWAYSAUTOCONNECT, g_alwaysAutoConnect ? BST_CHECKED : BST_UNCHECKED );
  67. CheckDlgButton( hWnd, IDC_CONFIG_STARTMINIMIZED, g_startMinimized ? BST_CHECKED : BST_UNCHECKED );
  68. CheckDlgButton( hWnd, IDC_CONFIG_CAPTUREDEBUGSPEW, g_captureDebugSpew_StartupState ? BST_CHECKED : BST_UNCHECKED );
  69. }
  70. //-----------------------------------------------------------------------------
  71. // ConfigDlg_Ping
  72. //
  73. //-----------------------------------------------------------------------------
  74. BOOL ConfigDlg_Ping( HWND hwnd )
  75. {
  76. char xboxName[MAX_XBOXNAMELEN];
  77. BOOL canConnect;
  78. char* args[1];
  79. xboxName[0] = '\0';
  80. GetDlgItemText( hwnd, IDC_CONFIG_XBOXNAME, xboxName, MAX_XBOXNAMELEN );
  81. // ignore ping to current connection
  82. if ( !stricmp( g_xboxName, xboxName ) )
  83. {
  84. if ( g_connectedToXBox )
  85. {
  86. Sys_MessageBox( "Ping", "Already Connected To: '%s'", xboxName );
  87. return true;
  88. }
  89. }
  90. // terminate any current connection
  91. lc_disconnect( 0, NULL );
  92. // trial connect
  93. args[0] = xboxName;
  94. canConnect = lc_connect( 1, args );
  95. if ( !canConnect )
  96. Sys_MessageBox( "Ping FAILURE", "Could Not Connect To: %s", xboxName );
  97. else
  98. Sys_MessageBox( "Ping SUCCESS", "Connection Valid To: %s", g_xboxName );
  99. if ( canConnect )
  100. lc_disconnect( 0, NULL );
  101. return canConnect;
  102. }
  103. //-----------------------------------------------------------------------------
  104. // ConfigDlg_GetChanges
  105. //
  106. //-----------------------------------------------------------------------------
  107. bool ConfigDlg_GetChanges( HWND hwnd )
  108. {
  109. char remotePath[MAX_PATH];
  110. char localPath[MAX_PATH];
  111. char targetPath[MAX_PATH];
  112. char installPath[MAX_PATH];
  113. char xboxName[MAX_XBOXNAMELEN];
  114. char xexLocalPath[MAX_PATH];
  115. char xexTargetPath[MAX_PATH];
  116. xboxName[0] = '\0';
  117. remotePath[0] = '\0';
  118. localPath[0] = '\0';
  119. targetPath[0] = '\0';
  120. xexLocalPath[0] = '\0';
  121. xexTargetPath[0] = '\0';
  122. GetDlgItemText( hwnd, IDC_CONFIG_XBOXNAME, xboxName, MAX_XBOXNAMELEN );
  123. GetDlgItemText( hwnd, IDC_CONFIG_LOCALPATH, localPath, MAX_PATH );
  124. GetDlgItemText( hwnd, IDC_CONFIG_TARGETPATH, targetPath, MAX_PATH );
  125. GetDlgItemText( hwnd, IDC_CONFIG_INSTALLPATH, installPath, MAX_PATH );
  126. strcpy( g_localPath, localPath );
  127. Sys_NormalizePath( g_localPath, true );
  128. strcpy( g_targetPath, targetPath );
  129. Sys_NormalizePath( g_targetPath, true );
  130. strcpy( g_installPath, installPath );
  131. Sys_NormalizePath( g_installPath, true );
  132. strcpy( g_xboxTargetName, xboxName );
  133. g_clsOnConnect = IsDlgButtonChecked( hwnd, IDC_CONFIG_CLEARONCONNECT );
  134. g_loadSymbolsOnConnect = IsDlgButtonChecked( hwnd, IDC_CONFIG_LOADSYMBOLS );
  135. g_alwaysAutoConnect = IsDlgButtonChecked( hwnd, IDC_CONFIG_ALWAYSAUTOCONNECT );
  136. g_startMinimized = IsDlgButtonChecked( hwnd, IDC_CONFIG_STARTMINIMIZED );
  137. g_captureDebugSpew_StartupState = IsDlgButtonChecked( hwnd, IDC_CONFIG_CAPTUREDEBUGSPEW );
  138. // success
  139. return ( true );
  140. }
  141. //-----------------------------------------------------------------------------
  142. // ConfigDlg_Proc
  143. //
  144. //-----------------------------------------------------------------------------
  145. BOOL CALLBACK ConfigDlg_Proc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
  146. {
  147. switch ( message )
  148. {
  149. case WM_INITDIALOG:
  150. ConfigDlg_Setup( hwnd );
  151. return ( TRUE );
  152. case WM_COMMAND:
  153. switch ( LOWORD( wParam ) )
  154. {
  155. case IDC_CONFIG_PING:
  156. ConfigDlg_Ping( hwnd );
  157. break;
  158. case IDC_CONFIG_XBOXNAME:
  159. CHAR buff[MAX_XBOXNAMELEN];
  160. GetDlgItemText( hwnd, IDC_CONFIG_XBOXNAME, buff, sizeof( buff ) );
  161. EnableWindow( GetDlgItem( hwnd, IDC_CONFIG_PING ), strlen( buff ) > 0 );
  162. break;
  163. case IDC_OK:
  164. if ( !ConfigDlg_GetChanges( hwnd ) )
  165. break;
  166. case IDCANCEL:
  167. case IDC_CANCEL:
  168. EndDialog( hwnd, wParam );
  169. return ( TRUE );
  170. }
  171. break;
  172. }
  173. return ( FALSE );
  174. }
  175. //-----------------------------------------------------------------------------
  176. // ConfigDlg_Open
  177. //
  178. //-----------------------------------------------------------------------------
  179. void ConfigDlg_Open( void )
  180. {
  181. int result;
  182. result = DialogBox( g_hInstance, MAKEINTRESOURCE( IDD_CONFIG ), g_hDlgMain, ( DLGPROC )ConfigDlg_Proc );
  183. if ( LOWORD( result ) != IDC_OK )
  184. return;
  185. ConfigDlg_SaveConfig();
  186. }