This commit is contained in:
FluorescentCIAAfricanAmerican
2020-04-22 12:56:21 -04:00
commit 3bf9df6b27
15370 changed files with 5489726 additions and 0 deletions
+589
View File
@@ -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();
}
+144
View File
@@ -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
+410
View File
@@ -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;
}
+196
View File
@@ -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() );
}
File diff suppressed because it is too large Load Diff
@@ -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"
}
}