mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-03-12 05:51:02 +00:00
engine: minimize SetCursorType calls count
This commit is contained in:
parent
d45e6e0ad1
commit
1a09d297ee
2
3rdparty/mainui
vendored
2
3rdparty/mainui
vendored
@ -1 +1 @@
|
||||
Subproject commit 7ba2010e8dffa60ca1bc166db005c13c7b75aeb9
|
||||
Subproject commit 0f31c646d623d75b46a9b16f887ac29a167319a3
|
@ -914,11 +914,7 @@ void CL_ParseServerData( sizebuf_t *msg )
|
||||
|
||||
// set the background state
|
||||
if( cls.demoplayback && ( cls.demonum != -1 ))
|
||||
{
|
||||
// re-init mouse
|
||||
host.mouse_visible = false;
|
||||
cl.background = true;
|
||||
}
|
||||
else cl.background = background;
|
||||
|
||||
if( cl.background ) // tell the game parts about background state
|
||||
@ -2502,11 +2498,7 @@ void CL_ParseLegacyServerData( sizebuf_t *msg )
|
||||
|
||||
// set the background state
|
||||
if( cls.demoplayback && ( cls.demonum != -1 ))
|
||||
{
|
||||
// re-init mouse
|
||||
host.mouse_visible = false;
|
||||
cl.background = true;
|
||||
}
|
||||
else cl.background = background;
|
||||
|
||||
if( cl.background ) // tell the game parts about background state
|
||||
|
@ -237,10 +237,6 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
|
||||
}
|
||||
else Cvar_Reset( "r_decals" );
|
||||
|
||||
// re-init mouse
|
||||
if( cl.background )
|
||||
host.mouse_visible = false;
|
||||
|
||||
if( cl.background ) // tell the game parts about background state
|
||||
Cvar_FullSet( "cl_background", "1", FCVAR_READ_ONLY );
|
||||
else Cvar_FullSet( "cl_background", "0", FCVAR_READ_ONLY );
|
||||
|
@ -469,8 +469,8 @@ static touch_button_t *Touch_FindFirst( touchbuttonlist_t *list, const char *nam
|
||||
|
||||
void Touch_SetClientOnly( byte state )
|
||||
{
|
||||
// TODO: fix clash with vgui cursors
|
||||
touch.clientonly = state;
|
||||
host.mouse_visible = state;
|
||||
|
||||
touch.move_finger = touch.look_finger = -1;
|
||||
touch.forward = touch.side = 0;
|
||||
@ -2070,6 +2070,11 @@ void Touch_KeyEvent( int key, int down )
|
||||
ly = y;
|
||||
}
|
||||
|
||||
qboolean Touch_WantVisibleCursor( void )
|
||||
{
|
||||
return ( touch_enable.value && touch_emulate.value ) || touch.clientonly;
|
||||
}
|
||||
|
||||
void Touch_Shutdown( void )
|
||||
{
|
||||
if( !touch.initialized )
|
||||
|
@ -47,8 +47,6 @@ convar_t *cl_backspeed;
|
||||
convar_t *look_filter;
|
||||
convar_t *m_rawinput;
|
||||
|
||||
static qboolean s_bRawInput, s_bMouseGrab;
|
||||
|
||||
/*
|
||||
================
|
||||
IN_CollectInputDevices
|
||||
@ -173,19 +171,16 @@ Called when key_dest is changed
|
||||
*/
|
||||
void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
{
|
||||
if( newstate == oldstate ) return;
|
||||
if( newstate == oldstate )
|
||||
return;
|
||||
|
||||
if( oldstate == key_game )
|
||||
// since SetCursorType controls cursor visibility
|
||||
// execute it first, and then check mouse grab state
|
||||
if(( newstate == key_menu || newstate == key_console || newstate == key_message ) &&
|
||||
( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( )))
|
||||
{
|
||||
IN_DeactivateMouse();
|
||||
}
|
||||
else if( newstate == key_game )
|
||||
{
|
||||
IN_ActivateMouse();
|
||||
}
|
||||
Platform_SetCursorType( dc_arrow );
|
||||
|
||||
if( ( newstate == key_menu || newstate == key_console || newstate == key_message ) && ( !CL_IsBackgroundMap() || CL_IsBackgroundDemo( )))
|
||||
{
|
||||
#if XASH_ANDROID
|
||||
Android_ShowMouse( true );
|
||||
#endif
|
||||
@ -195,6 +190,8 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
}
|
||||
else
|
||||
{
|
||||
Platform_SetCursorType( dc_none );
|
||||
|
||||
#if XASH_ANDROID
|
||||
Android_ShowMouse( false );
|
||||
#endif
|
||||
@ -202,10 +199,21 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
|
||||
Evdev_SetGrab( true );
|
||||
#endif
|
||||
}
|
||||
|
||||
if( oldstate == key_game )
|
||||
{
|
||||
IN_DeactivateMouse();
|
||||
}
|
||||
else if( newstate == key_game )
|
||||
{
|
||||
IN_ActivateMouse();
|
||||
}
|
||||
}
|
||||
|
||||
void IN_CheckMouseState( qboolean active )
|
||||
{
|
||||
static qboolean s_bRawInput, s_bMouseGrab;
|
||||
|
||||
#if XASH_WIN32
|
||||
qboolean useRawInput = CVAR_TO_BOOL( m_rawinput ) && clgame.client_dll_uses_sdl || clgame.dllFuncs.pfnLookEvent;
|
||||
#else
|
||||
@ -313,15 +321,6 @@ void IN_MouseMove( void )
|
||||
if( !in_mouseinitialized )
|
||||
return;
|
||||
|
||||
if( FBitSet( touch_emulate.flags, FCVAR_CHANGED ))
|
||||
{
|
||||
// FIXME: do not hide cursor if it was requested by GUI
|
||||
if( !touch_emulate.value )
|
||||
Platform_SetCursorType( dc_none );
|
||||
|
||||
ClearBits( touch_emulate.flags, FCVAR_CHANGED );
|
||||
}
|
||||
|
||||
if( touch_emulate.value )
|
||||
{
|
||||
// touch emulation overrides all input
|
||||
@ -334,11 +333,6 @@ void IN_MouseMove( void )
|
||||
|
||||
VGui_MouseMove( x, y );
|
||||
|
||||
// HACKHACK: show cursor in UI, as mainui doesn't call
|
||||
// platform-dependent SetCursor anymore
|
||||
if( UI_IsVisible( ))
|
||||
Platform_SetCursorType( dc_arrow );
|
||||
|
||||
// if the menu is visible, move the menu cursor
|
||||
UI_MouseMove( x, y );
|
||||
}
|
||||
|
@ -74,6 +74,7 @@ void Touch_GetMove( float * forward, float *side, float *yaw, float *pitch );
|
||||
void Touch_ResetDefaultButtons( void );
|
||||
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
|
||||
void Touch_KeyEvent( int key, int down );
|
||||
qboolean Touch_WantVisibleCursor( void );
|
||||
|
||||
//
|
||||
// in_joy.c
|
||||
|
@ -24,7 +24,7 @@ GNU General Public License for more details.
|
||||
#include "platform/platform.h"
|
||||
|
||||
static enum VGUI_KeyCode s_pVirtualKeyTrans[256];
|
||||
static VGUI_DefaultCursor s_currentCursor;
|
||||
static VGUI_DefaultCursor s_currentCursor = -1;
|
||||
static HINSTANCE s_pVGuiSupport; // vgui_support library
|
||||
static convar_t *vgui_utf8 = NULL;
|
||||
|
||||
@ -50,8 +50,12 @@ void GAME_EXPORT VGUI_GetMousePos( int *_x, int *_y )
|
||||
|
||||
void GAME_EXPORT VGUI_CursorSelect( VGUI_DefaultCursor cursor )
|
||||
{
|
||||
Platform_SetCursorType( cursor );
|
||||
s_currentCursor = cursor;
|
||||
if( s_currentCursor != cursor )
|
||||
{
|
||||
Platform_SetCursorType( cursor );
|
||||
|
||||
s_currentCursor = cursor;
|
||||
}
|
||||
}
|
||||
|
||||
byte GAME_EXPORT VGUI_GetColor( int i, int j)
|
||||
@ -250,7 +254,6 @@ void VGui_Startup( const char *clientlib, int width, int height )
|
||||
|
||||
if( vgui.initialized )
|
||||
{
|
||||
//host.mouse_visible = true;
|
||||
vgui.Startup( width, height );
|
||||
}
|
||||
else if ( COM_CheckString( clientlib ) )
|
||||
|
@ -358,7 +358,7 @@ typedef struct host_parm_s
|
||||
qboolean allow_cheats; // this host will allow cheating
|
||||
qboolean con_showalways; // show console always (developer and dedicated)
|
||||
qboolean change_game; // initialize when game is changed
|
||||
qboolean mouse_visible; // vgui override cursor control
|
||||
qboolean mouse_visible; // vgui override cursor control (never change outside Platform_SetCursorType!)
|
||||
qboolean shutdown_issued; // engine is shutting down
|
||||
qboolean force_draw_version; // used when fraps is loaded
|
||||
float force_draw_version_time;
|
||||
|
@ -703,15 +703,6 @@ void GAME_EXPORT Host_Error( const char *error, ... )
|
||||
static qboolean recursive = false;
|
||||
va_list argptr;
|
||||
|
||||
if( host.mouse_visible && !CL_IsInMenu( ))
|
||||
{
|
||||
// hide VGUI mouse
|
||||
#ifdef XASH_SDL
|
||||
SDL_ShowCursor( 0 );
|
||||
#endif
|
||||
host.mouse_visible = false;
|
||||
}
|
||||
|
||||
va_start( argptr, error );
|
||||
Q_vsprintf( hosterror1, error, argptr );
|
||||
va_end( argptr );
|
||||
|
@ -400,12 +400,16 @@ void Sys_Error( const char *error, ... )
|
||||
va_list argptr;
|
||||
char text[MAX_PRINT_MSG];
|
||||
|
||||
// enable cursor before debugger call
|
||||
if( !Host_IsDedicated( ))
|
||||
Platform_SetCursorType( dc_arrow );
|
||||
|
||||
DEBUG_BREAK;
|
||||
|
||||
if( host.status == HOST_ERR_FATAL )
|
||||
return; // don't multiple executes
|
||||
|
||||
// make sure what console received last message
|
||||
// make sure that console received last message
|
||||
if( host.change_game ) Sys_Sleep( 200 );
|
||||
|
||||
error_on_exit = true;
|
||||
|
@ -668,7 +668,7 @@ TODO: kill mouse in win32 clients too
|
||||
*/
|
||||
void Platform_PreCreateMove( void )
|
||||
{
|
||||
if( CVAR_TO_BOOL( m_ignore ) )
|
||||
if( CVAR_TO_BOOL( m_ignore ))
|
||||
{
|
||||
SDL_GetRelativeMouseState( NULL, NULL );
|
||||
SDL_ShowCursor( SDL_TRUE );
|
||||
|
Loading…
x
Reference in New Issue
Block a user