summaryrefslogtreecommitdiff
path: root/game/client/hl2mp/ui/hl2mptextwindow.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/hl2mp/ui/hl2mptextwindow.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/hl2mp/ui/hl2mptextwindow.cpp')
-rw-r--r--game/client/hl2mp/ui/hl2mptextwindow.cpp174
1 files changed, 174 insertions, 0 deletions
diff --git a/game/client/hl2mp/ui/hl2mptextwindow.cpp b/game/client/hl2mp/ui/hl2mptextwindow.cpp
new file mode 100644
index 0000000..dcf5a07
--- /dev/null
+++ b/game/client/hl2mp/ui/hl2mptextwindow.cpp
@@ -0,0 +1,174 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "cbase.h"
+#include "hl2mptextwindow.h"
+#include "backgroundpanel.h"
+#include <cdll_client_int.h>
+
+#include <vgui/IScheme.h>
+#include <vgui/ILocalize.h>
+#include <vgui/ISurface.h>
+#include <filesystem.h>
+#include <KeyValues.h>
+#include <convar.h>
+#include <vgui_controls/ImageList.h>
+
+#include <vgui_controls/TextEntry.h>
+#include <vgui_controls/Button.h>
+#include <vgui_controls/BuildGroup.h>
+
+#include "IGameUIFuncs.h" // for key bindings
+#include <igameresources.h>
+extern IGameUIFuncs *gameuifuncs; // for key binding details
+
+#include <game/client/iviewport.h>
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+using namespace vgui;
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+CHL2MPTextWindow::CHL2MPTextWindow(IViewPort *pViewPort) : CTextWindow( pViewPort )
+{
+ SetProportional( true );
+
+ m_iScoreBoardKey = BUTTON_CODE_INVALID; // this is looked up in Activate()
+
+ CreateBackground( this );
+ m_backgroundLayoutFinished = false;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor
+//-----------------------------------------------------------------------------
+CHL2MPTextWindow::~CHL2MPTextWindow()
+{
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::Update()
+{
+ BaseClass::Update();
+
+ m_pOK->RequestFocus();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::SetVisible(bool state)
+{
+ BaseClass::SetVisible(state);
+
+ if ( state )
+ {
+ m_pOK->RequestFocus();
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: shows the text window
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::ShowPanel(bool bShow)
+{
+ if ( bShow )
+ {
+ // get key binding if shown
+ if ( m_iScoreBoardKey == BUTTON_CODE_INVALID ) // you need to lookup the jump key AFTER the engine has loaded
+ {
+ m_iScoreBoardKey = gameuifuncs->GetButtonCodeForBind( "showscores" );
+ }
+ }
+
+ BaseClass::ShowPanel( bShow );
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::OnKeyCodePressed(KeyCode code)
+{
+ if ( m_iScoreBoardKey != BUTTON_CODE_INVALID && m_iScoreBoardKey == code )
+ {
+ gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, true );
+ gViewPortInterface->PostMessageToPanel( PANEL_SCOREBOARD, new KeyValues( "PollHideCode", "code", code ) );
+ }
+ else
+ {
+ BaseClass::OnKeyCodePressed( code );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: The CS background is painted by image panels, so we should do nothing
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::PaintBackground()
+{
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Scale / center the window
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::PerformLayout()
+{
+ BaseClass::PerformLayout();
+
+ // stretch the window to fullscreen
+ if ( !m_backgroundLayoutFinished )
+ LayoutBackgroundPanel( this );
+ m_backgroundLayoutFinished = true;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void CHL2MPTextWindow::ApplySchemeSettings( vgui::IScheme *pScheme )
+{
+ BaseClass::ApplySchemeSettings( pScheme );
+ ApplyBackgroundSchemeSettings( this, pScheme );
+}
+
+CHL2MPSpectatorGUI::CHL2MPSpectatorGUI(IViewPort *pViewPort) : CSpectatorGUI(pViewPort)
+{
+}
+
+
+bool CHL2MPSpectatorGUI::NeedsUpdate( void )
+{
+ if ( !C_BasePlayer::GetLocalPlayer() )
+ return false;
+
+ if ( m_nLastSpecMode != C_BasePlayer::GetLocalPlayer()->GetObserverMode() )
+ return true;
+
+ if ( m_nLastSpecTarget != C_BasePlayer::GetLocalPlayer()->GetObserverTarget() )
+ return true;
+
+ return BaseClass::NeedsUpdate();
+}
+
+
+void CHL2MPSpectatorGUI::Update()
+{
+ BaseClass::Update();
+
+ C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
+
+ if( pLocalPlayer )
+ {
+ m_nLastSpecMode = pLocalPlayer->GetObserverMode();
+ m_nLastSpecTarget = pLocalPlayer->GetObserverTarget();
+ }
+}
+
+