Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/game/client/econ/item_style_select_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,36 @@
#include <tier0/memdbgon.h>





class CStyleComboMenu : public vgui::Menu
{
DECLARE_CLASS_SIMPLE(CStyleComboMenu, vgui::Menu);

public:
CStyleComboMenu(vgui::Panel* pParent, const char* pszName)
: BaseClass(pParent, pszName)
{
}

virtual void OnKeyCodeTyped(vgui::KeyCode code)
{
if (code == KEY_ESCAPE)
{
SetVisible(false);
PostActionSignal(new KeyValues("ComboBoxEscape"));
return;
}

BaseClass::OnKeyCodeTyped(code);
}
};





//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand All @@ -35,6 +65,10 @@ CComboBoxBackpackOverlayDialogBase::CComboBoxBackpackOverlayDialogBase( vgui::Pa
}

m_pComboBox = new vgui::ComboBox( this, "ComboBox", 5, false );
CStyleComboMenu* pMenu = new CStyleComboMenu(m_pComboBox, "StyleComboMenu");

pMenu->AddActionSignalTarget(this);
m_pComboBox->SetMenu(pMenu);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -75,6 +109,25 @@ void CComboBoxBackpackOverlayDialogBase::ApplySchemeSettings( vgui::IScheme *pSc
}
}


void CComboBoxBackpackOverlayDialogBase::OnComboBoxEscape()
{
OnCommand("cancel");
}


void CComboBoxBackpackOverlayDialogBase::OnKeyCodeTyped(vgui::KeyCode code)
{
if (code == KEY_ESCAPE)
{
OnCommand("cancel");
return;
}

BaseClass::OnKeyCodeTyped(code);
}


//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/game/client/econ/item_style_select_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ class CComboBoxBackpackOverlayDialogBase : public vgui::EditablePanel
virtual void PopulateComboBoxOptions() = 0;
virtual void OnComboBoxApplication() = 0;
virtual void OnComboBoxChanged( int iNewSelection ) { }
virtual void OnKeyCodeTyped(vgui::KeyCode code);
virtual const char *GetTitleLabelLocalizationToken() const = 0;

MESSAGE_FUNC_PARAMS( OnTextChanged, "TextChanged", data );
MESSAGE_FUNC(OnComboBoxEscape, "ComboBoxEscape");

CItemModelPanel *m_pPreviewModelPanel;
vgui::ComboBox *m_pComboBox;
Expand Down