mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Allow changing jump height and fov again.
This commit is contained in:
parent
619a713ae7
commit
5e5ee2a1cd
@ -115,7 +115,7 @@ namespace ClassicalSharp {
|
||||
lastZoomFov = game.ZoomFieldOfView;
|
||||
int index = 0;
|
||||
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 " )
|
||||
.AppendNum( ref index, lastZoomFov ).Append( ref index, " " );
|
||||
|
@ -32,6 +32,10 @@ namespace ClassicalSharp {
|
||||
(g, v) => { g.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
|
||||
Make( 140, -100, "Liquids breakable", OnWidgetClick,
|
||||
g => g.LiquidsBreakable ? "yes" : "no",
|
||||
@ -39,21 +43,16 @@ namespace ClassicalSharp {
|
||||
Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ),
|
||||
|
||||
Make( 140, -50, "Pushback placing", OnWidgetClick,
|
||||
g => g.LocalPlayer.PushbackPlacing
|
||||
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",
|
||||
(g, v) => {
|
||||
if( g.LocalPlayer.CanPushbackBlocks) {
|
||||
g.LocalPlayer.PushbackPlacing = v == "yes";
|
||||
Options.Set( OptionsKey.PushbackPlacing, v == "yes" );
|
||||
}
|
||||
}),
|
||||
g => g.LocalPlayer.PushbackPlacing ? "yes" : "no",
|
||||
(g, v) => { g.LocalPlayer.PushbackPlacing = v == "yes";
|
||||
Options.Set( OptionsKey.PushbackPlacing, v == "yes" ); }),
|
||||
|
||||
Make( 140, 0, "Noclip slide", OnWidgetClick,
|
||||
g => g.LocalPlayer.NoclipSlide ? "yes" : "no",
|
||||
(g, v) => { g.LocalPlayer.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, v) => { g.FieldOfView = Int32.Parse( v );
|
||||
Options.Set( OptionsKey.FieldOfView, v );
|
||||
@ -69,13 +68,26 @@ namespace ClassicalSharp {
|
||||
new BooleanValidator(),
|
||||
new RealValidator( 0.1f, 50 ),
|
||||
new BooleanValidator(),
|
||||
new RealValidator( 0.1f, 1024f ),
|
||||
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new IntegerValidator( 1, 179 ),
|
||||
new IntegerValidator( 1, 150 ),
|
||||
};
|
||||
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,
|
||||
@ -86,5 +98,10 @@ namespace ClassicalSharp {
|
||||
widget.SetValue = setter;
|
||||
return widget;
|
||||
}
|
||||
|
||||
public override void Dispose() {
|
||||
base.Dispose();
|
||||
game.Events.HackPermissionsChanged -= CheckHacksAllowed;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,6 +15,11 @@ namespace ClassicalSharp {
|
||||
|
||||
buttons = new ButtonWidget[] {
|
||||
// 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,
|
||||
g => g.UseSound ? "yes" : "no",
|
||||
(g, v) => { g.UseSound = v == "yes";
|
||||
@ -80,10 +85,11 @@ namespace ClassicalSharp {
|
||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||
null,
|
||||
};
|
||||
buttons[2].Metadata = typeof(NameMode);
|
||||
buttons[3].Metadata = typeof(FpsLimitMethod);
|
||||
buttons[3].Metadata = typeof(NameMode);
|
||||
buttons[4].Metadata = typeof(FpsLimitMethod);
|
||||
|
||||
validators = new MenuInputValidator[] {
|
||||
network.IsSinglePlayer ? new RealValidator(1, 1024) : null,
|
||||
new BooleanValidator(),
|
||||
new BooleanValidator(),
|
||||
new EnumValidator(),
|
||||
|
@ -61,7 +61,6 @@ namespace ClassicalSharp {
|
||||
buttons[i].Disabled = false;
|
||||
}
|
||||
if( !game.LocalPlayer.CanAnyHacks ) {
|
||||
buttons[2].Disabled = true; // hack permissions
|
||||
buttons[3].Disabled = true; // env settings
|
||||
buttons[8].Disabled = true; // select texture pack
|
||||
}
|
||||
|
@ -91,14 +91,12 @@ namespace ClassicalSharp.Commands {
|
||||
game.Chat.Add( "Currently not targeting a block" );
|
||||
} else {
|
||||
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" ) ) {
|
||||
game.Chat.Add( "map width: " + game.Map.Width );
|
||||
game.Chat.Add( "map height: " + game.Map.Height );
|
||||
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 {
|
||||
game.Chat.Add( "&e/client info: Unrecognised property: \"&f" + property + "&e\"." );
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace ClassicalSharp {
|
||||
/// <summary> Whether the player should slide after letting go of movement buttons in noclip. </summary>
|
||||
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/>
|
||||
/// Note that when speeding is enabled the client is able to jump much further. </summary>
|
||||
public float JumpHeight {
|
||||
@ -72,7 +72,7 @@ namespace ClassicalSharp {
|
||||
|
||||
SpeedMultiplier = Options.GetFloat( OptionsKey.Speed, 0.1f, 50, 7 );
|
||||
PushbackPlacing = Options.GetBool( OptionsKey.PushbackPlacing, false );
|
||||
NoclipSlide = Options.GetBool( OptionsKey.NoclipSlide, true );
|
||||
NoclipSlide = Options.GetBool( OptionsKey.NoclipSlide, false );
|
||||
InitRenderingData();
|
||||
}
|
||||
|
||||
@ -249,12 +249,8 @@ namespace ClassicalSharp {
|
||||
|
||||
if( !CanUseThirdPersonCamera || !HacksEnabled )
|
||||
game.CycleCamera();
|
||||
if( !HacksEnabled || !CanAnyHacks || !CanUseThirdPersonCamera ) {
|
||||
game.FieldOfView = 70;
|
||||
int max = Options.GetInt( OptionsKey.FieldOfView, 1, 179, 70 );
|
||||
game.ZoomFieldOfView = max;
|
||||
game.UpdateProjection();
|
||||
}
|
||||
if( !HacksEnabled || !CanAnyHacks || !CanSpeed )
|
||||
jumpVel = serverJumpVel;
|
||||
}
|
||||
|
||||
/// <summary> Sets the user type of this user. This is used to control permissions for grass,
|
||||
|
@ -98,7 +98,7 @@ namespace ClassicalSharp {
|
||||
thirdPersonCam = new ThirdPersonCamera( this );
|
||||
forwardThirdPersonCam = new ForwardThirdPersonCamera( this );
|
||||
Camera = firstPersonCam;
|
||||
FieldOfView = Options.GetInt( OptionsKey.FieldOfView, 1, 179, 70 );
|
||||
FieldOfView = Options.GetInt( OptionsKey.FieldOfView, 1, 150, 70 );
|
||||
ZoomFieldOfView = FieldOfView;
|
||||
UpdateProjection();
|
||||
CommandManager = new CommandManager();
|
||||
|
@ -388,7 +388,7 @@ namespace ClassicalSharp {
|
||||
|
||||
if( fovIndex == -1 ) fovIndex = game.ZoomFieldOfView;
|
||||
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 );
|
||||
|
||||
game.FieldOfView = (int)fovIndex;
|
||||
|
@ -377,6 +377,7 @@ namespace ClassicalSharp {
|
||||
float jumpHeight = reader.ReadInt16() / 32f;
|
||||
if( jumpHeight < 0 ) jumpHeight = 1.4f;
|
||||
p.CalculateJumpVelocity( jumpHeight );
|
||||
p.serverJumpVel = p.jumpVel;
|
||||
game.Events.RaiseHackPermissionsChanged();
|
||||
}
|
||||
|
||||
|
@ -132,6 +132,7 @@ namespace ClassicalSharp {
|
||||
if( opcode == 0xFF && lastOpcode == PacketId.CpeHackControl ) {
|
||||
reader.Remove( 1 );
|
||||
game.LocalPlayer.CalculateJumpVelocity( 1.4f ); // assume default jump height
|
||||
game.LocalPlayer.serverJumpVel = game.LocalPlayer.jumpVel;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user