diff --git a/src/game/client/tf/vgui/class_loadout_panel.cpp b/src/game/client/tf/vgui/class_loadout_panel.cpp index a6614b204..4551094af 100644 --- a/src/game/client/tf/vgui/class_loadout_panel.cpp +++ b/src/game/client/tf/vgui/class_loadout_panel.cpp @@ -686,6 +686,14 @@ void CClassLoadoutPanel::OnKeyCodePressed( vgui::KeyCode code ) OnCommand( VarArgs("change%d", nSelected ) ); } } + else if ( nButtonCode == KEY_XBUTTON_X || nButtonCode == STEAMCONTROLLER_X ) + { + int nSelected = GetFirstSelectedItemIndex( true ); + if( nSelected != -1 ) + { + OnCommand( VarArgs("preview%d", nSelected ) ); + } + } else { BaseClass::OnKeyCodePressed( code ); @@ -930,6 +938,23 @@ void CClassLoadoutPanel::OnItemPanelMouseReleased( vgui::Panel *panel ) } } +void CClassLoadoutPanel::OnItemPanelMouseRightRelease( vgui::Panel *panel ) +{ + CItemModelPanel *pItemPanel = dynamic_cast < CItemModelPanel * > ( panel ); + + if ( pItemPanel && IsVisible() ) + { + for ( int i = 0; i < m_pItemModelPanels.Count(); i++ ) + { + if ( m_pItemModelPanels[i] == pItemPanel ) + { + OnCommand( VarArgs("preview%d", i) ); + return; + } + } + } +} + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -1215,6 +1240,22 @@ void CClassLoadoutPanel::OnCommand( const char *command ) return; } + else if ( !V_strnicmp( command, "preview", 7 ) ) + { + const char *pszNum = command+7; + if ( pszNum && pszNum[0] ) + { + int iSlot = atoi(pszNum); + if ( iSlot >= 0 && iSlot < CLASS_LOADOUT_POSITION_COUNT && m_iCurrentClassIndex != TF_CLASS_UNDEFINED ) + { + if ( m_iCurrentSlotIndex != iSlot ) + { + m_iCurrentSlotIndex = iSlot; + UpdateModelPanels(); + } + } + } + } else if ( !V_strnicmp( command, "options", 7 ) ) { const char *pszNum = command + 7; diff --git a/src/game/client/tf/vgui/class_loadout_panel.h b/src/game/client/tf/vgui/class_loadout_panel.h index 894b0e662..65760d92c 100644 --- a/src/game/client/tf/vgui/class_loadout_panel.h +++ b/src/game/client/tf/vgui/class_loadout_panel.h @@ -84,6 +84,7 @@ public: CEconItemView *GetItemInSlot( int iSlot ); MESSAGE_FUNC_PTR( OnItemPanelMouseReleased, "ItemPanelMouseReleased", panel ); + MESSAGE_FUNC_PTR( OnItemPanelMouseRightRelease, "ItemPanelMouseRightRelease", panel ); MESSAGE_FUNC_PARAMS( OnSelectionReturned, "SelectionReturned", data ); MESSAGE_FUNC( OnCancelSelection, "CancelSelection" ); MESSAGE_FUNC( OnClosing, "Closing" );