Get VGUI back (optionally) (#194)

* Get VGUI back (optionally)

* Add some missing VGUI invocations

* Update CMakeLists.txt to build with vgui for Windows

* Move windows.h inclusions only to those places where it's really needed

* Try fix mingw build

* Update hud_spectator

* Merge nekonomicon's vgui branch

* Don't include vgui panel and app in cdll_int.cpp if vgui is real

* Deduplicate scoreboard global variables

* Add options to prefer non-vgui motd and scoreboard when vgui is enabled

* Add vgui-dev as a submodule. Add building vith vgui to CI

* Fix artifact uploading

* Don't use global variable when not necessary

* char* to const char* in CMenuHandler_StringCommand constructor

* Fix 'format string is not a literal string' warnings

* Fix 'always evaluate to true' warnings

* Team Fortress classes to const char*

* CreateCommandMenu accepts const char*

* Fix printf formats. Turn some unsigned longs into unsigned ints since they use only 32 bits anyway

* Explicit assignment result as condition

* Prevent memory leak on menu reading

* Localize button text

* Create FileInputStream on stack avoiding the leak

* Remove Servers Browser code

* Arrow file names to const char*

* Fix assignment to the wrong variable
pull/198/head
Roman Chistokhodov 2 years ago committed by GitHub
parent 302e2d7a2a
commit ba2cab60df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,6 +23,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Checkout steam-runtime
if: startsWith(matrix.os, 'ubuntu')
@ -58,6 +60,13 @@ jobs:
schroot --chroot steamrt_scout_i386 -- cmake -B build -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="$PWD/dist"
schroot --chroot steamrt_scout_i386 -- cmake --build build --target all
schroot --chroot steamrt_scout_i386 -- cmake --build build --target install
- name: Build with goldsource input and vgui
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.cc, 'gcc')
run: |
schroot --chroot steamrt_scout_i386 -- cmake -B build-vgui -S . -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DGOLDSOURCE_SUPPORT=ON -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="$PWD/dist-vgui"
cp vgui-dev/lib/vgui.so build-vgui/cl_dll
schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target all
schroot --chroot steamrt_scout_i386 -- cmake --build build-vgui --target install
- name: Build with mingw
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.cc, 'gcc')
@ -74,6 +83,11 @@ jobs:
run: |
cmake -G "Visual Studio 15 2017" -B build -DGOLDSOURCE_SUPPORT=ON -DCMAKE_INSTALL_PREFIX="dist"
msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj
- name: Build with msvc and vgui
if: startsWith(matrix.os, 'windows')
run: |
cmake -G "Visual Studio 15 2017" -B build -DGOLDSOURCE_SUPPORT=ON -DUSE_VGUI=ON -DCMAKE_INSTALL_PREFIX="dist-vgui"
msbuild -verbosity:normal /property:Configuration=Release build/INSTALL.vcxproj
- name: Extract branch name
shell: bash
@ -89,10 +103,22 @@ jobs:
with:
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux
path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
- name: Upload linux artifact with vgui
if: startsWith(matrix.os, 'ubuntu') && matrix.cc == 'gcc'
uses: actions/upload-artifact@v2
with:
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-linux-vgui
path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }}
- name: Upload windows artifact
if: startsWith(matrix.os, 'windows')
uses: actions/upload-artifact@v2
with:
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows
path: dist/${{ steps.extract_gamedir.outputs.gamedir }}
- name: Upload windows artifact with vgui
if: startsWith(matrix.os, 'windows')
uses: actions/upload-artifact@v2
with:
name: hlsdk-${{ steps.extract_branch.outputs.branch }}-windows-vgui
path: dist-vgui/${{ steps.extract_gamedir.outputs.gamedir }}

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "vgui-dev"]
path = vgui-dev
url = https://github.com/FWGS/vgui-dev

@ -36,8 +36,10 @@ project (HLSDK-XASH3D)
#--------------
# USER DEFINES \
################\
option(USE_VGUI "Enable VGUI1. UNDONE" OFF)
option(USE_VGUI "Enable VGUI1." OFF)
option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF)
option(USE_NOVGUI_MOTD "Prefer non-VGUI MOTD when USE_VGUI is enabled" OFF)
option(USE_NOVGUI_SCOREBOARD "Prefer non-VGUI Scoreboard when USE_VGUI is enabled" OFF)
option(USE_VOICEMGR "Enable VOICE MANAGER." OFF)
option(BUILD_CLIENT "Build client dll" ON)
option(BUILD_SERVER "Build server dll" ON)

@ -50,6 +50,15 @@ if (GOLDSOURCE_SUPPORT)
add_definitions(-DGOLDSOURCE_SUPPORT)
endif()
if (USE_VGUI)
add_definitions(-DUSE_VGUI)
if (USE_NOVGUI_MOTD)
add_definitions(-DUSE_NOVGUI_MOTD)
endif()
if (USE_NOVGUI_SCOREBOARD)
add_definitions(-DUSE_NOVGUI_SCOREBOARD)
endif()
endif()
set (CLDLL_SOURCES
../dlls/crossbow.cpp
@ -112,11 +121,52 @@ set (CLDLL_SOURCES
train.cpp
tri.cpp
util.cpp
view.cpp
scoreboard.cpp
MOTD.cpp)
view.cpp)
if (USE_VGUI)
list(APPEND CLDLL_SOURCES
vgui_int.cpp
vgui_ClassMenu.cpp
vgui_ConsolePanel.cpp
vgui_ControlConfigPanel.cpp
vgui_CustomObjects.cpp
vgui_MOTDWindow.cpp
vgui_SchemeManager.cpp
vgui_ScorePanel.cpp
vgui_TeamFortressViewport.cpp
vgui_SpectatorPanel.cpp
vgui_teammenu.cpp
voice_status.cpp
../game_shared/vgui_checkbutton2.cpp
../game_shared/vgui_grid.cpp
../game_shared/vgui_helpers.cpp
../game_shared/vgui_listbox.cpp
../game_shared/vgui_loadtga.cpp
../game_shared/vgui_scrollbar2.cpp
../game_shared/vgui_slider2.cpp
../game_shared/voice_banmgr.cpp
)
if (USE_NOVGUI_MOTD)
list(APPEND CLDLL_SOURCES MOTD.cpp)
endif()
if (USE_NOVGUI_SCOREBOARD)
list(APPEND CLDLL_SOURCES scoreboard.cpp)
endif()
else()
list(APPEND CLDLL_SOURCES
MOTD.cpp
scoreboard.cpp)
endif()
include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include)
include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public)
if (USE_VGUI)
SET(CMAKE_SKIP_RPATH TRUE)
link_directories(${CMAKE_SOURCE_DIR}/vgui-dev/lib)
include_directories(../vgui-dev/include)
else()
include_directories(../utils/false_vgui/include)
endif()
if(USE_VOICEMGR)
#set(CLDLL_SOURCES
@ -126,10 +176,25 @@ if(USE_VOICEMGR)
endif()
add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES})
if (GOLDSOURCE_SUPPORT)
target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} )
endif()
if (USE_VGUI)
if (WIN32)
add_library(vgui SHARED IMPORTED)
set_property(TARGET vgui PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/vgui-dev/lib/win32_vc6/vgui.dll")
set_property(TARGET vgui PROPERTY IMPORTED_IMPLIB "${CMAKE_SOURCE_DIR}/vgui-dev/lib/win32_vc6/vgui.lib")
target_link_libraries(${CLDLL_LIBRARY} vgui)
target_link_libraries(${CLDLL_LIBRARY} ws2_32)
elseif(APPLE)
target_link_libraries(${CLDLL_LIBRARY} "-Wl,--no-undefined -L${CMAKE_SOURCE_DIR}/vgui-dev/lib vgui.dylib")
else()
target_link_libraries(${CLDLL_LIBRARY} :vgui.so)
endif()
endif()
if(WIN32)
target_link_libraries( ${CLDLL_LIBRARY} user32.lib )
if (GOLDSOURCE_SUPPORT)

@ -26,13 +26,17 @@
#include <string.h>
#include <stdio.h>
#if !USE_VGUI || USE_NOVGUI_MOTD
DECLARE_MESSAGE( m_MOTD, MOTD )
#endif
int CHudMOTD::Init( void )
{
gHUD.AddHudElem( this );
#if !USE_VGUI || USE_NOVGUI_MOTD
HOOK_MESSAGE( MOTD );
#endif
m_bShow = false;

@ -27,6 +27,9 @@
#include <stdio.h>
#include "ammohistory.h"
#if USE_VGUI
#include "vgui_TeamFortressViewport.h"
#endif
WEAPON *gpActiveSel; // NULL means off, 1 means just the menu bar, otherwise
// this points to the active weapon menu item
@ -673,10 +676,11 @@ int CHudAmmo::MsgFunc_WeaponList( const char *pszName, int iSize, void *pbuf )
// Slot button pressed
void CHudAmmo::SlotInput( int iSlot )
{
#if USE_VGUI
// Let the Viewport use it first, for menus
// if( gViewPort && gViewPort->SlotInput( iSlot ) )
// return;
if( gViewPort && gViewPort->SlotInput( iSlot ) )
return;
#endif
gWR.SelectSlot(iSlot, FALSE, 1);
}

@ -23,11 +23,18 @@
#include "netadr.h"
#include "parsemsg.h"
#if USE_VGUI
#include "vgui_int.h"
#include "vgui_TeamFortressViewport.h"
#endif
#if GOLDSOURCE_SUPPORT && (_WIN32 || __linux__ || __APPLE__) && (__i386 || _M_IX86)
#define USE_VGUI_FOR_GOLDSOURCE_SUPPORT 1
#define USE_FAKE_VGUI !USE_VGUI
#if USE_FAKE_VGUI
#include "VGUI_Panel.h"
#include "VGUI_App.h"
#endif
#endif
extern "C"
{
@ -38,6 +45,9 @@ extern "C"
cl_enginefunc_t gEngfuncs;
CHud gHUD;
#if USE_VGUI
TeamFortressViewport *gViewPort = NULL;
#endif
mobile_engfuncs_t *gMobileEngfuncs = NULL;
extern "C" int g_bhopcap;
@ -183,7 +193,7 @@ int *HUD_GetRect( void )
return extent;
}
#if USE_VGUI_FOR_GOLDSOURCE_SUPPORT
#if USE_FAKE_VGUI
class TeamFortressViewport : public vgui::Panel
{
public:
@ -238,7 +248,7 @@ so the HUD can reinitialize itself.
int DLLEXPORT HUD_VidInit( void )
{
gHUD.VidInit();
#if USE_VGUI_FOR_GOLDSOURCE_SUPPORT
#if USE_FAKE_VGUI
vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel();
if (root) {
gEngfuncs.Con_Printf( "Root VGUI panel exists\n" );
@ -256,6 +266,8 @@ int DLLEXPORT HUD_VidInit( void )
} else {
gEngfuncs.Con_Printf( "Root VGUI panel does not exist\n" );
}
#elif USE_VGUI
VGui_Startup();
#endif
return 1;
}
@ -274,6 +286,9 @@ void DLLEXPORT HUD_Init( void )
{
InitInput();
gHUD.Init();
#if USE_VGUI
Scheme_Init();
#endif
gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap );
}
@ -337,7 +352,9 @@ Called by engine every frame that client .dll is loaded
void DLLEXPORT HUD_Frame( double time )
{
#if USE_VGUI_FOR_GOLDSOURCE_SUPPORT
#if USE_VGUI
GetClientVoiceMgr()->Frame(time);
#elif USE_FAKE_VGUI
if (!gViewPort)
gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect());
#else
@ -355,7 +372,9 @@ Called when a player starts or stops talking.
void DLLEXPORT HUD_VoiceStatus( int entindex, qboolean bTalking )
{
#if USE_VGUI
GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking);
#endif
}
/*

@ -23,6 +23,10 @@
#include <string.h>
#include <stdio.h>
#if USE_VGUI
#include "vgui_TeamFortressViewport.h"
#endif
DECLARE_MESSAGE( m_DeathNotice, DeathMsg )
struct DeathNoticeItem {
@ -110,7 +114,9 @@ int CHudDeathNotice::Draw( float flTime )
// Only draw if the viewport will let me
// vgui dropped out
//if( gViewPort && gViewPort->AllowedToPrintText() )
#if USE_VGUI
if( gViewPort && gViewPort->AllowedToPrintText() )
#endif
{
// Draw the death notice
y = YRES( DEATHNOTICE_TOP ) + 2 + ( 20 * i ); //!!!
@ -168,6 +174,11 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu
strcpy( killedwith, "d_" );
strncat( killedwith, READ_STRING(), sizeof(killedwith) - strlen(killedwith) - 1 );
#if USE_VGUI
if (gViewPort)
gViewPort->DeathMsg( killer, victim );
#endif
gHUD.m_Spectator.DeathMessage( victim );
for( i = 0; i < MAX_DEATHNOTICES; i++ )
@ -182,9 +193,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu
i = MAX_DEATHNOTICES - 1;
}
//if(gViewPort)
// gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo();
gHUD.GetAllPlayersInfo();
// Get the Killer's name
const char *killer_name = "";

@ -7,6 +7,8 @@
// Client side entity management functions
#include <memory.h>
#include "hud.h"
#include "cl_util.h"
#include "const.h"
@ -526,6 +528,10 @@ void DLLEXPORT HUD_CreateEntities( void )
#endif
// Add in any game specific objects
Game_AddObjects();
#if USE_VGUI
GetClientVoiceMgr()->CreateEntities();
#endif
}
/*

@ -23,11 +23,72 @@
#include <string.h>
#include <stdio.h>
#include "parsemsg.h"
#include "hud_servers.h"
#if USE_VGUI
#include "vgui_int.h"
#include "vgui_TeamFortressViewport.h"
#endif
#include "demo.h"
#include "demo_api.h"
hud_player_info_t g_PlayerInfoList[MAX_PLAYERS+1]; // player info from the engine
extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS+1]; // additional player info sent directly to the client dll
team_info_t g_TeamInfo[MAX_TEAMS + 1];
int g_IsSpectator[MAX_PLAYERS+1];
int g_iPlayerClass;
int g_iTeamNumber;
int g_iUser1 = 0;
int g_iUser2 = 0;
int g_iUser3 = 0;
#if USE_VGUI
#include "vgui_ScorePanel.h"
class CHLVoiceStatusHelper : public IVoiceStatusHelper
{
public:
virtual void GetPlayerTextColor(int entindex, int color[3])
{
color[0] = color[1] = color[2] = 255;
if( entindex >= 0 && entindex < sizeof(g_PlayerExtraInfo)/sizeof(g_PlayerExtraInfo[0]) )
{
int iTeam = g_PlayerExtraInfo[entindex].teamnumber;
if ( iTeam < 0 )
{
iTeam = 0;
}
iTeam = iTeam % iNumberOfTeamColors;
color[0] = iTeamColors[iTeam][0];
color[1] = iTeamColors[iTeam][1];
color[2] = iTeamColors[iTeam][2];
}
}
virtual void UpdateCursorState()
{
gViewPort->UpdateCursorState();
}
virtual int GetAckIconHeight()
{
return ScreenHeight - gHUD.m_iFontHeight*3 - 6;
}
virtual bool CanShowSpeakerLabels()
{
if( gViewPort && gViewPort->m_pScoreBoard )
return !gViewPort->m_pScoreBoard->isVisible();
else
return false;
}
};
static CHLVoiceStatusHelper g_VoiceStatusHelper;
#endif
cvar_t *hud_textmode;
float g_hud_text_color[3];
@ -81,73 +142,182 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf )
// TFFree Command Menu
void __CmdFunc_OpenCommandMenu( void )
{
#if USE_VGUI
if ( gViewPort )
{
gViewPort->ShowCommandMenu( gViewPort->m_StandardMenu );
}
#endif
}
// TFC "special" command
void __CmdFunc_InputPlayerSpecial( void )
{
#if USE_VGUI
if ( gViewPort )
{
gViewPort->InputPlayerSpecial();
}
#endif
}
void __CmdFunc_CloseCommandMenu( void )
{
#if USE_VGUI
if ( gViewPort )
{
gViewPort->InputSignalHideCommandMenu();
}
#endif
}
void __CmdFunc_ForceCloseCommandMenu( void )
{
}
void __CmdFunc_ToggleServerBrowser( void )
{
#if USE_VGUI
if ( gViewPort )
{
gViewPort->HideCommandMenu();
}
#endif
}
// TFFree Command Menu Message Handlers
int __MsgFunc_ValClass( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_ValClass( pszName, iSize, pbuf );
#endif
return 0;
}
int __MsgFunc_TeamNames( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_TeamNames( pszName, iSize, pbuf );
#endif
return 0;
}
int __MsgFunc_Feign( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_Feign( pszName, iSize, pbuf );
#endif
return 0;
}
int __MsgFunc_Detpack( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_Detpack( pszName, iSize, pbuf );
#endif
return 0;
}
int __MsgFunc_VGUIMenu( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_VGUIMenu( pszName, iSize, pbuf );
#endif
return 0;
}
#if USE_VGUI && !USE_NOVGUI_MOTD
int __MsgFunc_MOTD(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return gViewPort->MsgFunc_MOTD( pszName, iSize, pbuf );
return 0;
}
#endif
int __MsgFunc_BuildSt( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_BuildSt( pszName, iSize, pbuf );
#endif
return 0;
}
int __MsgFunc_RandomPC( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_RandomPC( pszName, iSize, pbuf );
#endif
return 0;
}
int __MsgFunc_ServerName( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_ServerName( pszName, iSize, pbuf );
#endif
return 0;
}
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
int __MsgFunc_ScoreInfo(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return gViewPort->MsgFunc_ScoreInfo( pszName, iSize, pbuf );
return 0;
}
int __MsgFunc_TeamScore(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return gViewPort->MsgFunc_TeamScore( pszName, iSize, pbuf );
return 0;
}
int __MsgFunc_TeamInfo(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return gViewPort->MsgFunc_TeamInfo( pszName, iSize, pbuf );
return 0;
}
#endif
int __MsgFunc_Spectator( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_Spectator( pszName, iSize, pbuf );
#endif
return 0;
}
#if USE_VGUI
int __MsgFunc_SpecFade(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return gViewPort->MsgFunc_SpecFade( pszName, iSize, pbuf );
return 0;
}
int __MsgFunc_ResetFade(const char *pszName, int iSize, void *pbuf)
{
if (gViewPort)
return gViewPort->MsgFunc_ResetFade( pszName, iSize, pbuf );
return 0;
}
#endif
int __MsgFunc_AllowSpec( const char *pszName, int iSize, void *pbuf )
{
#if USE_VGUI
if (gViewPort)
return gViewPort->MsgFunc_AllowSpec( pszName, iSize, pbuf );
#endif
return 0;
}
@ -167,7 +337,6 @@ void CHud::Init( void )
HOOK_COMMAND( "-commandmenu", CloseCommandMenu );
HOOK_COMMAND( "ForceCloseCommandMenu", ForceCloseCommandMenu );
HOOK_COMMAND( "special", InputPlayerSpecial );
HOOK_COMMAND( "togglebrowser", ToggleServerBrowser );
HOOK_MESSAGE( ValClass );
HOOK_MESSAGE( TeamNames );
@ -177,9 +346,24 @@ void CHud::Init( void )
HOOK_MESSAGE( RandomPC );
HOOK_MESSAGE( ServerName );
#if USE_VGUI && !USE_NOVGUI_MOTD
HOOK_MESSAGE( MOTD );
#endif
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
HOOK_MESSAGE( ScoreInfo );
HOOK_MESSAGE( TeamScore );
HOOK_MESSAGE( TeamInfo );
#endif
HOOK_MESSAGE( Spectator );
HOOK_MESSAGE( AllowSpec );
#if USE_VGUI
HOOK_MESSAGE( SpecFade );
HOOK_MESSAGE( ResetFade );
#endif
// VGUI Menus
HOOK_MESSAGE( VGUIMenu );
@ -230,11 +414,19 @@ void CHud::Init( void )
m_AmmoSecondary.Init();
m_TextMessage.Init();
m_StatusIcons.Init();
#if USE_VGUI
GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort);
#endif
#if !USE_VGUI || USE_NOVGUI_MOTD
m_MOTD.Init();
#endif
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
m_Scoreboard.Init();
#endif
m_Menu.Init();
MsgFunc_ResetHUD( 0, 0, NULL );
}
@ -411,8 +603,15 @@ void CHud::VidInit( void )
m_AmmoSecondary.VidInit();
m_TextMessage.VidInit();
m_StatusIcons.VidInit();
m_Scoreboard.VidInit();
#if USE_VGUI
GetClientVoiceMgr()->VidInit();
#endif
#if !USE_VGUI || USE_NOVGUI_MOTD
m_MOTD.VidInit();
#endif
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
m_Scoreboard.VidInit();
#endif
}
int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf )
@ -588,3 +787,22 @@ float CHud::GetSensitivity( void )
{
return m_flMouseSensitivity;
}
void CHud::GetAllPlayersInfo()
{
for( int i = 1; i < MAX_PLAYERS; i++ )
{
GetPlayerInfo( i, &g_PlayerInfoList[i] );
if( g_PlayerInfoList[i].thisplayer )
{
#if USE_VGUI
if(gViewPort)
gViewPort->m_pScoreBoard->m_iPlayerNum = i;
#endif
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
m_Scoreboard.m_iPlayerNum = i; // !!!HACK: this should be initialized elsewhere... maybe gotten from the engine
#endif
}
}
}

@ -63,6 +63,9 @@ typedef struct cvar_s cvar_t;
#define MAX_MOTD_LENGTH 1536
#define MAX_SERVERNAME_LENGTH 64
#define MAX_TEAMNAME_SIZE 32
//
//-----------------------------------------------------
//
@ -89,6 +92,9 @@ struct HUDLIST
//
//-----------------------------------------------------
#if USE_VGUI
#include "voice_status.h" // base voice handling class
#endif
#include "hud_spectator.h"
//
@ -196,11 +202,7 @@ private:
int m_iPos;
};
//
//-----------------------------------------------------
//
// REMOVED: Vgui has replaced this.
//
#if !USE_VGUI || USE_NOVGUI_MOTD
class CHudMOTD : public CHudBase
{
public:
@ -222,7 +224,9 @@ protected:
int m_iLines;
int m_iMaxLength;
};
#endif
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
class CHudScoreboard : public CHudBase
{
public:
@ -249,6 +253,7 @@ public:
void GetAllPlayersInfo( void );
};
#endif
//
//-----------------------------------------------------
@ -283,41 +288,6 @@ protected:
float *m_pflNameColors[MAX_STATUSBAR_LINES];
};
//
//-----------------------------------------------------
//
// REMOVED: Vgui has replaced this.
//
/*
class CHudScoreboard : public CHudBase
{
public:
int Init( void );
void InitHUDData( void );
int VidInit( void );
int Draw( float flTime );
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
void UserCmd_ShowScores( void );
void UserCmd_HideScores( void );
int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf );
int MsgFunc_TeamInfo( const char *pszName, int iSize, void *pbuf );
int MsgFunc_TeamScore( const char *pszName, int iSize, void *pbuf );
void DeathMsg( int killer, int victim );
int m_iNumTeams;
int m_iLastKilledBy;
int m_fLastKillTime;
int m_iPlayerNum;
int m_iShowscoresHeld;
void GetAllPlayersInfo( void );
private:
struct cvar_s *cl_showpacketloss;
};
*/
struct extra_player_info_t
{
short frags;
@ -633,8 +603,12 @@ public:
CHudAmmoSecondary m_AmmoSecondary;
CHudTextMessage m_TextMessage;
CHudStatusIcons m_StatusIcons;
#if !USE_VGUI || USE_NOVGUI_SCOREBOARD
CHudScoreboard m_Scoreboard;
#endif
#if !USE_VGUI || USE_NOVGUI_MOTD
CHudMOTD m_MOTD;
#endif
void Init( void );
void VidInit( void );
@ -670,6 +644,8 @@ public:
void AddHudElem( CHudBase *p );
float GetSensitivity();
void GetAllPlayersInfo( void );
};
extern CHud gHUD;

@ -21,6 +21,10 @@
#include "cl_util.h"
//#include "triangleapi.h"
#if USE_VGUI
#include "vgui_TeamFortressViewport.h"
#endif
#define MAX_LOGO_FRAMES 56
int grgLogoFrame[MAX_LOGO_FRAMES] =
@ -39,6 +43,11 @@ extern cvar_t *sensitivity;
// Think
void CHud::Think( void )
{
#if USE_VGUI
m_scrinfo.iSize = sizeof(m_scrinfo);
GetScreenInfo(&m_scrinfo);
#endif
int newfov;
HUDLIST *pList = m_pHudList;
@ -94,13 +103,40 @@ int CHud::Redraw( float flTime, int intermission )
if( m_flTimeDelta < 0 )
m_flTimeDelta = 0;
#if USE_VGUI
// Bring up the scoreboard during intermission
if (gViewPort)
{
if( m_iIntermission && !intermission )
{
// Have to do this here so the scoreboard goes away
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideScoreBoard();
gViewPort->UpdateSpectatorPanel();
}
else if( !m_iIntermission && intermission )
{
m_iIntermission = intermission;
gViewPort->HideCommandMenu();
gViewPort->HideVGUIMenu();
#if !USE_NOVGUI_SCOREBOARD
gViewPort->ShowScoreBoard();
#endif
gViewPort->UpdateSpectatorPanel();
// Take a screenshot if the client's got the cvar set
if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0; // Take a screenshot in a second
}
}
#else
if( !m_iIntermission && intermission )
{
// Take a screenshot if the client's got the cvar set
if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
m_flShotTime = flTime + 1.0f; // Take a screenshot in a second
}
#endif
if( m_flShotTime && m_flShotTime < flTime )
{
gEngfuncs.pfnClientCmd( "snapshot\n" );

File diff suppressed because it is too large Load Diff

@ -1,40 +0,0 @@
//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================
#if !defined( HUD_SERVERSH )
#define HUD_SERVERSH
#pragma once
#define NET_CALLBACK /* */
// Dispatchers
void NET_CALLBACK ListResponse( struct net_response_s *response );
void NET_CALLBACK ServerResponse( struct net_response_s *response );
void NET_CALLBACK PingResponse( struct net_response_s *response );
void NET_CALLBACK RulesResponse( struct net_response_s *response );
void NET_CALLBACK PlayersResponse( struct net_response_s *response );
void ServersInit( void );
void ServersShutdown( void );
void ServersThink( double time );
void ServersCancel( void );
// Get list and get server info from each
void ServersList( void );
// Query for IP / IPX LAN servers
void BroadcastServersList( int clearpending );
void ServerPing( int server );
void ServerRules( int server );
void ServerPlayers( int server );
int ServersGetCount( void );
const char *ServersGetInfo( int server );
int ServersIsQuerying( void );
void SortServers( const char *fieldname );
#endif // HUD_SERVERSH

@ -9,6 +9,10 @@
#include "cl_util.h"
#include "cl_entity.h"
#include "triangleapi.h"
#if USE_VGUI
#include "vgui_TeamFortressViewport.h"
#include "vgui_SpectatorPanel.h"
#endif
#include "hltv.h"
#include "pm_shared.h"
@ -76,8 +80,16 @@ void SpectatorSpray( void )
gEngfuncs.pfnServerCmd( string );
}
}
void SpectatorHelp( void )
{
#if USE_VGUI
if( gViewPort )
{
gViewPort->ShowVGUIMenu( MENU_SPECHELP );
}
else
#endif
{
char *text = CHudTextMessage::BufferedLocaliseTextString( "#Spec_Help_Text" );
@ -100,10 +112,33 @@ void SpectatorMenu( void )
gEngfuncs.Con_Printf( "usage: spec_menu <0|1>\n" );
return;
}
#if USE_VGUI
gViewPort->m_pSpectatorPanel->ShowMenu( atoi( gEngfuncs.Cmd_Argv( 1 ) ) != 0 );
#endif
}
void ToggleScores( void )
{
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
if( gViewPort )
{
if( gViewPort->IsScoreBoardVisible() )
{
gViewPort->HideScoreBoard();
}
else
{
gViewPort->ShowScoreBoard();
}
}
#else
if (gHUD.m_Scoreboard.m_iShowscoresHeld) {
gHUD.m_Scoreboard.UserCmd_HideScores();
} else {
gHUD.m_Scoreboard.UserCmd_ShowScores();
}
#endif
}
//-----------------------------------------------------------------------------
@ -392,8 +427,7 @@ int CHudSpectator::Draw( float flTime )
return 1;
// make sure we have player info
//gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo();
gHUD.GetAllPlayersInfo();
// loop through all the players and draw additional infos to their sprites on the map
for( int i = 0; i < MAX_PLAYERS; i++ )
@ -529,9 +563,16 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
READ_LONG(); // total number of spectator slots
m_iSpectatorNumber = READ_LONG(); // total number of spectator
READ_WORD(); // total number of relay proxies
#if USE_VGUI
gViewPort->UpdateSpectatorPanel();
#endif
break;
case DRC_CMD_BANNER:
// gEngfuncs.Con_DPrintf( "GUI: Banner %s\n",READ_STRING() ); // name of banner tga eg gfx/temp/7454562234563475.tga
#if USE_VGUI
gViewPort->m_pSpectatorPanel->m_TopBanner->LoadImage( READ_STRING() );
gViewPort->UpdateSpectatorPanel();
#endif
break;
case DRC_CMD_FADE:
break;
@ -573,8 +614,7 @@ void CHudSpectator::FindNextPlayer( bool bReverse )
int iDir = bReverse ? -1 : 1;
// make sure we have player info
//gViewPort->GetAllPlayersInfo();
gHUD.m_Scoreboard.GetAllPlayersInfo();
gHUD.GetAllPlayersInfo();
do
{
@ -611,6 +651,68 @@ void CHudSpectator::FindNextPlayer( bool bReverse )
VectorCopy( pEnt->angles, vJumpAngles );
}
iJumpSpectator = 1;
#if USE_VGUI
gViewPort->MsgFunc_ResetFade( NULL, 0, NULL );
#endif
}
void CHudSpectator::FindPlayer(const char *name)
{
// MOD AUTHORS: Modify the logic of this function if you want to restrict the observer to watching
// only a subset of the players. e.g. Make it check the target's team.
// if we are NOT in HLTV mode, spectator targets are set on server
if ( !gEngfuncs.IsSpectateOnly() )
{
char cmdstring[32];
// forward command to server
sprintf(cmdstring,"follow %s",name);
gEngfuncs.pfnServerCmd(cmdstring);
return;
}
g_iUser2 = 0;
// make sure we have player info
gHUD.GetAllPlayersInfo();
cl_entity_t * pEnt = NULL;
for (int i = 1; i < MAX_PLAYERS; i++ )
{
pEnt = gEngfuncs.GetEntityByIndex( i );
if ( !IsActivePlayer( pEnt ) )
continue;
if(!stricmp(g_PlayerInfoList[pEnt->index].name,name))
{
g_iUser2 = i;
break;
}
}
// Did we find a target?
if ( !g_iUser2 )
{
gEngfuncs.Con_DPrintf( "No observer targets.\n" );
// take save camera position
VectorCopy(m_cameraOrigin, vJumpOrigin);
VectorCopy(m_cameraAngles, vJumpAngles);
}
else
{
// use new entity position for roaming
VectorCopy ( pEnt->origin, vJumpOrigin );
VectorCopy ( pEnt->angles, vJumpAngles );
}
iJumpSpectator = 1;
#if USE_VGUI
gViewPort->MsgFunc_ResetFade( NULL, 0, NULL );
#endif
}
void CHudSpectator::HandleButtonsDown( int ButtonPressed )
@ -622,6 +724,11 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
// gEngfuncs.Con_Printf( " HandleButtons:%i\n", ButtonPressed );
#if USE_VGUI
if( !gViewPort )
return;
#endif
//Not in intermission.
if( gHUD.m_iIntermission )
return;
@ -637,8 +744,10 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
return;
// enable spectator screen
//if( ButtonPressed & IN_DUCK )
// gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible );
#if USE_VGUI
if( ButtonPressed & IN_DUCK )
gViewPort->m_pSpectatorPanel->ShowMenu( !gViewPort->m_pSpectatorPanel->m_menuVisible );
#endif
// 'Use' changes inset window mode
if( ButtonPressed & IN_USE )
@ -705,6 +814,14 @@ void CHudSpectator::HandleButtonsDown( int ButtonPressed )
void CHudSpectator::HandleButtonsUp( int ButtonPressed )
{
#if USE_VGUI
if( !gViewPort )
return;
if( !gViewPort->m_pSpectatorPanel->isVisible() )
return; // dont do anything if not in spectator mode
#endif
if( ButtonPressed & ( IN_FORWARD | IN_BACK ) )
m_zoomDelta = 0.0f;
@ -800,12 +917,19 @@ void CHudSpectator::SetModes( int iNewMainMode, int iNewInsetMode )
SetCrosshair( 0, m_crosshairRect, 0, 0, 0 );
}
#if USE_VGUI
gViewPort->MsgFunc_ResetFade( NULL, 0, NULL );
#endif
char string[128];
sprintf( string, "#Spec_Mode%d", g_iUser1 );
sprintf( string, "%c%s", HUD_PRINTCENTER, CHudTextMessage::BufferedLocaliseTextString( string ) );
gHUD.m_TextMessage.MsgFunc_TextMsg( NULL, strlen( string ) + 1, string );
}
#if USE_VGUI
gViewPort->UpdateSpectatorPanel();
#endif
}
bool CHudSpectator::IsActivePlayer( cl_entity_t *ent )
@ -1454,6 +1578,9 @@ void CHudSpectator::CheckSettings()
m_pip->value = INSET_OFF;
// draw small border around inset view, adjust upper black bar
#if USE_VGUI
gViewPort->m_pSpectatorPanel->EnableInsetView( m_pip->value != INSET_OFF );
#endif
}
int CHudSpectator::ToggleInset( bool allowOff )

@ -73,6 +73,7 @@ public:
void HandleButtonsDown( int ButtonPressed );
void HandleButtonsUp( int ButtonPressed );
void FindNextPlayer( bool bReverse );
void FindPlayer(const char *name);
void DirectorMessage( int iSize, void *pbuf );
void SetSpectatorStartPosition();
int Init();

@ -15,6 +15,22 @@
#include "camera.h"
#include "in_defs.h"
#if _WIN32
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define WIN32_EXTRA_LEAN
#define HSPRITE WINDOWS_HSPRITE
#include <windows.h>
#undef HSPRITE
#else
typedef struct point_s
{
int x;
int y;
} POINT;
#define GetCursorPos(x)
#define SetCursorPos(x,y)
#endif
float CL_KeyState( kbutton_t *key );
extern "C"

@ -16,17 +16,4 @@
// fall over
#define ROLL 2
#if _WIN32
#define HSPRITE HSPRITE_win32
#include <windows.h>
#undef HSPRITE
#else
typedef struct point_s
{
int x;
int y;
} POINT;
#define GetCursorPos(x)
#define SetCursorPos(x,y)
#endif
#endif

@ -28,6 +28,10 @@ extern "C"
#include <string.h>
#include <ctype.h>
#if USE_VGUI
#include "vgui_TeamFortressViewport.h"
#endif
extern "C"
{
struct kbutton_s DLLEXPORT *KB_Find( const char *name );
@ -645,13 +649,27 @@ void IN_Impulse( void )
void IN_ScoreDown( void )
{
KeyDown( &in_score );
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
if ( gViewPort )
{
gViewPort->ShowScoreBoard();
}
#else
gHUD.m_Scoreboard.UserCmd_ShowScores();
#endif
}
void IN_ScoreUp( void )
{
KeyUp( &in_score );
#if USE_VGUI && !USE_NOVGUI_SCOREBOARD
if ( gViewPort )
{
gViewPort->HideScoreBoard();
}
#else
gHUD.m_Scoreboard.UserCmd_HideScores();
#endif
}
void IN_MLookUp( void )
@ -849,6 +867,12 @@ void DLLEXPORT CL_CreateMove( float frametime, struct usercmd_s *cmd, int active
//
cmd->buttons = CL_ButtonBits( 1 );
#if USE_VGUI
// If they're in a modal dialog, ignore the attack button.
if(GetClientVoiceMgr()->IsInSquelchMode())
cmd->buttons &= ~IN_ATTACK;
#endif
// Using joystick?
if( in_joystick->value )
{
@ -903,9 +927,11 @@ int CL_ButtonBits( int bResetState )
if( in_attack.state & 3 )
{
#if !USE_VGUI || USE_NOVGUI_MOTD
if( gHUD.m_MOTD.m_bShow )
gHUD.m_MOTD.Reset();
else
#endif
bits |= IN_ATTACK;
}

@ -47,6 +47,21 @@ protected:
// No need for goldsource input support on the platforms that are not supported by GoldSource.
#if GOLDSOURCE_SUPPORT && (_WIN32 || __linux__ || __APPLE__) && (__i386 || _M_IX86)
#define SUPPORT_GOLDSOURCE_INPUT 1
#if _WIN32
#define HSPRITE WINDOWS_HSPRITE
#include <windows.h>
#undef HSPRITE
#else
typedef struct point_s
{
int x;
int y;
} POINT;
#define GetCursorPos(x)
#define SetCursorPos(x,y)
#endif
class GoldSourceInput : public AbstractInput
{
public:

@ -187,9 +187,11 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd )
viewangles[YAW] -= ac_sidemove * 5;
ac_sidemove = 0;
}
#if !USE_VGUI || USE_NOVGUI_MOTD
if( gHUD.m_MOTD.m_bShow )
gHUD.m_MOTD.scroll += rel_pitch;
else
#endif
viewangles[PITCH] += rel_pitch;
if( viewangles[PITCH] > cl_pitchdown->value )

@ -24,6 +24,10 @@
#include <string.h>
#include <stdio.h>
#if USE_VGUI