Allow changing jump height and fov again.

This commit is contained in:
UnknownShadow200 2016-01-02 22:51:38 +11:00
parent 619a713ae7
commit 5e5ee2a1cd
10 changed files with 45 additions and 27 deletions

View File

@ -115,7 +115,7 @@ namespace ClassicalSharp {
lastZoomFov = game.ZoomFieldOfView; lastZoomFov = game.ZoomFieldOfView;
int index = 0; int index = 0;
text.Clear(); text.Clear();
int defFov = Options.GetInt( OptionsKey.FieldOfView, 1, 179, 70 ); int defFov = Options.GetInt( OptionsKey.FieldOfView, 1, 150, 70 );
if( lastZoomFov != defFov ) text.Append( ref index, "Zoom fov " ) if( lastZoomFov != defFov ) text.Append( ref index, "Zoom fov " )
.AppendNum( ref index, lastZoomFov ).Append( ref index, " " ); .AppendNum( ref index, lastZoomFov ).Append( ref index, " " );

View File

@ -32,6 +32,10 @@ namespace ClassicalSharp {
(g, v) => { g.CameraClipping = v == "yes"; (g, v) => { g.CameraClipping = v == "yes";
Options.Set( OptionsKey.CameraClipping, v == "yes" ); } ), Options.Set( OptionsKey.CameraClipping, v == "yes" ); } ),
Make( -140, 50, "Jump height", OnWidgetClick,
g => g.LocalPlayer.JumpHeight.ToString(),
(g, v) => g.LocalPlayer.CalculateJumpVelocity( Single.Parse( v ) ) ),
// Column 2 // Column 2
Make( 140, -100, "Liquids breakable", OnWidgetClick, Make( 140, -100, "Liquids breakable", OnWidgetClick,
g => g.LiquidsBreakable ? "yes" : "no", g => g.LiquidsBreakable ? "yes" : "no",
@ -39,21 +43,16 @@ namespace ClassicalSharp {
Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ), Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ),
Make( 140, -50, "Pushback placing", OnWidgetClick, Make( 140, -50, "Pushback placing", OnWidgetClick,
g => g.LocalPlayer.PushbackPlacing g => g.LocalPlayer.PushbackPlacing ? "yes" : "no",
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no", (g, v) => { g.LocalPlayer.PushbackPlacing = v == "yes";
(g, v) => { Options.Set( OptionsKey.PushbackPlacing, v == "yes" ); }),
if( g.LocalPlayer.CanPushbackBlocks) {
g.LocalPlayer.PushbackPlacing = v == "yes";
Options.Set( OptionsKey.PushbackPlacing, v == "yes" );
}
}),
Make( 140, 0, "Noclip slide", OnWidgetClick, Make( 140, 0, "Noclip slide", OnWidgetClick,
g => g.LocalPlayer.NoclipSlide ? "yes" : "no", g => g.LocalPlayer.NoclipSlide ? "yes" : "no",
(g, v) => { g.LocalPlayer.NoclipSlide = v == "yes"; (g, v) => { g.LocalPlayer.NoclipSlide = v == "yes";
Options.Set( OptionsKey.NoclipSlide, v == "yes" ); } ), Options.Set( OptionsKey.NoclipSlide, v == "yes" ); } ),
Make( -140, 50, "Field of view", OnWidgetClick, Make( 140, 50, "Field of view", OnWidgetClick,
g => g.FieldOfView.ToString(), g => g.FieldOfView.ToString(),
(g, v) => { g.FieldOfView = Int32.Parse( v ); (g, v) => { g.FieldOfView = Int32.Parse( v );
Options.Set( OptionsKey.FieldOfView, v ); Options.Set( OptionsKey.FieldOfView, v );
@ -69,13 +68,26 @@ namespace ClassicalSharp {
new BooleanValidator(), new BooleanValidator(),
new RealValidator( 0.1f, 50 ), new RealValidator( 0.1f, 50 ),
new BooleanValidator(), new BooleanValidator(),
new RealValidator( 0.1f, 1024f ),
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new IntegerValidator( 1, 179 ), new IntegerValidator( 1, 150 ),
}; };
okayIndex = buttons.Length - 1; okayIndex = buttons.Length - 1;
game.Events.HackPermissionsChanged += CheckHacksAllowed;
}
void CheckHacksAllowed( object sender, EventArgs e ) {
for( int i = 0; i < buttons.Length; i++ ) {
if( buttons[i] == null ) continue;
buttons[i].Disabled = false;
}
LocalPlayer p = game.LocalPlayer;
bool globalHacks = p.CanAnyHacks && p.HacksEnabled;
buttons[3].Disabled = !globalHacks || !p.CanSpeed;
buttons[5].Disabled = !globalHacks || !p.CanPushbackBlocks;
} }
ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick, ButtonWidget Make( int x, int y, string text, Action<Game, Widget> onClick,
@ -86,5 +98,10 @@ namespace ClassicalSharp {
widget.SetValue = setter; widget.SetValue = setter;
return widget; return widget;
} }
public override void Dispose() {
base.Dispose();
game.Events.HackPermissionsChanged -= CheckHacksAllowed;
}
} }
} }

View File

@ -15,6 +15,11 @@ namespace ClassicalSharp {
buttons = new ButtonWidget[] { buttons = new ButtonWidget[] {
// Column 1 // Column 1
!network.IsSinglePlayer ? null :
Make( -140, -200, "Click distance", OnWidgetClick,
g => g.LocalPlayer.ReachDistance.ToString(),
(g, v) => g.LocalPlayer.ReachDistance = Single.Parse( v ) ),
Make( -140, -150, "Use sound", OnWidgetClick, Make( -140, -150, "Use sound", OnWidgetClick,
g => g.UseSound ? "yes" : "no", g => g.UseSound ? "yes" : "no",
(g, v) => { g.UseSound = v == "yes"; (g, v) => { g.UseSound = v == "yes";
@ -80,10 +85,11 @@ namespace ClassicalSharp {
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
null, null,
}; };
buttons[2].Metadata = typeof(NameMode); buttons[3].Metadata = typeof(NameMode);
buttons[3].Metadata = typeof(FpsLimitMethod); buttons[4].Metadata = typeof(FpsLimitMethod);
validators = new MenuInputValidator[] { validators = new MenuInputValidator[] {
network.IsSinglePlayer ? new RealValidator(1, 1024) : null,
new BooleanValidator(), new BooleanValidator(),
new BooleanValidator(), new BooleanValidator(),
new EnumValidator(), new EnumValidator(),

View File

@ -61,7 +61,6 @@ namespace ClassicalSharp {
buttons[i].Disabled = false; buttons[i].Disabled = false;
} }
if( !game.LocalPlayer.CanAnyHacks ) { if( !game.LocalPlayer.CanAnyHacks ) {
buttons[2].Disabled = true; // hack permissions
buttons[3].Disabled = true; // env settings buttons[3].Disabled = true; // env settings
buttons[8].Disabled = true; // select texture pack buttons[8].Disabled = true; // select texture pack
} }

View File

@ -91,14 +91,12 @@ namespace ClassicalSharp.Commands {
game.Chat.Add( "Currently not targeting a block" ); game.Chat.Add( "Currently not targeting a block" );
} else { } else {
game.Chat.Add( "Currently targeting at: " + pos.BlockPos ); game.Chat.Add( "Currently targeting at: " + pos.BlockPos );
game.Chat.Add( "ID of block targeted: " + game.Map.SafeGetBlock( pos.BlockPos ) );
} }
} else if( Utils.CaselessEquals( property, "dimensions" ) ) { } else if( Utils.CaselessEquals( property, "dimensions" ) ) {
game.Chat.Add( "map width: " + game.Map.Width ); game.Chat.Add( "map width: " + game.Map.Width );
game.Chat.Add( "map height: " + game.Map.Height ); game.Chat.Add( "map height: " + game.Map.Height );
game.Chat.Add( "map length: " + game.Map.Length ); game.Chat.Add( "map length: " + game.Map.Length );
} else if( Utils.CaselessEquals( property, "jumpheight" ) ) {
float jumpHeight = game.LocalPlayer.JumpHeight;
game.Chat.Add( jumpHeight.ToString( "F2" ) + " blocks" );
} else { } else {
game.Chat.Add( "&e/client info: Unrecognised property: \"&f" + property + "&e\"." ); game.Chat.Add( "&e/client info: Unrecognised property: \"&f" + property + "&e\"." );
} }

View File

@ -56,7 +56,7 @@ namespace ClassicalSharp {
/// <summary> Whether the player should slide after letting go of movement buttons in noclip. </summary> /// <summary> Whether the player should slide after letting go of movement buttons in noclip. </summary>
public bool NoclipSlide = true; public bool NoclipSlide = true;
float jumpVel = 0.42f; internal float jumpVel = 0.42f, serverJumpVel = 0.42f;
/// <summary> Returns the height that the client can currently jump up to.<br/> /// <summary> Returns the height that the client can currently jump up to.<br/>
/// Note that when speeding is enabled the client is able to jump much further. </summary> /// Note that when speeding is enabled the client is able to jump much further. </summary>
public float JumpHeight { public float JumpHeight {
@ -72,7 +72,7 @@ namespace ClassicalSharp {
SpeedMultiplier = Options.GetFloat( OptionsKey.Speed, 0.1f, 50, 7 ); SpeedMultiplier = Options.GetFloat( OptionsKey.Speed, 0.1f, 50, 7 );
PushbackPlacing = Options.GetBool( OptionsKey.PushbackPlacing, false ); PushbackPlacing = Options.GetBool( OptionsKey.PushbackPlacing, false );
NoclipSlide = Options.GetBool( OptionsKey.NoclipSlide, true ); NoclipSlide = Options.GetBool( OptionsKey.NoclipSlide, false );
InitRenderingData(); InitRenderingData();
} }
@ -249,12 +249,8 @@ namespace ClassicalSharp {
if( !CanUseThirdPersonCamera || !HacksEnabled ) if( !CanUseThirdPersonCamera || !HacksEnabled )
game.CycleCamera(); game.CycleCamera();
if( !HacksEnabled || !CanAnyHacks || !CanUseThirdPersonCamera ) { if( !HacksEnabled || !CanAnyHacks || !CanSpeed )
game.FieldOfView = 70; jumpVel = serverJumpVel;
int max = Options.GetInt( OptionsKey.FieldOfView, 1, 179, 70 );
game.ZoomFieldOfView = max;
game.UpdateProjection();
}
} }
/// <summary> Sets the user type of this user. This is used to control permissions for grass, /// <summary> Sets the user type of this user. This is used to control permissions for grass,

View File

@ -98,7 +98,7 @@ namespace ClassicalSharp {
thirdPersonCam = new ThirdPersonCamera( this ); thirdPersonCam = new ThirdPersonCamera( this );
forwardThirdPersonCam = new ForwardThirdPersonCamera( this ); forwardThirdPersonCam = new ForwardThirdPersonCamera( this );
Camera = firstPersonCam; Camera = firstPersonCam;
FieldOfView = Options.GetInt( OptionsKey.FieldOfView, 1, 179, 70 ); FieldOfView = Options.GetInt( OptionsKey.FieldOfView, 1, 150, 70 );
ZoomFieldOfView = FieldOfView; ZoomFieldOfView = FieldOfView;
UpdateProjection(); UpdateProjection();
CommandManager = new CommandManager(); CommandManager = new CommandManager();

View File

@ -388,7 +388,7 @@ namespace ClassicalSharp {
if( fovIndex == -1 ) fovIndex = game.ZoomFieldOfView; if( fovIndex == -1 ) fovIndex = game.ZoomFieldOfView;
fovIndex -= e.DeltaPrecise * 5; fovIndex -= e.DeltaPrecise * 5;
int max = Options.GetInt( OptionsKey.FieldOfView, 1, 179, 70 ); int max = Options.GetInt( OptionsKey.FieldOfView, 1, 150, 70 );
Utils.Clamp( ref fovIndex, 1, max ); Utils.Clamp( ref fovIndex, 1, max );
game.FieldOfView = (int)fovIndex; game.FieldOfView = (int)fovIndex;

View File

@ -377,6 +377,7 @@ namespace ClassicalSharp {
float jumpHeight = reader.ReadInt16() / 32f; float jumpHeight = reader.ReadInt16() / 32f;
if( jumpHeight < 0 ) jumpHeight = 1.4f; if( jumpHeight < 0 ) jumpHeight = 1.4f;
p.CalculateJumpVelocity( jumpHeight ); p.CalculateJumpVelocity( jumpHeight );
p.serverJumpVel = p.jumpVel;
game.Events.RaiseHackPermissionsChanged(); game.Events.RaiseHackPermissionsChanged();
} }

View File

@ -132,6 +132,7 @@ namespace ClassicalSharp {
if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) { if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) {
reader.Remove( 1 ); reader.Remove( 1 );
game.LocalPlayer.CalculateJumpVelocity( 1.4f ); // assume default jump height game.LocalPlayer.CalculateJumpVelocity( 1.4f ); // assume default jump height
game.LocalPlayer.serverJumpVel = game.LocalPlayer.jumpVel;
continue; continue;
} }