From e9c190c28cd5ebd2b0e2beb4ba9ca57bea3a81e6 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 9 Oct 2015 16:47:39 +1100 Subject: [PATCH] Refactor and comment gui, make tab list higher up and more solid. --- ClassicalSharp/2D/GuiElement.cs | 70 +++++++ ClassicalSharp/2D/Screens/ChatScreen.cs | 12 +- ClassicalSharp/2D/Screens/ErrorScreen.cs | 4 +- ClassicalSharp/2D/Screens/FpsScreen.cs | 3 + ClassicalSharp/2D/Screens/LoadingMapScreen.cs | 4 +- .../2D/Screens/Menu/EnvSettingsScreen.cs | 24 +-- .../2D/Screens/Menu/KeyMappingsScreen.cs | 12 +- .../2D/Screens/Menu/MenuInputScreen.cs | 6 +- ClassicalSharp/2D/Screens/Menu/MenuScreen.cs | 4 +- .../2D/Screens/Menu/OptionsScreen.cs | 18 +- ClassicalSharp/2D/Screens/Menu/PauseScreen.cs | 16 +- .../2D/Screens/Menu/SaveLevelScreen.cs | 12 +- ClassicalSharp/2D/Screens/NormalScreen.cs | 4 +- ClassicalSharp/2D/Screens/Screen.cs | 80 ++------ .../2D/Widgets/BlockHotbarWidget.cs | 4 +- ClassicalSharp/2D/Widgets/ButtonWidget.cs | 12 +- .../2D/Widgets/ExtPlayerListWidget.cs | 4 +- .../2D/Widgets/Menu/MenuInputWidget.cs | 16 +- .../2D/Widgets/NormalPlayerListWidget.cs | 4 +- ClassicalSharp/2D/Widgets/PlayerListWidget.cs | 32 ++- ClassicalSharp/2D/Widgets/TextGroupWidget.cs | 8 +- ClassicalSharp/2D/Widgets/TextInputWidget.cs | 4 +- ClassicalSharp/2D/Widgets/TextWidget.cs | 10 +- ClassicalSharp/2D/Widgets/Widget.cs | 188 ++++++------------ ClassicalSharp/ClassicalSharp.csproj | 1 + ClassicalSharp/Game/Game.cs | 2 +- Launcher/MainForm.Designer.cs | 40 ++-- 27 files changed, 280 insertions(+), 314 deletions(-) create mode 100644 ClassicalSharp/2D/GuiElement.cs diff --git a/ClassicalSharp/2D/GuiElement.cs b/ClassicalSharp/2D/GuiElement.cs new file mode 100644 index 000000000..1d70cad7e --- /dev/null +++ b/ClassicalSharp/2D/GuiElement.cs @@ -0,0 +1,70 @@ +using System; +using ClassicalSharp.GraphicsAPI; +using OpenTK.Input; + +namespace ClassicalSharp { + + public abstract class GuiElement : IDisposable { + + protected Game game; + protected IGraphicsApi graphicsApi; + + public GuiElement( Game game ) { + this.game = game; + graphicsApi = game.Graphics; + } + + public abstract void Init(); + + public abstract void Render( double delta ); + + public abstract void Dispose(); + + /// Called when the game window is resized. + public abstract void OnResize( int oldWidth, int oldHeight, int width, int height ); + + public virtual bool HandlesKeyDown( Key key ) { + return false; + } + + public virtual bool HandlesKeyPress( char key ) { + return false; + } + + public virtual bool HandlesKeyUp( Key key ) { + return false; + } + + public virtual bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) { + return false; + } + + public virtual bool HandlesMouseMove( int mouseX, int mouseY ) { + return false; + } + + public virtual bool HandlesMouseScroll( int delta ) { + return false; + } + + public virtual bool HandlesMouseUp( int mouseX, int mouseY, MouseButton button ) { + return false; + } + + protected static int CalcDelta( int newVal, int oldVal, Anchor mode ) { + return CalcOffset( newVal, oldVal, 0, mode ); + } + + protected static int CalcOffset( int axisSize, int elemSize, int offset, Anchor mode ) { + if( mode == Anchor.LeftOrTop ) return offset; + if( mode == Anchor.BottomOrRight) return axisSize - elemSize - offset; + return (axisSize - elemSize) / 2 + offset; + } + } + + public enum Anchor { + LeftOrTop = 0, + Centre = 1, + BottomOrRight = 2, + } +} diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index e49bb0965..c2bf3b246 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -56,19 +56,19 @@ namespace ClassicalSharp { textInput = new TextInputWidget( game, chatFont, chatInputFont ); textInput.YOffset = ChatInputYOffset; status = new TextGroupWidget( game, 3, chatFont ); - status.VerticalDocking = Docking.LeftOrTop; - status.HorizontalDocking = Docking.BottomOrRight; + status.VerticalAnchor = Anchor.LeftOrTop; + status.HorizontalAnchor = Anchor.BottomOrRight; status.Init(); bottomRight = new TextGroupWidget( game, 3, chatFont ); - bottomRight.VerticalDocking = Docking.BottomOrRight; - bottomRight.HorizontalDocking = Docking.BottomOrRight; + bottomRight.VerticalAnchor = Anchor.BottomOrRight; + bottomRight.HorizontalAnchor = Anchor.BottomOrRight; bottomRight.YOffset = ChatInputYOffset; bottomRight.Init(); normalChat = new TextGroupWidget( game, chatLines, chatFont ); normalChat.XOffset = 10; normalChat.YOffset = ChatLogYOffset; - normalChat.HorizontalDocking = Docking.LeftOrTop; - normalChat.VerticalDocking = Docking.BottomOrRight; + normalChat.HorizontalAnchor = Anchor.LeftOrTop; + normalChat.VerticalAnchor = Anchor.BottomOrRight; normalChat.Init(); ChatLog chat = game.Chat; diff --git a/ClassicalSharp/2D/Screens/ErrorScreen.cs b/ClassicalSharp/2D/Screens/ErrorScreen.cs index a992a4873..852ca8ee0 100644 --- a/ClassicalSharp/2D/Screens/ErrorScreen.cs +++ b/ClassicalSharp/2D/Screens/ErrorScreen.cs @@ -25,8 +25,8 @@ namespace ClassicalSharp { public override void Init() { graphicsApi.ClearColour( new FastColour( 65, 31, 31 ) ); - titleWidget = TextWidget.Create( game, 0, -30, title, Docking.Centre, Docking.Centre, titleFont ); - messageWidget = TextWidget.Create( game, 0, 10, message, Docking.Centre, Docking.Centre, messageFont ); + titleWidget = TextWidget.Create( game, 0, -30, title, Anchor.Centre, Anchor.Centre, titleFont ); + messageWidget = TextWidget.Create( game, 0, 10, message, Anchor.Centre, Anchor.Centre, messageFont ); } public override void Dispose() { diff --git a/ClassicalSharp/2D/Screens/FpsScreen.cs b/ClassicalSharp/2D/Screens/FpsScreen.cs index c7f91ceb3..48d211e86 100644 --- a/ClassicalSharp/2D/Screens/FpsScreen.cs +++ b/ClassicalSharp/2D/Screens/FpsScreen.cs @@ -73,6 +73,9 @@ namespace ClassicalSharp { graphicsApi.DeleteTexture( ref posTexture ); } + public override void OnResize( int oldWidth, int oldHeight, int width, int height ) { + } + void DrawPosition() { int index = 0; TextureRec xy = new TextureRec( 0, posTexture.Y1, baseWidth, posTexture.Height ); diff --git a/ClassicalSharp/2D/Screens/LoadingMapScreen.cs b/ClassicalSharp/2D/Screens/LoadingMapScreen.cs index 6bbaf8c4d..13bffbcfa 100644 --- a/ClassicalSharp/2D/Screens/LoadingMapScreen.cs +++ b/ClassicalSharp/2D/Screens/LoadingMapScreen.cs @@ -31,8 +31,8 @@ namespace ClassicalSharp { public override void Init() { graphicsApi.Fog = false; - titleWidget = TextWidget.Create( game, 0, 30, serverName, Docking.Centre, Docking.LeftOrTop, font ); - messageWidget = TextWidget.Create( game, 0, 60, serverMotd, Docking.Centre, Docking.LeftOrTop, font ); + titleWidget = TextWidget.Create( game, 0, 30, serverName, Anchor.Centre, Anchor.LeftOrTop, font ); + messageWidget = TextWidget.Create( game, 0, 60, serverMotd, Anchor.Centre, Anchor.LeftOrTop, font ); progX = game.Width / 2f - progWidth / 2f; Size size = new Size( progWidth, progHeight ); diff --git a/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs index ff2f7cb3b..ba1ce56d9 100644 --- a/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs @@ -13,46 +13,46 @@ namespace ClassicalSharp { base.Init(); buttons = new ButtonWidget[] { - Make( -140, -150, "Clouds colour", Docking.Centre, OnWidgetClick, + Make( -140, -150, "Clouds colour", Anchor.Centre, OnWidgetClick, g => g.Map.CloudsCol.ToRGBHexString(), (g, v) => g.Map.SetCloudsColour( FastColour.Parse( v ) ) ), - Make( -140, -100, "Sky colour", Docking.Centre, OnWidgetClick, + Make( -140, -100, "Sky colour", Anchor.Centre, OnWidgetClick, g => g.Map.SkyCol.ToRGBHexString(), (g, v) => g.Map.SetSkyColour( FastColour.Parse( v ) ) ), - Make( -140, -50, "Fog colour", Docking.Centre, OnWidgetClick, + Make( -140, -50, "Fog colour", Anchor.Centre, OnWidgetClick, g => g.Map.FogCol.ToRGBHexString(), (g, v) => g.Map.SetFogColour( FastColour.Parse( v ) ) ), - Make( -140, 0, "Clouds speed", Docking.Centre, OnWidgetClick, + Make( -140, 0, "Clouds speed", Anchor.Centre, OnWidgetClick, g => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer; return env == null ? "(not active)" : env.CloudsSpeed.ToString(); }, (g, v) => { StandardEnvRenderer env = game.EnvRenderer as StandardEnvRenderer; if( env != null ) env.CloudsSpeed = Single.Parse( v ); } ), - Make( -140, 50, "Clouds offset", Docking.Centre, OnWidgetClick, + Make( -140, 50, "Clouds offset", Anchor.Centre, OnWidgetClick, g => (g.Map.CloudHeight - g.Map.Height).ToString(), (g, v) => g.Map.SetCloudsLevel( g.Map.Height + Int32.Parse( v ) ) ), - Make( 140, -150, "Sunlight colour", Docking.Centre, OnWidgetClick, + Make( 140, -150, "Sunlight colour", Anchor.Centre, OnWidgetClick, g => g.Map.Sunlight.ToRGBHexString(), (g, v) => g.Map.SetSunlight( FastColour.Parse( v ) ) ), - Make( 140, -100, "Shadow colour", Docking.Centre, OnWidgetClick, + Make( 140, -100, "Shadow colour", Anchor.Centre, OnWidgetClick, g => g.Map.Shadowlight.ToRGBHexString(), (g, v) => g.Map.SetShadowlight( FastColour.Parse( v ) ) ), - Make( 140, -50, "Weather", Docking.Centre, OnWidgetClick, + Make( 140, -50, "Weather", Anchor.Centre, OnWidgetClick, g => ((int)g.Map.Weather).ToString(), (g, v) => g.Map.SetWeather( (Weather)Int32.Parse( v ) ) ), - Make( 140, 0, "Water level", Docking.Centre, OnWidgetClick, + Make( 140, 0, "Water level", Anchor.Centre, OnWidgetClick, g => g.Map.WaterHeight.ToString(), (g, v) => g.Map.SetWaterLevel( Int32.Parse( v ) ) ), - Make( 0, 5, "Back to menu", Docking.BottomOrRight, + Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ), null, }; @@ -71,9 +71,9 @@ namespace ClassicalSharp { okayIndex = buttons.Length - 1; } - ButtonWidget Make( int x, int y, string text, Docking vDocking, Action onClick, + 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, Docking.Centre, vDocking, titleFont, onClick ); + ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick ); widget.GetValue = getter; widget.SetValue = setter; return widget; diff --git a/ClassicalSharp/2D/Screens/Menu/KeyMappingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/KeyMappingsScreen.cs index d09431432..0edf5d917 100644 --- a/ClassicalSharp/2D/Screens/Menu/KeyMappingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/KeyMappingsScreen.cs @@ -35,8 +35,8 @@ namespace ClassicalSharp { MakeKeys( 0, 11, -140 ); MakeKeys( 11, 11, 140 ); - buttons[index] = Make( 0, 5, "Back to menu", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ); - statusWidget = TextWidget.Create( game, 0, 150, "", Docking.Centre, Docking.Centre, regularFont ); + 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 ); } int index; @@ -47,7 +47,7 @@ namespace ClassicalSharp { string text = descriptions[start + i] + ": " + keyNames[(int)game.Keys[mapping]]; buttons[index++] = ButtonWidget.Create( game, x, y, 240, 25, text, - Docking.Centre, Docking.Centre, keyFont, OnWidgetClick ); + Anchor.Centre, Anchor.Centre, keyFont, OnWidgetClick ); y += 30; } } @@ -59,7 +59,7 @@ namespace ClassicalSharp { statusWidget.Dispose(); string text = "Press new key binding for " + descriptions[index] + ":"; - statusWidget = TextWidget.Create( game, 0, 150, text, Docking.Centre, Docking.Centre, regularFont ); + statusWidget = TextWidget.Create( game, 0, 150, text, Anchor.Centre, Anchor.Centre, regularFont ); } public override bool HandlesKeyDown( Key key ) { @@ -86,8 +86,8 @@ namespace ClassicalSharp { return true; } - ButtonWidget Make( int x, int y, string text, Docking vDocking, Action onClick ) { - return ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, keyFont, onClick ); + ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action onClick ) { + return ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, keyFont, onClick ); } public override void Dispose() { diff --git a/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs index 55d464681..ebd37cb5e 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuInputScreen.cs @@ -89,7 +89,7 @@ namespace ClassicalSharp { descWidget.Dispose(); string text = widget.Text + ": " + widget.GetValue( game ); - descWidget = TextWidget.Create( game, 0, 100, text, Docking.Centre, Docking.Centre, regularFont ); + descWidget = TextWidget.Create( game, 0, 100, text, Anchor.Centre, Anchor.Centre, regularFont ); } protected void OnWidgetClick( Game game, ButtonWidget widget ) { @@ -112,10 +112,10 @@ namespace ClassicalSharp { targetWidget = selectedWidget; inputWidget = MenuInputWidget.Create( game, 0, 150, 400, 25, widget.GetValue( game ), - Docking.Centre, Docking.Centre, regularFont, titleFont, + Anchor.Centre, Anchor.Centre, regularFont, titleFont, hintFont, validator ); buttons[okayIndex] = ButtonWidget.Create( game, 240, 150, 30, 30, "OK", - Docking.Centre, Docking.Centre, titleFont, OnWidgetClick ); + Anchor.Centre, Anchor.Centre, titleFont, OnWidgetClick ); UpdateDescription( targetWidget ); } diff --git a/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs index 9c86550cb..e45afc2b2 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuScreen.cs @@ -47,7 +47,7 @@ namespace ClassicalSharp { if( button != MouseButton.Left ) return false; for( int i = 0; i < buttons.Length; i++ ) { ButtonWidget widget = buttons[i]; - if( widget != null && widget.ContainsPoint( mouseX, mouseY ) ) { + if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) { if( widget.OnClick != null ) widget.OnClick( game, widget ); return true; @@ -64,7 +64,7 @@ namespace ClassicalSharp { for( int i = 0; i < buttons.Length; i++ ) { ButtonWidget widget = buttons[i]; - if( widget != null && widget.ContainsPoint( mouseX, mouseY ) ) { + if( widget != null && widget.Bounds.Contains( mouseX, mouseY ) ) { widget.Active = true; WidgetSelected( widget ); return true; diff --git a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs index 5d7060ff7..617a82894 100644 --- a/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/OptionsScreen.cs @@ -14,34 +14,34 @@ namespace ClassicalSharp { INetworkProcessor network = game.Network; buttons = new ButtonWidget[] { - Make( -140, -50, "Show FPS", Docking.Centre, OnWidgetClick, + Make( -140, -50, "Show FPS", Anchor.Centre, OnWidgetClick, g => g.ShowFPS ? "yes" : "no", (g, v) => g.ShowFPS = v == "yes" ), - Make( -140, 0, "View distance", Docking.Centre, OnWidgetClick, + Make( -140, 0, "View distance", Anchor.Centre, OnWidgetClick, g => g.ViewDistance.ToString(), (g, v) => g.SetViewDistance( Int32.Parse( v ) ) ), - Make( -140, 50, "VSync active", Docking.Centre, OnWidgetClick, + Make( -140, 50, "VSync active", Anchor.Centre, OnWidgetClick, g => g.VSync ? "yes" : "no", (g, v) => g.Graphics.SetVSync( g, v == "yes" ) ), - Make( 140, -50, "Mouse sensitivity", Docking.Centre, OnWidgetClick, + 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( 140, 0, "Chat font size", Docking.Centre, OnWidgetClick, + Make( 140, 0, "Chat font size", Anchor.Centre, OnWidgetClick, g => g.Chat.FontSize.ToString(), (g, v) => { g.Chat.FontSize = Int32.Parse( v ); Options.Set( OptionsKey.FontSize, v ); } ), !network.IsSinglePlayer ? null : - Make( 140, 50, "Singleplayer physics", Docking.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") ), - Make( 0, 5, "Back to menu", Docking.BottomOrRight, + Make( 0, 5, "Back to menu", Anchor.BottomOrRight, (g, w) => g.SetNewScreen( new PauseScreen( g ) ), null, null ), null, }; @@ -56,9 +56,9 @@ namespace ClassicalSharp { okayIndex = buttons.Length - 1; } - ButtonWidget Make( int x, int y, string text, Docking vDocking, Action onClick, + 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, Docking.Centre, vDocking, titleFont, onClick ); + ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick ); widget.GetValue = getter; widget.SetValue = setter; return widget; diff --git a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs index b68905eab..4c7f8053d 100644 --- a/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/PauseScreen.cs @@ -19,18 +19,18 @@ namespace ClassicalSharp { public override void Init() { titleFont = new Font( "Arial", 16, FontStyle.Bold ); buttons = new ButtonWidget[] { - Make( 0, -100, "Options", Docking.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), - Make( 0, -50, "Environment settings", Docking.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), - Make( 0, 0, "Key mappings", Docking.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ), - Make( 0, 50, "Save level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), + Make( 0, -100, "Options", Anchor.Centre, (g, w) => g.SetNewScreen( new OptionsScreen( g ) ) ), + Make( 0, -50, "Environment settings", Anchor.Centre, (g, w) => g.SetNewScreen( new EnvSettingsScreen( g ) ) ), + Make( 0, 0, "Key mappings", Anchor.Centre, (g, w) => g.SetNewScreen( new KeyMappingsScreen( g ) ) ), + Make( 0, 50, "Save level", Anchor.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), // TODO: singleplayer Make( 0, 50, "Load/Save/Gen level", Docking.Centre, (g, w) => g.SetNewScreen( new SaveLevelScreen( g ) ) ), - Make( 0, 55, "Back to game", Docking.BottomOrRight, (g, w) => g.SetNewScreen( new NormalScreen( g ) ) ), - Make( 0, 5, "Quit game", Docking.BottomOrRight, (g, w) => g.Exit() ), + 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() ), }; } - ButtonWidget Make( int x, int y, string text, Docking vDocking, Action onClick ) { - return ButtonWidget.Create( game, x, y, 240, 35, text, Docking.Centre, vDocking, titleFont, onClick ); + ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action onClick ) { + return ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick ); } public override bool HandlesKeyDown( Key key ) { diff --git a/ClassicalSharp/2D/Screens/Menu/SaveLevelScreen.cs b/ClassicalSharp/2D/Screens/Menu/SaveLevelScreen.cs index d9abe9f59..18e4d2921 100644 --- a/ClassicalSharp/2D/Screens/Menu/SaveLevelScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/SaveLevelScreen.cs @@ -52,13 +52,13 @@ namespace ClassicalSharp { hintFont = new Font( "Arial", 14, FontStyle.Italic ); inputWidget = MenuInputWidget.Create( - game, -30, 50, 500, 25, "", Docking.Centre, Docking.Centre, + game, -30, 50, 500, 25, "", Anchor.Centre, Anchor.Centre, regularFont, titleFont, hintFont, new PathValidator() ); buttons = new [] { - ButtonWidget.Create( game, 260, 50, 60, 30, "Save", Docking.Centre, - Docking.Centre, titleFont, OkButtonClick ), - ButtonWidget.Create( game, 0, 5, 240, 35, "Back to menu", Docking.Centre, Docking.BottomOrRight, + ButtonWidget.Create( game, 260, 50, 60, 30, "Save", Anchor.Centre, + Anchor.Centre, titleFont, OkButtonClick ), + ButtonWidget.Create( game, 0, 5, 240, 35, "Back to menu", Anchor.Centre, Anchor.BottomOrRight, titleFont, (g, w) => g.SetNewScreen( new PauseScreen( g ) ) ), }; } @@ -110,9 +110,9 @@ namespace ClassicalSharp { game.SetNewScreen( new PauseScreen( game ) ); } - void MakeDescWidget( string text) { + void MakeDescWidget( string text ) { DisposeDescWidget(); - descWidget = TextWidget.Create( game, 0, 90, text, Docking.Centre, Docking.Centre, regularFont ); + descWidget = TextWidget.Create( game, 0, 90, text, Anchor.Centre, Anchor.Centre, regularFont ); } void DisposeDescWidget() { diff --git a/ClassicalSharp/2D/Screens/NormalScreen.cs b/ClassicalSharp/2D/Screens/NormalScreen.cs index 6b869664b..5ab4c2713 100644 --- a/ClassicalSharp/2D/Screens/NormalScreen.cs +++ b/ClassicalSharp/2D/Screens/NormalScreen.cs @@ -67,7 +67,8 @@ namespace ClassicalSharp { chat.OnResize( oldWidth, oldHeight, width, height ); hotbar.OnResize( oldWidth, oldHeight, width, height ); if( playerList != null ) { - playerList.OnResize( oldWidth, oldHeight, width, height ); + int deltaX = CalcDelta( width, oldWidth, Anchor.Centre ); + playerList.MoveTo( playerList.X + deltaX, height / 4 ); } } @@ -102,6 +103,7 @@ namespace ClassicalSharp { playerList = new NormalPlayerListWidget( game, playerFont ); } playerList.Init(); + playerList.MoveTo( playerList.X, game.Height / 4 ); } } if( chat.HandlesKeyDown( key ) ) { diff --git a/ClassicalSharp/2D/Screens/Screen.cs b/ClassicalSharp/2D/Screens/Screen.cs index 073120fcf..12039cfd8 100644 --- a/ClassicalSharp/2D/Screens/Screen.cs +++ b/ClassicalSharp/2D/Screens/Screen.cs @@ -1,61 +1,21 @@ using System; -using ClassicalSharp.GraphicsAPI; -using OpenTK.Input; - -namespace ClassicalSharp { - - public abstract class Screen : IDisposable { - - protected Game game; - protected IGraphicsApi graphicsApi; - - public Screen( Game game ) { - this.game = game; - graphicsApi = game.Graphics; - } - - public virtual bool HandlesAllInput { get; protected set; } - - public abstract void Init(); - - public abstract void Render( double delta ); - - public abstract void Dispose(); - - public virtual void OnResize( int oldWidth, int oldHeight, int width, int height ) { - } - - public virtual bool HandlesKeyDown( Key key ) { - return false; - } - - public virtual bool HandlesKeyPress( char key ) { - return false; - } - - public virtual bool HandlesKeyUp( Key key ) { - return false; - } - - public virtual bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) { - return false; - } - - public virtual bool HandlesMouseMove( int mouseX, int mouseY ) { - return false; - } - - public virtual bool HandlesMouseScroll( int delta ) { - return false; - } - - public virtual bool HandlesMouseUp( int mouseX, int mouseY, MouseButton button ) { - return false; - } - - /// Whether the screen completely covers the world behind it. - public virtual bool BlocksWorld { - get { return false; } - } - } -} + +namespace ClassicalSharp { + + /// Represents a container of widgets and other 2D elements. + /// May cover the entire game window. + public abstract class Screen : GuiElement { + + public Screen( Game game ) : base( game ) { + } + + /// Whether this screen handles all mouse and keyboard input. + /// This prevents the client from interacting with the world. + public virtual bool HandlesAllInput { get; protected set; } + + /// Whether this screen completely and opaquely covers the game world behind it. + public virtual bool BlocksWorld { + get { return false; } + } + } +} diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs index f44054484..ac5acfc3e 100644 --- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs +++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs @@ -8,8 +8,8 @@ namespace ClassicalSharp { public sealed class BlockHotbarWidget : Widget { public BlockHotbarWidget( Game game ) : base( game ) { - HorizontalDocking = Docking.Centre; - VerticalDocking = Docking.BottomOrRight; + HorizontalAnchor = Anchor.Centre; + VerticalAnchor = Anchor.BottomOrRight; hotbarCount = game.Inventory.Hotbar.Length; } diff --git a/ClassicalSharp/2D/Widgets/ButtonWidget.cs b/ClassicalSharp/2D/Widgets/ButtonWidget.cs index 27b61742e..fe5b8ce41 100644 --- a/ClassicalSharp/2D/Widgets/ButtonWidget.cs +++ b/ClassicalSharp/2D/Widgets/ButtonWidget.cs @@ -10,12 +10,12 @@ namespace ClassicalSharp { this.font = font; } - public static ButtonWidget Create( Game game, int x, int y, int width, int height, string text, Docking horizontal, - Docking vertical, Font font, Action onClick ) { + public static ButtonWidget Create( Game game, int x, int y, int width, int height, string text, Anchor horizontal, + Anchor vertical, Font font, Action onClick ) { ButtonWidget widget = new ButtonWidget( game, font ); widget.Init(); - widget.HorizontalDocking = horizontal; - widget.VerticalDocking = vertical; + widget.HorizontalAnchor = horizontal; + widget.VerticalAnchor = vertical; widget.XOffset = x; widget.YOffset = y; widget.DesiredMaxWidth = width; @@ -47,8 +47,8 @@ namespace ClassicalSharp { Height = defaultHeight; } else { MakeTexture( text ); - X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalDocking ); - Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalDocking ); + X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalAnchor ); + Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalAnchor ); Height = texture.Height; } Width = texture.Width; diff --git a/ClassicalSharp/2D/Widgets/ExtPlayerListWidget.cs b/ClassicalSharp/2D/Widgets/ExtPlayerListWidget.cs index 627f49a04..cb975a018 100644 --- a/ClassicalSharp/2D/Widgets/ExtPlayerListWidget.cs +++ b/ClassicalSharp/2D/Widgets/ExtPlayerListWidget.cs @@ -83,7 +83,7 @@ namespace ClassicalSharp { RemoveItemAt( textures, i ); RemoveItemAt( info, i ); namesCount--; - columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); + columns = Utils.CeilDiv( namesCount, namesPerColumn ); SortPlayerInfo(); return; } @@ -92,7 +92,7 @@ namespace ClassicalSharp { void PlayerListInfoAdded( object sender, IdEventArgs e ) { AddPlayerInfo( game.CpePlayersList[e.Id], -1 ); - columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); + columns = Utils.CeilDiv( namesCount, namesPerColumn ); SortPlayerInfo(); } diff --git a/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs b/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs index f84df46f8..282fd0999 100644 --- a/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs +++ b/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs @@ -7,20 +7,20 @@ namespace ClassicalSharp { public sealed class MenuInputWidget : Widget { public MenuInputWidget( Game game, Font font, Font boldFont, Font hintFont ) : base( game ) { - HorizontalDocking = Docking.LeftOrTop; - VerticalDocking = Docking.BottomOrRight; + HorizontalAnchor = Anchor.LeftOrTop; + VerticalAnchor = Anchor.BottomOrRight; this.font = font; this.boldFont = boldFont; this.hintFont = hintFont; chatInputText = new StringBuffer( 64 ); } - public static MenuInputWidget Create( Game game, int x, int y, int width, int height, string text, Docking horizontal, - Docking vertical, Font font, Font tildeFont, Font hintFont, MenuInputValidator validator ) { + public static MenuInputWidget Create( Game game, int x, int y, int width, int height, string text, Anchor horizontal, + Anchor vertical, Font font, Font tildeFont, Font hintFont, MenuInputValidator validator ) { MenuInputWidget widget = new MenuInputWidget( game, font, tildeFont, hintFont ); - widget.HorizontalDocking = horizontal; - widget.VerticalDocking = vertical; + widget.HorizontalAnchor = horizontal; + widget.VerticalAnchor = vertical; widget.XOffset = x; widget.YOffset = y; widget.DesiredMaxWidth = width; @@ -76,8 +76,8 @@ namespace ClassicalSharp { } } - X = CalcOffset( game.Width, size.Width, XOffset, HorizontalDocking ); - Y = CalcOffset( game.Height, size.Height, YOffset, VerticalDocking ); + X = CalcOffset( game.Width, size.Width, XOffset, HorizontalAnchor ); + Y = CalcOffset( game.Height, size.Height, YOffset, VerticalAnchor ); chatCaretTexture.X1 = chatInputTexture.X1 = X; chatCaretTexture.X1 += textSize.Width; chatCaretTexture.Y1 = chatInputTexture.Y1 = Y; diff --git a/ClassicalSharp/2D/Widgets/NormalPlayerListWidget.cs b/ClassicalSharp/2D/Widgets/NormalPlayerListWidget.cs index 7f4a2daa8..33606ec3a 100644 --- a/ClassicalSharp/2D/Widgets/NormalPlayerListWidget.cs +++ b/ClassicalSharp/2D/Widgets/NormalPlayerListWidget.cs @@ -36,7 +36,7 @@ namespace ClassicalSharp { void PlayerSpawned( object sender, IdEventArgs e ) { Player player = game.Players[e.Id]; AddPlayerInfo( player ); - columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); + columns = Utils.CeilDiv( namesCount, namesPerColumn ); SortPlayerInfo(); } @@ -66,7 +66,7 @@ namespace ClassicalSharp { RemoveItemAt( info, i ); RemoveItemAt( textures, i ); namesCount--; - columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); + columns = Utils.CeilDiv( namesCount, namesPerColumn ); SortPlayerInfo(); return; } diff --git a/ClassicalSharp/2D/Widgets/PlayerListWidget.cs b/ClassicalSharp/2D/Widgets/PlayerListWidget.cs index 66e8d254d..1b563f20d 100644 --- a/ClassicalSharp/2D/Widgets/PlayerListWidget.cs +++ b/ClassicalSharp/2D/Widgets/PlayerListWidget.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Drawing; namespace ClassicalSharp { @@ -8,8 +7,8 @@ namespace ClassicalSharp { protected readonly Font font; public PlayerListWidget( Game game, Font font ) : base( game ) { - HorizontalDocking = Docking.Centre; - VerticalDocking = Docking.Centre; + HorizontalAnchor = Anchor.Centre; + VerticalAnchor = Anchor.Centre; this.font = font; } @@ -19,11 +18,11 @@ namespace ClassicalSharp { protected Texture[] textures = new Texture[256]; protected int columns; protected int xMin, xMax, yHeight; - protected static FastColour tableCol = new FastColour( 100, 100, 100, 80 ); + protected static FastColour tableCol = new FastColour( 20, 20, 20, 220 ); public override void Init() { CreateInitialPlayerInfo(); - columns = (int)Math.Ceiling( (double)namesCount / namesPerColumn ); + columns = Utils.CeilDiv( namesCount, namesPerColumn ); SortPlayerInfo(); } @@ -67,9 +66,8 @@ namespace ClassicalSharp { int maxWidth = 0; int maxIndex = Math.Min( namesCount, i + namesPerColumn ); - for( ; i < maxIndex; i++ ) { + for( ; i < maxIndex; i++ ) maxWidth = Math.Max( maxWidth, textures[i].Width ); - } return maxWidth; } @@ -78,9 +76,8 @@ namespace ClassicalSharp { int total = 0; int maxIndex = Math.Min( namesCount, i + namesPerColumn ); - for( ; i < maxIndex; i++ ) { + for( ; i < maxIndex; i++ ) total += textures[i].Height; - } return total; } @@ -90,24 +87,19 @@ namespace ClassicalSharp { for( ; i < maxIndex; i++ ) { Texture tex = textures[i]; - tex.X1 = x; - tex.Y1 = y; + tex.X1 = x; tex.Y1 = y; y += tex.Height; textures[i] = tex; } } public override void MoveTo( int newX, int newY ) { - int deltaX = newX - X; - int deltaY = newY - Y; + int diffX = newX - X; int diffY = newY - Y; for( int i = 0; i < namesCount; i++ ) { - Texture tex = textures[i]; - tex.X1 += deltaX; - tex.Y1 += deltaY; - textures[i] = tex; + textures[i].X1 += diffX; + textures[i].Y1 += diffY; } - X = newX; - Y = newY; + X = newX; Y = newY; } protected abstract void CreateInitialPlayerInfo(); @@ -131,7 +123,7 @@ namespace ClassicalSharp { int offset = 0; if( columns % 2 != 0 ) { // For an odd number of columns, the middle column is centred. - offset = ( GetColumnWidth( midCol ) + 1 ) / 2; // ceiling divide by 2 + offset = Utils.CeilDiv( GetColumnWidth( midCol ), 2 ); } int x = centreX - offset; diff --git a/ClassicalSharp/2D/Widgets/TextGroupWidget.cs b/ClassicalSharp/2D/Widgets/TextGroupWidget.cs index 2d0116c94..c2e346b24 100644 --- a/ClassicalSharp/2D/Widgets/TextGroupWidget.cs +++ b/ClassicalSharp/2D/Widgets/TextGroupWidget.cs @@ -31,7 +31,7 @@ namespace ClassicalSharp { if( !String.IsNullOrEmpty( text ) ) { DrawTextArgs args = new DrawTextArgs( text, true ); Texture tex = game.Drawer2D.MakeTextTexture( font, 0, 0, ref args ); - tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalDocking ); + tex.X1 = CalcOffset( game.Width, tex.Width, XOffset, HorizontalAnchor ); tex.Y1 = CalcY( index, tex.Height ); textures[index] = tex; } else { @@ -56,7 +56,7 @@ namespace ClassicalSharp { int y = 0; int deltaY = newHeight - textures[index].Height; - if( VerticalDocking == Docking.LeftOrTop ) { + if( VerticalAnchor == Anchor.LeftOrTop ) { y = Y; for( int i = 0; i < index; i++ ) { y += textures[i].Height; @@ -91,7 +91,7 @@ namespace ClassicalSharp { for( int i = 0; i < textures.Length; i++ ) { Height += textures[i].Height; } - Y = CalcOffset( game.Height, Height, YOffset, VerticalDocking ); + Y = CalcOffset( game.Height, Height, YOffset, VerticalAnchor ); Width = 0; for( int i = 0; i < textures.Length; i++ ) { @@ -100,7 +100,7 @@ namespace ClassicalSharp { Width = width; } } - X = CalcOffset( game.Width, Width, XOffset, HorizontalDocking ); + X = CalcOffset( game.Width, Width, XOffset, HorizontalAnchor ); } public override void Render( double delta ) { diff --git a/ClassicalSharp/2D/Widgets/TextInputWidget.cs b/ClassicalSharp/2D/Widgets/TextInputWidget.cs index a39dde0f0..6a21681cc 100644 --- a/ClassicalSharp/2D/Widgets/TextInputWidget.cs +++ b/ClassicalSharp/2D/Widgets/TextInputWidget.cs @@ -8,8 +8,8 @@ namespace ClassicalSharp { public sealed class TextInputWidget : Widget { public TextInputWidget( Game game, Font font, Font boldFont ) : base( game ) { - HorizontalDocking = Docking.LeftOrTop; - VerticalDocking = Docking.BottomOrRight; + HorizontalAnchor = Anchor.LeftOrTop; + VerticalAnchor = Anchor.BottomOrRight; typingLogPos = game.Chat.InputLog.Count; // Index of newest entry + 1. this.font = font; this.boldFont = boldFont; diff --git a/ClassicalSharp/2D/Widgets/TextWidget.cs b/ClassicalSharp/2D/Widgets/TextWidget.cs index 5338fafdc..39e0ef0d4 100644 --- a/ClassicalSharp/2D/Widgets/TextWidget.cs +++ b/ClassicalSharp/2D/Widgets/TextWidget.cs @@ -10,11 +10,11 @@ namespace ClassicalSharp { this.font = font; } - public static TextWidget Create( Game game, int x, int y, string text, Docking horizontal, Docking vertical, Font font ) { + public static TextWidget Create( Game game, int x, int y, string text, Anchor horizontal, Anchor vertical, Font font ) { TextWidget widget = new TextWidget( game, font ); widget.Init(); - widget.HorizontalDocking = horizontal; - widget.VerticalDocking = vertical; + widget.HorizontalAnchor = horizontal; + widget.VerticalAnchor = vertical; widget.XOffset = x; widget.YOffset = y; widget.SetText( text ); @@ -39,8 +39,8 @@ namespace ClassicalSharp { } else { DrawTextArgs args = new DrawTextArgs( text, true ); texture = game.Drawer2D.MakeTextTexture( font, 0, 0, ref args ); - X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalDocking ); - Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalDocking ); + X = texture.X1 = CalcOffset( game.Width, texture.Width, XOffset, HorizontalAnchor ); + Y = texture.Y1 = CalcOffset( game.Height, texture.Height, YOffset, VerticalAnchor ); Height = texture.Height; } Width = texture.Width; diff --git a/ClassicalSharp/2D/Widgets/Widget.cs b/ClassicalSharp/2D/Widgets/Widget.cs index 377269a07..497145dd5 100644 --- a/ClassicalSharp/2D/Widgets/Widget.cs +++ b/ClassicalSharp/2D/Widgets/Widget.cs @@ -1,125 +1,63 @@ -using System; -using System.Drawing; -using ClassicalSharp.GraphicsAPI; -using OpenTK.Input; - -namespace ClassicalSharp { - - public abstract class Widget : IDisposable { - - protected internal Game game; - protected IGraphicsApi graphicsApi; - - public Widget( Game game ) { - this.game = game; - graphicsApi = game.Graphics; - HorizontalDocking = Docking.LeftOrTop; - VerticalDocking = Docking.LeftOrTop; - } - - public int X { get; set; } - - public int Y { get; set; } - - public int Width { get; set; } - - public int Height { get; set; } - - public Docking HorizontalDocking { get; set; } - - public Docking VerticalDocking { get; set; } - - public Size Size { - get { return new Size( Width, Height ); } - } - - public Point TopLeft { - get { return new Point( X, Y ); } - } - - public Point BottomRight { - get { return new Point( X + Width, Y + Height ); } - } - - public Rectangle Bounds { - get { return new Rectangle( X, Y, Width, Height ); } - } - - public bool ContainsPoint( int x, int y ) { - return Bounds.Contains( x, y ); - } - - public bool ContainsPoint( Point point ) { - return Bounds.Contains( point ); - } - - public bool ContainsRectangle( Rectangle rect ) { - return Bounds.Contains( rect ); - } - - public bool IntersectsRectangle( Rectangle rect ) { - return Bounds.IntersectsWith( rect ); - } - - public virtual bool HandlesKeyDown( Key key ) { - return false; - } - - public virtual bool HandlesKeyPress( char key ) { - return false; - } - - public virtual bool HandlesKeyUp( Key key ) { - return false; - } - - public virtual bool HandleMouseClick( int mouseX, int mouseY ) { - return false; - } - - public virtual bool HandleMouseHover( int mouseX, int mouseY ) { - return false; - } - - public virtual bool HandleMouseLeave( int mouseX, int mouseY ) { - return false; - } - - public virtual bool HandleMouseDeClick( int mouseX, int mouseY ) { - return false; - } - - public abstract void Init(); - - public abstract void Render( double delta ); - - public abstract void Dispose(); - - public virtual void MoveTo( int newX, int newY ) { - X = newX; - Y = newY; - } - - public virtual void OnResize( int oldWidth, int oldHeight, int width, int height ) { - int deltaX = CalcDelta( width, oldWidth, HorizontalDocking ); - int deltaY = CalcDelta( height, oldHeight, VerticalDocking ); - MoveTo( X + deltaX, Y + deltaY ); - } - - protected static int CalcDelta( int newVal, int oldVal, Docking mode ) { - return CalcOffset( newVal, oldVal, 0, mode ); - } - - protected static int CalcOffset( int axisSize, int elemSize, int offset, Docking mode ) { - if( mode == Docking.LeftOrTop ) return offset; - if( mode == Docking.BottomOrRight) return axisSize - elemSize - offset; - return ( axisSize - elemSize ) / 2 + offset; - } - } - - public enum Docking { - LeftOrTop = 0, - Centre = 1, - BottomOrRight = 2, - } -} \ No newline at end of file +using System; +using System.Drawing; + +namespace ClassicalSharp { + + /// Represents an individual 2D gui component. + public abstract class Widget : GuiElement { + + public Widget( Game game ) : base( game ) { + HorizontalAnchor = Anchor.LeftOrTop; + VerticalAnchor = Anchor.LeftOrTop; + } + + /// Horizontal coordinate of top left corner in window space. + public int X; + + /// Vertical coordinate of top left corner in window space. + public int Y; + + /// Horizontal length of widget's bounds in window space. + public int Width; + + /// Vertical length of widget's bounds in window space. + public int Height; + + /// Specifies the horizontal reference point for when the widget is resized. + public Anchor HorizontalAnchor; + + /// Specifies the vertical reference point for when the widget is resized. + public Anchor VerticalAnchor; + + /// Width and height of widget in window space. + public Size Size { + get { return new Size( Width, Height ); } + } + + /// Coordinate of top left corner of widget's bounds in window space. + public Point TopLeft { + get { return new Point( X, Y ); } + } + + /// Coordinate of bottom right corner of widget's bounds in window space. + public Point BottomRight { + get { return new Point( X + Width, Y + Height ); } + } + + /// Specifies the boundaries of the widget in window space. + public Rectangle Bounds { + get { return new Rectangle( X, Y, Width, Height ); } + } + + /// Moves the widget to the specified window space coordinates. + public virtual void MoveTo( int newX, int newY ) { + X = newX; Y = newY; + } + + public override void OnResize( int oldWidth, int oldHeight, int width, int height ) { + int deltaX = CalcDelta( width, oldWidth, HorizontalAnchor ); + int deltaY = CalcDelta( height, oldHeight, VerticalAnchor ); + MoveTo( X + deltaX, Y + deltaY ); + } + } +} diff --git a/ClassicalSharp/ClassicalSharp.csproj b/ClassicalSharp/ClassicalSharp.csproj index 6cf2e7e6f..cfcc9f9c7 100644 --- a/ClassicalSharp/ClassicalSharp.csproj +++ b/ClassicalSharp/ClassicalSharp.csproj @@ -65,6 +65,7 @@ + diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index fb3f5fbbc..8179928d9 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -194,7 +194,7 @@ namespace ClassicalSharp { imageCheckAccumulator += e.Time; ticksAccumulator += e.Time; Vertices = 0; - if( !Focused && ( activeScreen == null || !activeScreen.HandlesAllInput ) ) { + if( !Focused && (activeScreen == null || !activeScreen.HandlesAllInput) ) { SetNewScreen( new PauseScreen( this ) ); } diff --git a/Launcher/MainForm.Designer.cs b/Launcher/MainForm.Designer.cs index b01f742b7..b7be82cbc 100644 --- a/Launcher/MainForm.Designer.cs +++ b/Launcher/MainForm.Designer.cs @@ -53,6 +53,8 @@ namespace Launcher this.txtCCSearch = new System.Windows.Forms.TextBox(); this.lblCCSearch = new System.Windows.Forms.Label(); this.tabMinecraftNet = new System.Windows.Forms.TabPage(); + this.lblMCdead2 = new System.Windows.Forms.Label(); + this.lblMCdead = new System.Windows.Forms.Label(); this.tabDC = new System.Windows.Forms.TabPage(); this.lblDChint = new System.Windows.Forms.Label(); this.txtDCmppass = new System.Windows.Forms.TextBox(); @@ -66,8 +68,6 @@ namespace Launcher this.lblDCaddress = new System.Windows.Forms.Label(); this.lblDCuser = new System.Windows.Forms.Label(); this.tabs = new System.Windows.Forms.TabControl(); - this.lblMCdead = new System.Windows.Forms.Label(); - this.lblMCdead2 = new System.Windows.Forms.Label(); this.tabClassicubeNet.SuspendLayout(); this.tabCC.SuspendLayout(); this.tabCCSignIn.SuspendLayout(); @@ -318,6 +318,24 @@ namespace Launcher this.tabMinecraftNet.Text = "minecraft.net"; this.tabMinecraftNet.UseVisualStyleBackColor = true; // + // lblMCdead2 + // + this.lblMCdead2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblMCdead2.Location = new System.Drawing.Point(20, 62); + this.lblMCdead2.Name = "lblMCdead2"; + this.lblMCdead2.Size = new System.Drawing.Size(300, 41); + this.lblMCdead2.TabIndex = 1; + this.lblMCdead2.Text = "But don\'t despair! You can sign up for an account at classicube.net."; + // + // lblMCdead + // + this.lblMCdead.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblMCdead.Location = new System.Drawing.Point(20, 20); + this.lblMCdead.Name = "lblMCdead"; + this.lblMCdead.Size = new System.Drawing.Size(380, 23); + this.lblMCdead.TabIndex = 0; + this.lblMCdead.Text = "Classic has been removed from minecraft.net."; + // // tabDC // this.tabDC.Controls.Add(this.lblDChint); @@ -450,24 +468,6 @@ namespace Launcher this.tabs.Size = new System.Drawing.Size(482, 466); this.tabs.TabIndex = 0; // - // lblMCdead - // - this.lblMCdead.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblMCdead.Location = new System.Drawing.Point(20, 20); - this.lblMCdead.Name = "lblMCdead"; - this.lblMCdead.Size = new System.Drawing.Size(380, 23); - this.lblMCdead.TabIndex = 0; - this.lblMCdead.Text = "Classic has been removed from minecraft.net."; - // - // lblMCdead2 - // - this.lblMCdead2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblMCdead2.Location = new System.Drawing.Point(20, 62); - this.lblMCdead2.Name = "lblMCdead2"; - this.lblMCdead2.Size = new System.Drawing.Size(300, 41); - this.lblMCdead2.TabIndex = 1; - this.lblMCdead2.Text = "But don\'t despair! You can sign up for an account at classicube.net."; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);