diff --git a/PathfinderAPI/Options/OptionsManager.cs b/PathfinderAPI/Options/OptionsManager.cs index 9fa8cf70..43d37a71 100644 --- a/PathfinderAPI/Options/OptionsManager.cs +++ b/PathfinderAPI/Options/OptionsManager.cs @@ -1,5 +1,7 @@ using Pathfinder.GUI; using BepInEx.Configuration; +using HarmonyLib; +using Hacknet; namespace Pathfinder.Options; diff --git a/PathfinderAPI/Options/PathfinderOptionsMenu.cs b/PathfinderAPI/Options/PathfinderOptionsMenu.cs index c291e7a1..8c5fa59d 100644 --- a/PathfinderAPI/Options/PathfinderOptionsMenu.cs +++ b/PathfinderAPI/Options/PathfinderOptionsMenu.cs @@ -72,16 +72,13 @@ internal static bool Draw(ref OptionsMenu __instance, GameTime gameTime) #pragma warning disable 618 var tabs = OptionsManager.Tabs; #pragma warning restore 618 - - int tabX = 10; + + int tabX = 10, tabY = 70; foreach (var tab in OptionsManager.PluginTabs) { - if(tab.ButtonData.X == null) - { - tab.ButtonData.Set(tabX); - tabX += 10 + tab.ButtonData.Width.GetValueOrDefault(); - } + if(tab.TrySetButtonOffset(new Point(tabX, tabY))) + tabX += 10 + tab.ButtonRect.Width; tab.OnDraw(gameTime); } @@ -91,7 +88,7 @@ internal static bool Draw(ref OptionsMenu __instance, GameTime gameTime) CurrentTabId = tab.Name; var active = CurrentTabId == tab.Name; // Display tab button - if (Button.doButton(tab.ButtonID, tabX, 70, 128, 20, tab.Name, active ? Color.Green : Color.Gray)) + if (Button.doButton(tab.ButtonID, tabX, tabY, 128, 20, tab.Name, active ? Color.Green : Color.Gray)) { CurrentTabId = tab.Name; break; diff --git a/PathfinderAPI/Options/PluginOptionTab.cs b/PathfinderAPI/Options/PluginOptionTab.cs index 33abadac..c8760ab0 100644 --- a/PathfinderAPI/Options/PluginOptionTab.cs +++ b/PathfinderAPI/Options/PluginOptionTab.cs @@ -20,14 +20,22 @@ public class PluginOptionTab : IReadOnlyDictionary public SpriteBatch Batch { get; internal set; } public int HacknetGuiId { get; } public bool IsLoaded { get; internal set; } - public PluginOptionDrawData ButtonData { get; set; } = new PluginOptionDrawData + public Rectangle ButtonRect { get; set; } = new Rectangle { X = 0, - Y = 70, + Y = 0, Width = 128, Height = 20 }; + public Point ButtonPosition => ButtonRect.Location + ButtonOffset; + public Point ButtonOffset { get; protected set; } + public virtual bool TrySetButtonOffset(Point offset) + { + ButtonOffset = offset; + return ButtonOffset == offset; + } + public PluginOptionTab(string tabName, string tabId = null) { TabName = tabName; @@ -101,10 +109,10 @@ public virtual void OnDraw(GameTime gameTime) var active = PathfinderOptionsMenu.CurrentTabId == Id; // Display tab button if (Button.doButton(HacknetGuiId, - ButtonData.X.GetValueOrDefault(), - ButtonData.Y.GetValueOrDefault(), - ButtonData.Width.GetValueOrDefault(), - ButtonData.Height.GetValueOrDefault(), + ButtonPosition.X, + ButtonPosition.Y, + ButtonRect.Width, + ButtonRect.Height, TabName, active ? Color.Green : Color.Gray)) {