mirror of
https://github.com/celisej567/source-engine.git
synced 2026-09-19 20:09:06 +03:00
upload "kind" alien swarm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@@ -9,12 +9,11 @@
|
||||
#include "vguitextwindow.h"
|
||||
#include <networkstringtabledefs.h>
|
||||
#include <cdll_client_int.h>
|
||||
#include <clientmode_shared.h>
|
||||
|
||||
#include <vgui/IScheme.h>
|
||||
#include <vgui/ILocalize.h>
|
||||
#include <vgui/ISurface.h>
|
||||
#include <filesystem.h>
|
||||
#include <FileSystem.h>
|
||||
#include <KeyValues.h>
|
||||
#include <convar.h>
|
||||
#include <vgui_controls/ImageList.h>
|
||||
@@ -32,23 +31,19 @@ extern INetworkStringTable *g_pStringTableInfoPanel;
|
||||
|
||||
#define TEMP_HTML_FILE "textwindow_temp.html"
|
||||
|
||||
ConVar cl_disablehtmlmotd( "cl_disablehtmlmotd", "1", FCVAR_ARCHIVE, "Disable HTML motds." );
|
||||
#define MINI_MOTD_FADE_TIME 2.5f
|
||||
#define MINI_MOTD_HOLD_TIME 5.0f;
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Replaced text window command string with TEXTWINDOW_CMD enumeration
|
||||
// of options. Passing a command string is dangerous and allowed a server network
|
||||
// message to run arbitrary commands on the client.
|
||||
//=============================================================================
|
||||
CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command number>]" )
|
||||
|
||||
CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command>]" )
|
||||
{
|
||||
if ( !gViewPortInterface )
|
||||
if ( !GetViewPortInterface() )
|
||||
return;
|
||||
|
||||
if ( args.ArgC() < 4 )
|
||||
return;
|
||||
|
||||
IViewPortPanel * panel = gViewPortInterface->FindPanelByName( PANEL_INFO );
|
||||
IViewPortPanel * panel = GetViewPortInterface()->FindPanelByName( PANEL_INFO );
|
||||
|
||||
if ( panel )
|
||||
{
|
||||
@@ -62,7 +57,7 @@ CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command n
|
||||
|
||||
panel->SetData( kv );
|
||||
|
||||
gViewPortInterface->ShowPanel( panel, true );
|
||||
GetViewPortInterface()->ShowPanel( panel, true );
|
||||
|
||||
kv->deleteThis();
|
||||
}
|
||||
@@ -71,14 +66,11 @@ CON_COMMAND( showinfo, "Shows a info panel: <type> <title> <message> [<command n
|
||||
Msg("Couldn't find info panel.\n" );
|
||||
}
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
CTextWindow::CTextWindow(IViewPort *pViewPort) : Frame(NULL, PANEL_INFO )
|
||||
CTextWindow::CTextWindow(IViewPort *pViewPort) : BaseClass(NULL, PANEL_INFO )
|
||||
{
|
||||
// initialize dialog
|
||||
m_pViewPort = pViewPort;
|
||||
@@ -87,28 +79,30 @@ CTextWindow::CTextWindow(IViewPort *pViewPort) : Frame(NULL, PANEL_INFO )
|
||||
|
||||
m_szTitle[0] = '\0';
|
||||
m_szMessage[0] = '\0';
|
||||
m_szMessageFallback[0] = '\0';
|
||||
m_nExitCommand = TEXTWINDOW_CMD_NONE;
|
||||
m_bShownURL = false;
|
||||
m_bUnloadOnDismissal = false;
|
||||
m_szExitCommand[0] = '\0';
|
||||
|
||||
// load the new scheme early!!
|
||||
SetScheme("ClientScheme");
|
||||
SetMoveable(false);
|
||||
SetSizeable(false);
|
||||
SetProportional(true);
|
||||
|
||||
// hide the system buttons
|
||||
SetTitleBarVisible( false );
|
||||
|
||||
m_pTextMessage = new TextEntry( this, "TextMessage" );
|
||||
m_pHTMLMessage = new CMOTDHTML( this,"HTMLMessage" );
|
||||
m_pTextMessage = new TextEntry(this, "TextMessage");
|
||||
#if defined( ENABLE_HTMLWINDOW )
|
||||
m_pHTMLMessage = new HTML(this,"HTMLMessage");;
|
||||
#endif
|
||||
m_pTitleLabel = new Label( this, "MessageTitle", "Message Title" );
|
||||
m_pOK = new Button(this, "ok", "#PropertyDialog_OK");
|
||||
|
||||
m_pOK->SetCommand("okay");
|
||||
m_pTextMessage->SetMultiline( true );
|
||||
m_nContentType = TYPE_TEXT;
|
||||
m_iFadeStatus = FADE_STATUS_IN;
|
||||
|
||||
m_bMiniMode = false;
|
||||
|
||||
ListenForGameEvent( "game_newmap" );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -118,9 +112,15 @@ void CTextWindow::ApplySchemeSettings( IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
LoadControlSettings("Resource/UI/TextWindow.res");
|
||||
if ( !m_bMiniMode )
|
||||
{
|
||||
LoadControlSettings("Resource/UI/TextWindow.res");
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadControlSettings("Resource/UI/MiniMOTD.res");
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -129,72 +129,44 @@ void CTextWindow::ApplySchemeSettings( IScheme *pScheme )
|
||||
CTextWindow::~CTextWindow()
|
||||
{
|
||||
// remove temp file again
|
||||
if (g_pFullFileSystem->FileExists(TEMP_HTML_FILE))
|
||||
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
|
||||
g_pFullFileSystem->RemoveFile( TEMP_HTML_FILE, "DEFAULT_WRITE_PATH" );
|
||||
}
|
||||
|
||||
void CTextWindow::Reset( void )
|
||||
{
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Replace strange hard-coded default message with hard-coded error message.
|
||||
//=============================================================================
|
||||
V_strcpy_safe( m_szTitle, "Error loading info message." );
|
||||
V_strcpy_safe( m_szMessage, "" );
|
||||
V_strcpy_safe( m_szMessageFallback, "" );
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
Q_strcpy( m_szTitle, "This could be your Title." );
|
||||
Q_strcpy( m_szMessage, "Just for 10 Euros a week!" );
|
||||
m_szExitCommand[0] = 0;
|
||||
|
||||
m_nExitCommand = TEXTWINDOW_CMD_NONE;
|
||||
m_nContentType = TYPE_TEXT;
|
||||
m_bShownURL = false;
|
||||
m_bUnloadOnDismissal = false;
|
||||
Update();
|
||||
if ( m_bMiniMode )
|
||||
{
|
||||
m_iFadeStatus = FADE_STATUS_OFF;
|
||||
SetAlpha( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetAlpha( 255 );
|
||||
}
|
||||
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
void CTextWindow::ShowText( const char *text )
|
||||
void CTextWindow::ShowText( const char *text)
|
||||
{
|
||||
m_pTextMessage->SetVisible( true );
|
||||
m_pTextMessage->SetText( text );
|
||||
m_pTextMessage->GotoTextStart();
|
||||
}
|
||||
|
||||
void CTextWindow::ShowURL( const char *URL, bool bAllowUserToDisable )
|
||||
void CTextWindow::ShowURL( const char *URL)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
Msg( "CTextWindow::ShowURL( %s )\n", URL );
|
||||
#endif
|
||||
|
||||
ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal();
|
||||
if ( ( bAllowUserToDisable && cl_disablehtmlmotd.GetBool() ) || !mode->IsHTMLInfoPanelAllowed() )
|
||||
{
|
||||
Warning( "Blocking HTML info panel '%s'; Using plaintext instead.\n", URL );
|
||||
|
||||
// User has disabled HTML TextWindows. Show the fallback as text only.
|
||||
if ( g_pStringTableInfoPanel )
|
||||
{
|
||||
int index = g_pStringTableInfoPanel->FindStringIndex( "motd_text" );
|
||||
if ( index != ::INVALID_STRING_INDEX )
|
||||
{
|
||||
int length = 0;
|
||||
const char *data = (const char *)g_pStringTableInfoPanel->GetStringUserData( index, &length );
|
||||
if ( data && data[0] )
|
||||
{
|
||||
m_pHTMLMessage->SetVisible( false );
|
||||
ShowText( data );
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined( ENABLE_HTMLWINDOW )
|
||||
m_pHTMLMessage->SetVisible( true );
|
||||
m_pHTMLMessage->OpenURL( URL, NULL );
|
||||
m_bShownURL = true;
|
||||
m_pHTMLMessage->OpenURL( URL );
|
||||
#endif
|
||||
}
|
||||
|
||||
void CTextWindow::ShowIndex( const char *entry )
|
||||
void CTextWindow::ShowIndex( const char *entry)
|
||||
{
|
||||
const char *data = NULL;
|
||||
int length = 0;
|
||||
@@ -211,7 +183,7 @@ void CTextWindow::ShowIndex( const char *entry )
|
||||
return; // nothing to show
|
||||
|
||||
// is this a web URL ?
|
||||
if ( !Q_strncmp( data, "http://", 7 ) || !Q_strncmp( data, "https://", 8 ) )
|
||||
if ( !Q_strncmp( data, "http://", 7 ) )
|
||||
{
|
||||
ShowURL( data );
|
||||
return;
|
||||
@@ -251,6 +223,9 @@ void CTextWindow::ShowFile( const char *filename )
|
||||
g_pFullFileSystem->GetLocalPath( filename, pPathData, sizeof(pPathData) );
|
||||
Q_strncat( localURL, pPathData, sizeof( localURL ), COPY_ALL_CHARACTERS );
|
||||
|
||||
// force steam to dump a local copy
|
||||
filesystem->GetLocalCopy( pPathData );
|
||||
|
||||
ShowURL( localURL );
|
||||
}
|
||||
else
|
||||
@@ -275,14 +250,114 @@ void CTextWindow::ShowFile( const char *filename )
|
||||
}
|
||||
|
||||
void CTextWindow::Update( void )
|
||||
{
|
||||
if ( IsVisible() == false )
|
||||
return;
|
||||
|
||||
if ( m_bMiniMode )
|
||||
{
|
||||
if ( m_iFadeStatus == FADE_STATUS_IN )
|
||||
{
|
||||
float flDeltaTime = ( m_flNextFadeTime - gpGlobals->curtime );
|
||||
|
||||
SetAlpha ( MAX( 0, RemapValClamped( flDeltaTime, MINI_MOTD_FADE_TIME, 0, -128, 255 ) ) );
|
||||
|
||||
if ( flDeltaTime <= 0.0f )
|
||||
{
|
||||
m_iFadeStatus = FADE_STATUS_HOLD;
|
||||
m_flNextFadeTime = gpGlobals->curtime + MINI_MOTD_HOLD_TIME
|
||||
}
|
||||
}
|
||||
else if ( m_iFadeStatus == FADE_STATUS_HOLD )
|
||||
{
|
||||
float flDeltaTime = ( m_flNextFadeTime - gpGlobals->curtime );
|
||||
|
||||
if ( flDeltaTime <= 0.0f )
|
||||
{
|
||||
m_iFadeStatus = FADE_STATUS_OUT;
|
||||
m_flNextFadeTime = gpGlobals->curtime + MINI_MOTD_FADE_TIME;
|
||||
}
|
||||
}
|
||||
else if ( m_iFadeStatus == FADE_STATUS_OUT )
|
||||
{
|
||||
float flDeltaTime = ( m_flNextFadeTime - gpGlobals->curtime );
|
||||
|
||||
SetAlpha ( RemapValClamped( flDeltaTime, 0.0f, MINI_MOTD_FADE_TIME, 0, 255 ) );
|
||||
|
||||
if ( flDeltaTime <= 0.0f )
|
||||
{
|
||||
m_iFadeStatus = FADE_STATUS_OFF;
|
||||
SetVisible( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTextWindow::OnCommand( const char *command)
|
||||
{
|
||||
if (!Q_strcmp(command, "okay"))
|
||||
{
|
||||
if ( m_szExitCommand[0] )
|
||||
{
|
||||
engine->ClientCmd( m_szExitCommand );
|
||||
}
|
||||
|
||||
m_pViewPort->ShowPanel( this, false );
|
||||
}
|
||||
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
|
||||
void CTextWindow::SetData(KeyValues *data)
|
||||
{
|
||||
if ( IsVisible() == true )
|
||||
return;
|
||||
|
||||
SetData( data->GetInt( "type" ), data->GetString( "title"), data->GetString( "msg" ), data->GetString( "cmd" ) );
|
||||
}
|
||||
|
||||
void CTextWindow::SetData( int type, const char *title, const char *message, const char *command )
|
||||
{
|
||||
Q_strncpy( m_szTitle, title, sizeof( m_szTitle ) );
|
||||
Q_strncpy( m_szMessage, message, sizeof( m_szMessage ) );
|
||||
|
||||
if ( command )
|
||||
{
|
||||
Q_strncpy( m_szExitCommand, command, sizeof(m_szExitCommand) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_szExitCommand[0]=0;
|
||||
}
|
||||
|
||||
m_nContentType = type;
|
||||
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
void CTextWindow::UpdateContents( void )
|
||||
{
|
||||
SetTitle( m_szTitle, false );
|
||||
|
||||
m_pTitleLabel->SetText( m_szTitle );
|
||||
if ( m_pTitleLabel )
|
||||
{
|
||||
m_pTitleLabel->SetText( m_szTitle );
|
||||
}
|
||||
|
||||
#if defined( ENABLE_HTMLWINDOW )
|
||||
if ( m_pHTMLMessage )
|
||||
{
|
||||
m_pHTMLMessage->SetVisible( false );
|
||||
m_pTextMessage->SetVisible( false );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( m_pTextMessage )
|
||||
{
|
||||
m_pTextMessage->SetVisible( false );
|
||||
}
|
||||
|
||||
if ( m_bMiniMode )
|
||||
return;
|
||||
|
||||
if ( m_nContentType == TYPE_INDEX )
|
||||
{
|
||||
@@ -290,15 +365,7 @@ void CTextWindow::Update( void )
|
||||
}
|
||||
else if ( m_nContentType == TYPE_URL )
|
||||
{
|
||||
if ( !Q_strncmp( m_szMessage, "http://", 7 ) || !Q_strncmp( m_szMessage, "https://", 8 ) || !Q_stricmp( m_szMessage, "about:blank" ) )
|
||||
{
|
||||
ShowURL( m_szMessage );
|
||||
}
|
||||
else
|
||||
{
|
||||
// We should have trapped this at a higher level
|
||||
Assert( !"URL protocol is missing or blocked" );
|
||||
}
|
||||
ShowURL( m_szMessage );
|
||||
}
|
||||
else if ( m_nContentType == TYPE_FILE )
|
||||
{
|
||||
@@ -314,124 +381,77 @@ void CTextWindow::Update( void )
|
||||
}
|
||||
}
|
||||
|
||||
void CTextWindow::OnCommand( const char *command )
|
||||
{
|
||||
if (!Q_strcmp(command, "okay"))
|
||||
{
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [Forrest] Replaced text window command string with TEXTWINDOW_CMD enumeration
|
||||
// of options. Passing a command string is dangerous and allowed a server network
|
||||
// message to run arbitrary commands on the client.
|
||||
//=============================================================================
|
||||
const char *pszCommand = NULL;
|
||||
switch ( m_nExitCommand )
|
||||
{
|
||||
case TEXTWINDOW_CMD_NONE:
|
||||
break;
|
||||
|
||||
case TEXTWINDOW_CMD_JOINGAME:
|
||||
pszCommand = "joingame";
|
||||
break;
|
||||
|
||||
case TEXTWINDOW_CMD_CHANGETEAM:
|
||||
pszCommand = "changeteam";
|
||||
break;
|
||||
|
||||
case TEXTWINDOW_CMD_IMPULSE101:
|
||||
pszCommand = "impulse 101";
|
||||
break;
|
||||
|
||||
case TEXTWINDOW_CMD_MAPINFO:
|
||||
pszCommand = "mapinfo";
|
||||
break;
|
||||
|
||||
case TEXTWINDOW_CMD_CLOSED_HTMLPAGE:
|
||||
pszCommand = "closed_htmlpage";
|
||||
break;
|
||||
|
||||
case TEXTWINDOW_CMD_CHOOSETEAM:
|
||||
pszCommand = "chooseteam";
|
||||
break;
|
||||
|
||||
default:
|
||||
DevMsg("CTextWindow::OnCommand: unknown exit command value %i\n", m_nExitCommand );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( pszCommand != NULL )
|
||||
{
|
||||
engine->ClientCmd_Unrestricted( pszCommand );
|
||||
}
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
m_pViewPort->ShowPanel( this, false );
|
||||
}
|
||||
|
||||
BaseClass::OnCommand(command);
|
||||
}
|
||||
|
||||
void CTextWindow::OnKeyCodePressed( vgui::KeyCode code )
|
||||
{
|
||||
if ( code == KEY_XBUTTON_A || code == KEY_XBUTTON_B || code == STEAMCONTROLLER_A || code == STEAMCONTROLLER_B )
|
||||
{
|
||||
OnCommand( "okay" );
|
||||
return;
|
||||
}
|
||||
|
||||
BaseClass::OnKeyCodePressed(code);
|
||||
}
|
||||
|
||||
void CTextWindow::SetData(KeyValues *data)
|
||||
{
|
||||
SetData( data->GetInt( "type" ), data->GetString( "title" ), data->GetString( "msg" ), data->GetString( "msg_fallback" ), data->GetInt( "cmd" ), data->GetBool( "unload" ) );
|
||||
}
|
||||
|
||||
void CTextWindow::SetData( int type, const char *title, const char *message, const char *message_fallback, int command, bool bUnload )
|
||||
{
|
||||
Q_strncpy( m_szTitle, title, sizeof( m_szTitle ) );
|
||||
Q_strncpy( m_szMessage, message, sizeof( m_szMessage ) );
|
||||
Q_strncpy( m_szMessageFallback, message_fallback, sizeof( m_szMessageFallback ) );
|
||||
|
||||
m_nExitCommand = command;
|
||||
|
||||
m_nContentType = type;
|
||||
m_bUnloadOnDismissal = bUnload;
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
void CTextWindow::ShowPanel( bool bShow )
|
||||
{
|
||||
if ( IsX360() )
|
||||
{
|
||||
// Say no to MOTD from Xbox 360 clients!
|
||||
bShow = false;
|
||||
}
|
||||
|
||||
if ( BaseClass::IsVisible() == bShow )
|
||||
return;
|
||||
|
||||
m_pViewPort->ShowBackGround( bShow );
|
||||
|
||||
m_bMiniMode = false;
|
||||
if ( m_szMessage && m_szMessage[0] )
|
||||
{
|
||||
if ( !Q_strncmp( m_szMessage, "hostfile", 8 ) )
|
||||
{
|
||||
m_bMiniMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bShow )
|
||||
{
|
||||
InvalidateLayout( true, true );
|
||||
}
|
||||
|
||||
UpdateContents();
|
||||
|
||||
if ( bShow )
|
||||
{
|
||||
Activate();
|
||||
SetMouseInputEnabled( true );
|
||||
|
||||
if ( !m_bMiniMode )
|
||||
{
|
||||
SetVisible( true );
|
||||
SetMouseInputEnabled( true );
|
||||
SetKeyBoardInputEnabled( true );
|
||||
SetAlpha( 255 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iFadeStatus = FADE_STATUS_IN;
|
||||
m_flNextFadeTime = gpGlobals->curtime + MINI_MOTD_FADE_TIME;
|
||||
SetAlpha( 0 );
|
||||
|
||||
SetMouseInputEnabled( false );
|
||||
SetKeyBoardInputEnabled( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVisible( false );
|
||||
SetMouseInputEnabled( false );
|
||||
|
||||
if ( m_bUnloadOnDismissal && m_bShownURL && m_pHTMLMessage )
|
||||
if ( !m_bMiniMode )
|
||||
{
|
||||
m_pHTMLMessage->OpenURL( "about:blank", NULL );
|
||||
m_bShownURL = false;
|
||||
SetMouseInputEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CTextWindow::CMOTDHTML::OnStartRequest( const char *url, const char *target, const char *pchPostData, bool bIsRedirect )
|
||||
void CTextWindow::FireGameEvent( IGameEvent *event )
|
||||
{
|
||||
if ( Q_strstr( url, "steam://" ) )
|
||||
return false;
|
||||
|
||||
return BaseClass::OnStartRequest( url, target, pchPostData, bIsRedirect );
|
||||
const char *name = event->GetName();
|
||||
if ( Q_strcmp( name, "game_newmap" ) == 0 )
|
||||
{
|
||||
m_bIgnoreMultipleShowRequests = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CTextWindow::WantsBackgroundBlurred( void )
|
||||
{
|
||||
return (!m_bMiniMode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user