mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
World Restriction Checks
Updated the UI based on the world restriction.
This commit is contained in:
parent
498dcff8b9
commit
be05c04e72
2 changed files with 235 additions and 194 deletions
|
@ -1,107 +1,114 @@
|
|||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using NAK.Stickers.Networking;
|
||||
using NAK.Stickers.Utilities;
|
||||
|
||||
namespace NAK.Stickers.Integrations;
|
||||
|
||||
public static partial class BTKUIAddon
|
||||
{
|
||||
private static Page _rootPage;
|
||||
private static string _rootPageElementID;
|
||||
|
||||
private static bool _isOurTabOpened;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Setup_Icons();
|
||||
Setup_StickerModTab();
|
||||
Setup_PlayerOptionsPage();
|
||||
}
|
||||
|
||||
#region Setup
|
||||
|
||||
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-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"));
|
||||
}
|
||||
|
||||
private static void Setup_StickerModTab()
|
||||
{
|
||||
_rootPage = new Page(ModSettings.ModName, ModSettings.SM_SettingsCategory, true, "Stickers-puzzle")
|
||||
{
|
||||
MenuTitle = ModSettings.SM_SettingsCategory,
|
||||
MenuSubtitle = "Stickers! Double-click the tab to quickly toggle Sticker Mode.",
|
||||
};
|
||||
|
||||
_rootPageElementID = _rootPage.ElementID;
|
||||
|
||||
QuickMenuAPI.OnTabChange += OnTabChange;
|
||||
ModNetwork.OnTextureOutboundStateChanged += (isSending) =>
|
||||
{
|
||||
if (_isOurTabOpened && isSending) QuickMenuAPI.ShowAlertToast("Sending Sticker over Mod Network...", 2);
|
||||
//_rootPage.Disabled = isSending; // TODO: fix being able to select stickers while sending
|
||||
};
|
||||
|
||||
StickerSystem.OnStickerLoaded += (slotIndex, imageRelativePath) =>
|
||||
{
|
||||
if (_isOurTabOpened) QuickMenuAPI.ShowAlertToast($"Sticker loaded: {imageRelativePath}", 2);
|
||||
_stickerSelectionButtons[slotIndex].ButtonIcon = StickerCache.GetBtkUiIconName(imageRelativePath);
|
||||
};
|
||||
|
||||
StickerSystem.OnStickerLoadFailed += (slotIndex, error) =>
|
||||
{
|
||||
if (_isOurTabOpened) QuickMenuAPI.ShowAlertToast(error, 3);
|
||||
};
|
||||
|
||||
Setup_StickersModCategory();
|
||||
Setup_StickerSelectionCategory();
|
||||
Setup_OtherOptionsCategory();
|
||||
}
|
||||
|
||||
#endregion Setup
|
||||
|
||||
#region Double-Click Place Sticker
|
||||
|
||||
private static DateTime lastTime = DateTime.Now;
|
||||
|
||||
private static void OnTabChange(string newTab, string previousTab)
|
||||
{
|
||||
_isOurTabOpened = newTab == _rootPageElementID;
|
||||
if (!_isOurTabOpened) return;
|
||||
|
||||
TimeSpan timeDifference = DateTime.Now - lastTime;
|
||||
if (timeDifference.TotalSeconds <= 0.5)
|
||||
{
|
||||
switch (ModSettings.Entry_TabDoubleClick.Value)
|
||||
{
|
||||
default:
|
||||
case TabDoubleClick.ToggleStickerMode:
|
||||
OnPlaceStickersButtonClick();
|
||||
break;
|
||||
case TabDoubleClick.ClearAllStickers:
|
||||
OnClearAllStickersButtonClick();
|
||||
break;
|
||||
case TabDoubleClick.ClearSelfStickers:
|
||||
OnClearSelfStickersButtonClick();
|
||||
break;
|
||||
case TabDoubleClick.None:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
lastTime = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion Double-Click Place Sticker
|
||||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using NAK.Stickers.Networking;
|
||||
using NAK.Stickers.Utilities;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace NAK.Stickers.Integrations;
|
||||
|
||||
public static partial class BTKUIAddon
|
||||
{
|
||||
private static Page _rootPage;
|
||||
private static string _rootPageElementID;
|
||||
|
||||
private static bool _isOurTabOpened;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Setup_Icons();
|
||||
Setup_StickerModTab();
|
||||
Setup_PlayerOptionsPage();
|
||||
}
|
||||
|
||||
#region Setup
|
||||
|
||||
private static void Setup_Icons()
|
||||
{
|
||||
// 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"));
|
||||
}
|
||||
|
||||
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..
|
||||
{
|
||||
MenuTitle = ModSettings.SM_SettingsCategory,
|
||||
MenuSubtitle = "", //Left this blank as it is defined when the world loads
|
||||
};
|
||||
|
||||
_rootPageElementID = _rootPage.ElementID;
|
||||
|
||||
QuickMenuAPI.OnTabChange += OnTabChange;
|
||||
ModNetwork.OnTextureOutboundStateChanged += (isSending) =>
|
||||
{
|
||||
if (_isOurTabOpened && isSending) QuickMenuAPI.ShowAlertToast("Sending Sticker over Mod Network...", 2);
|
||||
//_rootPage.Disabled = isSending; // TODO: fix being able to select stickers while sending
|
||||
};
|
||||
|
||||
StickerSystem.OnStickerLoaded += (slotIndex, imageRelativePath) =>
|
||||
{
|
||||
if (_isOurTabOpened) QuickMenuAPI.ShowAlertToast($"Sticker loaded: {imageRelativePath}", 2);
|
||||
_stickerSelectionButtons[slotIndex].ButtonIcon = StickerCache.GetBtkUiIconName(imageRelativePath);
|
||||
};
|
||||
|
||||
StickerSystem.OnStickerLoadFailed += (slotIndex, error) =>
|
||||
{
|
||||
if (_isOurTabOpened) QuickMenuAPI.ShowAlertToast(error, 3);
|
||||
};
|
||||
|
||||
Setup_StickersModCategory();
|
||||
Setup_StickerSelectionCategory();
|
||||
Setup_OtherOptionsCategory();
|
||||
}
|
||||
|
||||
#endregion Setup
|
||||
|
||||
#region Double-Click Place Sticker
|
||||
|
||||
private static DateTime lastTime = DateTime.Now;
|
||||
|
||||
private static void OnTabChange(string newTab, string previousTab)
|
||||
{
|
||||
_isOurTabOpened = newTab == _rootPageElementID;
|
||||
if (!_isOurTabOpened) return;
|
||||
|
||||
TimeSpan timeDifference = DateTime.Now - lastTime;
|
||||
if (timeDifference.TotalSeconds <= 0.5)
|
||||
{
|
||||
switch (ModSettings.Entry_TabDoubleClick.Value)
|
||||
{
|
||||
default:
|
||||
case TabDoubleClick.ToggleStickerMode:
|
||||
if (StickerSystem.RestrictedInstance == false)
|
||||
{
|
||||
OnPlaceStickersButtonClick();
|
||||
}
|
||||
break;
|
||||
case TabDoubleClick.ClearAllStickers:
|
||||
OnClearAllStickersButtonClick();
|
||||
break;
|
||||
case TabDoubleClick.ClearSelfStickers:
|
||||
OnClearSelfStickersButtonClick();
|
||||
break;
|
||||
case TabDoubleClick.None:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
lastTime = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion Double-Click Place Sticker
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue