Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for VGUI2 #447

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "vgui_support"]
path = vgui_support
url = https://github.com/FWGS/vgui_support
[submodule "hl1_source_sdk"]
path = hl1_source_sdk
url = https://github.com/tmp64/hl1_source_sdk
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# SOFTWARE.
#

set (CMAKE_CXX_STANDARD 17)

# 3.9 added captures in if(MATCHES)
cmake_minimum_required(VERSION 3.9)

Expand All @@ -41,6 +43,7 @@ project (HLSDK-PORTABLE)
# USER DEFINES \
################\
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)
Expand Down Expand Up @@ -120,7 +123,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT)
error("UNDONE: set 32 build flags")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32 -msse3")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
endif()
set(CMAKE_SIZEOF_VOID_P 4)
Expand Down Expand Up @@ -152,6 +155,19 @@ else()
add_definitions(-D_CRT_SILENCE_NONCONFORMING_TGMATH_H)
endif()

if(USE_VGUI2)
add_definitions(-DUSE_VGUI2)
if(NOT MSVC)
add_compile_options(-msse3)
endif()

if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

add_subdirectory(source_sdk)
endif()

if(VITA)
add_compile_options(-fno-use-cxa-atexit)
endif()
Expand Down
17 changes: 17 additions & 0 deletions cl_dll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ if (USE_VGUI)
endif()
endif()

if (USE_VGUI2)
add_definitions(-DUSE_VGUI2)
add_compile_definitions(${SOURCE_SDK_DEFINES})
endif()

set (CLDLL_SOURCES
../dlls/crossbow.cpp
../dlls/crowbar.cpp
Expand Down Expand Up @@ -160,6 +165,10 @@ else()
scoreboard.cpp)
endif()

if (USE_VGUI2)
list(APPEND CLDLL_SOURCES vgui2/CClientVGUI.cpp vgui2/vgui2_utils.cpp)
endif()

include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public)

if (USE_VGUI)
Expand All @@ -170,6 +179,10 @@ else()
include_directories(../utils/fake_vgui/include)
endif()

if (USE_VGUI2)
include_directories(${SOURCE_SDK_INCLUDE_PATHS})
endif()

if(USE_VOICEMGR)
#set(CLDLL_SOURCES
# ${CLDLL_SOURCES}
Expand All @@ -196,6 +209,10 @@ if (USE_VGUI)
endif()
endif()

if (USE_VGUI2)
target_link_libraries(${CLDLL_LIBRARY} ${SOURCE_SDK_LIBS})
endif()

if(WIN32)
target_link_libraries( ${CLDLL_LIBRARY} user32.lib )
if (GOLDSOURCE_SUPPORT)
Expand Down
117 changes: 117 additions & 0 deletions cl_dll/Exports.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// CL_DLLEXPORT is the client version of dllexport. It's turned off for secure clients.
#ifdef _WIN32
#define CL_DLLEXPORT __declspec(dllexport)
#else
#define CL_DLLEXPORT __attribute__ ((visibility("default")))
#endif

extern "C"
{
// From hl_weapons
void CL_DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed );

// From cdll_int
int CL_DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion );
int CL_DLLEXPORT HUD_VidInit( void );
void CL_DLLEXPORT HUD_Init( void );
int CL_DLLEXPORT HUD_Redraw( float flTime, int intermission );
int CL_DLLEXPORT HUD_UpdateClientData( client_data_t *cdata, float flTime );
void CL_DLLEXPORT HUD_Reset ( void );
void CL_DLLEXPORT HUD_PlayerMove( struct playermove_s *ppmove, int server );
void CL_DLLEXPORT HUD_PlayerMoveInit( struct playermove_s *ppmove );
char CL_DLLEXPORT HUD_PlayerMoveTexture( char *name );
int CL_DLLEXPORT HUD_ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size );
int CL_DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs );
void CL_DLLEXPORT HUD_Frame( double time );
void CL_DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking);
void CL_DLLEXPORT HUD_DirectorMessage( int iSize, void *pbuf );
void CL_DLLEXPORT HUD_ChatInputPosition( int *x, int *y );

// From demo
void CL_DLLEXPORT Demo_ReadBuffer( int size, unsigned char *buffer );

// From entity
int CL_DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *modelname );
void CL_DLLEXPORT HUD_CreateEntities( void );
void CL_DLLEXPORT HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity );
void CL_DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const struct clientdata_s *client );
void CL_DLLEXPORT HUD_ProcessPlayerState( struct entity_state_s *dst, const struct entity_state_s *src );
void CL_DLLEXPORT HUD_TxferPredictionData ( struct entity_state_s *ps, const struct entity_state_s *pps, struct clientdata_s *pcd, const struct clientdata_s *ppcd, struct weapon_data_s *wd, const struct weapon_data_s *pwd );
void CL_DLLEXPORT HUD_TempEntUpdate( double frametime, double client_time, double cl_gravity, struct tempent_s **ppTempEntFree, struct tempent_s **ppTempEntActive, int ( *Callback_AddVisibleEntity )( struct cl_entity_s *pEntity ), void ( *Callback_TempEntPlaySound )( struct tempent_s *pTemp, float damp ) );
struct cl_entity_s CL_DLLEXPORT *HUD_GetUserEntity( int index );

// From in_camera
void CL_DLLEXPORT CAM_Think( void );
int CL_DLLEXPORT CL_IsThirdPerson( void );
void CL_DLLEXPORT CL_CameraOffset( float *ofs );

// From input
struct kbutton_s CL_DLLEXPORT *KB_Find( const char *name );
void CL_DLLEXPORT CL_CreateMove ( float frametime, struct usercmd_s *cmd, int active );
void CL_DLLEXPORT HUD_Shutdown( void );
int CL_DLLEXPORT HUD_Key_Event( int eventcode, int keynum, const char *pszCurrentBinding );

// From inputw32
void CL_DLLEXPORT IN_ActivateMouse( void );
void CL_DLLEXPORT IN_DeactivateMouse( void );
void CL_DLLEXPORT IN_MouseEvent (int mstate);
void CL_DLLEXPORT IN_Accumulate (void);
void CL_DLLEXPORT IN_ClearStates (void);

// From tri
void CL_DLLEXPORT HUD_DrawNormalTriangles( void );
void CL_DLLEXPORT HUD_DrawTransparentTriangles( void );

// From view
void CL_DLLEXPORT V_CalcRefdef( struct ref_params_s *pparams );

// From GameStudioModelRenderer
int CL_DLLEXPORT HUD_GetStudioModelInterface( int version, struct r_studio_interface_s **ppinterface, struct engine_studio_api_s *pstudio );
}

/*
extern cldll_func_dst_t *g_pcldstAddrs;

// Macros for the client receiving calls from the engine
#define RecClInitialize(a, b) (g_pcldstAddrs->pInitFunc(&a, &b))
#define RecClHudInit() (g_pcldstAddrs->pHudInitFunc())
#define RecClHudVidInit() (g_pcldstAddrs->pHudVidInitFunc())
#define RecClHudRedraw(a, b) (g_pcldstAddrs->pHudRedrawFunc(&a, &b))
#define RecClHudUpdateClientData(a, b) (g_pcldstAddrs->pHudUpdateClientDataFunc(&a, &b))
#define RecClHudReset() (g_pcldstAddrs->pHudResetFunc())
#define RecClClientMove(a, b) (g_pcldstAddrs->pClientMove(&a, &b))
#define RecClClientMoveInit(a) (g_pcldstAddrs->pClientMoveInit(&a))
#define RecClClientTextureType(a) (g_pcldstAddrs->pClientTextureType(&a))
#define RecClIN_ActivateMouse() (g_pcldstAddrs->pIN_ActivateMouse())
#define RecClIN_DeactivateMouse() (g_pcldstAddrs->pIN_DeactivateMouse())
#define RecClIN_MouseEvent(a) (g_pcldstAddrs->pIN_MouseEvent(&a))
#define RecClIN_ClearStates() (g_pcldstAddrs->pIN_ClearStates())
#define RecClIN_Accumulate() (g_pcldstAddrs->pIN_Accumulate())
#define RecClCL_CreateMove(a, b, c) (g_pcldstAddrs->pCL_CreateMove(&a, &b, &c))
#define RecClCL_IsThirdPerson() (g_pcldstAddrs->pCL_IsThirdPerson())
#define RecClCL_GetCameraOffsets(a) (g_pcldstAddrs->pCL_GetCameraOffsets(&a))
#define RecClFindKey(a) (g_pcldstAddrs->pFindKey(&a))
#define RecClCamThink() (g_pcldstAddrs->pCamThink())
#define RecClCalcRefdef(a) (g_pcldstAddrs->pCalcRefdef(&a))
#define RecClAddEntity(a, b, c) (g_pcldstAddrs->pAddEntity(&a, &b, &c))
#define RecClCreateEntities() (g_pcldstAddrs->pCreateEntities())
#define RecClDrawNormalTriangles() (g_pcldstAddrs->pDrawNormalTriangles())
#define RecClDrawTransparentTriangles() (g_pcldstAddrs->pDrawTransparentTriangles())
#define RecClStudioEvent(a, b) (g_pcldstAddrs->pStudioEvent(&a, &b))
#define RecClPostRunCmd(a, b, c, d, e, f) (g_pcldstAddrs->pPostRunCmd(&a, &b, &c, &d, &e, &f))
#define RecClShutdown() (g_pcldstAddrs->pShutdown())
#define RecClTxferLocalOverrides(a, b) (g_pcldstAddrs->pTxferLocalOverrides(&a, &b))
#define RecClProcessPlayerState(a, b) (g_pcldstAddrs->pProcessPlayerState(&a, &b))
#define RecClTxferPredictionData(a, b, c, d, e, f) (g_pcldstAddrs->pTxferPredictionData(&a, &b, &c, &d, &e, &f))
#define RecClReadDemoBuffer(a, b) (g_pcldstAddrs->pReadDemoBuffer(&a, &b))
#define RecClConnectionlessPacket(a, b, c, d) (g_pcldstAddrs->pConnectionlessPacket(&a, &b, &c, &d))
#define RecClGetHullBounds(a, b, c) (g_pcldstAddrs->pGetHullBounds(&a, &b, &c))
#define RecClHudFrame(a) (g_pcldstAddrs->pHudFrame(&a))
#define RecClKeyEvent(a, b, c) (g_pcldstAddrs->pKeyEvent(&a, &b, &c))
#define RecClTempEntUpdate(a, b, c, d, e, f, g) (g_pcldstAddrs->pTempEntUpdate(&a, &b, &c, &d, &e, &f, &g))
#define RecClGetUserEntity(a) (g_pcldstAddrs->pGetUserEntity(&a))
#define RecClVoiceStatus(a, b) (g_pcldstAddrs->pVoiceStatus(&a, &b))
#define RecClDirectorMessage(a, b) (g_pcldstAddrs->pDirectorMessage(&a, &b))
#define RecClStudioInterface(a, b, c) (g_pcldstAddrs->pStudioInterface(&a, &b, &c))
#define RecClChatInputPosition(a, b) (g_pcldstAddrs->pChatInputPosition(&a, &b))
*/
74 changes: 74 additions & 0 deletions cl_dll/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "netadr.h"
#include "parsemsg.h"

#include "Exports.h"

#if USE_VGUI
#include "vgui_int.h"
#include "vgui_TeamFortressViewport.h"
Expand All @@ -36,6 +38,10 @@
#endif
#endif

#if USE_VGUI2
#include "vgui2/vgui2_utils.h"
#endif

extern "C"
{
#include "pm_shared.h"
Expand Down Expand Up @@ -289,6 +295,9 @@ void DLLEXPORT HUD_Init( void )
#if USE_VGUI
Scheme_Init();
#endif
#if USE_VGUI2
VGUI2_Init();
#endif
}

/*
Expand Down Expand Up @@ -410,6 +419,71 @@ bool HUD_MessageBox( const char *msg )
return false;
}

#if USE_VGUI2
extern "C" DLLEXPORT void *ClientFactory() {
return NULL;
}

extern "C" void DLLEXPORT F(void *data) {
cldll_func_t *exports = reinterpret_cast<cldll_func_t *>(data);

cldll_func_t functions = {
Initialize,
HUD_Init,
HUD_VidInit,
HUD_Redraw,
HUD_UpdateClientData,
HUD_Reset,
HUD_PlayerMove,
HUD_PlayerMoveInit,
HUD_PlayerMoveTexture,
IN_ActivateMouse,
IN_DeactivateMouse,
IN_MouseEvent,
IN_ClearStates,
IN_Accumulate,
CL_CreateMove,
CL_IsThirdPerson,
CL_CameraOffset,
KB_Find,
CAM_Think,
V_CalcRefdef,
HUD_AddEntity,
HUD_CreateEntities,
HUD_DrawNormalTriangles,
HUD_DrawTransparentTriangles,
HUD_StudioEvent,
HUD_PostRunCmd,
HUD_Shutdown,
HUD_TxferLocalOverrides,
HUD_ProcessPlayerState,
HUD_TxferPredictionData,
Demo_ReadBuffer,
HUD_ConnectionlessPacket,
HUD_GetHullBounds,
HUD_Frame,
HUD_Key_Event,
HUD_TempEntUpdate,
HUD_GetUserEntity,
HUD_VoiceStatus,
HUD_DirectorMessage,
HUD_GetStudioModelInterface,
#if USE_VGUI
HUD_ChatInputPosition,
#else
NULL,
#endif
NULL,
ClientFactory,
#if !GOLDSOURCE_SUPPORT
// TODO: How many Xash3D-specific exports are there?
#endif
};

*exports = functions;
}
#endif

bool IsXashFWGS()
{
return gMobileEngfuncs != NULL;
Expand Down
10 changes: 9 additions & 1 deletion cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "exportdef.h"
#include "cvardef.h"

#if USE_VGUI2
#include "vgui2/vgui2_utils.h"
#endif

#if !defined(TRUE)
#define TRUE 1
#define FALSE 0
Expand Down Expand Up @@ -102,7 +106,11 @@ inline client_textmessage_t *TextMessageGet( const char *pName )

inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b )
{
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
#if USE_VGUI2
return VGUI2_DrawCharacter(x, y, number, r, g, b);
#else
return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b );
#endif
}

inline int DrawConsoleString( int x, int y, const char *string )
Expand Down
11 changes: 10 additions & 1 deletion cl_dll/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ void CHudMessage::MessageScanNextChar( void )

if( m_parms.pMessage->effect == 1 && m_parms.charTime != 0 )
{
if( m_parms.x >= 0 && m_parms.y >= 0 && ( m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text] ) <= ScreenWidth )
#if USE_VGUI2
const int width = VGUI2_GetCharacterWidth(m_parms.text);
#else
const int width = gHUD.m_scrinfo.charWidths[m_parms.text];
#endif
if( m_parms.x >= 0 && m_parms.y >= 0 && ( m_parms.x + width ) <= ScreenWidth )
TextMessageDrawChar( m_parms.x, m_parms.y, m_parms.text, m_parms.pMessage->r2, m_parms.pMessage->g2, m_parms.pMessage->b2 );
}
}
Expand Down Expand Up @@ -295,7 +300,11 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time )
for( j = 0; j < m_parms.lineLength; j++ )
{
m_parms.text = (unsigned char)pLineStart[j];
#if USE_VGUI2
int next = m_parms.x + VGUI2_GetCharacterWidth(m_parms.text);
#else
int next = m_parms.x + gHUD.m_scrinfo.charWidths[m_parms.text];
#endif
MessageScanNextChar();

if( m_parms.x >= 0 && m_parms.y >= 0 && next <= ScreenWidth )
Expand Down
Loading
Loading