mirror of
https://github.com/nillerusr/source-engine.git
synced 2024-12-22 06:06:50 +00:00
game/client: fix messagemode, add acceleration for touch, GameUI: add touch options
This commit is contained in:
parent
0feeab91dd
commit
ab5c1c0b3a
@ -52,6 +52,7 @@
|
||||
#include "replay/vgui/replaymessagepanel.h"
|
||||
#include "econ/econ_controls.h"
|
||||
#include "econ/confirm_dialog.h"
|
||||
|
||||
extern IClientReplayContext *g_pClientReplayContext;
|
||||
extern ConVar replay_rendersetting_renderglow;
|
||||
#endif
|
||||
@ -144,6 +145,18 @@ CON_COMMAND( hud_reloadscheme, "Reloads hud layout and animation scripts." )
|
||||
mode->ReloadScheme();
|
||||
}
|
||||
|
||||
CON_COMMAND( messagemode, "Opens chat dialog" )
|
||||
{
|
||||
ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal();
|
||||
mode->StartMessageMode( MM_SAY );
|
||||
}
|
||||
|
||||
CON_COMMAND( messagemode2, "Opens chat dialog" )
|
||||
{
|
||||
ClientModeShared *mode = ( ClientModeShared * )GetClientModeNormal();
|
||||
mode->StartMessageMode( MM_SAY_TEAM );
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
CON_COMMAND_F( crash, "Crash the client. Optional parameter -- type of crash:\n 0: read from NULL\n 1: write to NULL\n 2: DmCrashDump() (xbox360 only)", FCVAR_CHEAT )
|
||||
{
|
||||
@ -632,28 +645,6 @@ int ClientModeShared::KeyInput( int down, ButtonCode_t keynum, const char *pszCu
|
||||
if ( engine->Con_IsVisible() )
|
||||
return 1;
|
||||
|
||||
// Should we start typing a message?
|
||||
if ( pszCurrentBinding &&
|
||||
( Q_strcmp( pszCurrentBinding, "messagemode" ) == 0 ||
|
||||
Q_strcmp( pszCurrentBinding, "say" ) == 0 ) )
|
||||
{
|
||||
if ( down )
|
||||
{
|
||||
StartMessageMode( MM_SAY );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else if ( pszCurrentBinding &&
|
||||
( Q_strcmp( pszCurrentBinding, "messagemode2" ) == 0 ||
|
||||
Q_strcmp( pszCurrentBinding, "say_team" ) == 0 ) )
|
||||
{
|
||||
if ( down )
|
||||
{
|
||||
StartMessageMode( MM_SAY_TEAM );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If we're voting...
|
||||
#ifdef VOTING_ENABLED
|
||||
CHudVote *pHudVote = GET_HUDELEMENT( CHudVote );
|
||||
|
@ -947,7 +947,8 @@ void CInput::ControllerMove( float frametime, CUserCmd *cmd )
|
||||
}
|
||||
|
||||
JoyStickMove( frametime, cmd);
|
||||
gTouch.Move( frametime, cmd );
|
||||
|
||||
TouchMove( cmd );
|
||||
|
||||
// NVNT if we have a haptic device..
|
||||
if(haptics && haptics->HasDevice())
|
||||
@ -1194,9 +1195,9 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
|
||||
|
||||
// Using joystick?
|
||||
#ifdef SIXENSE
|
||||
if ( in_joystick.GetInt() || g_pSixenseInput->IsEnabled() )
|
||||
if ( in_joystick.GetInt() || g_pSixenseInput->IsEnabled() || touch_enable.GetInt() )
|
||||
#else
|
||||
if ( in_joystick.GetInt() )
|
||||
if ( in_joystick.GetInt() || touch_enable.GetInt() )
|
||||
#endif
|
||||
{
|
||||
if ( cmd->forwardmove > 0 )
|
||||
|
113
game/client/in_touch.cpp
Normal file
113
game/client/in_touch.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Mouse input routines
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#if defined( WIN32 ) && !defined( _X360 )
|
||||
#define _WIN32_WINNT 0x0502
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "cbase.h"
|
||||
#include "hud.h"
|
||||
#include "cdll_int.h"
|
||||
#include "kbutton.h"
|
||||
#include "basehandle.h"
|
||||
#include "usercmd.h"
|
||||
#include "input.h"
|
||||
#include "iviewrender.h"
|
||||
#include "iclientmode.h"
|
||||
#include "tier0/icommandline.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "vgui/Cursor.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "cdll_util.h"
|
||||
#include "tier1/convar_serverbounded.h"
|
||||
#include "cam_thirdperson.h"
|
||||
#include "inputsystem/iinputsystem.h"
|
||||
#include "touch.h"
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
// left / right
|
||||
#define YAW 1
|
||||
|
||||
extern ConVar cl_sidespeed;
|
||||
extern ConVar cl_forwardspeed;
|
||||
extern ConVar sensitivity;
|
||||
extern ConVar lookstrafe;
|
||||
extern ConVar thirdperson_platformer;
|
||||
extern ConVar touch_pitch;
|
||||
extern ConVar touch_yaw;
|
||||
extern ConVar default_fov;
|
||||
|
||||
#ifdef PORTAL
|
||||
extern bool g_bUpsideDown;
|
||||
#endif
|
||||
|
||||
ConVar touch_enable_accel( "touch_enable_accel", "0", FCVAR_ARCHIVE );
|
||||
ConVar touch_accel( "touch_accel", "1.f", FCVAR_ARCHIVE );
|
||||
ConVar touch_reverse( "touch_reverse", "0", FCVAR_ARCHIVE );
|
||||
ConVar touch_sensitivity( "touch_sensitivity", "3.0", FCVAR_ARCHIVE, "touch look sensitivity" );
|
||||
|
||||
void CInput::TouchScale( float &dx, float &dy )
|
||||
{
|
||||
dx *= touch_yaw.GetFloat();
|
||||
dy *= touch_pitch.GetFloat();
|
||||
|
||||
float sensitivity = touch_sensitivity.GetFloat() * gHUD.GetFOVSensitivityAdjust() * ( touch_reverse.GetBool() ? -1.f : 1.f );
|
||||
|
||||
if( touch_enable_accel.GetBool() )
|
||||
{
|
||||
float raw_touch_movement_distance_squared = dx * dx + dy * dy;
|
||||
float fExp = MAX(0.0f, (touch_accel.GetFloat() - 1.0f) / 2.0f);
|
||||
float accelerated_sensitivity = powf( raw_touch_movement_distance_squared, fExp ) * sensitivity;
|
||||
|
||||
dx *= accelerated_sensitivity;
|
||||
dy *= accelerated_sensitivity;
|
||||
}
|
||||
else
|
||||
{
|
||||
dx *= sensitivity;
|
||||
dy *= sensitivity;
|
||||
}
|
||||
}
|
||||
|
||||
void CInput::ApplyTouch( QAngle &viewangles, CUserCmd *cmd, float dx, float dy )
|
||||
{
|
||||
viewangles[YAW] -= dx;
|
||||
viewangles[PITCH] += dy;
|
||||
cmd->mousedx = dx;
|
||||
cmd->mousedy = dy;
|
||||
}
|
||||
|
||||
void CInput::TouchMove( CUserCmd *cmd )
|
||||
{
|
||||
QAngle viewangles;
|
||||
float dx,dy,side,forward,pitch,yaw;
|
||||
|
||||
engine->GetViewAngles( viewangles );
|
||||
|
||||
view->StopPitchDrift();
|
||||
|
||||
gTouch.GetTouchAccumulators( &side, &forward, &yaw, &pitch );
|
||||
|
||||
cmd->sidemove -= cl_sidespeed.GetFloat() * side;
|
||||
cmd->forwardmove += cl_forwardspeed.GetFloat() * forward;
|
||||
|
||||
gTouch.GetTouchDelta( yaw, pitch, &dx, &dy );
|
||||
|
||||
TouchScale( dx, dy );
|
||||
|
||||
// Let the client mode at the mouse input before it's used
|
||||
g_pClientMode->OverrideMouseInput( &dx, &dy );
|
||||
|
||||
// Add mouse X/Y movement to cmd
|
||||
ApplyTouch( viewangles, cmd, dx, dy );
|
||||
|
||||
// Store out the new viewangles.
|
||||
engine->SetViewAngles( viewangles );
|
||||
}
|
@ -135,7 +135,10 @@ private:
|
||||
void GetMouseDelta( float inmousex, float inmousey, float *pOutMouseX, float *pOutMouseY );
|
||||
void ScaleMouse( float *x, float *y );
|
||||
void ApplyMouse( QAngle& viewangles, CUserCmd *cmd, float mouse_x, float mouse_y );
|
||||
void MouseMove ( CUserCmd *cmd );
|
||||
void MouseMove( CUserCmd *cmd );
|
||||
void TouchMove( CUserCmd *cmd );
|
||||
void TouchScale( float &dx, float &dy );
|
||||
void ApplyTouch( QAngle &viewangles, CUserCmd *cmd, float dx, float dy );
|
||||
|
||||
// Joystick movement input helpers
|
||||
void ControllerMove ( float frametime, CUserCmd *cmd );
|
||||
@ -287,4 +290,4 @@ extern void KeyUp( kbutton_t *b, const char *c );
|
||||
|
||||
|
||||
#endif // INPUT_H
|
||||
|
||||
|
||||
|
@ -28,6 +28,8 @@ extern ConVar sensitivity;
|
||||
#define TOUCH_DEFAULT_CFG "touch_default.cfg"
|
||||
|
||||
ConVar touch_enable( "touch_enable", TOUCH_DEFAULT, FCVAR_ARCHIVE );
|
||||
ConVar touch_draw( "touch_draw", "1", FCVAR_ARCHIVE );
|
||||
ConVar touch_filter( "touch_filter", "0", FCVAR_ARCHIVE );
|
||||
ConVar touch_forwardzone( "touch_forwardzone", "0.06", FCVAR_ARCHIVE, "forward touch zone" );
|
||||
ConVar touch_sidezone( "touch_sidezone", "0.06", FCVAR_ARCHIVE, "side touch zone" );
|
||||
ConVar touch_pitch( "touch_pitch", "90", FCVAR_ARCHIVE, "touch pitch sensitivity" );
|
||||
@ -258,6 +260,36 @@ CON_COMMAND( touch_toggleselection, "toggle visibility on selected button in edi
|
||||
|
||||
}*/
|
||||
|
||||
void CTouchControls::GetTouchAccumulators( float *side, float *forward, float *yaw, float *pitch )
|
||||
{
|
||||
*forward = this->forward;
|
||||
*side = this->side;
|
||||
*pitch = this->pitch;
|
||||
*yaw = this->yaw;
|
||||
this->yaw = 0.f;
|
||||
this->pitch = 0.f;
|
||||
}
|
||||
|
||||
void CTouchControls::GetTouchDelta( float yaw, float pitch, float *dx, float *dy )
|
||||
{
|
||||
// Apply filtering?
|
||||
if( touch_filter.GetBool() )
|
||||
{
|
||||
// Average over last two samples
|
||||
*dx = ( yaw + m_flPreviousYaw ) * 0.5f;
|
||||
*dy = ( pitch + m_flPreviousPitch ) * 0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
*dx = yaw;
|
||||
*dy = pitch;
|
||||
}
|
||||
|
||||
// Latch previous
|
||||
m_flPreviousYaw = yaw;
|
||||
m_flPreviousPitch = pitch;
|
||||
}
|
||||
|
||||
void CTouchControls::ResetToDefaults()
|
||||
{
|
||||
rgba_t color(255, 255, 255, 155);
|
||||
@ -291,7 +323,7 @@ void CTouchControls::ResetToDefaults()
|
||||
else
|
||||
{
|
||||
Q_snprintf(buf, sizeof buf, "exec %s", TOUCH_DEFAULT_CFG);
|
||||
engine->ClientCmd_Unrestricted(buf);
|
||||
engine->ExecuteClientCmd(buf);
|
||||
}
|
||||
|
||||
WriteConfig();
|
||||
@ -307,7 +339,8 @@ void CTouchControls::Init()
|
||||
config_loaded = false;
|
||||
btns.EnsureCapacity( 64 );
|
||||
look_finger = move_finger = resize_finger = -1;
|
||||
forward = side = 0;
|
||||
forward = side = 0.f;
|
||||
pitch = yaw = 0.f;
|
||||
scolor = rgba_t( -1, -1, -1, -1 );
|
||||
state = state_none;
|
||||
swidth = 1;
|
||||
@ -317,6 +350,7 @@ void CTouchControls::Init()
|
||||
precision = false;
|
||||
mouse_events = 0;
|
||||
move_start_x = move_start_y = 0.0f;
|
||||
m_flPreviousYaw = m_flPreviousPitch = 0.f;
|
||||
|
||||
showtexture = hidetexture = resettexture = closetexture = joytexture = 0;
|
||||
configchanged = false;
|
||||
@ -344,12 +378,15 @@ void CTouchControls::Init()
|
||||
AddButton( "menu", "vgui/touch/menu", "gameui_activate", 0.000000, 0.00000, 0.080000, 0.142222, color );
|
||||
|
||||
char buf[256];
|
||||
Q_snprintf(buf, sizeof buf, "exec %s\n", touch_config_file.GetString());
|
||||
engine->ClientCmd_Unrestricted(buf);
|
||||
|
||||
Q_snprintf(buf, sizeof buf, "cfg/%s", touch_config_file.GetString());
|
||||
if( !filesystem->FileExists(buf) )
|
||||
WriteConfig();
|
||||
if( filesystem->FileExists(buf, "MOD") )
|
||||
{
|
||||
Q_snprintf(buf, sizeof buf, "exec %s\n", touch_config_file.GetString());
|
||||
engine->ClientCmd_Unrestricted(buf);
|
||||
}
|
||||
else
|
||||
ResetToDefaults();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
@ -405,32 +442,10 @@ void CTouchControls::IN_CheckCoords( float *x1, float *y1, float *x2, float *y2
|
||||
|
||||
void CTouchControls::Move( float /*frametime*/, CUserCmd *cmd )
|
||||
{
|
||||
cmd->sidemove -= cl_sidespeed.GetFloat() * side;
|
||||
cmd->forwardmove += cl_forwardspeed.GetFloat() * forward;
|
||||
}
|
||||
|
||||
void CTouchControls::IN_Look()
|
||||
{
|
||||
C_BasePlayer *pl = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
float diff = 1.0f;
|
||||
if( pl )
|
||||
{
|
||||
float def_fov = default_fov.GetFloat();
|
||||
float fov = pl->GetFOV();
|
||||
diff = fov/def_fov;
|
||||
}
|
||||
|
||||
if( !pitch && !yaw )
|
||||
return;
|
||||
|
||||
|
||||
QAngle ang;
|
||||
engine->GetViewAngles( ang );
|
||||
ang.x += pitch*diff;
|
||||
ang.y += yaw*diff;
|
||||
engine->SetViewAngles( ang );
|
||||
pitch = yaw = 0;
|
||||
}
|
||||
|
||||
void CTouchControls::Frame()
|
||||
@ -438,9 +453,7 @@ void CTouchControls::Frame()
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
IN_Look();
|
||||
|
||||
if( touch_enable.GetBool() && !enginevgui->IsGameUIVisible() ) Paint();
|
||||
if( touch_enable.GetBool() && touch_draw.GetBool() && !enginevgui->IsGameUIVisible() ) Paint();
|
||||
}
|
||||
|
||||
void CTouchControls::Paint( )
|
||||
@ -448,12 +461,11 @@ void CTouchControls::Paint( )
|
||||
if (!initialized)
|
||||
return;
|
||||
|
||||
|
||||
if( state == state_edit )
|
||||
{
|
||||
vgui::surface()->DrawSetColor(255, 0, 0, 200);
|
||||
float x,y;
|
||||
|
||||
|
||||
for( x = 0.0f; x < 1.0f; x += GRID_X )
|
||||
vgui::surface()->DrawLine( screen_w*x, 0, screen_w*x, screen_h );
|
||||
|
||||
@ -472,7 +484,7 @@ void CTouchControls::Paint( )
|
||||
vgui::surface()->DrawSetColor(btn->color.r, btn->color.g, btn->color.b, btn->color.a);
|
||||
vgui::surface()->DrawTexturedRect( btn->x1*screen_w, btn->y1*screen_h, btn->x2*screen_w, btn->y2*screen_h );
|
||||
}
|
||||
|
||||
|
||||
if( state == state_edit && !(btn->flags & TOUCH_FL_NOEDIT) )
|
||||
{
|
||||
vgui::surface()->DrawSetColor(255, 0, 0, 50);
|
||||
@ -694,8 +706,8 @@ void CTouchControls::FingerMotion(touch_event_t *ev) // finger in my ass
|
||||
}
|
||||
else if( btn->type == touch_look )
|
||||
{
|
||||
yaw -= touch_yaw.GetFloat() * ev->dx * sensitivity.GetFloat();
|
||||
pitch += touch_pitch.GetFloat() * ev->dy * sensitivity.GetFloat();
|
||||
yaw += ev->dx;
|
||||
pitch += ev->dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -707,7 +719,7 @@ void CTouchControls::FingerPress(touch_event_t *ev)
|
||||
const float y = ev->y;
|
||||
|
||||
CUtlLinkedList<CTouchButton*>::iterator it;
|
||||
|
||||
|
||||
if( ev->type == IE_FingerDown )
|
||||
{
|
||||
for( it = btns.begin(); it != btns.end(); it++ )
|
||||
@ -717,7 +729,7 @@ void CTouchControls::FingerPress(touch_event_t *ev)
|
||||
{
|
||||
if( btn->flags & TOUCH_FL_HIDE )
|
||||
continue;
|
||||
|
||||
|
||||
btn->finger = ev->fingerid;
|
||||
if( btn->type == touch_move )
|
||||
{
|
||||
|
@ -174,24 +174,25 @@ public:
|
||||
void SetCommand( const char *name, const char *cmd );
|
||||
void SetFlags( const char *name, int flags );
|
||||
void WriteConfig();
|
||||
|
||||
|
||||
void IN_CheckCoords( float *x1, float *y1, float *x2, float *y2 );
|
||||
void InitGrid();
|
||||
|
||||
|
||||
|
||||
void Move( float frametime, CUserCmd *cmd );
|
||||
void IN_Look( );
|
||||
|
||||
void ProcessEvent( touch_event_t *ev );
|
||||
void FingerPress( touch_event_t *ev );
|
||||
void FingerMotion( touch_event_t *ev );
|
||||
|
||||
void GetTouchAccumulators( float *forward, float *side, float *yaw, float *pitch );
|
||||
void GetTouchDelta( float yaw, float pitch, float *dx, float *dy );
|
||||
void EditEvent( touch_event_t *ev );
|
||||
|
||||
void EnableTouchEdit(bool enable);
|
||||
|
||||
|
||||
CTouchPanel *touchPanel;
|
||||
float screen_h, screen_w;
|
||||
float forward, side, movecount;
|
||||
float yaw, pitch;
|
||||
|
||||
private:
|
||||
bool initialized = false;
|
||||
@ -199,11 +200,10 @@ private:
|
||||
CUtlLinkedList<CTouchButton*> btns;
|
||||
|
||||
int look_finger, move_finger, wheel_finger;
|
||||
float forward, side, movecount;
|
||||
float yaw, pitch;
|
||||
CTouchButton *move_button;
|
||||
|
||||
float move_start_x, move_start_y;
|
||||
float m_flPreviousYaw, m_flPreviousPitch;
|
||||
|
||||
// editing
|
||||
CTouchButton *edit;
|
||||
|
@ -15,6 +15,7 @@ games = {
|
||||
'hl2': ['client_base.vpc', 'client_hl2.vpc'],
|
||||
'hl2mp': ['client_base.vpc', 'client_hl2mp.vpc'],
|
||||
'hl1': ['client_base.vpc', 'client_hl1.vpc'],
|
||||
'episodic': ['client_base.vpc', 'client_episodic.vpc'],
|
||||
'portal': ['client_base.vpc', 'client_portal.vpc'],
|
||||
'hl1mp': ['client_base.vpc', 'client_hl1.vpc'],
|
||||
'cstrike': ['client_base.vpc', 'client_cstrike.vpc'],
|
||||
@ -25,6 +26,8 @@ def configure(conf):
|
||||
game = conf.options.GAMES
|
||||
conf.env.GAMES = game
|
||||
|
||||
conf.env.append_unique('DEFINES', ['DISABLE_STEAM=1'])
|
||||
|
||||
if game not in games.keys():
|
||||
conf.fatal("Couldn't find game: ", game)
|
||||
|
||||
@ -66,7 +69,7 @@ def build(bld):
|
||||
if bld.env.DEST_OS != 'android':
|
||||
install_path += '/'+bld.env.GAMES+'/bin'
|
||||
|
||||
source = [ 'touch.cpp' ]
|
||||
source = [ 'touch.cpp', 'in_touch.cpp' ]
|
||||
|
||||
source += game["sources"]
|
||||
includes += game["includes"]
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "KeyValues.h"
|
||||
#include "OptionsSubKeyboard.h"
|
||||
#include "OptionsSubMouse.h"
|
||||
#include "OptionsSubTouch.h"
|
||||
#include "OptionsSubAudio.h"
|
||||
#include "OptionsSubVideo.h"
|
||||
#include "OptionsSubVoice.h"
|
||||
@ -53,7 +54,7 @@ COptionsDialog::COptionsDialog(vgui::Panel *parent) : PropertyDialog(parent, "Op
|
||||
w = scheme()->GetProportionalScaledValueEx(GetScheme(), w);
|
||||
h = scheme()->GetProportionalScaledValueEx(GetScheme(), h);
|
||||
}
|
||||
|
||||
|
||||
SetBounds(0, 0, w, h);
|
||||
|
||||
SetSizeable( false );
|
||||
@ -86,6 +87,10 @@ COptionsDialog::COptionsDialog(vgui::Panel *parent) : PropertyDialog(parent, "Op
|
||||
AddPage(new COptionsSubKeyboard(this), "#GameUI_Keyboard");
|
||||
AddPage(new COptionsSubMouse(this), "#GameUI_Mouse");
|
||||
|
||||
#ifdef ANDROID
|
||||
AddPage(new COptionsSubTouch(this), "Touch");
|
||||
#endif
|
||||
|
||||
m_pOptionsSubAudio = new COptionsSubAudio(this);
|
||||
AddPage(m_pOptionsSubAudio, "#GameUI_Audio");
|
||||
m_pOptionsSubVideo = new COptionsSubVideo(this);
|
||||
|
220
gameui/OptionsSubTouch.cpp
Normal file
220
gameui/OptionsSubTouch.cpp
Normal file
@ -0,0 +1,220 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//
|
||||
//=============================================================================//
|
||||
#include "OptionsSubTouch.h"
|
||||
//#include "CommandCheckButton.h"
|
||||
#include "KeyToggleCheckButton.h"
|
||||
#include "CvarNegateCheckButton.h"
|
||||
#include "CvarToggleCheckButton.h"
|
||||
#include "cvarslider.h"
|
||||
|
||||
#include "EngineInterface.h"
|
||||
|
||||
#include <KeyValues.h>
|
||||
#include <vgui/IScheme.h>
|
||||
#include "tier1/convar.h"
|
||||
#include <stdio.h>
|
||||
#include <vgui_controls/TextEntry.h>
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
using namespace vgui;
|
||||
|
||||
COptionsSubTouch::COptionsSubTouch(vgui::Panel *parent) : PropertyPage(parent, NULL)
|
||||
{
|
||||
m_pTouchEnableCheckBox = new CCvarToggleCheckButton(this,
|
||||
"EnableTouch",
|
||||
"Enable touch",
|
||||
"touch_enable");
|
||||
|
||||
m_pTouchDrawCheckBox = new CCvarToggleCheckButton(this,
|
||||
"DrawTouch",
|
||||
"Draw touch",
|
||||
"touch_draw");
|
||||
|
||||
m_pReverseTouchCheckBox = new CCvarToggleCheckButton(
|
||||
this,
|
||||
"ReverseTouch",
|
||||
"Reverse touch",
|
||||
"touch_reverse" );
|
||||
|
||||
m_pTouchFilterCheckBox = new CCvarToggleCheckButton(
|
||||
this,
|
||||
"TouchFilter",
|
||||
"Touch filter",
|
||||
"touch_filter" );
|
||||
|
||||
m_pTouchAccelerationCheckBox = new CCvarToggleCheckButton(
|
||||
this,
|
||||
"TouchAccelerationCheckbox",
|
||||
"Touch acceleration",
|
||||
"touch_enable_accel" );
|
||||
|
||||
m_pTouchSensitivitySlider = new CCvarSlider( this, "Slider", "Touch sensitivity",
|
||||
0.1f, 6.0f, "touch_sensitivity", true );
|
||||
|
||||
m_pTouchSensitivityLabel = new TextEntry(this, "SensitivityLabel");
|
||||
m_pTouchSensitivityLabel->AddActionSignalTarget(this);
|
||||
|
||||
m_pTouchAccelExponentSlider = new CCvarSlider( this, "TouchAccelerationSlider", "Touch acceleration",
|
||||
1.0f, 1.5f, "touch_accel", true );
|
||||
|
||||
m_pTouchAccelExponentLabel = new TextEntry(this, "TouchAccelerationLabel");
|
||||
m_pTouchAccelExponentLabel->AddActionSignalTarget(this);
|
||||
|
||||
m_pTouchYawSensitivitySlider = new CCvarSlider( this, "TouchYawSlider", "#GameUI_JoystickYawSensitivity",
|
||||
50.f, 300.f, "touch_yaw", true );
|
||||
m_pTouchYawSensitivityPreLabel = new Label(this, "TouchYawSensitivityPreLabel", "#GameUI_JoystickLookSpeedYaw" );
|
||||
m_pTouchYawSensitivityLabel = new TextEntry(this, "TouchYawSensitivityLabel");
|
||||
m_pTouchYawSensitivityLabel->AddActionSignalTarget(this);
|
||||
|
||||
m_pTouchPitchSensitivitySlider = new CCvarSlider( this, "TouchPitchSlider", "#GameUI_JoystickPitchSensitivity",
|
||||
50.f, 300.f, "touch_pitch", true );
|
||||
m_pTouchPitchSensitivityPreLabel = new Label(this, "TouchPitchSensitivityPreLabel", "#GameUI_JoystickLookSpeedPitch" );
|
||||
m_pTouchPitchSensitivityLabel = new TextEntry(this, "TouchPitchSensitivityLabel");
|
||||
m_pTouchPitchSensitivityLabel->AddActionSignalTarget(this);
|
||||
|
||||
LoadControlSettings("Resource\\OptionsSubTouch.res");
|
||||
|
||||
UpdateLabel(m_pTouchSensitivitySlider, m_pTouchSensitivityLabel);
|
||||
UpdateLabel(m_pTouchAccelExponentSlider, m_pTouchAccelExponentLabel);
|
||||
UpdateLabel(m_pTouchYawSensitivitySlider, m_pTouchYawSensitivityLabel);
|
||||
UpdateLabel(m_pTouchPitchSensitivitySlider, m_pTouchPitchSensitivityLabel);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
COptionsSubTouch::~COptionsSubTouch()
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubTouch::OnResetData()
|
||||
{
|
||||
m_pReverseTouchCheckBox->Reset();
|
||||
m_pTouchFilterCheckBox->Reset();
|
||||
m_pTouchSensitivitySlider->Reset();
|
||||
m_pTouchAccelExponentSlider->Reset();
|
||||
m_pTouchYawSensitivitySlider->Reset();
|
||||
m_pTouchPitchSensitivitySlider->Reset();
|
||||
m_pTouchAccelerationCheckBox->Reset();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubTouch::OnApplyChanges()
|
||||
{
|
||||
m_pReverseTouchCheckBox->ApplyChanges();
|
||||
m_pTouchFilterCheckBox->ApplyChanges();
|
||||
m_pTouchSensitivitySlider->ApplyChanges();
|
||||
m_pTouchAccelExponentSlider->ApplyChanges();
|
||||
m_pTouchYawSensitivitySlider->ApplyChanges();
|
||||
m_pTouchPitchSensitivitySlider->ApplyChanges();
|
||||
m_pTouchEnableCheckBox->ApplyChanges();
|
||||
m_pTouchDrawCheckBox->ApplyChanges();
|
||||
m_pTouchAccelerationCheckBox->ApplyChanges();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: sets background color & border
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubTouch::ApplySchemeSettings(IScheme *pScheme)
|
||||
{
|
||||
BaseClass::ApplySchemeSettings(pScheme);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubTouch::OnControlModified(Panel *panel)
|
||||
{
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
|
||||
// the HasBeenModified() check is so that if the value is outside of the range of the
|
||||
// slider, it won't use the slider to determine the display value but leave the
|
||||
// real value that we determined in the constructor
|
||||
if (panel == m_pTouchSensitivitySlider && m_pTouchSensitivitySlider->HasBeenModified())
|
||||
UpdateLabel( m_pTouchSensitivitySlider, m_pTouchSensitivityLabel );
|
||||
else if (panel == m_pTouchAccelExponentSlider && m_pTouchAccelExponentSlider->HasBeenModified())
|
||||
UpdateLabel( m_pTouchAccelExponentSlider, m_pTouchAccelExponentLabel );
|
||||
else if (panel == m_pTouchYawSensitivitySlider && m_pTouchYawSensitivitySlider->HasBeenModified())
|
||||
UpdateLabel( m_pTouchYawSensitivitySlider, m_pTouchYawSensitivityLabel );
|
||||
else if (panel == m_pTouchPitchSensitivitySlider && m_pTouchPitchSensitivitySlider->HasBeenModified())
|
||||
UpdateLabel( m_pTouchPitchSensitivitySlider, m_pTouchPitchSensitivityLabel );
|
||||
else if (panel == m_pTouchAccelerationCheckBox)
|
||||
{
|
||||
m_pTouchAccelExponentSlider->SetEnabled(m_pTouchAccelerationCheckBox->IsSelected());
|
||||
m_pTouchAccelExponentLabel->SetEnabled(m_pTouchAccelerationCheckBox->IsSelected());
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void COptionsSubTouch::OnTextChanged(Panel *panel)
|
||||
{
|
||||
if ( panel == m_pTouchSensitivityLabel )
|
||||
{
|
||||
char buf[64];
|
||||
m_pTouchSensitivityLabel->GetText(buf, 64);
|
||||
|
||||
float fValue;
|
||||
int numParsed = sscanf(buf, "%f", &fValue);
|
||||
if ( ( numParsed == 1 ) && ( fValue >= 0.0f ) )
|
||||
{
|
||||
m_pTouchSensitivitySlider->SetSliderValue(fValue);
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
}
|
||||
}
|
||||
else if ( panel == m_pTouchAccelExponentLabel )
|
||||
{
|
||||
char buf[64];
|
||||
m_pTouchAccelExponentLabel->GetText(buf, 64);
|
||||
|
||||
float fValue = (float) atof(buf);
|
||||
if (fValue >= 1.0)
|
||||
{
|
||||
m_pTouchAccelExponentSlider->SetSliderValue(fValue);
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
}
|
||||
}
|
||||
else if( panel == m_pTouchPitchSensitivityLabel )
|
||||
{
|
||||
char buf[64];
|
||||
m_pTouchPitchSensitivityLabel->GetText(buf, 64);
|
||||
|
||||
float fValue = (float) atof(buf);
|
||||
if (fValue >= 1.0)
|
||||
{
|
||||
m_pTouchPitchSensitivitySlider->SetSliderValue(fValue);
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
}
|
||||
}
|
||||
else if( panel == m_pTouchYawSensitivityLabel )
|
||||
{
|
||||
char buf[64];
|
||||
m_pTouchYawSensitivityLabel->GetText(buf, 64);
|
||||
|
||||
float fValue = (float) atof(buf);
|
||||
if (fValue >= 1.0)
|
||||
{
|
||||
m_pTouchYawSensitivitySlider->SetSliderValue(fValue);
|
||||
PostActionSignal(new KeyValues("ApplyButtonEnable"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void COptionsSubTouch::UpdateLabel(CCvarSlider *slider, vgui::TextEntry *label)
|
||||
{
|
||||
char buf[64];
|
||||
Q_snprintf(buf, sizeof( buf ), " %.2f", slider->GetSliderValue());
|
||||
label->SetText(buf);
|
||||
}
|
81
gameui/OptionsSubTouch.h
Normal file
81
gameui/OptionsSubTouch.h
Normal file
@ -0,0 +1,81 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef OPTIONS_SUB_TOUCH_H
|
||||
#define OPTIONS_SUB_TOUCH_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <vgui_controls/PropertyPage.h>
|
||||
|
||||
class CCvarNegateCheckButton;
|
||||
class CKeyToggleCheckButton;
|
||||
class CCvarToggleCheckButton;
|
||||
class CCvarSlider;
|
||||
|
||||
namespace vgui
|
||||
{
|
||||
class Label;
|
||||
class Panel;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Touch Details, Part of OptionsDialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class COptionsSubTouch : public vgui::PropertyPage
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( COptionsSubTouch, vgui::PropertyPage );
|
||||
|
||||
public:
|
||||
COptionsSubTouch(vgui::Panel *parent);
|
||||
~COptionsSubTouch();
|
||||
|
||||
virtual void OnResetData();
|
||||
virtual void OnApplyChanges();
|
||||
|
||||
protected:
|
||||
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
|
||||
|
||||
MESSAGE_FUNC_PTR( OnControlModified, "ControlModified", panel );
|
||||
MESSAGE_FUNC_PTR( OnTextChanged, "TextChanged", panel );
|
||||
MESSAGE_FUNC_PTR( OnCheckButtonChecked, "CheckButtonChecked", panel )
|
||||
{
|
||||
OnControlModified( panel );
|
||||
}
|
||||
|
||||
void UpdateLabel(CCvarSlider *slider, vgui::TextEntry *label);
|
||||
private:
|
||||
CCvarToggleCheckButton *m_pReverseTouchCheckBox;
|
||||
CCvarToggleCheckButton *m_pTouchFilterCheckBox;
|
||||
CCvarToggleCheckButton *m_pTouchRawCheckBox;
|
||||
CCvarToggleCheckButton *m_pTouchAccelerationCheckBox;
|
||||
|
||||
CCvarToggleCheckButton *m_pTouchCheckBox;
|
||||
CCvarToggleCheckButton *m_pTouchSouthpawCheckBox;
|
||||
CCvarToggleCheckButton *m_pQuickInfoCheckBox;
|
||||
CCvarToggleCheckButton *m_pTouchEnableCheckBox;
|
||||
CCvarToggleCheckButton *m_pTouchDrawCheckBox;
|
||||
|
||||
CCvarSlider *m_pTouchSensitivitySlider;
|
||||
vgui::TextEntry *m_pTouchSensitivityLabel;
|
||||
|
||||
CCvarSlider *m_pTouchAccelExponentSlider;
|
||||
vgui::TextEntry *m_pTouchAccelExponentLabel;
|
||||
|
||||
CCvarSlider *m_pTouchYawSensitivitySlider;
|
||||
vgui::Label *m_pTouchYawSensitivityPreLabel;
|
||||
CCvarSlider *m_pTouchPitchSensitivitySlider;
|
||||
vgui::Label *m_pTouchPitchSensitivityPreLabel;
|
||||
vgui::TextEntry *m_pTouchYawSensitivityLabel;
|
||||
vgui::TextEntry *m_pTouchPitchSensitivityLabel;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // OPTIONS_SUB_TOUCH_H
|
@ -91,6 +91,7 @@ def build(bld):
|
||||
#'OptionsSubHaptics.cpp', [$WIN32] [$WIN32]
|
||||
'OptionsSubKeyboard.cpp',
|
||||
'OptionsSubMouse.cpp',
|
||||
'OptionsSubTouch.cpp',
|
||||
'OptionsSubMultiplayer.cpp',
|
||||
'OptionsSubPortal.cpp',
|
||||
'OptionsSubVideo.cpp',
|
||||
|
@ -113,7 +113,6 @@ void SetLauncherArgs()
|
||||
LogPrintf(binPath);
|
||||
D(binPath);
|
||||
|
||||
D("-console");
|
||||
D("-nouserclip");
|
||||
|
||||
parseArgs(java_args);
|
||||
|
Loading…
Reference in New Issue
Block a user