add source-sdk-2013

This commit is contained in:
nillerusr
2022-03-01 23:00:42 +03:00
parent 88b8830e8b
commit edc8d6c584
3288 changed files with 3731 additions and 1062455 deletions
-677
View File
@@ -1,677 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "backgroundpanel.h"
#include <vgui/IVGui.h>
#include <vgui/IScheme.h>
#include <vgui/ISurface.h>
#include <vgui_controls/Label.h>
#include <vgui/ILocalize.h>
#include "vgui_controls/BuildGroup.h"
#include "vgui_controls/BitmapImagePanel.h"
using namespace vgui;
#define DEBUG_WINDOW_RESIZING 0
#define DEBUG_WINDOW_REPOSITIONING 0
//-----------------------------------------------------------------------------
const int NumSegments = 7;
static int coord[NumSegments+1] = {
0,
1,
2,
3,
4,
6,
9,
10
};
//-----------------------------------------------------------------------------
void DrawRoundedBackground( Color bgColor, int wide, int tall )
{
int x1, x2, y1, y2;
surface()->DrawSetColor(bgColor);
surface()->DrawSetTextColor(bgColor);
int i;
// top-left corner --------------------------------------------------------
int xDir = 1;
int yDir = -1;
int xIndex = 0;
int yIndex = NumSegments - 1;
int xMult = 1;
int yMult = 1;
int x = 0;
int y = 0;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
y2 = y + coord[NumSegments];
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// top-right corner -------------------------------------------------------
xDir = 1;
yDir = -1;
xIndex = 0;
yIndex = NumSegments - 1;
x = wide;
y = 0;
xMult = -1;
yMult = 1;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
y2 = y + coord[NumSegments];
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// bottom-right corner ----------------------------------------------------
xDir = 1;
yDir = -1;
xIndex = 0;
yIndex = NumSegments - 1;
x = wide;
y = tall;
xMult = -1;
yMult = -1;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = y - coord[NumSegments];
y2 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// bottom-left corner -----------------------------------------------------
xDir = 1;
yDir = -1;
xIndex = 0;
yIndex = NumSegments - 1;
x = 0;
y = tall;
xMult = 1;
yMult = -1;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = y - coord[NumSegments];
y2 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// paint between top left and bottom left ---------------------------------
x1 = 0;
x2 = coord[NumSegments];
y1 = coord[NumSegments];
y2 = tall - coord[NumSegments];
surface()->DrawFilledRect( x1, y1, x2, y2 );
// paint between left and right -------------------------------------------
x1 = coord[NumSegments];
x2 = wide - coord[NumSegments];
y1 = 0;
y2 = tall;
surface()->DrawFilledRect( x1, y1, x2, y2 );
// paint between top right and bottom right -------------------------------
x1 = wide - coord[NumSegments];
x2 = wide;
y1 = coord[NumSegments];
y2 = tall - coord[NumSegments];
surface()->DrawFilledRect( x1, y1, x2, y2 );
}
//-----------------------------------------------------------------------------
void DrawRoundedBorder( Color borderColor, int wide, int tall )
{
int x1, x2, y1, y2;
surface()->DrawSetColor(borderColor);
surface()->DrawSetTextColor(borderColor);
int i;
// top-left corner --------------------------------------------------------
int xDir = 1;
int yDir = -1;
int xIndex = 0;
int yIndex = NumSegments - 1;
int xMult = 1;
int yMult = 1;
int x = 0;
int y = 0;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// top-right corner -------------------------------------------------------
xDir = 1;
yDir = -1;
xIndex = 0;
yIndex = NumSegments - 1;
x = wide;
y = 0;
xMult = -1;
yMult = 1;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// bottom-right corner ----------------------------------------------------
xDir = 1;
yDir = -1;
xIndex = 0;
yIndex = NumSegments - 1;
x = wide;
y = tall;
xMult = -1;
yMult = -1;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// bottom-left corner -----------------------------------------------------
xDir = 1;
yDir = -1;
xIndex = 0;
yIndex = NumSegments - 1;
x = 0;
y = tall;
xMult = 1;
yMult = -1;
for ( i=0; i<NumSegments; ++i )
{
x1 = MIN( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
x2 = MAX( x + coord[xIndex]*xMult, x + coord[xIndex+1]*xMult );
y1 = MIN( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
y2 = MAX( y + coord[yIndex]*yMult, y + coord[yIndex+1]*yMult );
surface()->DrawFilledRect( x1, y1, x2, y2 );
xIndex += xDir;
yIndex += yDir;
}
// top --------------------------------------------------------------------
x1 = coord[NumSegments];
x2 = wide - coord[NumSegments];
y1 = 0;
y2 = 1;
surface()->DrawFilledRect( x1, y1, x2, y2 );
// bottom -----------------------------------------------------------------
x1 = coord[NumSegments];
x2 = wide - coord[NumSegments];
y1 = tall - 1;
y2 = tall;
surface()->DrawFilledRect( x1, y1, x2, y2 );
// left -------------------------------------------------------------------
x1 = 0;
x2 = 1;
y1 = coord[NumSegments];
y2 = tall - coord[NumSegments];
surface()->DrawFilledRect( x1, y1, x2, y2 );
// right ------------------------------------------------------------------
x1 = wide - 1;
x2 = wide;
y1 = coord[NumSegments];
y2 = tall - coord[NumSegments];
surface()->DrawFilledRect( x1, y1, x2, y2 );
}
//-----------------------------------------------------------------------------
class CaptionLabel : public Label
{
public:
CaptionLabel(Panel *parent, const char *panelName, const char *text) : Label(parent, panelName, text)
{
}
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
{
Label::ApplySchemeSettings( pScheme );
SetFont( pScheme->GetFont( "MenuTitle", IsProportional() ) );
}
};
//-----------------------------------------------------------------------------
// Purpose: transform a normalized value into one that is scaled based the minimum
// of the horizontal and vertical ratios
//-----------------------------------------------------------------------------
static int GetAlternateProportionalValueFromNormal(int normalizedValue)
{
int wide, tall;
GetHudSize( wide, tall );
int proH, proW;
surface()->GetProportionalBase( proW, proH );
double scaleH = (double)tall / (double)proH;
double scaleW = (double)wide / (double)proW;
double scale = (scaleW < scaleH) ? scaleW : scaleH;
return (int)( normalizedValue * scale );
}
//-----------------------------------------------------------------------------
// Purpose: transform a standard scaled value into one that is scaled based the minimum
// of the horizontal and vertical ratios
//-----------------------------------------------------------------------------
int GetAlternateProportionalValueFromScaled(vgui::HScheme hScheme, int scaledValue)
{
return GetAlternateProportionalValueFromNormal( scheme()->GetProportionalNormalizedValueEx( hScheme, scaledValue ) );
}
//-----------------------------------------------------------------------------
// Purpose: moves and resizes a single control
//-----------------------------------------------------------------------------
static void RepositionControl( Panel *pPanel )
{
int x, y, w, h;
pPanel->GetBounds(x, y, w, h);
#if DEBUG_WINDOW_RESIZING
int x1, y1, w1, h1;
pPanel->GetBounds(x1, y1, w1, h1);
int x2, y2, w2, h2;
x2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),x1 );
y2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),y1 );
w2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),w1 );
h2 = scheme()->GetProportionalNormalizedValueEx( pPanel->GetScheme(),h1 );
#endif
x = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),x);
y = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),y);
w = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),w);
h = GetAlternateProportionalValueFromScaled(pPanel->GetScheme(),h);
pPanel->SetBounds(x, y, w, h);
#if DEBUG_WINDOW_RESIZING
DevMsg( "Resizing '%s' from (%d,%d) %dx%d to (%d,%d) %dx%d -- initially was (%d,%d) %dx%d\n",
pPanel->GetName(), x1, y1, w1, h1, x, y, w, h, x2, y2, w2, h2 );
#endif
}
//-----------------------------------------------------------------------------
// Purpose: Sets colors etc for background image panels
//-----------------------------------------------------------------------------
void ApplyBackgroundSchemeSettings( EditablePanel *pWindow, vgui::IScheme *pScheme )
{
Color bgColor = Color( 255, 255, 255, pScheme->GetColor( "BgColor", Color( 0, 0, 0, 0 ) )[3] );
Color fgColor = pScheme->GetColor( "FgColor", Color( 0, 0, 0, 0 ) );
if ( !pWindow )
return;
CBitmapImagePanel *pBitmapPanel;
// corners --------------------------------------------
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopLeftPanel" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopRightPanel" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomLeftPanel" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomRightPanel" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
// background -----------------------------------------
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "TopSolid" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "UpperMiddleSolid" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "LowerMiddleSolid" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "BottomSolid" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( bgColor );
}
// Logo -----------------------------------------------
/* pBitmapPanel = dynamic_cast< CBitmapImagePanel * >(pWindow->FindChildByName( "ExclamationPanel" ));
if ( pBitmapPanel )
{
pBitmapPanel->setImageColor( fgColor );
}
*/
}
//-----------------------------------------------------------------------------
// Purpose: Re-aligns background image panels so they are touching.
//-----------------------------------------------------------------------------
static void FixupBackgroundPanels( EditablePanel *pWindow, int offsetX, int offsetY )
{
if ( !pWindow )
return;
int screenWide, screenTall;
pWindow->GetSize( screenWide, screenTall );
int inset = GetAlternateProportionalValueFromNormal( 20 );
int cornerSize = GetAlternateProportionalValueFromNormal( 10 );
int titleHeight = GetAlternateProportionalValueFromNormal( 42 );
int mainHeight = GetAlternateProportionalValueFromNormal( 376 );
int logoSize = titleHeight;
int captionInset = GetAlternateProportionalValueFromNormal( 76 );
Panel *pPanel;
// corners --------------------------------------------
pPanel = pWindow->FindChildByName( "TopLeftPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, offsetY + inset, cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "TopRightPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, offsetY + inset, cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "BottomLeftPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "BottomRightPanel" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( screenWide - offsetX - inset - cornerSize, screenTall - offsetY - inset - cornerSize, cornerSize, cornerSize );
}
// background -----------------------------------------
pPanel = pWindow->FindChildByName( "TopSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset + cornerSize, offsetY + inset, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "UpperMiddleSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, offsetY + inset + cornerSize, screenWide - 2*offsetX - 2*inset, titleHeight );
}
pPanel = pWindow->FindChildByName( "LowerMiddleSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset + cornerSize, screenTall - offsetY - inset - cornerSize, screenWide - 2*offsetX - 2*inset - 2*cornerSize, cornerSize );
}
pPanel = pWindow->FindChildByName( "BottomSolid" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( offsetX + inset, screenTall - offsetY - inset - cornerSize - mainHeight, screenWide - 2*offsetX - 2*inset, mainHeight );
}
// transparent border ---------------------------------
pPanel = pWindow->FindChildByName( "TopClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( 0, 0, screenWide, offsetY + inset );
}
pPanel = pWindow->FindChildByName( "BottomClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( 0, screenTall - offsetY - inset, screenWide, offsetY + inset );
}
pPanel = pWindow->FindChildByName( "LeftClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( 0, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset );
}
pPanel = pWindow->FindChildByName( "RightClear" );
if ( pPanel )
{
pPanel->SetZPos( -20 );
pPanel->SetBounds( screenWide - offsetX - inset, offsetY + inset, offsetX + inset, screenTall - 2*offsetY - 2*inset );
}
// Logo -----------------------------------------------
/* int logoInset = (cornerSize + titleHeight - logoSize)/2;
pPanel = pWindow->FindChildByName( "ExclamationPanel" );
if ( pPanel )
{
pPanel->SetZPos( -19 ); // higher than the background
pPanel->SetBounds( offsetX + inset + logoInset, offsetY + inset + logoInset, logoSize, logoSize );
}
*/
// Title caption --------------------------------------
pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" ));
if ( pPanel )
{
pPanel->SetZPos( -19 ); // higher than the background
pPanel->SetBounds( offsetX + captionInset/*inset + 2*logoInset + logoSize*/, offsetY + inset /*+ logoInset*/, screenWide, logoSize );
}
}
//-----------------------------------------------------------------------------
// Purpose: Creates background image panels
//-----------------------------------------------------------------------------
void CreateBackground( EditablePanel *pWindow )
{
// corners --------------------------------------------
new CBitmapImagePanel( pWindow, "TopLeftPanel", "gfx/vgui/round_corner_nw" );
new CBitmapImagePanel( pWindow, "TopRightPanel", "gfx/vgui/round_corner_ne" );
new CBitmapImagePanel( pWindow, "BottomLeftPanel", "gfx/vgui/round_corner_sw" );
new CBitmapImagePanel( pWindow, "BottomRightPanel", "gfx/vgui/round_corner_se" );
// background -----------------------------------------
new CBitmapImagePanel( pWindow, "TopSolid", "gfx/vgui/solid_background" );
new CBitmapImagePanel( pWindow, "UpperMiddleSolid", "gfx/vgui/solid_background" );
new CBitmapImagePanel( pWindow, "LowerMiddleSolid", "gfx/vgui/solid_background" );
new CBitmapImagePanel( pWindow, "BottomSolid", "gfx/vgui/solid_background" );
// transparent border ---------------------------------
new CBitmapImagePanel( pWindow, "TopClear", "gfx/vgui/trans_background" );
new CBitmapImagePanel( pWindow, "BottomClear", "gfx/vgui/trans_background" );
new CBitmapImagePanel( pWindow, "LeftClear", "gfx/vgui/trans_background" );
new CBitmapImagePanel( pWindow, "RightClear", "gfx/vgui/trans_background" );
// Logo -----------------------------------------------
// new CBitmapImagePanel( pWindow, "ExclamationPanel", "gfx/vgui/TF_logo" );
// Title caption --------------------------------------
Panel *pPanel = dynamic_cast< Label * >(pWindow->FindChildByName( "CaptionLabel" ));
if ( !pPanel )
new CaptionLabel( pWindow, "CaptionLabel", "" );
}
void ResizeWindowControls( EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY )
{
if (!pWindow || !pWindow->GetBuildGroup() || !pWindow->GetBuildGroup()->GetPanelList())
return;
CUtlVector<PHandle> *panelList = pWindow->GetBuildGroup()->GetPanelList();
CUtlVector<Panel *> resizedPanels;
CUtlVector<Panel *> movedPanels;
// Resize to account for 1.25 aspect ratio (1280x1024) screens
{
for ( int i = 0; i < panelList->Size(); ++i )
{
PHandle handle = (*panelList)[i];
Panel *panel = handle.Get();
bool found = false;
for ( int j = 0; j < resizedPanels.Size(); ++j )
{
if (panel == resizedPanels[j])
found = true;
}
if (!panel || found)
{
continue;
}
resizedPanels.AddToTail( panel ); // don't move a panel more than once
if ( panel != pWindow )
{
RepositionControl( panel );
}
}
}
// and now re-center them. Woohoo!
for ( int i = 0; i < panelList->Size(); ++i )
{
PHandle handle = (*panelList)[i];
Panel *panel = handle.Get();
bool found = false;
for ( int j = 0; j < movedPanels.Size(); ++j )
{
if (panel == movedPanels[j])
found = true;
}
if (!panel || found)
{
continue;
}
movedPanels.AddToTail( panel ); // don't move a panel more than once
if ( panel != pWindow )
{
int x, y;
panel->GetPos( x, y );
panel->SetPos( x + offsetX, y + offsetY );
#if DEBUG_WINDOW_REPOSITIONING
DevMsg( "Repositioning '%s' from (%d,%d) to (%d,%d) -- a distance of (%d,%d)\n",
panel->GetName(), x, y, x + offsetX, y + offsetY, offsetX, offsetY );
#endif
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Resizes windows to fit completely on-screen (for 1280x1024), and
// centers them on the screen. Sub-controls are also resized and moved.
//-----------------------------------------------------------------------------
void LayoutBackgroundPanel( EditablePanel *pWindow )
{
if ( !pWindow )
return;
int screenW, screenH;
GetHudSize( screenW, screenH );
int wide, tall;
pWindow->GetSize( wide, tall );
int offsetX = 0;
int offsetY = 0;
// Slide everything over to the center
pWindow->SetBounds( 0, 0, screenW, screenH );
if ( wide != screenW || tall != screenH )
{
wide = GetAlternateProportionalValueFromScaled(pWindow->GetScheme(), wide);
tall = GetAlternateProportionalValueFromScaled(pWindow->GetScheme(), tall);
offsetX = (screenW - wide)/2;
offsetY = (screenH - tall)/2;
ResizeWindowControls( pWindow, tall, wide, offsetX, offsetY );
}
// now that the panels are moved/resized, look for some bg panels, and re-align them
FixupBackgroundPanels( pWindow, offsetX, offsetY );
}
//-----------------------------------------------------------------------------
-53
View File
@@ -1,53 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODBACKGROUND_H
#define DODBACKGROUND_H
#include <vgui_controls/Frame.h>
#include <vgui_controls/EditablePanel.h>
//-----------------------------------------------------------------------------
// Purpose: Creates background image panels
//-----------------------------------------------------------------------------
void CreateBackground( vgui::EditablePanel *pWindow );
//-----------------------------------------------------------------------------
// Purpose: Resizes windows to fit completely on-screen (for 1280x1024), and
// centers them on the screen. Sub-controls are also resized and moved.
//-----------------------------------------------------------------------------
void LayoutBackgroundPanel( vgui::EditablePanel *pWindow );
//-----------------------------------------------------------------------------
// Purpose: Sets colors etc for background image panels
//-----------------------------------------------------------------------------
void ApplyBackgroundSchemeSettings( vgui::EditablePanel *pWindow, vgui::IScheme *pScheme );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ResizeWindowControls( vgui::EditablePanel *pWindow, int tall, int wide, int offsetX, int offsetY );
//-----------------------------------------------------------------------------
// Purpose: transform a standard scaled value into one that is scaled based the minimum
// of the horizontal and vertical ratios
//-----------------------------------------------------------------------------
int GetAlternateProportionalValueFromScaled( vgui::HScheme hScheme, int scaledValue );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void DrawRoundedBackground( Color bgColor, int wide, int tall );
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void DrawRoundedBorder( Color borderColor, int wide, int tall );
//-----------------------------------------------------------------------------
#endif // DODBACKGROUND_H
-99
View File
@@ -1,99 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "dodbutton.h"
#include <vgui/ISurface.h>
#include <vgui_controls/EditablePanel.h>
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
using namespace vgui;
//===============================================
// CDODButtonShape - drawing class for dod button shape
//===============================================
void CDODButtonShape::DrawShapedBorder( int x, int y, int wide, int tall, Color fgcolor )
{
int halfheight = tall / 3;
surface()->DrawSetColor(fgcolor);
// top
surface()->DrawLine( 0, 1, wide-1, 1 );
// left
surface()->DrawLine( 1, 1, 1, tall-1 );
// bottom
surface()->DrawLine( 0, tall-1, wide-halfheight, tall-1 );
// right
surface()->DrawLine( wide-1, 0, wide-1, tall-halfheight );
// diagonal
surface()->DrawLine( wide-1, tall-halfheight-1, wide-halfheight-1, tall-1 );
}
void CDODButtonShape::DrawShapedBackground( int x, int y, int wide, int tall, Color bgcolor )
{
int halfheight = tall / 3;
if ( m_iWhiteTexture < 0 )
{
m_iWhiteTexture = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile( m_iWhiteTexture, "vgui/white" , true, false);
}
surface()->DrawSetColor(bgcolor);
surface()->DrawSetTexture( m_iWhiteTexture );
Vertex_t verts[5];
verts[0].Init( Vector2D( 0, 0 ) );
verts[1].Init( Vector2D( wide-1, 0 ) );
verts[2].Init( Vector2D( wide-1, tall-halfheight ) );
verts[3].Init( Vector2D( wide-halfheight, tall-1 ) );
verts[4].Init( Vector2D( 0, tall-1 ) );
surface()->DrawTexturedPolygon(5, verts);
surface()->DrawSetTexture(0);
}
//===============================================
// CDODButton - shaped button
//===============================================
void CDODButton::PaintBackground()
{
int wide, tall;
GetSize(wide,tall);
DrawShapedBackground( 0, 0, wide, tall, GetBgColor() );
}
void CDODButton::PaintBorder()
{
int wide, tall;
GetSize(wide,tall);
DrawShapedBorder( 0, 0, wide, tall, GetFgColor() );
}
//===============================================
// CDODProgressBar - used for weapon stat bars
//===============================================
void CDODProgressBar::ApplySchemeSettings(IScheme *pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);
SetFgColor( GetSchemeColor("ClassMenuLight", pScheme ) );
SetBgColor( GetSchemeColor("ClassMenuDark", pScheme ) );
SetBarInset(0);
SetSegmentInfo( 0, 1 );
SetBorder(NULL);
}
-88
View File
@@ -1,88 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DOD_BUTTON_H
#define DOD_BUTTON_H
#include "mouseoverpanelbutton.h"
#include "KeyValues.h"
#include <vgui/IScheme.h>
#include <vgui_controls/ProgressBar.h>
#include <vgui_controls/EditablePanel.h>
// a button with the bottom right corner cut out
/*
|``````````````|
| PRESS ME! |
|_____________/
*/
class CDODButtonShape
{
public:
CDODButtonShape()
{
m_iWhiteTexture = -1;
}
void DrawShapedBorder( int x, int y, int wide, int tall, Color fgcolor );
void DrawShapedBackground( int x, int y, int wide, int tall, Color bgcolor );
protected:
int m_iWhiteTexture;
};
class CDODButton : public vgui::Button, public CDODButtonShape
{
private:
DECLARE_CLASS_SIMPLE( CDODButton, vgui::Button );
public:
CDODButton(vgui::Panel *parent ) :
vgui::Button( parent, "DODButton", "" )
{
}
protected:
virtual void PaintBackground();
virtual void PaintBorder();
};
class CDODClassInfoPanel : public vgui::EditablePanel
{
private:
DECLARE_CLASS_SIMPLE( CDODClassInfoPanel, vgui::EditablePanel );
public:
CDODClassInfoPanel( vgui::Panel *parent, const char *panelName ) : vgui::EditablePanel( parent, panelName )
{
}
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual vgui::Panel *CreateControlByName( const char *controlName );
};
// Solid coloured progress bar with no border
class CDODProgressBar : public vgui::ProgressBar
{
private:
DECLARE_CLASS_SIMPLE( CDODProgressBar, vgui::ProgressBar );
public:
CDODProgressBar(vgui::Panel *parent) : vgui::ProgressBar( parent, "statBar" )
{
}
protected:
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
};
#endif //DOD_BUTTON_H
-353
View File
@@ -1,353 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "dodclassmenu.h"
#include <KeyValues.h>
#include <filesystem.h>
#include <vgui_controls/Button.h>
#include <vgui_controls/RichText.h>
#include <vgui/IVGui.h>
#include "hud.h" // for gEngfuncs
#include "c_dod_player.h"
#include "c_dod_team.h"
#include "imagemouseoverbutton.h"
#include "dodmouseoverpanelbutton.h"
#include "dodrandombutton.h"
#include "IconPanel.h"
#include "IGameUIFuncs.h" // for key bindings
extern IGameUIFuncs *gameuifuncs; // for key binding details
using namespace vgui;
extern ConVar hud_classautokill;
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Panel *CDODClassInfoPanel::CreateControlByName( const char *controlName )
{
if( !Q_stricmp( "ProgressBar", controlName ) )
{
return new CDODProgressBar(this);
}
else if ( !Q_stricmp( "CIconPanel", controlName ) )
{
return new CIconPanel(this, "icon_panel");
}
else
{
return BaseClass::CreateControlByName( controlName );
}
}
void CDODClassInfoPanel::ApplySchemeSettings( IScheme *pScheme )
{
RichText *pClassInfo = dynamic_cast<RichText*>(FindChildByName("classInfo"));
if ( pClassInfo )
{
pClassInfo->SetBorder(pScheme->GetBorder("NoBorder"));
pClassInfo->SetBgColor(pScheme->GetColor("Blank", Color(0,0,0,0)));
}
BaseClass::ApplySchemeSettings( pScheme );
}
CDODClassMenu::CDODClassMenu(IViewPort *pViewPort) : CClassMenu(pViewPort)
{
m_mouseoverButtons.RemoveAll();
m_iClassMenuKey = BUTTON_CODE_INVALID;
m_pInitialButton = NULL;
m_pBackground = SETUP_PANEL( new CDODMenuBackground( this ) );
m_pClassInfoPanel = new CDODClassInfoPanel( this, "ClassInfoPanel" );
vgui::ivgui()->AddTickSignal( GetVPanel() );
m_iActivePlayerClass = -1;
m_iLastPlayerClassCount = -1;
m_pClassNumLabel[0] = new Label( this, "class_1_num", "" );
m_pClassNumLabel[1] = new Label( this, "class_2_num", "" );
m_pClassNumLabel[2] = new Label( this, "class_3_num", "" );
m_pClassNumLabel[3] = new Label( this, "class_4_num", "" );
m_pClassNumLabel[4] = new Label( this, "class_5_num", "" );
m_pClassNumLabel[5] = new Label( this, "class_6_num", "" );
m_pClassFullLabel[0] = new Label( this, "class_1_full", "" );
m_pClassFullLabel[1] = new Label( this, "class_2_full", "" );
m_pClassFullLabel[2] = new Label( this, "class_3_full", "" );
m_pClassFullLabel[3] = new Label( this, "class_4_full", "" );
m_pClassFullLabel[4] = new Label( this, "class_5_full", "" );
m_pClassFullLabel[5] = new Label( this, "class_6_full", "" );
m_pSuicideOption = new CheckButton( this, "suicide_option", "Sky is blue?" );
}
void CDODClassMenu::ShowPanel( bool bShow )
{
if ( bShow )
{
engine->CheckPoint( "ClassMenu" );
m_iClassMenuKey = gameuifuncs->GetButtonCodeForBind( "changeclass" );
m_pSuicideOption->SetSelected( hud_classautokill.GetBool() );
}
for( int i = 0; i< GetChildCount(); i++ )
{
CImageMouseOverButton<CDODClassInfoPanel> *button =
dynamic_cast<CImageMouseOverButton<CDODClassInfoPanel> *>(GetChild(i));
if ( button )
{
if( button == m_pInitialButton && bShow == true )
button->ShowPage();
else
button->HidePage();
}
}
CDODRandomButton<CDODClassInfoPanel> *pRandom =
dynamic_cast<CDODRandomButton<CDODClassInfoPanel> *>( FindChildByName("random") );
if ( pRandom )
pRandom->HidePage();
// recalc position of checkbox, since it doesn't do right alignment
m_pSuicideOption->SizeToContents();
int x, y, wide, tall;
m_pSuicideOption->GetBounds( x, y, wide, tall );
int parentW, parentH;
GetSize( parentW, parentH );
x = parentW / 2; // - wide;
m_pSuicideOption->SetPos( x, y );
BaseClass::ShowPanel( bShow );
}
void CDODClassMenu::OnKeyCodePressed( KeyCode code )
{
#ifdef REFRESH_CLASSMENU_TOOL
if ( code == KEY_PAD_MULTIPLY )
{
OnRefreshClassMenu();
}
#endif
if ( m_iClassMenuKey != BUTTON_CODE_INVALID && m_iClassMenuKey == code )
{
ShowPanel( false );
}
else
{
BaseClass::OnKeyCodePressed( code );
}
}
void CDODClassMenu::Update()
{
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if ( pPlayer && pPlayer->m_Shared.DesiredPlayerClass() == PLAYERCLASS_UNDEFINED )
{
SetVisibleButton( "CancelButton", false );
}
else
{
SetVisibleButton( "CancelButton", true );
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Panel *CDODClassMenu::CreateControlByName( const char *controlName )
{
if ( !Q_stricmp( "DODMouseOverPanelButton", controlName ) )
{
return new CDODMouseOverButton<CDODClassInfoPanel>( this, NULL, m_pClassInfoPanel );
}
else if( !Q_stricmp( "DODButton", controlName ) )
{
return new CDODButton(this);
}
else if( !Q_stricmp( "DODRandomButton", controlName ) )
{
return new CDODRandomButton<CDODClassInfoPanel>(this, NULL, m_pClassInfoPanel );
}
else if ( !Q_stricmp( "ImageButton", controlName ) )
{
CImageMouseOverButton<CDODClassInfoPanel> *newButton = new CImageMouseOverButton<CDODClassInfoPanel>( this, NULL, m_pClassInfoPanel );
if( !m_pInitialButton )
{
m_pInitialButton = newButton;
}
return newButton;
}
else if ( !Q_stricmp( "CIconPanel", controlName ) )
{
return new CIconPanel(this, "icon_panel");
}
else
{
return BaseClass::CreateControlByName( controlName );
}
}
//-----------------------------------------------------------------------------
// Catch the mouseover event and set the active class
//-----------------------------------------------------------------------------
void CDODClassMenu::OnShowPage( const char *pagename )
{
// change which class we are counting based on class name
// turn the button name into a classname
char buf[64];
Q_snprintf( buf, sizeof(buf), "cls_%s", pagename );
C_DODTeam *pTeam = dynamic_cast<C_DODTeam *>( GetGlobalTeam(GetTeamNumber()) );
if( !pTeam )
return;
// Pull the index of this class via IsClassOnTeam
if ( !pTeam->IsClassOnTeam( buf, m_iActivePlayerClass ) )
{
Assert( !"bad class name on class button" );
}
UpdateNumClassLabel();
}
//-----------------------------------------------------------------------------
// Draw nothing
//-----------------------------------------------------------------------------
void CDODClassMenu::PaintBackground( void )
{
}
//-----------------------------------------------------------------------------
// Do things that should be done often, eg number of players in the
// selected class
//-----------------------------------------------------------------------------
void CDODClassMenu::OnTick( void )
{
//When a player changes teams, their class and team values don't get here
//necessarily before the command to update the class menu. This leads to the cancel button
//being visible and people cancelling before they have a class. check for class == DOD_CLASS_NONE and if so
//hide the cancel button
if ( !IsVisible() )
return;
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if( pPlayer && pPlayer->m_Shared.PlayerClass() == PLAYERCLASS_UNDEFINED )
{
SetVisibleButton("CancelButton", false);
}
UpdateNumClassLabel();
BaseClass::OnTick();
}
void CDODClassMenu::UpdateNumClassLabel( void )
{
int iClassCount[NUM_CLASSES];
// Initialize to zero. Was previously used uninitialized.
int iClassLimit[NUM_CLASSES] = {};
// count how many of this class there are
C_DODTeam *pTeam = dynamic_cast<C_DODTeam *>( GetGlobalTeam(GetTeamNumber()) );
if ( !pTeam )
return;
char buf[16];
for( int i=0;i<NUM_CLASSES;i++ )
{
iClassCount[i] = pTeam->CountPlayersOfThisClass( i );
if ( !m_pClassNumLabel[i] || !m_pClassFullLabel[i] )
continue;
if ( pTeam->IsClassOnTeam( i ) )
{
// FIXME - store pointers to these cvars
const CDODPlayerClassInfo &pClassInfo = pTeam->GetPlayerClassInfo( i );
ConVar *pLimitCvar = ( ConVar * )cvar->FindVar( pClassInfo.m_szLimitCvar );
if ( pLimitCvar )
iClassLimit[i] = MIN( 32, pLimitCvar->GetInt() );
}
if ( iClassLimit[i] < 0 || iClassCount[i] < iClassLimit[i] )
m_pClassFullLabel[i]->SetVisible( false );
else
m_pClassFullLabel[i]->SetVisible( true );
if ( iClassLimit[i] > -1 )
{
// draw "3 / 4"
Q_snprintf( buf, sizeof(buf), "%d / %d", iClassCount[i], iClassLimit[i] );
}
else
{
// just "3"
Q_snprintf( buf, sizeof(buf), "x %d", iClassCount[i] );
}
m_pClassNumLabel[i]->SetText( buf );
}
}
void CDODClassMenu::SetVisible( bool state )
{
BaseClass::SetVisible( state );
}
void CDODClassMenu::OnSuicideOptionChanged( vgui::Panel *Panel )
{
hud_classautokill.SetValue( m_pSuicideOption->IsSelected() );
}
#ifdef REFRESH_CLASSMENU_TOOL
void CDODClassMenu::OnRefreshClassMenu( void )
{
for( int i = 0; i< GetChildCount(); i++ )
{
CImageMouseOverButton<CDODClassInfoPanel> *button =
dynamic_cast<CImageMouseOverButton<CDODClassInfoPanel> *>(GetChild(i));
if ( button )
{
button->RefreshClassPage();
}
}
}
#endif
-129
View File
@@ -1,129 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODCLASSMENU_H
#define DODCLASSMENU_H
#ifdef _WIN32
#pragma once
#endif
#include <classmenu.h>
#include <vgui_controls/EditablePanel.h>
#include <filesystem.h>
#include <dod_shareddefs.h>
#include "cbase.h"
#include "dod_gamerules.h"
#include "dodmenubackground.h"
#include "dodbutton.h"
#include "imagemouseoverbutton.h"
#include "IconPanel.h"
#include <vgui_controls/CheckButton.h>
using namespace vgui;
#define NUM_CLASSES 6
class CDODClassMenu : public CClassMenu
{
private:
DECLARE_CLASS_SIMPLE( CDODClassMenu, CClassMenu );
public:
CDODClassMenu(IViewPort *pViewPort);
virtual void Update( void );
virtual Panel *CreateControlByName( const char *controlName );
virtual void OnTick( void );
virtual void PaintBackground( void );
virtual void OnKeyCodePressed(KeyCode code);
virtual void SetVisible( bool state );
MESSAGE_FUNC_CHARPTR( OnShowPage, "ShowPage", page );
virtual void ShowPanel(bool bShow);
void UpdateNumClassLabel( void );
virtual int GetTeamNumber( void ) = 0;
#ifdef REFRESH_CLASSMENU_TOOL
MESSAGE_FUNC( OnRefreshClassMenu, "refresh_classes" );
#endif
MESSAGE_FUNC_PTR( OnSuicideOptionChanged, "CheckButtonChecked", panel );
private:
CDODClassInfoPanel *m_pClassInfoPanel;
CDODMenuBackground *m_pBackground;
CheckButton *m_pSuicideOption;
CImageMouseOverButton<CDODClassInfoPanel> *m_pInitialButton;
int m_iActivePlayerClass;
int m_iLastPlayerClassCount;
int m_iLastClassLimit;
ButtonCode_t m_iClassMenuKey;
vgui::Label *m_pClassNumLabel[NUM_CLASSES];
vgui::Label *m_pClassFullLabel[NUM_CLASSES];
};
//-----------------------------------------------------------------------------
// Purpose: Draws the U.S. class menu
//-----------------------------------------------------------------------------
class CDODClassMenu_Allies : public CDODClassMenu
{
private:
DECLARE_CLASS_SIMPLE( CDODClassMenu_Allies, CDODClassMenu );
public:
CDODClassMenu_Allies(IViewPort *pViewPort) : BaseClass(pViewPort)
{
LoadControlSettings( "Resource/UI/ClassMenu_Allies.res" );
}
virtual const char *GetName( void )
{
return PANEL_CLASS_ALLIES;
}
virtual int GetTeamNumber( void )
{
return TEAM_ALLIES;
}
};
//-----------------------------------------------------------------------------
// Purpose: Draws the Wermacht class menu
//-----------------------------------------------------------------------------
class CDODClassMenu_Axis : public CDODClassMenu
{
private:
DECLARE_CLASS_SIMPLE( CDODClassMenu_Axis, CDODClassMenu );
public:
CDODClassMenu_Axis(IViewPort *pViewPort) : BaseClass(pViewPort)
{
LoadControlSettings( "Resource/UI/ClassMenu_Axis.res" );
}
virtual const char *GetName( void )
{
return PANEL_CLASS_AXIS;
}
virtual int GetTeamNumber( void )
{
return TEAM_AXIS;
}
};
#endif // DODCLASSMENU_H
@@ -1,621 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "hud.h"
#include "dodclientscoreboard.h"
#include "c_team.h"
#include "c_dod_team.h"
#include "c_dod_playerresource.h"
#include "c_dod_player.h"
#include "dod_gamerules.h"
#include "backgroundpanel.h"
#include <KeyValues.h>
#include <vgui/IScheme.h>
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <vgui/IVGui.h>
#include <vgui_controls/SectionedListPanel.h>
#include <vgui_controls/ImageList.h>
#include "voice_status.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CDODClientScoreBoardDialog::CDODClientScoreBoardDialog( IViewPort *pViewPort ):CClientScoreBoardDialog( pViewPort )
{
m_pPlayerListAllies = new SectionedListPanel( this, "PlayerListAllies" );
m_pPlayerListAxis = new SectionedListPanel( this, "PlayerListAxis" );
m_iImageDead = 0;
m_iImageDominated = 0;
m_iImageNemesis = 0;
m_pAllies_PlayerCount = new Label( this, "Allies_PlayerCount", "" );
m_pAllies_Score = new Label( this, "Allies_Score", "" );
m_pAllies_Kills = new Label( this, "Allies_Kills", "" );
m_pAllies_Deaths = new Label( this, "Allies_Deaths", "" );
m_pAllies_Ping = new Label( this, "Allies_Ping", "" );
m_pAxis_PlayerCount = new Label( this, "Axis_PlayerCount", "" );
m_pAxis_Score = new Label( this, "Axis_Score", "" );
m_pAxis_Kills = new Label( this, "Axis_Kills", "" );
m_pAxis_Deaths = new Label( this, "Axis_Deaths", "" );
m_pAxis_Ping = new Label( this, "Axis_Ping", "" );
ListenForGameEvent( "server_spawn" );
SetDialogVariable( "server", "" );
SetVisible( false );
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CDODClientScoreBoardDialog::~CDODClientScoreBoardDialog()
{
}
//-----------------------------------------------------------------------------
// Purpose: Paint background for rounded corners
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::PaintBackground()
{
int wide, tall;
GetSize( wide, tall );
DrawRoundedBackground( m_bgColor, wide, tall );
}
//-----------------------------------------------------------------------------
// Purpose: Paint border for rounded corners
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::PaintBorder()
{
int wide, tall;
GetSize( wide, tall );
DrawRoundedBorder( m_borderColor, wide, tall );
}
//-----------------------------------------------------------------------------
// Purpose: Apply scheme settings
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
LoadControlSettings( "Resource/UI/scoreboard.res" );
m_bgColor = GetSchemeColor( "SectionedListPanel.BgColor", GetBgColor(), pScheme );
m_borderColor = pScheme->GetColor( "Yellow", Color( 251, 206, 60, 255 ) );
SetBgColor( Color( 0, 0, 0, 0 ) );
SetBorder( pScheme->GetBorder( "BaseBorder" ) );
if ( m_pImageList )
{
m_iImageDead = m_pImageList->AddImage( scheme()->GetImage( "../hud/leaderboard_dead", true ) );
m_iImageDominated = m_pImageList->AddImage( scheme()->GetImage( "../hud/leaderboard_dominated", true ) );
m_iImageNemesis = m_pImageList->AddImage( scheme()->GetImage( "../hud/leaderboard_nemesis", true ) );
// resize the images to our resolution
for (int i = 1; i < m_pImageList->GetImageCount(); i++ )
{
int wide = 13, tall = 13;
m_pImageList->GetImage(i)->SetSize(scheme()->GetProportionalScaledValueEx( GetScheme(), wide ), scheme()->GetProportionalScaledValueEx( GetScheme(),tall ) );
}
}
if ( m_pPlayerListAllies )
{
m_pPlayerListAllies->SetImageList( m_pImageList, false );
m_pPlayerListAllies->SetBgColor( Color( 0, 0, 0, 0 ) );
m_pPlayerListAllies->SetBorder( NULL );
m_pPlayerListAllies->SetVisible( true );
}
if ( m_pPlayerListAxis )
{
m_pPlayerListAxis->SetImageList( m_pImageList, false );
m_pPlayerListAxis->SetBgColor( Color( 0, 0, 0, 0 ) );
m_pPlayerListAxis->SetBorder( NULL );
m_pPlayerListAxis->SetVisible( true );
}
// turn off the default player list since we have our own
if ( m_pPlayerList )
{
m_pPlayerList->SetVisible( false );
}
if ( m_pAllies_PlayerCount && m_pAllies_Score && m_pAllies_Kills && m_pAllies_Deaths && m_pAllies_Ping )
{
m_pAllies_PlayerCount->SetFgColor( COLOR_DOD_GREEN );
m_pAllies_Score->SetFgColor( COLOR_DOD_GREEN );
m_pAllies_Kills->SetFgColor( COLOR_DOD_GREEN );
m_pAllies_Deaths->SetFgColor( COLOR_DOD_GREEN );
m_pAllies_Ping->SetFgColor( COLOR_DOD_GREEN );
}
if ( m_pAxis_PlayerCount && m_pAxis_Score && m_pAxis_Kills && m_pAxis_Deaths && m_pAxis_Ping )
{
m_pAxis_PlayerCount->SetFgColor( COLOR_DOD_RED );
m_pAxis_Score->SetFgColor( COLOR_DOD_RED );
m_pAxis_Kills->SetFgColor( COLOR_DOD_RED );
m_pAxis_Deaths->SetFgColor( COLOR_DOD_RED );
m_pAxis_Ping->SetFgColor( COLOR_DOD_RED );
}
SetVisible( false );
Reset();
}
//-----------------------------------------------------------------------------
// Purpose: Resets the scoreboard panel
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::Reset()
{
InitPlayerList( m_pPlayerListAllies, TEAM_ALLIES );
InitPlayerList( m_pPlayerListAxis, TEAM_AXIS );
}
//-----------------------------------------------------------------------------
// Purpose: Sorts players
//-----------------------------------------------------------------------------
bool CDODClientScoreBoardDialog::DODPlayerSortFunc( vgui::SectionedListPanel *list, int itemID1, int itemID2 )
{
KeyValues *it1 = list->GetItemData( itemID1 );
KeyValues *it2 = list->GetItemData( itemID2 );
Assert( it1 && it2 );
// first compare score
int v1 = it1->GetInt( "score" );
int v2 = it2->GetInt( "score" );
if ( v1 > v2 )
return true;
else if ( v1 < v2 )
return false;
// then compare frags
v1 = it1->GetInt( "frags" );
v2 = it2->GetInt( "frags" );
if ( v1 > v2 )
return true;
else if ( v1 < v2 )
return false;
// next compare deaths
v1 = it1->GetInt( "deaths" );
v2 = it2->GetInt( "deaths" );
if ( v1 > v2 )
return false;
else if ( v1 < v2 )
return true;
// if score and deaths are the same, use player index to get deterministic sort
int iPlayerIndex1 = it1->GetInt( "playerIndex" );
int iPlayerIndex2 = it2->GetInt( "playerIndex" );
return ( iPlayerIndex1 > iPlayerIndex2 );
}
//-----------------------------------------------------------------------------
// Purpose: Inits the player list in a list panel
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::InitPlayerList( SectionedListPanel *pPlayerList, int teamNumber )
{
pPlayerList->SetVerticalScrollbar( false );
pPlayerList->RemoveAll();
pPlayerList->RemoveAllSections();
pPlayerList->AddSection( 0, "Players", DODPlayerSortFunc );
pPlayerList->SetSectionAlwaysVisible( 0, true );
pPlayerList->SetSectionFgColor( 0, Color( 255, 255, 255, 255 ) );
pPlayerList->SetBgColor( Color( 0, 0, 0, 0 ) );
pPlayerList->SetBorder( NULL );
// set the section to have the team color
if ( teamNumber && GameResources() )
{
pPlayerList->SetSectionFgColor( 0, GameResources()->GetTeamColor( teamNumber ) );
}
// Avatars are always displayed at 32x32 regardless of resolution
pPlayerList->AddColumnToSection( 0, "avatar", "", SectionedListPanel::COLUMN_IMAGE | SectionedListPanel::COLUMN_CENTER, m_iProportionalAvatarWidth );
pPlayerList->AddColumnToSection( 0, "name", "", 0, m_iNameWidth );
pPlayerList->AddColumnToSection( 0, "status", "", SectionedListPanel::COLUMN_IMAGE | SectionedListPanel::COLUMN_CENTER, m_iStatusWidth );
pPlayerList->AddColumnToSection( 0, "class", "", 0, m_iClassWidth );
pPlayerList->AddColumnToSection( 0, "score", "", SectionedListPanel::COLUMN_RIGHT, m_iScoreWidth );
pPlayerList->AddColumnToSection( 0, "frags", "", SectionedListPanel::COLUMN_RIGHT, m_iFragsWidth );
pPlayerList->AddColumnToSection( 0, "deaths", "", SectionedListPanel::COLUMN_RIGHT, m_iDeathWidth );
pPlayerList->AddColumnToSection( 0, "ping", "", SectionedListPanel::COLUMN_RIGHT, m_iPingWidth );
}
//-----------------------------------------------------------------------------
// Purpose: Updates the dialog
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::Update()
{
UpdateTeamInfo();
UpdatePlayerList();
UpdateSpectatorList();
MoveToCenterOfScreen();
// update every second
m_fNextUpdateTime = gpGlobals->curtime + 1.0f;
}
//-----------------------------------------------------------------------------
// Purpose: Updates information about teams
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::UpdateTeamInfo()
{
// update the team sections in the scoreboard
for ( int teamIndex = TEAM_ALLIES; teamIndex <= TEAM_AXIS; teamIndex++ )
{
wchar_t *teamName = NULL;;
C_DODTeam *team = dynamic_cast<C_DODTeam *>( GetGlobalTeam(teamIndex) );
if ( team )
{
// choose dialog variables to set depending on team
const char *pDialogVarTeamScore = NULL;
const char *pDialogVarTeamPlayerCount = NULL;
const char *pDialogVarTeamPing = NULL;
const char *pDialogVarTeamDeaths = NULL;
const char *pDialogVarTeamFrags = NULL;
switch ( teamIndex )
{
case TEAM_ALLIES:
teamName = g_pVGuiLocalize->Find( "#Teamname_Allies" );
pDialogVarTeamScore = "allies_teamscore";
pDialogVarTeamPlayerCount = "allies_teamplayercount";
pDialogVarTeamPing = "allies_teamping";
pDialogVarTeamDeaths = "allies_teamdeaths";
pDialogVarTeamFrags = "allies_teamfrags";
break;
case TEAM_AXIS:
teamName = g_pVGuiLocalize->Find( "#Teamname_Axis" );
pDialogVarTeamScore = "axis_teamscore";
pDialogVarTeamPlayerCount = "axis_teamplayercount";
pDialogVarTeamPing = "axis_teamping";
pDialogVarTeamDeaths = "axis_teamdeaths";
pDialogVarTeamFrags = "axis_teamfrags";
break;
default:
Assert( false );
break;
}
// update team name
wchar_t name[64];
wchar_t string1[1024];
wchar_t wNumPlayers[6];
_snwprintf( wNumPlayers, ARRAYSIZE( wNumPlayers ), L"%i", team->Get_Number_Players() );
if ( !teamName && team )
{
g_pVGuiLocalize->ConvertANSIToUnicode( team->Get_Name(), name, sizeof( name ) );
teamName = name;
}
if ( team->Get_Number_Players() == 1 )
{
g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#scoreboard_Player" ), 2, teamName, wNumPlayers );
}
else
{
g_pVGuiLocalize->ConstructString( string1, sizeof(string1), g_pVGuiLocalize->Find( "#scoreboard_Players" ), 2, teamName, wNumPlayers );
}
// set # of players for team in dialog
SetDialogVariable( pDialogVarTeamPlayerCount, string1 );
// Rounds won ( + tick )
wchar_t wTeamScore[128];
wchar_t wRoundsWon[8];
wchar_t wTickScore[8];
_snwprintf( wRoundsWon, ARRAYSIZE( wRoundsWon ), L"%i", team->GetRoundsWon() );
_snwprintf( wTickScore, ARRAYSIZE( wTickScore ), L"%i", team->Get_Score() );
g_pVGuiLocalize->ConstructString( wTeamScore, sizeof(wTeamScore), g_pVGuiLocalize->Find( "#scoreboard_teamscore" ), 2, wRoundsWon, wTickScore );
// set team score in dialog
SetDialogVariable( pDialogVarTeamScore, wTeamScore );
int kills = 0;
int deaths = 0;
int pingsum = 0;
int numcounted = 0;
int ping;
for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ )
{
if( g_PR->IsConnected( playerIndex ) && g_PR->GetTeam( playerIndex ) == teamIndex )
{
ping = g_PR->GetPing( playerIndex );
kills += g_PR->GetPlayerScore( playerIndex );
deaths += g_PR->GetDeaths( playerIndex );
if ( ping >= 1 )
{
pingsum += ping;
numcounted++;
}
}
}
if ( numcounted > 0 )
{
int ping = (int)( (float)pingsum / (float)numcounted );
SetDialogVariable( pDialogVarTeamPing, ping );
}
else
{
SetDialogVariable( pDialogVarTeamPing, "" );
}
SetDialogVariable( pDialogVarTeamFrags, kills );
SetDialogVariable( pDialogVarTeamDeaths, deaths );
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Updates the player list
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::UpdatePlayerList()
{
m_pPlayerListAllies->RemoveAll();
m_pPlayerListAxis->RemoveAll();
C_DOD_PlayerResource *dod_PR = dynamic_cast<C_DOD_PlayerResource *>( g_PR );
if ( !dod_PR )
return;
C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer();
if ( !pLocalPlayer )
return;
int iLocalPlayerIndex = GetLocalPlayerIndex();
for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ )
{
if( g_PR->IsConnected( playerIndex ) )
{
SectionedListPanel *pPlayerList = NULL;
switch ( g_PR->GetTeam( playerIndex ) )
{
case TEAM_ALLIES:
pPlayerList = m_pPlayerListAllies;
break;
case TEAM_AXIS:
pPlayerList = m_pPlayerListAxis;
break;
}
if ( pPlayerList == NULL )
{
continue;
}
KeyValues *pKeyValues = new KeyValues( "data" );
GetPlayerScoreInfo( playerIndex, pKeyValues );
if ( pLocalPlayer->m_Shared.IsPlayerDominatingMe( playerIndex ) )
{
// if local player is dominated by this player, show a nemesis icon
pKeyValues->SetString( "class", "#Scoreboard_Nemesis" );
pKeyValues->SetInt( "status", m_iImageNemesis );
}
else if ( pLocalPlayer->m_Shared.IsPlayerDominated( playerIndex) )
{
// if this player is dominated by the local player, show the domination icon
pKeyValues->SetString( "class", "#Scoreboard_Dominated" );
pKeyValues->SetInt( "status", m_iImageDominated );
}
int itemID = pPlayerList->AddItem( 0, pKeyValues );
Color clr = g_PR->GetTeamColor( g_PR->GetTeam( playerIndex ) );
pPlayerList->SetItemFgColor( itemID, clr );
if ( playerIndex == iLocalPlayerIndex )
{
pPlayerList->SetSelectedItem( itemID );
}
pKeyValues->deleteThis();
}
}
}
//-----------------------------------------------------------------------------
// Purpose: Updates the spectator list
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::UpdateSpectatorList()
{
char szSpectatorList[512] = "" ;
int nSpectators = 0;
for( int playerIndex = 1 ; playerIndex <= MAX_PLAYERS; playerIndex++ )
{
if ( ShouldShowAsSpectator( playerIndex ) )
{
if ( nSpectators > 0 )
{
Q_strncat( szSpectatorList, ", ", ARRAYSIZE( szSpectatorList ) );
}
Q_strncat( szSpectatorList, g_PR->GetPlayerName( playerIndex ), ARRAYSIZE( szSpectatorList ) );
nSpectators++;
}
}
wchar_t wzSpectators[512] = L"";
if ( nSpectators > 0 )
{
const char *pchFormat = ( 1 == nSpectators ? "#ScoreBoard_Spectator" : "#ScoreBoard_Spectators" );
wchar_t wzSpectatorCount[16];
wchar_t wzSpectatorList[1024];
_snwprintf( wzSpectatorCount, ARRAYSIZE( wzSpectatorCount ), L"%i", nSpectators );
g_pVGuiLocalize->ConvertANSIToUnicode( szSpectatorList, wzSpectatorList, sizeof( wzSpectatorList ) );
g_pVGuiLocalize->ConstructString( wzSpectators, sizeof(wzSpectators), g_pVGuiLocalize->Find( pchFormat), 2, wzSpectatorCount, wzSpectatorList );
}
SetDialogVariable( "spectators", wzSpectators );
}
//-----------------------------------------------------------------------------
// Purpose: Returns whether the specified player index is a spectator
//-----------------------------------------------------------------------------
bool CDODClientScoreBoardDialog::ShouldShowAsSpectator( int iPlayerIndex )
{
C_DOD_PlayerResource *dod_PR = dynamic_cast<C_DOD_PlayerResource *>( g_PR );
if ( !dod_PR )
return false;
// see if player is connected
if ( dod_PR->IsConnected( iPlayerIndex ) )
{
// either spectator or unassigned team should show in spectator list
int iTeam = dod_PR->GetTeam( iPlayerIndex );
if ( TEAM_SPECTATOR == iTeam || TEAM_UNASSIGNED == iTeam )
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Purpose: Event handler
//-----------------------------------------------------------------------------
void CDODClientScoreBoardDialog::FireGameEvent( IGameEvent *event )
{
const char *type = event->GetName();
if ( 0 == Q_strcmp( type, "server_spawn" ) )
{
// set server name in scoreboard
const char *hostname = event->GetString( "hostname" );
wchar_t wzHostName[256];
wchar_t wzServerLabel[256];
g_pVGuiLocalize->ConvertANSIToUnicode( hostname, wzHostName, sizeof( wzHostName ) );
g_pVGuiLocalize->ConstructString( wzServerLabel, sizeof(wzServerLabel), g_pVGuiLocalize->Find( "#Scoreboard_Server" ), 1, wzHostName );
SetDialogVariable( "server", wzServerLabel );
}
if( IsVisible() )
{
Update();
}
}
//-----------------------------------------------------------------------------
// Purpose: Adds a new row to the scoreboard, from the playerinfo structure
//-----------------------------------------------------------------------------
bool CDODClientScoreBoardDialog::GetPlayerScoreInfo( int playerIndex, KeyValues *kv )
{
C_DOD_PlayerResource *dod_PR = dynamic_cast<C_DOD_PlayerResource *>( g_PR );
if ( !dod_PR )
return true;
// Clean up the player name
const char *oldName = g_PR->GetPlayerName( playerIndex );
int bufsize = strlen( oldName ) * 2 + 1;
char *newName = (char *)_alloca( bufsize );
UTIL_MakeSafeName( oldName, newName, bufsize );
kv->SetString( "name", newName );
kv->SetInt( "playerIndex", playerIndex );
kv->SetInt( "score", dod_PR->GetScore( playerIndex ) );
kv->SetInt( "frags", g_PR->GetPlayerScore( playerIndex ) );
kv->SetInt( "deaths", g_PR->GetDeaths( playerIndex ) );
kv->SetString( "class", "" );
UpdatePlayerAvatar( playerIndex, kv );
if ( g_PR->GetPing( playerIndex ) < 1 )
{
if ( g_PR->IsFakePlayer( playerIndex ) )
{
kv->SetString( "ping", "BOT" );
}
else
{
kv->SetString( "ping", "" );
}
}
else
{
kv->SetInt( "ping", g_PR->GetPing( playerIndex ) );
}
C_DODPlayer *pLocalPlayer = C_DODPlayer::GetLocalDODPlayer();
if ( !pLocalPlayer )
return true;
int team = g_PR->GetTeam( playerIndex );
int localteam = pLocalPlayer->GetTeamNumber();
// If we are on a team that shows class/status, and the local player is allowed to see this information
if( ( localteam == TEAM_SPECTATOR || localteam == TEAM_UNASSIGNED || team == localteam ) )
{
// class name
if( g_PR->IsConnected( playerIndex ) )
{
C_DODTeam *pTeam = dynamic_cast<C_DODTeam *>( GetGlobalTeam( team ) );
Assert( pTeam );
int cls = dod_PR->GetPlayerClass( playerIndex );
char szClassName[64];
szClassName[0] = '\0';
if( cls != PLAYERCLASS_UNDEFINED )
{
const CDODPlayerClassInfo &info = pTeam->GetPlayerClassInfo( cls );
g_pVGuiLocalize->ConvertUnicodeToANSI( g_pVGuiLocalize->Find( info.m_szPrintName ), szClassName, sizeof(szClassName) );
}
kv->SetString( "class", szClassName );
}
else
{
Assert(0);
}
// status
// display whether player is alive or dead (all players see this for all other players on both teams)
kv->SetInt( "status", g_PR->IsAlive( playerIndex ) ? 0 : m_iImageDead );
}
if ( g_PR->IsHLTV( playerIndex ) )
{
// show #spectators in class field, it's transmitted as player's score
char numspecs[32];
Q_snprintf( numspecs, sizeof( numspecs ), "%i Spectators", m_HLTVSpectators );
kv->SetString( "class", numspecs );
}
return true;
}
void CDODClientScoreBoardDialog::ShowPanel( bool bShow )
{
BaseClass::ShowPanel( bShow );
int iRenderGroup = gHUD.LookupRenderGroupIndexByName( "global" );
if ( bShow )
{
gHUD.LockRenderGroup( iRenderGroup );
}
else
{
gHUD.UnlockRenderGroup( iRenderGroup );
}
}
@@ -1,79 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODCLIENTSCOREBOARDDIALOG_H
#define DODCLIENTSCOREBOARDDIALOG_H
#ifdef _WIN32
#pragma once
#endif
#include <clientscoreboarddialog.h>
#include "dod_shareddefs.h"
//-----------------------------------------------------------------------------
// Purpose: Game ScoreBoard
//-----------------------------------------------------------------------------
class CDODClientScoreBoardDialog : public CClientScoreBoardDialog
{
private:
DECLARE_CLASS_SIMPLE( CDODClientScoreBoardDialog, CClientScoreBoardDialog );
public:
CDODClientScoreBoardDialog( IViewPort *pViewPort );
~CDODClientScoreBoardDialog();
virtual void Reset();
virtual void Update();
virtual void PaintBackground();
virtual void PaintBorder();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void ShowPanel( bool bShow );
private:
void InitPlayerList( vgui::SectionedListPanel *pPlayerList, int teamNumber );
void UpdateTeamInfo();
void UpdatePlayerList();
void UpdateSpectatorList();
bool GetPlayerScoreInfo( int playerIndex, KeyValues *outPlayerInfo );
bool ShouldShowAsSpectator( int iPlayerIndex );
void FireGameEvent( IGameEvent *event );
static bool DODPlayerSortFunc( vgui::SectionedListPanel *list, int itemID1, int itemID2 );
Color m_bgColor;
Color m_borderColor;
int m_iImageDead;
int m_iImageDominated;
int m_iImageNemesis;
// player lists
vgui::SectionedListPanel *m_pPlayerListAllies;
vgui::SectionedListPanel *m_pPlayerListAxis;
CPanelAnimationVarAliasType( int, m_iStatusWidth, "status_width", "35", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iFragsWidth, "frags_width", "30", "proportional_int" );
CPanelAnimationVarAliasType( int, m_iProportionalAvatarWidth, "avatar_width_prop", "34", "proportional_int" );
vgui::Label *m_pAllies_PlayerCount;
vgui::Label *m_pAllies_Score;
vgui::Label *m_pAllies_Kills;
vgui::Label *m_pAllies_Deaths;
vgui::Label *m_pAllies_Ping;
vgui::Label *m_pAxis_PlayerCount;
vgui::Label *m_pAxis_Score;
vgui::Label *m_pAxis_Kills;
vgui::Label *m_pAxis_Deaths;
vgui::Label *m_pAxis_Ping;
};
#endif // DODCLIENTSCOREBOARDDIALOG_H
-245
View File
@@ -1,245 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include <vgui_controls/EditablePanel.h>
#include <vgui_controls/ImagePanel.h>
#include <vgui/ISurface.h>
#include <KeyValues.h>
#include "dodcornercutpanel.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CDoDCutEditablePanel::CDoDCutEditablePanel( vgui::Panel *parent, const char *name ) : vgui::EditablePanel( parent, name )
{
m_nCornerToCut = DOD_CORNERCUT_PANEL_BOTTOMRIGHT;
m_nCornerCutSize = 1;
memset( m_szBackgroundTexture, 0, sizeof( m_szBackgroundTexture ) );
memset( m_szBackgroudColor, 0, sizeof( m_szBackgroudColor ) );
memset( m_szBorderColor, 0, sizeof( m_szBorderColor ) );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::SetBorder( vgui::IBorder *border )
{
BaseClass::SetBorder( border );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::ApplySettings( KeyValues *inResourceData )
{
BaseClass::ApplySettings( inResourceData );
// check to see if we have a new name assigned
Q_strncpy( m_szBackgroundTexture, inResourceData->GetString( "BackgroundTexture", "vgui/white" ), sizeof( m_szBackgroundTexture ) );
Q_strncpy( m_szBackgroudColor, inResourceData->GetString( "BackgroundColor", "HudPanelForeground" ), sizeof( m_szBackgroudColor ) );
Q_strncpy( m_szBorderColor, inResourceData->GetString( "BackgroundBorder", "HudPanelBorder" ), sizeof( m_szBorderColor ) );
m_iBackgroundTexture = vgui::surface()->DrawGetTextureId( m_szBackgroundTexture );
if ( m_iBackgroundTexture == -1 )
{
m_iBackgroundTexture = vgui::surface()->CreateNewTextureID();
}
vgui::surface()->DrawSetTextureFile( m_iBackgroundTexture, m_szBackgroundTexture, true, true );
m_nCornerCutSize = inResourceData->GetInt( "CornerCutSize", 1 );
// scale the cut size to our screen co-ords
if ( IsProportional() )
{
m_nCornerCutSize = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(), m_nCornerCutSize );
}
const char *pszCorner = inResourceData->GetString( "CornerToCut", "" );
if ( pszCorner )
{
if ( !Q_strcmp( pszCorner, "bottom_right" ) )
{
m_nCornerToCut = DOD_CORNERCUT_PANEL_BOTTOMRIGHT;
}
else if ( !Q_strcmp( pszCorner, "bottom_left" ) )
{
m_nCornerToCut = DOD_CORNERCUT_PANEL_BOTTOMLEFT;
}
else if ( !Q_strcmp( pszCorner, "top_right" ) )
{
m_nCornerToCut = DOD_CORNERCUT_PANEL_TOPRIGHT;
}
else if ( !Q_strcmp( pszCorner, "top_left" ) )
{
m_nCornerToCut = DOD_CORNERCUT_PANEL_TOPLEFT;
}
}
InvalidateLayout( false, true );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::GetSettings( KeyValues *outResourceData )
{
BaseClass::GetSettings( outResourceData );
outResourceData->SetString( "BackgroundTexture", m_szBackgroundTexture);
outResourceData->SetString( "BackgroundColor", m_szBackgroudColor);
outResourceData->SetString( "BackgroundBorder", m_szBorderColor);
outResourceData->SetFloat( "CornerCutSize", m_nCornerCutSize );
const char *pszCorner = NULL;
switch( m_nCornerToCut )
{
case DOD_CORNERCUT_PANEL_TOPLEFT:
pszCorner = "top_left";
break;
case DOD_CORNERCUT_PANEL_TOPRIGHT:
pszCorner = "top_right";
break;
case DOD_CORNERCUT_PANEL_BOTTOMLEFT:
pszCorner = "bottom_left";
break;
case DOD_CORNERCUT_PANEL_BOTTOMRIGHT:
default:
pszCorner = "bottom_right";
break;
}
outResourceData->SetString( "CornerToCut", pszCorner );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
SetBorder( NULL );
m_clrBackground = pScheme->GetColor( m_szBackgroudColor, GetFgColor() );
m_clrBorder = pScheme->GetColor( m_szBorderColor, GetBgColor() );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::PaintBackground()
{
vgui::Vertex_t lineverts[5];
vgui::Vertex_t verts[5];
int nwide, ntall;
GetSize( nwide, ntall );
int wide = nwide - 1; // -1 because we can't draw all the way out to the width of our panel (it gets clipped), we can only draw to width - 1
int tall = ntall - 1; // (same as above)
switch ( m_nCornerToCut )
{
case DOD_CORNERCUT_PANEL_TOPLEFT:
verts[0].Init( Vector2D( m_nCornerCutSize, 0 ) );
verts[1].Init( Vector2D( wide, 0 ) );
verts[2].Init( Vector2D( wide, tall ) );
verts[3].Init( Vector2D( 0, tall ) );
verts[4].Init( Vector2D( 0, m_nCornerCutSize ) );
lineverts[0].Init( Vector2D( m_nCornerCutSize-1, 0 ) );
lineverts[1].Init( Vector2D( wide, 0 ) );
lineverts[2].Init( Vector2D( wide, tall ) );
lineverts[3].Init( Vector2D( 0, tall ) );
lineverts[4].Init( Vector2D( 0, m_nCornerCutSize-1 ) );
break;
case DOD_CORNERCUT_PANEL_TOPRIGHT:
verts[0].Init( Vector2D( 0, 0 ) );
verts[1].Init( Vector2D( wide - m_nCornerCutSize, 0 ) );
verts[2].Init( Vector2D( wide, m_nCornerCutSize ) );
verts[3].Init( Vector2D( wide, tall ) );
verts[4].Init( Vector2D( 0, tall ) );
lineverts[0].Init( Vector2D( 0, 0 ) );
lineverts[1].Init( Vector2D( wide - m_nCornerCutSize, 0 ) );
lineverts[2].Init( Vector2D( wide, m_nCornerCutSize ) );
lineverts[3].Init( Vector2D( wide, tall ) );
lineverts[4].Init( Vector2D( 0, tall ) );
break;
case DOD_CORNERCUT_PANEL_BOTTOMLEFT:
verts[0].Init( Vector2D( 0, 0 ) );
verts[1].Init( Vector2D( wide, 0 ) );
verts[2].Init( Vector2D( wide, tall ) );
verts[3].Init( Vector2D( m_nCornerCutSize, tall ) );
verts[4].Init( Vector2D( 0, tall - m_nCornerCutSize ) );
lineverts[0].Init( Vector2D( 0, 0 ) );
lineverts[1].Init( Vector2D( wide, 0 ) );
lineverts[2].Init( Vector2D( wide, tall ) );
lineverts[3].Init( Vector2D( m_nCornerCutSize, tall ) );
lineverts[4].Init( Vector2D( 0, tall - m_nCornerCutSize ) );
break;
case DOD_CORNERCUT_PANEL_BOTTOMRIGHT:
default:
verts[0].Init( Vector2D( 0, 0 ) );
verts[1].Init( Vector2D( wide, 0 ) );
verts[2].Init( Vector2D( wide, tall - m_nCornerCutSize + 1 ) );
verts[3].Init( Vector2D( wide - m_nCornerCutSize + 1, tall ) );
verts[4].Init( Vector2D( 0, tall ) );
lineverts[0].Init( Vector2D( 0, 0 ) );
lineverts[1].Init( Vector2D( wide, 0 ) );
lineverts[2].Init( Vector2D( wide, tall - m_nCornerCutSize ) );
lineverts[3].Init( Vector2D( wide - m_nCornerCutSize, tall ) );
lineverts[4].Init( Vector2D( 0, tall ) );
break;
}
vgui::surface()->DrawSetTexture( m_iBackgroundTexture );
vgui::surface()->DrawSetColor( m_clrBackground );
vgui::surface()->DrawTexturedPolygon( 5, verts );
vgui::surface()->DrawSetColor( m_clrBorder );
vgui::surface()->DrawTexturedPolyLine( lineverts, 5 );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::SetBackGroundColor( const char *pszNewColor )
{
if ( !pszNewColor )
{
return;
}
Q_strncpy( m_szBackgroudColor, pszNewColor, sizeof( m_szBackgroudColor ) );
InvalidateLayout( false, true );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDoDCutEditablePanel::SetBorderColor( const char *pszNewColor )
{
if ( !pszNewColor )
{
return;
}
Q_strncpy( m_szBorderColor, pszNewColor, sizeof( m_szBorderColor ) );
InvalidateLayout( false, true );
}
-66
View File
@@ -1,66 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DOD_CORNERCUTPANEL_H
#define DOD_CORNERCUTPANEL_H
#ifdef _WIN32
#pragma once
#endif
#include "cbase.h"
#include <vgui_controls/EditablePanel.h>
#include <vgui/ISurface.h>
#include "dod_shareddefs.h"
//-----------------------------------------------------------------------------
// Purpose: Draws the corner-cut background panels
//-----------------------------------------------------------------------------
class CDoDCutEditablePanel : public vgui::EditablePanel
{
public:
DECLARE_CLASS_SIMPLE( CDoDCutEditablePanel, vgui::EditablePanel );
CDoDCutEditablePanel( vgui::Panel *parent, const char *name );
virtual void PaintBackground();
virtual void SetBorder( vgui::IBorder *border );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
virtual void SetVisible( bool state )
{
BaseClass::SetVisible( state );
}
virtual void ApplySettings( KeyValues *inResourceData );
virtual void GetSettings( KeyValues *outResourceData );
virtual void SetCornerToCut( int nCorner ){ m_nCornerToCut = nCorner; }
virtual void SetCornerCutSize( int nCutSize ){ m_nCornerCutSize = nCutSize; }
virtual void SetBackGroundColor( const char *pszNewColor );
virtual void SetBorderColor( const char *pszNewColor );
private:
int m_iBackgroundTexture;
int m_nCornerToCut;
int m_nCornerCutSize;
char m_szBackgroundTexture[128];
char m_szBackgroudColor[128];
char m_szBorderColor[128];
Color m_clrBackground;
Color m_clrBorder;
};
#endif // DOD_CORNERCUTPANEL_H
@@ -1,89 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include <vgui/ISurface.h>
#include "dodmenubackground.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CDODMenuBackground::CDODMenuBackground(Panel *parent) : EditablePanel(parent, "MenuBackground")
{
SetProportional(true);
SetVisible(true);
SetZPos( -1 );
LoadControlSettings("Resource/UI/MenuBackground.res");
}
void CDODMenuBackground::Init( void )
{
m_iBackgroundTexture = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile( m_iBackgroundTexture, "vgui/white", true, false);
}
void CDODMenuBackground::ApplySchemeSettings( IScheme *pScheme )
{
int top[8];
int main[8];
int box[8];
int i;
for( i=0;i<8;i++ )
{
top[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iTopDims[i]);
main[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iMainDims[i]);
box[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iBoxDims[i]);
if ( i < 6 )
m_LineDims[i] = vgui::scheme()->GetProportionalScaledValueEx( GetScheme(),iLineDims[i]);
}
m_BackgroundTopVerts[0].Init( Vector2D( top[0], top[1] ) );
m_BackgroundTopVerts[1].Init( Vector2D( top[2], top[3] ) );
m_BackgroundTopVerts[2].Init( Vector2D( top[4], top[5] ) );
m_BackgroundTopVerts[3].Init( Vector2D( top[6], top[7] ) );
m_BackgroundMainVerts[0].Init( Vector2D( main[0], main[1] ) );
m_BackgroundMainVerts[1].Init( Vector2D( main[2], main[3] ) );
m_BackgroundMainVerts[2].Init( Vector2D( main[4], main[5] ) );
m_BackgroundMainVerts[3].Init( Vector2D( main[6], main[7] ) );
m_BoxVerts[0].Init( Vector2D( box[0], box[1] ) );
m_BoxVerts[1].Init( Vector2D( box[2], box[3] ) );
m_BoxVerts[2].Init( Vector2D( box[4], box[5] ) );
m_BoxVerts[3].Init( Vector2D( box[6], box[7] ) );
BaseClass::ApplySchemeSettings(pScheme);
}
//-----------------------------------------------------------------------------
// Purpose: paint the dod style background
//-----------------------------------------------------------------------------
void CDODMenuBackground::Paint(void)
{
vgui::surface()->DrawSetColor(128,110,53,235);
vgui::surface()->DrawSetTexture( m_iBackgroundTexture );
//top background
vgui::surface()->DrawTexturedPolygon( 4, m_BackgroundTopVerts );
//main background
vgui::surface()->DrawTexturedPolygon( 4, m_BackgroundMainVerts );
// top white line
vgui::surface()->DrawSetColor(255,255,255,196);
vgui::surface()->DrawLine( m_LineDims[0], m_LineDims[1], m_LineDims[2], m_LineDims[3] );
vgui::surface()->DrawLine( m_LineDims[2], m_LineDims[3], m_LineDims[4], m_LineDims[5] );
// top white box
vgui::surface()->DrawTexturedPolygon( 4, m_BoxVerts );
}
-74
View File
@@ -1,74 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODMENUBACKGROUND_H
#define DODMENUBACKGROUND_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/EditablePanel.h>
#include <vgui/ISurface.h>
#include "vgui_controls/BitmapImagePanel.h"
using namespace vgui;
static int iTopDims[8] =
{
41, 30,
562, 30,
599, 67,
41, 67
};
static int iMainDims[8] =
{
41, 67,
599, 67,
599, 465,
41, 465
};
static int iBoxDims[8] =
{
69, 83,
86, 83,
86, 89,
69, 89
};
static int iLineDims[6] =
{
69, 89,
558, 89,
568, 99
};
class CDODMenuBackground : public vgui::EditablePanel
{
private:
DECLARE_CLASS_SIMPLE( CDODMenuBackground, vgui::EditablePanel );
public:
CDODMenuBackground( Panel *parent);
void Init();
void ApplySchemeSettings( IScheme *pScheme );
virtual void Paint( void );
private:
vgui::Vertex_t m_BackgroundTopVerts[4];
vgui::Vertex_t m_BackgroundMainVerts[4];
vgui::Vertex_t m_BoxVerts[4];
int m_LineDims[6];
int m_iBackgroundTexture;
};
#endif //DODMENUBACKGROUND_H
@@ -1,72 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DOD_MOUSE_OVER_BUTTON_H
#define DOD_MOUSE_OVER_BUTTON_H
#include "dodbutton.h"
#include "mouseoverpanelbutton.h"
template <class T>
class CDODMouseOverButton : public MouseOverButton<T>, public CDODButtonShape
{
private:
//DECLARE_CLASS_SIMPLE( CDODMouseOverButton, MouseOverButton );
public:
CDODMouseOverButton(vgui::Panel *parent, const char *panelName, T *templatePanel ) :
MouseOverButton<T>( parent, panelName, templatePanel )
{
}
protected:
virtual void PaintBackground();
virtual void PaintBorder();
public:
virtual void ShowPage( void );
virtual void HidePage( void );
};
//===============================================
// CDODMouseOverButton - shaped mouseover button
//===============================================
template <class T>
void CDODMouseOverButton<T>::PaintBackground()
{
int wide, tall;
this->GetSize(wide,tall);
DrawShapedBackground( 0, 0, wide, tall, this->GetBgColor() );
}
template <class T>
void CDODMouseOverButton<T>::PaintBorder()
{
int wide, tall;
this->GetSize(wide,tall);
DrawShapedBorder( 0, 0, wide, tall, this->GetFgColor() );
}
template <class T>
void CDODMouseOverButton<T>::ShowPage( void )
{
MouseOverButton<T>::ShowPage();
// send message to parent that we triggered something
this->PostActionSignal( new KeyValues("ShowPage", "page", this->GetName() ) );
}
template <class T>
void CDODMouseOverButton<T>::HidePage( void )
{
MouseOverButton<T>::HidePage();
// send message to parent that we triggered something
this->PostActionSignal( new KeyValues("ShowPage", "page", this->GetName() ) );
}
#endif // DOD_MOUSE_OVER_BUTTON_H
-977
View File
@@ -1,977 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include <vgui/ISurface.h>
#include <vgui/ILocalize.h>
#include "dod_shareddefs.h"
#include "dodoverview.h"
#include "c_playerresource.h"
#include "c_dod_objective_resource.h"
#include "usermessages.h"
#include "coordsize.h"
#include "clientmode.h"
#include <vgui_controls/AnimationController.h>
#include "voice_status.h"
#include "spectatorgui.h"
#include "dod_hud_freezepanel.h"
using namespace vgui;
void __MsgFunc_UpdateRadar(bf_read &msg)
{
if ( !g_pMapOverview )
return;
int iPlayerEntity = msg.ReadByte();
while ( iPlayerEntity > 0 )
{
int x = msg.ReadSBitLong( COORD_INTEGER_BITS-1 ) * 4;
int y = msg.ReadSBitLong( COORD_INTEGER_BITS-1 ) * 4;
int a = msg.ReadSBitLong( 9 );
Vector origin( x, y, 0 );
QAngle angles( 0, a, 0 );
g_pMapOverview->SetPlayerPositions( iPlayerEntity-1, origin, angles );
iPlayerEntity = msg.ReadByte(); // read index for next player
}
}
extern ConVar _overview_mode;
ConVar _cl_minimapzoom( "_cl_minimapzoom", "1", FCVAR_ARCHIVE );
ConVar _overview_mode( "_overview_mode", "1", FCVAR_ARCHIVE, "Overview mode - 0=off, 1=inset, 2=full\n", true, 0, true, 2 );
CDODMapOverview *GetDODOverview( void )
{
return dynamic_cast<CDODMapOverview *>(g_pMapOverview);
}
// overview_togglezoom rotates through 3 levels of zoom for the small map
//-----------------------------------------------------------------------
void ToggleZoom( void )
{
if ( !GetDODOverview() )
return;
GetDODOverview()->ToggleZoom();
}
static ConCommand overview_togglezoom( "overview_togglezoom", ToggleZoom );
// overview_largemap toggles showing the large map
//------------------------------------------------
void ShowLargeMap( void )
{
if ( !GetDODOverview() )
return;
GetDODOverview()->ShowLargeMap();
}
static ConCommand overview_showlargemap( "+overview_largemap", ShowLargeMap );
void HideLargeMap( void )
{
if ( !GetDODOverview() )
return;
GetDODOverview()->HideLargeMap();
}
static ConCommand overview_hidelargemap( "-overview_largemap", HideLargeMap );
//--------------------------------
// map border ?
// icon minimum zoom
// flag swipes
// grenades
// chatting icon
// voice com icon
//---------------------------------
DECLARE_HUDELEMENT( CDODMapOverview );
ConVar dod_overview_voice_icon_size( "dod_overview_voice_icon_size", "64", FCVAR_ARCHIVE );
CDODMapOverview::CDODMapOverview( const char *pElementName ) : BaseClass( pElementName )
{
InitTeamColorsAndIcons();
m_flIconSize = 96.0f;
m_iLastMode = MAP_MODE_OFF;
usermessages->HookMessage( "UpdateRadar", __MsgFunc_UpdateRadar );
}
void CDODMapOverview::Update()
{
UpdateCapturePoints();
BaseClass::Update();
}
void CDODMapOverview::VidInit( void )
{
m_pC4Icon = gHUD.GetIcon( "icon_c4" );
m_pExplodedIcon = gHUD.GetIcon( "icon_c4_exploded" );
m_pC4PlantedBG = gHUD.GetIcon( "icon_c4_planted_bg" );
m_pIconDefended = gHUD.GetIcon( "icon_defended" );
BaseClass::VidInit();
}
void CDODMapOverview::UpdateCapturePoints()
{
if ( !g_pObjectiveResource )
return;
Color colorGreen(0,255,0,255);
if ( !g_pObjectiveResource )
return;
for( int i=0;i<g_pObjectiveResource->GetNumControlPoints();i++ )
{
// check if CP is visible at all
if( !g_pObjectiveResource->IsCPVisible(i) )
{
if ( m_CapturePoints[i] != 0 )
{
// remove capture point from map
RemoveObject( m_CapturePoints[i] );
m_CapturePoints[i] = 0;
}
continue;
}
// ok, show CP
int iOwningTeam = g_pObjectiveResource->GetOwningTeam(i);
int iCappingTeam = g_pObjectiveResource->GetCappingTeam(i);
int iOwningIcon = g_pObjectiveResource->GetIconForTeam( i, iOwningTeam );
if ( iOwningIcon <= 0 )
continue; // baah
const char *textureName = GetMaterialNameFromIndex( iOwningIcon );
int objID = m_CapturePoints[i];
if ( objID == 0 )
{
// add object if not already there
objID = m_CapturePoints[i] = AddObject( textureName, 0, -1 );
// objective positions never change (so far)
SetObjectPosition( objID, g_pObjectiveResource->GetCPPosition(i), vec3_angle );
AddObjectFlags( objID, MAP_OBJECT_ALIGN_TO_MAP );
}
SetObjectIcon( objID, textureName, 128.0 );
int iBombs = g_pObjectiveResource->GetBombsRemaining( i );
if ( iBombs > 0 )
{
char text[8];
Q_snprintf( text, sizeof(text), "%d", iBombs );
SetObjectText( objID, text, colorGreen );
}
//Draw the number of cappers below the icon
else if ( iCappingTeam != TEAM_UNASSIGNED )
{
int numPlayers = g_pObjectiveResource->GetNumPlayersInArea( i, iCappingTeam );
int requiredPlayers = g_pObjectiveResource->GetRequiredCappers( i, iCappingTeam );
if( requiredPlayers > 1 )
{
char text[8];
Q_snprintf( text, sizeof(text), "%d/%d", numPlayers, requiredPlayers );
SetObjectText( objID, text, colorGreen );
}
else
{
SetObjectText( objID, NULL, colorGreen );
}
}
else
{
SetObjectText( objID, NULL, colorGreen );
}
float flBombTime = g_pObjectiveResource->GetBombTimeForPoint( i );
//Draw cap percentage
if( iCappingTeam != TEAM_UNASSIGNED )
{
SetObjectStatus( objID, g_pObjectiveResource->GetCPCapPercentage(i), colorGreen );
}
else if ( flBombTime > 0 )
{
float flPercentRemaining = ( flBombTime / DOD_BOMB_TIMER_LENGTH );
SetObjectStatus( objID, flPercentRemaining, colorGreen );
}
else
{
SetObjectStatus( objID, -1, colorGreen ); // turn it off
}
}
}
void CDODMapOverview::InitTeamColorsAndIcons()
{
BaseClass::InitTeamColorsAndIcons();
m_TeamColors[TEAM_ALLIES] = COLOR_DOD_GREEN;
m_TeamIcons[TEAM_ALLIES] = AddIconTexture( "sprites/minimap_icons/aplayer" );
m_CameraIcons[TEAM_ALLIES] = AddIconTexture( "sprites/minimap_icons/allies_camera" );
m_TeamColors[TEAM_AXIS] = COLOR_DOD_RED;
m_TeamIcons[TEAM_AXIS] = AddIconTexture( "sprites/minimap_icons/gplayer" );
m_CameraIcons[TEAM_AXIS] = AddIconTexture( "sprites/minimap_icons/axis_camera" );
Q_memset( m_flPlayerChatTime, 0, sizeof(m_flPlayerChatTime ) );
m_iVoiceIcon = AddIconTexture( "voice/icntlk_pl" );
m_iChatIcon = AddIconTexture( "sprites/minimap_icons/voiceIcon" );
Q_memset( m_CapturePoints, 0, sizeof(m_CapturePoints) );
}
void CDODMapOverview::DrawCamera()
{
C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
if ( !localPlayer )
return;
int iTexture = m_CameraIcons[localPlayer->GetTeamNumber()];
if ( localPlayer->IsObserver() || iTexture <= 0 )
{
BaseClass::DrawCamera();
}
else
{
MapObject_t obj;
memset( &obj, 0, sizeof(MapObject_t) );
obj.icon = iTexture;
obj.position = localPlayer->GetAbsOrigin();
obj.size = m_flIconSize * 1.5;
obj.angle = localPlayer->EyeAngles();
obj.status = -1;
DrawIcon( &obj );
DrawVoiceIconForPlayer( localPlayer->entindex() - 1 );
}
}
void CDODMapOverview::FireGameEvent( IGameEvent *event )
{
const char * type = event->GetName();
if ( Q_strcmp(type, "player_death") == 0 )
{
MapPlayer_t *player = GetPlayerByUserID( event->GetInt("userid") );
if ( player && CanPlayerBeSeen( player ) )
{
// create skull icon for 3 seconds
int handle = AddObject( "sprites/minimap_icons/death", 0, 3 );
SetObjectText( handle, player->name, player->color );
SetObjectPosition( handle, player->position, player->angle );
}
}
else if ( Q_strcmp(type, "game_newmap") == 0 )
{
SetMode( _overview_mode.GetInt() );
}
BaseClass::FireGameEvent( event );
}
// rules that define if you can see a player on the overview or not
bool CDODMapOverview::CanPlayerBeSeen(MapPlayer_t *player)
{
C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
if ( !localPlayer || !player )
return false;
// don't draw ourselves
if ( localPlayer->entindex() == (player->index+1) )
return false;
// if local player is on spectator team, he can see everyone
if ( localPlayer->GetTeamNumber() <= TEAM_SPECTATOR )
return true;
// we never track unassigned or real spectators
if ( player->team <= TEAM_SPECTATOR )
return false;
// ingame and as dead player we can only see our own teammates
return (localPlayer->GetTeamNumber() == player->team );
}
void CDODMapOverview::ShowLargeMap( void )
{
// remember old mode
m_iLastMode = GetMode();
// if we hit the toggle while full, set to disappear when we release
if ( m_iLastMode == MAP_MODE_FULL )
m_iLastMode = MAP_MODE_OFF;
SetMode( MAP_MODE_FULL );
}
void CDODMapOverview::HideLargeMap( void )
{
SetMode( m_iLastMode );
}
void CDODMapOverview::ToggleZoom( void )
{
if ( GetMode() != MAP_MODE_INSET )
return;
int iZoomLevel = ( _cl_minimapzoom.GetInt() + 1 ) % DOD_MAP_ZOOM_LEVELS;
_cl_minimapzoom.SetValue( iZoomLevel );
switch( _cl_minimapzoom.GetInt() )
{
case 0:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel1" );
break;
case 1:
default:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel2" );
break;
}
}
void CDODMapOverview::SetMode(int mode)
{
m_flChangeSpeed = 0; // change size instantly
if ( mode == MAP_MODE_OFF )
{
ShowPanel( false );
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapOff" );
}
else if ( mode == MAP_MODE_INSET )
{
switch( _cl_minimapzoom.GetInt() )
{
case 0:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel1" );
break;
case 1:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel2" );
break;
case 2:
default:
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapZoomLevel3" );
break;
}
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
if ( pPlayer )
SetFollowEntity( pPlayer->entindex() );
ShowPanel( true );
if ( m_nMode == MAP_MODE_FULL )
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "MapScaleToSmall" );
else
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SnapToSmall" );
}
else if ( mode == MAP_MODE_FULL )
{
SetFollowEntity( 0 );
ShowPanel( true );
if ( m_nMode == MAP_MODE_INSET )
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "ZoomToLarge" );
else
g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SnapToLarge" );
}
// finally set mode
m_nMode = mode;
// save in a cvar for archive
_overview_mode.SetValue( m_nMode );
UpdateSizeAndPosition();
}
void CDODMapOverview::UpdateSizeAndPosition()
{
// move back up if the spectator menu is not visible
if ( !g_pSpectatorGUI || ( !g_pSpectatorGUI->IsVisible() && GetMode() == MAP_MODE_INSET ) )
{
int x,y,w,h;
GetBounds( x,y,w,h );
y = YRES(5); // hax, align to top of the screen
SetBounds( x,y,w,h );
}
BaseClass::UpdateSizeAndPosition();
}
void CDODMapOverview::AddGrenade( C_DODBaseGrenade *pGrenade )
{
C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
if ( !localPlayer )
return;
int localTeam = localPlayer->GetTeamNumber();
// Spectators can see all grenades
// players can only see them if they are on the same team
if ( localTeam == TEAM_SPECTATOR || ( localTeam == pGrenade->GetTeamNumber() ) )
{
AddObject( pGrenade->GetOverviewSpriteName(), pGrenade->entindex(), -1 );
}
}
void CDODMapOverview::RemoveGrenade( C_DODBaseGrenade *pGrenade )
{
RemoveObjectByIndex( pGrenade->entindex() );
}
ConVar cl_voicetest( "cl_voicetest", "0", FCVAR_CHEAT );
ConVar cl_overview_chat_time( "cl_overview_chat_time", "2.0", FCVAR_ARCHIVE );
void CDODMapOverview::PlayerChat( int index )
{
m_flPlayerChatTime[index-1] = gpGlobals->curtime + cl_overview_chat_time.GetFloat();
}
void CDODMapOverview::DrawMapPlayers()
{
BaseClass::DrawMapPlayers();
C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer();
Assert( localPlayer );
int iLocalPlayer = localPlayer->entindex() - 1;
for (int i=0; i<MAX_PLAYERS; i++)
{
if ( i == iLocalPlayer )
continue;
MapPlayer_t *player = &m_Players[i];
if ( !CanPlayerBeSeen( player ) )
continue;
if ( player->health <= 0 ) // don't draw dead players / spectators
continue;
DrawVoiceIconForPlayer( i );
}
}
void CDODMapOverview::DrawVoiceIconForPlayer( int playerIndex )
{
Assert( playerIndex >= 0 && playerIndex < MAX_PLAYERS );
MapPlayer_t *player = &m_Players[playerIndex];
// if they just sent a chat msg, or are using voice, or did a hand signal or voice command
// draw a chat icon
if ( cl_voicetest.GetInt() || GetClientVoiceMgr()->IsPlayerSpeaking( player->index+1 ) )
{
MapObject_t obj;
memset( &obj, 0, sizeof(MapObject_t) );
obj.icon = m_iVoiceIcon;
obj.position = player->position;
obj.size = dod_overview_voice_icon_size.GetFloat();
obj.status = -1;
DrawIcon( &obj );
}
else if ( m_flPlayerChatTime[player->index] > gpGlobals->curtime )
{
MapObject_t obj;
memset( &obj, 0, sizeof(MapObject_t) );
obj.icon = m_iChatIcon;
obj.position = player->position;
obj.size = dod_overview_voice_icon_size.GetFloat();
obj.status = -1;
DrawIcon( &obj );
}
}
bool CDODMapOverview::DrawIcon( MapObject_t *obj )
{
for ( int i=0;i<MAX_CONTROL_POINTS;i++ )
{
if ( obj->objectID == m_CapturePoints[i] && obj->objectID != 0 )
{
return DrawCapturePoint( i, obj );
}
}
return BaseClass::DrawIcon( obj );
}
void CDODMapOverview::DrawQuad( Vector pos, int scale, float angle, int textureID, int alpha )
{
Vector offset;
offset.z = 0;
offset.x = -scale; offset.y = scale;
VectorYawRotate( offset, angle, offset );
Vector2D pos1 = WorldToMap( pos + offset );
offset.x = scale; offset.y = scale;
VectorYawRotate( offset, angle, offset );
Vector2D pos2 = WorldToMap( pos + offset );
offset.x = scale; offset.y = -scale;
VectorYawRotate( offset, angle, offset );
Vector2D pos3 = WorldToMap( pos + offset );
offset.x = -scale; offset.y = -scale;
VectorYawRotate( offset, angle, offset );
Vector2D pos4 = WorldToMap( pos + offset );
Vertex_t points[4] =
{
Vertex_t( MapToPanel ( pos1 ), Vector2D(0,0) ),
Vertex_t( MapToPanel ( pos2 ), Vector2D(1,0) ),
Vertex_t( MapToPanel ( pos3 ), Vector2D(1,1) ),
Vertex_t( MapToPanel ( pos4 ), Vector2D(0,1) )
};
surface()->DrawSetColor( 255, 255, 255, alpha );
surface()->DrawSetTexture( textureID );
surface()->DrawTexturedPolygon( 4, points );
}
bool CDODMapOverview::DrawCapturePoint( int iCP, MapObject_t *obj )
{
int textureID = obj->icon;
Vector pos = obj->position;
float scale = obj->size;
float angle = 0;
Vector2D pospanel = WorldToMap( pos );
pospanel = MapToPanel( pospanel );
if ( !IsInPanel( pospanel ) )
return false; // player is not within overview panel
int iBombsRequired = g_pObjectiveResource->GetBombsRequired( iCP );
if ( iBombsRequired )
{
if ( g_pObjectiveResource->IsBombSetAtPoint( iCP ) )
{
// draw swipe over blank icon
// 'white' icon
int iBlankIcon = g_pObjectiveResource->GetCPTimerCapIcon( iCP );
const char *textureName = GetMaterialNameFromIndex( iBlankIcon );
DrawQuad( pos, scale, 0, AddIconTexture( textureName ), 255 );
// the circular swipe
float flBombTime = g_pObjectiveResource->GetBombTimeForPoint( iCP );
float flPercentRemaining = ( flBombTime / DOD_BOMB_TIMER_LENGTH );
DrawBombTimerSwipeIcon( pos, scale, textureID, flPercentRemaining );
}
else
{
DrawQuad( pos, scale, 0, textureID, 255 );
}
}
else
{
// draw capture swipe
DrawQuad( pos, scale, 0, textureID, 255 );
int iCappingTeam = g_pObjectiveResource->GetCappingTeam( iCP );
if ( iCappingTeam != TEAM_UNASSIGNED )
{
int iCapperIcon = g_pObjectiveResource->GetCPCappingIcon( iCP );
const char *textureName = GetMaterialNameFromIndex( iCapperIcon );
float flCapPercent = g_pObjectiveResource->GetCPCapPercentage(iCP);
bool bSwipeLeft = ( iCappingTeam == TEAM_AXIS ) ? true : false;
DrawHorizontalSwipe( pos, scale, AddIconTexture( textureName ), flCapPercent, bSwipeLeft );
}
// fixup for noone is capping, but someone is in the area
int iNumAllies = g_pObjectiveResource->GetNumPlayersInArea( iCP, TEAM_ALLIES );
int iNumAxis = g_pObjectiveResource->GetNumPlayersInArea( iCP, TEAM_AXIS );
int iOwningTeam = g_pObjectiveResource->GetOwningTeam( iCP );
if ( iCappingTeam == TEAM_UNASSIGNED )
{
if ( iNumAllies > 0 && iNumAxis == 0 && iOwningTeam != TEAM_ALLIES )
{
iCappingTeam = TEAM_ALLIES;
}
else if ( iNumAxis > 0 && iNumAllies == 0 && iOwningTeam != TEAM_AXIS )
{
iCappingTeam = TEAM_AXIS;
}
}
if ( iCappingTeam != TEAM_UNASSIGNED )
{
// Draw the number of cappers below the icon
int numPlayers = g_pObjectiveResource->GetNumPlayersInArea( iCP, iCappingTeam );
int requiredPlayers = g_pObjectiveResource->GetRequiredCappers( iCP, iCappingTeam );
if ( requiredPlayers > 1 )
{
numPlayers = MIN( numPlayers, requiredPlayers );
wchar_t wText[6];
_snwprintf( wText, sizeof(wText)/sizeof(wchar_t), L"%d/%d", numPlayers, requiredPlayers );
int wide, tall;
surface()->GetTextSize( m_hIconFont, wText, wide, tall );
int x = pospanel.x-(wide/2);
int y = pospanel.y;
// match the offset that MapOverview uses
y += GetPixelOffset( scale ) + 4;
// draw black shadow text
surface()->DrawSetTextColor( 0, 0, 0, 255 );
surface()->DrawSetTextPos( x+1, y );
surface()->DrawPrintText( wText, wcslen(wText) );
// draw name in color
surface()->DrawSetTextColor( g_PR->GetTeamColor( iCappingTeam ) );
surface()->DrawSetTextPos( x, y );
surface()->DrawPrintText( wText, wcslen(wText) );
}
}
}
// draw bombs underneath if necessary
if ( iBombsRequired > 0 )
{
int iBombsRemaining = g_pObjectiveResource->GetBombsRemaining( iCP );
bool bBombPlanted = g_pObjectiveResource->IsBombSetAtPoint( iCP );
// draw bomb state underneath
float flBombIconScale = scale * 0.5;
switch( iBombsRequired )
{
case 1:
{
Vector bombPos = pos;
bombPos.y -= scale * 1.5;
switch( iBombsRemaining )
{
case 0:
DrawQuad( bombPos, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 );
break;
case 1:
if ( bBombPlanted )
{
// draw the background behind 1
int alpha = (float)( abs( sin(2*gpGlobals->curtime) ) * 205.0 + 50.0 );
DrawQuad( bombPos, flBombIconScale*2, angle, m_pC4PlantedBG->textureId, alpha );
}
DrawQuad( bombPos, flBombIconScale, angle, m_pC4Icon->textureId, 255 );
break;
}
}
break;
case 2:
{
Vector bombPos1, bombPos2;
bombPos1 = bombPos2 = pos;
bombPos1.y = bombPos2.y = pos.y - scale * 1.5;
bombPos1.x = pos.x - scale * 0.5;
bombPos2.x = pos.x + scale * 0.5;
switch( iBombsRemaining )
{
case 0:
DrawQuad( bombPos1, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 );
DrawQuad( bombPos2, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 );
break;
case 1:
if ( bBombPlanted )
{
// draw the background behind 1
int alpha = (float)( abs( sin(2*gpGlobals->curtime) ) * 205.0 + 50.0 );
DrawQuad( bombPos1, flBombIconScale*2, angle, m_pC4PlantedBG->textureId, alpha );
}
DrawQuad( bombPos1, flBombIconScale, angle, m_pC4Icon->textureId, 255 );
DrawQuad( bombPos2, flBombIconScale, angle, m_pExplodedIcon->textureId, 255 );
break;
case 2:
if ( bBombPlanted )
{
// draw the background behind 2
int alpha = (float)( abs( sin(2*gpGlobals->curtime) ) * 205.0 + 50.0 );
DrawQuad( bombPos2, flBombIconScale*2, angle, m_pC4PlantedBG->textureId, alpha );
}
DrawQuad( bombPos1, flBombIconScale, angle, m_pC4Icon->textureId, 255 );
DrawQuad( bombPos2, flBombIconScale, angle, m_pC4Icon->textureId, 255 );
break;
}
}
break;
}
// draw shield over top
if ( g_pObjectiveResource->IsBombBeingDefused( iCP ) )
{
DrawQuad( pos, scale * 0.75, angle, m_pIconDefended->textureId, 255 );
}
}
return true;
}
void CDODMapOverview::DrawBombTimerSwipeIcon( Vector pos, int scale, int textureID, float flPercentRemaining )
{
const float flCompleteCircle = ( 2.0f * M_PI );
const float fl90degrees = flCompleteCircle * 0.25f;
const float fl45degrees = fl90degrees * 0.5f;
float flEndAngle = flCompleteCircle * flPercentRemaining; // clockwise
typedef struct
{
Vector2D vecTrailing;
Vector2D vecLeading;
} icon_quadrant_t;
/*
Quadrants are numbered 0 - 7 counter-clockwise
_________________
| 0 | 7 |
| | |
| 1 | 6 |
-----------------
| 2 | 5 |
| | |
| 3 | 4 |
-----------------
*/
// Encode the leading and trailing edge of each quadrant
// in the range 0.0 -> 1.0
icon_quadrant_t quadrants[8];
quadrants[0].vecTrailing.Init( 0.5, 0.0 );
quadrants[0].vecLeading.Init( 0.0, 0.0 );
quadrants[1].vecTrailing.Init( 0.0, 0.0 );
quadrants[1].vecLeading.Init( 0.0, 0.5 );
quadrants[2].vecTrailing.Init( 0.0, 0.5 );
quadrants[2].vecLeading.Init( 0.0, 1.0 );
quadrants[3].vecTrailing.Init( 0.0, 1.0 );
quadrants[3].vecLeading.Init( 0.5, 1.0 );
quadrants[4].vecTrailing.Init( 0.5, 1.0 );
quadrants[4].vecLeading.Init( 1.0, 1.0 );
quadrants[5].vecTrailing.Init( 1.0, 1.0 );
quadrants[5].vecLeading.Init( 1.0, 0.5 );
quadrants[6].vecTrailing.Init( 1.0, 0.5 );
quadrants[6].vecLeading.Init( 1.0, 0.0 );
quadrants[7].vecTrailing.Init( 1.0, 0.0 );
quadrants[7].vecLeading.Init( 0.5, 0.0 );
surface()->DrawSetColor( 255, 255, 255, 255 );
surface()->DrawSetTexture( textureID );
Vector2D uvMid( 0.5, 0.5 );
Vector2D newPos( pos.x - scale, pos.y + scale );
int j;
for ( j=0;j<=7;j++ )
{
float flMinAngle = j * fl45degrees;
float flAngle = clamp( flEndAngle - flMinAngle, 0, fl45degrees );
if ( flAngle <= 0 )
{
// past our quadrant, draw nothing
continue;
}
else
{
// draw our segment
vgui::Vertex_t vert[3];
// vert 0 is mid ( 0.5, 0.5 )
Vector2D pos0 = WorldToMap( pos );
vert[0].Init( MapToPanel( pos0 ), uvMid );
int xdir = 0, ydir = 0;
switch( j )
{
case 0:
case 7:
//right
xdir = 1;
ydir = 0;
break;
case 1:
case 2:
//up
xdir = 0;
ydir = -1;
break;
case 3:
case 4:
//left
xdir = -1;
ydir = 0;
break;
case 5:
case 6:
//down
xdir = 0;
ydir = 1;
break;
}
Vector vec1;
Vector2D uv1;
// vert 1 is the variable vert based on leading edge
vec1.x = newPos.x + quadrants[j].vecTrailing.x * scale*2 - xdir * tan(flAngle) * scale;
vec1.y = newPos.y - quadrants[j].vecTrailing.y * scale*2 + ydir * tan(flAngle) * scale;
uv1.x = quadrants[j].vecTrailing.x - xdir * abs( quadrants[j].vecLeading.x - quadrants[j].vecTrailing.x ) * tan(flAngle);
uv1.y = quadrants[j].vecTrailing.y - ydir * abs( quadrants[j].vecLeading.y - quadrants[j].vecTrailing.y ) * tan(flAngle);
Vector2D pos1 = WorldToMap( vec1 );
vert[1].Init( MapToPanel( pos1 ), uv1 );
// vert 2 is our trailing edge
Vector vec2;
vec2.x = newPos.x + quadrants[j].vecTrailing.x * scale*2;
vec2.y = newPos.y - quadrants[j].vecTrailing.y * scale*2;
Vector2D pos2 = WorldToMap( vec2 );
vert[2].Init( MapToPanel( pos2 ), quadrants[j].vecTrailing );
surface()->DrawTexturedPolygon( 3, vert );
}
}
}
void CDODMapOverview::DrawHorizontalSwipe( Vector pos, int scale, int textureID, float flCapPercentage, bool bSwipeLeft )
{
float flIconSize = scale * 2;
float width = ( flIconSize * flCapPercentage );
float uv1 = 0.0f;
float uv2 = 1.0f;
Vector2D uv11( uv1, uv2 );
Vector2D uv21( flCapPercentage, uv2 );
Vector2D uv22( flCapPercentage, uv1 );
Vector2D uv12( uv1, uv1 );
// reversing the direction of the swipe effect
if ( bSwipeLeft )
{
uv11.x = uv2 - flCapPercentage;
uv21.x = uv2;
uv22.x = uv2;
uv12.x = uv2 - flCapPercentage;
}
float flXPos = pos.x - scale;
float flYPos = pos.y - scale;
Vector upperLeft( flXPos, flYPos, 0 );
Vector upperRight( flXPos + width, flYPos, 0 );
Vector lowerRight( flXPos + width, flYPos + flIconSize, 0 );
Vector lowerLeft ( flXPos, flYPos + flIconSize, 0 );
/// reversing the direction of the swipe effect
if ( bSwipeLeft )
{
upperLeft.x = flXPos + flIconSize - width;
upperRight.x = flXPos + flIconSize;
lowerRight.x = flXPos + flIconSize;
lowerLeft.x = flXPos + flIconSize - width;
}
vgui::Vertex_t vert[4];
Vector2D pos0 = WorldToMap( upperLeft );
vert[0].Init( MapToPanel( pos0 ), uv11 );
Vector2D pos3 = WorldToMap( lowerLeft );
vert[1].Init( MapToPanel( pos3 ), uv12 );
Vector2D pos2 = WorldToMap( lowerRight );
vert[2].Init( MapToPanel( pos2 ), uv22 );
Vector2D pos1 = WorldToMap( upperRight );
vert[3].Init( MapToPanel( pos1 ), uv21 );
surface()->DrawSetColor( 255, 255, 255, 255 );
surface()->DrawSetTexture( textureID );
surface()->DrawTexturedPolygon( 4, vert );
}
bool CDODMapOverview::IsVisible( void )
{
if ( IsTakingAFreezecamScreenshot() )
return false;
return BaseClass::IsVisible();
}
-81
View File
@@ -1,81 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODOVERVIEW_H
#define DODOVERVIEW_H
#include <mapoverview.h>
#include "dod_shareddefs.h"
#include "c_dod_basegrenade.h"
class CDODMapOverview : public CMapOverview
{
DECLARE_CLASS_SIMPLE( CDODMapOverview, CMapOverview );
CDODMapOverview( const char *pElementName );
int m_CameraIcons[MAX_TEAMS];
int m_CapturePoints[MAX_CONTROL_POINTS];
void ShowLargeMap( void );
void HideLargeMap( void );
void ToggleZoom( void );
void AddGrenade( C_DODBaseGrenade *pGrenade );
void RemoveGrenade( C_DODBaseGrenade *pGrenade );
void PlayerChat( int index );
void DrawQuad( Vector pos, int scale, float angle, int textureID, int alpha );
void DrawBombTimerSwipeIcon( Vector pos, int scale, int textureID, float flPercentRemaining );
void DrawHorizontalSwipe( Vector pos, int scale, int textureID, float flCapPercentage, bool bSwipeLeft );
bool DrawCapturePoint( int iCP, MapObject_t *obj );
virtual void VidInit( void );
virtual bool IsVisible( void );
protected:
virtual void SetMode(int mode);
virtual void InitTeamColorsAndIcons();
virtual void FireGameEvent( IGameEvent *event );
virtual void DrawCamera();
virtual void DrawMapPlayers();
virtual void Update();
virtual void UpdateSizeAndPosition();
// rules that define if you can see a player on the overview or not
virtual bool CanPlayerBeSeen(MapPlayer_t *player);
void DrawVoiceIconForPlayer( int playerIndex );
virtual bool DrawIcon( MapObject_t *obj );
protected:
void UpdateCapturePoints();
private:
int m_iLastMode;
CUtlVector<MapObject_t> m_Grenades;
int m_iVoiceIcon;
int m_iChatIcon;
float m_flPlayerChatTime[MAX_PLAYERS];
CHudTexture *m_pC4Icon;
CHudTexture *m_pExplodedIcon;
CHudTexture *m_pC4PlantedBG;
CHudTexture *m_pIconDefended;
#define DOD_MAP_ZOOM_LEVELS 2
};
extern CDODMapOverview *GetDODOverview( void );
#endif // DODOVERVIEW_H
-93
View File
@@ -1,93 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DOD_RANDOM_BUTTON_H
#define DOD_RANDOM_BUTTON_H
#include "dodmouseoverpanelbutton.h"
// CDODRandomButton - has the lower left corner cut out
// and does mouseover
/*
|''''''''''''''''|
| 9. Random |
\_______________|
*/
template <class T>
class CDODRandomButton : public CDODMouseOverButton<T>
{
private:
//DECLARE_CLASS_SIMPLE( CDODRandomButton, CDODMouseOverButton );
public:
CDODRandomButton(vgui::Panel *parent, const char *panelName, T *templatePanel ) :
CDODMouseOverButton<T>( parent, panelName, templatePanel )
{
}
protected:
virtual void PaintBackground();
virtual void PaintBorder();
};
//===============================================
// CDODRandomButton - differently shaped button
//===============================================
template <class T>
void CDODRandomButton<T>::PaintBackground()
{
int wide, tall;
this->GetSize(wide,tall);
int inset = tall;
if ( CDODRandomButton<T>::m_iWhiteTexture < 0 )
{
CDODRandomButton<T>::m_iWhiteTexture = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile( CDODRandomButton<T>::m_iWhiteTexture, "vgui/white" , true, false);
}
surface()->DrawSetColor(this->GetBgColor());
surface()->DrawSetTexture( CDODRandomButton<T>::m_iWhiteTexture );
Vertex_t verts[4];
verts[0].Init( Vector2D( 0, 0 ) );
verts[1].Init( Vector2D( wide-1, 0 ) );
verts[2].Init( Vector2D( wide-1, tall-1 ) );
verts[3].Init( Vector2D( inset, tall-1 ) );
surface()->DrawTexturedPolygon(4, verts);
}
template <class T>
void CDODRandomButton<T>::PaintBorder()
{
int wide, tall;
this->GetSize(wide,tall);
int inset = tall;
surface()->DrawSetColor(this->GetFgColor());
// top
surface()->DrawLine( 0, 1, wide-1, 1 );
// left
surface()->DrawLine( 1, 1, inset-1, tall-1 );
// bottom
surface()->DrawLine( inset-1, tall-1, wide-1, tall-1 );
// right
surface()->DrawLine( wide-1, 0, wide-1, tall-1 );
}
#endif //DOD_RANDOM_BUTTON_H
-194
View File
@@ -1,194 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "dodspectatorgui.h"
#include "hud.h"
#include "dod_shareddefs.h"
#include <vgui/ILocalize.h>
#include <vgui/ISurface.h>
#include <imapoverview.h>
#include "dod_gamerules.h"
#include "c_team.h"
#include "c_dod_team.h"
#include "c_dod_player.h"
#include "c_dod_playerresource.h"
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CDODSpectatorGUI::CDODSpectatorGUI(IViewPort *pViewPort) : CSpectatorGUI(pViewPort)
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CDODSpectatorGUI::NeedsUpdate( void )
{
if ( !C_BasePlayer::GetLocalPlayer() )
return false;
if( IsVisible() )
return true;
//if ( DODGameRules()->IsGameUnderTimeLimit() && m_nLastTime != DODGameRules()->GetTimeLeft() )
// return true;
if ( m_nLastSpecMode != C_BasePlayer::GetLocalPlayer()->GetObserverMode() )
return true;
if ( m_nLastSpecTarget != C_BasePlayer::GetLocalPlayer()->GetObserverTarget() )
return true;
return BaseClass::NeedsUpdate();
}
Color CDODSpectatorGUI::GetClientColor(int index)
{
C_BasePlayer *player = ToBasePlayer( ClientEntityList().GetEnt( index) );
int team = player->GetTeamNumber();
Assert( team == TEAM_ALLIES || team == TEAM_AXIS || team == TEAM_SPECTATOR );
if ( GameResources() )
return GameResources()->GetTeamColor( team );
else
return Color( 255, 255, 255, 255 );
}
void CDODSpectatorGUI::Update()
{
BaseClass::Update();
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
if( pLocalPlayer )
{
m_nLastSpecMode = pLocalPlayer->GetObserverMode();
m_nLastSpecTarget = pLocalPlayer->GetObserverTarget();
}
UpdateTimer();
UpdateScores();
}
void CDODSpectatorGUI::UpdateTimer( void )
{
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if( !pPlayer || pPlayer->IsHLTV() )
{
wchar_t wText[ 63 ];
int timer;
timer = (int)( DODGameRules()->GetTimeLeft() );
if ( timer < 0 )
timer = 0;
_snwprintf ( wText, sizeof(wText)/sizeof(wchar_t), L"%d:%02d", (timer / 60), (timer % 60) );
wText[62] = 0;
SetDialogVariable( "timer", wText );
SetDialogVariable( "reinforcements", wText );
}
else if( pPlayer->GetTeamNumber() == TEAM_SPECTATOR )
{
SetDialogVariable( "timer", L"" );
SetDialogVariable( "reinforcements", L"" );
}
else
{
SetDialogVariable( "timer", L"" );
// we need to know how much longer we are going to be in death cam
// once we know that, we can ask dodgamerules if we are going to make the next
// wave. If we aren't, gamerules can tell us the new time based on the reserve wave
float flSpawnEligibleTime;
if ( pPlayer->GetObserverMode() == OBS_MODE_DEATHCAM )
{
flSpawnEligibleTime = pPlayer->GetDeathTime() + DEATH_CAM_TIME;
}
else
flSpawnEligibleTime = 0;
//will never return negative seconds
int timer = DODGameRules()->GetReinforcementTimerSeconds( pPlayer->GetTeamNumber(), flSpawnEligibleTime );
if( timer < 0 || ( pPlayer->GetObserverMode() == OBS_MODE_DEATHCAM ) )
{
SetDialogVariable( "reinforcements", L"" );
}
else
{
char szMins[4], szSecs[4];
int mins = timer / 60;
int secs = timer % 60;
Q_snprintf( szMins, sizeof(szMins), "%d", mins );
Q_snprintf( szSecs, sizeof(szSecs), "%d", secs );
wchar_t wMins[4], wSecs[4];
g_pVGuiLocalize->ConvertANSIToUnicode(szMins, wMins, sizeof(wMins));
g_pVGuiLocalize->ConvertANSIToUnicode(szSecs, wSecs, sizeof(wSecs));
wchar_t wLabel[128];
if ( mins == 1 ) //"1 minute"
{
g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_min" ), 2, wMins, wSecs );
}
else if ( mins > 0 ) //"2 minutes"
{
g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_mins" ), 2, wMins, wSecs );
}
else if ( secs == 1 ) //"1 second"
{
g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_sec" ), 1, wSecs );
}
else if ( secs == 0 ) //"Prepare to Respawn"
{
g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_prepare_to_respawn" ), 0 );
}
else //"2 seconds"
{
g_pVGuiLocalize->ConstructString( wLabel, sizeof( wLabel ), g_pVGuiLocalize->Find("#Dod_Reinforcements_in_secs" ), 1, wSecs );
}
SetDialogVariable( "reinforcements", wLabel );
}
}
}
void CDODSpectatorGUI::UpdateScores( void )
{
C_DODTeam *pAlliesTeam = static_cast<C_DODTeam *>( GetGlobalTeam(TEAM_ALLIES) );
if ( pAlliesTeam )
{
SetDialogVariable( "alliesscore", pAlliesTeam->GetRoundsWon() );
}
C_DODTeam *pAxisTeam = static_cast<C_DODTeam *>( GetGlobalTeam(TEAM_AXIS) );
if ( pAxisTeam )
{
SetDialogVariable( "axisscore", pAxisTeam->GetRoundsWon() );
}
}
bool CDODSpectatorGUI::ShouldShowPlayerLabel( int specmode )
{
return ( (specmode == OBS_MODE_IN_EYE) ||
(specmode == OBS_MODE_CHASE) ||
(specmode == OBS_MODE_DEATHCAM) );
}
-46
View File
@@ -1,46 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODSPECTATORGUI_H
#define DODSPECTATORGUI_H
#ifdef _WIN32
#pragma once
#endif
#include <spectatorgui.h>
//-----------------------------------------------------------------------------
// Purpose: Cstrike Spectator UI
//-----------------------------------------------------------------------------
class CDODSpectatorGUI : public CSpectatorGUI
{
private:
DECLARE_CLASS_SIMPLE( CDODSpectatorGUI, CSpectatorGUI );
public:
CDODSpectatorGUI( IViewPort *pViewPort );
virtual void Update( void );
virtual bool NeedsUpdate( void );
virtual Color GetClientColor(int index);
virtual bool ShouldShowPlayerLabel( int specmode );
//virtual bool HasInputElements( void ) { return true; }
protected:
void UpdateTimer();
void UpdateScores();
int m_nLastTime;
int m_nLastSpecMode;
CBaseEntity *m_nLastSpecTarget;
};
#endif // DODSPECTATORGUI_H
-285
View File
@@ -1,285 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "dodteammenu.h"
#include <convar.h>
#include "hud.h" // for gEngfuncs
#include "c_dod_player.h"
#include "dod_gamerules.h"
#include <vgui/ILocalize.h>
#include <vgui/IVGui.h>
#include <vgui_controls/RichText.h>
#include "c_dod_team.h"
#include "IGameUIFuncs.h" // for key bindings
extern IGameUIFuncs *gameuifuncs; // for key binding details
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CDODTeamMenu::CDODTeamMenu(IViewPort *pViewPort) : CTeamMenu(pViewPort)
{
m_pBackground = SETUP_PANEL( new CDODMenuBackground( this ) );
m_pPanel = new EditablePanel( this, "TeamImagePanel" );// team image panel
m_pFirstButton = NULL;
LoadControlSettings("Resource/UI/TeamMenu.res"); // reload this to catch DODButtons
vgui::ivgui()->AddTickSignal( GetVPanel() );
m_iActiveTeam = TEAM_UNASSIGNED;
m_iLastPlayerCount = -1;
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CDODTeamMenu::~CDODTeamMenu()
{
}
void CDODTeamMenu::ShowPanel(bool bShow)
{
if ( bShow )
{
engine->CheckPoint( "TeamMenu" ); //MATTTODO what is this?
m_iTeamMenuKey = gameuifuncs->GetButtonCodeForBind( "changeteam" );
}
BaseClass::ShowPanel( bShow );
}
//-----------------------------------------------------------------------------
// Purpose: Make the first buttons page get displayed when the menu becomes visible
//-----------------------------------------------------------------------------
void CDODTeamMenu::SetVisible( bool state )
{
BaseClass::SetVisible( state );
for( int i = 0; i< GetChildCount(); i++ ) // get all the buy buttons to performlayout
{
CDODMouseOverButton<EditablePanel> *button = dynamic_cast<CDODMouseOverButton<EditablePanel> *>(GetChild(i));
if ( button )
{
if( button == m_pFirstButton && state == true )
button->ShowPage();
else
button->HidePage();
button->InvalidateLayout();
}
}
if ( state )
{
Panel *pAutoButton = FindChildByName( "autobutton" );
if ( pAutoButton )
{
pAutoButton->RequestFocus();
}
}
}
void CDODTeamMenu::OnTick( void )
{
C_DODTeam *pAllies = dynamic_cast<C_DODTeam *>( GetGlobalTeam(TEAM_ALLIES) );
C_DODTeam *pAxis = dynamic_cast<C_DODTeam *>( GetGlobalTeam(TEAM_AXIS) );
if ( !pAllies || !pAxis )
return;
static int iLastAlliesCount = -1;
static int iLastAxisCount = -1;
int iNumAllies = pAllies->Get_Number_Players();
int iNumAxis = pAxis->Get_Number_Players();
if ( iNumAllies != iLastAlliesCount )
{
iLastAlliesCount = iNumAllies;
wchar_t wbuf[128];
if ( iNumAllies == 1 )
{
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAllies_1"), 0 );
}
else
{
wchar_t wnum[6];
_snwprintf( wnum, ARRAYSIZE(wnum), L"%d", iNumAllies );
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAllies"), 1, wnum );
}
Label *pLabel = dynamic_cast<Label *>( FindChildByName("num_allies") );
if ( pLabel )
pLabel->SetText( wbuf );
}
if ( iNumAxis != iLastAxisCount )
{
iLastAxisCount = iNumAxis;
wchar_t wbuf[128];
if ( iNumAxis == 1 )
{
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAxis_1"), 0 );
}
else
{
wchar_t wnum[6];
_snwprintf( wnum, ARRAYSIZE(wnum), L"%d", iNumAxis );
g_pVGuiLocalize->ConstructString( wbuf, sizeof(wbuf), g_pVGuiLocalize->Find("#teammenu_numAxis"), 1, wnum );
}
Label *pLabel = dynamic_cast<Label *>( FindChildByName("num_axis") );
if ( pLabel )
pLabel->SetText( wbuf );
}
}
//-----------------------------------------------------------------------------
// Purpose: called to update the menu with new information
//-----------------------------------------------------------------------------
void CDODTeamMenu::Update( void )
{
BaseClass::Update();
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
Assert( pPlayer );
const ConVar *allowspecs = cvar->FindVar( "mp_allowspectators" );
if ( allowspecs && allowspecs->GetBool() )
{
if ( !pPlayer || !DODGameRules() )
return;
SetVisibleButton("specbutton", true);
}
else
{
SetVisibleButton("specbutton", false );
}
if( pPlayer->GetTeamNumber() == TEAM_UNASSIGNED ) // we aren't on a team yet
{
SetVisibleButton("CancelButton", false);
}
else
{
SetVisibleButton("CancelButton", true);
}
}
//-----------------------------------------------------------------------------
// Purpose: When a team button is pressed it triggers this function to
// cause the player to join a team
//-----------------------------------------------------------------------------
void CDODTeamMenu::OnCommand( const char *command )
{
if ( !FStrEq( command, "vguicancel" ) )
{
engine->ClientCmd( command );
}
BaseClass::OnCommand( command );
gViewPortInterface->ShowBackGround( false );
OnClose();
}
//-----------------------------------------------------------------------------
// Purpose: Sets the visibility of a button by name
//-----------------------------------------------------------------------------
void CDODTeamMenu::SetVisibleButton(const char *textEntryName, bool state)
{
Button *entry = dynamic_cast<Button *>(FindChildByName(textEntryName));
if (entry)
{
entry->SetVisible(state);
}
}
void CDODTeamMenu::ApplySchemeSettings( IScheme *pScheme )
{
BaseClass::ApplySchemeSettings(pScheme);
}
//-----------------------------------------------------------------------------
// Draw nothing
//-----------------------------------------------------------------------------
void CDODTeamMenu::PaintBackground( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Panel *CDODTeamMenu::CreateControlByName( const char *controlName )
{
if( !Q_stricmp( "DODMouseOverPanelButton", controlName ) )
{
CDODMouseOverButton<EditablePanel> *newButton = new CDODMouseOverButton<EditablePanel>( this, NULL, m_pPanel );
if( !m_pFirstButton )
{
m_pFirstButton = newButton;
}
return newButton;
}
else if( !Q_stricmp( "DODButton", controlName ) )
{
return new CDODButton(this);
}
else if ( !Q_stricmp( "CIconPanel", controlName ) )
{
return new CIconPanel(this, "icon_panel");
}
else
{
return BaseClass::CreateControlByName( controlName );
}
}
void CDODTeamMenu::OnShowPage( char const *pagename )
{
if ( !pagename || !pagename[ 0 ] )
return;
if ( !Q_stricmp( pagename, "allies") )
{
m_iActiveTeam = TEAM_ALLIES;
}
else if ( !Q_stricmp( pagename, "axis" ) )
{
m_iActiveTeam = TEAM_AXIS;
}
}
void CDODTeamMenu::OnKeyCodePressed(KeyCode code)
{
if ( m_iTeamMenuKey != BUTTON_CODE_INVALID && m_iTeamMenuKey == code )
{
ShowPanel( false );
}
else
{
BaseClass::OnKeyCodePressed( code );
}
}
-67
View File
@@ -1,67 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODTEAMMENU_H
#define DODTEAMMENU_H
#ifdef _WIN32
#pragma once
#endif
#include "teammenu.h"
#include "dodmenubackground.h"
#include "dodbutton.h"
#include "dodmouseoverpanelbutton.h"
#include "IconPanel.h"
//-----------------------------------------------------------------------------
// Purpose: Displays the team menu
//-----------------------------------------------------------------------------
class CDODTeamMenu : public CTeamMenu
{
private:
DECLARE_CLASS_SIMPLE( CDODTeamMenu, CTeamMenu );
public:
CDODTeamMenu(IViewPort *pViewPort);
~CDODTeamMenu();
virtual void Update();
virtual void OnTick();
void ShowPanel( bool bShow );
virtual void SetVisible( bool state );
virtual void PaintBackground();
virtual Panel *CreateControlByName( const char *controlName );
virtual void ApplySchemeSettings( IScheme *pScheme );
virtual void OnKeyCodePressed(KeyCode code);
private:
enum { NUM_TEAMS = 3 };
MESSAGE_FUNC_CHARPTR( OnShowPage, "ShowPage", page );
// VGUI2 override
void OnCommand( const char *command);
// helper functions
void SetVisibleButton(const char *textEntryName, bool state);
CDODMenuBackground *m_pBackground;
vgui::EditablePanel *m_pPanel;
CDODMouseOverButton<vgui::EditablePanel> *m_pFirstButton;
int m_iLastPlayerCount;
int m_iActiveTeam;
ButtonCode_t m_iTeamMenuKey;
};
#endif // DODTEAMMENU_H
-162
View File
@@ -1,162 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "dodtextwindow.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 "dodbutton.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
//-----------------------------------------------------------------------------
CDODTextWindow::CDODTextWindow(IViewPort *pViewPort) : CTextWindow( pViewPort )
{
SetProportional( true );
m_iScoreBoardKey = BUTTON_CODE_INVALID;
m_pBackground = SETUP_PANEL( new CDODMenuBackground( this ) );
// Do this again ( base class already does it )
// If we don't, custom controls that we catch in our CreateControlByName
// will not go to the CDODTextWindow version as we haven't instantiated
// ourselves as a CDODTextWindow yet.
LoadControlSettings("Resource/UI/TextWindow.res");
}
//-----------------------------------------------------------------------------
// Purpose: Destructor
//-----------------------------------------------------------------------------
CDODTextWindow::~CDODTextWindow()
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDODTextWindow::Update()
{
BaseClass::Update();
Panel *ok = FindChildByName("okbutton");
if (ok)
{
ok->RequestFocus();
}
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDODTextWindow::SetVisible(bool state)
{
BaseClass::SetVisible(state);
if ( state )
{
Panel *ok = FindChildByName("okbutton");
if (ok)
{
ok->RequestFocus();
}
}
}
//-----------------------------------------------------------------------------
// Purpose: shows the text window
//-----------------------------------------------------------------------------
void CDODTextWindow::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 CDODTextWindow::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 background is painted elsewhere, so we should do nothing
//-----------------------------------------------------------------------------
void CDODTextWindow::PaintBackground()
{
}
//-----------------------------------------------------------------------------
// Purpose: Scale / center the window
//-----------------------------------------------------------------------------
void CDODTextWindow::PerformLayout()
{
BaseClass::PerformLayout();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CDODTextWindow::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
Panel *CDODTextWindow::CreateControlByName( const char *controlName )
{
if( !Q_stricmp( "DODButton", controlName ) )
{
return new CDODButton(this);
}
else
{
return BaseClass::CreateControlByName( controlName );
}
}
-52
View File
@@ -1,52 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODTEXTWINDOW_H
#define DODTEXTWINDOW_H
#ifdef _WIN32
#pragma once
#endif
#include "vguitextwindow.h"
#include "dodmenubackground.h"
#include <vgui_controls/Panel.h>
using namespace vgui;
//-----------------------------------------------------------------------------
// Purpose: displays the MOTD
//-----------------------------------------------------------------------------
class CDODTextWindow : public CTextWindow
{
private:
DECLARE_CLASS_SIMPLE( CDODTextWindow, CTextWindow );
public:
CDODTextWindow(IViewPort *pViewPort);
virtual ~CDODTextWindow();
virtual void Update();
virtual void SetVisible(bool state);
virtual void ShowPanel( bool bShow );
virtual void OnKeyCodePressed(vgui::KeyCode code);
virtual Panel *CreateControlByName( const char *controlName );
protected:
ButtonCode_t m_iScoreBoardKey;
public:
virtual void PaintBackground();
virtual void PerformLayout();
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
CDODMenuBackground *m_pBackground;
};
#endif // DODTEXTWINDOW_H
-195
View File
@@ -1,195 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Client DLL VGUI2 Viewport
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#pragma warning( disable : 4800 ) // disable forcing int to bool performance warning
// VGUI panel includes
#include <vgui_controls/Panel.h>
#include <vgui/ISurface.h>
#include <KeyValues.h>
#include <vgui/Cursor.h>
#include <vgui/IScheme.h>
#include <vgui/IVGui.h>
#include <vgui/ILocalize.h>
#include <vgui/VGUI.h>
// client dll/engine defines
#include "hud.h"
#include <voice_status.h>
#include "dodteammenu.h"
#include "dodclassmenu.h"
#include "dodclientscoreboard.h"
#include "dodspectatorgui.h"
#include "dodtextwindow.h"
#include "dodmenubackground.h"
#include "dodoverview.h"
#include "IGameUIFuncs.h"
// viewport definitions
#include <baseviewport.h>
#include "dodviewport.h"
#include "vguicenterprint.h"
#include "text_message.h"
#include "c_dod_player.h"
CON_COMMAND_F( changeteam, "Choose a new team", FCVAR_SERVER_CAN_EXECUTE|FCVAR_CLIENTCMD_CAN_EXECUTE )
{
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if ( pPlayer && pPlayer->CanShowTeamMenu() )
{
gViewPortInterface->ShowPanel( PANEL_TEAM, true );
}
}
CON_COMMAND_F( changeclass, "Choose a new class", FCVAR_SERVER_CAN_EXECUTE|FCVAR_CLIENTCMD_CAN_EXECUTE )
{
C_DODPlayer *pPlayer = C_DODPlayer::GetLocalDODPlayer();
if ( pPlayer && pPlayer->CanShowClassMenu())
{
switch( pPlayer->GetTeamNumber() )
{
case TEAM_ALLIES:
gViewPortInterface->ShowPanel( PANEL_CLASS_ALLIES, true );
break;
case TEAM_AXIS:
gViewPortInterface->ShowPanel( PANEL_CLASS_AXIS, true );
break;
default:
break;
}
}
}
CON_COMMAND_F( spec_menu, "Activates spectator menu", FCVAR_SERVER_CAN_EXECUTE|FCVAR_CLIENTCMD_CAN_EXECUTE)
{
bool bShowIt = true;
if ( args.ArgC() == 2 )
{
bShowIt = atoi( args[ 1 ] ) == 1;
}
if ( gViewPortInterface )
{
gViewPortInterface->ShowPanel( PANEL_SPECMENU, bShowIt );
}
}
CON_COMMAND_F( togglescores, "Toggles score panel", FCVAR_SERVER_CAN_EXECUTE|FCVAR_CLIENTCMD_CAN_EXECUTE)
{
if ( !gViewPortInterface )
return;
IViewPortPanel *scoreboard = gViewPortInterface->FindPanelByName( PANEL_SCOREBOARD );
if ( !scoreboard )
return;
if ( scoreboard->IsVisible() )
{
gViewPortInterface->ShowPanel( scoreboard, false );
GetClientVoiceMgr()->StopSquelchMode();
}
else
{
gViewPortInterface->ShowPanel( scoreboard, true );
}
}
void DODViewport::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
gHUD.InitColors( pScheme );
SetPaintBackgroundEnabled( false );
}
IViewPortPanel* DODViewport::CreatePanelByName(const char *szPanelName)
{
IViewPortPanel* newpanel = NULL;
// overwrite MOD specific panel creation
if ( Q_strcmp(PANEL_TEAM, szPanelName) == 0 )
{
newpanel = new CDODTeamMenu( this );
}
else if ( Q_strcmp(PANEL_CLASS_ALLIES, szPanelName) == 0 )
{
newpanel = new CDODClassMenu_Allies( this );
}
else if ( Q_strcmp(PANEL_CLASS_AXIS, szPanelName) == 0 )
{
newpanel = new CDODClassMenu_Axis( this );
}
else if ( Q_strcmp(PANEL_SCOREBOARD, szPanelName) == 0)
{
newpanel = new CDODClientScoreBoardDialog( this );
}
else if ( Q_strcmp(PANEL_SPECGUI, szPanelName) == 0 )
{
newpanel = new CDODSpectatorGUI( this );
}
else if ( Q_strcmp(PANEL_INFO, szPanelName) == 0 )
{
newpanel = new CDODTextWindow( this );
}
else
{
// create a generic base panel, don't add twice
newpanel = BaseClass::CreatePanelByName( szPanelName );
}
return newpanel;
}
void DODViewport::CreateDefaultPanels( void )
{
AddNewPanel( CreatePanelByName( PANEL_TEAM ), "PANEL_TEAM" );
AddNewPanel( CreatePanelByName( PANEL_CLASS_ALLIES ), "PANEL_CLASS_ALLIES" );
AddNewPanel( CreatePanelByName( PANEL_CLASS_AXIS ), "PANEL_CLASS_AXIS" );
BaseClass::CreateDefaultPanels();
}
int DODViewport::GetDeathMessageStartHeight( void )
{
int y = YRES(5);
if ( g_pSpectatorGUI && g_pSpectatorGUI->IsVisible() )
{
y = g_pSpectatorGUI->GetTopBarHeight() + YRES(5);
}
if ( g_pMapOverview && g_pMapOverview->IsVisible() )
{
if ( g_pMapOverview->GetMode() == CMapOverview::MAP_MODE_INSET )
{
int map_x, map_y, map_w, map_h;
g_pMapOverview->GetBounds( map_x, map_y, map_w, map_h );
y = map_y + map_h + YRES(5);
}
}
return y;
}
-49
View File
@@ -1,49 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef DODVIEWPORT_H
#define DODVIEWPORT_H
#include "baseviewport.h"
using namespace vgui;
namespace vgui
{
class Panel;
}
class CDODTeamMenu;
class CDODClassMenu_Allies;
class CDODClassMenu_Axis;
class CDODSpectatorGUI;
class CDODClientScoreBoardDialog;
class CDODMenuBackground;
//==============================================================================
class DODViewport : public CBaseViewport
{
private:
DECLARE_CLASS_SIMPLE( DODViewport, CBaseViewport );
public:
IViewPortPanel* CreatePanelByName(const char *szPanelName);
void CreateDefaultPanels( void );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
int GetDeathMessageStartHeight( void );
// Never show the background
virtual void ShowBackGround(bool bShow) { NULL; }
};
#endif // DODVIEWPORT_H
-25
View File
@@ -1,25 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: interface class between viewport msg funcs and "c" based client dll
//
// $NoKeywords: $
//=============================================================================//
#if !defined( IDODVIEWPORTMSGS_H )
#define IDODVIEWPORTMSGS_H
#ifdef _WIN32
#pragma once
#endif
//#include "vgui/IViewPortMsgs.h"
class IDODViewPortMsgs /*: public IViewPortMsgs*/
{
public:
virtual int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf ) = 0;
};
extern IDODViewPortMsgs *gDODViewPortMsgs;
#endif // IDODVIEWPORTMSGS_H
-106
View File
@@ -1,106 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "vgui_int.h"
#include "ienginevgui.h"
#include "vgui_rootpanel_dod.h"
#include "vgui/IVGui.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
C_DODRootPanel *g_pRootPanel = NULL;
//-----------------------------------------------------------------------------
// Global functions.
//-----------------------------------------------------------------------------
void VGUI_CreateClientDLLRootPanel( void )
{
g_pRootPanel = new C_DODRootPanel( enginevgui->GetPanel( PANEL_CLIENTDLL ) );
}
void VGUI_DestroyClientDLLRootPanel( void )
{
delete g_pRootPanel;
g_pRootPanel = NULL;
}
vgui::VPANEL VGui_GetClientDLLRootPanel( void )
{
return g_pRootPanel->GetVPanel();
}
//-----------------------------------------------------------------------------
// C_DODRootPanel implementation.
//-----------------------------------------------------------------------------
C_DODRootPanel::C_DODRootPanel( vgui::VPANEL parent )
: BaseClass( NULL, "DOD Root Panel" )
{
SetParent( parent );
SetPaintEnabled( false );
SetPaintBorderEnabled( false );
SetPaintBackgroundEnabled( false );
// This panel does post child painting
SetPostChildPaintEnabled( true );
// Make it screen sized
SetBounds( 0, 0, ScreenWidth(), ScreenHeight() );
// Ask for OnTick messages
vgui::ivgui()->AddTickSignal( GetVPanel() );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_DODRootPanel::~C_DODRootPanel( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_DODRootPanel::PostChildPaint()
{
BaseClass::PostChildPaint();
// Draw all panel effects
RenderPanelEffects();
}
//-----------------------------------------------------------------------------
// Purpose: For each panel effect, check if it wants to draw and draw it on
// this panel/surface if so
//-----------------------------------------------------------------------------
void C_DODRootPanel::RenderPanelEffects( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_DODRootPanel::OnTick( void )
{
}
//-----------------------------------------------------------------------------
// Purpose: Reset effects on level load/shutdown
//-----------------------------------------------------------------------------
void C_DODRootPanel::LevelInit( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void C_DODRootPanel::LevelShutdown( void )
{
}
-56
View File
@@ -1,56 +0,0 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef VGUI_ROOTPANEL_DOD_H
#define VGUI_ROOTPANEL_DOD_H
#ifdef _WIN32
#pragma once
#endif
#include <vgui_controls/Panel.h>
#include <vgui_controls/EditablePanel.h>
#include "utlvector.h"
class CPanelEffect;
// Serial under of effect, for safe lookup
typedef unsigned int EFFECT_HANDLE;
//-----------------------------------------------------------------------------
// Purpose: Sits between engine and client .dll panels
// Responsible for drawing screen overlays
//-----------------------------------------------------------------------------
class C_DODRootPanel : public vgui::Panel
{
typedef vgui::Panel BaseClass;
public:
C_DODRootPanel( vgui::VPANEL parent );
virtual ~C_DODRootPanel( void );
// Draw Panel effects here
virtual void PostChildPaint();
// Clear list of Panel Effects
virtual void LevelInit( void );
virtual void LevelShutdown( void );
// Run effects and let them decide whether to remove themselves
void OnTick( void );
private:
// Render all panel effects
void RenderPanelEffects( void );
// List of current panel effects
CUtlVector< CPanelEffect *> m_Effects;
};
#endif // VGUI_ROOTPANEL_DOD_H