diff --git a/src/game/client/view.cpp b/src/game/client/view.cpp index de0c0b07a4b..db56837b94a 100644 --- a/src/game/client/view.cpp +++ b/src/game/client/view.cpp @@ -45,6 +45,8 @@ #include "ScreenSpaceEffects.h" #include "sourcevr/isourcevirtualreality.h" #include "client_virtualreality.h" +#include "fmtstr.h" +#include "vgui/ISystem.h" #if defined( REPLAY_ENABLED ) #include "replay/ireplaysystem.h" @@ -1275,30 +1277,46 @@ static void GetPos( const CCommand &args, Vector &vecOrigin, QAngle &angles ) } } -CON_COMMAND( spec_pos, "dump position and angles to the console" ) +CON_COMMAND( spec_pos, "dump position and angles to the console ( 1 = to clipboard )" ) { Vector vecOrigin; QAngle angles; GetPos( args, vecOrigin, angles ); - Warning( "spec_goto %.1f %.1f %.1f %.1f %.1f\n", vecOrigin.x, vecOrigin.y, - vecOrigin.z, angles.x, angles.y ); + + bool bClip = ( args.ArgC() >= 2 && Q_atoi( args[ 1 ] ) == 1 ); + + CFmtStr fmtCommand( + "spec_goto %.1f %.1f %.1f %.1f %.1f", + vecOrigin.x, vecOrigin.y, vecOrigin.z, angles.x, angles.y + ); + + Warning( "%s\n", fmtCommand.String() ); + if ( bClip ) + { + vgui::system()->SetClipboardText( fmtCommand.String(), fmtCommand.Length() ); + } } -CON_COMMAND( getpos, "dump position and angles to the console" ) +CON_COMMAND( getpos, "dump position and angles to the console ( 1 = to clipboard, 2 = exact pos, 3 = all )" ) { Vector vecOrigin; QAngle angles; GetPos( args, vecOrigin, angles ); - const char *pCommand1 = "setpos"; - const char *pCommand2 = "setang"; - if ( args.ArgC() == 2 && atoi( args[1] ) == 2 ) + int nParm = ( args.ArgC() >= 2 ) ? Q_atoi( args[ 1 ] ) : 0; + bool bClip = ( nParm == 1 || nParm == 3 ); + bool bExact = ( nParm == 2 || nParm == 3 ); + + CFmtStr fmtCommand( + "%s %f %f %f;%s %f %f %f", + bExact ? "setpos_exact" : "setpos", vecOrigin.x, vecOrigin.y, vecOrigin.z, + bExact ? "setang_exact" : "setang", angles.x, angles.y, angles.z + ); + + Warning( "%s\n", fmtCommand.String() ); + if ( bClip ) { - pCommand1 = "setpos_exact"; - pCommand2 = "setang_exact"; + vgui::system()->SetClipboardText( fmtCommand.String(), fmtCommand.Length() ); } - - Warning( "%s %f %f %f;", pCommand1, vecOrigin.x, vecOrigin.y, vecOrigin.z ); - Warning( "%s %f %f %f\n", pCommand2, angles.x, angles.y, angles.z ); }