mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Add option to disable all hacks, move hacks settings to their own screen.
This commit is contained in:
parent
c33e5e05c4
commit
86a7b49c08
70
ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs
Normal file
70
ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using ClassicalSharp.Singleplayer;
|
||||||
|
|
||||||
|
namespace ClassicalSharp {
|
||||||
|
|
||||||
|
public class HacksSettingsScreen : MenuInputScreen {
|
||||||
|
|
||||||
|
public HacksSettingsScreen( Game game ) : base( game ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Init() {
|
||||||
|
base.Init();
|
||||||
|
INetworkProcessor network = game.Network;
|
||||||
|
|
||||||
|
buttons = new ButtonWidget[] {
|
||||||
|
// Column 1
|
||||||
|
Make( -140, -100, "Hacks enabled", Anchor.Centre, OnWidgetClick,
|
||||||
|
g => g.LocalPlayer.HacksEnabled ? "yes" : "no",
|
||||||
|
(g, v) => { g.LocalPlayer.HacksEnabled = v == "yes";
|
||||||
|
Options.Set( OptionsKey.HacksEnabled, v == "yes" );
|
||||||
|
g.LocalPlayer.CheckHacksConsistency();
|
||||||
|
} ),
|
||||||
|
|
||||||
|
Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
||||||
|
g => g.LocalPlayer.SpeedMultiplier.ToString(),
|
||||||
|
(g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v );
|
||||||
|
Options.Set( OptionsKey.Speed, v ); } ),
|
||||||
|
|
||||||
|
// Column 2
|
||||||
|
Make( 140, -100, "Liquids breakable", Anchor.Centre, OnWidgetClick,
|
||||||
|
g => g.LiquidsBreakable ? "yes" : "no",
|
||||||
|
(g, v) => { g.LiquidsBreakable = v == "yes";
|
||||||
|
Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ),
|
||||||
|
|
||||||
|
Make( 140, -50, "Pushback placing", Anchor.Centre, 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" );
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
MakeBack( false, titleFont,
|
||||||
|
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||||
|
null,
|
||||||
|
};
|
||||||
|
|
||||||
|
validators = new MenuInputValidator[] {
|
||||||
|
new BooleanValidator(),
|
||||||
|
new RealValidator( 0.1f, 50 ),
|
||||||
|
|
||||||
|
new BooleanValidator(),
|
||||||
|
new BooleanValidator(),
|
||||||
|
};
|
||||||
|
okayIndex = buttons.Length - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick,
|
||||||
|
Func<Game, string> getter, Action<Game, string> setter ) {
|
||||||
|
ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text,
|
||||||
|
Anchor.Centre, vDocking, titleFont, onClick );
|
||||||
|
widget.GetValue = getter;
|
||||||
|
widget.SetValue = setter;
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,27 +15,18 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
buttons = new ButtonWidget[] {
|
buttons = new ButtonWidget[] {
|
||||||
// Column 1
|
// Column 1
|
||||||
Make( -140, -200, "Liquids breakable", Anchor.Centre, OnWidgetClick,
|
|
||||||
g => g.LiquidsBreakable ? "yes" : "no",
|
|
||||||
(g, v) => { g.LiquidsBreakable = v == "yes";
|
|
||||||
Options.Set( OptionsKey.LiquidsBreakable, v == "yes" ); } ),
|
|
||||||
|
|
||||||
Make( -140, -150, "Use sound (WIP)", Anchor.Centre, OnWidgetClick,
|
Make( -140, -100, "Use sound (WIP)", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.UseSound ? "yes" : "no",
|
g => g.UseSound ? "yes" : "no",
|
||||||
(g, v) => { g.UseSound = v == "yes";
|
(g, v) => { g.UseSound = v == "yes";
|
||||||
g.AudioPlayer.SetSound( g.UseSound );
|
g.AudioPlayer.SetSound( g.UseSound );
|
||||||
Options.Set( OptionsKey.UseSound, v == "yes" ); }),
|
Options.Set( OptionsKey.UseSound, v == "yes" ); }),
|
||||||
|
|
||||||
Make( -140, -100, "Show hover names", Anchor.Centre, OnWidgetClick,
|
Make( -140, -50, "Show hover names", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.Players.ShowHoveredNames ? "yes" : "no",
|
g => g.Players.ShowHoveredNames ? "yes" : "no",
|
||||||
(g, v) => { g.Players.ShowHoveredNames = v == "yes";
|
(g, v) => { g.Players.ShowHoveredNames = v == "yes";
|
||||||
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" ); }),
|
Options.Set( OptionsKey.ShowHoveredNames, v == "yes" ); }),
|
||||||
|
|
||||||
Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick,
|
|
||||||
g => g.LocalPlayer.SpeedMultiplier.ToString(),
|
|
||||||
(g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v );
|
|
||||||
Options.Set( OptionsKey.Speed, v ); } ),
|
|
||||||
|
|
||||||
Make( -140, 0, "FPS limit", Anchor.Centre, OnWidgetClick,
|
Make( -140, 0, "FPS limit", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.FpsLimit.ToString(),
|
g => g.FpsLimit.ToString(),
|
||||||
(g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v );
|
(g, v) => { object raw = Enum.Parse( typeof(FpsLimitMethod), v );
|
||||||
@ -48,38 +39,28 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
// Column 2
|
// Column 2
|
||||||
!network.IsSinglePlayer ? null :
|
!network.IsSinglePlayer ? null :
|
||||||
Make( 140, -200, "Block physics", Anchor.Centre, OnWidgetClick,
|
Make( 140, -150, "Block physics", Anchor.Centre, OnWidgetClick,
|
||||||
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no",
|
||||||
(g, v) => {
|
(g, v) => {
|
||||||
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
((SinglePlayerServer)network).physics.Enabled = v == "yes";
|
||||||
Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
|
Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" );
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Make( 140, -150, "Use music", Anchor.Centre, OnWidgetClick,
|
Make( 140, -100, "Use music", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.UseMusic ? "yes" : "no",
|
g => g.UseMusic ? "yes" : "no",
|
||||||
(g, v) => { g.UseMusic = v == "yes";
|
(g, v) => { g.UseMusic = v == "yes";
|
||||||
g.AudioPlayer.SetMusic( g.UseMusic );
|
g.AudioPlayer.SetMusic( g.UseMusic );
|
||||||
Options.Set( OptionsKey.UseMusic, v == "yes" ); }),
|
Options.Set( OptionsKey.UseMusic, v == "yes" ); }),
|
||||||
|
|
||||||
Make( 140, -100, "View bobbing", Anchor.Centre, OnWidgetClick,
|
Make( 140, -50, "View bobbing", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.ViewBobbing ? "yes" : "no",
|
g => g.ViewBobbing ? "yes" : "no",
|
||||||
(g, v) => { g.ViewBobbing = v == "yes";
|
(g, v) => { g.ViewBobbing = v == "yes";
|
||||||
Options.Set( OptionsKey.ViewBobbing, v == "yes" ); }),
|
Options.Set( OptionsKey.ViewBobbing, v == "yes" ); }),
|
||||||
|
|
||||||
Make( 140, -50, "Auto close launcher", Anchor.Centre, OnWidgetClick,
|
Make( 140, 0, "Auto close launcher", Anchor.Centre, OnWidgetClick,
|
||||||
g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no",
|
g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no",
|
||||||
(g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ),
|
(g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ),
|
||||||
|
|
||||||
Make( 140, 0, "Pushback placing", Anchor.Centre, 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" );
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick,
|
||||||
g => g.MouseSensitivity.ToString(),
|
g => g.MouseSensitivity.ToString(),
|
||||||
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
(g, v) => { g.MouseSensitivity = Int32.Parse( v );
|
||||||
@ -89,13 +70,11 @@ namespace ClassicalSharp {
|
|||||||
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new PauseScreen( g ) ) ),
|
||||||
null,
|
null,
|
||||||
};
|
};
|
||||||
buttons[4].Metadata = typeof(FpsLimitMethod);
|
buttons[2].Metadata = typeof(FpsLimitMethod);
|
||||||
|
|
||||||
validators = new MenuInputValidator[] {
|
validators = new MenuInputValidator[] {
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new BooleanValidator(),
|
|
||||||
new RealValidator( 0.1f, 50 ),
|
|
||||||
new EnumValidator(),
|
new EnumValidator(),
|
||||||
new IntegerValidator( 16, 4096 ),
|
new IntegerValidator( 16, 4096 ),
|
||||||
|
|
||||||
@ -103,7 +82,6 @@ namespace ClassicalSharp {
|
|||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new BooleanValidator(),
|
new BooleanValidator(),
|
||||||
new BooleanValidator(),
|
|
||||||
new IntegerValidator( 1, 100 ),
|
new IntegerValidator( 1, 100 ),
|
||||||
};
|
};
|
||||||
okayIndex = buttons.Length - 1;
|
okayIndex = buttons.Length - 1;
|
||||||
|
@ -24,12 +24,12 @@ namespace ClassicalSharp {
|
|||||||
(g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ),
|
||||||
Make( -140, -100, "Gui options", Anchor.Centre,
|
Make( -140, -100, "Gui options", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ),
|
||||||
Make( -140, -50, "Env settings", Anchor.Centre,
|
Make( -140, -50, "Hacks settings", Anchor.Centre,
|
||||||
|
(g, w) => g.SetNewScreen( new HacksSettingsScreen( g ) ) ),
|
||||||
|
Make( -140, 0, "Env settings", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ),
|
||||||
Make( -140, 0, "Key bindings", Anchor.Centre,
|
Make( -140, 50, "Key bindings", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new NormalKeyBindingsScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new NormalKeyBindingsScreen( g ) ) ),
|
||||||
Make( -140, 50, "Hotkeys", Anchor.Centre,
|
|
||||||
(g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ),
|
|
||||||
|
|
||||||
// Column 2
|
// Column 2
|
||||||
Make( 140, -150, "Save level", Anchor.Centre,
|
Make( 140, -150, "Save level", Anchor.Centre,
|
||||||
@ -40,8 +40,10 @@ namespace ClassicalSharp {
|
|||||||
!game.Network.IsSinglePlayer ? null :
|
!game.Network.IsSinglePlayer ? null :
|
||||||
Make( 140, -50, "Generate level", Anchor.Centre,
|
Make( 140, -50, "Generate level", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new GenLevelScreen( g ) ) ),
|
||||||
Make( 140, 50, "Select texture pack", Anchor.Centre,
|
Make( 140, 0, "Select texture pack", Anchor.Centre,
|
||||||
(g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
|
(g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ),
|
||||||
|
Make( 140, 50, "Hotkeys", Anchor.Centre,
|
||||||
|
(g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ),
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
MakeOther( 10, 5, 120, "Quit game", Anchor.BottomOrRight,
|
MakeOther( 10, 5, 120, "Quit game", Anchor.BottomOrRight,
|
||||||
|
@ -100,6 +100,7 @@
|
|||||||
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\EnvSettingsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\GenLevelScreen.cs" />
|
<Compile Include="2D\Screens\Menu\GenLevelScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\GuiOptionsScreen.cs" />
|
<Compile Include="2D\Screens\Menu\GuiOptionsScreen.cs" />
|
||||||
|
<Compile Include="2D\Screens\Menu\HacksSettingsScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\LoadLevelScreen.cs" />
|
<Compile Include="2D\Screens\Menu\LoadLevelScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\MenuInputScreen.cs" />
|
<Compile Include="2D\Screens\Menu\MenuInputScreen.cs" />
|
||||||
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
<Compile Include="2D\Screens\Menu\MenuScreen.cs" />
|
||||||
|
@ -16,6 +16,8 @@ namespace ClassicalSharp {
|
|||||||
public byte UserType;
|
public byte UserType;
|
||||||
public bool PushbackPlacing;
|
public bool PushbackPlacing;
|
||||||
|
|
||||||
|
public bool HacksEnabled = true;
|
||||||
|
|
||||||
/// <summary> Whether the player is allowed to use the types of cameras that use third person. </summary>
|
/// <summary> Whether the player is allowed to use the types of cameras that use third person. </summary>
|
||||||
public bool CanUseThirdPersonCamera = true;
|
public bool CanUseThirdPersonCamera = true;
|
||||||
|
|
||||||
@ -125,7 +127,7 @@ namespace ClassicalSharp {
|
|||||||
if( game.IsKeyDown( KeyBinding.Right ) ) zMoving += 0.98f;
|
if( game.IsKeyDown( KeyBinding.Right ) ) zMoving += 0.98f;
|
||||||
|
|
||||||
jumping = game.IsKeyDown( KeyBinding.Jump );
|
jumping = game.IsKeyDown( KeyBinding.Jump );
|
||||||
speeding = CanSpeed && game.IsKeyDown( KeyBinding.Speed );
|
speeding = CanSpeed && HacksEnabled && game.IsKeyDown( KeyBinding.Speed );
|
||||||
flyingUp = game.IsKeyDown( KeyBinding.FlyUp );
|
flyingUp = game.IsKeyDown( KeyBinding.FlyUp );
|
||||||
flyingDown = game.IsKeyDown( KeyBinding.FlyDown );
|
flyingDown = game.IsKeyDown( KeyBinding.FlyDown );
|
||||||
}
|
}
|
||||||
@ -264,12 +266,12 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
|
/// <summary> Disables any hacks if their respective CanHackX value is set to false. </summary>
|
||||||
public void CheckHacksConsistency() {
|
public void CheckHacksConsistency() {
|
||||||
if( !CanFly ) { flying = false; flyingDown = false; flyingUp = false; }
|
if( !CanFly || !HacksEnabled ) { flying = false; flyingDown = false; flyingUp = false; }
|
||||||
if( !CanNoclip ) noClip = false;
|
if( !CanNoclip || !HacksEnabled ) noClip = false;
|
||||||
if( !CanSpeed) speeding = false;
|
if( !CanSpeed || !HacksEnabled ) speeding = false;
|
||||||
if( !CanPushbackBlocks ) PushbackPlacing = false;
|
if( !CanPushbackBlocks || !HacksEnabled ) PushbackPlacing = false;
|
||||||
|
|
||||||
if( !CanUseThirdPersonCamera )
|
if( !CanUseThirdPersonCamera || !HacksEnabled )
|
||||||
game.SetCamera( false );
|
game.SetCamera( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +301,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
internal bool HandleKeyDown( Key key ) {
|
internal bool HandleKeyDown( Key key ) {
|
||||||
KeyMap keys = game.InputHandler.Keys;
|
KeyMap keys = game.InputHandler.Keys;
|
||||||
if( key == keys[KeyBinding.Respawn] && CanRespawn ) {
|
if( key == keys[KeyBinding.Respawn] && CanRespawn && HacksEnabled ) {
|
||||||
Vector3I p = Vector3I.Floor( SpawnPoint );
|
Vector3I p = Vector3I.Floor( SpawnPoint );
|
||||||
if( game.Map.IsValidPos( p ) ) {
|
if( game.Map.IsValidPos( p ) ) {
|
||||||
// Spawn player at highest valid position.
|
// Spawn player at highest valid position.
|
||||||
@ -316,11 +318,11 @@ namespace ClassicalSharp {
|
|||||||
Vector3 spawn = (Vector3)p + new Vector3( 0.5f, 0.01f, 0.5f );
|
Vector3 spawn = (Vector3)p + new Vector3( 0.5f, 0.01f, 0.5f );
|
||||||
LocationUpdate update = LocationUpdate.MakePos( spawn, false );
|
LocationUpdate update = LocationUpdate.MakePos( spawn, false );
|
||||||
SetLocation( update, false );
|
SetLocation( update, false );
|
||||||
} else if( key == keys[KeyBinding.SetSpawn] && CanRespawn ) {
|
} else if( key == keys[KeyBinding.SetSpawn] && CanRespawn && HacksEnabled ) {
|
||||||
SpawnPoint = Position;
|
SpawnPoint = Position;
|
||||||
} else if( key == keys[KeyBinding.Fly] && CanFly ) {
|
} else if( key == keys[KeyBinding.Fly] && CanFly && HacksEnabled ) {
|
||||||
flying = !flying;
|
flying = !flying;
|
||||||
} else if( key == keys[KeyBinding.NoClip] && CanNoclip ) {
|
} else if( key == keys[KeyBinding.NoClip] && CanNoclip && HacksEnabled ) {
|
||||||
noClip = !noClip;
|
noClip = !noClip;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -21,6 +21,7 @@ namespace ClassicalSharp {
|
|||||||
public const string ShowBlockInHand = "blockinhand";
|
public const string ShowBlockInHand = "blockinhand";
|
||||||
public const string UseMusic = "usemusic";
|
public const string UseMusic = "usemusic";
|
||||||
public const string UseSound = "usesound";
|
public const string UseSound = "usesound";
|
||||||
|
public const string HacksEnabled = "hacksenabled";
|
||||||
|
|
||||||
public const string MouseLeft = "mouseleft";
|
public const string MouseLeft = "mouseleft";
|
||||||
public const string MouseMiddle = "mousemiddle";
|
public const string MouseMiddle = "mousemiddle";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user