diff --git a/UUIRegisterShared/UUIRegister.cs b/UUIRegisterShared/UUIRegister.cs index 9c114717..e30dabe0 100644 --- a/UUIRegisterShared/UUIRegister.cs +++ b/UUIRegisterShared/UUIRegister.cs @@ -1,12 +1,10 @@ -using ColossalFramework; +using ColossalFramework; using ColossalFramework.UI; using ModsCommon.UI; using ModsCommon.Utilities; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using UnifiedUI.Helpers; +using UnityEngine; using static ModsCommon.SettingsHelper; namespace ModsCommon @@ -15,6 +13,9 @@ public interface IUUITool : ITool { public bool UUIRegistered { get; } public UIComponent UUIButton { get; } + public Texture2D UUIIconTexture { get; } + public string Mod_Description { get; } + public string Mod_Group { get; } public void RegisterUUI(); } public abstract partial class BaseTool : ToolBase, IUUITool @@ -26,12 +27,9 @@ public abstract partial class BaseTool : ToolBase, IUUITool public bool UUIRegistered { get; private set; } public UIComponent UUIButton { get; private set; } - - protected abstract UITextureAtlas UUIAtlas { get; } - protected abstract string UUINormalSprite { get; } - protected abstract string UUIHoveredSprite { get; } - protected abstract string UUIPressedSprite { get; } - protected abstract string UUIDisabledSprite { get; } + public abstract string Mod_Description { get; } + public abstract string Mod_Group { get; } + public abstract Texture2D UUIIconTexture { get; } public virtual void RegisterUUI() { @@ -41,20 +39,18 @@ public virtual void RegisterUUI() try { - var uuiSprites = new UUIHelpers.UUISprites() - { - Atlas = UUIAtlas, - NormalSprite = UUINormalSprite, - HoveredSprite = UUIHoveredSprite, - PressedSprite = UUIPressedSprite, - DisabledSprite = UUIDisabledSprite, - }; + var icon = UUIIconTexture; + SingletonMod.Logger.Debug($"[{SingletonMod.Name}] Unified UI button loaded"); + var hotkeys = new UUIHotKeys { ActivationKey = Activation.InputKey }; - var tool = SingletonTool.Instance; - UUIButton = UUIHelpers.RegisterToolButton(SingletonMod.Name, "MacSergeyMods", string.Empty, uuiSprites, tool, tool.Activation.InputKey, tool.Shortcuts.Select(s => s.InputKey)); + UUIButton = UUIHelpers.RegisterToolButton( + name: SingletonMod.Name, + groupName: Mod_Group, + tooltip: Mod_Description, + tool: this, + icon: icon, + hotkeys: hotkeys); - UUIButton.isVisible = BaseSettings.IsUUIButtonVisible(); - UUIButton.eventTooltipEnter += (UIComponent component, UIMouseEventParameter eventParam) => component.tooltip = ToolTip; UUIRegistered = true; } catch (Exception error)