summaryrefslogtreecommitdiff
path: root/utils/modelcheckin
diff options
context:
space:
mode:
Diffstat (limited to 'utils/modelcheckin')
-rw-r--r--utils/modelcheckin/modelcheckin.cpp79
-rw-r--r--utils/modelcheckin/modelcheckin.h56
-rw-r--r--utils/modelcheckin/modelcheckin.rc196
-rw-r--r--utils/modelcheckin/modelcheckin.vpc55
-rw-r--r--utils/modelcheckin/modelcheckindlg.cpp490
-rw-r--r--utils/modelcheckin/modelcheckindlg.h99
-rw-r--r--utils/modelcheckin/res/modelcheckin.icobin0 -> 1078 bytes
-rw-r--r--utils/modelcheckin/res/modelcheckin.rc213
-rw-r--r--utils/modelcheckin/resource.h35
-rw-r--r--utils/modelcheckin/stdafx.cpp15
-rw-r--r--utils/modelcheckin/stdafx.h33
11 files changed, 1071 insertions, 0 deletions
diff --git a/utils/modelcheckin/modelcheckin.cpp b/utils/modelcheckin/modelcheckin.cpp
new file mode 100644
index 0000000..80f99bb
--- /dev/null
+++ b/utils/modelcheckin/modelcheckin.cpp
@@ -0,0 +1,79 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// ModelCheckIn.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "ModelCheckIn.h"
+#include "ModelCheckInDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInApp
+
+BEGIN_MESSAGE_MAP(CModelCheckInApp, CWinApp)
+ //{{AFX_MSG_MAP(CModelCheckInApp)
+ // NOTE - the ClassWizard will add and remove mapping macros here.
+ // DO NOT EDIT what you see in these blocks of generated code!
+ //}}AFX_MSG
+ ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInApp construction
+
+CModelCheckInApp::CModelCheckInApp()
+{
+ // TODO: add construction code here,
+ // Place all significant initialization in InitInstance
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CModelCheckInApp object
+
+CModelCheckInApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInApp initialization
+
+BOOL CModelCheckInApp::InitInstance()
+{
+ // Standard initialization
+ // If you are not using these features and wish to reduce the size
+ // of your final executable, you should remove from the following
+ // the specific initialization routines you do not need.
+
+#ifdef _AFXDLL
+ Enable3dControls(); // Call this when using MFC in a shared DLL
+#else
+ Enable3dControlsStatic(); // Call this when linking to MFC statically
+#endif
+
+ CModelCheckInDlg dlg;
+ m_pMainWnd = &dlg;
+ int nResponse = dlg.DoModal();
+ if (nResponse == IDOK)
+ {
+ // TODO: Place code here to handle when the dialog is
+ // dismissed with OK
+ }
+ else if (nResponse == IDCANCEL)
+ {
+ // TODO: Place code here to handle when the dialog is
+ // dismissed with Cancel
+ }
+
+ // Since the dialog has been closed, return FALSE so that we exit the
+ // application, rather than start the application's message pump.
+ return FALSE;
+}
diff --git a/utils/modelcheckin/modelcheckin.h b/utils/modelcheckin/modelcheckin.h
new file mode 100644
index 0000000..be1ab14
--- /dev/null
+++ b/utils/modelcheckin/modelcheckin.h
@@ -0,0 +1,56 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// ModelCheckIn.h : main header file for the MODELCHECKIN application
+//
+
+#if !defined(AFX_MODELCHECKIN_H__05EE4104_1C0C_46E2_B5A2_C005630DCD19__INCLUDED_)
+#define AFX_MODELCHECKIN_H__05EE4104_1C0C_46E2_B5A2_C005630DCD19__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#ifndef __AFXWIN_H__
+ #error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInApp:
+// See ModelCheckIn.cpp for the implementation of this class
+//
+
+class CModelCheckInApp : public CWinApp
+{
+public:
+ CModelCheckInApp();
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CModelCheckInApp)
+ public:
+ virtual BOOL InitInstance();
+ //}}AFX_VIRTUAL
+
+// Implementation
+
+ //{{AFX_MSG(CModelCheckInApp)
+ // NOTE - the ClassWizard will add and remove member functions here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MODELCHECKIN_H__05EE4104_1C0C_46E2_B5A2_C005630DCD19__INCLUDED_)
diff --git a/utils/modelcheckin/modelcheckin.rc b/utils/modelcheckin/modelcheckin.rc
new file mode 100644
index 0000000..4c59b6f
--- /dev/null
+++ b/utils/modelcheckin/modelcheckin.rc
@@ -0,0 +1,196 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+ "#define _AFX_NO_OLE_RESOURCES\r\n"
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+ "\r\n"
+ "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+ "#ifdef _WIN32\r\n"
+ "LANGUAGE 9, 1\r\n"
+ "#pragma code_page(1252)\r\n"
+ "#endif //_WIN32\r\n"
+ "#include ""res\\ModelCheckIn.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
+ "#include ""afxres.rc"" // Standard components\r\n"
+ "#endif\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDR_MAINFRAME ICON DISCARDABLE "res\\ModelCheckIn.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_MODELCHECKIN_DIALOG DIALOGEX 0, 0, 221, 110
+STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_APPWINDOW
+CAPTION "Model Checker Inner"
+MENU IDR_MENU
+FONT 8, "MS Sans Serif"
+BEGIN
+ EDITTEXT IDC_EDIT_USERNAME,68,13,100,14,ES_AUTOHSCROLL
+ LTEXT "User Name",IDC_STATIC_USER_NAME,15,15,49,9
+ LTEXT "HL2 Game Directory",IDC_STATIC_HL2_ROOT,15,52,68,11
+ EDITTEXT IDC_EDIT_HL2_GAME_DIRECTORY,97,50,92,16,ES_AUTOHSCROLL
+ LTEXT "TF2 Game Directory",IDC_STATIC_TF2_ROOT,15,73,68,11
+ EDITTEXT IDC_EDIT_TF2_GAME_DIRECTORY,97,70,92,16,ES_AUTOHSCROLL
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "ModelCheckIn MFC Application\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "ModelCheckIn\0"
+ VALUE "LegalCopyright", "Copyright (C) 2001\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "ModelCheckIn.EXE\0"
+ VALUE "ProductName", "ModelCheckIn Application\0"
+ VALUE "ProductVersion", "1, 0, 0, 1\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_MODELCHECKIN_DIALOG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 214
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 103
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDR_MENU MENU DISCARDABLE
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "Check &Out...", ID_FILE_CHECK_OUT
+ MENUITEM "Check &In...", ID_FILE_CHECK_IN
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", ID_FILE_EXIT
+ END
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif //_WIN32
+#include "res\ModelCheckIn.rc2" // non-Microsoft Visual C++ edited resources
+#include "afxres.rc" // Standard components
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/utils/modelcheckin/modelcheckin.vpc b/utils/modelcheckin/modelcheckin.vpc
new file mode 100644
index 0000000..c411cc6
--- /dev/null
+++ b/utils/modelcheckin/modelcheckin.vpc
@@ -0,0 +1,55 @@
+//-----------------------------------------------------------------------------
+// MODELCHECKIN.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"
+ $PrecompiledHeaderFile "Debug/modelcheckin.pch"
+ }
+}
+
+$Project "ModelCheckIn"
+{
+ $Folder "Source Files"
+ {
+ -$File "$SRCDIR\public\tier0\memoverride.cpp"
+
+ $File "ModelCheckIn.cpp"
+ $File "ModelCheckIn.rc"
+ $File "ModelCheckInDlg.cpp"
+ $File "StdAfx.cpp"
+ {
+ $Configuration
+ {
+ $Compiler
+ {
+ $Create/UsePrecompiledHeader "Create Precompiled Header (/Yc)"
+ }
+ }
+ }
+ }
+
+ $Folder "Header Files"
+ {
+ $File "ModelCheckIn.h"
+ $File "ModelCheckInDlg.h"
+ $File "Resource.h"
+ $File "StdAfx.h"
+ }
+
+ $Folder "Resources"
+ {
+ $File "res\ModelCheckIn.ico"
+ $File "res\ModelCheckIn.rc2"
+ }
+}
diff --git a/utils/modelcheckin/modelcheckindlg.cpp b/utils/modelcheckin/modelcheckindlg.cpp
new file mode 100644
index 0000000..4987509
--- /dev/null
+++ b/utils/modelcheckin/modelcheckindlg.cpp
@@ -0,0 +1,490 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// ModelCheckInDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "ModelCheckIn.h"
+#include "ModelCheckInDlg.h"
+#include <direct.h>
+#include <sys/stat.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInDlg dialog
+
+CModelCheckInDlg::CModelCheckInDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CModelCheckInDlg::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CModelCheckInDlg)
+ m_HL2GameDirectory = _T("");
+ m_TF2GameDirectory = _T("");
+ m_UserName = _T("");
+ m_HL2Radio = -1;
+ m_TF2Radio = -1;
+ //}}AFX_DATA_INIT
+ // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+}
+
+void CModelCheckInDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CModelCheckInDlg)
+ DDX_Text(pDX, IDC_EDIT_HL2_GAME_DIRECTORY, m_HL2GameDirectory);
+ DDX_Text(pDX, IDC_EDIT_TF2_GAME_DIRECTORY, m_TF2GameDirectory);
+ DDX_Text(pDX, IDC_EDIT_USERNAME, m_UserName);
+ //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CModelCheckInDlg, CDialog)
+ //{{AFX_MSG_MAP(CModelCheckInDlg)
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ //}}AFX_MSG_MAP
+
+ ON_COMMAND(ID_FILE_CHECK_OUT, OnFileCheckOut)
+ ON_COMMAND(ID_FILE_CHECK_IN, OnFileCheckIn)
+ ON_COMMAND(ID_FILE_EXIT, OnFileExit)
+
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInDlg message handlers
+
+BOOL CModelCheckInDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ // Restore state
+ RestoreStateFromRegistry();
+ UpdateData( FALSE );
+
+ // Set the icon for this dialog. The framework does this automatically
+ // when the application's main window is not a dialog
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
+
+ // TODO: Add extra initialization here
+
+ return TRUE; // return TRUE unless you set the focus to a control
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+// to draw the icon. For MFC applications using the document/view model,
+// this is automatically done for you by the framework.
+
+void CModelCheckInDlg::OnPaint()
+{
+ if (IsIconic())
+ {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ }
+ else
+ {
+ CDialog::OnPaint();
+ }
+}
+
+// The system calls this to obtain the cursor to display while the user drags
+// the minimized window.
+HCURSOR CModelCheckInDlg::OnQueryDragIcon()
+{
+ return (HCURSOR) m_hIcon;
+}
+
+
+//-----------------------------------------------------------------------------
+// Resets our last used directory
+//-----------------------------------------------------------------------------
+
+void CModelCheckInDlg::ResetDirectoryEntry( CString &fullPath, char *pRegEntry )
+{
+ // reset the last directory...
+ CString temp = fullPath;
+ int i = temp.ReverseFind( '\\' );
+ int j = temp.ReverseFind( '/' );
+ if (i < j) i = j;
+ temp.SetAt(i, 0);
+
+ AfxGetApp()->WriteProfileString( MDL_CHECKOUT_REG_CLASS, pRegEntry, temp );
+}
+
+
+//-----------------------------------------------------------------------------
+// Stores state
+//-----------------------------------------------------------------------------
+
+void CModelCheckInDlg::StoreStateIntoRegistry( )
+{
+ AfxGetApp()->WriteProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_USER, m_UserName );
+ AfxGetApp()->WriteProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_HL2_PATH, m_HL2GameDirectory );
+ AfxGetApp()->WriteProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_TF2_PATH, m_TF2GameDirectory );
+}
+
+
+//-----------------------------------------------------------------------------
+// Restores state
+//-----------------------------------------------------------------------------
+
+void CModelCheckInDlg::RestoreStateFromRegistry( )
+{
+ m_UserName = AfxGetApp()->GetProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_USER, "" );
+ m_HL2GameDirectory = AfxGetApp()->GetProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_HL2_PATH, "u:/hl2/hl2" );
+ m_TF2GameDirectory = AfxGetApp()->GetProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_TF2_PATH, "u:/hl2/tf2" );
+}
+
+
+//-----------------------------------------------------------------------------
+// Extensions of all files related to the model file
+//-----------------------------------------------------------------------------
+
+static char* s_ppExtensions[] =
+{
+ ".dx7_2bone.vtx",
+ ".dx80.vtx",
+ ".phy",
+ ".mdl",
+ ""
+};
+
+
+static char* s_ppProjectDir[] =
+{
+ "$/HL2/release/dev/hl2/",
+ "$/TF2/release/dev/tf2/"
+};
+
+//-----------------------------------------------------------------------------
+// Checks it out/ checks it in baby
+//-----------------------------------------------------------------------------
+
+void CModelCheckInDlg::PerformCheckoutCommand( ProjectType_t project,
+ char const* pRelativeDir, char const* pDestPath, char const* pFileName )
+{
+ char error[1024];
+ char buf[1024];
+ int len = 0;
+
+ int currExtension;
+ for ( currExtension = 0; s_ppExtensions[currExtension][0]; ++currExtension )
+ {
+ // Check for the existence of the file in source safe...
+ sprintf( buf, "ss filetype %s%s/%s%s -O- -y%s\n",
+ s_ppProjectDir[project], pRelativeDir, pFileName, s_ppExtensions[currExtension],
+ (char const*)m_UserName );
+ int retVal = system( buf );
+ if (retVal > 0)
+ continue;
+
+ // It's there, try to check it out
+ sprintf( buf, "ss checkout %s%s/%s%s -GL%s -GWA -O- -y%s\n",
+ s_ppProjectDir[project], pRelativeDir, pFileName, s_ppExtensions[currExtension],
+ pDestPath, (char const*)m_UserName );
+ retVal = system( buf );
+ if (retVal > 0)
+ {
+ len += sprintf( &error[len], "*** SourceSafe error attempting to check out \"%s%s\"\n",
+ pFileName, s_ppExtensions[currExtension] );
+ }
+ }
+
+ if (len > 0)
+ {
+ MessageBox( error, "Error!" );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Checks it out/ checks it in baby
+//-----------------------------------------------------------------------------
+
+void CModelCheckInDlg::PerformCheckinCommand( ProjectType_t project,
+ char const* pRelativeDir, char const* pDestPath, char const* pFileName )
+{
+ char buf[1024];
+ char error[1024];
+ int len = 0;
+
+ int currExtension;
+ for ( currExtension = 0; s_ppExtensions[currExtension][0]; ++currExtension )
+ {
+ // Check for the existence of the file on disk. If it's not there, don't bother
+ sprintf( buf, "%s/%s%s", pDestPath, pFileName, s_ppExtensions[currExtension] );
+ struct _stat statbuf;
+ int result = _stat( buf, &statbuf );
+ if (result != 0)
+ continue;
+
+ // Check for the existence of the file in source safe...
+ sprintf( buf, "ss filetype %s%s/%s%s -O- -y%s\n",
+ s_ppProjectDir[project], pRelativeDir, pFileName, s_ppExtensions[currExtension],
+ (char const*)m_UserName );
+ int retVal = system( buf );
+ if (retVal > 0)
+ {
+ // Try to add the file to source safe...
+ sprintf( buf, "ss add %s%s/%s%s -GL%s -O- -y%s\n",
+ s_ppProjectDir[project], pRelativeDir, pFileName, s_ppExtensions[currExtension],
+ pDestPath, (char const*)m_UserName );
+ int retVal = system( buf );
+ if (retVal > 0)
+ {
+ len += sprintf( &error[len], "SourceSafe error attempting to add \"%s%s\"\n",
+ pFileName, s_ppExtensions[currExtension] );
+ }
+ }
+ else
+ {
+ // It's there, just check it in
+ sprintf( buf, "ss checkin %s%s/%s%s -GL%s -O- -y%s\n",
+ s_ppProjectDir[project], pRelativeDir, pFileName, s_ppExtensions[currExtension],
+ pDestPath, (char const*)m_UserName );
+ retVal = system( buf );
+ if (retVal > 0)
+ {
+ len += sprintf( &error[len], "SourceSafe error attempting to check in \"%s%s\"\n",
+ pFileName, s_ppExtensions[currExtension] );
+ }
+ }
+ }
+
+ if (len > 0)
+ {
+ MessageBox( error, "Error!" );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Fixes up a filename
+//-----------------------------------------------------------------------------
+
+static int FixupFileName( char const* pInFile, char* pOutBuf )
+{
+ if (!pInFile)
+ {
+ *pOutBuf = '\0';
+ return 0;
+ }
+
+ int len = strlen(pInFile);
+ for (int i = 0; i <= len; ++i)
+ {
+ pOutBuf[i] = tolower( pInFile[i] );
+ if (pOutBuf[i] == '\\')
+ pOutBuf[i] = '/';
+ }
+
+ // Make sure no trailing '/'
+ if (pOutBuf[len - 1] == '/')
+ pOutBuf[--len] = '\0';
+
+ return len;
+}
+
+
+//-----------------------------------------------------------------------------
+// Gets the relative file name
+//-----------------------------------------------------------------------------
+
+CModelCheckInDlg::ProjectType_t CModelCheckInDlg::ComputeRelativeFileName( char const* pInFile, char* pRelativeFile )
+{
+ // Depending on which project is selected, strip out the game directory
+ char tempIn[MAX_PATH];
+ char tempPath[MAX_PATH];
+
+ FixupFileName( pInFile, tempIn );
+
+ int len;
+ if (!m_HL2GameDirectory.IsEmpty())
+ {
+ len = FixupFileName( m_HL2GameDirectory, tempPath );
+ if (!strncmp( tempIn, m_HL2GameDirectory, len ))
+ {
+ strcpy( pRelativeFile, &tempIn[len+1] );
+ return PROJECT_HL2;
+ }
+ }
+
+ if (!m_TF2GameDirectory.IsEmpty())
+ {
+ len = FixupFileName( m_TF2GameDirectory, tempPath );
+ if (!strncmp( tempIn, m_TF2GameDirectory, len ))
+ {
+ strcpy( pRelativeFile, &tempIn[len+1] );
+ return PROJECT_TF2;
+ }
+ }
+
+ return PROJECT_ERROR;
+}
+
+
+//-----------------------------------------------------------------------------
+// Have we typed in anything for our user name?
+//-----------------------------------------------------------------------------
+
+bool CModelCheckInDlg::CheckInfo()
+{
+ if (m_UserName.IsEmpty())
+ {
+ MessageBox( "Please enter your user name.\n", "Error!" );
+ return false;
+ }
+
+ if (m_HL2GameDirectory.IsEmpty() && m_TF2GameDirectory.IsEmpty())
+ {
+ MessageBox( "Please enter the game directories for HL2 and/or TF2.\n", "Error!" );
+ return false;
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// Resets our last used directory
+//-----------------------------------------------------------------------------
+
+CModelCheckInDlg::ProjectType_t CModelCheckInDlg::GetFileNames( char const* pTitle,
+ char*& pRelativePath, char*& pFileName, char*& pDestPath )
+{
+ UpdateData( TRUE );
+
+ StoreStateIntoRegistry();
+
+ if (!CheckInfo())
+ return PROJECT_ERROR;
+
+ CFileDialog dlg( TRUE, ".mdl", "*.mdl", OFN_HIDEREADONLY,
+ "Model Files (*.mdl)|*.mdl||" );
+
+ // Set up initial paths
+ char pCwd[MAX_PATH];
+ _getcwd( pCwd, MAX_PATH );
+
+ // Setup the title and initial directory
+ CString temp = AfxGetApp()->GetProfileString( MDL_CHECKOUT_REG_CLASS,
+ MDL_CHECKOUT_REG_LAST_PATH, pCwd );
+ dlg.m_ofn.lpstrInitialDir = temp;
+ dlg.m_ofn.lpstrTitle = pTitle;
+
+ // Grab the data from the dialog...
+ if (dlg.DoModal() != IDOK)
+ return PROJECT_ERROR;
+
+ // Get the relative file name
+ static char relativeFile[MAX_PATH];
+ ProjectType_t projectType = ComputeRelativeFileName( dlg.GetPathName(), relativeFile );
+ if (projectType == PROJECT_ERROR)
+ {
+ char buf[MAX_PATH];
+ sprintf( buf, "%s\nwas not found under either game directory!\n", dlg.GetPathName() );
+ MessageBox( buf, "Error!" );
+ return PROJECT_ERROR;
+ }
+
+ // reset the last directory...
+ ResetDirectoryEntry( dlg.GetPathName(), MDL_CHECKOUT_REG_LAST_PATH );
+
+ // Split into relative file + path...
+ char* pSlash = strrchr( relativeFile, '/' );
+ if (pSlash)
+ {
+ *pSlash = 0;
+ pRelativePath = relativeFile;
+ pFileName = pSlash + 1;
+ }
+ else
+ {
+ pFileName = relativeFile;
+ pRelativePath = "";
+ }
+
+ // Remove extension
+ char* pExt = strchr( pFileName, '.' );
+ if (pExt)
+ *pExt = 0;
+
+ static char destPath[MAX_PATH];
+ FixupFileName( dlg.GetPathName(), destPath );
+ pSlash = strrchr( destPath, '/' );
+ if (pSlash)
+ *pSlash = 0;
+ else
+ destPath[0] = 0;
+ pDestPath = destPath;
+
+ return projectType;
+}
+
+
+
+//-----------------------------------------------------------------------------
+// Does checkout and check-in
+//-----------------------------------------------------------------------------
+
+void CModelCheckInDlg::OnFileCheckOut()
+{
+ char* pRelativePath;
+ char* pFileName;
+ char* pDestPath;
+ ProjectType_t projectType;
+ projectType = GetFileNames( "Select MDL file to check out...", pRelativePath,
+ pFileName, pDestPath );
+
+ if (projectType != PROJECT_ERROR)
+ {
+ PerformCheckoutCommand( projectType, pRelativePath, pDestPath, pFileName );
+ }
+}
+
+
+void CModelCheckInDlg::OnFileCheckIn()
+{
+ char* pRelativePath;
+ char* pFileName;
+ char* pDestPath;
+ ProjectType_t projectType;
+ projectType = GetFileNames( "Select MDL file to check in...", pRelativePath,
+ pFileName, pDestPath );
+
+ if (projectType != PROJECT_ERROR)
+ {
+ PerformCheckinCommand( projectType, pRelativePath, pDestPath, pFileName );
+ }
+}
+
+void CModelCheckInDlg::OnFileExit()
+{
+ PostQuitMessage(0);
+}
diff --git a/utils/modelcheckin/modelcheckindlg.h b/utils/modelcheckin/modelcheckindlg.h
new file mode 100644
index 0000000..bdacd48
--- /dev/null
+++ b/utils/modelcheckin/modelcheckindlg.h
@@ -0,0 +1,99 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// ModelCheckInDlg.h : header file
+//
+
+#if !defined(AFX_MODELCHECKINDLG_H__75541530_E85C_4FAB_8C76_6EE68353E2E2__INCLUDED_)
+#define AFX_MODELCHECKINDLG_H__75541530_E85C_4FAB_8C76_6EE68353E2E2__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+/////////////////////////////////////////////////////////////////////////////
+// CModelCheckInDlg dialog
+
+class CModelCheckInDlg : public CDialog
+{
+// Construction
+public:
+ CModelCheckInDlg(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ //{{AFX_DATA(CModelCheckInDlg)
+ enum { IDD = IDD_MODELCHECKIN_DIALOG };
+ CString m_HL2GameDirectory;
+ CString m_TF2GameDirectory;
+ CString m_UserName;
+ int m_HL2Radio;
+ int m_TF2Radio;
+ //}}AFX_DATA
+
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CModelCheckInDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ HICON m_hIcon;
+
+ // Generated message map functions
+ //{{AFX_MSG(CModelCheckInDlg)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ //}}AFX_MSG
+
+ afx_msg void OnFileCheckIn();
+ afx_msg void OnFileCheckOut();
+ afx_msg void OnFileExit();
+
+ DECLARE_MESSAGE_MAP()
+
+private:
+ enum ProjectType_t
+ {
+ PROJECT_ERROR = -1,
+ PROJECT_HL2 = 0,
+ PROJECT_TF2
+ };
+
+ bool CheckInfo();
+ bool SetCurrentSSProject( ProjectType_t project, char const* pRelativeDir );
+ ProjectType_t ComputeRelativeFileName( char const* pInFile, char* pRelativeFile );
+
+ void StoreStateIntoRegistry( );
+ void RestoreStateFromRegistry( );
+
+ ProjectType_t GetFileNames( char const* pTitle, char*& pRelativePath,
+ char*& pFileName, char*& pDestPath );
+
+ void ResetDirectoryEntry( CString &fullPath, char *pRegEntry );
+ void PerformCheckoutCommand( ProjectType_t project,
+ char const* pRelativeDir, char const* pDestPath, char const* pFileName );
+ void PerformCheckinCommand( ProjectType_t project,
+ char const* pRelativeDir, char const* pDestPath, char const* pFileName );
+};
+
+//-----------------------------------------------------------------------------
+// registry info
+//-----------------------------------------------------------------------------
+
+#define MDL_CHECKOUT_REG_CLASS "HKEY_CURRENT_USER\\SOFTWARE\\Valve\\MDLCheckOut"
+#define MDL_CHECKOUT_REG_LAST_PATH "Path"
+#define MDL_CHECKOUT_REG_USER "User"
+#define MDL_CHECKOUT_REG_HL2_PATH "HL2"
+#define MDL_CHECKOUT_REG_TF2_PATH "TF2"
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MODELCHECKINDLG_H__75541530_E85C_4FAB_8C76_6EE68353E2E2__INCLUDED_)
diff --git a/utils/modelcheckin/res/modelcheckin.ico b/utils/modelcheckin/res/modelcheckin.ico
new file mode 100644
index 0000000..7eef0bc
--- /dev/null
+++ b/utils/modelcheckin/res/modelcheckin.ico
Binary files differ
diff --git a/utils/modelcheckin/res/modelcheckin.rc2 b/utils/modelcheckin/res/modelcheckin.rc2
new file mode 100644
index 0000000..f112c46
--- /dev/null
+++ b/utils/modelcheckin/res/modelcheckin.rc2
@@ -0,0 +1,13 @@
+//
+// MODELCHECKIN.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+ #error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/utils/modelcheckin/resource.h b/utils/modelcheckin/resource.h
new file mode 100644
index 0000000..8ca67f6
--- /dev/null
+++ b/utils/modelcheckin/resource.h
@@ -0,0 +1,35 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by ModelCheckIn.rc
+//
+#define IDD_MODELCHECKIN_DIALOG 102
+#define IDR_MAINFRAME 128
+#define IDR_MENU 129
+#define IDC_EDIT_USERNAME 1000
+#define IDC_STATIC_USER_NAME 1001
+#define IDC_RADIO_TF2 1004
+#define IDC_STATIC_HL2_ROOT 1005
+#define IDC_EDIT_HL2_GAME_DIRECTORY 1006
+#define IDC_STATIC_TF2_ROOT 1007
+#define IDC_EDIT_TF2_GAME_DIRECTORY 1008
+#define ID_FILE_CHECK_OUT 32771
+#define ID_FILE_CHECK_IN 32772
+#define ID_FILE_EXIT 32773
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 130
+#define _APS_NEXT_COMMAND_VALUE 32774
+#define _APS_NEXT_CONTROL_VALUE 1007
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/utils/modelcheckin/stdafx.cpp b/utils/modelcheckin/stdafx.cpp
new file mode 100644
index 0000000..8762e64
--- /dev/null
+++ b/utils/modelcheckin/stdafx.cpp
@@ -0,0 +1,15 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// stdafx.cpp : source file that includes just the standard includes
+// ModelCheckIn.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+
+
diff --git a/utils/modelcheckin/stdafx.h b/utils/modelcheckin/stdafx.h
new file mode 100644
index 0000000..fd3e556
--- /dev/null
+++ b/utils/modelcheckin/stdafx.h
@@ -0,0 +1,33 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__E1BDB0EE_61CC_4BD0_BD80_5B466703FB31__INCLUDED_)
+#define AFX_STDAFX_H__E1BDB0EE_61CC_4BD0_BD80_5B466703FB31__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h> // MFC core and standard components
+#include <afxext.h> // MFC extensions
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h> // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__E1BDB0EE_61CC_4BD0_BD80_5B466703FB31__INCLUDED_)