diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index e318f85f3..d63a131a1 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -79,8 +79,8 @@ namespace ClassicalSharp { Font chatFont, chatInputFont, chatUnderlineFont, announcementFont; public override void Init() { - int fontSize = (int)(14 * game.GuiScale()); - Utils.Clamp( ref fontSize, 8, 40 ); + int fontSize = (int)(12 * game.GuiScale() * game.ChatScale); + Utils.Clamp( ref fontSize, 8, 60 ); chatFont = new Font( "Arial", fontSize ); chatInputFont = new Font( "Arial", fontSize, FontStyle.Bold ); diff --git a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs new file mode 100644 index 000000000..df46f44ff --- /dev/null +++ b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs @@ -0,0 +1,76 @@ +using System; + +namespace ClassicalSharp { + + public class GuiOptionsScreen : MenuInputScreen { + + public GuiOptionsScreen( Game game ) : base( game ) { + } + + public override void Init() { + base.Init(); + INetworkProcessor network = game.Network; + + buttons = new ButtonWidget[] { + // Column 1 + Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick, + g => g.ShowFPS ? "yes" : "no", + (g, v) => g.ShowFPS = v == "yes" ), + + Make( -140, 0, "Hud scale", Anchor.Centre, OnWidgetClick, + g => g.HudScale.ToString(), + (g, v) => { g.HudScale = Single.Parse( v ); + Options.Set( OptionsKey.HudScale, v ); + g.RefreshHud(); + } ), + + // Column 2 + Make( 140, -50, "Chat scale", Anchor.Centre, OnWidgetClick, + g => g.ChatScale.ToString(), + (g, v) => { g.ChatScale = Single.Parse( v ); + Options.Set( OptionsKey.ChatScale, v ); + g.RefreshHud(); + } ), + + Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick, + g => g.ChatLines.ToString(), + (g, v) => { g.ChatLines = Int32.Parse( v ); + Options.Set( OptionsKey.ChatLines, v ); + g.RefreshHud(); + } ), + + Make( 140, 50, "Arial chat font", Anchor.Centre, OnWidgetClick, + g => g.Drawer2D.UseBitmappedChat ? "no" : "yes", + (g, v) => { + g.Drawer2D.UseBitmappedChat = v == "no"; + Options.Set( OptionsKey.ArialChatFont, v == "yes" ); + game.Events.RaiseChatFontChanged(); + g.RefreshHud(); + } ), + + + Make( 0, 5, "Back to menu", Anchor.BottomOrRight, + (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ), + null, + }; + validators = new MenuInputValidator[] { + new BooleanValidator(), + new RealValidator( 0.25f, 5f ), + + new RealValidator( 0.25f, 5f ), + new IntegerValidator( 1, 30 ), + new BooleanValidator(), + new BooleanValidator(), + }; + okayIndex = buttons.Length - 1; + } + + ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action onClick, + Func getter, Action setter ) { + ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick ); + widget.GetValue = getter; + widget.SetValue = setter; + return widget; + } + } +} \ No newline at end of file diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs index 35b8ea2e7..8f30cc082 100644 --- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs @@ -15,15 +15,17 @@ namespace ClassicalSharp { buttons = new ButtonWidget[] { // Column 1 - Make( -140, -100, "Speed multiplier", Anchor.Centre, OnWidgetClick, + Make( -140, -100, "Show hover names", Anchor.Centre, OnWidgetClick, + g => g.Players.ShowHoveredNames ? "yes" : "no", + (g, v) => { + g.Players.ShowHoveredNames = v == "yes"; + Options.Set( OptionsKey.ShowHoveredNames, v == "yes" ); + }), + Make( -140, -50, "Speed multiplier", Anchor.Centre, OnWidgetClick, g => g.LocalPlayer.SpeedMultiplier.ToString(), (g, v) => { g.LocalPlayer.SpeedMultiplier = Single.Parse( v ); Options.Set( OptionsKey.Speed, v ); } ), - Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick, - g => g.ShowFPS ? "yes" : "no", - (g, v) => g.ShowFPS = v == "yes" ), - Make( -140, 0, "VSync active", Anchor.Centre, OnWidgetClick, g => g.VSync ? "yes" : "no", (g, v) => { g.Graphics.SetVSync( g, v == "yes" ); @@ -32,76 +34,39 @@ namespace ClassicalSharp { Make( -140, 50, "View distance", Anchor.Centre, OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ), + // Column 2 - Make( 140, -100, "Mouse sensitivity", Anchor.Centre, OnWidgetClick, - g => g.MouseSensitivity.ToString(), - (g, v) => { g.MouseSensitivity = Int32.Parse( v ); - Options.Set( OptionsKey.Sensitivity, v ); } ), - - Make( 140, -50, "Hud scale", Anchor.Centre, OnWidgetClick, - g => g.HudScale.ToString(), - (g, v) => { g.HudScale = Single.Parse( v ); - Options.Set( OptionsKey.HudScale, v ); - g.RefreshHud(); - } ), - - Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick, - g => g.ChatLines.ToString(), - (g, v) => { g.ChatLines = Int32.Parse( v ); - Options.Set( OptionsKey.ChatLines, v ); - g.RefreshHud(); - } ), - - Make( 140, 50, "Arial chat font", Anchor.Centre, OnWidgetClick, - g => g.Drawer2D.UseBitmappedChat ? "no" : "yes", - (g, v) => { - g.Drawer2D.UseBitmappedChat = v == "no"; - Options.Set( OptionsKey.ArialChatFont, v == "yes" ); - game.Events.RaiseChatFontChanged(); - g.RefreshHud(); - } ), - - // Extra stuff !network.IsSinglePlayer ? null : - Make( -140, -200, "Singleplayer physics", Anchor.Centre, OnWidgetClick, + Make( 140, -50, "Singleplayer physics", Anchor.Centre, OnWidgetClick, g => ((SinglePlayerServer)network).physics.Enabled ? "yes" : "no", (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 + Make( 140, 0, "Pushback block placing", Anchor.Centre, OnWidgetClick, + g => g.LocalPlayer.PushbackBlockPlacing && g.LocalPlayer.CanPushbackBlocks ? "yes" : "no", - (g, v) => { + (g, v) => { if( g.LocalPlayer.CanPushbackBlocks) - g.LocalPlayer.PushbackBlockPlacing = v == "yes"; + g.LocalPlayer.PushbackBlockPlacing = v == "yes"; }), - - Make( -140, -150, "Show hover names", Anchor.Centre, OnWidgetClick, - g => g.Players.ShowHoveredNames ? "yes" : "no", - (g, v) => { - g.Players.ShowHoveredNames = v == "yes"; - Options.Set( OptionsKey.ShowHoveredNames, v == "yes" ); - }), - + Make( 140, 50, "Mouse sensitivity", Anchor.Centre, OnWidgetClick, + g => g.MouseSensitivity.ToString(), + (g, v) => { g.MouseSensitivity = Int32.Parse( v ); + Options.Set( OptionsKey.Sensitivity, v ); } ), Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ), null, }; validators = new MenuInputValidator[] { - new RealValidator( 0.1f, 50 ), new BooleanValidator(), + new RealValidator( 0.1f, 50 ), new BooleanValidator(), new IntegerValidator( 16, 4096 ), - new IntegerValidator( 1, 100 ), - new RealValidator( 0.25f, 2f ), - new IntegerValidator( 1, 30 ), - new BooleanValidator(), - network.IsSinglePlayer ? new BooleanValidator() : null, new BooleanValidator(), - new BooleanValidator(), + new IntegerValidator( 1, 100 ), }; okayIndex = buttons.Length - 1; } diff --git a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs index dfe430333..9de82b62b 100644 --- a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs @@ -20,20 +20,21 @@ namespace ClassicalSharp { titleFont = new Font( "Arial", 16, FontStyle.Bold ); buttons = new ButtonWidget[] { // Column 1 - Make( -140, -100, "Options", Anchor.Centre, + Make( -140, -150, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), + Make( -140, -100, "Gui options", Anchor.Centre, + (g, w) => g.SetNewScreen( new GuiOptionsScreen( g ) ) ), Make( -140, -50, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), - - Make( -140, 0, "Hotkeys", Anchor.Centre, + Make( -140, 0, "Key bindings", Anchor.Centre, + (g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ) ), + Make( -140, 50, "Hotkeys", Anchor.Centre, (g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ), - Make( -140, 50, "Key bindings", Anchor.Centre, - (g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ) ), // Column 2 - Make( 140, -100, "Save level", Anchor.Centre, + Make( 140, -150, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), !game.Network.IsSinglePlayer ? null : - Make( 140, -50, "Load level", Anchor.Centre, + Make( 140, -100, "Load level", Anchor.Centre, (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), // TODO: singleplayer Generate level screen Make( 140, 50, "Select texture pack", Anchor.Centre, diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs index 8ab8f4ba0..7cc1f8423 100644 --- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs +++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs @@ -26,7 +26,7 @@ namespace ClassicalSharp { } static FastColour backCol = new FastColour( 60, 60, 60, 160 ); - static FastColour outlineCol = new FastColour( 169, 143, 192 ); + static FastColour outlineCol = new FastColour( 151, 120, 180 ); static FastColour selCol = new FastColour( 213, 200, 223 ); public override void Init() { blockSize = (int)(38 * game.GuiScale()); diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj index c31dd718e..f1e080bb7 100644 --- a/ClassicalSharp/ClassicalSharp.csproj +++ b/ClassicalSharp/ClassicalSharp.csproj @@ -91,6 +91,7 @@ + diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 337244e5e..dde9475e6 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 = 0.8f; + internal float HudScale = 1.0f, ChatScale = 1.0f; public Animations Animations; internal int CloudsTextureId, RainTextureId, SnowTextureId; @@ -124,7 +124,8 @@ namespace ClassicalSharp { ViewDistance = Options.GetInt( OptionsKey.ViewDist, 16, 4096, 512 ); InputHandler = new InputHandler( this ); Chat = new ChatLog( this ); - HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 2f, 1 ); + HudScale = Options.GetFloat( OptionsKey.HudScale, 0.25f, 5f, 1f ); + ChatScale = Options.GetFloat( OptionsKey.ChatScale, 0.35f, 5f, 1f ); defaultIb = Graphics.MakeDefaultIb(); MouseSensitivity = Options.GetInt( OptionsKey.Sensitivity, 1, 100, 30 ); BlockInfo = new BlockInfo(); diff --git a/ClassicalSharp/Game/InputHandler.cs b/ClassicalSharp/Game/InputHandler.cs index fd80820da..146f41a13 100644 --- a/ClassicalSharp/Game/InputHandler.cs +++ b/ClassicalSharp/Game/InputHandler.cs @@ -77,9 +77,8 @@ namespace ClassicalSharp { int buttonsDown = (left ? 1 : 0) + (right ? 1 : 0) + (middle ? 1 : 0); if( buttonsDown > 1 || game.ScreenLockedInput || inv.HeldBlock == Block.Air ) return; - // always play animations, even if we aren't picking a block. + // always play delete animations, even if we aren't picking a block. if( left ) game.BlockHandRenderer.SetAnimationClick( true ); - else if( right ) game.BlockHandRenderer.SetAnimationClick( false ); if( !game.SelectedPos.Valid ) return; if( middle ) { @@ -96,7 +95,7 @@ namespace ClassicalSharp { && inv.CanDelete[block] ) { game.ParticleManager.BreakBlockEffect( pos, block ); game.UpdateBlock( pos.X, pos.Y, pos.Z, 0 ); - game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, false, (byte)inv.HeldBlock ); + game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, false, (byte)inv.HeldBlock ); } } else if( right ) { Vector3I pos = game.SelectedPos.TranslatedPos; @@ -106,7 +105,8 @@ namespace ClassicalSharp { if( !game.CanPick( game.Map.GetBlock( pos ) ) && inv.CanPlace[block] && CheckIsFree( game.SelectedPos, block ) ) { game.UpdateBlock( pos.X, pos.Y, pos.Z, block ); - game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, true, block ); + game.Network.SendSetBlock( pos.X, pos.Y, pos.Z, true, block ); + game.BlockHandRenderer.SetAnimationClick( false ); } } } @@ -285,7 +285,7 @@ namespace ClassicalSharp { } } - void HandleHotkey( Key key ) { + void HandleHotkey( Key key ) { string text; bool more; diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index 1fc909d92..bfa561ae0 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -8,7 +8,8 @@ namespace ClassicalSharp { public static class OptionsKey { public const string ViewDist = "viewdist"; - public const string HudScale = "chatscale"; + public const string HudScale = "hudscale"; + public const string ChatScale = "chatscale"; public const string Sensitivity = "mousesensitivity"; public const string Speed = "speedmultiplier"; public const string ChatLines = "chatlines"; diff --git a/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs b/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs index 1e1660aa7..d48e90eba 100644 --- a/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs +++ b/Launcher2/Gui/Screens/ClassiCubeServersScreen.cs @@ -13,7 +13,7 @@ namespace Launcher2 { titleFont = new Font( "Arial", 16, FontStyle.Bold ); inputFont = new Font( "Arial", 13, FontStyle.Regular ); boldInputFont = new Font( "Arial", 13, FontStyle.Bold ); - enterIndex = 4; + enterIndex = 5; widgets = new LauncherWidget[7]; }