diff --git a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs index 323931bfc..5ae27ae16 100644 --- a/ClassicalSharp/2D/Screens/BlockSelectScreen.cs +++ b/ClassicalSharp/2D/Screens/BlockSelectScreen.cs @@ -18,7 +18,7 @@ namespace ClassicalSharp { int startX, startY, blockSize; float selBlockExpand; readonly Font font; - StringBuffer buffer = new StringBuffer( 96 ); + StringBuffer buffer = new StringBuffer( 128 ); int TableX { get { return startX - 5 - 10; } } int TableY { get { return startY - 5 - 30; } } @@ -116,7 +116,7 @@ namespace ClassicalSharp { if( selIndex >= blocksTable.Length ) selIndex = blocksTable.Length - 1; UpdateScrollY(); - RecreateBlockInfoTexture(); + RecreateBlockInfoTexture(); } static string[] normalNames = null; @@ -127,19 +127,17 @@ namespace ClassicalSharp { int index = 0; buffer.Clear(); buffer.Append( ref index, "&f" ); - if( block == Block.TNT ) { - buffer.Append( ref index, "TNT" ); + string value = game.BlockInfo.Name[(byte)block]; + if( (byte)block < BlockInfo.CpeBlocksCount && value == "Invalid" ) { + buffer.Append( ref index, normalNames[(byte)block] ); } else { - string value = game.BlockInfo.Name[(byte)block]; - if( (byte)block < BlockInfo.CpeBlocksCount && value == "Invalid" ) { - buffer.Append( ref index, normalNames[(byte)block] ); - } else { - buffer.Append( ref index, value ); - } + buffer.Append( ref index, value ); } - buffer.Append( ref index, " (can place: " ); + buffer.Append( ref index, " (ID: " ); + buffer.AppendNum( ref index, (byte)block ); + buffer.Append( ref index, ", place: " ); buffer.Append( ref index, game.Inventory.CanPlace[(int)block] ? "&aYes" : "&cNo" ); - buffer.Append( ref index, "&f, can delete: " ); + buffer.Append( ref index, "&f, delete: " ); buffer.Append( ref index, game.Inventory.CanDelete[(int)block] ? "&aYes" : "&cNo" ); buffer.Append( ref index, "&f)" ); } @@ -150,6 +148,10 @@ namespace ClassicalSharp { string origName = Enum.GetName( typeof(Block), (byte)i ); buffer.Clear(); + if( origName == "TNT") { + normalNames[i] = "TNT"; + continue; + } int index = 0; SplitUppercase( origName, ref index ); normalNames[i] = buffer.ToString(); diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs index d01a69ae0..427cf2a26 100644 --- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs @@ -14,18 +14,18 @@ namespace ClassicalSharp { INetworkProcessor network = game.Network; buttons = new ButtonWidget[] { - // Column 1 - Make( -140, -150, "Simple arms anim", OnWidgetClick, - g => g.SimpleArmsAnim? "yes" : "no", - (g, v) => { g.SimpleArmsAnim = v == "yes"; - Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }), - - Make( -140, -100, "Use sound", OnWidgetClick, + // Column 1 + Make( -140, -150, "Use sound", OnWidgetClick, g => g.UseSound ? "yes" : "no", (g, v) => { g.UseSound = v == "yes"; g.AudioPlayer.SetSound( g.UseSound ); Options.Set( OptionsKey.UseSound, v == "yes" ); }), + Make( -140, -100, "Simple arms anim", OnWidgetClick, + g => g.SimpleArmsAnim? "yes" : "no", + (g, v) => { g.SimpleArmsAnim = v == "yes"; + Options.Set( OptionsKey.SimpleArmsAnim, v == "yes" ); }), + Make( -140, -50, "Names mode", OnWidgetClick, g => g.Players.NamesMode.ToString(), (g, v) => { object raw = Enum.Parse( typeof(NameMode), v ); @@ -44,35 +44,40 @@ namespace ClassicalSharp { // Column 2 !network.IsSinglePlayer ? null : - Make( 140, -150, "Block physics", OnWidgetClick, + Make( 140, -200, "Block physics", OnWidgetClick, g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", (g, v) => { ((SinglePlayerServer)network).physics.Enabled = v == "yes"; Options.Set( OptionsKey.SingleplayerPhysics, v == "yes" ); }), - Make( 140, -100, "Use music", OnWidgetClick, + Make( 140, -150, "Use music", OnWidgetClick, g => g.UseMusic ? "yes" : "no", (g, v) => { g.UseMusic = v == "yes"; g.AudioPlayer.SetMusic( g.UseMusic ); Options.Set( OptionsKey.UseMusic, v == "yes" ); }), - Make( 140, -50, "View bobbing", OnWidgetClick, + Make( 140, -100, "View bobbing", OnWidgetClick, g => g.ViewBobbing ? "yes" : "no", (g, v) => { g.ViewBobbing = v == "yes"; Options.Set( OptionsKey.ViewBobbing, v == "yes" ); }), - Make( 140, 0, "Auto close launcher", OnWidgetClick, + Make( 140, -50, "Auto close launcher", OnWidgetClick, g => Options.GetBool( OptionsKey.AutoCloseLauncher, false ) ? "yes" : "no", (g, v) => Options.Set( OptionsKey.AutoCloseLauncher, v == "yes" ) ), + Make( 140, 0, "Invert mouse", OnWidgetClick, + g => g.InvertMouse ? "yes" : "no", + (g, v) => { g.InvertMouse = v == "yes"; + Options.Set( OptionsKey.InvertMouse, v == "yes" ); }), + Make( 140, 50, "Mouse sensitivity", OnWidgetClick, g => g.MouseSensitivity.ToString(), (g, v) => { g.MouseSensitivity = Int32.Parse( v ); Options.Set( OptionsKey.Sensitivity, v ); } ), MakeBack( false, titleFont, - (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), + (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), null, }; buttons[2].Metadata = typeof(NameMode); @@ -89,6 +94,7 @@ namespace ClassicalSharp { new BooleanValidator(), new BooleanValidator(), new BooleanValidator(), + new BooleanValidator(), new IntegerValidator( 1, 100 ), }; okayIndex = buttons.Length - 1; @@ -96,7 +102,7 @@ namespace ClassicalSharp { ButtonWidget Make( int x, int y, string text, Action onClick, Func getter, Action setter ) { - ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, + ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, Anchor.Centre, titleFont, onClick ); widget.GetValue = getter; widget.SetValue = setter; diff --git a/ClassicalSharp/Game/Game.Properties.cs b/ClassicalSharp/Game/Game.Properties.cs index 20bab7e18..c0e5432dc 100644 --- a/ClassicalSharp/Game/Game.Properties.cs +++ b/ClassicalSharp/Game/Game.Properties.cs @@ -104,7 +104,10 @@ namespace ClassicalSharp { public bool ShowAxisLines; /// Whether players should animate using simple swinging parallel to their bodies. - public bool SimpleArmsAnim = false; + public bool SimpleArmsAnim; + + /// Whether mouse rotation on the y axis should be inverted. + public bool InvertMouse; public long Vertices; public FrustumCulling Culling; diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 807553fef..adfa2fb80 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -62,6 +62,7 @@ namespace ClassicalSharp { Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false ); ViewBobbing = Options.GetBool( OptionsKey.ViewBobbing, false ); ShowBlockInHand = Options.GetBool( OptionsKey.ShowBlockInHand, true ); + InvertMouse = Options.GetBool( OptionsKey.InvertMouse, false ); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); diff --git a/ClassicalSharp/Utils/Camera.cs b/ClassicalSharp/Utils/Camera.cs index dbf984c69..1c00e6937 100644 --- a/ClassicalSharp/Utils/Camera.cs +++ b/ClassicalSharp/Utils/Camera.cs @@ -87,7 +87,8 @@ namespace ClassicalSharp { private void UpdateMouseRotation() { float sensitivity = sensiFactor * game.MouseSensitivity; float yaw = player.nextYaw + delta.X * sensitivity; - float pitch = player.nextPitch + delta.Y * sensitivity; + float yAdj = game.InvertMouse ? -delta.Y * sensitivity : delta.Y * sensitivity; + float pitch = player.nextPitch + yAdj; LocationUpdate update = LocationUpdate.MakeOri( yaw, pitch ); // Need to make sure we don't cross the vertical axes, because that gets weird. diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index 396c7aa6a..11118e241 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -33,6 +33,7 @@ namespace ClassicalSharp { public const string FieldOfView = "fov"; public const string LiquidsBreakable = "liquidsbreakable"; public const string PushbackPlacing = "pushbackplacing"; + public const string InvertMouse = "invertmouse"; } // TODO: implement this