summaryrefslogtreecommitdiff
path: root/game/client/game_controls/buymenu.cpp
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 /game/client/game_controls/buymenu.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/game_controls/buymenu.cpp')
-rw-r--r--game/client/game_controls/buymenu.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/game/client/game_controls/buymenu.cpp b/game/client/game_controls/buymenu.cpp
new file mode 100644
index 0000000..7d6160a
--- /dev/null
+++ b/game/client/game_controls/buymenu.cpp
@@ -0,0 +1,151 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "cbase.h"
+#include "buymenu.h"
+
+#include "buysubmenu.h"
+using namespace vgui;
+
+#include "mouseoverpanelbutton.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+CBuyMenu::CBuyMenu(IViewPort *pViewPort) : WizardPanel( NULL, PANEL_BUY )
+{
+ SetScheme("ClientScheme");
+ SetTitle( "#Cstrike_Buy_Menu", true);
+
+ SetMoveable(false);
+ SetSizeable(false);
+ SetProportional(true);
+
+ // hide the system buttons
+ SetTitleBarVisible( false );
+
+ SetAutoDelete( false ); // we reuse this panel, don't let WizardPanel delete us
+
+ LoadControlSettings( "Resource/UI/BuyMenu.res" );
+ ShowButtons( false );
+
+ m_pViewPort = pViewPort;
+
+ m_pMainMenu = new CBuySubMenu( this, "mainmenu" );
+ m_pMainMenu->LoadControlSettings( "Resource/UI/MainBuyMenu.res" );
+ m_pMainMenu->SetVisible( false );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor
+//-----------------------------------------------------------------------------
+CBuyMenu::~CBuyMenu()
+{
+ if ( m_pMainMenu )
+ m_pMainMenu->DeleteSubPanels(); //?
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: shows/hides the buy menu
+//-----------------------------------------------------------------------------
+void CBuyMenu::ShowPanel(bool bShow)
+{
+ if ( BaseClass::IsVisible() == bShow )
+ return;
+
+ if ( bShow )
+ {
+ Update();
+
+ Run( m_pMainMenu );
+
+ SetMouseInputEnabled( true );
+
+ engine->ClientCmd_Unrestricted( "gameui_preventescapetoshow\n" );
+ }
+ else
+ {
+ engine->ClientCmd_Unrestricted( "gameui_allowescapetoshow\n" );
+
+ SetVisible( false );
+ SetMouseInputEnabled( false );
+ }
+
+ m_pViewPort->ShowBackGround( bShow );
+}
+
+
+void CBuyMenu::Update()
+{
+ //Don't need to do anything, but do need to implement this function as base is pure virtual
+}
+void CBuyMenu::OnClose()
+{
+ engine->ClientCmd_Unrestricted( "gameui_allowescapetoshow\n" );
+
+ BaseClass::OnClose();
+ ResetHistory();
+}
+
+void CBuyMenu::OnKeyCodePressed( vgui::KeyCode code )
+{
+ int nDir = 0;
+
+ switch ( code )
+ {
+ case KEY_XBUTTON_UP:
+ case KEY_XSTICK1_UP:
+ case KEY_XSTICK2_UP:
+ case KEY_UP:
+ case STEAMCONTROLLER_DPAD_UP:
+ nDir = -1;
+ break;
+
+ case KEY_XBUTTON_DOWN:
+ case KEY_XSTICK1_DOWN:
+ case KEY_XSTICK2_DOWN:
+ case KEY_DOWN:
+ case STEAMCONTROLLER_DPAD_DOWN:
+ nDir = 1;
+ break;
+ }
+
+ if ( nDir != 0 )
+ {
+ Panel *pSubPanel = ( GetCurrentSubPanel() ? GetCurrentSubPanel() : m_pMainMenu );
+
+ CUtlSortVector< SortedPanel_t, CSortedPanelYLess > vecSortedButtons;
+ VguiPanelGetSortedChildButtonList( pSubPanel, (void*)&vecSortedButtons, "&", 0 );
+
+ if ( VguiPanelNavigateSortedChildButtonList( (void*)&vecSortedButtons, nDir ) != -1 )
+ {
+ // Handled!
+ return;
+ }
+ }
+ else
+ {
+ BaseClass::OnKeyCodePressed( code );
+ }
+}
+
+void CBuyMenu::OnKeyCodeTyped( KeyCode code )
+{
+ if ( code == KEY_ESCAPE )
+ {
+ OnClose();
+ }
+ else
+ {
+ BaseClass::OnKeyCodeTyped( code );
+ }
+}
+