diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 41e1c28f..fd29d2d3 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -166,9 +166,7 @@ so the HUD can reinitialize itself. int DLLEXPORT HUD_VidInit( void ) { gHUD.VidInit(); - -// FIXME: implement Vgui -// VGui_Startup(); + VGui_Startup(); return 1; } @@ -253,8 +251,7 @@ void DLLEXPORT HUD_Frame( double time ) { ServersThink( time ); - if( gViewPort ) - GetClientVoiceMgr()->Frame(time); + GetClientVoiceMgr()->Frame(time); } @@ -268,8 +265,7 @@ Called when a player starts or stops talking. void DLLEXPORT HUD_VoiceStatus(int entindex, qboolean bTalking) { - if( gViewPort ) - GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking); + GetClientVoiceMgr()->UpdateSpeakerStatus(entindex, bTalking); } /* diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index cac9e9c2..6a209c86 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -539,8 +539,7 @@ void DLLEXPORT HUD_CreateEntities( void ) // Add in any game specific objects Game_AddObjects(); - if( gViewPort ) - GetClientVoiceMgr()->CreateEntities(); + GetClientVoiceMgr()->CreateEntities(); } /* diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index f614e95a..64ac7bed 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -347,8 +347,7 @@ void CHud :: Init( void ) m_TextMessage.Init(); m_StatusIcons.Init(); - if( gViewPort ) - GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort); + GetClientVoiceMgr()->Init(&g_VoiceStatusHelper, (vgui::Panel**)&gViewPort); m_Menu.Init(); @@ -497,8 +496,7 @@ void CHud :: VidInit( void ) m_TextMessage.VidInit(); m_StatusIcons.VidInit(); - if( gViewPort ) - GetClientVoiceMgr()->VidInit(); + GetClientVoiceMgr()->VidInit(); } int CHud::MsgFunc_Logo(const char *pszName, int iSize, void *pbuf) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index de84dd72..a2482f2d 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -2592,29 +2592,6 @@ static void pfnSetScreenFade( struct screenfade_s *fade ) if( fade ) clgame.fade = *fade; } -/* -============= -VGui_GetPanel - -============= -*/ -void *VGui_GetPanel( void ) -{ - // UNDONE: wait for version 0.75 - return NULL; -} - -/* -============= -VGui_ViewportPaintBackground - -============= -*/ -void VGui_ViewportPaintBackground( int extents[4] ) -{ - // UNDONE: wait for version 0.75 -} - /* ============= pfnLoadMapSprite @@ -3666,6 +3643,8 @@ qboolean CL_LoadProgs( const char *name ) CL_InitViewBeams (); CL_InitTempEnts (); + VGui_Startup (); + // initialize game clgame.dllFuncs.pfnInit(); diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 372709fb..013d3191 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -770,6 +770,9 @@ void CL_SendDisconnectMessage( void ) BF_WriteByte( &buf, clc_stringcmd ); BF_WriteString( &buf, "disconnect" ); + if( !cls.netchan.remote_address.type ) + cls.netchan.remote_address.type = NA_LOOPBACK; + // make sure message will be delivered Netchan_Transmit( &cls.netchan, BF_GetNumBytesWritten( &buf ), BF_GetData( &buf )); Netchan_Transmit( &cls.netchan, BF_GetNumBytesWritten( &buf ), BF_GetData( &buf )); diff --git a/engine/client/cl_scrn.c b/engine/client/cl_scrn.c index 53bb89bd..36f58995 100644 --- a/engine/client/cl_scrn.c +++ b/engine/client/cl_scrn.c @@ -258,8 +258,10 @@ void SCR_UpdateScreen( void ) V_PostRender(); } - if( clgame.hInstance ) - clgame.dllFuncs.pfnFrame( cl_time( )); + if( !clgame.hInstance ) return; + + clgame.dllFuncs.pfnFrame( cl.time ); + VGui_Paint (); } static void SCR_LoadCreditsFont( void ) @@ -356,6 +358,8 @@ void SCR_RegisterShaders( void ) menu.globals->scrWidth = scr_width->integer; menu.globals->scrHeight = scr_height->integer; + VGui_Startup (); + // vid_state has changed if( clgame.hInstance ) clgame.dllFuncs.pfnVidInit(); if( menu.hInstance ) menu.dllFuncs.pfnVidInit(); diff --git a/engine/client/client.h b/engine/client/client.h index 4c18e1d0..3da61110 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -426,12 +426,20 @@ typedef struct file_t *demofile; } client_static_t; +#ifdef __cplusplus +extern "C" { +#endif + extern client_t cl; extern client_static_t cls; extern clgame_static_t clgame; extern menu_static_t menu; extern render_exp_t *re; +#ifdef __cplusplus +} +#endif + // // cvars // @@ -530,8 +538,6 @@ void CL_TextMessageParse( byte *pMemFile, int fileSize ); int pfnDecalIndexFromName( const char *szDecalName ); int CL_FindModelIndex( const char *m ); HSPRITE pfnSPR_Load( const char *szPicName ); -void *VGui_GetPanel( void ); -void VGui_ViewportPaintBackground( int extents[4] ); _inline cl_entity_t *CL_EDICT_NUM( int n, const char *file, const int line ) { @@ -676,4 +682,20 @@ void SCR_RunCinematic( void ); void SCR_StopCinematic( void ); void CL_PlayVideo_f( void ); +// +// vgui_int.cpp +// +#ifdef __cplusplus +extern "C" { +#endif + +void VGui_Startup( void ); +void *VGui_GetPanel( void ); +void VGui_Paint( void ); +void VGui_ViewportPaintBackground( int extents[4] ); + +#ifdef __cplusplus +} +#endif + #endif//CLIENT_H \ No newline at end of file diff --git a/engine/common/com_export.h b/engine/common/com_export.h index f17dfe2b..6337b112 100644 --- a/engine/common/com_export.h +++ b/engine/common/com_export.h @@ -7,11 +7,19 @@ #include "cm_local.h" +#ifdef __cplusplus +extern "C" { +#endif + // linked interfaces extern stdlib_api_t com; extern vsound_exp_t *se; extern render_exp_t *re; +#ifdef __cplusplus +} +#endif + _inline int CL_CreateDecalList( decallist_t *pList, qboolean changelevel ) { if( !re ) return 0; diff --git a/engine/common/vgui_int.cpp b/engine/common/vgui_int.cpp new file mode 100644 index 00000000..f5125ef5 --- /dev/null +++ b/engine/common/vgui_int.cpp @@ -0,0 +1,169 @@ +//======================================================================= +// Copyright XashXT Group 2010 © +// vgi_int.c - vgui dll interaction +//======================================================================= + +#include "common.h" +#include "client.h" +#include "const.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace vgui; + +SurfaceGL::SurfaceGL( Panel* embeddedPanel ):Surface( embeddedPanel ) +{ + _embeddedPanel = embeddedPanel; +} + +void SurfaceGL::texturedRect( int x0, int y0, int x1, int y1 ) +{ + Msg( "texturedRect: %i %i %i %i\n", x0, y0, x1, y1 ); +} + +bool SurfaceGL:: recreateContext() +{ + return true; +} + +void SurfaceGL:: createPopup( Panel *embeddedPanel ) +{ +} + +void SurfaceGL:: pushMakeCurrent( Panel* panel, bool useInsets ) +{ +} + +void SurfaceGL:: popMakeCurrent( Panel* panel ) +{ +} + +void SurfaceGL:: makeCurrent( void ) +{ +} + +void SurfaceGL::swapBuffers( void ) +{ +} + +void SurfaceGL::setColor( int r, int g, int b ) +{ +} + +void SurfaceGL::filledRect( int x0, int y0, int x1, int y1 ) +{ +} + +void SurfaceGL::outlinedRect( int x0, int y0, int x1, int y1 ) +{ +} + +void SurfaceGL::setTextFont( Font* font ) +{ +} + +void SurfaceGL::setTextColor( int r, int g, int b ) +{ + Msg( "setTextColor: %i %i %i\n", r, g, b ); +} + +void SurfaceGL::setDrawPos( int x, int y ) +{ + Msg( "setDrawPos: %i %i\n", x, y ); +} + +void SurfaceGL::printText( const char *str, int strlen ) +{ + Msg( "printText: %s\n", str ); +} + +void SurfaceGL::setTextureRGBA( int id, const char *rgba, int wide, int tall ) +{ + Msg( "setTextureRGBA: %i\n", id ); +} + +void SurfaceGL::setTexture( int id ) +{ + Msg( "setTexture: %i\n", id ); +} + +class CEngineApp : public App +{ +public: + CEngineApp( void ) + { + reset(); + } + + virtual void main( int argc, char* argv[] ) + { + } + + virtual void setCursorPos( int x, int y ) + { + Msg( "setCursorPos: %i %i\n", x, y ); + } + + virtual void getCursorPos( int &x,int &y ) + { + App::getCursorPos( x, y ); + Msg( "getCursorPos: %i %i\n", x, y ); + } +}; + +class CEnginePanel : public Panel, public CEngineApp +{ + typedef Panel BaseClass; +public: + CEnginePanel( void ) + { + _surfaceBase = new SurfaceGL( this ); + setSurfaceBaseTraverse( _surfaceBase ); + setParent( NULL ); + } +}; + +CEnginePanel *rootpanel = NULL; + +void VGui_Startup( void ) +{ + if( rootpanel ) + { + rootpanel->reset(); + rootpanel->setSize( menu.globals->scrWidth, menu.globals->scrHeight ); + return; + } + + rootpanel = new CEnginePanel(); + rootpanel->setLayout( new BorderLayout( 0 )); + rootpanel->setEnabled( true ); + rootpanel->setVisible( true ); + + ASSERT( rootpanel->getApp() != NULL ); + ASSERT( rootpanel->getSurfaceBase() != NULL ); +} + +void VGui_Paint( void ) +{ + if( !rootpanel ) return; + + rootpanel->solveTraverse(); + rootpanel->paintTraverse(); +} + +void VGui_ViewportPaintBackground( int extents[4] ) +{ + Msg( "paint()\n" ); +} + +void *VGui_GetPanel( void ) +{ + return (void *)rootpanel; +} \ No newline at end of file diff --git a/engine/engine.dsp b/engine/engine.dsp index c251358d..34c4c3ef 100644 --- a/engine/engine.dsp +++ b/engine/engine.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "server" /I "client" /I "uimenu" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "./" /I "common" /I "server" /I "client" /I "uimenu" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -54,7 +54,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /opt:nowin98 -# ADD LINK32 user32.lib msvcrt.lib vfw32.lib msacm32.lib gdi32.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 +# ADD LINK32 user32.lib msvcrt.lib vfw32.lib msacm32.lib gdi32.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98 # SUBTRACT LINK32 /debug /nodefaultlib # Begin Custom Build TargetDir=\Xash3D\src_main\temp\engine\!release @@ -80,7 +80,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "common" /I "server" /I "client" /I "uimenu" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /Gi /GX /ZI /Od /I "./" /I "common" /I "server" /I "client" /I "uimenu" /I "../public" /I "../common" /I "../game_shared" /I "../pm_shared" /I "../utils/vgui/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -91,7 +91,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 -# ADD LINK32 user32.lib msvcrtd.lib vfw32.lib msacm32.lib gdi32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept +# ADD LINK32 user32.lib msvcrtd.lib vfw32.lib msacm32.lib gdi32.lib ../utils/vgui/lib/win32_vc6/vgui.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"msvcrt.lib" /pdbtype:sept # SUBTRACT LINK32 /incremental:no /map /nodefaultlib # Begin Custom Build TargetDir=\Xash3D\src_main\temp\engine\!debug @@ -310,6 +310,10 @@ SOURCE=.\common\titles.c # End Source File # Begin Source File +SOURCE=.\common\vgui_int.cpp +# End Source File +# Begin Source File + SOURCE=.\common\world.c # End Source File # End Group diff --git a/public/launch_api.h b/public/launch_api.h index 1027fe6b..4316be86 100644 --- a/public/launch_api.h +++ b/public/launch_api.h @@ -19,7 +19,10 @@ #define MAX_STRING_TABLES 8 // seperately stringsystems #define EXPORT __declspec( dllexport ) #define BIT( n ) (1<<( n )) + +#ifndef NULL #define NULL ((void *)0) +#endif // color strings #define IsColorString( p ) ( p && *( p ) == '^' && *(( p ) + 1) && *(( p ) + 1) >= '0' && *(( p ) + 1 ) <= '9' ) @@ -748,7 +751,7 @@ script shared declaration external and internal script_t struct have some differences ======================================================================== */ -typedef struct script_s +struct script_s { char *buffer; char *text; @@ -756,7 +759,7 @@ typedef struct script_s char TXcommand; // contain QuArK 'TX' command in the map file descriptions }; -typedef struct convar_s +struct convar_s { // this part shared with cvar_t char *name;