mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2026-01-01 14:17:31 +00:00
Normalize JSON encoding
This commit is contained in:
parent
ab46b2505f
commit
5046c2259d
8 changed files with 862 additions and 861 deletions
|
|
@ -1,122 +1,122 @@
|
|||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using BTKUILib.UIObjects.Components;
|
||||
using BTKUILib.UIObjects.Objects;
|
||||
|
||||
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);
|
||||
|
||||
private static readonly MultiSelection _desktopKeybindSelection =
|
||||
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_PlaceBinding);
|
||||
|
||||
private static readonly MultiSelection _tabDoubleClickSelection =
|
||||
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_TabDoubleClick);
|
||||
|
||||
#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;
|
||||
|
||||
Button clearSelfStickersButton = _ourCategory.AddButton("Clear Self", "Stickers-eraser", "Clear own stickers.", ButtonStyle.TextWithIcon);
|
||||
clearSelfStickersButton.OnPress += OnClearSelfStickersButtonClick;
|
||||
|
||||
Button clearAllStickersButton = _ourCategory.AddButton("Clear All", "Stickers-rubbish-bin", "Clear all stickers.", ButtonStyle.TextWithIcon);
|
||||
clearAllStickersButton.OnPress += OnClearAllStickersButtonClick;
|
||||
|
||||
Button openStickersFolderButton = _ourCategory.AddButton("Open Stickers Folder", "Stickers-folder", "Open UserData/Stickers folder in explorer. If above 256kb your image will automatically be downscaled for networking reasons.", ButtonStyle.TextWithIcon);
|
||||
openStickersFolderButton.OnPress += OnOpenStickersFolderButtonClick;
|
||||
|
||||
Button openStickerSFXButton = _ourCategory.AddButton("Sticker SFX", "Stickers-headset", "Choose the SFX used when a sticker is placed.", ButtonStyle.TextWithIcon);
|
||||
openStickerSFXButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_sfxSelection);
|
||||
|
||||
ToggleButton toggleDesktopKeybindButton = _ourCategory.AddToggle("Use Desktop Keybind", "Should the Desktop keybind be active.", ModSettings.Entry_UsePlaceBinding.Value);
|
||||
Button openDesktopKeybindButton = _ourCategory.AddButton("Desktop Keybind", "Stickers-alphabet", "Choose the key binding to place stickers.", ButtonStyle.TextWithIcon);
|
||||
openDesktopKeybindButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_desktopKeybindSelection);
|
||||
toggleDesktopKeybindButton.OnValueUpdated += (b) =>
|
||||
{
|
||||
ModSettings.Entry_UsePlaceBinding.Value = b;
|
||||
openDesktopKeybindButton.Disabled = !b;
|
||||
};
|
||||
|
||||
Button openTabDoubleClickButton = _ourCategory.AddButton("Tab Double Click", "Stickers-mouse", "Choose the action to perform when double clicking the Stickers tab.", ButtonStyle.TextWithIcon);
|
||||
openTabDoubleClickButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_tabDoubleClickSelection);
|
||||
}
|
||||
|
||||
#endregion Category Setup
|
||||
|
||||
#region Button Actions
|
||||
|
||||
private static void OnPlaceStickersButtonClick()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
|
||||
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()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
QuickMenuAPI.ShowAlertToast("Clearing own stickers in world...", 2);
|
||||
StickerSystem.Instance.ClearStickersSelf();
|
||||
}
|
||||
|
||||
private static void OnClearAllStickersButtonClick()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
QuickMenuAPI.ShowAlertToast("Clearing all stickers in world...", 2);
|
||||
StickerSystem.Instance.ClearAllStickers();
|
||||
}
|
||||
|
||||
private static void OnOpenStickersFolderButtonClick()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
QuickMenuAPI.ShowAlertToast("Opening Stickers folder in Explorer...", 2);
|
||||
StickerSystem.OpenStickersFolder();
|
||||
}
|
||||
|
||||
public static void OnStickerRestrictionUpdated(bool isRestricted = false) //TODO: add Icon changing, Bono needs to expose the value first.
|
||||
{
|
||||
if (_rootPage == null || _placeStickersButton == null)
|
||||
return;
|
||||
|
||||
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";
|
||||
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
|
||||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using BTKUILib.UIObjects.Components;
|
||||
using BTKUILib.UIObjects.Objects;
|
||||
|
||||
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);
|
||||
|
||||
private static readonly MultiSelection _desktopKeybindSelection =
|
||||
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_PlaceBinding);
|
||||
|
||||
private static readonly MultiSelection _tabDoubleClickSelection =
|
||||
MultiSelection.CreateMultiSelectionFromMelonPref(ModSettings.Entry_TabDoubleClick);
|
||||
|
||||
#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;
|
||||
|
||||
Button clearSelfStickersButton = _ourCategory.AddButton("Clear Self", "Stickers-eraser", "Clear own stickers.", ButtonStyle.TextWithIcon);
|
||||
clearSelfStickersButton.OnPress += OnClearSelfStickersButtonClick;
|
||||
|
||||
Button clearAllStickersButton = _ourCategory.AddButton("Clear All", "Stickers-rubbish-bin", "Clear all stickers.", ButtonStyle.TextWithIcon);
|
||||
clearAllStickersButton.OnPress += OnClearAllStickersButtonClick;
|
||||
|
||||
Button openStickersFolderButton = _ourCategory.AddButton("Open Stickers Folder", "Stickers-folder", "Open UserData/Stickers folder in explorer. If above 256kb your image will automatically be downscaled for networking reasons.", ButtonStyle.TextWithIcon);
|
||||
openStickersFolderButton.OnPress += OnOpenStickersFolderButtonClick;
|
||||
|
||||
Button openStickerSFXButton = _ourCategory.AddButton("Sticker SFX", "Stickers-headset", "Choose the SFX used when a sticker is placed.", ButtonStyle.TextWithIcon);
|
||||
openStickerSFXButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_sfxSelection);
|
||||
|
||||
ToggleButton toggleDesktopKeybindButton = _ourCategory.AddToggle("Use Desktop Keybind", "Should the Desktop keybind be active.", ModSettings.Entry_UsePlaceBinding.Value);
|
||||
Button openDesktopKeybindButton = _ourCategory.AddButton("Desktop Keybind", "Stickers-alphabet", "Choose the key binding to place stickers.", ButtonStyle.TextWithIcon);
|
||||
openDesktopKeybindButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_desktopKeybindSelection);
|
||||
toggleDesktopKeybindButton.OnValueUpdated += (b) =>
|
||||
{
|
||||
ModSettings.Entry_UsePlaceBinding.Value = b;
|
||||
openDesktopKeybindButton.Disabled = !b;
|
||||
};
|
||||
|
||||
Button openTabDoubleClickButton = _ourCategory.AddButton("Tab Double Click", "Stickers-mouse", "Choose the action to perform when double clicking the Stickers tab.", ButtonStyle.TextWithIcon);
|
||||
openTabDoubleClickButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_tabDoubleClickSelection);
|
||||
}
|
||||
|
||||
#endregion Category Setup
|
||||
|
||||
#region Button Actions
|
||||
|
||||
private static void OnPlaceStickersButtonClick()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
|
||||
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()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
QuickMenuAPI.ShowAlertToast("Clearing own stickers in world...", 2);
|
||||
StickerSystem.Instance.ClearStickersSelf();
|
||||
}
|
||||
|
||||
private static void OnClearAllStickersButtonClick()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
QuickMenuAPI.ShowAlertToast("Clearing all stickers in world...", 2);
|
||||
StickerSystem.Instance.ClearAllStickers();
|
||||
}
|
||||
|
||||
private static void OnOpenStickersFolderButtonClick()
|
||||
{
|
||||
if (!_isOurTabOpened) return;
|
||||
QuickMenuAPI.ShowAlertToast("Opening Stickers folder in Explorer...", 2);
|
||||
StickerSystem.OpenStickersFolder();
|
||||
}
|
||||
|
||||
public static void OnStickerRestrictionUpdated(bool isRestricted = false) //TODO: add Icon changing, Bono needs to expose the value first.
|
||||
{
|
||||
if (_rootPage == null || _placeStickersButton == null)
|
||||
return;
|
||||
|
||||
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";
|
||||
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
|
||||
}
|
||||
|
|
@ -1,116 +1,116 @@
|
|||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using NAK.Stickers.Networking;
|
||||
using NAK.Stickers.Utilities;
|
||||
using System.Reflection;
|
||||
|
||||
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()
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
string assemblyName = assembly.GetName().Name;
|
||||
|
||||
// All icons used - https://www.flaticon.com/authors/gohsantosadrive
|
||||
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..
|
||||
{
|
||||
MenuTitle = ModSettings.SM_SettingsCategory + $" (Network Version v{ModNetwork.NetworkVersion})",
|
||||
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:
|
||||
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;
|
||||
|
||||
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()
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
string assemblyName = assembly.GetName().Name;
|
||||
|
||||
// All icons used - https://www.flaticon.com/authors/gohsantosadrive
|
||||
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..
|
||||
{
|
||||
MenuTitle = ModSettings.SM_SettingsCategory + $" (Network Version v{ModNetwork.NetworkVersion})",
|
||||
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:
|
||||
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