vgui: remove unneeded SDL calls, remove unused VGUI API function, fix mouse cursor visibility

This commit is contained in:
Alibek Omarov 2022-01-04 08:13:57 +03:00 committed by a1batross
parent 7e687b45bb
commit f63d2d747f
3 changed files with 14 additions and 41 deletions

View File

@ -83,14 +83,13 @@ void VGUI_InitCursors( void )
s_pDefaultCursor[dc_sizeall] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_SIZEALL);
s_pDefaultCursor[dc_no] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_NO);
s_pDefaultCursor[dc_hand] = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
//host.mouse_visible = true;
SDL_SetCursor( s_pDefaultCursor[dc_arrow] );
#endif
}
void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
void GAME_EXPORT VGUI_CursorSelect( enum VGUI_DefaultCursor cursor )
{
qboolean visible;
if( cls.key_dest != key_game || cl.paused )
return;
@ -105,31 +104,26 @@ void GAME_EXPORT VGUI_CursorSelect(enum VGUI_DefaultCursor cursor )
break;
}
host.mouse_visible = visible;
#if SDL_VERSION_ATLEAST( 2, 0, 0 )
/// TODO: platform cursors
if( CVAR_TO_BOOL( touch_emulate ) )
return;
if( host.mouse_visible )
{
SDL_SetRelativeMouseMode( SDL_FALSE );
SDL_SetCursor( s_pDefaultCursor[cursor] );
SDL_ShowCursor( true );
}
else
{
SDL_ShowCursor( false );
if( host.mouse_visible )
SDL_GetRelativeMouseState( NULL, NULL );
Key_EnableTextInput( false, true );
}
//SDL_SetRelativeMouseMode(false);
#endif
if( s_currentCursor == cursor )
return;
s_currentCursor = cursor;
host.mouse_visible = visible;
}
byte GAME_EXPORT VGUI_GetColor( int i, int j)
@ -138,18 +132,6 @@ byte GAME_EXPORT VGUI_GetColor( int i, int j)
}
// Define and initialize vgui API
void GAME_EXPORT VGUI_SetVisible( qboolean state )
{
host.mouse_visible=state;
#ifdef XASH_SDL
SDL_ShowCursor( state );
if( !state )
SDL_GetRelativeMouseState( NULL, NULL );
#endif
Key_EnableTextInput( false, true );
}
int GAME_EXPORT VGUI_UtfProcessChar( int in )
{
if( CVAR_TO_BOOL( vgui_utf8 ) )
@ -175,12 +157,10 @@ vguiapi_t vgui =
NULL, // VGUI_GetTextureSizes,
NULL, // VGUI_GenerateTexture,
VGUI_EngineMalloc,
/* VGUI_ShowCursor,
VGUI_HideCursor,*/
VGUI_CursorSelect,
VGUI_GetColor,
VGUI_IsInGame,
VGUI_SetVisible,
NULL,
VGUI_GetMousePos,
VGUI_UtfProcessChar,
NULL,

View File

@ -176,11 +176,6 @@ enum VGUI_DefaultCursor
dc_last
};
typedef struct vguiapi_s
{
qboolean initialized;
@ -201,7 +196,7 @@ typedef struct vguiapi_s
void (*CursorSelect)( enum VGUI_DefaultCursor cursor );
byte (*GetColor)( int i, int j );
qboolean (*IsInGame)( void );
void (*SetVisible)( qboolean state );
void (*Unused)( void );
void (*GetCursorPos)( int *x, int *y );
int (*ProcessUtfChar)( int ch );
void (*Startup)( int width, int height );

View File

@ -92,7 +92,11 @@ bool CEngineSurface :: hasFocus( void )
void CEngineSurface :: setCursor( Cursor *cursor )
{
_currentCursor = cursor;
if( cursor )
{
g_api->CursorSelect( (VGUI_DefaultCursor)cursor->getDefaultCursor() );
}
}
void CEngineSurface :: SetupPaintState( const PaintStack *paintState )
@ -428,15 +432,9 @@ void CEngineSurface :: popMakeCurrent( Panel *panel )
bool CEngineSurface :: setFullscreenMode( int wide, int tall, int bpp )
{
// NOTE: Xash3D always working in 32-bit mode
// Skip it now. VGUI cannot change video modes
return false;
}
void CEngineSurface :: setWindowedMode( void )
{
// Skip it now. VGUI cannot change video modes
/*
Cvar_SetFloat( "fullscreen", 0.0f );
*/
}