Save singleplayer physics option, only use mob texture for external urls, use bigger font size for name texture.

This commit is contained in:
UnknownShadow200 2015-11-11 17:27:36 +11:00
parent d05fdd1aa0
commit 70a2fc868f
8 changed files with 25 additions and 15 deletions

View File

@ -65,7 +65,10 @@ namespace ClassicalSharp {
!network.IsSinglePlayer ? null : !network.IsSinglePlayer ? null :
Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick, Make( -140, -150, "Singleplayer physics", Anchor.Centre, OnWidgetClick,
g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", 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, Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick,
g => g.LocalPlayer.PushbackBlockPlacing g => g.LocalPlayer.PushbackBlockPlacing
&& g.LocalPlayer.CanPushbackBlocks ? "yes" : "no", && g.LocalPlayer.CanPushbackBlocks ? "yes" : "no",

View File

@ -41,6 +41,7 @@ namespace ClassicalSharp {
public LocalPlayer( Game window ) : base( window ) { public LocalPlayer( Game window ) : base( window ) {
DisplayName = window.Username; DisplayName = window.Username;
SkinName = window.Username; SkinName = window.Username;
SkinIdentifier = "skin_" + SkinName;
InitRenderingData(); InitRenderingData();
} }

View File

@ -10,6 +10,7 @@ namespace ClassicalSharp {
public NetPlayer( string displayName, string skinName, Game game ) : base( game ) { public NetPlayer( string displayName, string skinName, Game game ) : base( game ) {
DisplayName = displayName; DisplayName = displayName;
SkinName = Utils.StripColours( skinName ); SkinName = Utils.StripColours( skinName );
SkinIdentifier = "skin_" + SkinName;
InitRenderingData(); InitRenderingData();
} }

View File

@ -17,7 +17,7 @@ namespace ClassicalSharp {
} }
protected void InitRenderingData() { protected void InitRenderingData() {
using( Font font = new Font( "Arial", 14 ) ) { using( Font font = new Font( "Arial", 20 ) ) {
DrawTextArgs args = new DrawTextArgs( DisplayName, font, true ); DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 ); nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 );
} }
@ -32,8 +32,8 @@ namespace ClassicalSharp {
IGraphicsApi api = game.Graphics; IGraphicsApi api = game.Graphics;
api.BindTexture( nameTex.ID ); api.BindTexture( nameTex.ID );
float x1 = -nameTex.Width * 0.5f / 50f, y1 = nameTex.Height / 50f; float x1 = -nameTex.Width * 0.5f / 70f, y1 = nameTex.Height / 70f;
float x2 = nameTex.Width * 0.5f / 50f, y2 = 0; 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. // NOTE: Do this instead with network player's yaw to have names rotate with them instead.
//yaw = Math.Pi - Player.YawRadians; //yaw = Math.Pi - Player.YawRadians;
float angle = game.LocalPlayer.YawRadians; float angle = game.LocalPlayer.YawRadians;

View File

@ -12,7 +12,7 @@ namespace ClassicalSharp {
get { return new Vector3( Position.X, Position.Y + Model.GetEyeY( this ), Position.Z ); } 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 SkinType SkinType;
public Player( Game game ) : base( game ) { public Player( Game game ) : base( game ) {
@ -42,7 +42,7 @@ namespace ClassicalSharp {
protected void CheckSkin() { protected void CheckSkin() {
DownloadedItem item; DownloadedItem item;
game.AsyncDownloader.TryGetItem( "skin_" + SkinName, out item ); game.AsyncDownloader.TryGetItem( SkinIdentifier, out item );
if( item != null && item.Data != null ) { if( item != null && item.Data != null ) {
Bitmap bmp = (Bitmap)item.Data; Bitmap bmp = (Bitmap)item.Data;
game.Graphics.DeleteTexture( ref PlayerTextureId ); game.Graphics.DeleteTexture( ref PlayerTextureId );
@ -55,21 +55,23 @@ namespace ClassicalSharp {
MobTextureId = -1; MobTextureId = -1;
// Custom mob textures. // Custom mob textures.
if( Utils.IsUrlPrefix( item.Url ) && item.TimeAdded > lastModelChange ) { if( Utils.IsUrlPrefix( SkinName ) && item.TimeAdded > lastModelChange )
MobTextureId = PlayerTextureId; MobTextureId = PlayerTextureId;
}
RenderHat = HasHat( bmp, SkinType ); RenderHat = HasHat( bmp, SkinType );
} catch( NotSupportedException ) { } catch( NotSupportedException ) {
string formatString = "Skin {0} has unsupported dimensions({1}, {2}), reverting to default."; ResetSkin( bmp );
Utils.LogDebug( formatString, SkinName, bmp.Width, bmp.Height );
MobTextureId = -1;
PlayerTextureId = -1;
SkinType = game.DefaultPlayerSkinType;
RenderHat = false;
} }
bmp.Dispose(); 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 ); DateTime lastModelChange = new DateTime( 1, 1, 1 );

View File

@ -266,6 +266,7 @@ namespace ClassicalSharp {
game.AsyncDownloader.DownloadSkin( skinName ); game.AsyncDownloader.DownloadSkin( skinName );
} else { } else {
game.LocalPlayer.SkinName = skinName; game.LocalPlayer.SkinName = skinName;
game.LocalPlayer.SkinIdentifier = "skin_" + game.LocalPlayer.SkinName;
game.AsyncDownloader.DownloadSkin( skinName ); game.AsyncDownloader.DownloadSkin( skinName );
} }
if( readPosition ) { if( readPosition ) {

View File

@ -27,6 +27,7 @@ namespace ClassicalSharp.Singleplayer {
map = game.Map; map = game.Map;
info = game.BlockInfo; info = game.BlockInfo;
game.Events.OnNewMapLoaded += ResetMap; game.Events.OnNewMapLoaded += ResetMap;
enabled = Options.GetBool( OptionsKey.SingleplayerPhysics, true );
} }
bool CheckItem( Queue<uint> queue, out int posIndex ) { bool CheckItem( Queue<uint> queue, out int posIndex ) {

View File

@ -14,6 +14,7 @@ namespace ClassicalSharp {
public const string ChatLines = "chatlines"; public const string ChatLines = "chatlines";
public const string ArialChatFont = "arialchatfont"; public const string ArialChatFont = "arialchatfont";
public const string DefaultTexturePack = "defaulttexpack"; public const string DefaultTexturePack = "defaulttexpack";
public const string SingleplayerPhysics = "singleplayerphysics";
public const string MouseLeft = "mouseleft"; public const string MouseLeft = "mouseleft";
public const string MouseMiddle = "mousemiddle"; public const string MouseMiddle = "mousemiddle";