From 58585827fc488d22cf45d7db30e0b159b02bcd2a Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 11 Apr 2018 07:07:57 +1000 Subject: [PATCH] Simplify menu code a bit --- ClassicalSharp/2D/GuiElement.cs | 6 ++-- ClassicalSharp/2D/Screens/ChatScreen.cs | 4 +-- ClassicalSharp/2D/Screens/DisconnectScreen.cs | 4 +-- .../2D/Screens/Menu/ClassicOptionsScreen.cs | 36 ++++++++++--------- .../2D/Screens/Menu/ClickableScreen.cs | 4 +-- .../2D/Screens/Menu/EnvSettingsScreen.cs | 4 ++- .../2D/Screens/Menu/GraphicsOptionsScreen.cs | 17 +++++---- .../2D/Screens/Menu/GuiOptionsScreen.cs | 30 ++++++++-------- .../2D/Screens/Menu/HacksSettingsScreen.cs | 30 ++++++++-------- .../2D/Screens/Menu/MenuOptionsScreen.cs | 33 ++++++++++------- .../2D/Screens/Menu/MiscOptionsScreen.cs | 18 +++++----- .../2D/Screens/Menu/NostalgiaScreen.cs | 31 ++++++---------- ClassicalSharp/2D/Widgets/HotbarWidget.cs | 2 +- ClassicalSharp/MeshBuilder/Builder.cs | 2 +- 14 files changed, 116 insertions(+), 105 deletions(-) diff --git a/ClassicalSharp/2D/GuiElement.cs b/ClassicalSharp/2D/GuiElement.cs index 85c6c0e50..c4bbc1f36 100644 --- a/ClassicalSharp/2D/GuiElement.cs +++ b/ClassicalSharp/2D/GuiElement.cs @@ -72,11 +72,13 @@ namespace ClassicalSharp.Gui { public Anchor HorizontalAnchor, VerticalAnchor; public int XOffset, YOffset; - public Rectangle Bounds { get { return new Rectangle(X, Y, Width, Height); } } - public virtual void Reposition() { X = CalcPos(HorizontalAnchor, XOffset, Width, game.Width); Y = CalcPos(VerticalAnchor, YOffset, Height, game.Height); } + + public bool Contains(int x, int y) { + return GuiElement.Contains(X, Y, Width, Height, x, y); + } } } diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index cdfc03f9d..b69f1305d 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -400,8 +400,8 @@ namespace ClassicalSharp.Gui.Screens { public override bool HandlesMouseDown(int mouseX, int mouseY, MouseButton button) { if (!HandlesAllInput || game.HideGui) return false; - if (!normalChat.Bounds.Contains(mouseX, mouseY)) { - if (altText.Active && altText.Bounds.Contains(mouseX, mouseY)) { + if (!normalChat.Contains(mouseX, mouseY)) { + if (altText.Active && altText.Contains(mouseX, mouseY)) { altText.HandlesMouseDown(mouseX, mouseY, button); UpdateAltTextY(); return true; diff --git a/ClassicalSharp/2D/Screens/DisconnectScreen.cs b/ClassicalSharp/2D/Screens/DisconnectScreen.cs index db05c6ef5..3d3c77385 100644 --- a/ClassicalSharp/2D/Screens/DisconnectScreen.cs +++ b/ClassicalSharp/2D/Screens/DisconnectScreen.cs @@ -72,7 +72,7 @@ namespace ClassicalSharp.Gui.Screens { public override bool HandlesMouseDown(int mouseX, int mouseY, MouseButton button) { if (button != MouseButton.Left) return true; - if (!reconnect.Disabled && reconnect.Bounds.Contains(mouseX, mouseY)) { + if (!reconnect.Disabled && reconnect.Contains(mouseX, mouseY)) { string connect = "Connecting to " + game.IPAddress + ":" + game.Port + ".."; for (int i = 0; i < game.Components.Count; i++) game.Components[i].Reset(game); @@ -85,7 +85,7 @@ namespace ClassicalSharp.Gui.Screens { } public override bool HandlesMouseMove(int mouseX, int mouseY) { - reconnect.Active = !reconnect.Disabled && reconnect.Bounds.Contains(mouseX, mouseY); + reconnect.Active = !reconnect.Disabled && reconnect.Contains(mouseX, mouseY); return true; } diff --git a/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs index 9016ad3fa..b93950b8a 100644 --- a/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/ClassicOptionsScreen.cs @@ -20,18 +20,20 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextRecreated() { bool multi = !game.Server.IsSinglePlayer, hacks = game.ClassicHacks; - ClickHandler onClick = OnButtonClick; + ClickHandler onEnum = OnEnumClick; + ClickHandler onBool = OnBoolClick; + widgets = new Widget[] { - MakeOpt(-1, -150, "Music", onClick, GetMusic, SetMusic), - MakeOpt(-1, -100, "Invert mouse", onClick, GetInvert, SetInvert), - MakeOpt(-1, -50, "Render distance", onClick, GetViewDist, SetViewDist), - multi ? null : MakeOpt(-1, 0, "Block physics", onClick, GetPhysics, SetPhysics), + MakeOpt(-1, -150, "Music", onBool, GetMusic, SetMusic), + MakeOpt(-1, -100, "Invert mouse", onBool, GetInvert, SetInvert), + MakeOpt(-1, -50, "Render distance", onEnum, GetViewDist, SetViewDist), + multi ? null : MakeOpt(-1, 0, "Block physics", onBool, GetPhysics, SetPhysics), - MakeOpt(1, -150, "Sound", onClick, GetSounds, SetSounds), - MakeOpt(1, -100, "Show FPS", onClick, GetShowFPS, SetShowFPS), - MakeOpt(1, -50, "View bobbing", onClick, GetViewBob, SetViewBob), - MakeOpt(1, 0, "FPS mode", onClick, GetFPS, SetFPS), - !hacks ? null : MakeOpt(0, 60, "Hacks enabled", onClick, GetHacks, SetHacks), + MakeOpt(1, -150, "Sound", onBool, GetSounds, SetSounds), + MakeOpt(1, -100, "Show FPS", onBool, GetShowFPS, SetShowFPS), + MakeOpt(1, -50, "View bobbing", onBool, GetViewBob, SetViewBob), + MakeOpt(1, 0, "FPS mode", onEnum, GetFPS, SetFPS), + !hacks ? null : MakeOpt(0, 60, "Hacks enabled", onBool, GetHacks, SetHacks), ButtonWidget.Create(game, 400, "Controls...", titleFont, SwitchClassic) .SetLocation(Anchor.Centre, Anchor.Max, 0, 95), @@ -92,16 +94,16 @@ namespace ClassicalSharp.Gui.Screens { void MakeValidators() { IServerConnection network = game.Server; validators = new MenuInputValidator[] { - new BooleanValidator(), - new BooleanValidator(), + null, + null, new EnumValidator(typeof(ViewDist)), - network.IsSinglePlayer ? new BooleanValidator() : null, + null, - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), + null, + null, + null, new EnumValidator(typeof(FpsLimitMethod)), - game.ClassicHacks ? new BooleanValidator() : null, + null, }; } } diff --git a/ClassicalSharp/2D/Screens/Menu/ClickableScreen.cs b/ClassicalSharp/2D/Screens/Menu/ClickableScreen.cs index 5548109e1..f1d7fcf90 100644 --- a/ClassicalSharp/2D/Screens/Menu/ClickableScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/ClickableScreen.cs @@ -24,7 +24,7 @@ namespace ClassicalSharp.Gui.Screens { // iterate backwards (because last elements rendered are shown over others) for (int i = widgets.Length - 1; i >= 0; i--) { Widget widget = widgets[i]; - if (widget == null || !widget.Bounds.Contains(mouseX, mouseY)) continue; + if (widget == null || !widget.Contains(mouseX, mouseY)) continue; if (widget.Disabled) return i; if (widget.MenuClick != null && button == MouseButton.Left) { @@ -45,7 +45,7 @@ namespace ClassicalSharp.Gui.Screens { for (int i = widgets.Length - 1; i >= 0; i--) { Widget widget = widgets[i]; - if (widget == null || !widget.Bounds.Contains(mouseX, mouseY)) continue; + if (widget == null || !widget.Contains(mouseX, mouseY)) continue; widget.Active = true; return i; diff --git a/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs index 0d1abbf07..99a53780d 100644 --- a/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/EnvSettingsScreen.cs @@ -24,6 +24,8 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextRecreated() { ClickHandler onClick = OnButtonClick; + ClickHandler onEnum = OnEnumClick; + widgets = new Widget[] { MakeOpt(-1, -150, "Clouds col", onClick, GetCloudsCol, SetCloudsCol), MakeOpt(-1, -100, "Sky col", onClick, GetSkyCol, SetSkyCol), @@ -33,7 +35,7 @@ namespace ClassicalSharp.Gui.Screens { MakeOpt(1, -150, "Sunlight col", onClick, GetSunCol, SetSunCol), MakeOpt(1, -100, "Shadow col", onClick, GetShadowCol, SetShadowCol), - MakeOpt(1, -50, "Weather", onClick, GetWeather, SetWeather), + MakeOpt(1, -50, "Weather", onEnum, GetWeather, SetWeather), MakeOpt(1, 0, "Rain/Snow speed", onClick, GetWeatherSpeed, SetWeatherSpeed), MakeOpt(1, 50, "Water level", onClick, GetEdgeHeight, SetEdgeHeight), diff --git a/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs index f6666fcd5..88c8b5339 100644 --- a/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/GraphicsOptionsScreen.cs @@ -20,14 +20,17 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextRecreated() { ClickHandler onClick = OnButtonClick; + ClickHandler onEnum = OnEnumClick; + ClickHandler onBool = OnBoolClick; + widgets = new Widget[] { - MakeOpt(-1, -50, "FPS mode", onClick, GetFPS, SetFPS), + MakeOpt(-1, -50, "FPS mode", onEnum, GetFPS, SetFPS), MakeOpt(-1, 0, "View distance", onClick, GetViewDist, SetViewDist), - MakeOpt(-1, 50, "Advanced lighting", onClick, GetSmooth, SetSmooth), + MakeOpt(-1, 50, "Advanced lighting", onBool, GetSmooth, SetSmooth), - MakeOpt(1, -50, "Names", onClick, GetNames, SetNames), - MakeOpt(1, 0, "Shadows", onClick, GetShadows, SetShadows), - MakeOpt(1, 50, "Mipmaps", onClick, GetMipmaps, SetMipmaps), + MakeOpt(1, -50, "Names", onEnum, GetNames, SetNames), + MakeOpt(1, 0, "Shadows", onEnum, GetShadows, SetShadows), + MakeOpt(1, 50, "Mipmaps", onBool, GetMipmaps, SetMipmaps), MakeBack(false, titleFont, SwitchOptions), null, null, @@ -86,11 +89,11 @@ namespace ClassicalSharp.Gui.Screens { validators = new MenuInputValidator[] { new EnumValidator(typeof(FpsLimitMethod)), new IntegerValidator(8, 4096), - new BooleanValidator(), + null, new EnumValidator(typeof(NameMode)), new EnumValidator(typeof(EntityShadow)), - new BooleanValidator(), + null, }; } diff --git a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs index 508e1d5a7..4cd63ad40 100644 --- a/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/GuiOptionsScreen.cs @@ -16,18 +16,20 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextRecreated() { ClickHandler onClick = OnButtonClick; + ClickHandler onBool = OnBoolClick; + widgets = new Widget[] { - MakeOpt(-1, -150, "Black text shadows", onClick, GetShadows, SetShadows), - MakeOpt(-1, -100, "Show FPS", onClick, GetShowFPS, SetShowFPS), - MakeOpt(-1, -50, "Hotbar scale", onClick, GetHotbar, SetHotbar), - MakeOpt(-1, 0, "Inventory scale", onClick, GetInventory, SetInventory), - MakeOpt(-1, 50, "Tab auto-complete", onClick, GetTabAuto, SetTabAuto), + MakeOpt(-1, -150, "Black text shadows", onBool, GetShadows, SetShadows), + MakeOpt(-1, -100, "Show FPS", onBool, GetShowFPS, SetShowFPS), + MakeOpt(-1, -50, "Hotbar scale", onClick, GetHotbar, SetHotbar), + MakeOpt(-1, 0, "Inventory scale", onClick, GetInventory, SetInventory), + MakeOpt(-1, 50, "Tab auto-complete", onBool, GetTabAuto, SetTabAuto), - MakeOpt(1, -150, "Clickable chat", onClick, GetClickable, SetClickable), + MakeOpt(1, -150, "Clickable chat", onBool, GetClickable, SetClickable), MakeOpt(1, -100, "Chat scale", onClick, GetChatScale, SetChatScale), - MakeOpt(1, -50, "Chat lines", onClick, GetChatlines, SetChatlines), - MakeOpt(1, 0, "Use system font", onClick, GetUseFont, SetUseFont), - MakeOpt(1, 50, "Font", onClick, GetFont, SetFont), + MakeOpt(1, -50, "Chat lines", onClick, GetChatlines, SetChatlines), + MakeOpt(1, 0, "Use system font", onBool, GetUseFont, SetUseFont), + MakeOpt(1, 50, "Font", onClick, GetFont, SetFont), MakeBack(false, titleFont, SwitchOptions), null, null, @@ -94,16 +96,16 @@ namespace ClassicalSharp.Gui.Screens { void MakeValidators() { validators = new MenuInputValidator[] { - new BooleanValidator(), - new BooleanValidator(), + null, + null, new RealValidator(0.25f, 4f), new RealValidator(0.25f, 4f), - new BooleanValidator(), + null, - new BooleanValidator(), + null, new RealValidator(0.25f, 4f), new IntegerValidator(0, 30), - new BooleanValidator(), + null, new StringValidator(), }; } diff --git a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs index 46190b50f..3c8677a8b 100644 --- a/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/HacksSettingsScreen.cs @@ -27,17 +27,19 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextRecreated() { ClickHandler onClick = OnButtonClick; + ClickHandler onBool = OnBoolClick; + widgets = new Widget[] { - MakeOpt(-1, -150, "Hacks enabled", onClick, GetHacks, SetHacks), + MakeOpt(-1, -150, "Hacks enabled", onBool, GetHacks, SetHacks), MakeOpt(-1, -100, "Speed multiplier", onClick, GetSpeed, SetSpeed), - MakeOpt(-1, -50, "Camera clipping", onClick, GetClipping, SetClipping), + MakeOpt(-1, -50, "Camera clipping", onBool, GetClipping, SetClipping), MakeOpt(-1, 0, "Jump height", onClick, GetJump, SetJump), - MakeOpt(-1, 50, "WOM style hacks", onClick, GetWOMHacks, SetWOMHacks), + MakeOpt(-1, 50, "WOM style hacks", onBool, GetWOMHacks, SetWOMHacks), - MakeOpt(1, -150, "Full block stepping", onClick, GetFullStep, SetFullStep), - MakeOpt(1, -100, "Modifiable liquids", onClick, GetLiquids, SetLiquids), - MakeOpt(1, -50, "Pushback placing", onClick, GetPushback, SetPushback), - MakeOpt(1, 0, "Noclip slide", onClick, GetSlide, SetSlide), + MakeOpt(1, -150, "Full block stepping", onBool, GetFullStep, SetFullStep), + MakeOpt(1, -100, "Modifiable liquids", onBool, GetLiquids, SetLiquids), + MakeOpt(1, -50, "Pushback placing", onBool, GetPushback, SetPushback), + MakeOpt(1, 0, "Noclip slide", onBool, GetSlide, SetSlide), MakeOpt(1, 50, "Field of view", onClick, GetFOV, SetFOV), null, @@ -134,16 +136,16 @@ namespace ClassicalSharp.Gui.Screens { void MakeValidators() { validators = new MenuInputValidator[] { - new BooleanValidator(), + null, new RealValidator(0.1f, 50), - new BooleanValidator(), + null, new RealValidator(0.1f, 2048f), - new BooleanValidator(), + null, - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), + null, + null, + null, + null, new IntegerValidator(1, 150), }; } diff --git a/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs index 785d8084c..268c997c5 100644 --- a/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MenuOptionsScreen.cs @@ -162,24 +162,31 @@ namespace ClassicalSharp.Gui.Screens { ChangeSetting(); } - protected void OnButtonClick(Game game, Widget widget) { - ButtonWidget button = widget as ButtonWidget; - if (button == null) return; + protected void OnBoolClick(Game game, Widget widget) { + ButtonWidget button = (ButtonWidget)widget; + DisposeExtendedHelp(); + + string value = button.GetValue(game); + SetButtonValue(button, value == "ON" ? "OFF" : "ON"); + UpdateDescription(button); + } + + protected void OnEnumClick(Game game, Widget widget) { + ButtonWidget button = (ButtonWidget)widget; DisposeExtendedHelp(); int index = IndexOfWidget(button); MenuInputValidator validator = validators[index]; - if (validator is BooleanValidator) { - string value = button.GetValue(game); - SetButtonValue(button, value == "ON" ? "OFF" : "ON"); - UpdateDescription(button); - return; - } else if (validator is EnumValidator) { - Type type = ((EnumValidator)validator).EnumType; - HandleEnumOption(button, type); - return; - } + Type type = ((EnumValidator)validator).EnumType; + HandleEnumOption(button, type); + } + + protected void OnButtonClick(Game game, Widget widget) { + ButtonWidget button = (ButtonWidget)widget; + DisposeExtendedHelp(); + int index = IndexOfWidget(button); + MenuInputValidator validator = validators[index]; activeButton = button; InputClosed(); diff --git a/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs b/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs index c06c689c1..1b9584ac7 100644 --- a/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/MiscOptionsScreen.cs @@ -19,15 +19,17 @@ namespace ClassicalSharp.Gui.Screens { protected override void ContextRecreated() { bool multi = !game.Server.IsSinglePlayer; ClickHandler onClick = OnButtonClick; + ClickHandler onBool = OnBoolClick; + widgets = new Widget[] { multi ? null : MakeOpt(-1, -100, "Reach distance", onClick, GetReach, SetReach), MakeOpt(-1, -50, "Music volume", onClick, GetMusic, SetMusic), MakeOpt(-1, 0, "Sounds volume", onClick, GetSounds, SetSounds), - MakeOpt(-1, 50, "View bobbing", onClick, GetViewBob, SetViewBob), + MakeOpt(-1, 50, "View bobbing", onBool, GetViewBob, SetViewBob), - multi ? null : MakeOpt(1, -100, "Block physics", onClick, GetPhysics, SetPhysics), - MakeOpt(1, -50, "Auto close launcher", onClick, GetAutoClose, SetAutoClose), - MakeOpt(1, 0, "Invert mouse", onClick, GetInvert, SetInvert), + multi ? null : MakeOpt(1, -100, "Block physics", onBool, GetPhysics, SetPhysics), + MakeOpt(1, -50, "Auto close launcher", onBool, GetAutoClose, SetAutoClose), + MakeOpt(1, 0, "Invert mouse", onBool, GetInvert, SetInvert), MakeOpt(1, 50, "Mouse sensitivity", onClick, GetSensitivity, SetSensitivity), MakeBack(false, titleFont, SwitchOptions), @@ -78,11 +80,11 @@ namespace ClassicalSharp.Gui.Screens { network.IsSinglePlayer ? new RealValidator(1, 1024) : null, new IntegerValidator(0, 100), new IntegerValidator(0, 100), - new BooleanValidator(), + null, - network.IsSinglePlayer ? new BooleanValidator() : null, - new BooleanValidator(), - new BooleanValidator(), + null, + null, + null, new IntegerValidator(1, 200), }; } diff --git a/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs b/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs index 809e56447..dec8c79a9 100644 --- a/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs +++ b/ClassicalSharp/2D/Screens/Menu/NostalgiaScreen.cs @@ -13,32 +13,21 @@ namespace ClassicalSharp.Gui.Screens { public override void Init() { base.Init(); ContextRecreated(); - - validators = new MenuInputValidator[] { - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), - - new BooleanValidator(), - new BooleanValidator(), - new BooleanValidator(), - }; } protected override void ContextRecreated() { - ClickHandler onClick = OnButtonClick; + ClickHandler onBool = OnBoolClick; + widgets = new Widget[] { - MakeOpt(-1, -150, "Classic hand model", onClick, GetHand, SetHand), - MakeOpt(-1, -100, "Classic walk anim", onClick, GetAnim, SetAnim), - MakeOpt(-1, -50, "Classic gui textures", onClick, GetGui, SetGui), - MakeOpt(-1, 0, "Classic player list", onClick, GetList, SetList), - MakeOpt(-1, 50, "Classic options", onClick, GetOpts, SetOpts), + MakeOpt(-1, -150, "Classic hand model", onBool, GetHand, SetHand), + MakeOpt(-1, -100, "Classic walk anim", onBool, GetAnim, SetAnim), + MakeOpt(-1, -50, "Classic gui textures", onBool, GetGui, SetGui), + MakeOpt(-1, 0, "Classic player list", onBool, GetList, SetList), + MakeOpt(-1, 50, "Classic options", onBool, GetOpts, SetOpts), - MakeOpt(1, -150, "Allow custom blocks", onClick, GetCustom, SetCustom), - MakeOpt(1, -100, "Use CPE", onClick, GetCPE, SetCPE), - MakeOpt(1, -50, "Use server textures", onClick, GetTexs, SetTexs), + MakeOpt(1, -150, "Allow custom blocks", onBool, GetCustom, SetCustom), + MakeOpt(1, -100, "Use CPE", onBool, GetCPE, SetCPE), + MakeOpt(1, -50, "Use server textures", onBool, GetTexs, SetTexs), TextWidget.Create(game, "&eButtons on the right require restarting game", textFont) .SetLocation(Anchor.Centre, Anchor.Centre, 0, 100), diff --git a/ClassicalSharp/2D/Widgets/HotbarWidget.cs b/ClassicalSharp/2D/Widgets/HotbarWidget.cs index cc231409a..4e736c0b3 100644 --- a/ClassicalSharp/2D/Widgets/HotbarWidget.cs +++ b/ClassicalSharp/2D/Widgets/HotbarWidget.cs @@ -122,7 +122,7 @@ namespace ClassicalSharp.Gui.Widgets { } public override bool HandlesMouseDown(int mouseX, int mouseY, MouseButton button) { - if (button != MouseButton.Left || !Bounds.Contains(mouseX, mouseY)) + if (button != MouseButton.Left || !Contains(mouseX, mouseY)) return false; InventoryScreen screen = game.Gui.ActiveScreen as InventoryScreen; if (screen == null) return false; diff --git a/ClassicalSharp/MeshBuilder/Builder.cs b/ClassicalSharp/MeshBuilder/Builder.cs index 54d45ddf1..a112fa626 100644 --- a/ClassicalSharp/MeshBuilder/Builder.cs +++ b/ClassicalSharp/MeshBuilder/Builder.cs @@ -283,7 +283,7 @@ namespace ClassicalSharp { } index++; - if (counts[index] == 0 || + if (counts[index] == 0 || y == 0 || (hidden[tileIdx + chunk[cIndex - 324]] & (1 << Side.Bottom)) != 0) { counts[index] = 0; } else {