From 70a2fc868f2e8dfd35cafd9e9ffefa83939f9b22 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 11 Nov 2015 17:27:36 +1100 Subject: [PATCH] Save singleplayer physics option, only use mob texture for external urls, use bigger font size for name texture. --- .../2D/Screens/Menu/OptionsScreen.cs | 5 +++- ClassicalSharp/Entities/LocalPlayer.cs | 1 + ClassicalSharp/Entities/NetPlayer.cs | 1 + ClassicalSharp/Entities/Player.Rendering.cs | 6 ++--- ClassicalSharp/Entities/Player.cs | 24 ++++++++++--------- .../Network/NetworkProcessor.Original.cs | 1 + ClassicalSharp/Singleplayer/Physics.cs | 1 + ClassicalSharp/Utils/Options.cs | 1 + 8 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs index f89342cbe..06d7cb234 100644 --- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs @@ -65,7 +65,10 @@ namespace ClassicalSharp { !network.IsSinglePlayer ? null : Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick, g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", - (g, v) => ((SinglePlayerServer)network).physics.Enabled = (v == "yes") ), + (g, v) => { + ((SinglePlayerServer)network).physics.Enabled = v == "yes"; + Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" ); + }), Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick, g => g.LocalPlayer.PushbackBlockPlacing && g.LocalPlayer.CanPushbackBlocks ? "yes" : "no", diff --git a/ClassicalSharp/Entities/LocalPlayer.cs b/ClassicalSharp/Entities/LocalPlayer.cs index 4d1461bd3..5832b0744 100644 --- a/ClassicalSharp/Entities/LocalPlayer.cs +++ b/ClassicalSharp/Entities/LocalPlayer.cs @@ -41,6 +41,7 @@ namespace ClassicalSharp { public LocalPlayer( Game window ) : base( window ) { DisplayName = window.Username; SkinName = window.Username; + SkinIdentifier = "skin_" + SkinName; InitRenderingData(); } diff --git a/ClassicalSharp/Entities/NetPlayer.cs b/ClassicalSharp/Entities/NetPlayer.cs index a04df1b7c..4cd6faf8d 100644 --- a/ClassicalSharp/Entities/NetPlayer.cs +++ b/ClassicalSharp/Entities/NetPlayer.cs @@ -10,6 +10,7 @@ namespace ClassicalSharp { public NetPlayer( string displayName, string skinName, Game game ) : base( game ) { DisplayName = displayName; SkinName = Utils.StripColours( skinName ); + SkinIdentifier = "skin_" + SkinName; InitRenderingData(); } diff --git a/ClassicalSharp/Entities/Player.Rendering.cs b/ClassicalSharp/Entities/Player.Rendering.cs index fc8b5a31c..152ad129d 100644 --- a/ClassicalSharp/Entities/Player.Rendering.cs +++ b/ClassicalSharp/Entities/Player.Rendering.cs @@ -17,7 +17,7 @@ namespace ClassicalSharp { } protected void InitRenderingData() { - using( Font font = new Font( "Arial", 14 ) ) { + using( Font font = new Font( "Arial", 20 ) ) { DrawTextArgs args = new DrawTextArgs( DisplayName, font, true ); nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 ); } @@ -32,8 +32,8 @@ namespace ClassicalSharp { IGraphicsApi api = game.Graphics; api.BindTexture( nameTex.ID ); - float x1 = -nameTex.Width * 0.5f / 50f, y1 = nameTex.Height / 50f; - float x2 = nameTex.Width * 0.5f / 50f, y2 = 0; + float x1 = -nameTex.Width * 0.5f / 70f, y1 = nameTex.Height / 70f; + float x2 = nameTex.Width * 0.5f / 70f, y2 = 0; // NOTE: Do this instead with network player's yaw to have names rotate with them instead. //yaw = Math.Pi - Player.YawRadians; float angle = game.LocalPlayer.YawRadians; diff --git a/ClassicalSharp/Entities/Player.cs b/ClassicalSharp/Entities/Player.cs index b98497ff6..1aa80f7b7 100644 --- a/ClassicalSharp/Entities/Player.cs +++ b/ClassicalSharp/Entities/Player.cs @@ -12,7 +12,7 @@ namespace ClassicalSharp { get { return new Vector3( Position.X, Position.Y + Model.GetEyeY( this ), Position.Z ); } } - public string DisplayName, SkinName; + public string DisplayName, SkinName, SkinIdentifier; public SkinType SkinType; public Player( Game game ) : base( game ) { @@ -42,7 +42,7 @@ namespace ClassicalSharp { protected void CheckSkin() { DownloadedItem item; - game.AsyncDownloader.TryGetItem( "skin_" + SkinName, out item ); + game.AsyncDownloader.TryGetItem( SkinIdentifier, out item ); if( item != null && item.Data != null ) { Bitmap bmp = (Bitmap)item.Data; game.Graphics.DeleteTexture( ref PlayerTextureId ); @@ -55,21 +55,23 @@ namespace ClassicalSharp { MobTextureId = -1; // Custom mob textures. - if( Utils.IsUrlPrefix( item.Url ) && item.TimeAdded > lastModelChange ) { + if( Utils.IsUrlPrefix( SkinName ) && item.TimeAdded > lastModelChange ) MobTextureId = PlayerTextureId; - } RenderHat = HasHat( bmp, SkinType ); } catch( NotSupportedException ) { - string formatString = "Skin {0} has unsupported dimensions({1}, {2}), reverting to default."; - Utils.LogDebug( formatString, SkinName, bmp.Width, bmp.Height ); - MobTextureId = -1; - PlayerTextureId = -1; - SkinType = game.DefaultPlayerSkinType; - RenderHat = false; + ResetSkin( bmp ); } bmp.Dispose(); } - + } + + void ResetSkin( Bitmap bmp ) { + string formatString = "Skin {0} has unsupported dimensions({1}, {2}), reverting to default."; + Utils.LogDebug( formatString, SkinName, bmp.Width, bmp.Height ); + MobTextureId = -1; + PlayerTextureId = -1; + SkinType = game.DefaultPlayerSkinType; + RenderHat = false; } DateTime lastModelChange = new DateTime( 1, 1, 1 ); diff --git a/ClassicalSharp/Network/NetworkProcessor.Original.cs b/ClassicalSharp/Network/NetworkProcessor.Original.cs index 45e1d1310..647c94ef5 100644 --- a/ClassicalSharp/Network/NetworkProcessor.Original.cs +++ b/ClassicalSharp/Network/NetworkProcessor.Original.cs @@ -266,6 +266,7 @@ namespace ClassicalSharp { game.AsyncDownloader.DownloadSkin( skinName ); } else { game.LocalPlayer.SkinName = skinName; + game.LocalPlayer.SkinIdentifier = "skin_" + game.LocalPlayer.SkinName; game.AsyncDownloader.DownloadSkin( skinName ); } if( readPosition ) { diff --git a/ClassicalSharp/Singleplayer/Physics.cs b/ClassicalSharp/Singleplayer/Physics.cs index 968de9a45..6565aa5a6 100644 --- a/ClassicalSharp/Singleplayer/Physics.cs +++ b/ClassicalSharp/Singleplayer/Physics.cs @@ -27,6 +27,7 @@ namespace ClassicalSharp.Singleplayer { map = game.Map; info = game.BlockInfo; game.Events.OnNewMapLoaded += ResetMap; + enabled = Options.GetBool( OptionsKey.SingleplayerPhysics, true ); } bool CheckItem( Queue queue, out int posIndex ) { diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index dcaa85409..8d56f7777 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -14,6 +14,7 @@ namespace ClassicalSharp { public const string ChatLines = "chatlines"; public const string ArialChatFont = "arialchatfont"; public const string DefaultTexturePack = "defaulttexpack"; + public const string SingleplayerPhysics = "singleplayerphysics"; public const string MouseLeft = "mouseleft"; public const string MouseMiddle = "mousemiddle";