Skip to content
Draft
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
2 changes: 2 additions & 0 deletions src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ set(VGUI
"ui/vgui_teamfortressviewport.cpp"
"ui/vgui_teamfortressviewport.h"
"ui/vgui_voice_tweakdlg.cpp"
"vgui2/CClientVGUI.cpp"
"vgui2/CClientVGUI.h"
)
source_group("VGUI" FILES ${VGUI})

Expand Down
65 changes: 65 additions & 0 deletions src/game/client/cdll_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "logger.h"
#include "clientlibrary.h"
#include "movement/pm_shared.h"
#include "exports.h"
#ifdef _WIN32
#include <windows.h>
#endif
Expand Down Expand Up @@ -429,3 +430,67 @@ void DLLEXPORT HUD_ChatInputPosition(int* x, int* y)
// g_pParticleMan->SetUp(&gEngfuncs);
// }
// }

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

cldll_func_dst_t* g_pcldstAddrs;

extern "C" void CL_DLLEXPORT F(void* pv)
{
cldll_func_t* pcldll_func = (cldll_func_t*)pv;

// Hack!
g_pcldstAddrs = ((cldll_func_dst_t*)pcldll_func->pHudVidInitFunc);

cldll_func_t cldll_func =
{
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,
HUD_ChatInputPosition,
HUD_GetPlayerTeam,
ClientFactory,
};

*pcldll_func = cldll_func;
}
193 changes: 192 additions & 1 deletion src/game/client/exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,195 @@ extern cldll_func_dst_t *g_pcldstAddrs;
#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))
*/
*/

// Function type declarations for client destination functions
typedef void (*DST_INITIALIZE_FUNC) (struct cl_enginefuncs_s**, int*);
typedef void (*DST_HUD_INIT_FUNC) (void);
typedef void (*DST_HUD_VIDINIT_FUNC) (void);
typedef void (*DST_HUD_REDRAW_FUNC) (float*, int*);
typedef void (*DST_HUD_UPDATECLIENTDATA_FUNC) (struct client_data_s**, float*);
typedef void (*DST_HUD_RESET_FUNC) (void);
typedef void (*DST_HUD_CLIENTMOVE_FUNC)(struct playermove_s**, qboolean*);
typedef void (*DST_HUD_CLIENTMOVEINIT_FUNC)(struct playermove_s**);
typedef void (*DST_HUD_TEXTURETYPE_FUNC)(char**);
typedef void (*DST_HUD_IN_ACTIVATEMOUSE_FUNC) (void);
typedef void (*DST_HUD_IN_DEACTIVATEMOUSE_FUNC) (void);
typedef void (*DST_HUD_IN_MOUSEEVENT_FUNC) (int*);
typedef void (*DST_HUD_IN_CLEARSTATES_FUNC) (void);
typedef void (*DST_HUD_IN_ACCUMULATE_FUNC) (void);
typedef void (*DST_HUD_CL_CREATEMOVE_FUNC) (float*, struct usercmd_s**, int*);
typedef void (*DST_HUD_CL_ISTHIRDPERSON_FUNC) (void);
typedef void (*DST_HUD_CL_GETCAMERAOFFSETS_FUNC)(float**);
typedef void (*DST_HUD_KB_FIND_FUNC) (const char**);
typedef void (*DST_HUD_CAMTHINK_FUNC)(void);
typedef void (*DST_HUD_CALCREF_FUNC) (struct ref_params_s**);
typedef void (*DST_HUD_ADDENTITY_FUNC) (int*, struct cl_entity_s**, const char**);
typedef void (*DST_HUD_CREATEENTITIES_FUNC) (void);
typedef void (*DST_HUD_DRAWNORMALTRIS_FUNC) (void);
typedef void (*DST_HUD_DRAWTRANSTRIS_FUNC) (void);
typedef void (*DST_HUD_STUDIOEVENT_FUNC) (const struct mstudioevent_s**, const struct cl_entity_s**);
typedef void (*DST_HUD_POSTRUNCMD_FUNC) (struct local_state_s**, struct local_state_s**, struct usercmd_s**, int*, double*, unsigned int*);
typedef void (*DST_HUD_SHUTDOWN_FUNC) (void);
typedef void (*DST_HUD_TXFERLOCALOVERRIDES_FUNC)(struct entity_state_s**, const struct clientdata_s**);
typedef void (*DST_HUD_PROCESSPLAYERSTATE_FUNC)(struct entity_state_s**, const struct entity_state_s**);
typedef void (*DST_HUD_TXFERPREDICTIONDATA_FUNC) (struct entity_state_s**, const struct entity_state_s**, struct clientdata_s**, const struct clientdata_s**, struct weapon_data_s**, const struct weapon_data_s**);
typedef void (*DST_HUD_DEMOREAD_FUNC) (int*, unsigned char**);
typedef void (*DST_HUD_CONNECTIONLESS_FUNC)(const struct netadr_s**, const char**, char**, int**);
typedef void (*DST_HUD_GETHULLBOUNDS_FUNC) (int*, float**, float**);
typedef void (*DST_HUD_FRAME_FUNC) (double*);
typedef void (*DST_HUD_KEY_EVENT_FUNC) (int*, int*, const char**);
typedef void (*DST_HUD_TEMPENTUPDATE_FUNC) (double*, double*, double*, struct tempent_s***, struct tempent_s***, int (**Callback_AddVisibleEntity)(struct cl_entity_s* pEntity), void (**Callback_TempEntPlaySound)(struct tempent_s* pTemp, float damp));
typedef void (*DST_HUD_GETUSERENTITY_FUNC) (int*);
typedef void (*DST_HUD_VOICESTATUS_FUNC)(int*, qboolean*);
typedef void (*DST_HUD_DIRECTORMESSAGE_FUNC)(int*, void**);
typedef void (*DST_HUD_STUDIO_INTERFACE_FUNC) (int*, struct r_studio_interface_s***, struct engine_studio_api_s**);
typedef void (*DST_HUD_CHATINPUTPOSITION_FUNC)(int**, int**);
typedef void (*DST_HUD_GETPLAYERTEAM)(int);

// Pointers to the client destination functions
typedef struct
{
DST_INITIALIZE_FUNC pInitFunc;
DST_HUD_INIT_FUNC pHudInitFunc;
DST_HUD_VIDINIT_FUNC pHudVidInitFunc;
DST_HUD_REDRAW_FUNC pHudRedrawFunc;
DST_HUD_UPDATECLIENTDATA_FUNC pHudUpdateClientDataFunc;
DST_HUD_RESET_FUNC pHudResetFunc;
DST_HUD_CLIENTMOVE_FUNC pClientMove;
DST_HUD_CLIENTMOVEINIT_FUNC pClientMoveInit;
DST_HUD_TEXTURETYPE_FUNC pClientTextureType;
DST_HUD_IN_ACTIVATEMOUSE_FUNC pIN_ActivateMouse;
DST_HUD_IN_DEACTIVATEMOUSE_FUNC pIN_DeactivateMouse;
DST_HUD_IN_MOUSEEVENT_FUNC pIN_MouseEvent;
DST_HUD_IN_CLEARSTATES_FUNC pIN_ClearStates;
DST_HUD_IN_ACCUMULATE_FUNC pIN_Accumulate;
DST_HUD_CL_CREATEMOVE_FUNC pCL_CreateMove;
DST_HUD_CL_ISTHIRDPERSON_FUNC pCL_IsThirdPerson;
DST_HUD_CL_GETCAMERAOFFSETS_FUNC pCL_GetCameraOffsets;
DST_HUD_KB_FIND_FUNC pFindKey;
DST_HUD_CAMTHINK_FUNC pCamThink;
DST_HUD_CALCREF_FUNC pCalcRefdef;
DST_HUD_ADDENTITY_FUNC pAddEntity;
DST_HUD_CREATEENTITIES_FUNC pCreateEntities;
DST_HUD_DRAWNORMALTRIS_FUNC pDrawNormalTriangles;
DST_HUD_DRAWTRANSTRIS_FUNC pDrawTransparentTriangles;
DST_HUD_STUDIOEVENT_FUNC pStudioEvent;
DST_HUD_POSTRUNCMD_FUNC pPostRunCmd;
DST_HUD_SHUTDOWN_FUNC pShutdown;
DST_HUD_TXFERLOCALOVERRIDES_FUNC pTxferLocalOverrides;
DST_HUD_PROCESSPLAYERSTATE_FUNC pProcessPlayerState;
DST_HUD_TXFERPREDICTIONDATA_FUNC pTxferPredictionData;
DST_HUD_DEMOREAD_FUNC pReadDemoBuffer;
DST_HUD_CONNECTIONLESS_FUNC pConnectionlessPacket;
DST_HUD_GETHULLBOUNDS_FUNC pGetHullBounds;
DST_HUD_FRAME_FUNC pHudFrame;
DST_HUD_KEY_EVENT_FUNC pKeyEvent;
DST_HUD_TEMPENTUPDATE_FUNC pTempEntUpdate;
DST_HUD_GETUSERENTITY_FUNC pGetUserEntity;
DST_HUD_VOICESTATUS_FUNC pVoiceStatus; // Possibly null on old client dlls.
DST_HUD_DIRECTORMESSAGE_FUNC pDirectorMessage; // Possibly null on old client dlls.
DST_HUD_STUDIO_INTERFACE_FUNC pStudioInterface; // Not used by all clients
DST_HUD_CHATINPUTPOSITION_FUNC pChatInputPosition; // Not used by all clients
DST_HUD_GETPLAYERTEAM pGetPlayerTeam; // Not used by all clients
} cldll_func_dst_t;

// ********************************************************
// Functions exported by the client .dll
// ********************************************************

// Function type declarations for client exports
typedef int (*INITIALIZE_FUNC) (struct cl_enginefuncs_s*, int);
typedef void (*HUD_INIT_FUNC) (void);
typedef int (*HUD_VIDINIT_FUNC) (void);
typedef int (*HUD_REDRAW_FUNC) (float, int);
typedef int (*HUD_UPDATECLIENTDATA_FUNC) (struct client_data_s*, float);
typedef void (*HUD_RESET_FUNC) (void);
typedef void (*HUD_CLIENTMOVE_FUNC)(struct playermove_s* ppmove, qboolean server);
typedef void (*HUD_CLIENTMOVEINIT_FUNC)(struct playermove_s* ppmove);
typedef char (*HUD_TEXTURETYPE_FUNC)(char* name);
typedef void (*HUD_IN_ACTIVATEMOUSE_FUNC) (void);
typedef void (*HUD_IN_DEACTIVATEMOUSE_FUNC) (void);
typedef void (*HUD_IN_MOUSEEVENT_FUNC) (int mstate);
typedef void (*HUD_IN_CLEARSTATES_FUNC) (void);
typedef void (*HUD_IN_ACCUMULATE_FUNC) (void);
typedef void (*HUD_CL_CREATEMOVE_FUNC) (float frametime, struct usercmd_s* cmd, int active);
typedef int (*HUD_CL_ISTHIRDPERSON_FUNC) (void);
typedef void (*HUD_CL_GETCAMERAOFFSETS_FUNC)(float* ofs);
typedef struct kbutton_s* (*HUD_KB_FIND_FUNC) (const char* name);
typedef void (*HUD_CAMTHINK_FUNC)(void);
typedef void (*HUD_CALCREF_FUNC) (struct ref_params_s* pparams);
typedef int (*HUD_ADDENTITY_FUNC) (int type, struct cl_entity_s* ent, const char* modelname);
typedef void (*HUD_CREATEENTITIES_FUNC) (void);
typedef void (*HUD_DRAWNORMALTRIS_FUNC) (void);
typedef void (*HUD_DRAWTRANSTRIS_FUNC) (void);
typedef void (*HUD_STUDIOEVENT_FUNC) (const struct mstudioevent_s* event, const struct cl_entity_s* entity);
typedef void (*HUD_POSTRUNCMD_FUNC) (struct local_state_s* from, struct local_state_s* to, struct usercmd_s* cmd, int runfuncs, double time, unsigned int random_seed);
typedef void (*HUD_SHUTDOWN_FUNC) (void);
typedef void (*HUD_TXFERLOCALOVERRIDES_FUNC)(struct entity_state_s* state, const struct clientdata_s* client);
typedef void (*HUD_PROCESSPLAYERSTATE_FUNC)(struct entity_state_s* dst, const struct entity_state_s* src);
typedef void (*HUD_TXFERPREDICTIONDATA_FUNC) (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);
typedef void (*HUD_DEMOREAD_FUNC) (int size, unsigned char* buffer);
typedef int (*HUD_CONNECTIONLESS_FUNC)(const struct netadr_s* net_from, const char* args, char* response_buffer, int* response_buffer_size);
typedef int (*HUD_GETHULLBOUNDS_FUNC) (int hullnumber, float* mins, float* maxs);
typedef void (*HUD_FRAME_FUNC) (double);
typedef int (*HUD_KEY_EVENT_FUNC) (int eventcode, int keynum, const char* pszCurrentBinding);
typedef void (*HUD_TEMPENTUPDATE_FUNC) (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));
typedef struct cl_entity_s* (*HUD_GETUSERENTITY_FUNC) (int index);
typedef void (*HUD_VOICESTATUS_FUNC)(int entindex, qboolean bTalking);
typedef void (*HUD_DIRECTORMESSAGE_FUNC)(int iSize, void* pbuf);
typedef int (*HUD_STUDIO_INTERFACE_FUNC)(int version, struct r_studio_interface_s** ppinterface, struct engine_studio_api_s* pstudio);
typedef void (*HUD_CHATINPUTPOSITION_FUNC)(int* x, int* y);
typedef int (*HUD_GETPLAYERTEAM)(int iplayer);
typedef void* (*CLIENTFACTORY)(); // this should be CreateInterfaceFn but that means including interface.h
// which is a C++ file and some of the client files a C only...
// so we return a void * which we then do a typecast on later.


// Pointers to the exported client functions themselves
typedef struct
{
INITIALIZE_FUNC pInitFunc;
HUD_INIT_FUNC pHudInitFunc;
HUD_VIDINIT_FUNC pHudVidInitFunc;
HUD_REDRAW_FUNC pHudRedrawFunc;
HUD_UPDATECLIENTDATA_FUNC pHudUpdateClientDataFunc;
HUD_RESET_FUNC pHudResetFunc;
HUD_CLIENTMOVE_FUNC pClientMove;
HUD_CLIENTMOVEINIT_FUNC pClientMoveInit;
HUD_TEXTURETYPE_FUNC pClientTextureType;
HUD_IN_ACTIVATEMOUSE_FUNC pIN_ActivateMouse;
HUD_IN_DEACTIVATEMOUSE_FUNC pIN_DeactivateMouse;
HUD_IN_MOUSEEVENT_FUNC pIN_MouseEvent;
HUD_IN_CLEARSTATES_FUNC pIN_ClearStates;
HUD_IN_ACCUMULATE_FUNC pIN_Accumulate;
HUD_CL_CREATEMOVE_FUNC pCL_CreateMove;
HUD_CL_ISTHIRDPERSON_FUNC pCL_IsThirdPerson;
HUD_CL_GETCAMERAOFFSETS_FUNC pCL_GetCameraOffsets;
HUD_KB_FIND_FUNC pFindKey;
HUD_CAMTHINK_FUNC pCamThink;
HUD_CALCREF_FUNC pCalcRefdef;
HUD_ADDENTITY_FUNC pAddEntity;
HUD_CREATEENTITIES_FUNC pCreateEntities;
HUD_DRAWNORMALTRIS_FUNC pDrawNormalTriangles;
HUD_DRAWTRANSTRIS_FUNC pDrawTransparentTriangles;
HUD_STUDIOEVENT_FUNC pStudioEvent;
HUD_POSTRUNCMD_FUNC pPostRunCmd;
HUD_SHUTDOWN_FUNC pShutdown;
HUD_TXFERLOCALOVERRIDES_FUNC pTxferLocalOverrides;
HUD_PROCESSPLAYERSTATE_FUNC pProcessPlayerState;
HUD_TXFERPREDICTIONDATA_FUNC pTxferPredictionData;
HUD_DEMOREAD_FUNC pReadDemoBuffer;
HUD_CONNECTIONLESS_FUNC pConnectionlessPacket;
HUD_GETHULLBOUNDS_FUNC pGetHullBounds;
HUD_FRAME_FUNC pHudFrame;
HUD_KEY_EVENT_FUNC pKeyEvent;
HUD_TEMPENTUPDATE_FUNC pTempEntUpdate;
HUD_GETUSERENTITY_FUNC pGetUserEntity;
HUD_VOICESTATUS_FUNC pVoiceStatus; // Possibly null on old client dlls.
HUD_DIRECTORMESSAGE_FUNC pDirectorMessage; // Possibly null on old client dlls.
HUD_STUDIO_INTERFACE_FUNC pStudioInterface; // Not used by all clients
HUD_CHATINPUTPOSITION_FUNC pChatInputPosition; // Not used by all clients
HUD_GETPLAYERTEAM pGetPlayerTeam; // Not used by all clients
CLIENTFACTORY pClientFactory;
} cldll_func_t;
66 changes: 66 additions & 0 deletions src/game/client/vgui2/CClientVGUI.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <tier0/dbg.h>

#include <tier1/interface.h>
#include <tier1/tier1.h>

#include <tier2/tier2.h>

#include <vgui_controls/Controls.h>

#include "CClientVGUI.h"

namespace vgui2
{
vgui2::HScheme VGui_GetDefaultScheme()
{
return 0;
}
}

EXPOSE_SINGLE_INTERFACE(CClientVGUI, IClientVGUI, ICLIENTVGUI_NAME);

void CClientVGUI::Initialize(CreateInterfaceFn* factories, int count)
{
ConnectTier1Libraries(factories, count);
ConnectTier2Libraries(factories, count);

if (!vgui2::VGui_InitInterfacesList("CLIENT", factories, count))
{
Error("Failed to intialize VGUI2!\n");
return;
}
}

void CClientVGUI::Start()
{
}

void CClientVGUI::SetParent(vgui2::VPANEL parent)
{
}

// TODO: Setting to false breaks the mouse cursor
int CClientVGUI::UseVGUI1()
{
return true;
}

void CClientVGUI::HideScoreBoard()
{
}

void CClientVGUI::HideAllVGUIMenu()
{
}

void CClientVGUI::ActivateClientUI()
{
}

void CClientVGUI::HideClientUI()
{
}

void CClientVGUI::Shutdown()
{
}
19 changes: 19 additions & 0 deletions src/game/client/vgui2/CClientVGUI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <vgui/VGUI2.h>

#include <IClientVGUI.h>

class CClientVGUI : public IClientVGUI
{
public:
void Initialize(CreateInterfaceFn* factories, int count);
void Start() override;
void SetParent(vgui2::VPANEL parent);
int UseVGUI1() override;
void HideScoreBoard();
void HideAllVGUIMenu();
void ActivateClientUI();
void HideClientUI();
void Shutdown();
};
Loading