summaryrefslogtreecommitdiff
path: root/utils/itemtest
diff options
context:
space:
mode:
Diffstat (limited to 'utils/itemtest')
-rw-r--r--utils/itemtest/itemtest.vpc73
-rw-r--r--utils/itemtest/itemtest_com.vpc102
-rw-r--r--utils/itemtest/itemtest_con.cpp237
-rw-r--r--utils/itemtest/itemtest_vgui.cpp333
-rw-r--r--utils/itemtest/itemtestapp.cpp704
-rw-r--r--utils/itemtest/itemtestapp.h86
-rw-r--r--utils/itemtest/res/itemtest.icobin0 -> 505462 bytes
-rw-r--r--utils/itemtest/res/itemtest.rc72
-rw-r--r--utils/itemtest/res/resource.h19
-rw-r--r--utils/itemtest/res/src/hat.icnsbin0 -> 90988 bytes
-rw-r--r--utils/itemtest/res/src/hat.icobin0 -> 134306 bytes
-rw-r--r--utils/itemtest/res/src/readme.txt5
-rw-r--r--utils/itemtest/res/src/testitem.pngbin0 -> 65811 bytes
-rw-r--r--utils/itemtest/res/src/testitem.psdbin0 -> 1287939 bytes
-rw-r--r--utils/itemtest/runexe.cpp52
-rw-r--r--utils/itemtest/runexe.h18
16 files changed, 1701 insertions, 0 deletions
diff --git a/utils/itemtest/itemtest.vpc b/utils/itemtest/itemtest.vpc
new file mode 100644
index 0000000..8b3a441
--- /dev/null
+++ b/utils/itemtest/itemtest.vpc
@@ -0,0 +1,73 @@
+//============ Copyright (c) Valve Corporation, All rights reserved. ==========
+//
+// Converts various input bitmap & geometry formats into standard
+// Valve formats, renames and places items in the proper directories
+// and calls vtex/studiomdl and can ZIP archive the results.
+//
+// Uses:
+//
+// itemtest_lib to do the work
+// itemtest_controls for VGUI
+//
+//=============================================================================
+
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+$Include "$SRCDIR\utils\itemtest_lib\itemtest_lib_support.vpc"
+
+$Configuration
+{
+ $Linker
+ {
+ $AdditionalDependencies "$BASE comctl32.lib odbc32.lib odbccp32.lib Rpcrt4.lib"
+ }
+}
+
+$Project "itemtest"
+{
+ $Folder "Source Files"
+ {
+ $File "itemtest_vgui.cpp"
+ $File "itemtestapp.cpp"
+
+ $Folder "External"
+ {
+ $File "$SRCDIR\public\interpolatortypes.cpp"
+ $File "$SRCDIR\public\movieobjects\movieobjects.cpp"
+ $File "$SRCDIR\public\vgui_controls\vgui_controls.cpp"
+ }
+ }
+
+ $Folder "Header Files"
+ {
+ $File "itemtestapp.h"
+ $Folder "External"
+ {
+ $File "$SRCDIR\public\interpolatortypes.h"
+ }
+ }
+
+ $Folder "Link Libraries"
+ {
+ $DynamicFile "$SRCDIR\lib\public\appframework.lib"
+ $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
+ $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
+ $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $DynamicFile "$SRCDIR\lib\public\tier3.lib"
+
+ $DynamicFile "$SRCDIR\lib\public\steam_api.lib"
+ $DynamicFile "$SRCDIR\lib\public\vtf.lib"
+ $DynamicFile "$SRCDIR\lib\public\itemtest_controls.lib"
+
+ $DynamicFile "$SRCDIR\lib\public\vgui_controls.lib"
+ }
+
+ $Folder "Resources" [$WIN32]
+ {
+ $File "res/itemtest.rc"
+ $File "res/itemtest.ico"
+ }
+}
diff --git a/utils/itemtest/itemtest_com.vpc b/utils/itemtest/itemtest_com.vpc
new file mode 100644
index 0000000..1bea97a
--- /dev/null
+++ b/utils/itemtest/itemtest_com.vpc
@@ -0,0 +1,102 @@
+//============ Copyright (c) Valve Corporation, All rights reserved. ==========
+//
+//=============================================================================
+
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+// Initially we link this as itemtest_com.exe, to avoid conflicting with itemtest.exe
+$Macro OUTBINNAME "itemtest_com"
+// Then we copy the result to itemtest.com so that the command-line version will be
+// launched first.
+$Macro FINAL_OUTBINNAME "itemtest.com"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
+$Include "$SRCDIR\utils\itemtest_lib\itemtest_lib_support.vpc"
+
+$Configuration
+{
+ $Linker
+ {
+ $AdditionalDependencies "$BASE comctl32.lib odbc32.lib odbccp32.lib Rpcrt4.lib"
+ }
+
+ // This is a special case... there is a name collision between game/bin/itemtest.com (this project)
+ // and game/bin/itemtest.exe, so we need a custom build event that doesn't try to copy the .map/.pdb
+ // for the .com into game/bin to avoid a race condition when doing parallel builds... maybe there's
+ // a better solution
+ $PostBuildEvent [!$ANALYZE]
+ {
+ $CommandLine "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$FINAL_OUTBINNAME $SRCDIR" "\n" \
+ "copy $QUOTE$(TargetDir)$QUOTE$(TargetFileName) $OUTBINDIR\$FINAL_OUTBINNAME" "\n" \
+ "if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
+ "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetName).pdb $SRCDIR" "\n" \
+ "copy $QUOTE$(TargetDir)$QUOTE$(TargetName).pdb $OUTBINDIR\$(TargetName).pdb" "\n" \
+ "if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
+ "goto BuildEventOK" "\n" \
+ ":BuildEventFailed" "\n" \
+ "echo *** ERROR! PostBuildStep FAILED for $(ProjectName)! COM is probably running. ***" "\n" \
+ "del /q $QUOTE$(TargetDir)$QUOTE$(TargetFileName)" "\n" \
+ "exit 1" "\n" \
+ ":BuildEventOK" "\n"
+
+ $Description "Publishing to $OUTBINDIR"
+ $ExcludedFromBuild "No"
+ }
+}
+
+$Configuration "Debug"
+{
+ $General
+ {
+ $OutputDirectory ".\Debug_itemtest_com"
+ $IntermediateDirectory ".\Debug_itemtest_com"
+ }
+}
+
+$Configuration "Release"
+{
+ $General
+ {
+ $OutputDirectory ".\Release_itemtest_com"
+ $IntermediateDirectory ".\Release_itemtest_com"
+ }
+}
+
+$Project "itemtest_com"
+{
+ $Folder "Source Files"
+ {
+ $File "itemtestapp.cpp"
+ $File "itemtest_con.cpp"
+ $File "runexe.cpp"
+
+ $Folder "External"
+ {
+ $File "$SRCDIR\public\interpolatortypes.cpp"
+ $File "$SRCDIR\public\movieobjects\movieobjects.cpp"
+ }
+ }
+
+ $Folder "Header Files"
+ {
+ $File "itemtestapp.h"
+ $File "runexe.h"
+ $Folder "External"
+ {
+ $File "$SRCDIR\public\interpolatortypes.h"
+ }
+ }
+
+ $Folder "Link Libraries"
+ {
+ $Lib appframework
+ $Lib bitmap
+ $Lib mathlib
+ $Lib tier2
+ $Lib tier3
+
+ $ImpLib steam_api
+ $Lib vtf
+ }
+}
diff --git a/utils/itemtest/itemtest_con.cpp b/utils/itemtest/itemtest_con.cpp
new file mode 100644
index 0000000..60c13af
--- /dev/null
+++ b/utils/itemtest/itemtest_con.cpp
@@ -0,0 +1,237 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+#include <windows.h>
+
+// Valve includes
+#include "itemtest/itemtest.h"
+#include "p4lib/ip4.h"
+#include "tier0/icommandline.h"
+
+
+// Local includes
+#include "itemtestapp.h"
+#include "runexe.h"
+
+
+// Last include
+#include <tier0/memdbgon.h>
+
+
+//=============================================================================
+//
+//=============================================================================
+class CItemTestConApp : public CItemTestApp
+{
+ typedef CItemTestApp BaseClass;
+
+public:
+ // Methods of IApplication
+ virtual bool Create();
+ virtual int Main();
+
+protected:
+ static bool DoSteamId();
+
+ static bool DoHelp();
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+DEFINE_CONSOLE_STEAM_APPLICATION_OBJECT( CItemTestConApp );
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestConApp::Create()
+{
+ AppSystemInfo_t appSystems[] =
+ {
+ { "", "" } // Required to terminate the list
+ };
+
+ if ( FindParam( kDev ) && !FindParam( kNoP4 ) )
+ {
+ AppModule_t p4Module = LoadModule( "p4lib.dll" );
+ AddSystem( p4Module, P4_INTERFACE_VERSION );
+ }
+
+ return AddSystems( appSystems );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool View( CAsset &asset )
+{
+ CUtlString sBinDir;
+ if ( !CItemUpload::GetBinDirectory( sBinDir ) )
+ {
+ Warning( "Cannot determine bin directory\n" );
+ return false;
+ }
+
+ CSmartPtr< CTargetMDL > pTargetMDL = asset.GetTargetMDL();
+ if ( !pTargetMDL.IsValid() )
+ {
+ Warning( "No target MDL\n" );
+ return false;
+ }
+
+ CUtlString sMdlPath;
+ if ( !pTargetMDL->GetOutputPath( sMdlPath ) )
+ {
+ Warning( "Cannot determine path to MDL\n" );
+ return false;
+ }
+
+ CFmtStrMax sHlmvCmd;
+
+ if ( CItemUpload::GetDevMode() )
+ {
+ sHlmvCmd.sprintf( "\"%s\\hlmv.exe\" \"%s\"", sBinDir.Get(), sMdlPath.Get() );
+ }
+ else
+ {
+ CUtlString sVProjectDir;
+ if ( CItemUpload::GetVProjectDir( sVProjectDir ) )
+ {
+ sHlmvCmd.sprintf( "\"%s\\hlmv.exe\" -allowdebug -game \"%s\" -nop4 \"%s\"", sBinDir.Get(), sVProjectDir.Get(), sMdlPath.Get() );
+ }
+ else
+ {
+ Warning( "Cannot determine VPROJECT (gamedir)\n" );
+ return false;
+ }
+ }
+
+ char szBinLaunchDir[ MAX_PATH ];
+ V_ExtractFilePath( sBinDir.String(), szBinLaunchDir, ARRAYSIZE( szBinLaunchDir ) );
+
+ return CItemUpload::RunCommandLine( sHlmvCmd.String(), szBinLaunchDir, false );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool Explore( CAsset &asset )
+{
+ CUtlString sBinDir;
+ if ( !CItemUpload::GetBinDirectory( sBinDir ) )
+ {
+ Warning( "Cannot determine bin directory\n" );
+ return false;
+ }
+
+ CUtlString sDir;
+ asset.GetAbsoluteDir( sDir, NULL, &asset );
+
+ char szBuf[ MAX_PATH ];
+ V_FixupPathName( szBuf, ARRAYSIZE( szBuf ), sDir.Get() );
+
+ char szBinLaunchDir[ MAX_PATH ];
+ V_ExtractFilePath( sBinDir.String(), szBinLaunchDir, ARRAYSIZE( szBinLaunchDir ) );
+
+ ShellExecute( NULL, "explore", NULL, NULL, szBuf, SW_SHOWNORMAL );
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CItemTestConApp::Main()
+{
+ if ( DoHelp() )
+ return 0;
+
+ if ( DoSteamId() )
+ return 0;
+
+ CItemUpload::InitManifest();
+
+ // If launched with -batch stay in console app and run from parameters specified on the command line only
+
+ const bool bListMats = FindParam( kListMats );
+
+ if ( bListMats || FindParam( kBatch ) )
+ {
+ CAssetTF assetTF;
+ if ( !ProcessCommandLine( &assetTF, bListMats ) )
+ return 1;
+
+ if ( !bListMats )
+ {
+ if ( !assetTF.Compile() )
+ {
+ Warning( "Error! Compile Failed\n" );
+ return 1;
+ }
+
+ Msg( "Compile OK!\n" );
+
+ if ( FindParam( kView ) )
+ {
+ View( assetTF );
+ }
+
+ if ( FindParam( kExplore ) )
+ {
+ Explore( assetTF );
+ }
+ }
+ }
+ else
+ {
+ // If launched without -batch then launch the .exe with the same name in the same directory as this .com executable
+ RunExe();
+ }
+
+ return 0;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestConApp::DoHelp()
+{
+ if ( !FindParam( kHelp ) )
+ return false;
+
+ PrintHelp();
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestConApp::DoSteamId()
+{
+ if ( !FindParam( kSteamId ) )
+ return false;
+
+ CUtlString sSteamId;
+
+ if ( CItemUpload::GetSteamId( sSteamId ) )
+ {
+ Msg( "%s\n", sSteamId.String() );
+ }
+ else
+ {
+ Warning( "Error! Couldn't determine SteamId\n" );
+ }
+
+ return true;
+}
+
diff --git a/utils/itemtest/itemtest_vgui.cpp b/utils/itemtest/itemtest_vgui.cpp
new file mode 100644
index 0000000..8db45a3
--- /dev/null
+++ b/utils/itemtest/itemtest_vgui.cpp
@@ -0,0 +1,333 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+#define WIN32_LEAN_AND_MEAN
+#include <Windows.h> // HINSTANCE
+
+
+// Valve includes
+#include "inputsystem/iinputsystem.h"
+#include "itemtest/itemtest.h"
+#include "itemtest/itemtest_controls.h"
+#include "p4lib/ip4.h"
+#include "tier0/icommandline.h"
+#include "vgui/ILocalize.h"
+#include "vgui/ISurface.h"
+#include "vgui/IVGui.h"
+#include "vgui_controls/consoledialog.h"
+#include "vgui_controls/MessageBox.h"
+#include "vgui_controls/Panel.h"
+
+
+// Local includes
+#include "itemtestapp.h"
+
+
+// Last include
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CConsoleDialogNew;
+SpewRetval_t ConsoleDialogSpewFunc( SpewType_t spewType, const tchar *pMsg );
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+static vgui::Panel *g_pTopPanel = NULL;
+static vgui::DHANDLE< CConsoleDialogNew > g_hConsoleDialog;
+static vgui::DHANDLE< vgui::Frame > g_hMainFrame;
+
+
+//=============================================================================
+//
+//=============================================================================
+class CItemTestVGUIApp : public CItemTestApp
+{
+ typedef CItemTestApp BaseClass;
+
+public:
+ virtual bool Create();
+ virtual int Main();
+
+ // Methods of IApplication
+ virtual bool PreInit();
+
+protected:
+ static vgui::Panel *InitializeVGUI();
+
+ static void ShutdownVGUI();
+
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CItemTestVGUIApp );
+
+
+//=============================================================================
+//
+//=============================================================================
+class CConsoleDialogNew : public vgui::CConsoleDialog
+{
+ DECLARE_CLASS_SIMPLE( CConsoleDialogNew, vgui::CConsoleDialog );
+
+public:
+ CConsoleDialogNew( vgui::Panel *pPanel, const char *pszName )
+ : CConsoleDialog( pPanel, pszName, false )
+ {
+ }
+
+ virtual void OnCommandSubmitted( const char *pszCommand )
+ {
+ if ( !V_stricmp( pszCommand, "quit" ) )
+ {
+ if ( g_hMainFrame )
+ g_hMainFrame->Close();
+
+ Close();
+ }
+ else if ( !V_stricmp( pszCommand, "help" ) )
+ {
+ __s_ApplicationObject.PrintHelp();
+ }
+ else
+ {
+ Warning( "Error! Unknown command \"%s\"\n", pszCommand );
+ }
+ }
+
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestVGUIApp::Create()
+{
+ AppSystemInfo_t appSystems[] =
+ {
+ { "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
+ { "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
+ { "", "" } // Required to terminate the list
+ };
+
+ if ( FindParam( kDev ) && !FindParam( kNoP4 ) )
+ {
+ AppModule_t p4Module = LoadModule( "p4lib.dll" );
+ AddSystem( p4Module, P4_INTERFACE_VERSION );
+ }
+
+ return AddSystems( appSystems );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestVGUIApp::PreInit()
+{
+ if ( !BaseClass::PreInit() )
+ return false;
+
+ CreateInterfaceFn factory = GetFactory();
+ return vgui::VGui_InitInterfacesList( "CVguiSteamApp", &factory, 1 );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CItemTestVGUIApp::Main()
+{
+ g_pTopPanel = InitializeVGUI();
+ if ( !g_pTopPanel )
+ return 1;
+
+ SpewOutputFunc( ConsoleDialogSpewFunc );
+
+ if ( !g_hMainFrame )
+ {
+ // add our main window
+ CItemUploadWizard *pItemUploadWizard = new CItemUploadWizard( g_pTopPanel, "Item Upload Wizard" );
+ if ( pItemUploadWizard )
+ {
+ g_hMainFrame = pItemUploadWizard;
+
+ CAssetTF &assetTF = pItemUploadWizard->Asset();
+
+ ProcessCommandLine( &assetTF, false );
+ pItemUploadWizard->UpdateGUI();
+ }
+ }
+
+ if ( !g_hConsoleDialog )
+ {
+ if ( g_pTopPanel )
+ {
+ CConsoleDialogNew *pConsoleDialog = g_hMainFrame ?
+ new CConsoleDialogNew( g_hMainFrame, "console" ) :
+ new CConsoleDialogNew( g_pTopPanel, "console" );
+
+ if ( pConsoleDialog )
+ {
+ g_hConsoleDialog = pConsoleDialog;
+ if ( !g_hMainFrame )
+ {
+ g_hMainFrame = g_hConsoleDialog;
+
+ g_hConsoleDialog->SetSize( 640, 480 );
+ g_hConsoleDialog->MoveToCenterOfScreen();
+ }
+ else
+ {
+ int nWide = 0;
+ int nTall = 0;
+ int nX = 0;
+ int nY = 0;
+
+ g_hMainFrame->GetBounds( nX, nY, nWide, nTall );
+
+ g_hConsoleDialog->SetSize( nWide, MAX( nTall / 3, 120 ) );
+ g_hConsoleDialog->SetPos( nX, nY + nTall + 3 );
+ }
+
+ g_hConsoleDialog->Activate();
+ g_hConsoleDialog->SetVisible( true );
+ g_hConsoleDialog->SetDeleteSelfOnClose( true );
+ g_hConsoleDialog->ColorPrint( Color( 255, 192, 0, 255 ), "\nNOTE" );
+ g_hConsoleDialog->Print( ": The only commands available are 'quit' and 'help'\n" );
+ }
+ }
+ }
+
+ if ( g_hMainFrame )
+ {
+ // show main window
+ g_hMainFrame->SetSizeable( true );
+ g_hMainFrame->SetMenuButtonVisible( true );
+ g_hMainFrame->MoveToCenterOfScreen();
+ g_hMainFrame->Activate();
+
+ // Run the app
+ while ( vgui::ivgui()->IsRunning() && g_hMainFrame )
+ {
+ vgui::ivgui()->RunFrame();
+ }
+ }
+
+ ShutdownVGUI();
+
+ return 0;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+vgui::Panel *CItemTestVGUIApp::InitializeVGUI()
+{
+ // Init the surface
+ vgui::Panel *pTopPanel = new vgui::Panel( NULL, "TopPanel" );
+ if ( !pTopPanel )
+ return NULL;
+
+ pTopPanel->SetVisible( true );
+
+ vgui::surface()->SetEmbeddedPanel( pTopPanel->GetVPanel() );
+
+ // load the scheme
+ vgui::scheme()->LoadSchemeFromFile( "resource/itemtest_scheme.res", NULL );
+
+ // localization
+ g_pVGuiLocalize->AddFile( "resource/platform_%language%.txt");
+ g_pVGuiLocalize->AddFile( "resource/vgui_%language%.txt" );
+
+ g_pVGuiLocalize->AddFile( "resource/itemtest_%language%.txt");
+ g_pVGuiLocalize->AddFile( "resource/itemtest_english.txt");
+
+ // Start vgui
+ vgui::ivgui()->Start();
+
+
+ return pTopPanel;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemTestVGUIApp::ShutdownVGUI()
+{
+ if ( g_hConsoleDialog )
+ g_hConsoleDialog->Close();
+
+ if ( g_hMainFrame )
+ g_hMainFrame->Close();
+
+ if ( !g_pTopPanel )
+ return;
+
+ delete g_pTopPanel;
+ g_pTopPanel = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Spew func
+//-----------------------------------------------------------------------------
+SpewRetval_t ConsoleDialogSpewFunc( SpewType_t spewType, const tchar *pMsg )
+{
+ vgui::CConsoleDialog *pConsole = g_hConsoleDialog;
+
+ if ( !pConsole )
+ return SPEW_CONTINUE;
+
+ OutputDebugString( pMsg );
+
+ switch( spewType )
+ {
+ case SPEW_ASSERT:
+ pConsole->ColorPrint( Color( 255, 192, 0, 255 ), pMsg );
+#ifdef _DEBUG
+ return SPEW_DEBUGGER;
+#else
+ return SPEW_CONTINUE;
+#endif
+
+ case SPEW_ERROR:
+ pConsole->ColorPrint( Color( 255, 0, 0, 255 ), pMsg );
+ break;
+
+ case SPEW_WARNING:
+ pConsole->ColorPrint( Color( 192, 192, 0, 255 ), pMsg );
+ break;
+
+ case SPEW_MESSAGE:
+ {
+ Color c = *GetSpewOutputColor();
+ if ( !V_stricmp( GetSpewOutputGroup(), "developer" ) )
+ {
+ pConsole->Print( pMsg );
+ }
+ else
+ {
+ pConsole->ColorPrint( c, pMsg );
+ }
+ }
+ break;
+ }
+
+ if ( vgui::ivgui()->IsRunning() && g_hMainFrame )
+ {
+ vgui::ivgui()->RunFrame();
+ }
+
+ return SPEW_CONTINUE;
+} \ No newline at end of file
diff --git a/utils/itemtest/itemtestapp.cpp b/utils/itemtest/itemtestapp.cpp
new file mode 100644
index 0000000..ae74077
--- /dev/null
+++ b/utils/itemtest/itemtestapp.cpp
@@ -0,0 +1,704 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+// Valve includes
+#include "filesystem.h"
+#include "itemtest/itemtest.h"
+#include "tier0/icommandline.h"
+#include "tier2/p4helpers.h"
+
+
+// Local includes
+#include "itemtestapp.h"
+
+
+// Last include
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+char CItemTestApp::s_szName[] = "itemtest";
+
+
+char CItemTestApp::s_szDesc[] =
+ "itemtest is a command line utility to assist with packaging data "
+ "intended to be submitted to Valve.";
+
+
+char *CItemTestApp::s_pszFlags[][4] = {
+ { "-h", "-help", NULL, "Print this information." },
+ { "-s", "-steamid", NULL, "Print the itemtest steam id for the current user or \"<unknown>\" and exit" },
+ { "-b", "-batch", NULL, "Run in batch mode, i.e. no GUI, all parameters must be specified on the command line." },
+ { "-c", "-class", "<class>", "Specify the class of the item. One of: demo, engineer, heavy, medic, pyro, scout, sniper, soldier, spy" },
+ { "-n", "-name", "<name>", "Specify the name of the item" },
+ { "-d", "-dev", NULL, "Turn on dev mode" },
+ { "-nop4", "-nop4", NULL, "If -dev mode is specified optionally turn off perforce. NOTE: Perforce is only enabled in dev mode." },
+ { "-as", "-autoskin", NULL, "Turn on auto skinning of the geometry to bip_head." },
+ { "-l", "-lod", "<file>", "Specify the LOD, can be specified multiple times, first is LOD0, 2nd is LOD1, etc.." },
+ { "-lm", "-listmats", NULL, "If some lod files are specified and this option is specified, the names of the materials found in the LOD files are printed to stdout and the program exits, all texture flags are ignored. The material names are the arguments needed to -mat" },
+ { "-m", "-mat", "<name>", "Specify a material. <name> is the name of the material from the geometry file" },
+ { "-mt", "-mattype", "<type>", "Category of previously specified material, one of: primary, secondary, duplicate_primary, duplicate_secondary" },
+ { "-t", "-tex", "<file>", "Specify a texture to use with the previously specified material" },
+ { "-tt", "-textype", "<type>", "Category of previously specified texture, one of: common, red, blue, normal" },
+ { "-at", "-alphatype", "<type>", "Category of alpha data of previously specified texture, one of: none, transparency, paintable, spec" },
+ { "-v", "-view", NULL, "Run hlmv on the compiled model if successful" },
+ { "-ex", "-explore", NULL, "Open explorer window on the compiled zip if successful" },
+ { "-o", "-output", "<file>", "Save output to a specific file" }
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestApp::PreInit()
+{
+ // This just has to go in the right scope so it can access kFlagsCount
+ COMPILE_TIME_ASSERT( kFlagsCount == ARRAYSIZE( s_pszFlags ) );
+
+ if ( !BaseClass::PreInit() )
+ return false;
+
+ MathLib_Init();
+
+ // Set Dev mode appropriately
+ DoDevMode();
+
+ CUtlString sSourceSDKPath, sSourceSDKBin;
+
+ {
+ CUtlString sSteamAppInstallLocation;
+
+ // See if we have to do special initialization because TF & the SourceSDK are configured oddly
+ // GetSourceSDKFromExe() will fail if it's not that specific configuration and so normal
+ // initialization will proceed in that case
+
+ // TODO: These are specific values for TF but hopefully this code will only be needed for TF & SourceSDK
+ const char *pszMod = "tf";
+ const int nAppId = 440;
+
+ if ( CItemUpload::GetSourceSDKFromExe( sSourceSDKPath, sSourceSDKBin ) && CItemUpload::GetSteamAppInstallLocation( sSteamAppInstallLocation, nAppId ) )
+ {
+ char szGameDir[ MAX_PATH ] = "";
+ V_ComposeFileName( sSteamAppInstallLocation.String(), pszMod, szGameDir, ARRAYSIZE( szGameDir ) );
+
+ if ( !SetupSearchPaths( szGameDir, true, true ) )
+ {
+ return false;
+ }
+ }
+ else if ( !SetupSearchPaths( NULL, false, true ) )
+ {
+ return false;
+ }
+ }
+
+ const char *pszGameInfoPath = GetGameInfoPath();
+
+ char szGameInfoParent[ MAX_PATH ] = "";
+
+ V_ExtractFilePath( pszGameInfoPath, szGameInfoParent, ARRAYSIZE( szGameInfoParent ) );
+ char szPlatformDir[ MAX_PATH ] = "";
+ V_ComposeFileName( szGameInfoParent, "platform", szPlatformDir, ARRAYSIZE( szPlatformDir ) );
+
+ g_pFullFileSystem->AddSearchPath( szPlatformDir, "PLATFORM" );
+
+ if ( !sSourceSDKPath.IsEmpty() )
+ {
+ V_ComposeFileName( sSourceSDKPath.String(), "platform", szPlatformDir, ARRAYSIZE( szPlatformDir ) );
+ g_pFullFileSystem->AddSearchPath( szPlatformDir, "PLATFORM" );
+ }
+
+ // This bit of hackery allows us to access files on the harddrive
+ g_pFullFileSystem->AddSearchPath( "", "LOCAL", PATH_ADD_TO_HEAD );
+
+ CreateInterfaceFn factory = GetFactory();
+ if ( !ConnectDataModel( factory ) )
+ return false;
+
+ const InitReturnVal_t nRetVal = InitDataModel();
+
+#ifdef _DEBUG
+
+ {
+ g_pFullFileSystem->PrintSearchPaths();
+
+ Msg( "// itemtest paths:\n" );
+
+ CUtlString sTmp;
+ if ( CItemUpload::GetVProjectDir( sTmp ) )
+ {
+ Msg( "// VProject: %s\n", sTmp.String() );
+ }
+
+ if ( CItemUpload::GetVMod( sTmp ) )
+ {
+ Msg( "// Mod: %s\n", sTmp.String() );
+ }
+
+ if ( CItemUpload::GetContentDir( sTmp ) )
+ {
+ Msg( "// Content: %s\n", sTmp.String() );
+ }
+
+ if ( CItemUpload::GetBinDirectory( sTmp ) )
+ {
+ Msg( "// Bin: %s\n", sTmp.String() );
+ }
+ }
+#endif // _DEBUG
+
+ return ( nRetVal == INIT_OK );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemTestApp::PostShutdown()
+{
+ ShutdownDataModel();
+ DisconnectDataModel();
+ BaseClass::PostShutdown();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemTestApp::DoDevMode()
+{
+ if ( FindParam( kDev ) )
+ {
+ CItemUpload::SetDevMode( true );
+
+ const bool bP4DLLExists = g_pFullFileSystem->FileExists( "p4lib.dll", "EXECUTABLE_PATH" );
+
+ // No p4 mode if specified on the command line or no p4lib.dll found
+ if ( !bP4DLLExists || FindParam( kNoP4 ) )
+ {
+ g_p4factory->SetDummyMode( true );
+
+ CItemUpload::SetP4( false );
+ }
+ else
+ {
+ CItemUpload::SetP4( true );
+ }
+
+ // Set the named changelist
+ g_p4factory->SetOpenFileChangeList( "itemtest Auto Checkout" );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemTestApp::ProcessCommandLine( CAsset *pAsset, bool bDoListMats )
+{
+ const char *pszName = ParmValue( kName );
+ if ( pszName )
+ {
+ pAsset->SetName( pszName );
+ }
+
+ CAssetTF *pAssetTF = dynamic_cast< CAssetTF * >( pAsset );
+ if ( pAssetTF )
+ {
+ const char *pszUserClass = ParmValue( kClass );
+ const char *pszClass = GetClassString( pszUserClass );
+
+ if ( pszClass )
+ {
+ pAssetTF->SetClass( pszClass );
+ }
+ }
+
+ const char *pszOutput = ParmValue( kOutput );
+ if ( pszOutput )
+ {
+ pAsset->SetArchivePath( pszOutput );
+ }
+ else
+ {
+ CUtlString sFileName;
+ pAsset->GetName( sFileName );
+
+ char pszWorkshopPath[ MAX_PATH ];
+ if ( g_pFullFileSystem->RelativePathToFullPath( "workshop", "GAME", pszWorkshopPath, sizeof(pszWorkshopPath) ) && !sFileName.IsEmpty() )
+ {
+ sFileName += ".zip";
+ V_ComposeFileName( pszWorkshopPath, sFileName, pszWorkshopPath, sizeof(pszWorkshopPath) );
+ pAsset->SetArchivePath( pszWorkshopPath );
+ }
+ }
+
+ pAsset->SetSkinToBipHead( FindParam( kAutoSkin ) > 0 );
+
+ ICommandLine *pCmdLine = CommandLine();
+ const int nParamCount = pCmdLine->ParmCount();
+
+ for ( int i = 0; i < nParamCount; ++i )
+ {
+ const char *pszFlag = pCmdLine->GetParm( i );
+ if ( !V_stricmp( pszFlag, s_pszFlags[kLod][kShortFlag] ) || !V_stricmp( pszFlag, s_pszFlags[kLod][kLongFlag] ) )
+ {
+ if ( i + 1 < nParamCount )
+ {
+ const char *pszLod = pCmdLine->GetParm( i + 1 );
+ pAsset->AddTargetDMX( pszLod );
+ }
+ else
+ {
+ Warning( "Error! Command line switch \"%s\" specified without parameter value\n", pszFlag );
+ }
+ }
+ }
+
+ if ( bDoListMats )
+ {
+ bool bRetVal = false;
+
+ if ( pAsset->TargetDMXCount() <= 0 )
+ {
+ Warning( "Error! %s specified but no no geometry files specified via %s\n", s_pszFlags[kListMats][kLongFlag], s_pszFlags[kLod][kLongFlag] );
+ }
+ else
+ {
+ const int nTargetVMTCount = pAsset->GetTargetVMTCount();
+
+ if ( nTargetVMTCount <= 0 )
+ {
+ Warning( "Error! %s specified but no materials found in specified LODs\n", s_pszFlags[kListMats][kLongFlag] );
+ }
+ else
+ {
+ CUtlString sTargetVMT;
+
+ for ( int i = 0; i < nTargetVMTCount; ++i )
+ {
+ pAsset->GetTargetVMT( i )->GetMaterialId( sTargetVMT );
+ Msg( "Material: %s\n", sTargetVMT.String() );
+ }
+
+ bRetVal = true;
+ }
+ }
+
+ return bRetVal;
+ }
+
+ CSmartPtr< CTargetVMT > pTargetVmt = NULL;
+ int nTexParmIndex = -1;
+ bool bTexNormal = false;
+
+ for ( int i = 0; i < nParamCount; ++i )
+ {
+ const char *pszFlag = pCmdLine->GetParm( i );
+ if ( !V_stricmp( pszFlag, s_pszFlags[kMat][kShortFlag] ) || !V_stricmp( pszFlag, s_pszFlags[kMat][kLongFlag] ) )
+ {
+ if ( i + 1 < nParamCount )
+ {
+ const char *pszMatName = pCmdLine->GetParm( i + 1 );
+ pTargetVmt = pAsset->FindOrAddMaterial( pszMatName, CItemUpload::Manifest()->GetDefaultMaterialType() );
+ nTexParmIndex = -1;
+ bTexNormal = false;
+ }
+ else
+ {
+ Warning( "Error! Command line switch \"%s\" specified without parameter value\n", pszFlag );
+ }
+ }
+ else if ( !V_stricmp( pszFlag, s_pszFlags[kMatType][kShortFlag] ) || !V_stricmp( pszFlag, s_pszFlags[kMatType][kLongFlag] ) )
+ {
+ if ( !pTargetVmt )
+ {
+ Warning( "Error! No -mat specified before \"%s\"\n", pszFlag );
+ continue;
+ }
+
+ const char *pszMatType = GetParm( i + 1 );
+ if ( !pszMatType )
+ {
+ Warning( "Error! Command line switch \"%s\" specified without parameter value\n", pszFlag );
+ continue;
+ }
+
+ bool bDuplicate = false;
+
+ if ( StringHasPrefix( pszMatType, "duplicate_" ) )
+ {
+ pszMatType += 10;
+ bDuplicate = true;
+ }
+ else if ( StringHasPrefix( pszMatType, "d" ) )
+ {
+ pszMatType += 1;
+ bDuplicate = true;
+ }
+
+ int nMatType = CTargetVMT::StringToMaterialType( pszMatType );
+ if ( nMatType != kInvalidMaterialType )
+ {
+ if ( bDuplicate )
+ {
+ pTargetVmt->SetDuplicate( nMatType );
+ }
+ else
+ {
+ pTargetVmt->SetMaterialType( nMatType );
+ }
+ }
+ else
+ {
+ Warning( "Error! Invalid Parameter Value: \"%s\" \"%s\", expected one of primary, secondary, duplicate_primary, duplicate_secondary\n", pszFlag, pszMatType );
+ }
+ }
+ else if ( !V_stricmp( pszFlag, s_pszFlags[kTex][kShortFlag] ) || !V_stricmp( pszFlag, s_pszFlags[kTex][kLongFlag] ) )
+ {
+ if ( !pTargetVmt )
+ {
+ Warning( "Error! No -mat specified before \"%s\"\n", pszFlag );
+ continue;
+ }
+
+ if ( pTargetVmt->GetDuplicate() )
+ {
+ Warning( "Error! Previous material specified as duplicate before \"%s\", ignoring\n", pszFlag );
+ continue;
+ }
+
+ const char *pszTex = GetParm( i + 1 );
+ if ( !pszTex )
+ {
+ Warning( "Error! Command line switch \"%s\" specified without parameter value\n", pszFlag );
+ continue;
+ }
+
+ nTexParmIndex = i + 1;
+ }
+ else if ( !V_stricmp( pszFlag, s_pszFlags[kTexType][kShortFlag] ) || !V_stricmp( pszFlag, s_pszFlags[kTexType][kLongFlag] ) )
+ {
+ if ( !pTargetVmt )
+ {
+ Warning( "Error! No -mat specified before \"%s\"\n", pszFlag );
+ continue;
+ }
+
+ if ( pTargetVmt->GetDuplicate() )
+ {
+ Warning( "Error! Previous material specified as duplicate before \"%s\", ignoring\n", pszFlag );
+ continue;
+ }
+
+ const char *pszTex = GetParm( nTexParmIndex );
+ if ( !pszTex )
+ {
+ Warning( "Error! No -tex specified before \"%s\"\n", pszFlag );
+ continue;
+ }
+
+ const char *pszTexType = GetParm( i + 1 );
+ if ( !pszTex )
+ {
+ Warning( "Error! Command line switch \"%s\" specified without parameter value\n", pszFlag );
+ continue;
+ }
+
+ if ( StringHasPrefix( pszTexType, "C" ) )
+ {
+ pTargetVmt->SetTargetVTF( "_color", pszTex ); // Comes from texture_types in manifest
+ }
+ else if ( StringHasPrefix( pszTexType, "N" ) )
+ {
+ pTargetVmt->SetTargetVTF( "_normal", pszTex ); // Comes from texture_types in manifest
+ bTexNormal = true;
+ }
+ else if ( StringHasPrefix( pszTexType, "R" ) )
+ {
+ pTargetVmt->SetTargetVTF( "_color", pszTex, CItemUpload::Manifest()->GetMaterialSkin( "red" ) ); // Comes from texture_types in manifest
+ }
+ else if ( StringHasPrefix( pszTexType, "B" ) )
+ {
+ pTargetVmt->SetTargetVTF( "_color", pszTex, CItemUpload::Manifest()->GetMaterialSkin( "blue" ) ); // Comes from texture_types in manifest
+ }
+ }
+ else if ( !V_stricmp( pszFlag, s_pszFlags[kAlphaType][kShortFlag] ) || !V_stricmp( pszFlag, s_pszFlags[kAlphaType][kLongFlag] ) )
+ {
+ if ( !pTargetVmt )
+ {
+ Warning( "Error! No -mat specified before \"%s\"\n", pszFlag );
+ continue;
+ }
+
+ if ( pTargetVmt->GetDuplicate() )
+ {
+ Warning( "Error! Previous material specified as duplicate before \"%s\", ignoring\n", pszFlag );
+ continue;
+ }
+
+ const char *pszTex = GetParm( nTexParmIndex );
+ if ( !pszTex )
+ {
+ Warning( "Error! No -tex specified before \"%s\"\n", pszFlag );
+ continue;
+ }
+
+ const char *pszTexType = GetParm( i + 1 );
+ if ( !pszTex )
+ {
+ Warning( "Error! Command line switch \"%s\" specified without parameter value\n", pszFlag );
+ continue;
+ }
+
+ if ( StringHasPrefix( pszTexType, "N" ) )
+ {
+ if ( bTexNormal )
+ {
+ pTargetVmt->SetNormalAlphaType( CTargetVMT::kNoNormalAlpha );
+ }
+ else
+ {
+ pTargetVmt->SetColorAlphaType( CTargetVMT::kNoColorAlpha );
+ }
+ }
+ else if ( StringHasPrefix( pszTexType, "T" ) )
+ {
+ if ( bTexNormal )
+ {
+ Warning( "Error! Command line switch \"%s\" \"%s\" specified after a \"normal\" texture, only applies to color textures\n", pszFlag, pszTexType );
+ continue;
+ }
+ else
+ {
+ pTargetVmt->SetColorAlphaType( CTargetVMT::kTransparency );
+ }
+ }
+ else if ( StringHasPrefix( pszTexType, "P" ) )
+ {
+ if ( bTexNormal )
+ {
+ Warning( "Error! Command line switch \"%s\" \"%s\" specified after a \"normal\" texture, only applies to color textures\n", pszFlag, pszTexType );
+ continue;
+ }
+ else
+ {
+ pTargetVmt->SetColorAlphaType( CTargetVMT::kPaintable );
+ }
+ }
+ else if ( StringHasPrefix( pszTexType, "S" ) )
+ {
+ if ( bTexNormal )
+ {
+ pTargetVmt->SetNormalAlphaType( CTargetVMT::kNormalSpecPhong );
+ }
+ else
+ {
+ pTargetVmt->SetColorAlphaType( CTargetVMT::kColorSpecPhong );
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemTestApp::PrintHelp()
+{
+ // TODO: Find with of current output device
+ static const int nLineLength = 79;
+
+ Msg( "\n" );
+ Msg( "\n" "NAME" "\n" );
+
+ CUtlString sLine = " ";
+ CUtlString sWord;
+ sLine += s_szName;
+
+ CFmtStr sFmt;
+ CFmtStr sIndent;
+
+ sFmt.sprintf( "%%%ds", sLine.Length() + 1 );
+ sIndent.sprintf( sFmt, " " );
+
+ for ( int i = 0; i < kFlagsCount; ++i )
+ {
+ const int nSpaceLeft = nLineLength - sLine.Length();
+
+ sWord = "[";
+ sWord += s_pszFlags[i][kShortFlag];
+ sWord += " | ";
+ sWord += s_pszFlags[i][kLongFlag];
+ if ( s_pszFlags[i][kArgDesc] )
+ {
+ sWord += " ";
+ sWord += s_pszFlags[i][kArgDesc];
+ }
+ sWord += "]";
+
+ const int nWordWidth = sWord.Length();
+
+ if ( nWordWidth > nSpaceLeft )
+ {
+ Msg( "%s\n", sLine.Get() );
+ sLine = sIndent;
+ }
+ else
+ {
+ sLine += " ";
+ }
+
+ sLine += sWord;
+ }
+
+ if ( sLine.Length() )
+ {
+ Msg( "%s\n", sLine.Get() );
+ }
+
+ Msg( "\n" "DESCRIPTION" "\n" );
+
+ sIndent = " ";
+ sLine = " "; // One less space than indent to start because space gets added below
+
+ CUtlVector< char *, CUtlMemory< char *, int > > outStrings;
+ const char *pszSeparators[] = { " ", "\t", "\n", "\r", "\v", "\f" };
+
+ V_SplitString2( s_szDesc, pszSeparators, ARRAYSIZE( pszSeparators ), outStrings );
+
+ for ( int j = 0; j < outStrings.Count(); ++j )
+ {
+ const int nSpaceLeft = nLineLength - sLine.Length();
+ const int nWordWidth = V_strlen( outStrings[j] ) + 1;
+
+ if ( nWordWidth > nSpaceLeft )
+ {
+ Msg( "%s\n", sLine.Get() );
+ sLine = sIndent;
+ }
+ else
+ {
+ sLine += " ";
+ }
+
+ sLine += outStrings[j];
+ }
+
+ if ( sLine.Length() )
+ {
+ Msg( "%s\n", sLine.Get() );
+ }
+
+ Msg( "\n" "OPTIONS" "\n" );
+
+ int nLineLen[ kFlagsCount ];
+ int nMaxLen = 0;
+
+ for ( int i = 0; i < kFlagsCount; ++i )
+ {
+ nLineLen[i] = 3; // Space prefix
+ nLineLen[i] += V_strlen( s_pszFlags[i][kShortFlag] ); // Short flag
+ nLineLen[i] += 3; // " | "
+ nLineLen[i] += V_strlen( s_pszFlags[i][kLongFlag] ); // Long flag
+ nLineLen[i] += s_pszFlags[i][kArgDesc] ? V_strlen( s_pszFlags[i][kArgDesc] ) + 1 : 0; // Optional parameter
+ nMaxLen = MAX( nMaxLen, nLineLen[i] );
+ }
+ nMaxLen += 2;
+
+ char szElipsis[ BUFSIZ ];
+ CFmtStr sFlags;
+
+ for ( int i = 0; i < kFlagsCount; ++i )
+ {
+ int nParmsLen = nMaxLen - nLineLen[i];
+ if ( nParmsLen % 2 == 0 )
+ {
+ V_snprintf( szElipsis, nParmsLen, ". . . . . . . . . . . . ." );
+ }
+ else
+ {
+ V_snprintf( szElipsis, nParmsLen, " . . . . . . . . . . . . ." );
+ }
+
+ sFmt.sprintf( " %%s | %%s%%s%%s %-s", szElipsis );
+ sFlags.sprintf( sFmt, s_pszFlags[i][kShortFlag], s_pszFlags[i][kLongFlag], s_pszFlags[i][kArgDesc] ? " " : "", s_pszFlags[i][kArgDesc] ? s_pszFlags[i][kArgDesc] : "" );
+
+ sLine = sFlags;
+
+ sFmt.sprintf( "%%%ds", sLine.Length() + 1 );
+ sIndent.sprintf( sFmt, " " );
+
+ V_SplitString2( s_pszFlags[i][kFlagDesc], pszSeparators, ARRAYSIZE( pszSeparators ), outStrings );
+ for ( int j = 0; j < outStrings.Count(); ++j )
+ {
+ const int nSpaceLeft = nLineLength - sLine.Length();
+ const int nWordWidth = V_strlen( outStrings[j] ) + 1;
+
+ if ( nWordWidth > nSpaceLeft )
+ {
+ Msg( "%s\n", sLine.Get() );
+ sLine = sIndent;
+ }
+ else
+ {
+ sLine += " ";
+ }
+
+ sLine += outStrings[j];
+ }
+
+ if ( sLine.Length() )
+ {
+ Msg( "%s\n", sLine.Get() );
+ }
+ }
+
+ Msg( "\n" );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CItemTestApp::FindParam( Flags_t nFlag )
+{
+ int nRet = CommandLine()->FindParm( s_pszFlags[nFlag][kShortFlag] );
+
+ if ( nRet )
+ return nRet;
+
+ return CommandLine()->FindParm( s_pszFlags[nFlag][kLongFlag] );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+const char *CItemTestApp::ParmValue( Flags_t nFlag )
+{
+ const char *pszParmValue = CommandLine()->ParmValue( s_pszFlags[nFlag][kShortFlag] );
+ if ( pszParmValue )
+ return pszParmValue;
+
+ return CommandLine()->ParmValue( s_pszFlags[nFlag][kLongFlag] );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+const char *CItemTestApp::GetParm( int nParmIndex )
+{
+ if ( nParmIndex >= 0 || nParmIndex < CommandLine()->ParmCount() )
+ return CommandLine()->GetParm( nParmIndex );
+
+ return NULL;
+} \ No newline at end of file
diff --git a/utils/itemtest/itemtestapp.h b/utils/itemtest/itemtestapp.h
new file mode 100644
index 0000000..cdd72f8
--- /dev/null
+++ b/utils/itemtest/itemtestapp.h
@@ -0,0 +1,86 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+#ifndef ITEMTESTAPP_H
+#define ITEMTESTAPP_H
+
+#if COMPILER_MSVC
+#pragma once
+#endif
+
+
+// Valve includes
+#include "appframework/tier3app.h"
+
+
+//-----------------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------------
+class CAsset;
+
+
+//=============================================================================
+//
+//=============================================================================
+class CItemTestApp : public CTier3SteamApp
+{
+ typedef CTier3SteamApp BaseClass;
+
+public:
+ // Methods of IApplication
+ virtual bool PreInit();
+ virtual void Destroy() {}
+ virtual void PostShutdown();
+
+ static void PrintHelp();
+
+protected:
+ enum Flags_t // Should match up to s_pszFlags
+ {
+ kHelp,
+ kSteamId,
+ kBatch,
+ kClass,
+ kName,
+ kDev,
+ kNoP4,
+ kAutoSkin,
+ kLod,
+ kListMats,
+ kMat,
+ kMatType,
+ kTex,
+ kTexType,
+ kAlphaType,
+ kView,
+ kExplore,
+ kOutput,
+ kFlagsCount // For compile time assert
+ };
+
+ static void DoDevMode();
+ static bool ProcessCommandLine( CAsset *pAsset, bool bDoListMats );
+ static int FindParam( Flags_t nFlag );
+ static const char *ParmValue( Flags_t nFlag );
+ static const char *GetParm( int nIndex );
+
+private:
+ enum FlagData_t
+ {
+ kShortFlag,
+ kLongFlag,
+ kArgDesc,
+ kFlagDesc
+ };
+
+ static char s_szName[];
+ static char s_szDesc[];
+ static char s_szExample[];
+ static char *s_pszFlags[][4];
+
+};
+
+
+#endif // ITEMTESTAPP_H
diff --git a/utils/itemtest/res/itemtest.ico b/utils/itemtest/res/itemtest.ico
new file mode 100644
index 0000000..bf3a3ea
--- /dev/null
+++ b/utils/itemtest/res/itemtest.ico
Binary files differ
diff --git a/utils/itemtest/res/itemtest.rc b/utils/itemtest/res/itemtest.rc
new file mode 100644
index 0000000..74ee390
--- /dev/null
+++ b/utils/itemtest/res/itemtest.rc
@@ -0,0 +1,72 @@
+//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
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ITEMTEST ICON DISCARDABLE "res/itemtest.ico"
+
+#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
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/utils/itemtest/res/resource.h b/utils/itemtest/res/resource.h
new file mode 100644
index 0000000..b767b29
--- /dev/null
+++ b/utils/itemtest/res/resource.h
@@ -0,0 +1,19 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by launcher_main.rc
+//
+#define IDI_ITEMTEST 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/utils/itemtest/res/src/hat.icns b/utils/itemtest/res/src/hat.icns
new file mode 100644
index 0000000..6ef9cee
--- /dev/null
+++ b/utils/itemtest/res/src/hat.icns
Binary files differ
diff --git a/utils/itemtest/res/src/hat.ico b/utils/itemtest/res/src/hat.ico
new file mode 100644
index 0000000..9dfcb5f
--- /dev/null
+++ b/utils/itemtest/res/src/hat.ico
Binary files differ
diff --git a/utils/itemtest/res/src/readme.txt b/utils/itemtest/res/src/readme.txt
new file mode 100644
index 0000000..268493a
--- /dev/null
+++ b/utils/itemtest/res/src/readme.txt
@@ -0,0 +1,5 @@
+This is the PSD source for the ICON as well as a a Mac and a PNG compressed
+Windows ICON.
+
+VS 2005 cannot handle PNG compressed icons so an uncompressed version
+is used in the parent directory for the time being.
diff --git a/utils/itemtest/res/src/testitem.png b/utils/itemtest/res/src/testitem.png
new file mode 100644
index 0000000..7f72d33
--- /dev/null
+++ b/utils/itemtest/res/src/testitem.png
Binary files differ
diff --git a/utils/itemtest/res/src/testitem.psd b/utils/itemtest/res/src/testitem.psd
new file mode 100644
index 0000000..adc25e3
--- /dev/null
+++ b/utils/itemtest/res/src/testitem.psd
Binary files differ
diff --git a/utils/itemtest/runexe.cpp b/utils/itemtest/runexe.cpp
new file mode 100644
index 0000000..72dd921
--- /dev/null
+++ b/utils/itemtest/runexe.cpp
@@ -0,0 +1,52 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+#include <Windows.h> // GetModuleFileName, ShellExecute
+
+
+// Valve includes
+#include "strtools.h"
+#include "tier0/icommandline.h"
+#include "tier1/utlstring.h"
+
+
+// Last include
+#include "tier0/memdbgon.h"
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void RunExe()
+{
+ CUtlString sParameters;
+ ICommandLine *pCmdLine = CommandLine();
+
+ for ( int i = 1; i < pCmdLine->ParmCount(); ++i )
+ {
+ if ( i > 1 )
+ {
+ sParameters += " ";
+ }
+
+ const char *pszParm = pCmdLine->GetParm( i );
+ if ( strchr( pszParm, ' ' ) || strchr( pszParm, '\t' ) )
+ {
+ sParameters += "\"";
+ sParameters += pszParm;
+ sParameters += "\"";
+ }
+ else
+ {
+ sParameters += pszParm;
+ }
+ }
+
+ // Invoked with no command-line args: run in GUI mode.
+ char szExeName[ MAX_PATH ];
+ GetModuleFileName( NULL, szExeName, ARRAYSIZE( szExeName ) );
+ V_SetExtension( szExeName, ".exe", ARRAYSIZE( szExeName ) );
+ ShellExecute( NULL, _T( "open" ), szExeName, sParameters.String(), NULL, SW_SHOWNORMAL );
+}
diff --git a/utils/itemtest/runexe.h b/utils/itemtest/runexe.h
new file mode 100644
index 0000000..00cde9a
--- /dev/null
+++ b/utils/itemtest/runexe.h
@@ -0,0 +1,18 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Function to call ShellExecute on the .exe version of the current executable
+// intended for a .com/.exe pair named the same thing to enable a hybrid
+// console/gui app
+//
+//=============================================================================
+
+#ifndef RUN_EXE_H
+#define RUN_EXE_H
+
+#if COMPILER_MSVC
+#pragma once
+#endif
+
+void RunExe();
+
+#endif // RUN_EXE_H