Stickers: cleanup

This commit is contained in:
NotAKidoS 2024-09-21 01:07:04 -05:00
parent 50804b323d
commit dbc6341f9e
12 changed files with 113 additions and 126 deletions

View file

@ -8,6 +8,8 @@ namespace NAK.Stickers.Integrations;
public static partial class BTKUIAddon
{
private static Category _ourCategory;
private static Button _placeStickersButton;
private static readonly MultiSelection _sfxSelection =
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_SelectedSFX);
@ -17,17 +19,15 @@ public static partial class BTKUIAddon
private static readonly MultiSelection _tabDoubleClickSelection =
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_TabDoubleClick);
public static Button placeStickersButton;
#region Category Setup
private static void Setup_StickersModCategory()
{
_ourCategory = _rootPage.AddMelonCategory(ModSettings.Hidden_Foldout_SettingsCategory);
placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon);
placeStickersButton.OnPress += OnPlaceStickersButtonClick;
_placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon);
_placeStickersButton.OnPress += OnPlaceStickersButtonClick;
Button clearSelfStickersButton = _ourCategory.AddButton("Clear Self", "Stickers-eraser", "Clear own stickers.", ButtonStyle.TextWithIcon);
clearSelfStickersButton.OnPress += OnClearSelfStickersButtonClick;
@ -62,16 +62,15 @@ public static partial class BTKUIAddon
{
if (!_isOurTabOpened) return;
if (StickerSystem.RestrictedInstance == false)
{
string mode = StickerSystem.Instance.IsInStickerMode ? "Exiting" : "Entering";
QuickMenuAPI.ShowAlertToast($"{mode} sticker placement mode...", 2);
StickerSystem.Instance.IsInStickerMode = !StickerSystem.Instance.IsInStickerMode;
}
else
if (StickerSystem.Instance.IsRestrictedInstance)
{
QuickMenuAPI.ShowAlertToast("Stickers are not allowed in this world!", 2);
return;
}
string mode = StickerSystem.Instance.IsInStickerMode ? "Exiting" : "Entering";
QuickMenuAPI.ShowAlertToast($"{mode} sticker placement mode...", 2);
StickerSystem.Instance.IsInStickerMode = !StickerSystem.Instance.IsInStickerMode;
}
private static void OnClearSelfStickersButtonClick()
@ -95,28 +94,25 @@ public static partial class BTKUIAddon
StickerSystem.OpenStickersFolder();
}
public static void UpdateStickerMenu() //TODO: add Icon changing, Bono needs to expose the value first.
public static void OnStickerRestrictionUpdated(bool isRestricted = false) //TODO: add Icon changing, Bono needs to expose the value first.
{
if (StickerSystem.RestrictedInstance == true)
if (isRestricted)
{
_rootPage.MenuSubtitle = "Stickers... are sadly disabled in this world.";
placeStickersButton.Disabled = true;
placeStickersButton.ButtonText = "Stickers Disabled";
placeStickersButton.ButtonTooltip = "This world is not allowing Stickers.";
placeStickersButton.ButtonIcon = "Stickers-magic-wand-broken";
}
else
{
_rootPage.MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode.";
placeStickersButton.Disabled = false;
placeStickersButton.ButtonText = "Place Stickers";
placeStickersButton.ButtonTooltip = "Place stickers via raycast.";
placeStickersButton.ButtonIcon = "Stickers-magic-wand";
_placeStickersButton.Disabled = true;
_placeStickersButton.ButtonText = "Stickers Disabled";
_placeStickersButton.ButtonTooltip = "This world is not allowing Stickers.";
_placeStickersButton.ButtonIcon = "Stickers-magic-wand-broken";
return;
}
_rootPage.MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode.";
_placeStickersButton.Disabled = false;
_placeStickersButton.ButtonText = "Place Stickers";
_placeStickersButton.ButtonTooltip = "Place stickers via raycast.";
_placeStickersButton.ButtonIcon = "Stickers-magic-wand";
}
#endregion Button Actions

View file

@ -22,30 +22,36 @@ public static partial class BTKUIAddon
}
#region Setup
private static void Setup_Icons()
{
Assembly assembly = Assembly.GetExecutingAssembly();
string assemblyName = assembly.GetName().Name;
// All icons used - https://www.flaticon.com/authors/gohsantosadrive
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-alphabet.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-eraser.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-folder.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-headset.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magnifying-glass.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magic-wand.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand-broken", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-magic-wand-broken.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-mouse.png"));
//QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-pencil", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-pencil.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-puzzle.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle-disabled", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-puzzle-disabled.png")); //Disabled Sticker Puzzle
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", Assembly.GetExecutingAssembly().GetManifestResourceStream("Stickers.Resources.Gohsantosadrive_Icons.Stickers-rubbish-bin.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", GetIconStream("Gohsantosadrive_Icons.Stickers-alphabet.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", GetIconStream("Gohsantosadrive_Icons.Stickers-eraser.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", GetIconStream("Gohsantosadrive_Icons.Stickers-folder.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", GetIconStream("Gohsantosadrive_Icons.Stickers-headset.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", GetIconStream("Gohsantosadrive_Icons.Stickers-magnifying-glass.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", GetIconStream("Gohsantosadrive_Icons.Stickers-magic-wand.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand-broken", GetIconStream("Gohsantosadrive_Icons.Stickers-magic-wand-broken.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", GetIconStream("Gohsantosadrive_Icons.Stickers-mouse.png"));
//QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-pencil", GetIconStream("Gohsantosadrive_Icons.Stickers-pencil.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle", GetIconStream("Gohsantosadrive_Icons.Stickers-puzzle.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-puzzle-disabled", GetIconStream("Gohsantosadrive_Icons.Stickers-puzzle-disabled.png")); // disabled Sticker Puzzle
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", GetIconStream("Gohsantosadrive_Icons.Stickers-rubbish-bin.png"));
return;
Stream GetIconStream(string iconName) => assembly.GetManifestResourceStream($"{assemblyName}.Resources.{iconName}");
}
private static void Setup_StickerModTab()
{
_rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-Puzzle") //Sticker Icon will be left blank as it is updated on world join, AFTER Icon value is exposed..
_rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-Puzzle") // sticker icon will be left blank as it is updated on world join, AFTER Icon value is exposed..
{
MenuTitle = ModSettings.SM_SettingsCategory,
MenuSubtitle = "", //Left this blank as it is defined when the world loads
MenuSubtitle = "", // left this blank as it is defined when the world loads
};
_rootPageElementID = _rootPage.ElementID;
@ -91,10 +97,7 @@ public static partial class BTKUIAddon
{
default:
case TabDoubleClick.ToggleStickerMode:
if (StickerSystem.RestrictedInstance == false)
{
OnPlaceStickersButtonClick();
}
OnPlaceStickersButtonClick();
break;
case TabDoubleClick.ClearAllStickers:
OnClearAllStickersButtonClick();