From f069a32222605ce0770461b312e7c1baf8cd13a2 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 28 Oct 2015 17:21:29 +1100 Subject: [PATCH] Use default.png for chat, can toggle on or off with an option. --- .../2D/Screens/Menu/KeyBindingsScreen.cs | 3 +- .../2D/Screens/Menu/OptionsScreen.cs | 37 +++++++++++-------- ClassicalSharp/2D/Screens/Menu/PauseScreen.cs | 27 ++++++++++---- .../2D/Widgets/Chat/TextInputWidget.cs | 12 +++--- ClassicalSharp/ClassicalSharp.csproj | 2 +- ClassicalSharp/Game/Game.cs | 1 + ClassicalSharp/Game/InputHandler.cs | 7 ---- ClassicalSharp/Utils/Options.cs | 1 + 8 files changed, 52 insertions(+), 38 deletions(-) diff --git a/ClassicalSharp/2D/Screens/Menu/KeyBindingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/KeyBindingsScreen.cs index 71e115a83..f644ff1eb 100644 --- a/ClassicalSharp/2D/Screens/Menu/KeyBindingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/KeyBindingsScreen.cs @@ -35,7 +35,8 @@ namespace ClassicalSharp { MakeKeys( 0, 11, -140 ); MakeKeys( 11, 11, 140 ); - buttons[index] = Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ); + buttons[index] = Make( 0, 5, "Back to menu", Anchor.BottomOrRight, + (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ); statusWidget = TextWidget.Create( game, 0, 150, "", Anchor.Centre, Anchor.Centre, regularFont ); } diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs index 4c9334f19..c88c2c1c7 100644 --- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs @@ -33,28 +33,33 @@ namespace ClassicalSharp { g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ), // Column 2 - Make( 140, -100, "Chat font size", Anchor.Centre, OnWidgetClick, - g => g.Chat.FontSize.ToString(), - (g, v) => { g.Chat.FontSize = Int32.Parse( v ); - Options.Set( OptionsKey.FontSize, v ); } ), - - Make( 140, -50, "Chat lines", Anchor.Centre, OnWidgetClick, - g => g.ChatLines.ToString(), - (g, v) => { g.ChatLines = Int32.Parse( v ); - Options.Set( OptionsKey.ChatLines, v ); } ), - - Make( 140, 0, "Mouse sensitivity", Anchor.Centre, OnWidgetClick, + 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, "Key bindings", Anchor.Centre, - (g, w) => g.SetNewScreen( new KeyBindingsScreen( g ) ), null, null ), + Make( 140, -50, "Chat font size", Anchor.Centre, OnWidgetClick, + g => g.Chat.FontSize.ToString(), + (g, v) => { g.Chat.FontSize = Int32.Parse( v ); + Options.Set( OptionsKey.FontSize, v ); } ), + + Make( 140, 0, "Chat lines", Anchor.Centre, OnWidgetClick, + g => g.ChatLines.ToString(), + (g, v) => { g.ChatLines = Int32.Parse( v ); + Options.Set( OptionsKey.ChatLines, v ); } ), + + 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(); } ), + // Extra stuff !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") ), Make( 140, -150, "Pushback block placing", Anchor.Centre, OnWidgetClick, g => g.PushbackBlockPlacing ? "yes" : "no", (g, v) => g.PushbackBlockPlacing = (v == "yes" ) ), @@ -69,10 +74,10 @@ namespace ClassicalSharp { new BooleanValidator(), new IntegerValidator( 16, 4096 ), + new IntegerValidator( 1, 100 ), new IntegerValidator( 6, 30 ), new IntegerValidator( 1, 30 ), - new IntegerValidator( 1, 100 ), - null, + new BooleanValidator(), network.IsSinglePlayer ? new BooleanValidator() : null, new BooleanValidator() diff --git a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs index a37a58e77..e18f34b57 100644 --- a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs @@ -19,17 +19,28 @@ namespace ClassicalSharp { public override void Init() { titleFont = new Font( "Arial", 16, FontStyle.Bold ); buttons = new ButtonWidget[] { - Make( -140, -100, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), - Make( -140, -50, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), - Make( -140, 0, "Select texture pack", Anchor.Centre, (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ), - Make( -140, 50, "Hotkeys", Anchor.Centre, (g, w) => g.SetNewScreen( new HotkeyScreen( g ) ) ), + // Column 1 + Make( -140, -100, "Options", Anchor.Centre, + (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), + Make( -140, -50, "Environment settings", Anchor.Centre, + (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), - Make( 140, -100, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), + Make( -140, 0, "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, + (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), !game.Network.IsSinglePlayer ? null : - Make( 140, -50, "Load level", Anchor.Centre, (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), + Make( 140, -50, "Load level", Anchor.Centre, + (g, w) => g.SetNewScreen( new LoadLevelScreen( g ) ) ), // TODO: singleplayer Generate level screen - - Make( 0, 55, "Back to game", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ), + Make( 140, 50, "Select texture pack", Anchor.Centre, + (g, w) => g.SetNewScreen( new TexturePackScreen( g ) ) ), + // Other + Make( 0, 55, "Back to game", Anchor.BottomOrRight, + (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ), Make( 0, 5, "Quit game", Anchor.BottomOrRight, (g, w) => g.Exit() ), }; } diff --git a/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.cs b/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.cs index 582ece85a..7cd779a6b 100644 --- a/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.cs +++ b/ClassicalSharp/2D/Widgets/Chat/TextInputWidget.cs @@ -42,14 +42,16 @@ namespace ClassicalSharp { public override void Init() { X = 10; DrawTextArgs args = new DrawTextArgs( "_", boldFont, false ); - caretTexture = game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); + caretTexture = game.Drawer2D.UseBitmappedChat ? + game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 ) : + game.Drawer2D.MakeTextTexture( ref args, 0, 0 ); chatInputText.WordWrap( ref parts, ref partLens, 64 ); maxWidth = 0; args = new DrawTextArgs( null, font, false ); for( int i = 0; i < lines; i++ ) { args.Text = parts[i]; - sizes[i] = game.Drawer2D.MeasureSize( ref args ); + sizes[i] = game.Drawer2D.MeasureChatSize( ref args ); maxWidth = Math.Max( maxWidth, sizes[i].Width ); } @@ -80,11 +82,11 @@ namespace ClassicalSharp { caretCol = nextCaretCol; } else { args.Text = parts[indexY].Substring( 0, indexX ); - Size trimmedSize = game.Drawer2D.MeasureSize( ref args ); + Size trimmedSize = game.Drawer2D.MeasureChatSize( ref args ); caretTexture.X1 = 10 + trimmedSize.Width; args.Text = new String( parts[indexY][indexX], 1 ); - Size charSize = game.Drawer2D.MeasureSize( ref args ); + Size charSize = game.Drawer2D.MeasureChatSize( ref args ); caretTexture.Width = charSize.Width; caretTexture.Y1 = sizes[0].Height * indexY; @@ -112,7 +114,7 @@ namespace ClassicalSharp { args.Text = parts[i]; drawer.Clear( backColour, 0, yyy, sizes[i].Width, sizes[i].Height ); - drawer.DrawText( ref args, 0, yyy ); + drawer.DrawChatText( ref args, 0, yyy ); yyy += sizes[i].Height; } chatInputTexture = drawer.Make2DTexture( bmp, size, 10, y ); diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj index d5518f3f5..bf1058384 100644 --- a/ClassicalSharp/ClassicalSharp.csproj +++ b/ClassicalSharp/ClassicalSharp.csproj @@ -4,7 +4,7 @@ {BEB1C785-5CAD-48FF-A886-876BF0A318D4} Debug AnyCPU - WinExe + Exe ClassicalSharp ClassicalSharp v2.0 diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 17de18ba5..66e584bac 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -109,6 +109,7 @@ namespace ClassicalSharp { ModelCache.InitCache(); AsyncDownloader = new AsyncDownloader( skinServer ); Drawer2D = new GdiPlusDrawer2D( Graphics ); + Drawer2D.UseBitmappedChat = !Options.GetBool( OptionsKey.ArialChatFont, false ); TerrainAtlas1D = new TerrainAtlas1D( Graphics ); TerrainAtlas = new TerrainAtlas2D( Graphics, Drawer2D ); diff --git a/ClassicalSharp/Game/InputHandler.cs b/ClassicalSharp/Game/InputHandler.cs index d47dde4dd..ece0b03ca 100644 --- a/ClassicalSharp/Game/InputHandler.cs +++ b/ClassicalSharp/Game/InputHandler.cs @@ -268,13 +268,6 @@ namespace ClassicalSharp { Key key = e.Key; if( SimulateMouse( key, true ) ) return; - // TODO: this is a temp debug statement - // NOTE: this is a temp debug statement - if( key == Key.F8 ) { - game.Drawer2D.UseBitmappedChat = !game.Drawer2D.UseBitmappedChat; - game.Events.RaiseChatFontChanged(); - return; - } if( key == Key.F4 && (game.IsKeyDown( Key.AltLeft ) || game.IsKeyDown( Key.AltRight )) ) { game.Exit(); } else if( key == Keys[KeyBinding.Screenshot] ) { diff --git a/ClassicalSharp/Utils/Options.cs b/ClassicalSharp/Utils/Options.cs index 719d066e2..5356b7164 100644 --- a/ClassicalSharp/Utils/Options.cs +++ b/ClassicalSharp/Utils/Options.cs @@ -12,6 +12,7 @@ namespace ClassicalSharp { public const string Sensitivity = "mousesensitivity"; public const string Speed = "speedmultiplier"; public const string ChatLines = "chatlines"; + public const string ArialChatFont = "arialchatfont"; public const string MouseLeft = "mouseleft"; public const string MouseMiddle = "mousemiddle";