World Restriction Checks

Updated the UI based on the world restriction.
This commit is contained in:
SketchFoxsky 2024-09-20 18:14:03 -04:00 committed by GitHub
parent 498dcff8b9
commit be05c04e72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 235 additions and 194 deletions

View file

@ -18,13 +18,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);
Button placeStickersButton = _ourCategory.AddButton("Place Stickers", "Stickers-magic-wand", "Place stickers via raycast.", ButtonStyle.TextWithIcon);
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);
@ -59,10 +61,18 @@ public static partial class BTKUIAddon
private static void OnPlaceStickersButtonClick()
{
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
{
QuickMenuAPI.ShowAlertToast("Stickers are not allowed in this world!", 2);
}
}
private static void OnClearSelfStickersButtonClick()
{
@ -85,5 +95,29 @@ public static partial class BTKUIAddon
StickerSystem.OpenStickersFolder();
}
public static void UpdateStickerMenu() //TODO: add Icon changing, Bono needs to expose the value first.
{
if (StickerSystem.RestrictedInstance == true)
{
_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";
}
}
#endregion Button Actions
}

View file

@ -2,6 +2,8 @@
using BTKUILib.UIObjects;
using NAK.Stickers.Networking;
using NAK.Stickers.Utilities;
using System.Reflection;
using System.Runtime.InteropServices;
namespace NAK.Stickers.Integrations;
@ -24,24 +26,26 @@ public static partial class BTKUIAddon
private static void Setup_Icons()
{
// All icons used - https://www.flaticon.com/authors/gohsantosadrive
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-alphabet", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-alphabet.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-eraser", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-eraser.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-folder", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-folder.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-headset", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-headset.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magnifying-glass", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-magnifying-glass.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-magic-wand", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-magic-wand.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-mouse", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-mouse.png"));
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", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-puzzle.png"));
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "Stickers-rubbish-bin", UIUtils.GetIconStream("Gohsantosadrive_Icons.Stickers-rubbish-bin.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"));
}
private static void Setup_StickerModTab()
{
_rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-puzzle")
_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 = "Stickers! Double-click the tab to quickly toggle Sticker Mode.",
MenuSubtitle = "", //Left this blank as it is defined when the world loads
};
_rootPageElementID = _rootPage.ElementID;
@ -87,7 +91,10 @@ public static partial class BTKUIAddon
{
default:
case TabDoubleClick.ToggleStickerMode:
if (StickerSystem.RestrictedInstance == false)
{
OnPlaceStickersButtonClick();
}
break;
case TabDoubleClick.ClearAllStickers:
OnClearAllStickersButtonClick();