summaryrefslogtreecommitdiff
path: root/utils/itemtest_controls
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/itemtest_controls
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/itemtest_controls')
-rw-r--r--utils/itemtest_controls/dualpanellist.cpp589
-rw-r--r--utils/itemtest_controls/dualpanellist.h144
-rw-r--r--utils/itemtest_controls/finalsubpanel.cpp410
-rw-r--r--utils/itemtest_controls/globalsubpanel.cpp196
-rw-r--r--utils/itemtest_controls/itemtest_controls.cpp1759
-rw-r--r--utils/itemtest_controls/itemtest_controls.vpc36
6 files changed, 3134 insertions, 0 deletions
diff --git a/utils/itemtest_controls/dualpanellist.cpp b/utils/itemtest_controls/dualpanellist.cpp
new file mode 100644
index 0000000..44b63bc
--- /dev/null
+++ b/utils/itemtest_controls/dualpanellist.cpp
@@ -0,0 +1,589 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+// Valve includes
+#include "tier1/KeyValues.h"
+
+#include "vgui/MouseCode.h"
+#include "vgui/IInput.h"
+#include "vgui/IScheme.h"
+#include "vgui/ISurface.h"
+
+#include "vgui_controls/EditablePanel.h"
+#include "vgui_controls/ScrollBar.h"
+#include "vgui_controls/Label.h"
+#include "vgui_controls/Button.h"
+#include "vgui_controls/Controls.h"
+
+
+// Local includes
+#include "dualpanellist.h"
+
+
+// Last include
+#include "tier0/memdbgon.h"
+
+
+//=============================================================================
+//
+//=============================================================================
+CDualPanelList::CDualPanelList( vgui::Panel *pParent, char const *pszPanelName )
+: vgui::Panel( pParent, pszPanelName )
+, m_pScrollBar( NULL )
+{
+ SetBounds( 0, 0, 100, 100 );
+
+ if ( false )
+ {
+ m_pScrollBar = new vgui::ScrollBar( this, "CDualPanelListVScroll", true );
+ m_pScrollBar->AddActionSignalTarget( this );
+ }
+
+ m_pPanelEmbedded = new vgui::EditablePanel( this, "PanelListEmbedded" );
+ m_pPanelEmbedded->SetBounds( 0, 0, 20, 20 );
+ m_pPanelEmbedded->SetPaintBackgroundEnabled( false );
+ m_pPanelEmbedded->SetPaintBorderEnabled( false );
+
+ m_iFirstColumnWidth = 100; // default width
+ m_nNumColumns = 1; // 1 column by default
+
+ if ( false && IsProportional() )
+ {
+ m_iDefaultHeight = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), DEFAULT_HEIGHT );
+ m_iPanelBuffer = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), PANELBUFFER );
+ }
+ else
+ {
+ m_iDefaultHeight = DEFAULT_HEIGHT;
+ m_iPanelBuffer = PANELBUFFER;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CDualPanelList::~CDualPanelList()
+{
+ // free data from table
+ DeleteAllItems();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::SetVerticalBufferPixels( int buffer )
+{
+ m_iPanelBuffer = buffer;
+ InvalidateLayout();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::ComputeVPixelsNeeded()
+{
+ int iCurrentItem = 0;
+ int iLargestH = 0;
+
+ int nPixels = 0;
+ for ( int i = 0; i < m_SortedItems.Count(); i++ )
+ {
+ Panel *pPanel = m_DataItems[ m_SortedItems[i] ].panel;
+ if ( !pPanel || !pPanel->IsVisible() )
+ continue;
+
+ if ( pPanel->IsLayoutInvalid() )
+ {
+ pPanel->InvalidateLayout( true );
+ }
+
+ int iCurrentColumn = iCurrentItem % m_nNumColumns;
+
+ int w, h;
+ pPanel->GetSize( w, h );
+
+ if ( iLargestH < h )
+ iLargestH = h;
+
+ if ( iCurrentColumn == 0 )
+ nPixels += m_iPanelBuffer; // add in buffer. between rows.
+
+ if ( iCurrentColumn >= m_nNumColumns - 1 )
+ {
+ nPixels += iLargestH;
+ iLargestH = 0;
+ }
+
+ iCurrentItem++;
+ }
+
+ // Add in remaining largest height
+ nPixels += iLargestH;
+
+ nPixels += m_iPanelBuffer; // add in buffer below last item
+
+ /*
+ nPixels = 0;
+ for ( int i = 0; i < m_SortedItems.Count(); ++i )
+ {
+ Panel *pPanel = m_DataItems[ m_SortedItems[i] ].panel;
+ if ( !pPanel )
+ continue;
+
+ int nWide = 0;
+ int nHeight = 0;
+ pPanel->GetSize( nWide, nHeight );
+
+ nPixels += nHeight;
+ }
+ */
+
+ return nPixels;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+vgui::Panel *CDualPanelList::GetCellRenderer( int row )
+{
+ if ( !m_SortedItems.IsValidIndex(row) )
+ return NULL;
+
+ Panel *panel = m_DataItems[ m_SortedItems[row] ].panel;
+ return panel;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::AddItem( vgui::Panel *labelPanel, vgui::Panel *panel)
+{
+ Assert(panel);
+
+ if ( labelPanel )
+ {
+ labelPanel->SetParent( m_pPanelEmbedded );
+ }
+
+ panel->SetParent( m_pPanelEmbedded );
+
+ int itemID = m_DataItems.AddToTail();
+ CDataItem &newitem = m_DataItems[itemID];
+ newitem.labelPanel = labelPanel;
+ newitem.panel = panel;
+ m_SortedItems.AddToTail(itemID);
+
+ InvalidateLayout();
+ return itemID;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::GetItemCount() const
+{
+ return m_DataItems.Count();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::GetItemIDFromRow( int nRow ) const
+{
+ if ( nRow < 0 || nRow >= GetItemCount() )
+ return m_DataItems.InvalidIndex();
+
+ return m_SortedItems[ nRow ];
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::FirstItem() const
+{
+ return m_DataItems.Head();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::NextItem( int nItemID ) const
+{
+ return m_DataItems.Next( nItemID );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::InvalidItemID() const
+{
+ return m_DataItems.InvalidIndex();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+vgui::Panel *CDualPanelList::GetItemLabel(int nItemID)
+{
+ if ( !m_DataItems.IsValidIndex( nItemID ) )
+ return NULL;
+
+ return m_DataItems[nItemID].labelPanel;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+vgui::Panel *CDualPanelList::GetItemPanel( int nItemID )
+{
+ if ( !m_DataItems.IsValidIndex( nItemID ) )
+ return NULL;
+
+ return m_DataItems[nItemID].panel;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CDualPanelList::IsItemVisible( int nItemID ) const
+{
+ if ( !m_DataItems.IsValidIndex( nItemID ) )
+ return true;
+
+ return m_DataItems[nItemID].IsVisible();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::SetItemVisible( int nItemID, bool bVisible )
+{
+ if ( !m_DataItems.IsValidIndex( nItemID ) )
+ return;
+
+ m_DataItems[nItemID].SetVisible( bVisible );
+
+ InvalidateLayout();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::RemoveItem( int nItemID )
+{
+ if ( !m_DataItems.IsValidIndex( nItemID ) )
+ return;
+
+ CDataItem &item = m_DataItems[nItemID];
+ if ( item.panel )
+ {
+ item.panel->MarkForDeletion();
+ }
+
+ if ( item.labelPanel )
+ {
+ item.labelPanel->MarkForDeletion();
+ }
+
+ m_DataItems.Remove( nItemID );
+ m_SortedItems.FindAndRemove( nItemID );
+
+ InvalidateLayout();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::DeleteAllItems()
+{
+ FOR_EACH_LL( m_DataItems, i )
+ {
+ if ( m_DataItems[i].panel )
+ {
+ delete m_DataItems[i].panel;
+ }
+ }
+
+ m_DataItems.RemoveAll();
+ m_SortedItems.RemoveAll();
+
+ InvalidateLayout();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::RemoveAll()
+{
+ m_DataItems.RemoveAll();
+ m_SortedItems.RemoveAll();
+
+// m_pScrollBar->SetValue( 0 );
+ InvalidateLayout();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::OnSizeChanged( int nWide, int nTall )
+{
+ BaseClass::OnSizeChanged( nWide, nTall );
+ InvalidateLayout();
+ Repaint();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::PerformLayout()
+{
+ int nWide, nTall;
+ GetSize( nWide, nTall );
+
+ int vpixels = ComputeVPixelsNeeded();
+
+ int top = 0;
+ if ( m_pScrollBar )
+ {
+
+ m_pScrollBar->SetRange( 0, vpixels );
+ m_pScrollBar->SetRangeWindow( nTall );
+ m_pScrollBar->SetButtonPressedScrollValue( nTall / 4 ); // standard height of labels/buttons etc.
+
+ m_pScrollBar->SetPos( nWide - m_pScrollBar->GetWide() - 2, 0 );
+ m_pScrollBar->SetSize( m_pScrollBar->GetWide(), nTall - 2 );
+
+ top = m_pScrollBar->GetValue();
+ }
+
+ m_pPanelEmbedded->SetPos( 1, -top );
+ if ( m_pScrollBar )
+ {
+ m_pPanelEmbedded->SetSize( nWide - m_pScrollBar->GetWide() - 2, vpixels );
+ }
+ else
+ {
+ m_pPanelEmbedded->SetSize( nWide - 2, vpixels );
+ }
+
+ SetSize( nWide, vpixels );
+
+ /*
+ bool bScrollbarVisible = true;
+ // If we're supposed to automatically hide the scrollbar when unnecessary, check it now
+ if ( m_bAutoHideScrollbar )
+ {
+ bScrollbarVisible = (m_pPanelEmbedded->GetTall() > nTall);
+ }
+ m_pScrollBar->SetVisible( bScrollbarVisible );
+ */
+
+ // Now lay out the controls on the embedded panel
+ int y = 0;
+ int h = 0;
+ int totalh = 0;
+
+ int xpos = m_iFirstColumnWidth + m_iPanelBuffer;
+ int iColumnWidth = ( nWide - xpos - 12 ) / m_nNumColumns;
+ if ( m_pScrollBar )
+ {
+ iColumnWidth = ( nWide - xpos - m_pScrollBar->GetWide() - 12 ) / m_nNumColumns;
+ }
+
+ for ( int i = 0; i < m_SortedItems.Count(); i++ )
+ {
+ CDataItem &item = m_DataItems[ m_SortedItems[i] ];
+ if ( !item.IsVisible() )
+ continue;
+
+ int iCurrentColumn = i % m_nNumColumns;
+
+ // add in a little buffer between panels
+ if ( iCurrentColumn == 0 )
+ y += m_iPanelBuffer;
+
+ if ( h < item.panel->GetTall() )
+ h = item.panel->GetTall();
+
+ if ( item.labelPanel )
+ {
+ item.labelPanel->SetBounds( 0, y, m_iFirstColumnWidth, item.panel->GetTall() );
+ }
+
+ item.panel->SetBounds( xpos + iCurrentColumn * iColumnWidth, y, iColumnWidth, item.panel->GetTall() );
+
+ if ( iCurrentColumn >= m_nNumColumns - 1 )
+ {
+ y += h;
+ totalh += h;
+
+ h = 0;
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::ApplySchemeSettings( vgui::IScheme *pScheme )
+{
+ BaseClass::ApplySchemeSettings( pScheme );
+
+ SetBorder( pScheme->GetBorder( "ButtonDepressedBorder" ) );
+ SetBgColor( GetSchemeColor( "ListPanel.BgColor", GetBgColor(), pScheme ) );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::OnSliderMoved( int /* nPosition */ )
+{
+ InvalidateLayout();
+ Repaint();
+}
+
+
+/*
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::MoveScrollBarToTop()
+{
+ m_pScrollBar->SetValue( 0 );
+}
+*/
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::SetFirstColumnWidth( int nWidth )
+{
+ m_iFirstColumnWidth = nWidth;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::GetFirstColumnWidth()
+{
+ return m_iFirstColumnWidth;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::SetNumColumns( int nNumColumns )
+{
+ m_nNumColumns = nNumColumns;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+int CDualPanelList::GetNumColumns()
+{
+ return m_nNumColumns;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::OnMouseWheeled( int nDelta )
+{
+ if ( !m_pScrollBar )
+ return;
+
+ int nVal = m_pScrollBar->GetValue();
+ nVal -= ( nDelta * DEFAULT_HEIGHT );
+ m_pScrollBar->SetValue( nVal );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::SetSelectedPanel( vgui::Panel *pPanel )
+{
+ if ( pPanel != m_hSelectedItem )
+ {
+ // notify the panels of the selection change
+ if ( m_hSelectedItem )
+ {
+ PostMessage( m_hSelectedItem.Get(), new KeyValues( "PanelSelected", "state", 0 ) );
+ }
+
+ if ( pPanel )
+ {
+ PostMessage( pPanel, new KeyValues( "PanelSelected", "state", 1 ) );
+ }
+
+ m_hSelectedItem = pPanel;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+vgui::Panel *CDualPanelList::GetSelectedPanel()
+{
+ return m_hSelectedItem;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CDualPanelList::ScrollToItem( int nItemNumber )
+{
+ if ( !m_pScrollBar || !m_pScrollBar->IsVisible() )
+ return;
+
+ CDataItem& item = m_DataItems[ m_SortedItems[ nItemNumber ] ];
+ if ( !item.panel )
+ return;
+
+ int x, y;
+ item.panel->GetPos( x, y );
+ int lx, ly;
+ lx = x;
+ ly = y;
+ m_pPanelEmbedded->LocalToScreen( lx, ly );
+ ScreenToLocal( lx, ly );
+
+ int h = item.panel->GetTall();
+
+ if ( ly >= 0 && ly + h < GetTall() )
+ return;
+
+ m_pScrollBar->SetValue( y );
+ InvalidateLayout();
+}
diff --git a/utils/itemtest_controls/dualpanellist.h b/utils/itemtest_controls/dualpanellist.h
new file mode 100644
index 0000000..a364a45
--- /dev/null
+++ b/utils/itemtest_controls/dualpanellist.h
@@ -0,0 +1,144 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+#ifndef DUAL_PANEL_LIST_H
+#define DUAL_PANEL_LIST_H
+
+#if defined( _WIN32 )
+#pragma once
+#endif
+
+#include <utllinkedlist.h>
+#include <utlvector.h>
+#include <vgui/VGUI.h>
+#include <vgui_controls/Panel.h>
+
+class KeyValues;
+
+//-----------------------------------------------------------------------------
+// Purpose: A list of variable height child panels
+// each list item consists of a label-panel pair. Height of the item is
+// determined from the lable.
+//-----------------------------------------------------------------------------
+class CDualPanelList : public vgui::Panel
+{
+ DECLARE_CLASS_SIMPLE( CDualPanelList, vgui::Panel );
+
+public:
+ CDualPanelList( vgui::Panel *parent, char const *panelName );
+ ~CDualPanelList();
+
+ // DATA & ROW HANDLING
+ // The list now owns the panel
+ virtual int AddItem( vgui::Panel *labelPanel, vgui::Panel *panel );
+ int GetItemCount() const;
+ int GetItemIDFromRow( int nRow ) const;
+
+ // Iteration. Use these until they return InvalidItemID to iterate all the items.
+ int FirstItem() const;
+ int NextItem( int nItemID ) const;
+ int InvalidItemID() const;
+
+ virtual Panel *GetItemLabel( int itemID );
+ virtual Panel *GetItemPanel( int itemID );
+ virtual bool IsItemVisible( int nItemID ) const;
+ virtual void SetItemVisible( int nItemID, bool bVisible );
+
+// vgui::ScrollBar *GetScrollbar() { return m_pScrollBar; }
+
+ virtual void RemoveItem( int itemID ); // removes an item from the table (changing the indices of all following items)
+ virtual void DeleteAllItems(); // clears and deletes all the memory used by the data items
+ void RemoveAll();
+
+ // painting
+ virtual vgui::Panel *GetCellRenderer( int row );
+
+ // layout
+ void SetFirstColumnWidth( int width );
+ int GetFirstColumnWidth();
+ void SetNumColumns( int iNumColumns );
+ int GetNumColumns( void );
+// void MoveScrollBarToTop();
+
+ // selection
+ void SetSelectedPanel( vgui::Panel *panel );
+ Panel *GetSelectedPanel();
+ /*
+ On a panel being selected, a message gets sent to it
+ "PanelSelected" int "state"
+ where state is 1 on selection, 0 on deselection
+ */
+
+ void SetVerticalBufferPixels( int buffer );
+
+ void ScrollToItem( int itemNumber );
+
+ CUtlVector< int > *GetSortedVector( void )
+ {
+ return &m_SortedItems;
+ }
+
+protected:
+ // overrides
+ virtual void OnSizeChanged(int wide, int tall);
+ MESSAGE_FUNC_INT( OnSliderMoved, "ScrollBarSliderMoved", position );
+ virtual void PerformLayout();
+ virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
+ virtual void OnMouseWheeled(int delta);
+
+private:
+ int ComputeVPixelsNeeded();
+
+ enum { DEFAULT_HEIGHT = 24, PANELBUFFER = 5 };
+
+ class CDataItem
+ {
+ public:
+ CDataItem()
+ : m_bVisible( true )
+ {
+ }
+
+ void SetVisible( int bVisible )
+ {
+ m_bVisible = bVisible;
+
+ if ( panel )
+ {
+ panel->SetVisible( m_bVisible );
+ }
+
+ if ( labelPanel )
+ {
+ labelPanel->SetVisible( m_bVisible );
+ }
+ }
+
+ bool IsVisible() const { return m_bVisible; }
+
+ // Always store a panel pointer
+ vgui::Panel *panel;
+ vgui::Panel *labelPanel;
+ bool m_bVisible;
+ };
+
+ // list of the column headers
+
+ CUtlLinkedList< CDataItem, int> m_DataItems;
+ CUtlVector<int> m_SortedItems;
+
+ vgui::ScrollBar *m_pScrollBar;
+ vgui::Panel *m_pPanelEmbedded;
+
+ vgui::PHandle m_hSelectedItem;
+ int m_iFirstColumnWidth;
+ int m_nNumColumns;
+ int m_iDefaultHeight;
+ int m_iPanelBuffer;
+
+// CPanelAnimationVar( bool, m_bAutoHideScrollbar, "autohide_scrollbar", "0" );
+};
+
+
+#endif // DUAL_PANEL_LIST_H
diff --git a/utils/itemtest_controls/finalsubpanel.cpp b/utils/itemtest_controls/finalsubpanel.cpp
new file mode 100644
index 0000000..4828308
--- /dev/null
+++ b/utils/itemtest_controls/finalsubpanel.cpp
@@ -0,0 +1,410 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+// Valve includes
+#include "itemtest/itemtest_controls.h"
+#include "vgui_controls/ComboBox.h"
+#include "vgui_controls/MenuItem.h"
+#include "vgui_controls/PanelListPanel.h"
+#include "vgui/ISystem.h"
+#include "vgui_controls/MessageBox.h"
+#include "tier1/fmtstr.h"
+
+
+// Last include
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CFinalSubPanel::CFinalSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName )
+: BaseClass( pParent, pszName, pszNextName )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ {
+ m_pHLMVButton = new vgui::Button( this, "hlmvButton", "#hlmvButton", this, "Hlmv" );
+ m_pHLMVLabel = new vgui::Label( this, "hlmvLabel", "#hlmvLabel" );
+
+ CFmtStrMax sCmd;
+ if ( GetHlmvCmd( sCmd ) )
+ {
+ m_pHLMVLabel->SetText( sCmd.Access() );
+ }
+
+ m_pPanelListPanel->AddItem( m_pHLMVButton, m_pHLMVLabel );
+ m_pHLMVButton->AddActionSignalTarget( this );
+ }
+
+ {
+ m_pExploreMaterialContentButton = new vgui::Button( this, "exploreMaterialContentButton", "#exploreMaterialContentButton", this, "ExploreMaterialContent" );
+ m_pExploreMaterialContentLabel = new vgui::Label( this, "exploreMaterialContentLabel", "#exploreMaterialContentLabel" );
+
+ m_pPanelListPanel->AddItem( m_pExploreMaterialContentButton, m_pExploreMaterialContentLabel );
+ }
+
+ {
+ m_pExploreModelContentButton = new vgui::Button( this, "exploreModelContentButton", "#exploreModelContentButton", this, "ExploreModelContent" );
+ m_pExploreModelContentLabel = new vgui::Label( this, "exploreModelContentLabel", "#exploreModelContentLabel" );
+
+ m_pPanelListPanel->AddItem( m_pExploreModelContentButton, m_pExploreModelContentLabel );
+ }
+
+ {
+ m_pExploreMaterialGameButton = new vgui::Button( this, "exploreMaterialGameButton", "#exploreMaterialGameButton", this, "ExploreMaterialGame" );
+ m_pExploreMaterialGameLabel = new vgui::Label( this, "exploreMaterialGameLabel", "#exploreMaterialGameLabel" );
+
+ m_pPanelListPanel->AddItem( m_pExploreMaterialGameButton, m_pExploreMaterialGameLabel );
+ }
+
+ {
+ m_pExploreModelGameButton = new vgui::Button( this, "exploreModelGameButton", "#exploreModelGameButton", this, "ExploreModelGame" );
+ m_pExploreModelGameLabel = new vgui::Label( this, "exploreModelGameLabel", "#exploreModelGameLabel" );
+
+ m_pPanelListPanel->AddItem( m_pExploreModelGameButton, m_pExploreModelGameLabel );
+ }
+
+ UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::PerformLayout()
+{
+ BaseClass::PerformLayout();
+
+ m_pPanelListPanel->SetFirstColumnWidth( 256 );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::UpdateGUI()
+{
+ UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnCommand( const char *command )
+{
+ if ( !V_strcmp( command, "Gather" ) )
+ {
+ OnGather();
+ }
+ else if ( !V_strcmp( command, "StudioMDL" ) )
+ {
+ OnStudioMDL();
+ }
+ else if ( !V_strcmp( command, "Zip" ) )
+ {
+ OnZip();
+ }
+ else if ( !V_strcmp( command, "Hlmv" ) )
+ {
+ OnHlmv();
+ }
+ else if ( !V_strcmp( command, "ExploreMaterialContent" ) )
+ {
+ OnExplore( true, true );
+ }
+ else if ( !V_strcmp( command, "ExploreModelContent" ) )
+ {
+ OnExplore( false, true );
+ }
+ else if ( !V_strcmp( command, "ExploreMaterialGame" ) )
+ {
+ OnExplore( true, false );
+ }
+ else if ( !V_strcmp( command, "ExploreModelGame" ) )
+ {
+ OnExplore( false, false );
+ }
+ else
+ {
+ BaseClass::OnCommand( command );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CFinalSubPanel::UpdateStatus()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return false;
+
+ SetStatus( true, "", NULL, true );
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ {
+ char szBuf[ MAX_PATH ];
+
+ CUtlString sDir;
+
+ asset.GetAbsoluteDir( sDir, "materialsrc", true );
+ V_FixupPathName( szBuf, ARRAYSIZE( szBuf ), sDir.Get() );
+ m_pExploreMaterialContentLabel->SetText( szBuf );
+
+ asset.GetAbsoluteDir( sDir, "materials", false );
+ V_FixupPathName( szBuf, ARRAYSIZE( szBuf ), sDir.Get() );
+ m_pExploreMaterialGameLabel->SetText( szBuf );
+
+ asset.GetAbsoluteDir( sDir, NULL, true );
+ V_FixupPathName( szBuf, ARRAYSIZE( szBuf ), sDir.Get() );
+ m_pExploreModelContentLabel->SetText( szBuf );
+
+ asset.GetAbsoluteDir( sDir, NULL, false );
+ V_FixupPathName( szBuf, ARRAYSIZE( szBuf ), sDir.Get() );
+ m_pExploreModelGameLabel->SetText( szBuf );
+
+ CFmtStrMax sCmd;
+ if ( GetHlmvCmd( sCmd ) )
+ {
+ m_pHLMVLabel->SetText( sCmd.Access() );
+ }
+ }
+
+ return BaseClass::UpdateStatus();
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnGather()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ {
+// m_pGatherLabel->SetText( "Gather Failed" );
+ return;
+ }
+
+// m_pGatherLabel->SetText( "OnGather" );
+
+ m_pExploreMaterialContentButton->SetEnabled( true );
+ m_pExploreModelContentButton->SetEnabled( true );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnStudioMDL()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ {
+// m_pStudioMDLLabel->SetText( "StudioMDL Failed" );
+ return;
+ }
+
+ OnGather();
+
+// m_pStudioMDLLabel->SetText( "OnStudioMDL" );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+// The idea is that there could be three steps...
+// 1. Gather data from user specified sources into properly named & organized content, make VMT's & QC
+// 2. Run StudioMDL on the gathered content
+// 3. Zip the results
+//
+// Right now all three steps are combined
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnZip()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+
+ CAsset &asset = pItemUploadWizard->Asset();
+ const bool bOk = asset.Compile();
+
+ vgui::MessageBox *pMsgDialog = NULL;
+
+ if ( bOk )
+ {
+ pMsgDialog = new vgui::MessageBox( "Compile Ok", "Compile Ok", this );
+ }
+ else
+ {
+ pMsgDialog = new vgui::MessageBox( "Compile Failed", "Compile Failed", this );
+ }
+
+ pMsgDialog->SetOKButtonVisible( true );
+ pMsgDialog->SetOKButtonText( "Quit ItemTest" );
+ pMsgDialog->SetCommand( new KeyValues( "QuitApp" ) );
+
+ pMsgDialog->SetCancelButtonVisible( true );
+ pMsgDialog->SetCancelButtonText( "Dismiss And Continue" );
+
+ pMsgDialog->AddActionSignalTarget( this );
+
+ pMsgDialog->DoModal();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnHlmv()
+{
+ CUtlString sBinDir;
+ if ( !CItemUpload::GetBinDirectory( sBinDir ) )
+ {
+ m_pHLMVLabel->SetText( "Cannot determine bin directory" );
+ return;
+ }
+
+ char szBinLaunchDir[ MAX_PATH ];
+ V_ExtractFilePath( sBinDir.String(), szBinLaunchDir, ARRAYSIZE( szBinLaunchDir ) );
+
+ CFmtStrMax sCmd;
+ if ( !GetHlmvCmd( sCmd ) )
+ return;
+
+ if ( CItemUpload::RunCommandLine( sCmd.Access(), szBinLaunchDir, false ) )
+ {
+ m_pHLMVLabel->SetText( sCmd.Access() );
+ }
+ else
+ {
+ m_pHLMVLabel->SetText( "Hlmv launch failed" );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnExplore( bool bMaterial, bool bContent )
+{
+ vgui::Label *pLabel = NULL;
+ if ( bMaterial )
+ {
+ if ( bContent )
+ {
+ pLabel = m_pExploreMaterialContentLabel;
+ }
+ else
+ {
+ pLabel = m_pExploreMaterialGameLabel;
+ }
+ }
+ else
+ {
+ if ( bContent )
+ {
+ pLabel = m_pExploreModelContentLabel;
+ }
+ else
+ {
+ pLabel = m_pExploreModelGameLabel;
+ }
+ }
+
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ {
+ pLabel->SetText( "Explore game failed" );
+ return;
+ }
+
+ CAsset &asset = pItemUploadWizard->Asset();
+ CUtlString sDir;
+ const char *pszPrefix = bMaterial ? ( bContent ? "materialsrc" : "materials" ) : NULL;
+ asset.GetAbsoluteDir( sDir, pszPrefix, bContent );
+
+ char szBuf[ MAX_PATH ];
+ V_FixupPathName( szBuf, ARRAYSIZE( szBuf ), sDir.Get() );
+ vgui::system()->ShellExecute( "open", szBuf );
+
+ pLabel->SetText( szBuf );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CFinalSubPanel::OnQuitApp()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ pItemUploadWizard->Close();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CFinalSubPanel::GetHlmvCmd( CFmtStrMax &sHlmvCmd )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ {
+ m_pHLMVLabel->SetText( "Hlmv Failed" );
+ return false;
+ }
+
+ CUtlString sBinDir;
+ if ( !CItemUpload::GetBinDirectory( sBinDir ) )
+ {
+ m_pHLMVLabel->SetText( "Cannot determine bin directory" );
+ return false;
+ }
+
+ CAsset &asset = pItemUploadWizard->Asset();
+ CSmartPtr< CTargetMDL > pTargetMDL = asset.GetTargetMDL();
+ if ( !pTargetMDL.IsValid() )
+ {
+ m_pHLMVLabel->SetText( "No TargetMDL" );
+ return false;
+ }
+
+ CUtlString sMdlPath;
+ if ( !pTargetMDL->GetOutputPath( sMdlPath ) )
+ {
+ m_pHLMVLabel->SetText( "Cannot determine path to MDL" );
+ return false;
+ }
+
+
+ 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
+ {
+ m_pHLMVLabel->SetText( "Cannot determine VPROJECT (gamedir)" );
+ return false;
+ }
+ }
+
+ return true;
+} \ No newline at end of file
diff --git a/utils/itemtest_controls/globalsubpanel.cpp b/utils/itemtest_controls/globalsubpanel.cpp
new file mode 100644
index 0000000..bd9d8a6
--- /dev/null
+++ b/utils/itemtest_controls/globalsubpanel.cpp
@@ -0,0 +1,196 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+
+// Valve includes
+#include "itemtest/itemtest_controls.h"
+#include "vgui_controls/CheckButton.h"
+#include "vgui_controls/ComboBox.h"
+#include "vgui_controls/MenuItem.h"
+#include "vgui_controls/PanelListPanel.h"
+#include "tier1/fmtstr.h"
+
+
+// Last include
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CGlobalSubPanel::CGlobalSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName )
+: BaseClass( pParent, pszName, pszNextName )
+{
+ {
+ vgui::Label *pNameLabel = new vgui::Label( this, "nameLabel", "#nameLabel" );
+ m_pNameTextEntry = new vgui::TextEntry( this, "nameTextEntry" );
+ m_pNameTextEntry->AddActionSignalTarget( this );
+
+ m_pPanelListPanel->AddItem( pNameLabel, m_pNameTextEntry );
+ }
+
+ AddStatusPanels( "name" );
+
+ {
+ vgui::Label *pClassLabel = new vgui::Label( this, "classLabel", "#classLabel" );
+ m_pClassComboBox = new vgui::ComboBox( this, "classComboBox", CItemUploadTF::GetClassCount(), false );
+ m_pClassComboBox->AddItem( "#none", NULL );
+ for ( int i = 0; i < CItemUploadTF::GetClassCount(); ++i )
+ {
+ m_pClassComboBox->AddItem( CItemUploadTF::GetClassString( i ), NULL );
+ }
+ m_pClassComboBox->SilentActivateItemByRow( 0 );
+ m_pClassComboBox->AddActionSignalTarget( this );
+
+ m_pPanelListPanel->AddItem( pClassLabel, m_pClassComboBox );
+ }
+
+ AddStatusPanels( "class" );
+
+ {
+ vgui::Label *pAutoSkinLabel = new vgui::Label( this, "autoSkinLabel", "#autoSkinLabel" );
+ m_pAutoSkinCheckButton = new vgui::CheckButton( this, "autoSkinCheckButton", "#autoSkinCheckButtonText" );
+ m_pAutoSkinCheckButton->AddActionSignalTarget( this );
+
+ m_pPanelListPanel->AddItem( pAutoSkinLabel, m_pAutoSkinCheckButton );
+ }
+
+ AddStatusPanels( "autoSkin" );
+
+ {
+ vgui::Label *pSteamLabel = new vgui::Label( this, "steamLabel", "#steamLabel" );
+ m_pSteamTextEntry = new vgui::TextEntry( this, "steamTextEntry" );
+ m_pSteamTextEntry->SetEditable( false );
+
+ m_pPanelListPanel->AddItem( pSteamLabel, m_pSteamTextEntry );
+ }
+
+ AddStatusPanels( "steam" );
+
+ UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGlobalSubPanel::UpdateGUI()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ m_pNameTextEntry->SetText( pItemUploadWizard->Asset().GetName() );
+ const char *pszSteamId = pItemUploadWizard->Asset().GetSteamId();
+ if ( CItemUpload::GetDevMode() && ( !pszSteamId || *pszSteamId == '\0' ) )
+ {
+ m_pSteamTextEntry->SetText( "<dev mode>" );
+ }
+ else
+ {
+ m_pSteamTextEntry->SetText( pszSteamId );
+ }
+
+ vgui::Menu *pMenu = m_pClassComboBox->GetMenu();
+ if ( pMenu )
+ {
+ bool bFound = false;
+
+ const char *pszClass = pItemUploadWizard->Asset().GetClass();
+ for ( int i = 0; i < pMenu->GetItemCount(); ++i )
+ {
+ vgui::MenuItem *pMenuItem = pMenu->GetMenuItem( i );
+ if ( !pMenuItem )
+ continue;
+
+ if ( !V_stricmp( pszClass, pMenuItem->GetName() ) )
+ {
+ m_pClassComboBox->ActivateItemByRow( i );
+ bFound = true;
+ break;
+ }
+ }
+
+ if ( !bFound )
+ {
+ m_pClassComboBox->ActivateItemByRow( 0 );
+ }
+ }
+
+ m_pAutoSkinCheckButton->SetSelected( pItemUploadWizard->Asset().SkinToBipHead() );
+
+ UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CGlobalSubPanel::UpdateStatus()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return false;
+
+ CAssetTF &asset = pItemUploadWizard->Asset();
+
+ SetStatus( asset.IsNameValid(), "name" );
+ SetStatus( asset.IsClassValid(), "class" );
+ SetStatus( true, "autoSkin" );
+ SetStatus( asset.IsSteamIdValid(), "steam" );
+
+ return BaseClass::UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGlobalSubPanel::OnTextChanged( vgui::Panel *pPanel )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ char szBuf[ BUFSIZ ];
+
+ if ( pPanel == m_pNameTextEntry )
+ {
+ m_pNameTextEntry->GetText( szBuf, ARRAYSIZE( szBuf ) );
+
+ if ( !V_strcmp( pItemUploadWizard->Asset().GetName(), szBuf ) )
+ return;
+
+ pItemUploadWizard->Asset().SetName( szBuf );
+
+ UpdateStatus();
+ }
+ else if ( pPanel == m_pClassComboBox )
+ {
+ m_pClassComboBox->GetText( szBuf, ARRAYSIZE( szBuf ) );
+
+ if ( !V_strcmp( pItemUploadWizard->Asset().GetClass(), szBuf ) )
+ return;
+
+ pItemUploadWizard->Asset().SetClass( szBuf );
+
+ UpdateStatus();
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGlobalSubPanel::OnCheckButtonChecked( vgui::Panel *pPanel )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ if ( pPanel != m_pAutoSkinCheckButton )
+ return;
+
+ pItemUploadWizard->Asset().SetSkinToBipHead( m_pAutoSkinCheckButton->IsSelected() );
+} \ No newline at end of file
diff --git a/utils/itemtest_controls/itemtest_controls.cpp b/utils/itemtest_controls/itemtest_controls.cpp
new file mode 100644
index 0000000..ca2fb6e
--- /dev/null
+++ b/utils/itemtest_controls/itemtest_controls.cpp
@@ -0,0 +1,1759 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//=============================================================================
+//
+//=============================================================================
+
+
+// Standard includes
+#define WIN32_LEAN_AND_MEAN
+#include <direct.h>
+#include <Windows.h>
+
+
+// Valve includes
+#include "itemtest/itemtest_controls.h"
+#include "vgui/IVGui.h"
+#include "vgui/IInput.h"
+#include "vgui/ISystem.h"
+#include "vgui/IPanel.h"
+#include "vgui_controls/CheckButton.h"
+#include "vgui_controls/ComboBox.h"
+#include "vgui_controls/FileOpenDialog.h"
+#include "vgui_controls/Menu.h"
+#include "vgui_controls/MenuItem.h"
+#include "vgui_controls/MessageBox.h"
+#include "vgui_controls/PanelListPanel.h"
+#include "vgui_controls/ScrollBar.h"
+#include "vgui_controls/TextImage.h"
+#include "tier1/fmtstr.h"
+
+
+// Local includes
+#include "dualpanellist.h"
+
+
+// Last include
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CItemUploadDialog *g_pItemUploadDialog = NULL;
+
+
+//=============================================================================
+//
+//=============================================================================
+CStatusLabel::CStatusLabel( vgui::Panel *pPanel, const char *pszName, bool bValid /* = false */ )
+: BaseClass( pPanel, pszName, "" )
+, m_bValid( bValid )
+, m_cValid( 0, 192, 0, 255 )
+, m_cInvalid( 192, 0, 0, 255 )
+{
+ SetText( m_bValid ? "#valid" : "#invalid" );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CStatusLabel::ApplySchemeSettings( vgui::IScheme *pScheme )
+{
+ BaseClass::ApplySchemeSettings( pScheme );
+
+ SetContentAlignment( vgui::Label::a_center );
+
+ m_cValid = pScheme->GetColor( "StatusLabel.ValidColor", m_cValid );
+ m_cInvalid = pScheme->GetColor( "StatusLabel.InvalidColor", m_cInvalid );
+
+ UpdateColors();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CStatusLabel::SetValid( bool bValid )
+{
+ if ( bValid == m_bValid )
+ return;
+
+ m_bValid = bValid;
+ SetText( m_bValid ? "#valid" : "#invalid" );
+
+ UpdateColors();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CStatusLabel::GetValid() const
+{
+ return m_bValid;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CStatusLabel::UpdateColors()
+{
+ // TODO: Set valid/invalid colors in scheme .res file...
+ if ( GetValid() )
+ {
+ SetBgColor( m_cValid );
+ }
+ else
+ {
+ SetBgColor( m_cInvalid );
+ }
+}
+
+
+//=============================================================================
+//
+//=============================================================================
+CItemUploadSubPanel::CItemUploadSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName )
+: BaseClass( pParent, pszName )
+, m_sNextName( pszNextName )
+{
+ // Set the Wizard panel if the parent is a Wizard panel (it should be)
+ vgui::WizardPanel *pWizardPanel = dynamic_cast< vgui::WizardPanel * >( pParent );
+ if ( pWizardPanel )
+ {
+ SetWizardPanel( pWizardPanel );
+ }
+
+ CFmtStr sTmp;
+
+ // Create the two standard widgets
+
+ if ( CItemUpload::GetDevMode() )
+ {
+ sTmp.sprintf( "#itemtest_wizard_%s_info_dev", GetName() );
+ const char *pszCheck = g_pVGuiLocalize->FindAsUTF8( sTmp );
+
+ if ( pszCheck == sTmp.Access() )
+ {
+ sTmp.Clear();
+ }
+ }
+
+ if ( sTmp.Length() <= 0 )
+ {
+ sTmp.sprintf( "#itemtest_wizard_%s_info", GetName() );
+ }
+
+ m_pLabel = new vgui::Label( this, "info", sTmp );
+
+ m_pPanelListPanel = new vgui::PanelListPanel( this, "list" );
+
+ m_pStatusLabel = new CStatusLabel( this, "statusLabel", false );
+ m_pStatusText = new vgui::Label( this, "statusText", "wonk" );
+
+ sTmp.sprintf( "itemtest_wizard_%s.res", GetName() );
+
+ LoadControlSettings( sTmp );
+
+ m_pLabel->SetAutoResize( PIN_TOPLEFT, AUTORESIZE_RIGHT, 0, 0, 0, 0 );
+ m_pLabel->SizeToContents(); // Supposedly doesn't work until layout but kind of does...
+ m_pLabel->SetWrap( true );
+
+ m_pStatusLabel->SetAutoResize( PIN_BOTTOMLEFT, AUTORESIZE_NO, 0, 0, 0, 0 );
+
+ if ( GetWizardPanel() && pszNextName == NULL )
+ {
+ GetWizardPanel()->SetFinishButtonEnabled( false );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadSubPanel::PerformLayout()
+{
+ BaseClass::PerformLayout();
+
+ int nOldWide = m_pLabel->GetWide();
+ m_pLabel->SizeToContents();
+ m_pLabel->SetWide( nOldWide );
+
+ int nX = 0;
+ int nY = 0;
+
+ m_pLabel->GetPos( nX, nY );
+
+ int nX1 = 0;
+ int nY1 = 0;
+
+ m_pStatusLabel->GetPos( nX1, nY1 );
+
+ m_pPanelListPanel->SetBounds( nX, nY + m_pLabel->GetTall() + 10, m_pLabel->GetWide(), nY1 - nY - m_pLabel->GetTall() - 20 );
+
+ bool bDone = false;
+
+ for ( int i = 1; i < m_pPanelListPanel->GetItemCount(); i += 2 )
+ {
+ vgui::Panel *pPanelA0 = m_pPanelListPanel->GetItemLabel( i - 1 );
+ vgui::Panel *pPanelA1 = m_pPanelListPanel->GetItemPanel( i - 1 );
+ vgui::Panel *pPanelB0 = m_pPanelListPanel->GetItemLabel( i );
+ vgui::Panel *pPanelB1 = m_pPanelListPanel->GetItemPanel( i );
+
+ pPanelA0->SetTall( pPanelA1->GetTall() );
+ pPanelB1->SetTall( pPanelB0->GetTall() );
+
+ if ( !bDone )
+ {
+ bDone = true;
+ m_pStatusLabel->SetSize( pPanelA0->GetWide(), pPanelB0->GetTall() );
+ }
+ }
+
+ m_pStatusLabel->GetPos( nX, nY );
+ m_pStatusText->SetPos( nX + m_pStatusLabel->GetWide() + 5, nY );
+ m_pStatusText->SetWide( m_pLabel->GetWide() - nX );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadSubPanel::ApplySchemeSettings( vgui::IScheme *pScheme )
+{
+ BaseClass::ApplySchemeSettings( pScheme );
+
+ if ( dynamic_cast< CGlobalSubPanel * >( this ) )
+ return;
+
+ if ( dynamic_cast< CGeometrySubPanel * >( this ) )
+ return;
+
+ /*
+#ifdef _DEBUG
+
+ m_pLabel->SetBgColor( Color( 255, 127, 0, 255 ) );
+
+ m_pPanelListPanel->SetBgColor( Color( 0, 127, 0 ) );
+
+ for ( int i = 1; i < m_pPanelListPanel->GetItemCount(); i += 2 )
+ {
+ vgui::Panel *pPanel = m_pPanelListPanel->GetItemPanel( i );
+ if ( pPanel )
+ {
+ pPanel->SetBgColor( Color( 0, 0, 255 ) );
+ }
+ }
+
+#endif // _DEBUG
+ */
+
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadSubPanel::OnDisplay()
+{
+ UpdateGUI();
+// UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+vgui::WizardSubPanel *CItemUploadSubPanel::GetNextSubPanel()
+{
+ return dynamic_cast< WizardSubPanel * >( GetWizardPanel()->FindChildByName( m_sNextName.Get() ) );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CItemUploadSubPanel::UpdateStatus()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return false;
+
+ if ( pItemUploadWizard->GetCurrentItemUploadSubPanel() != this )
+ return false;
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ CFmtStr sTmp;
+ sTmp.sprintf( "#itemtest_wizard_%s_title", GetName() );
+
+ CUtlString sRelativeDir;
+ asset.GetRelativeDir( sRelativeDir, NULL );
+
+ const char *pszTitle = g_pVGuiLocalize->FindAsUTF8( sTmp );
+
+ CUtlString sStatusMsg;
+ if ( asset.IsOk( sStatusMsg ) && !sRelativeDir.IsEmpty() && pszTitle )
+ {
+ sTmp.sprintf( "%s : %s", pszTitle, sRelativeDir.Get() );
+ }
+ else if ( !sStatusMsg.IsEmpty() )
+ {
+ }
+
+ pItemUploadWizard->SetTitle( sTmp, true );
+
+ bool bValid = true;
+ for ( int i = 1; bValid && i < m_pPanelListPanel->GetItemCount(); i += 2 )
+ {
+ CStatusLabel *pStatusLabel = dynamic_cast< CStatusLabel * >( m_pPanelListPanel->GetItemLabel( i ) );
+ if ( !pStatusLabel )
+ continue;
+
+ bValid = bValid && pStatusLabel->GetValid();
+ }
+
+ m_pStatusLabel->SetValid( bValid );
+
+ sTmp.sprintf( "#itemtest_wizard_%s_%s", GetName(), bValid ? "valid" : "invalid" );
+ m_pStatusText->SetText( sTmp );
+
+ pItemUploadWizard->SetNextButtonEnabled( bValid );
+
+ if ( pItemUploadWizard->GetCurrentSubPanel() == this )
+ {
+ pItemUploadWizard->SetFinishButtonEnabled( m_sNextName.IsEmpty() ? true : false );
+ }
+
+ return bValid;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadSubPanel::AddStatusPanels( const char *pszPrefix )
+{
+ CFmtStr sTmp;
+
+ sTmp.sprintf( "%sStatusLabel", pszPrefix );
+ CStatusLabel *pStatusLabel = new CStatusLabel( this, sTmp );
+
+ sTmp.sprintf( "%sStatusText", pszPrefix );
+ vgui::Label *pStatusText = new vgui::Label( this, sTmp, "" );
+
+ m_pPanelListPanel->AddItem( pStatusLabel, pStatusText );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadSubPanel::SetStatus( bool bValid, const char *pszPrefix, const char *pszMessage /* = NULL */, bool bHide /* = false */ )
+{
+ CFmtStr sTmp;
+ sTmp.sprintf( "%sStatusLabel", pszPrefix );
+
+ CStatusLabel *pStatusLabel = dynamic_cast< CStatusLabel * >( m_pPanelListPanel->FindChildByName( sTmp, true ) );
+ if ( pStatusLabel )
+ {
+ pStatusLabel->SetValid( bValid );
+ pStatusLabel->SetVisible( !bHide );
+ }
+
+ sTmp.sprintf( "%sStatusText", pszPrefix );
+ vgui::Label *pStatusText = dynamic_cast< vgui::Label * >( m_pPanelListPanel->FindChildByName( sTmp, true ) );
+ if ( pStatusText )
+ {
+ if ( pszMessage )
+ {
+ pStatusText->SetText( pszMessage );
+ }
+ else
+ {
+ sTmp.sprintf( "#%s%s", pszPrefix, bValid ? "Valid" : "Invalid" );
+ pStatusText->SetText( sTmp );
+ }
+
+ pStatusText->SetVisible( !bHide );
+ }
+
+}
+
+
+//=============================================================================
+//
+//=============================================================================
+class CFileLocationPanel : public vgui::Panel
+{
+ DECLARE_CLASS_SIMPLE( CFileLocationPanel, vgui::Panel );
+
+public:
+
+ CFileLocationPanel( vgui::Panel *pParent, int nLodIndex )
+ : BaseClass( pParent )
+ {
+ m_pButtonBrowse = new vgui::Button( this, "BrowseButton", "#BrowseButton", pParent );
+ m_pButtonBrowse->SetCommand( new KeyValues( "Open" ) );
+ m_pButtonBrowse->AddActionSignalTarget( pParent );
+
+ m_pLabel = new vgui::Label( this, "FileLabel", "" );
+ }
+
+ virtual void PerformLayout()
+ {
+ BaseClass::PerformLayout();
+
+ int w = 0;
+ int h = 0;
+ GetSize( w, h );
+
+ m_pButtonBrowse->SizeToContents();
+
+ SetTall( m_pButtonBrowse->GetTall() );
+
+ m_pButtonBrowse->SetPos( w - m_pButtonBrowse->GetWide(), 0 );
+ m_pLabel->SetSize( w - m_pButtonBrowse->GetWide(), m_pButtonBrowse->GetTall() );
+ m_pLabel->SetPos( 0, 0 );
+ }
+
+ vgui::Button *m_pButtonBrowse;
+ vgui::Label *m_pLabel;
+
+};
+
+
+//=============================================================================
+//
+//=============================================================================
+class CLODFileLocationPanel : public vgui::Panel
+{
+ DECLARE_CLASS_SIMPLE( CLODFileLocationPanel, vgui::Panel );
+
+public:
+
+ CLODFileLocationPanel( vgui::Panel *pParent, int nLodIndex )
+ : BaseClass( pParent )
+ {
+ CFmtStr sButtonDelete;
+ sButtonDelete.sprintf( "#LOD%dDelete", nLodIndex );
+
+ m_pButtonDelete = new vgui::Button( this, sButtonDelete, sButtonDelete );
+ m_pButtonDelete->SetCommand( new KeyValues( "Delete", "nLODIndex", nLodIndex ) );
+ m_pButtonDelete->AddActionSignalTarget( pParent );
+
+ CFmtStr sButton;
+ sButton.sprintf( "#LOD%dButton", nLodIndex );
+
+ m_pButtonBrowse = new vgui::Button( this, sButton, sButton, pParent );
+ m_pButtonBrowse->SetCommand( new KeyValues( "Open", "nLODIndex", nLodIndex ) );
+ m_pButtonBrowse->AddActionSignalTarget( pParent );
+
+ CFmtStr sTextEntry;
+ sTextEntry.sprintf( "#LOD%dTextEntry", nLodIndex );
+
+ m_pLabel = new vgui::Label( this, sTextEntry, "" );
+ }
+
+ virtual void PerformLayout()
+ {
+ BaseClass::PerformLayout();
+
+ int w = 0;
+ int h = 0;
+ GetSize( w, h );
+
+ m_pButtonDelete->SizeToContents();
+ m_pButtonBrowse->SizeToContents();
+
+ SetTall( m_pButtonBrowse->GetTall() );
+
+ m_pButtonDelete->SetPos( w - m_pButtonDelete->GetWide(), 0 );
+ m_pButtonBrowse->SetPos( w - ( m_pButtonDelete->GetWide() + m_pButtonBrowse->GetWide() ), 0 );
+ m_pLabel->SetSize( w - ( m_pButtonDelete->GetWide() + m_pButtonBrowse->GetWide() ), m_pButtonBrowse->GetTall() );
+ m_pLabel->SetPos( 0, 0 );
+ }
+
+ vgui::Button *m_pButtonBrowse;
+ vgui::Button *m_pButtonDelete;
+ vgui::Label *m_pLabel;
+
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CGeometrySubPanel::CGeometrySubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName )
+: BaseClass( pParent, pszName, pszNextName )
+{
+ m_pFileOpenStateMachine = new vgui::FileOpenStateMachine( this, this );
+ m_pFileOpenStateMachine->AddActionSignalTarget( this );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGeometrySubPanel::UpdateGUI()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ int nGeometryCount = m_pPanelListPanel->GetItemCount() / 2;
+
+ for ( int i = 0; i < asset.TargetDMXCount(); ++i )
+ {
+ if ( i >= nGeometryCount )
+ {
+ AddGeometry();
+ nGeometryCount = m_pPanelListPanel->GetItemCount() / 2;
+ }
+
+ if ( i >= nGeometryCount )
+ break; // unrecoverable error
+
+ CLODFileLocationPanel *pFileLocationPanel = dynamic_cast< CLODFileLocationPanel * >( m_pPanelListPanel->GetItemPanel( i * 2 ) );
+ if ( !pFileLocationPanel )
+ continue;
+
+ vgui::Label *pLabel = pFileLocationPanel->m_pLabel;
+ if ( !pLabel )
+ continue;
+
+ CSmartPtr< CTargetDMX > pTargetDmx = asset.GetTargetDMX( i );
+ if ( !pTargetDmx )
+ continue;
+
+ pLabel->SetText( pTargetDmx->GetInputFile().Get() );
+ }
+
+ // Ensure an empty blank one at the end
+ if ( nGeometryCount == asset.TargetDMXCount() )
+ {
+ AddGeometry();
+ }
+ else
+ {
+ // Remove superfluous
+ while ( m_pPanelListPanel->GetItemCount() / 2 > ( asset.TargetDMXCount() + 1 ) )
+ {
+ m_pPanelListPanel->RemoveItem( m_pPanelListPanel->GetItemCount() - 1 );
+ m_pPanelListPanel->RemoveItem( m_pPanelListPanel->GetItemCount() - 1 );
+ }
+
+ // Set last one to empty
+ if ( ( m_pPanelListPanel->GetItemCount() / 2 ) == ( asset.TargetDMXCount() + 1 ) )
+ {
+ CLODFileLocationPanel *pFileLocationPanel = dynamic_cast< CLODFileLocationPanel * >( m_pPanelListPanel->GetItemPanel( m_pPanelListPanel->GetItemCount() - 2 ) );
+ if ( pFileLocationPanel )
+ {
+ vgui::Label *pLabel = pFileLocationPanel->m_pLabel;
+ if ( pLabel )
+ {
+ pLabel->SetText( "" );
+ }
+ }
+ }
+ }
+
+ UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CGeometrySubPanel::UpdateStatus()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return false;
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ CFmtStr sTmp;
+ CFmtStr sErrString;
+
+ int nLODIndex = 0;
+ int nThisPolyCount = 0;
+ int nLastPolyCount = 0;
+
+ for ( int i = 0; i < m_pPanelListPanel->GetItemCount(); i += 2, ++nLODIndex )
+ {
+ CLODFileLocationPanel *pFileLocationPanel = dynamic_cast< CLODFileLocationPanel * >( m_pPanelListPanel->GetItemPanel( i ) );
+ if ( !pFileLocationPanel )
+ continue;
+
+ vgui::Label *pLabel = pFileLocationPanel->m_pLabel;
+ if ( !pLabel )
+ continue;
+
+ if ( i == ( m_pPanelListPanel->GetItemCount() - 4 ) )
+ {
+ pFileLocationPanel->m_pButtonDelete->SetEnabled( true );
+ }
+ else
+ {
+ pFileLocationPanel->m_pButtonDelete->SetEnabled( false );
+ }
+
+ sTmp.sprintf( "LOD%d", nLODIndex );
+
+ if ( i < ( m_pPanelListPanel->GetItemCount() - 2 ) )
+ {
+ CSmartPtr< CTargetDMX > pTargetDMX = asset.GetTargetDMX( nLODIndex );
+
+ if ( !pTargetDMX )
+ {
+ sErrString.sprintf( "Invalid Geometry: LOD %d is NULL", nLODIndex );
+ SetStatus( false, sTmp, sErrString );
+ continue;
+ }
+
+ CUtlString sStatusMsg;
+ if ( !pTargetDMX->IsOk( sStatusMsg ) )
+ {
+ SetStatus( false, sStatusMsg.Get() );
+ continue;
+ }
+
+ nLastPolyCount = nThisPolyCount;
+ nThisPolyCount = pTargetDMX->GetPolyCount();
+
+ if ( nThisPolyCount <= 0 )
+ {
+ sErrString.sprintf( "LOD %d has bad polygon count: %d", i, nThisPolyCount );
+ SetStatus( false, sTmp, sErrString );
+ continue;
+ }
+
+ if ( ( i > 0 ) && ( nThisPolyCount == nLastPolyCount ) )
+ {
+ sErrString.sprintf( "LOD %d (%d polys) has the same number of polygons as previous LOD %d (%d polys)",
+ nLODIndex, nThisPolyCount, nLODIndex - 1, nLastPolyCount );
+ SetStatus( false, sTmp, sErrString );
+ continue;
+ }
+
+ if ( ( i > 0 ) && ( nThisPolyCount >= nLastPolyCount ) )
+ {
+ sErrString.sprintf( "LOD %d (%d polys) has more polygons than previous LOD %d (%d polys)",
+ nLODIndex, nThisPolyCount, nLODIndex - 1, nLastPolyCount );
+ SetStatus( false, sTmp, sErrString );
+ continue;
+ }
+
+ SetStatus( true, sTmp );
+ }
+ else
+ {
+ SetStatus( true, sTmp, NULL, true );
+ }
+ }
+
+ bool bValid = BaseClass::UpdateStatus();
+
+ // In this case there are more validation checks to be performed
+
+ // Ensure each LOD is non-empty
+ if ( bValid )
+ {
+ sErrString.Clear();
+
+ // Ensure at least two LODs
+ if ( CItemUpload::GetDevMode() )
+ {
+ if ( asset.TargetDMXCount() < 1 )
+ {
+ bValid = false;
+ sErrString.sprintf( "At least 1 LOD is required" );
+ }
+ }
+ else if ( asset.TargetDMXCount() < 2 )
+ {
+ bValid = false;
+ sErrString.sprintf( "At least 2 LODs are required" );
+ }
+
+ // Any other overall checks can go here
+
+ m_pStatusLabel->SetValid( bValid );
+
+ if ( !bValid )
+ {
+ // Not sure how to translate this message with parameters, etc...
+ m_pStatusText->SetText( sErrString );
+ }
+
+ pItemUploadWizard->SetNextButtonEnabled( bValid );
+ }
+
+ return bValid;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGeometrySubPanel::SetupFileOpenDialog(
+ vgui::FileOpenDialog *pDialog,
+ bool bOpenFile,
+ const char *pszFileName,
+ KeyValues *pContextKeyValues )
+{
+ char pszStartingDir[ MAX_PATH ];
+ if ( !vgui::system()->GetRegistryString(
+ "HKEY_CURRENT_USER\\Software\\Valve\\itemtest\\geometry\\opendir",
+ pszStartingDir, sizeof( pszStartingDir ) ) )
+ {
+ _getcwd( pszStartingDir, ARRAYSIZE( pszStartingDir ));
+
+ CUtlString sVMod;
+ CUtlString sContentDir;
+ if ( CItemUpload::GetVMod( sVMod ) && !sVMod.IsEmpty() && CItemUpload::GetContentDir( sContentDir ) && !sContentDir.IsEmpty() && CItemUpload::FileExists( sContentDir.Get() ) )
+ {
+ sContentDir += "/";
+ sContentDir += sVMod;
+ sContentDir += "/models";
+
+ CUtlString sTmp = sContentDir;
+ sTmp += "/player";
+
+ if ( CItemUpload::FileExists( sTmp.Get() ) )
+ {
+ sContentDir = sTmp;
+ sTmp += "/items";
+
+ if ( CItemUpload::FileExists( sTmp.Get() ) )
+ {
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( pItemUploadWizard )
+ {
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ sContentDir = sTmp;
+ sTmp += "/";
+ sTmp += asset.GetClass();
+ }
+
+ // TODO: Add steam id?
+
+ V_FixupPathName( pszStartingDir, ARRAYSIZE( pszStartingDir ), sTmp.Get() );
+ }
+ }
+ }
+ }
+
+ pDialog->SetStartDirectoryContext( "itemtest_geometry_browser", pszStartingDir );
+
+ if ( bOpenFile )
+ {
+ pDialog->AddFilter( "*.obj", "OBJ File (*.obj)", true, "obj" );
+ pDialog->AddFilter( "*.smd", "Valve SMD File (*.smd)", false, "smd" );
+ pDialog->AddFilter( "*.dmx", "Valve DMX File (*.dmx)", false, "dmx" );
+ pDialog->AddFilter( "*.*", "All Files (*.*)", false, "geometry" );
+
+ pDialog->SetTitle( "Open Geometry ( OBJ/SMD/DMX ) File", true );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CGeometrySubPanel::OnReadFileFromDisk(
+ const char *pszFileName,
+ const char *pszFileFormat,
+ KeyValues *pContextKeyValues )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return false;
+
+ const int nLODIndex = pContextKeyValues->GetInt( "nLODIndex", -1 );
+ if ( nLODIndex < 0 )
+ return false;
+
+ char szBuf0[ MAX_PATH ];
+ char szBuf1[ MAX_PATH ];
+
+ // Extract path and save to registry to open browser there next time
+ {
+ V_strncpy( szBuf0, pszFileName, sizeof( szBuf0 ) );
+ V_FixSlashes( szBuf0 );
+ V_StripFilename( szBuf0 );
+
+ _fullpath( szBuf1, szBuf0, ARRAYSIZE( szBuf1 ) );
+
+ vgui::system()->SetRegistryString(
+ "HKEY_CURRENT_USER\\Software\\Valve\\itemtest\\geometry\\opendir",
+ szBuf1 );
+ }
+
+ // Get the full path
+ _fullpath( szBuf1, pszFileName, ARRAYSIZE( szBuf1 ) );
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ for ( int i = 0; i < asset.TargetDMXCount(); ++i )
+ {
+ CSmartPtr< CTargetDMX > pTargetDMX = asset.GetTargetDMX( i );
+ if ( !pTargetDMX )
+ continue;
+
+ if ( !V_strcmp( pTargetDMX->GetInputFile().Get(), szBuf1 ) )
+ {
+ vgui::MessageBox *pMessageBox = new vgui::MessageBox( "#duplicate_file_title", "#duplicate_file_text", this );
+ if ( pMessageBox )
+ {
+ pMessageBox->SetSize( 640, 480 );
+ pMessageBox->SetMinimumSize( 320, 120 );
+
+ pMessageBox->DoModal();
+ }
+
+ return false;
+ }
+ }
+
+ bool bRet = false;
+
+ if ( nLODIndex < asset.TargetDMXCount() )
+ {
+ bRet = asset.SetTargetDMX( nLODIndex, szBuf1 );
+ }
+ else if ( nLODIndex == asset.TargetDMXCount() )
+ {
+ const int nCheck = asset.AddTargetDMX( szBuf1 );
+ Assert( nCheck == nLODIndex );
+ bRet = ( nCheck >= 0 );
+ }
+
+ UpdateGUI();
+
+ return bRet;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CGeometrySubPanel::OnWriteFileToDisk(
+ const char *pszFileName,
+ const char *pszFileFormat,
+ KeyValues *pContextKeyValues )
+{
+ return false;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGeometrySubPanel::OnOpen( int nLodIndex )
+{
+ KeyValues *pContextKeyValues = new KeyValues( "FileOpen", "nLODIndex", nLodIndex );
+ m_pFileOpenStateMachine->OpenFile( "geometry", pContextKeyValues );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGeometrySubPanel::OnDelete( int nLodIndex )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ asset.RemoveTargetDMX( nLodIndex );
+
+ UpdateGUI();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CGeometrySubPanel::AddGeometry()
+{
+ const int nLodIndex = m_pPanelListPanel->GetItemCount() / 2;
+
+ CFmtStr sLabel;
+ sLabel.sprintf( "#LOD%dLabel", nLodIndex );
+
+ vgui::Label *pLabel = new vgui::Label( this, sLabel, sLabel );
+ pLabel->SetContentAlignment( vgui::Label::a_center );
+
+ CLODFileLocationPanel *pFileLocationPanel = new CLODFileLocationPanel( this, nLodIndex );
+ m_pPanelListPanel->AddItem( pLabel, pFileLocationPanel );
+ pFileLocationPanel->m_pLabel->AddActionSignalTarget( this );
+ pFileLocationPanel->m_pButtonBrowse->AddActionSignalTarget( this );
+
+ sLabel.sprintf( "lod%d", nLodIndex );
+ AddStatusPanels( sLabel );
+}
+
+
+//=============================================================================
+//
+//=============================================================================
+class CVmtEntry : public CDualPanelList
+{
+ DECLARE_CLASS_SIMPLE( CVmtEntry, CDualPanelList );
+public:
+
+ MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
+ MESSAGE_FUNC_PTR( OnOpen, "Open", panel );
+
+ CVmtEntry( CMaterialSubPanel *pMaterialSubPanel, const char *pszName, int nVmtIndex )
+ : CDualPanelList( pMaterialSubPanel, pszName )
+ , m_pMaterialSubPanel( pMaterialSubPanel )
+ , m_nVmtIndex( nVmtIndex )
+ {
+ {
+ vgui::Label *pMaterialLabel = new vgui::Label( this, "MaterialLabel", "#MaterialLabel" );
+ m_pMaterialName = new vgui::Label( this, "MaterialName", "#MaterialName" );
+
+ AddItem( pMaterialLabel, m_pMaterialName );
+ }
+
+ {
+ vgui::Label *pMaterialTypeLabel = new vgui::Label( this, "MaterialTypeLabel", "#MaterialTypeLabel" );
+ m_pMaterialType = new vgui::ComboBox( this, "MaterialTypeComboBox", 0, false );
+ m_pMaterialType->AddItem( "#Invalid", new KeyValues( "Invalid" ) );
+ m_pMaterialType->AddItem( "#Primary", new KeyValues( "Primary" ) );
+ m_pMaterialType->AddItem( "#Secondary", new KeyValues( "Secondary" ) );
+ m_pMaterialType->AddItem( "#DuplicateOfPrimary", new KeyValues( "DuplicateOfPrimary" ) );
+ m_pMaterialType->AddItem( "#DuplicateOfSecondary", new KeyValues( "DuplicateOfSecondary" ) );
+ m_pMaterialType->AddActionSignalTarget( this );
+
+ AddItem( pMaterialTypeLabel, m_pMaterialType );
+ }
+
+ {
+ vgui::Label *pRedBlueLabel = new vgui::Label( this, "CommonRedBlueLabel", "#CommonRedBlueLabel" );
+ m_pCommonRedBlue = new vgui::ComboBox( this, "CommonRedBlue", 0, false );
+ m_pCommonRedBlue->AddItem( "#Common", new KeyValues( "Common" ) );
+ m_pCommonRedBlue->AddItem( "#RedAndBlue", new KeyValues( "RedAndBlue" ) );
+ m_pCommonRedBlue->AddActionSignalTarget( this );
+
+ m_nCommonRedBlueId = AddItem( pRedBlueLabel, m_pCommonRedBlue );
+ }
+
+ {
+ vgui::Label *pCommonTextureLabel = new vgui::Label( this, "CommonTextureLabel", "#CommonTextureLabel" );
+ m_pCommonTextureFileLocation = new CFileLocationPanel( this, 0 );
+
+ m_nCommonId = AddItem( pCommonTextureLabel, m_pCommonTextureFileLocation );
+ }
+
+ {
+ vgui::Label *pRedTextureLabel = new vgui::Label( this, "RedTextureLabel", "#RedTextureLabel" );
+ m_pRedTextureFileLocation = new CFileLocationPanel( this, 1 );
+
+ m_nRedId = AddItem( pRedTextureLabel, m_pRedTextureFileLocation );
+ }
+
+ {
+ vgui::Label *pBlueTextureLabel = new vgui::Label( this, "BlueTextureLabel", "#BlueTextureLabel" );
+ m_pBlueTextureFileLocation = new CFileLocationPanel( this, 1 );
+
+ m_nBlueId = AddItem( pBlueTextureLabel, m_pBlueTextureFileLocation );
+ }
+
+ {
+ vgui::Label *pColorAlphaLabel = new vgui::Label( this, "ColorAlphaLabel", "#ColorAlphaLabel" );
+
+ m_pColorAlpha = new vgui::ComboBox( this, "ColorAlphaComboBox", 0, false );
+ m_pColorAlpha->AddItem( "#Nothing", new KeyValues( "None" ) );
+ m_pColorAlpha->AddItem( "#Transparency", new KeyValues( "Transparency" ) );
+ m_pColorAlpha->AddItem( "#Paintable", new KeyValues( "Paintable" ) );
+ m_pColorAlpha->AddItem( "#SpecPhong", new KeyValues( "SpecPhong" ) );
+ m_pColorAlpha->AddActionSignalTarget( this );
+
+ m_nColorAlphaId = AddItem( pColorAlphaLabel, m_pColorAlpha );
+ }
+
+ {
+ vgui::Label *pNormalMapLabel = new vgui::Label( this, "NormalMapLabel", "#NormalMapLabel" );
+ m_pNormalTextureFileLocation = new CFileLocationPanel( this, 2 );
+
+ m_nNormalId = AddItem( pNormalMapLabel, m_pNormalTextureFileLocation );
+ }
+
+ {
+ vgui::Label *pNormalAlphaLabel = new vgui::Label( this, "NormalAlphaLabel", "#NormalAlphaLabel" );
+
+ m_pNormalAlpha = new vgui::ComboBox( this, "NormalAlphaComboBox", 0, false );
+ m_pNormalAlpha->AddItem( "#Nothing", new KeyValues( "None" ) );
+ m_pNormalAlpha->AddItem( "#SpecPhong", new KeyValues( "SpecPhong" ) );
+ m_pNormalAlpha->AddActionSignalTarget( this );
+
+ m_nNormalAlphaId = AddItem( pNormalAlphaLabel, m_pNormalAlpha );
+ }
+
+ m_pCommonRedBlue->ActivateItem( 0 );
+ SetItemVisible( m_nColorAlphaId, false );
+ m_pColorAlpha->SilentActivateItem( 0 );
+ SetItemVisible( m_nNormalAlphaId, false );
+ m_pNormalAlpha->SilentActivateItem( 0 );
+ }
+
+ int m_nCommonRedBlueId;
+ int m_nCommonId;
+ int m_nRedId;
+ int m_nBlueId;
+ int m_nColorAlphaId;
+ int m_nNormalId;
+ int m_nNormalAlphaId;
+
+ vgui::Label *m_pMaterialName;
+ vgui::ComboBox *m_pMaterialType;
+ vgui::ComboBox *m_pCommonRedBlue;
+ CFileLocationPanel *m_pCommonTextureFileLocation;
+ CFileLocationPanel *m_pRedTextureFileLocation;
+ CFileLocationPanel *m_pBlueTextureFileLocation;
+ vgui::ComboBox *m_pColorAlpha;
+ CFileLocationPanel *m_pNormalTextureFileLocation;
+ vgui::ComboBox *m_pNormalAlpha;
+
+ CMaterialSubPanel *m_pMaterialSubPanel;
+
+ int m_nVmtIndex;
+
+ void SetMaterialId( const char *pszMaterialName )
+ {
+ if ( !m_pMaterialName )
+ return;
+
+ m_pMaterialName->SetText( pszMaterialName );
+ }
+
+};
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CVmtEntry::OnTextChanged( vgui::Panel *pPanel )
+{
+ CTargetVMT *pTargetVMT = m_pMaterialSubPanel->GetTargetVMT( m_nVmtIndex );
+ if ( !pTargetVMT )
+ return;
+
+ bool bUpdate = false;
+
+ if ( pPanel == m_pMaterialType )
+ {
+ KeyValues *pUserData = m_pMaterialType->GetActiveItemUserData();
+ if ( pUserData )
+ {
+ if ( !V_strcmp( "Invalid", pUserData->GetName() ) )
+ {
+ pTargetVMT->SetMaterialType( CTargetVMT::kInvalidMaterialType );
+ }
+ else if ( !V_strcmp( "Primary", pUserData->GetName() ) )
+ {
+ pTargetVMT->SetMaterialType( CTargetVMT::kPrimary );
+ }
+ else if ( !V_strcmp( "Secondary", pUserData->GetName() ) )
+ {
+ pTargetVMT->SetMaterialType( CTargetVMT::kSecondary );
+ }
+ else if ( !V_strcmp( "DuplicateOfPrimary", pUserData->GetName() ) )
+ {
+ pTargetVMT->SetDuplicate( CTargetVMT::kPrimary );
+ }
+ else if ( !V_strcmp( "DuplicateOfSecondary", pUserData->GetName() ) )
+ {
+ pTargetVMT->SetDuplicate( CTargetVMT::kSecondary );
+ }
+ else
+ {
+ AssertMsg1( 0, "Unknown Material Type: %s\n", pUserData->GetName() );
+ }
+
+ bUpdate = true;
+ }
+ }
+ else if ( pPanel == m_pCommonRedBlue )
+ {
+ KeyValues *pUserData = m_pCommonRedBlue->GetActiveItemUserData();
+ if ( pUserData )
+ {
+ const bool bCommon = !V_strcmp( "Common", pUserData->GetName() );
+
+ pTargetVMT->SetColorMapCommon( bCommon );
+
+ bUpdate = true;
+ }
+ }
+ else if ( pPanel == m_pColorAlpha )
+ {
+ KeyValues *pUserData = m_pColorAlpha->GetActiveItemUserData();
+ if ( pUserData )
+ {
+ const char *pszUserData = pUserData->GetName();
+
+ if ( StringHasPrefix( pszUserData, "T" ) )
+ {
+ pTargetVMT->SetColorAlphaType( CTargetVMT::kTransparency );
+ }
+ else if ( StringHasPrefix( pszUserData, "P" ) )
+ {
+ pTargetVMT->SetColorAlphaType( CTargetVMT::kPaintable );
+ }
+ else if ( StringHasPrefix( pszUserData, "S" ) )
+ {
+ pTargetVMT->SetColorAlphaType( CTargetVMT::kColorSpecPhong );
+ }
+ else
+ {
+ pTargetVMT->SetColorAlphaType( CTargetVMT::kNoColorAlpha );
+ }
+
+ bUpdate = true;
+ }
+ }
+ else if ( pPanel == m_pNormalAlpha )
+ {
+ KeyValues *pUserData = m_pNormalAlpha->GetActiveItemUserData();
+ if ( pUserData )
+ {
+ const char *pszUserData = pUserData->GetName();
+
+ if ( StringHasPrefix( pszUserData, "S" ) )
+ {
+ pTargetVMT->SetNormalAlphaType( CTargetVMT::kNormalSpecPhong );
+ }
+ else
+ {
+ pTargetVMT->SetNormalAlphaType( CTargetVMT::kNoNormalAlpha );
+ }
+
+ bUpdate = true;
+ }
+ }
+
+ if ( bUpdate )
+ {
+ InvalidateLayout();
+ m_pMaterialSubPanel->InvalidateLayout();
+ m_pMaterialSubPanel->UpdateGUI();
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CVmtEntry::OnOpen( vgui::Panel *pPanel )
+{
+ if ( !m_pMaterialSubPanel )
+ return;
+
+ if ( pPanel == m_pCommonTextureFileLocation->m_pButtonBrowse )
+ {
+ m_pMaterialSubPanel->Browse( this, CMaterialSubPanel::kCommon );
+ }
+ else if ( pPanel == m_pRedTextureFileLocation->m_pButtonBrowse )
+ {
+ m_pMaterialSubPanel->Browse( this, CMaterialSubPanel::kRed );
+ }
+ else if ( pPanel == m_pBlueTextureFileLocation->m_pButtonBrowse )
+ {
+ m_pMaterialSubPanel->Browse( this, CMaterialSubPanel::kBlue );
+ }
+ else if ( pPanel == m_pNormalTextureFileLocation->m_pButtonBrowse )
+ {
+ m_pMaterialSubPanel->Browse( this, CMaterialSubPanel::kNormal );
+ }
+}
+
+
+//=============================================================================
+//
+//=============================================================================
+CMaterialSubPanel::CMaterialSubPanel( vgui::Panel *pParent, const char *pszName, const char *pszNextName )
+: BaseClass( pParent, pszName, pszNextName )
+{
+ m_pFileOpenStateMachine = new vgui::FileOpenStateMachine( this, this );
+ m_pFileOpenStateMachine->AddActionSignalTarget( this );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CMaterialSubPanel::InvalidateLayout()
+{
+ BaseClass::InvalidateLayout();
+ m_pPanelListPanel->InvalidateLayout();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CMaterialSubPanel::UpdateGUI()
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return;
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ int nMaterialCount = m_pPanelListPanel->GetItemCount() / 2;
+
+ CFmtStr sTmp;
+
+ // Add new gui elements & update existing
+ for ( int i = 0; i < asset.GetTargetVMTCount(); ++i )
+ {
+ if ( i >= nMaterialCount )
+ {
+ AddMaterial();
+ nMaterialCount = m_pPanelListPanel->GetItemCount() / 2;
+ }
+
+ if ( i >= nMaterialCount )
+ break; // unrecoverable error
+
+ CTargetVMT *pTargetVmt = asset.GetTargetVMT( i );
+ Assert( pTargetVmt );
+
+ if ( !pTargetVmt )
+ continue;
+
+ CVmtEntry *pVmtEntry = dynamic_cast< CVmtEntry * >( m_pPanelListPanel->GetItemPanel( i * 2 ) );
+ if ( !pVmtEntry )
+ continue;
+
+ CUtlString sMaterialId;
+ pTargetVmt->GetMaterialId( sMaterialId );
+ pVmtEntry->SetMaterialId( sMaterialId.Get() );
+
+ const bool bCommon = pTargetVmt->GetColorMapCommon();
+
+ pVmtEntry->m_pCommonRedBlue->SilentActivateItemByRow( bCommon ? 0 : 1 );
+
+ bool bVisible = true;
+
+ if ( pTargetVmt->GetDuplicate() )
+ {
+ bVisible = false;
+
+ switch ( pTargetVmt->GetMaterialType() )
+ {
+ case CTargetVMT::kInvalidMaterialType:
+ pVmtEntry->m_pMaterialType->SilentActivateItemByRow( 0 );
+ break;
+ case CTargetVMT::kPrimary:
+ pVmtEntry->m_pMaterialType->SilentActivateItemByRow( 3 );
+ break;
+ case CTargetVMT::kSecondary:
+ pVmtEntry->m_pMaterialType->SilentActivateItemByRow( 4 );
+ break;
+ default:
+ pVmtEntry->m_pMaterialType->ActivateItem( 0 );
+ break;
+ }
+ }
+ else
+ {
+ switch ( pTargetVmt->GetMaterialType() )
+ {
+ case CTargetVMT::kInvalidMaterialType:
+ pVmtEntry->m_pMaterialType->SilentActivateItemByRow( 0 );
+ break;
+ case CTargetVMT::kPrimary:
+ pVmtEntry->m_pMaterialType->SilentActivateItemByRow( 1 );
+ break;
+ case CTargetVMT::kSecondary:
+ pVmtEntry->m_pMaterialType->SilentActivateItemByRow( 2 );
+ break;
+ default:
+ pVmtEntry->m_pMaterialType->ActivateItem( 0 );
+ break;
+ }
+ }
+
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nCommonRedBlueId, bVisible );
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nCommonId, bVisible && bCommon );
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nRedId, bVisible && !bCommon );
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nBlueId, bVisible && !bCommon );
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nNormalId, bVisible );
+
+ bool bColorVisible = false;
+
+ CSmartPtr< CTargetVTF > pCommonTargetVTF = pTargetVmt->GetCommonTargetVTF();
+ if ( pCommonTargetVTF.IsValid() )
+ {
+ pVmtEntry->m_pCommonTextureFileLocation->m_pLabel->SetText( pCommonTargetVTF->GetInputFile() );
+ if ( pTargetVmt->GetColorMapCommon() && pCommonTargetVTF->HasAlpha() )
+ {
+ bColorVisible = true;
+ }
+ }
+ else
+ {
+ pVmtEntry->m_pCommonTextureFileLocation->m_pLabel->SetText( "" );
+ bColorVisible = false;
+ }
+
+ switch ( pTargetVmt->GetColorAlphaType() )
+ {
+ case CTargetVMT::kNoColorAlpha:
+ pVmtEntry->m_pColorAlpha->SilentActivateItemByRow( CTargetVMT::kNoColorAlpha );
+ break;
+ case CTargetVMT::kTransparency:
+ pVmtEntry->m_pColorAlpha->SilentActivateItemByRow( CTargetVMT::kTransparency );
+ break;
+ case CTargetVMT::kPaintable:
+ pVmtEntry->m_pColorAlpha->SilentActivateItemByRow( CTargetVMT::kPaintable );
+ break;
+ case CTargetVMT::kColorSpecPhong:
+ pVmtEntry->m_pColorAlpha->SilentActivateItemByRow( CTargetVMT::kColorSpecPhong );
+ break;
+ default:
+ pVmtEntry->m_pColorAlpha->SilentActivateItemByRow( CTargetVMT::kNoColorAlpha );
+ break;
+ }
+
+ CSmartPtr< CTargetVTF > pRedTargetVTF = pTargetVmt->GetRedTargetVTF();
+ CSmartPtr< CTargetVTF > pBlueTargetVTF = pTargetVmt->GetBlueTargetVTF();
+ if ( pRedTargetVTF.IsValid() )
+ {
+ pVmtEntry->m_pRedTextureFileLocation->m_pLabel->SetText( pRedTargetVTF->GetInputFile() );
+ }
+ else
+ {
+ pVmtEntry->m_pRedTextureFileLocation->m_pLabel->SetText( "" );
+ }
+
+ if ( pBlueTargetVTF.IsValid() )
+ {
+ pVmtEntry->m_pBlueTextureFileLocation->m_pLabel->SetText( pBlueTargetVTF->GetInputFile() );
+ }
+ else
+ {
+ pVmtEntry->m_pBlueTextureFileLocation->m_pLabel->SetText( "" );
+ }
+
+ if ( !pTargetVmt->GetColorMapCommon() && pRedTargetVTF.IsValid() && pBlueTargetVTF.IsValid() )
+ {
+ if ( pRedTargetVTF->HasAlpha() && pBlueTargetVTF->HasAlpha() )
+ {
+ bColorVisible = true;
+ }
+ }
+
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nColorAlphaId, bVisible && bColorVisible );
+
+ bool bNormalVisible = false;
+
+ CSmartPtr< CTargetVTF > pNormalTargetVTF = pTargetVmt->GetNormalTargetVTF();
+ if ( pNormalTargetVTF.IsValid() )
+ {
+ pVmtEntry->m_pNormalTextureFileLocation->m_pLabel->SetText( pNormalTargetVTF->GetInputFile() );
+ if ( pNormalTargetVTF->HasAlpha() )
+ {
+ bNormalVisible = true;
+ }
+ }
+
+ switch ( pTargetVmt->GetNormalAlphaType() )
+ {
+ case CTargetVMT::kNoNormalAlpha:
+ pVmtEntry->m_pNormalAlpha->SilentActivateItemByRow( CTargetVMT::kNoNormalAlpha );
+ break;
+ case CTargetVMT::kNormalSpecPhong:
+ pVmtEntry->m_pNormalAlpha->SilentActivateItemByRow( CTargetVMT::kNormalSpecPhong );
+ break;
+ default:
+ pVmtEntry->m_pNormalAlpha->SilentActivateItemByRow( CTargetVMT::kNoNormalAlpha );
+ break;
+ }
+
+ pVmtEntry->SetItemVisible( pVmtEntry->m_nNormalAlphaId, bVisible && bNormalVisible );
+
+ pVmtEntry->InvalidateLayout();
+ }
+
+ // Remove superfluous
+ while ( ( m_pPanelListPanel->GetItemCount() / 2 ) > asset.GetTargetVMTCount() )
+ {
+ m_pPanelListPanel->RemoveItem( m_pPanelListPanel->GetItemCount() - 1 );
+ m_pPanelListPanel->RemoveItem( m_pPanelListPanel->GetItemCount() - 1 );
+ }
+
+ InvalidateLayout();
+
+ UpdateStatus();
+}
+
+
+//-----------------------------------------------------------------------------
+// TODO: Set status
+//-----------------------------------------------------------------------------
+bool CMaterialSubPanel::UpdateStatus()
+{
+ CFmtStr sTmp;
+
+ int nIndex = 0;
+ for ( int i = 0; i < m_pPanelListPanel->GetItemCount(); i += 2, ++nIndex )
+ {
+ CVmtEntry *pVmtEntry = dynamic_cast< CVmtEntry * >( m_pPanelListPanel->GetItemPanel( i ) );
+ if ( !pVmtEntry )
+ continue;
+
+ CTargetVMT *pTargetVMT = GetTargetVMT( pVmtEntry->m_nVmtIndex );
+ Assert( pTargetVMT );
+ if ( !pTargetVMT )
+ continue;
+
+ sTmp.sprintf( "VMT%d", nIndex );
+
+ CUtlString sMsg;
+ if ( pTargetVMT->IsOk( sMsg ) )
+ {
+ SetStatus( true, sTmp );
+ continue;
+ }
+
+ if ( sMsg.IsEmpty() )
+ {
+ SetStatus( false, sTmp, "VMT is not valid\n" );
+ }
+ else
+ {
+ SetStatus( false, sTmp, sMsg.Get() );
+ }
+ }
+
+ bool bValid = BaseClass::UpdateStatus();
+
+ return bValid;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CMaterialSubPanel::SetupFileOpenDialog(
+ vgui::FileOpenDialog *pDialog,
+ bool bOpenFile,
+ const char *pszFileName,
+ KeyValues *pContextKeyValues )
+{
+ char pszStartingDir[ MAX_PATH ];
+
+ if ( !vgui::system()->GetRegistryString(
+ "HKEY_CURRENT_USER\\Software\\Valve\\itemtest\\texture\\opendir",
+ pszStartingDir, sizeof( pszStartingDir ) ) )
+ {
+ _getcwd( pszStartingDir, ARRAYSIZE( pszStartingDir ));
+
+ CUtlString sVMod;
+ CUtlString sContentDir;
+ if ( CItemUpload::GetVMod( sVMod ) && !sVMod.IsEmpty() && CItemUpload::GetContentDir( sContentDir ) && !sContentDir.IsEmpty() && CItemUpload::FileExists( sContentDir.Get() ) )
+ {
+ sContentDir += "/";
+ sContentDir += sVMod;
+ sContentDir += "/materialsrc/models";
+
+ CUtlString sTmp = sContentDir;
+ sTmp += "/player";
+
+ if ( CItemUpload::FileExists( sTmp.Get() ) )
+ {
+ sContentDir = sTmp;
+ sTmp += "/items";
+
+ if ( CItemUpload::FileExists( sTmp.Get() ) )
+ {
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( pItemUploadWizard )
+ {
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ sContentDir = sTmp;
+ sTmp += "/";
+ sTmp += asset.GetClass();
+ }
+
+ // TODO: Add steam id?
+
+ V_FixupPathName( pszStartingDir, ARRAYSIZE( pszStartingDir ), sTmp.Get() );
+ }
+ }
+ }
+ }
+
+ pDialog->SetStartDirectoryContext( "itemtest_texture_browser", pszStartingDir );
+
+ // TODO: Remember the mask the user likes
+ if ( bOpenFile )
+ {
+ pDialog->AddFilter( "*.tga", "Targa TrueVision File (*.tga)", true, "tga" );
+ pDialog->AddFilter( "*.psd", "Photoshop Document (*.psd)", false, "psd" );
+
+ pDialog->SetTitle( "Open Texture File", true );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CMaterialSubPanel::OnReadFileFromDisk(
+ const char *pszFileName,
+ const char *pszFileFormat,
+ KeyValues *pContextKeyValues )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return false;
+
+ char szBuf0[ MAX_PATH ];
+ char szBuf1[ MAX_PATH ];
+
+ // Extract path and save to registry to open browser there next time
+ {
+ V_strncpy( szBuf0, pszFileName, sizeof( szBuf0 ) );
+ V_FixSlashes( szBuf0 );
+ V_StripFilename( szBuf0 );
+
+ _fullpath( szBuf1, szBuf0, ARRAYSIZE( szBuf1 ) );
+
+ vgui::system()->SetRegistryString(
+ "HKEY_CURRENT_USER\\Software\\Valve\\itemtest\\texture\\opendir",
+ szBuf1 );
+ }
+
+ // Get the full path
+ _fullpath( szBuf1, pszFileName, ARRAYSIZE( szBuf1 ) );
+
+ CAsset &asset = pItemUploadWizard->Asset();
+
+ CVmtEntry *pVmtEntry = reinterpret_cast< CVmtEntry * >( pContextKeyValues->GetPtr( "pVmtEntry" ) );
+ const Browse_t nBrowseType = static_cast< Browse_t >( pContextKeyValues->GetInt( "nBrowseType" ) );
+
+ bool bReturnVal = false;
+
+ for ( int i = 0; i < m_pPanelListPanel->GetItemCount(); i += 2 )
+ {
+ if ( pVmtEntry == dynamic_cast< CVmtEntry * >( m_pPanelListPanel->GetItemPanel( i ) ) )
+ {
+ const int nVmtIndex = i / 2;
+ CTargetVMT *pTargetVMT = asset.GetTargetVMT( nVmtIndex );
+ if ( pTargetVMT )
+ {
+ bReturnVal = true;
+
+ switch( nBrowseType )
+ {
+ case CMaterialSubPanel::kCommon:
+ pTargetVMT->SetCommonTargetVTF( szBuf1 );
+ break;
+ case CMaterialSubPanel::kRed:
+ pTargetVMT->SetRedTargetVTF( szBuf1 );
+ break;
+ case CMaterialSubPanel::kBlue:
+ pTargetVMT->SetBlueTargetVTF( szBuf1 );
+ break;
+ case CMaterialSubPanel::kNormal:
+ pTargetVMT->SetNormalTargetVTF( szBuf1 );
+ break;
+ default:
+ bReturnVal = false;
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ UpdateGUI();
+
+ return bReturnVal;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+bool CMaterialSubPanel::OnWriteFileToDisk(
+ const char *pszFileName,
+ const char *pszFileFormat,
+ KeyValues *pContextKeyValues )
+{
+ return false;
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CMaterialSubPanel::Browse( CVmtEntry *pVmtEntry, Browse_t nBrowseType )
+{
+ if ( !pVmtEntry )
+ return;
+
+ KeyValues *pContextKeyValues = new KeyValues( "FileOpen", "nBrowseType", nBrowseType );
+ pContextKeyValues->SetPtr( "pVmtEntry", pVmtEntry );
+ m_pFileOpenStateMachine->OpenFile( "geometry", pContextKeyValues );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CTargetVMT *CMaterialSubPanel::GetTargetVMT( int nTargetVMTIndex )
+{
+ CItemUploadWizard *pItemUploadWizard = dynamic_cast< CItemUploadWizard * >( GetWizardPanel() );
+ if ( !pItemUploadWizard )
+ return NULL;
+
+ return pItemUploadWizard->Asset().GetTargetVMT( nTargetVMTIndex );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CMaterialSubPanel::AddMaterial()
+{
+ const int nIndex = m_pPanelListPanel->GetItemCount() / 2;
+
+ CFmtStr sLabel;
+ sLabel.sprintf( "#VMT%dLabel", nIndex );
+
+ vgui::Label *pLabel = new vgui::Label( this, sLabel, sLabel );
+ pLabel->SetContentAlignment( vgui::Label::a_center );
+
+ sLabel.sprintf( "#VMT%dLabel2", nIndex );
+
+ CVmtEntry *pVmtEntry = new CVmtEntry( this, sLabel, nIndex );
+
+ pVmtEntry->SetAutoResize( PIN_TOPLEFT, AUTORESIZE_RIGHT, 0, 0, 0, 0 );
+
+ m_pPanelListPanel->AddItem( pLabel, pVmtEntry );
+
+ sLabel.sprintf( "vmt%d", nIndex );
+ AddStatusPanels( sLabel );
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CItemUploadWizard::CItemUploadWizard(
+ vgui::Panel *pParent,
+ const char *pszName )
+: BaseClass( pParent, pszName )
+{
+ SetSize( 1024, 768 );
+ SetMinimumSize( 640, 480 );
+
+ vgui::WizardSubPanel *pSubPanel = NULL;
+ vgui::DHANDLE< vgui::WizardSubPanel > hSubPanel;
+
+ pSubPanel = new CGlobalSubPanel( this, "global", "geometry" );
+ pSubPanel->SetVisible( false );
+ hSubPanel = pSubPanel;
+ m_hSubPanelList.AddToTail( hSubPanel );
+
+ pSubPanel = new CGeometrySubPanel( this, "geometry", "texture" );
+ pSubPanel->SetVisible( false );
+ hSubPanel = pSubPanel;
+ m_hSubPanelList.AddToTail( hSubPanel );
+
+ pSubPanel = new CMaterialSubPanel( this, "texture", "final" );
+ pSubPanel->SetVisible( false );
+ hSubPanel = pSubPanel;
+ m_hSubPanelList.AddToTail( hSubPanel );
+
+ m_pFinalSubPanel = new CFinalSubPanel( this, "final", NULL );
+ pSubPanel = m_pFinalSubPanel;
+ pSubPanel->SetVisible( false );
+ hSubPanel = pSubPanel;
+ m_hSubPanelList.AddToTail( hSubPanel );
+
+ Run();
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+CItemUploadWizard::~CItemUploadWizard()
+{
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadWizard::Run()
+{
+ vgui::WizardSubPanel *pStartPanel = dynamic_cast< vgui::WizardSubPanel * >( FindChildByName( "global" ) );
+
+ if ( !pStartPanel )
+ {
+ Error( "Missing CItemUploadWizard global Panel" );
+ }
+
+ BaseClass::Run( pStartPanel );
+
+ MoveToCenterOfScreen();
+ Activate();
+
+ vgui::input()->SetAppModalSurface( GetVPanel() );
+
+ CGlobalSubPanel *pGlobalSubPanel = dynamic_cast< CGlobalSubPanel * >( pStartPanel );
+ if ( pGlobalSubPanel )
+ {
+ pGlobalSubPanel->UpdateStatus();
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadWizard::UpdateGUI()
+{
+ for ( int i = 0; i < m_hSubPanelList.Count(); ++i )
+ {
+ CItemUploadSubPanel *pSubPanel = dynamic_cast< CItemUploadSubPanel * >( m_hSubPanelList.Element( i ).Get() );
+ if ( !pSubPanel )
+ continue;
+
+ pSubPanel->UpdateGUI();
+ }
+
+ CItemUploadSubPanel *pItemUploadSubPanel = dynamic_cast< CItemUploadSubPanel * >( GetCurrentSubPanel() );
+ if ( pItemUploadSubPanel )
+ {
+ pItemUploadSubPanel->UpdateStatus();
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+void CItemUploadWizard::OnFinishButton()
+{
+ m_pFinalSubPanel->OnZip();
+} \ No newline at end of file
diff --git a/utils/itemtest_controls/itemtest_controls.vpc b/utils/itemtest_controls/itemtest_controls.vpc
new file mode 100644
index 0000000..edcaeb7
--- /dev/null
+++ b/utils/itemtest_controls/itemtest_controls.vpc
@@ -0,0 +1,36 @@
+//============ 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.
+//
+//=============================================================================
+
+
+$Macro SRCDIR "..\.."
+
+$Include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;VERSION_SAFE_STEAM_API_INTERFACES;ITEMUPLIB_LIB"
+ }
+}
+
+$Project "itemtest_controls"
+{
+ $Folder "Source Files"
+ {
+ $File "itemtest_controls.cpp"
+ $File "dualpanellist.cpp"
+ $File "globalsubpanel.cpp"
+ $File "finalsubpanel.cpp"
+ }
+
+ $Folder "Header Files"
+ {
+ $File "$SRCDIR\public\itemtest\itemtest_controls.h"
+ }
+}