mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Disable 'hacks setting' screen (as it is pointless to show anyways) when server sends hax/ophax in motd.
This commit is contained in:
parent
3e6e270044
commit
d7e3e9d200
@ -16,7 +16,7 @@ namespace ClassicalSharp {
|
|||||||
for( int i = widgets.Length - 1; i >= 0; i-- ) {
|
for( int i = widgets.Length - 1; i >= 0; i-- ) {
|
||||||
Widget widget = widgets[i];
|
Widget widget = widgets[i];
|
||||||
if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
|
if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) {
|
||||||
if( widget.OnClick != null )
|
if( widget.OnClick != null && !widget.Disabled )
|
||||||
widget.OnClick( game, widget );
|
widget.OnClick( game, widget );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public override void Init() {
|
public override void Init() {
|
||||||
base.Init();
|
base.Init();
|
||||||
|
game.Events.HackPermissionsChanged += CheckHacksAllowed;
|
||||||
buttons = new ButtonWidget[] {
|
buttons = new ButtonWidget[] {
|
||||||
// Column 1
|
// Column 1
|
||||||
Make( -140, -150, "Options", Anchor.Centre,
|
Make( -140, -150, "Options", Anchor.Centre,
|
||||||
@ -51,6 +52,17 @@ namespace ClassicalSharp {
|
|||||||
MakeBack( true, titleFont,
|
MakeBack( true, titleFont,
|
||||||
(g, w) => g.SetNewScreen( null ) ),
|
(g, w) => g.SetNewScreen( null ) ),
|
||||||
};
|
};
|
||||||
|
CheckHacksAllowed( null, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
void CheckHacksAllowed( object sender, EventArgs e ) {
|
||||||
|
for( int i = 0; i < buttons.Length; i++ )
|
||||||
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick ) {
|
ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, Widget> onClick ) {
|
||||||
@ -68,5 +80,10 @@ namespace ClassicalSharp {
|
|||||||
game.SetNewScreen( null );
|
game.SetNewScreen( null );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Dispose() {
|
||||||
|
base.Dispose();
|
||||||
|
game.Events.HackPermissionsChanged -= CheckHacksAllowed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,11 +35,12 @@ namespace ClassicalSharp {
|
|||||||
Height = defaultHeight;
|
Height = defaultHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextureRec shadowRec = new TextureRec( 0, 66/256f, 200/256f, 20/256f );
|
static Texture shadowTex = new Texture( 0, 0, 0, 0, 0,
|
||||||
static TextureRec selectedRec = new TextureRec( 0, 86/256f, 200/256f, 20/256f );
|
new TextureRec( 0, 66/256f, 200/256f, 20/256f ) );
|
||||||
static Texture shadowTex = new Texture( 0, 0, 0, 0, 0, shadowRec );
|
static Texture selectedTex = new Texture( 0, 0, 0, 0, 0,
|
||||||
static Texture selectedTex = new Texture( 0, 0, 0, 0, 0, selectedRec );
|
new TextureRec( 0, 86/256f, 200/256f, 20/256f ) );
|
||||||
|
static Texture disdabledTex = new Texture( 0, 0, 0, 0, 0,
|
||||||
|
new TextureRec( 0, 46/256f, 200/256f, 20/256f ) );
|
||||||
public string Text;
|
public string Text;
|
||||||
public void SetText( string text ) {
|
public void SetText( string text ) {
|
||||||
graphicsApi.DeleteTexture( ref texture );
|
graphicsApi.DeleteTexture( ref texture );
|
||||||
@ -57,15 +58,17 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Render( double delta ) {
|
public override void Render( double delta ) {
|
||||||
if( texture.IsValid ) {
|
if( !texture.IsValid )
|
||||||
Texture backTex = Active ? selectedTex : shadowTex;
|
return;
|
||||||
backTex.ID = game.GuiTexId;
|
Texture backTex = Active ? selectedTex : shadowTex;
|
||||||
backTex.X1 = X; backTex.Y1 = Y;
|
if( Disabled ) backTex = disdabledTex;
|
||||||
backTex.Width = Width; backTex.Height = Height;
|
backTex.ID = game.GuiTexId;
|
||||||
backTex.Render( graphicsApi );
|
backTex.X1 = X; backTex.Y1 = Y;
|
||||||
FastColour col = Active ? FastColour.White : new FastColour( 200, 200, 200 );
|
backTex.Width = Width; backTex.Height = Height;
|
||||||
texture.Render( graphicsApi, col );
|
backTex.Render( graphicsApi );
|
||||||
}
|
FastColour col = Active ? FastColour.White : new FastColour( 200, 200, 200 );
|
||||||
|
if( Disabled ) col = new FastColour( 150, 150, 150 );
|
||||||
|
texture.Render( graphicsApi, col );
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose() {
|
public override void Dispose() {
|
||||||
@ -73,12 +76,9 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void MoveTo( int newX, int newY ) {
|
public override void MoveTo( int newX, int newY ) {
|
||||||
int deltaX = newX - X;
|
int deltaX = newX - X, deltaY = newY - Y;
|
||||||
int deltaY = newY - Y;
|
texture.X1 += deltaX; texture.Y1 += deltaY;
|
||||||
texture.X1 += deltaX;
|
X = newX; Y = newY;
|
||||||
texture.Y1 += deltaY;
|
|
||||||
X = newX;
|
|
||||||
Y = newY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<Game, string> GetValue;
|
public Func<Game, string> GetValue;
|
||||||
|
@ -14,6 +14,9 @@ namespace ClassicalSharp {
|
|||||||
/// <summary> Whether this widget is currently being moused over. </summary>
|
/// <summary> Whether this widget is currently being moused over. </summary>
|
||||||
public bool Active;
|
public bool Active;
|
||||||
|
|
||||||
|
/// <summary> Whether this widget is prevented from being interacted with. </summary>
|
||||||
|
public bool Disabled;
|
||||||
|
|
||||||
/// <summary> Invoked when this widget is clicked on. Can be left null. </summary>
|
/// <summary> Invoked when this widget is clicked on. Can be left null. </summary>
|
||||||
public Action<Game, Widget> OnClick;
|
public Action<Game, Widget> OnClick;
|
||||||
|
|
||||||
|
@ -63,9 +63,8 @@ namespace ClassicalSharp.Commands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void Execute( CommandReader reader ) {
|
public override void Execute( CommandReader reader ) {
|
||||||
foreach( string line in game.Graphics.ApiInfo ) {
|
foreach( string line in game.Graphics.ApiInfo )
|
||||||
game.Chat.Add( "&a" + line );
|
game.Chat.Add( "&a" + line );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,16 +8,30 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public class LocalPlayer : Player {
|
public class LocalPlayer : Player {
|
||||||
|
|
||||||
|
/// <summary> Position the player's position is set to when the 'respawn' key binding is pressed. </summary>
|
||||||
public Vector3 SpawnPoint;
|
public Vector3 SpawnPoint;
|
||||||
|
|
||||||
|
/// <summary> The distance (in blocks) that players are allowed to
|
||||||
|
/// reach to and interact/modify blocks in. </summary>
|
||||||
public float ReachDistance = 5f;
|
public float ReachDistance = 5f;
|
||||||
|
|
||||||
|
/// <summary> The speed that the player move at, relative to normal speed,
|
||||||
|
/// when the 'speeding' key binding is held down. </summary>
|
||||||
public float SpeedMultiplier = 10;
|
public float SpeedMultiplier = 10;
|
||||||
|
|
||||||
public byte UserType;
|
public byte UserType;
|
||||||
|
|
||||||
|
/// <summary> Whether blocks that the player places that intersect themselves
|
||||||
|
/// should cause the player to be pushed back in the opposite direction of the placed block. </summary>
|
||||||
public bool PushbackPlacing;
|
public bool PushbackPlacing;
|
||||||
|
|
||||||
|
/// <summary> Whether the player has allowed hacks usage as an option.
|
||||||
|
/// Note that all 'can use X' set by the server override this. </summary>
|
||||||
public bool HacksEnabled = true;
|
public bool HacksEnabled = true;
|
||||||
|
|
||||||
|
/// <summary> Whether the player is allowed to use any type of hacks. </summary>
|
||||||
|
public bool CanAnyHacks = 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;
|
||||||
|
|
||||||
@ -27,7 +41,7 @@ namespace ClassicalSharp {
|
|||||||
/// <summary> Whether the player is allowed to fly in the world. </summary>
|
/// <summary> Whether the player is allowed to fly in the world. </summary>
|
||||||
public bool CanFly = true;
|
public bool CanFly = true;
|
||||||
|
|
||||||
/// <summary> Whether the player is allowed to teleport to their respawn point. </summary>
|
/// <summary> Whether the player is allowed to teleport to their respawn coordinates. </summary>
|
||||||
public bool CanRespawn = true;
|
public bool CanRespawn = true;
|
||||||
|
|
||||||
/// <summary> Whether the player is allowed to pass through all blocks. </summary>
|
/// <summary> Whether the player is allowed to pass through all blocks. </summary>
|
||||||
@ -171,7 +185,6 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
bool pastJumpPoint = liquidFeet && !(liquidBody || liquidHead)
|
bool pastJumpPoint = liquidFeet && !(liquidBody || liquidHead)
|
||||||
&& (Position.Y % 1 >= 0.4);
|
&& (Position.Y % 1 >= 0.4);
|
||||||
Console.WriteLine( pastJumpPoint );
|
|
||||||
if( !pastJumpPoint ) {
|
if( !pastJumpPoint ) {
|
||||||
canLiquidJump = true;
|
canLiquidJump = true;
|
||||||
Velocity.Y += speeding ? 0.08f : 0.04f;
|
Velocity.Y += speeding ? 0.08f : 0.04f;
|
||||||
@ -267,13 +280,10 @@ namespace ClassicalSharp {
|
|||||||
/// <remarks> Recognises +/-hax, +/-fly, +/-noclip, +/-speed, +/-respawn, +/-ophax </remarks>
|
/// <remarks> Recognises +/-hax, +/-fly, +/-noclip, +/-speed, +/-respawn, +/-ophax </remarks>
|
||||||
public void ParseHackFlags( string name, string motd ) {
|
public void ParseHackFlags( string name, string motd ) {
|
||||||
string joined = name + motd;
|
string joined = name + motd;
|
||||||
if( joined.Contains( "-hax" ) ) {
|
SetAllHacks( true );
|
||||||
CanFly = CanNoclip = CanRespawn = CanSpeed =
|
// By default (this is also the case with WoM), we can use hacks.
|
||||||
CanPushbackBlocks = CanUseThirdPersonCamera = false;
|
if( joined.Contains( "-hax" ) )
|
||||||
} else { // By default (this is also the case with WoM), we can use hacks.
|
SetAllHacks( false );
|
||||||
CanFly = CanNoclip = CanRespawn = CanSpeed =
|
|
||||||
CanPushbackBlocks = CanUseThirdPersonCamera = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ParseFlag( b => CanFly = b, joined, "fly" );
|
ParseFlag( b => CanFly = b, joined, "fly" );
|
||||||
ParseFlag( b => CanNoclip = b, joined, "noclip" );
|
ParseFlag( b => CanNoclip = b, joined, "noclip" );
|
||||||
@ -281,17 +291,21 @@ namespace ClassicalSharp {
|
|||||||
ParseFlag( b => CanRespawn = b, joined, "respawn" );
|
ParseFlag( b => CanRespawn = b, joined, "respawn" );
|
||||||
|
|
||||||
if( UserType == 0x64 )
|
if( UserType == 0x64 )
|
||||||
ParseFlag( b => CanFly = CanNoclip = CanRespawn =
|
ParseFlag( b => SetAllHacks( b ), joined, "ophax" );
|
||||||
CanSpeed = CanPushbackBlocks = b, joined, "ophax" );
|
|
||||||
CheckHacksConsistency();
|
CheckHacksConsistency();
|
||||||
|
game.Events.RaiseHackPermissionmsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetAllHacks( bool allowed ) {
|
||||||
|
CanAnyHacks = CanFly = CanNoclip = CanRespawn = CanSpeed =
|
||||||
|
CanPushbackBlocks = CanUseThirdPersonCamera = allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ParseFlag( Action<bool> action, string joined, string flag ) {
|
static void ParseFlag( Action<bool> action, string joined, string flag ) {
|
||||||
if( joined.Contains( "+" + flag ) ) {
|
if( joined.Contains( "+" + flag ) )
|
||||||
action( true );
|
action( true );
|
||||||
} else if( joined.Contains( "-" + flag ) ) {
|
else if( joined.Contains( "-" + flag ) )
|
||||||
action( false );
|
action( false );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <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>
|
||||||
|
@ -64,7 +64,8 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
/// <summary> Raised when the server or a client-side command sends a message. </summary>
|
/// <summary> Raised when the server or a client-side command sends a message. </summary>
|
||||||
public event EventHandler<ChatEventArgs> ChatReceived;
|
public event EventHandler<ChatEventArgs> ChatReceived;
|
||||||
internal void RaiseChatReceived( string text, CpeMessage type ) { chatArgs.Type = type; chatArgs.Text = text; Raise( ChatReceived, chatArgs ); }
|
internal void RaiseChatReceived( string text, CpeMessage type ) {
|
||||||
|
chatArgs.Type = type; chatArgs.Text = text; Raise( ChatReceived, chatArgs ); }
|
||||||
|
|
||||||
/// <summary> Raised when the user changes chat font to arial or back to bitmapped font,
|
/// <summary> Raised when the user changes chat font to arial or back to bitmapped font,
|
||||||
/// also raised when the bitmapped font changes. </summary>
|
/// also raised when the bitmapped font changes. </summary>
|
||||||
@ -72,6 +73,9 @@ namespace ClassicalSharp {
|
|||||||
internal void RaiseChatFontChanged() { Raise( ChatFontChanged ); }
|
internal void RaiseChatFontChanged() { Raise( ChatFontChanged ); }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary> Raised when the hack permissions of the player changes. </summary>
|
||||||
|
public event EventHandler HackPermissionsChanged;
|
||||||
|
internal void RaiseHackPermissionmsChanged() { Raise( HackPermissionsChanged ); }
|
||||||
|
|
||||||
// Cache event instances so we don't create needless new objects.
|
// Cache event instances so we don't create needless new objects.
|
||||||
IdEventArgs idArgs = new IdEventArgs();
|
IdEventArgs idArgs = new IdEventArgs();
|
||||||
|
@ -368,6 +368,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 );
|
||||||
|
game.Events.RaiseHackPermissionmsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleCpeExtAddEntity2() {
|
void HandleCpeExtAddEntity2() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user