From cca0b81f20b48f679fc9004eb42309b9e45c8da3 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 19 Nov 2015 16:45:38 +1100 Subject: [PATCH] Treat solid white and black pixels in humanoid hats as transparent, allowed speed multiplier to be less than 1. --- .../2D/Screens/Menu/OptionsScreen.cs | 6 ++--- ClassicalSharp/Entities/LocalPlayer.cs | 2 +- ClassicalSharp/Entities/Player.Rendering.cs | 1 - ClassicalSharp/Entities/Player.cs | 26 ++++++++++--------- ClassicalSharp/Game/Game.cs | 6 ++--- ClassicalSharp/Model/PlayerModel.cs | 8 +++--- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs index f21cf9165..35b8ea2e7 100644 --- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs @@ -17,7 +17,7 @@ namespace ClassicalSharp { // Column 1 Make( -140, -100, "Speed multiplier", Anchor.Centre, OnWidgetClick, g => g.LocalPlayer.SpeedMultiplier.ToString(), - (g, v) => { g.LocalPlayer.SpeedMultiplier = Int32.Parse( v ); + (g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v ); Options.Set( OptionsKey.Speed, v ); } ), Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick, @@ -89,13 +89,13 @@ namespace ClassicalSharp { null, }; validators = new MenuInputValidator[] { - new IntegerValidator( 1, 50 ), + new RealValidator( 0.1f, 50 ), new BooleanValidator(), new BooleanValidator(), new IntegerValidator( 16, 4096 ), new IntegerValidator( 1, 100 ), - new RealValidator( 0.5f, 2f ), + new RealValidator( 0.25f, 2f ), new IntegerValidator( 1, 30 ), new BooleanValidator(), diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index 5832b0744..a96afe8f6 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -11,7 +11,7 @@ namespace ClassicalSharp { public Vector3 SpawnPoint; public float ReachDistance = 5f; - public int SpeedMultiplier = 10; + public float SpeedMultiplier = 10; public byte UserType; public bool PushbackBlockPlacing; diff --git a/ClassicalSharp/Entities/Player.Rendering.cs b/ClassicalSharp/Entities/Player.Rendering.cs index 152ad129d..1a08d5dca 100644 --- a/ClassicalSharp/Entities/Player.Rendering.cs +++ b/ClassicalSharp/Entities/Player.Rendering.cs @@ -9,7 +9,6 @@ namespace ClassicalSharp { protected Texture nameTex; protected internal int PlayerTextureId = -1, MobTextureId = -1; - internal bool RenderHat = true; public override void Despawn() { game.Graphics.DeleteTexture( ref PlayerTextureId ); diff --git a/ClassicalSharp/Entities/Player.cs b/ClassicalSharp/Entities/Player.cs index 1aa80f7b7..e54f31329 100644 --- a/ClassicalSharp/Entities/Player.cs +++ b/ClassicalSharp/Entities/Player.cs @@ -1,7 +1,8 @@ -using System; -using System.Drawing; -using ClassicalSharp.Network; -using OpenTK; +using System; +using System.Drawing; +using ClassicalSharp.Model; +using ClassicalSharp.Network; +using OpenTK; namespace ClassicalSharp { @@ -51,13 +52,14 @@ namespace ClassicalSharp { try { SkinType = Utils.GetSkinType( bmp ); + if( Model is PlayerModel ) + ClearHat( bmp, SkinType ); PlayerTextureId = game.Graphics.CreateTexture( bmp ); MobTextureId = -1; // Custom mob textures. if( Utils.IsUrlPrefix( SkinName ) && item.TimeAdded > lastModelChange ) - MobTextureId = PlayerTextureId; - RenderHat = HasHat( bmp, SkinType ); + MobTextureId = PlayerTextureId; } catch( NotSupportedException ) { ResetSkin( bmp ); } @@ -71,7 +73,6 @@ namespace ClassicalSharp { MobTextureId = -1; PlayerTextureId = -1; SkinType = game.DefaultPlayerSkinType; - RenderHat = false; } DateTime lastModelChange = new DateTime( 1, 1, 1 ); @@ -82,7 +83,7 @@ namespace ClassicalSharp { MobTextureId = -1; } - unsafe static bool HasHat( Bitmap bmp, SkinType skinType ) { + unsafe static void ClearHat( Bitmap bmp, SkinType skinType ) { using( FastBitmap fastBmp = new FastBitmap( bmp, true ) ) { int sizeX = (bmp.Width / 64) * 32; int yScale = skinType == SkinType.Type64x32 ? 32 : 64; @@ -95,13 +96,14 @@ namespace ClassicalSharp { row += sizeX; for( int x = 0; x < sizeX; x++ ) { int pixel = row[x]; - if( !(pixel == fullWhite || pixel == fullBlack) ) { - return true; - } + Console.WriteLine( pixel.ToString( "X8" ) ); + if( pixel == fullWhite ) row[x] = 0; + if( pixel == fullBlack ) row[x] = 0; + Console.WriteLine( row[x].ToString( "X8" ) ); + Console.WriteLine( "====" ); } } } - return false; } } } \ No newline at end of file diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 3390f08b8..349cf54a5 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -72,7 +72,7 @@ namespace ClassicalSharp { public int MouseSensitivity = 30; public int ChatLines = 12; public bool HideGui = false, ShowFPS = true; - internal float HudScale = 1f; + internal float HudScale = 1.0f; public Animations Animations; internal int CloudsTextureId, RainTextureId, SnowTextureId; @@ -124,7 +124,7 @@ namespace ClassicalSharp { ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 ); InputHandler = new InputHandler( this ); Chat = new ChatLog( this ); - HudScale = Options.GetFloat( OptionsKey.HudScale, 0.5f, 2f, 1 ); + HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 2f, 1 ); defaultIb = Graphics.MakeDefaultIb(); MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 ); BlockInfo = new BlockInfo(); @@ -149,7 +149,7 @@ namespace ClassicalSharp { BlockInfo.SetDefaultBlockPermissions( Inventory.CanPlace, Inventory.CanDelete ); Map = new Map( this ); LocalPlayer = new LocalPlayer( this ); - LocalPlayer.SpeedMultiplier = Options.GetInt( OptionsKey.Speed, 1, 50, 10 ); + LocalPlayer.SpeedMultiplier = Options.GetFloat( OptionsKey.Speed, 0.1f, 50, 10 ); Players[255] = LocalPlayer; width = Width; height = Height; diff --git a/ClassicalSharp/Model/PlayerModel.cs b/ClassicalSharp/Model/PlayerModel.cs index 48a651539..e92af8e25 100644 --- a/ClassicalSharp/Model/PlayerModel.cs +++ b/ClassicalSharp/Model/PlayerModel.cs @@ -74,11 +74,9 @@ namespace ClassicalSharp.Model { graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 ); graphics.AlphaTest = true; - if( p.RenderHat ) { - index = 0; - DrawRotate( 0, 24f/16f, 0, -p.PitchRadians, 0, 0, model.Hat ); - graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 ); - } + index = 0; + DrawRotate( 0, 24f/16f, 0, -p.PitchRadians, 0, 0, model.Hat ); + graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb, cache.vertices, index, index * 6 / 4 ); } class ModelSet {