From 9c60cb2c8221b50c1e2db484f11d1043817ca220 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 15 Mar 2021 12:56:50 -0400 Subject: [PATCH] feat: update hotbar dimensions on layout change --- HUD Manager/PluginUi.cs | 2 +- HUD Manager/Structs/Options/HotbarOptions.cs | 29 +++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/HUD Manager/PluginUi.cs b/HUD Manager/PluginUi.cs index 658d7d2..b976fd6 100644 --- a/HUD Manager/PluginUi.cs +++ b/HUD Manager/PluginUi.cs @@ -835,7 +835,7 @@ namespace HUD_Manager { } if (kind.IsHotbar()) { - var hotbarOpts = new HotbarOptions(element.Options); + var hotbarOpts = new HotbarOptions(element); if (kind != ElementKind.PetHotbar) { ImGui.NextColumn(); diff --git a/HUD Manager/Structs/Options/HotbarOptions.cs b/HUD Manager/Structs/Options/HotbarOptions.cs index 4000c79..d3eed1a 100755 --- a/HUD Manager/Structs/Options/HotbarOptions.cs +++ b/HUD Manager/Structs/Options/HotbarOptions.cs @@ -1,5 +1,8 @@ -namespace HUD_Manager.Structs.Options { +using System; + +namespace HUD_Manager.Structs.Options { public class HotbarOptions { + private readonly Element _element; private readonly byte[] _options; public byte Index { @@ -9,11 +12,17 @@ public HotbarLayout Layout { get => (HotbarLayout) this._options[1]; - set => this._options[1] = (byte) value; + set { + this._options[1] = (byte) value; + var size = value.Size(); + this._element.Width = size.X; + this._element.Height = size.Y; + } } - public HotbarOptions(byte[] options) { - this._options = options; + public HotbarOptions(Element element) { + this._element = element; + this._options = element.Options; } } @@ -38,5 +47,17 @@ _ => layout.ToString(), }; } + + public static Vector2 Size(this HotbarLayout layout) { + return layout switch { + HotbarLayout.TwelveByOne => new Vector2(624, 72), + HotbarLayout.SixByTwo => new Vector2(331, 121), + HotbarLayout.FourByThree => new Vector2(241, 170), + HotbarLayout.ThreeByFour => new Vector2(162, 260), + HotbarLayout.TwoBySix => new Vector2(117, 358), + HotbarLayout.OneByTwelve => new Vector2(72, 618), + _ => throw new ArgumentOutOfRangeException(nameof(layout), layout, null), + }; + } } }