summaryrefslogtreecommitdiff
path: root/utils/QCGenerator
diff options
context:
space:
mode:
Diffstat (limited to 'utils/QCGenerator')
-rw-r--r--utils/QCGenerator/CQCGenMain.cpp94
-rw-r--r--utils/QCGenerator/CQCGenMain.h54
-rw-r--r--utils/QCGenerator/QCGenerator.h33
-rw-r--r--utils/QCGenerator/main.cpp223
-rw-r--r--utils/QCGenerator/qcgenerator_launcher.vpc51
5 files changed, 455 insertions, 0 deletions
diff --git a/utils/QCGenerator/CQCGenMain.cpp b/utils/QCGenerator/CQCGenMain.cpp
new file mode 100644
index 0000000..fec3fb4
--- /dev/null
+++ b/utils/QCGenerator/CQCGenMain.cpp
@@ -0,0 +1,94 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Dialog for selecting game configurations
+//
+//=====================================================================================//
+
+#include <windows.h>
+
+#include <vgui/IVGui.h>
+#include <vgui/IInput.h>
+#include <vgui/ISystem.h>
+#include <vgui_controls/MessageBox.h>
+
+#include "matsys_controls/QCGenerator.h"
+#include "CQCGenMain.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+using namespace vgui;
+
+CQCGenMain *g_pCQCGenMain = NULL;
+
+class CModalPreserveMessageBox : public vgui::MessageBox
+{
+public:
+ CModalPreserveMessageBox(const char *title, const char *text, vgui::Panel *parent)
+ : vgui::MessageBox( title, text, parent )
+ {
+ m_PrevAppFocusPanel = vgui::input()->GetAppModalSurface();
+ }
+
+ ~CModalPreserveMessageBox()
+ {
+ vgui::input()->SetAppModalSurface( m_PrevAppFocusPanel );
+ }
+
+public:
+ vgui::VPANEL m_PrevAppFocusPanel;
+};
+
+//-----------------------------------------------------------------------------
+// Constructor
+//-----------------------------------------------------------------------------
+CQCGenMain::CQCGenMain( Panel *parent, const char *pszPath, const char *pszScene , const char *name ) : BaseClass( parent, name ), m_bChanged( false )
+{
+ Assert( !g_pCQCGenMain );
+ g_pCQCGenMain = this;
+
+ SetMinimizeButtonVisible( true );
+
+ SetSize( 846, 770 );
+ SetMinimumSize(846, 770);
+ char szTitle[MAX_PATH];
+ strcpy( szTitle, pszPath );
+ strcat( szTitle, "\\" );
+ strcat( szTitle, pszScene );
+ SetTitle( szTitle, true );
+
+ m_pQCGenerator = new CQCGenerator( this, pszPath, pszScene );
+}
+
+//-----------------------------------------------------------------------------
+// Destructor
+//-----------------------------------------------------------------------------
+CQCGenMain::~CQCGenMain()
+{
+ g_pCQCGenMain = NULL;
+}
+
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Kills the whole app on close
+//-----------------------------------------------------------------------------
+void CQCGenMain::OnClose( void )
+{
+ BaseClass::OnClose();
+ ivgui()->Stop();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Parse commands coming in from the VGUI dialog
+//-----------------------------------------------------------------------------
+void CQCGenMain::OnCommand( const char *command )
+{
+ BaseClass::OnCommand( command );
+}
+
+void CQCGenMain::OnRefresh()
+{
+ Repaint();
+}
+
diff --git a/utils/QCGenerator/CQCGenMain.h b/utils/QCGenerator/CQCGenMain.h
new file mode 100644
index 0000000..7953c2a
--- /dev/null
+++ b/utils/QCGenerator/CQCGenMain.h
@@ -0,0 +1,54 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#ifndef MDRIPPERMAIN_H
+#define MDRIPPERMAIN_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "matsys_controls/QCGenerator.h"
+#include <vgui_controls/Frame.h>
+#include <FileSystem.h>
+#include "vgui/IScheme.h"
+
+using namespace vgui;
+
+//-----------------------------------------------------------------------------
+// Purpose: Main dialog for media browser
+//-----------------------------------------------------------------------------
+class CQCGenMain : public Frame
+{
+ DECLARE_CLASS_SIMPLE( CQCGenMain, Frame );
+
+public:
+
+ CQCGenerator *m_pQCGenerator;
+ CQCGenMain(Panel *parent, const char *name, const char *pszMDParam, const char *pszCollisionParam );
+ virtual ~CQCGenMain();
+
+protected:
+
+ virtual void OnClose();
+ virtual void OnCommand( const char *command );
+
+private:
+
+ void SetGlobalConfig( const char *modDir );
+
+ vgui::ComboBox *m_pConfigCombo;
+ bool m_bChanged;
+ vgui::MenuBar *m_pMenuBar;
+ vgui::Panel *m_pClientArea;
+
+ MESSAGE_FUNC( OnRefresh, "refresh" );
+};
+
+
+extern CQCGenMain *g_pCQCGenMain;
+
+
+#endif // MDRIPPERMAIN_H
diff --git a/utils/QCGenerator/QCGenerator.h b/utils/QCGenerator/QCGenerator.h
new file mode 100644
index 0000000..7f34e5e
--- /dev/null
+++ b/utils/QCGenerator/QCGenerator.h
@@ -0,0 +1,33 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#ifndef ELEMENTVIEWER_H
+#define ELEMENTVIEWER_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+namespace vgui
+{
+ class ISurface;
+ class IVGui;
+ class IPanel;
+}
+
+class IFileSystem;
+//class IMaterialSystem;
+class IMatSystemSurface;
+
+/*
+extern IFileSystem *g_pFileSystem;
+extern IMaterialSystem *g_pMaterialSystem;
+extern IMatSystemSurface *g_pMatSystemSurface;
+extern vgui::ISurface *g_pVGuiSurface;
+extern vgui::IVGui *g_pVGui;
+extern vgui::IPanel *g_pVGuiPanel;
+*/
+#endif // ELEMENTVIEWER_H
diff --git a/utils/QCGenerator/main.cpp b/utils/QCGenerator/main.cpp
new file mode 100644
index 0000000..67c30dd
--- /dev/null
+++ b/utils/QCGenerator/main.cpp
@@ -0,0 +1,223 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Configuration utility
+//
+//===========================================================================//
+
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+
+#include <vgui/ILocalize.h>
+#include <vgui/ISurface.h>
+#include <vgui/IVGui.h>
+#include <vgui_controls/Panel.h>
+
+#include "appframework/tier3app.h"
+#include "tier0/icommandline.h"
+#include "inputsystem/iinputsystem.h"
+#include "matsys_controls/QCGenerator.h"
+#include "filesystem_init.h"
+#include "CQCGenMain.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+#define QCGENERATOR_MAIN_PATH_ID "MAIN"
+#define QCGENERATOR_WRITE_PATH "DEFAULT_WRITE_PATH"
+
+CQCGenMain *g_pMainFrame = 0;
+
+// Dummy window
+static WNDCLASS staticWndclass = { NULL };
+static ATOM staticWndclassAtom = 0;
+static HWND staticHwnd = 0;
+
+// List of our game configs, as read from the gameconfig.txt file
+//HANDLE g_dwChangeHandle = NULL;
+
+char pszPath[MAX_PATH];
+char pszScene[MAX_PATH];
+
+//-----------------------------------------------------------------------------
+// Purpose: Copy a string into a CUtlVector of characters
+//-----------------------------------------------------------------------------
+void UtlStrcpy( CUtlVector<char> &dest, const char *pSrc )
+{
+ dest.EnsureCount( (int) (strlen( pSrc ) + 1) );
+ Q_strncpy( dest.Base(), pSrc, dest.Count() );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Output : const char
+//-----------------------------------------------------------------------------
+const char *GetBaseDirectory( void )
+{
+ static char path[MAX_PATH] = {0};
+ if ( path[0] == 0 )
+ {
+ GetModuleFileName( (HMODULE)GetAppInstance(), path, sizeof( path ) );
+ Q_StripLastDir( path, sizeof( path ) ); // Get rid of the filename.
+ Q_StripTrailingSlash( path );
+ }
+ return path;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Setup all our VGUI info
+//-----------------------------------------------------------------------------
+void InitializeVGUI( void )
+{
+ vgui::ivgui()->SetSleep(false);
+
+ // Init the surface
+ vgui::Panel *pPanel = new vgui::Panel( NULL, "TopPanel" );
+ pPanel->SetVisible(true);
+
+ vgui::surface()->SetEmbeddedPanel(pPanel->GetVPanel());
+
+ // load the scheme
+ vgui::scheme()->LoadSchemeFromFile( "resource/sourcescheme.res", NULL );
+
+ // localization
+ g_pVGuiLocalize->AddFile( "resource/platform_%language%.txt");
+ g_pVGuiLocalize->AddFile( "resource/vgui_%language%.txt");
+ g_pVGuiLocalize->AddFile( "QCGenerator_english.txt");
+
+ // Start vgui
+ vgui::ivgui()->Start();
+
+ // add our main window
+ g_pMainFrame = new CQCGenMain( pPanel, pszPath, pszScene, "CQCGenMain" );
+
+ // show main window
+ g_pMainFrame->MoveToCenterOfScreen();
+ g_pMainFrame->Activate();
+ g_pMainFrame->SetSizeable( true );
+ g_pMainFrame->SetMenuButtonVisible( true );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Stop VGUI
+//-----------------------------------------------------------------------------
+void ShutdownVGUI( void )
+{
+ delete g_pMainFrame;
+}
+
+
+//-----------------------------------------------------------------------------
+// The application object
+//-----------------------------------------------------------------------------
+class CQCGeneratorApp : public CVguiSteamApp
+{
+ typedef CVguiSteamApp BaseClass;
+
+public:
+ // Methods of IApplication
+ virtual bool Create();
+ virtual bool PreInit();
+ virtual int Main();
+ virtual void PostShutdown();
+ virtual void Destroy() {}
+};
+
+DEFINE_WINDOWED_STEAM_APPLICATION_OBJECT( CQCGeneratorApp );
+
+
+//-----------------------------------------------------------------------------
+// The application object
+//-----------------------------------------------------------------------------
+bool CQCGeneratorApp::Create()
+{
+ AppSystemInfo_t appSystems[] =
+ {
+ { "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
+ { "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
+ { "", "" } // Required to terminate the list
+ };
+
+ return AddSystems( appSystems );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Entry point
+//-----------------------------------------------------------------------------
+bool CQCGeneratorApp::PreInit()
+{
+ if ( !BaseClass::PreInit() )
+ return false;
+
+ FileSystem_SetErrorMode( FS_ERRORMODE_AUTO );
+
+ // We only want to use the gameinfo.txt that is in the bin\vconfig directory.
+ char dirName[MAX_PATH];
+ Q_strncpy( dirName, GetBaseDirectory(), sizeof( dirName ) );
+ Q_AppendSlash( dirName, sizeof( dirName ) );
+ Q_strncat( dirName, "QCGenerator", sizeof( dirName ), COPY_ALL_CHARACTERS );
+
+ if ( !BaseClass::SetupSearchPaths( dirName, true, true ) )
+ {
+ ::MessageBox( NULL, "Error", "Unable to initialize file system\n", MB_OK );
+ return false;
+ }
+
+ // the "base dir" so we can scan mod name
+ g_pFullFileSystem->AddSearchPath( GetBaseDirectory(), QCGENERATOR_MAIN_PATH_ID );
+
+ // the main platform dir
+ g_pFullFileSystem->AddSearchPath( "platform", "PLATFORM", PATH_ADD_TO_HEAD );
+ g_pFullFileSystem->AddSearchPath( ".\\QCGenerator\\", QCGENERATOR_WRITE_PATH, PATH_ADD_TO_HEAD );
+
+ return true;
+}
+
+
+void CQCGeneratorApp::PostShutdown()
+{
+ BaseClass::PostShutdown();
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Entry point
+//-----------------------------------------------------------------------------
+int CQCGeneratorApp::Main()
+{
+ if ( CommandLine()->ParmValue( "-path" ) )
+ {
+ Q_strcpy( pszPath, CommandLine()->ParmValue( "-path" ) );
+ }
+ else
+ {
+ ::MessageBox( NULL, "Usage: QCGenerator.exe -path [path to smd files] -scene [name of scene]\n", "Error", MB_OK );
+ return 0;
+ }
+
+ if ( CommandLine()->ParmValue( "-scene" ) )
+ {
+ Q_strcpy( pszScene, CommandLine()->ParmValue( "-scene" ) );
+ }
+ else
+ {
+ ::MessageBox( NULL, "Usage: QCGenerator.exe -path [path to smd files] -scene [name of scene]\n", "Error", MB_OK );
+ return 0;
+ }
+
+ // Run app frame loop
+ InitializeVGUI();
+
+ // Run the app
+ while (vgui::ivgui()->IsRunning())
+ {
+ Sleep( 10 );
+ vgui::ivgui()->RunFrame();
+ }
+
+ ShutdownVGUI();
+
+ return 1;
+}
diff --git a/utils/QCGenerator/qcgenerator_launcher.vpc b/utils/QCGenerator/qcgenerator_launcher.vpc
new file mode 100644
index 0000000..dd73dd5
--- /dev/null
+++ b/utils/QCGenerator/qcgenerator_launcher.vpc
@@ -0,0 +1,51 @@
+//-----------------------------------------------------------------------------
+// QCGENERATOR_LAUNCHER.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+$Macro OUTBINNAME "QCGenerator"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE;$SRCDIR\vgui2\include;$SRCDIR\vgui2\controls;$SRCDIR\..\src\utils\common"
+ $EnableC++Exceptions "Yes (/EHsc)"
+ }
+
+ $Linker
+ {
+ $AdditionalDependencies "$BASE comctl32.lib Rpcrt4.lib dbghelp.lib"
+ }
+}
+
+$Project "QCGenerator_Launcher"
+{
+ $Folder "Source Files"
+ {
+ $File "CQCGenMain.cpp"
+ $File "main.cpp"
+ $File "$SRCDIR\public\vgui_controls\vgui_controls.cpp"
+ }
+
+ $Folder "Header Files"
+ {
+ $File "CQCGenMain.h"
+ $File "..\common\filesystem_tools.h"
+ }
+
+ $Folder "Link Libraries"
+ {
+ $DynamicFile "$SRCDIR\lib\public\appframework.lib"
+ $DynamicFile "$SRCDIR\lib\public\matsys_controls.lib"
+ $File "$SRCDIR\lib\common\sqlwrapper.lib"
+ $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $DynamicFile "$SRCDIR\lib\public\tier3.lib"
+ $DynamicFile "$SRCDIR\lib\public\vgui_controls.lib"
+ }
+}