Skip to content
This repository was archived by the owner on Mar 1, 2021. It is now read-only.

Update base for Strobe #2

Merged
merged 8 commits into from
Mar 3, 2018
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ else()
endif()

# Misc
option(XASH_USE_STB_SPRINTF "Use stb_sprintf implementation for sprintf" ON)
option(XASH_NO_INSTALL_RUNSCRIPT "Don't install xash3d.sh" OFF)
option(XASH_NO_INSTALL_VGUI_BIN "Don't bundle proprietary VGUI" OFF)
if(WIN32) # Autodownload for lazy developers using Windows
Expand Down
4 changes: 4 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ if(XASH_NO_ASYNC_NS_RESOLVE)
add_definitions(-DXASH_NO_ASYNC_NS_RESOLVE)
endif()

if(XASH_USE_STB_SPRINTF)
add_definitions(-DXASH_USE_STB_SPRINTF)
endif()

fwgs_set_default_properties(${XASH_ENGINE})

if(NOT WIN32)
Expand Down
1 change: 1 addition & 0 deletions engine/client/gl_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ extern convar_t *r_fastsky;
extern convar_t *r_vbo;
extern convar_t *r_bump;
extern convar_t *r_strobe;
extern convar_t *r_underwater_distortion;

extern convar_t *mp_decals;

Expand Down
4 changes: 2 additions & 2 deletions engine/client/gl_rmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,10 @@ R_SetupGL
*/
static void R_SetupGL( void )
{
if( RI.refdef.waterlevel >= 3 )
if( r_underwater_distortion->value && RI.refdef.waterlevel >= 3 )
{
float f;
f = sin( cl.time * 0.4f * ( M_PI * 2.7f ));
f = sin( cl.time * r_underwater_distortion->value * ( M_PI * 2.7f ));
RI.refdef.fov_x += f;
RI.refdef.fov_y -= f;
}
Expand Down
16 changes: 10 additions & 6 deletions engine/client/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,11 +846,11 @@ CL_CharEvent
Normal keyboard characters, already shifted / capslocked / etc
===================
*/
void CL_CharEvent( int key )
void CL_CharEvent( int ch )
{
// the console key should never be used as a char
#ifdef _WIN32
if( key == '`' || key == '~' ) return;
if( ch == '`' || ch == '~' ) return;

#if 0
if( cls.key_dest == key_console && !Con_Visible( ))
Expand All @@ -861,13 +861,17 @@ void CL_CharEvent( int key )
#endif
#endif
// distribute the key down event to the apropriate handler
if( cls.key_dest == key_console || cls.key_dest == key_message )

Con_CharEvent( ch ); // a1ba: no need for checks, as Con_CharEvent already it does

if( cls.key_dest == key_menu )
{
Con_CharEvent( key );
UI_CharEvent( ch );
}
else if( cls.key_dest == key_menu )
else if( cls.key_dest == key_game ) // typing support for VGUI
{
UI_CharEvent( key );
VGui_KeyEvent( ch, 2 );
}

}
#endif
17 changes: 9 additions & 8 deletions engine/client/touch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1678,16 +1678,17 @@ int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx
}


VGui_MouseMove( TO_SCRN_X(x), TO_SCRN_Y(y) );
if( VGui_IsActive() )
{
VGui_MouseMove( TO_SCRN_X(x), TO_SCRN_Y(y) );

if( type == event_down )
VGui_KeyEvent(241, 1);
if( type == event_up )
VGui_KeyEvent(241, 0);
if( type != event_motion )
VGui_KeyEvent( K_MOUSE1, type == event_down ? 1 : 0 );

// allow scoreboard scroll
if( host.mouse_visible && type == event_motion )
return 0;
// allow scoreboard scroll
if( host.mouse_visible && type == event_motion )
return 0;
}

if( !touch.initialized || (!touch_enable->integer && !touch.clientonly) )
{
Expand Down
66 changes: 36 additions & 30 deletions engine/client/vgui/vgui_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static enum VGUI_DefaultCursor s_currentCursor;
#include "platform/sdl/events.h"
static SDL_Cursor* s_pDefaultCursor[20];
#endif
static void *s_pVGuiSupport; // vgui_support library

void VGUI_DrawInit( void );
void VGUI_DrawShutdown( void );
Expand Down Expand Up @@ -77,7 +78,7 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
{
float xscale = scr_width->value / (float)clgame.scrInfo.iWidth;
float yscale = scr_height->value / (float)clgame.scrInfo.iHeight;
int x,y;
int x, y;

CL_GetMousePosition( &x, &y );
*_x = x / xscale, *_y = y / yscale;
Expand Down Expand Up @@ -133,7 +134,7 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
{
SDL_ShowCursor( false );
if( host.mouse_visible )
SDL_GetRelativeMouseState( 0, 0 );
SDL_GetRelativeMouseState( NULL, NULL );
}
//SDL_SetRelativeMouseMode(false);
#endif
Expand All @@ -151,12 +152,14 @@ byte GAME_EXPORT VGUI_GetColor( int i, int j)

// Define and initialize vgui API

void GAME_EXPORT VGUI_SetVisible ( qboolean state )
void GAME_EXPORT VGUI_SetVisible( qboolean state )
{
host.mouse_visible=state;
#ifdef XASH_SDL
SDL_ShowCursor( state );
if(!state) SDL_GetRelativeMouseState( 0, 0 );
if( !state )
SDL_GetRelativeMouseState( NULL, NULL );

SDLash_EnableTextInput( state, true );
#endif
}
Expand All @@ -171,7 +174,7 @@ int GAME_EXPORT VGUI_UtfProcessChar( int in )

vguiapi_t vgui =
{
false, //Not initialized yet
false, // Not initialized yet
VGUI_DrawInit,
VGUI_DrawShutdown,
VGUI_SetupDrawingText,
Expand Down Expand Up @@ -201,11 +204,12 @@ vguiapi_t vgui =
NULL,
NULL,
NULL,
} ;


void *lib; //vgui_support library
};

qboolean VGui_IsActive( void )
{
return vgui.initialized;
}

/*
================
Expand All @@ -226,14 +230,15 @@ void VGui_Startup( int width, int height )

if( failed )
return;
#ifdef XASH_INTERNAL_GAMELIBS

if( !vgui.initialized )
{
lib = Com_LoadLibrary( "client", false );
#ifdef XASH_INTERNAL_GAMELIBS
s_pVGuiSupport = Com_LoadLibrary( "client", false );

if( lib )
if( s_pVGuiSupport )
{
F = Com_GetProcAddress( lib, "InitVGUISupportAPI" );
F = Com_GetProcAddress( s_pVGuiSupport, "InitVGUISupportAPI" );
if( F )
{
F( &vgui );
Expand All @@ -242,21 +247,19 @@ void VGui_Startup( int width, int height )
MsgDev( D_INFO, "vgui_support: found interal client support\n" );
}
}
}
#endif
#endif // XASH_INTERNAL_GAMELIBS

if( !vgui.initialized )
{
Com_ResetLibraryError();

// hack: load vgui with correct path first if specified.
// HACKHACK: load vgui with correct path first if specified.
// it will be reused while resolving vgui support and client deps
if( Sys_GetParmFromCmdLine( "-vguilib", vguilib ) )
{
if( Q_strstr( vguilib, ".dll") )
Q_strncpy( vguiloader, "vgui_support.dll", 256 );
else
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );

if( !Com_LoadLibrary( vguilib, false ) )
MsgDev( D_WARN, "VGUI preloading failed. Default library will be used!\n");
}
Expand All @@ -267,14 +270,14 @@ void VGui_Startup( int width, int height )
if( !vguiloader[0] && !Sys_GetParmFromCmdLine( "-vguiloader", vguiloader ) )
Q_strncpy( vguiloader, VGUI_SUPPORT_DLL, 256 );

lib = Com_LoadLibrary( vguiloader, false );
s_pVGuiSupport = Com_LoadLibrary( vguiloader, false );

if( !lib )
if( !s_pVGuiSupport )
{
lib = Com_LoadLibrary( va( "../%s", vguiloader ), false );
s_pVGuiSupport = Com_LoadLibrary( va( "../%s", vguiloader ), false );
}

if( !lib )
if( !s_pVGuiSupport )
{
if( FS_SysFileExists( vguiloader, false ) )
MsgDev( D_ERROR, "Failed to load vgui_support library: %s", Com_GetLibraryError() );
Expand All @@ -283,7 +286,7 @@ void VGui_Startup( int width, int height )
}
else
{
F = Com_GetProcAddress( lib, "InitAPI" );
F = Com_GetProcAddress( s_pVGuiSupport, "InitAPI" );
if( F )
{
F( &vgui );
Expand Down Expand Up @@ -338,9 +341,11 @@ void VGui_Shutdown( void )
{
if( vgui.Shutdown )
vgui.Shutdown();
if( lib )
Com_FreeLibrary( lib );
lib = NULL;

if( s_pVGuiSupport )
Com_FreeLibrary( s_pVGuiSupport );
s_pVGuiSupport = NULL;

vgui.initialized = false;
}

Expand All @@ -349,7 +354,8 @@ void VGUI_InitKeyTranslationTable( void )
{
static qboolean bInitted = false;

if( bInitted ) return;
if( bInitted )
return;
bInitted = true;

// set virtual key translation table
Expand Down Expand Up @@ -480,10 +486,12 @@ void VGui_KeyEvent( int key, int down )
{
if( !vgui.initialized )
return;

#ifdef XASH_SDL
if( host.mouse_visible )
SDLash_EnableTextInput( 1, false );
#endif

switch( key )
{
case K_MOUSE1:
Expand Down Expand Up @@ -546,7 +554,7 @@ void GAME_EXPORT VGUI_DrawShutdown( void )

for( i = 1; i < g_textureId; i++ )
{
GL_FreeImage( va( "*vgui%i", i ));
GL_FreeImage( va( "*vgui%i", i ));
}
}

Expand Down Expand Up @@ -754,8 +762,6 @@ void VGui_Paint()
vgui.Paint();
}



void VGui_RunFrame()
{
//stub
Expand Down
1 change: 1 addition & 0 deletions engine/client/vgui/vgui_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ void VGui_Paint();
void VGui_RunFrame();
void VGui_KeyEvent( int key, int down );
void VGui_MouseMove( int x, int y );
qboolean VGui_IsActive( void );
void *pfnVGui_GetPanel();
#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions engine/client/vid_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ convar_t *r_fastsky;
convar_t *r_vbo;
convar_t *r_bump;
convar_t *r_strobe;
convar_t *r_underwater_distortion;
convar_t *mp_decals;

convar_t *vid_displayfrequency;
Expand Down Expand Up @@ -869,6 +870,7 @@ void GL_InitCommands( void )
r_decals = Cvar_Get( "r_decals", "4096", 0, "sets the maximum number of decals" );
r_xpos = Cvar_Get( "r_xpos", "130", CVAR_GLCONFIG, "window position by horizontal" );
r_ypos = Cvar_Get( "r_ypos", "48", CVAR_GLCONFIG, "window position by vertical" );
r_underwater_distortion = Cvar_Get( "r_underwater_distortion", "0.4", CVAR_ARCHIVE, "underwater distortion speed" );
mp_decals = Cvar_Get( "mp_decals", "300", CVAR_ARCHIVE, "sets the maximum number of decals in multiplayer" );

gl_picmip = Cvar_Get( "gl_picmip", "0", CVAR_GLCONFIG, "reduces resolution of textures by powers of 2" );
Expand Down
2 changes: 1 addition & 1 deletion engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ qboolean CL_IsIntermission( void );
void CL_WarnLostSplitPacket( void );
float CL_GetServerTime( void );
float CL_GetLerpFrac( void );
void CL_CharEvent( int key );
void CL_CharEvent( int ch );
qboolean CL_DisableVisibility( void );
int CL_PointContents( const vec3_t point );
char *COM_ParseFile( char *data, char *token );
Expand Down
20 changes: 10 additions & 10 deletions engine/common/crtlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ const char* Q_timestamp( int format )

return timestamp;
}

#ifndef XASH_SKIPCRTLIB
char *Q_strstr( const char *string, const char *string2 )
{
Expand Down Expand Up @@ -371,15 +372,13 @@ char *Q_stristr( const char *string, const char *string2 )
}
return (char *)string;
}
#ifndef USE_STB_SPRINTF
#define USE_STB_SPRINTF 1
#endif
#if USE_STB_SPRINTF
#define STB_SPRINTF_IMPLEMENTATION
#define STB_SPRINTF_DECORATE(name) Q_##name
#undef Q_vsprintf
#include "stb/stb_sprintf.h"
#else

#if XASH_USE_STB_SPRINTF
#define STB_SPRINTF_IMPLEMENTATION
#define STB_SPRINTF_DECORATE(name) Q_##name
#undef Q_vsprintf
#include "stb/stb_sprintf.h"
#else // XASH_USE_STB_SPRINTF
int Q_vsnprintf( char *buffer, size_t buffersize, const char *format, va_list args )
{
int result;
Expand Down Expand Up @@ -417,8 +416,9 @@ int Q_sprintf( char *buffer, const char *format, ... )

return result;
}
#endif // USE_STB_SRPINTF
#endif // XASH_USE_STB_SPRINTF
#endif // XASH_SKIPCRTLIB

char *Q_pretifymem( float value, int digitsafterdecimal )
{
static char output[8][32];
Expand Down
4 changes: 1 addition & 3 deletions engine/platform/android/android_nosdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,7 @@ void Android_RunEvents()
}

// otherwise just push it by char, text render will decode unicode strings
Con_CharEvent( ch );
if( cls.key_dest == key_menu )
UI_CharEvent ( ch );
CL_CharEvent( ch );
}
events.inputtext[0] = 0; // no more text

Expand Down
Loading