Implemented FF-specific versions of VGUI RootPanel, HudViewport, and ClientMode in preparation for some unfinished changes that will need them

- Note: These files are based on the sdk_ versions, not the HL2/HL2MP versions; the scoreboard and whatnot won't work right now, but I will make it use the HL2MP HUD elements again soon
This commit is contained in:
squeek 2013-11-11 06:58:07 +00:00
parent 89b2c2098b
commit d6d589637f
9 changed files with 459 additions and 4 deletions

View File

@ -34,6 +34,15 @@ $Project "Client (FF)"
{
$File "ff\ff_cl_dll_interface.cpp"
$File "ff\ff_cl_dll_interface.h"
$File "ff\ff_cl_clientmode.cpp"
$File "ff\ff_cl_clientmode.h"
}
$Folder "UI"
{
$File "ff\ui\ff_cl_hudviewport.cpp"
$File "ff\ui\ff_cl_hudviewport.h"
$File "ff\ui\ff_cl_vgui_rootpanel.cpp"
$File "ff\ui\ff_cl_vgui_rootpanel.h"
}
$Folder "Lua"
{
@ -67,6 +76,9 @@ $Project "Client (FF)"
{
-$File "$SRCDIR\game\shared\hl2\hl_gamemovement.cpp"
-$File "$SRCDIR\game\shared\hl2\hl_gamemovement.h"
-$File "hl2\hl2_clientmode.cpp"
-$File "hl2\vgui_rootpanel_hl2.cpp"
}
$Folder "HL2MP"
@ -76,6 +88,9 @@ $Project "Client (FF)"
-$File "hl2mp\c_hl2mp_player.h"
-$File "$SRCDIR\game\shared\hl2mp\hl2mp_player_shared.cpp"
-$File "$SRCDIR\game\shared\hl2mp\hl2mp_player_shared.h"
-$File "hl2mp\clientmode_hl2mpnormal.cpp"
-$File "hl2mp\clientmode_hl2mpnormal.h"
}
$Folder "Shader Editor" [$WIN32]

View File

@ -0,0 +1,130 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//===========================================================================//
#include "cbase.h"
#include "hud.h"
#include "ff_cl_clientmode.h"
#include "cdll_client_int.h"
#include "iinput.h"
#include "vgui/ISurface.h"
#include "vgui/IPanel.h"
#include <vgui_controls/AnimationController.h>
#include "ivmodemanager.h"
#include "buymenu.h"
#include "filesystem.h"
#include "vgui/IVGui.h"
#include "hud_chat.h"
#include "view_shared.h"
#include "view.h"
#include "ivrenderview.h"
#include "model_types.h"
#include "iefx.h"
#include "dlight.h"
#include <imapoverview.h>
#include "c_playerresource.h"
#include <KeyValues.h>
#include "text_message.h"
#include "panelmetaclassmgr.h"
ConVar default_fov( "default_fov", "90", FCVAR_CHEAT );
IClientMode *g_pClientMode = NULL;
// --------------------------------------------------------------------------------- //
// CFF_CL_ClientModeManager.
// --------------------------------------------------------------------------------- //
class CFF_CL_ClientModeManager : public IVModeManager
{
public:
virtual void Init();
virtual void SwitchMode( bool commander, bool force ) {}
virtual void LevelInit( const char *newmap );
virtual void LevelShutdown( void );
virtual void ActivateMouse( bool isactive ) {}
};
static CFF_CL_ClientModeManager g_ModeManager;
IVModeManager *modemanager = ( IVModeManager * )&g_ModeManager;
// --------------------------------------------------------------------------------- //
// CFF_CL_ClientModeManager implementation.
// --------------------------------------------------------------------------------- //
#define SCREEN_FILE "scripts/vgui_screens.txt"
void CFF_CL_ClientModeManager::Init()
{
g_pClientMode = GetClientModeNormal();
PanelMetaClassMgr()->LoadMetaClassDefinitionFile( SCREEN_FILE );
}
void CFF_CL_ClientModeManager::LevelInit( const char *newmap )
{
g_pClientMode->LevelInit( newmap );
}
void CFF_CL_ClientModeManager::LevelShutdown( void )
{
g_pClientMode->LevelShutdown();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CFF_CL_ClientModeNormal::CFF_CL_ClientModeNormal()
{
}
//-----------------------------------------------------------------------------
// Purpose: If you don't know what a destructor is by now, you are probably going to get fired
//-----------------------------------------------------------------------------
CFF_CL_ClientModeNormal::~CFF_CL_ClientModeNormal()
{
}
void CFF_CL_ClientModeNormal::InitViewport()
{
m_pViewport = new CFF_CL_HudViewport();
m_pViewport->Start( gameuifuncs, gameeventmanager );
}
CFF_CL_ClientModeNormal g_ClientModeNormal;
IClientMode *GetClientModeNormal()
{
return &g_ClientModeNormal;
}
CFF_CL_ClientModeNormal* GetClientModeFFNormal()
{
Assert( dynamic_cast< CFF_CL_ClientModeNormal* >( GetClientModeNormal() ) );
return static_cast< CFF_CL_ClientModeNormal* >( GetClientModeNormal() );
}
float CFF_CL_ClientModeNormal::GetViewModelFOV( void )
{
return BaseClass::GetViewModelFOV();
}
int CFF_CL_ClientModeNormal::GetDeathMessageStartHeight( void )
{
return m_pViewport->GetDeathMessageStartHeight();
}
void CFF_CL_ClientModeNormal::PostRenderVGui()
{
}

View File

@ -0,0 +1,40 @@
#pragma once
#ifndef FF_CL_CLIENTMODE_H
#define FF_CL_CLIENTMODE_H
#include "clientmode_shared.h"
#include "ui/ff_cl_hudviewport.h"
class CFF_CL_ClientModeNormal : public ClientModeShared
{
DECLARE_CLASS( CFF_CL_ClientModeNormal, ClientModeShared );
private:
// IClientMode overrides.
public:
CFF_CL_ClientModeNormal();
virtual ~CFF_CL_ClientModeNormal();
virtual void InitViewport();
virtual float GetViewModelFOV( void );
int GetDeathMessageStartHeight( void );
virtual void PostRenderVGui();
private:
// void UpdateSpectatorMode( void );
};
extern IClientMode *GetClientModeNormal();
extern CFF_CL_ClientModeNormal* GetClientModeFFNormal();
#endif // FF_CL_CLIENTMODE_H

View File

@ -0,0 +1,85 @@
//========= 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>
// viewport definitions
#include <baseviewport.h>
#include "ff_cl_hudviewport.h"
#include "vguicenterprint.h"
#include "text_message.h"
void CFF_CL_HudViewport::ApplySchemeSettings( vgui::IScheme *pScheme )
{
BaseClass::ApplySchemeSettings( pScheme );
gHUD.InitColors( pScheme );
SetPaintBackgroundEnabled( false );
}
IViewPortPanel* CFF_CL_HudViewport::CreatePanelByName(const char *szPanelName)
{
IViewPortPanel* newpanel = NULL;
// Up here, strcmp against each type of panel we know how to create.
// else if ( Q_strcmp(PANEL_OVERVIEW, szPanelName) == 0 )
// {
// newpanel = new CCSMapOverview( this );
// }
// create a generic base panel, don't add twice
newpanel = BaseClass::CreatePanelByName( szPanelName );
return newpanel;
}
void CFF_CL_HudViewport::CreateDefaultPanels( void )
{
BaseClass::CreateDefaultPanels();
}
int CFF_CL_HudViewport::GetDeathMessageStartHeight( void )
{
int x = YRES(2);
IViewPortPanel *spectator = gViewPortInterface->FindPanelByName( PANEL_SPECGUI );
//TODO: Link to actual height of spectator bar
if ( spectator && spectator->IsVisible() )
{
x += YRES(52);
}
return x;
}

View File

@ -0,0 +1,31 @@
#pragma once
#ifndef FF_CL_HUDVIEWPORT_H
#define FF_CL_HUDVIEWPORT_H
#include "baseviewport.h"
using namespace vgui;
namespace vgui
{
class Panel;
}
class CFF_CL_HudViewport : public CBaseViewport
{
private:
DECLARE_CLASS_SIMPLE( CFF_CL_HudViewport, CBaseViewport );
public:
IViewPortPanel* CreatePanelByName(const char *szPanelName);
void CreateDefaultPanels( void );
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
int GetDeathMessageStartHeight( void );
};
#endif // FF_CL_HUDVIEWPORT_H

View File

@ -0,0 +1,106 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "vgui_int.h"
#include "ienginevgui.h"
#include "ff_cl_vgui_rootpanel.h"
#include "vgui/IVGui.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
CFF_CL_VGUI_RootPanel *g_pRootPanel = NULL;
//-----------------------------------------------------------------------------
// Global functions.
//-----------------------------------------------------------------------------
void VGUI_CreateClientDLLRootPanel( void )
{
g_pRootPanel = new CFF_CL_VGUI_RootPanel( enginevgui->GetPanel( PANEL_CLIENTDLL ) );
}
void VGUI_DestroyClientDLLRootPanel( void )
{
delete g_pRootPanel;
g_pRootPanel = NULL;
}
vgui::VPANEL VGui_GetClientDLLRootPanel( void )
{
return g_pRootPanel->GetVPanel();
}
//-----------------------------------------------------------------------------
// CFF_CL_VGUI_RootPanel implementation.
//-----------------------------------------------------------------------------
CFF_CL_VGUI_RootPanel::CFF_CL_VGUI_RootPanel( vgui::VPANEL parent )
: BaseClass( NULL, "FF 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:
//-----------------------------------------------------------------------------
CFF_CL_VGUI_RootPanel::~CFF_CL_VGUI_RootPanel( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFF_CL_VGUI_RootPanel::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 CFF_CL_VGUI_RootPanel::RenderPanelEffects( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFF_CL_VGUI_RootPanel::OnTick( void )
{
}
//-----------------------------------------------------------------------------
// Purpose: Reset effects on level load/shutdown
//-----------------------------------------------------------------------------
void CFF_CL_VGUI_RootPanel::LevelInit( void )
{
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFF_CL_VGUI_RootPanel::LevelShutdown( void )
{
}

View File

@ -0,0 +1,47 @@
#pragma once
#ifndef FF_CL_VGUI_ROOTPANEL_H
#define FF_CL_VGUI_ROOTPANEL_H
#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 CFF_CL_VGUI_RootPanel : public vgui::Panel
{
typedef vgui::Panel BaseClass;
public:
CFF_CL_VGUI_RootPanel( vgui::VPANEL parent );
virtual ~CFF_CL_VGUI_RootPanel( 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 // FF_CL_VGUI_ROOTPANEL_H

View File

@ -10,7 +10,7 @@
#include <vgui/IVGui.h>
#include <vgui_controls/Controls.h>
#include <vgui_controls/Label.h>
#include "clientmode_hlnormal.h"
//#include "clientmode_hlnormal.h"
#include "tier1/utllinkedlist.h"
// memdbgon must be the last include file in a .cpp file!!!
@ -105,7 +105,7 @@ DECLARE_VGUI_SCREEN_FACTORY( CTeleportCountdownScreen, "teleport_countdown_scree
// Constructor:
//-----------------------------------------------------------------------------
CTeleportCountdownScreen::CTeleportCountdownScreen( vgui::Panel *parent, const char *panelName )
: BaseClass( parent, panelName, g_hVGuiCombineScheme )
: BaseClass( parent, panelName/*, g_hVGuiCombineScheme*/ ) // FF: This scheme no longer exists
{
}

View File

@ -8,7 +8,8 @@
#include "hudelement.h"
#include "hud_macros.h"
#include "c_playerresource.h"
#include "clientmode_hl2mpnormal.h"
//#include "clientmode_hl2mpnormal.h"
#include "ff_cl_clientmode.h"
#include <vgui_controls/Controls.h>
#include <vgui_controls/Panel.h>
#include <vgui/ISurface.h>
@ -147,7 +148,7 @@ void CHudDeathNotice::Paint()
if ( !m_iconD_skull )
return;
int yStart = GetClientModeHL2MPNormal()->GetDeathMessageStartHeight();
int yStart = GetClientModeFFNormal()->GetDeathMessageStartHeight();
surface()->DrawSetTextFont( m_hTextFont );
surface()->DrawSetTextColor( GameResources()->GetTeamColor( 0 ) );