Stickers: minor changes

This commit is contained in:
NotAKidoS 2024-09-02 00:18:57 -05:00
parent c206d98a97
commit 2f65634031
16 changed files with 204 additions and 140 deletions

View file

@ -1,13 +0,0 @@
using BTKUILib.UIObjects;
namespace NAK.Stickers.Integrations;
public static partial class BTKUIAddon
{
private static void Setup_DebugOptionsCategory()
{
Category debugCategory = _rootPage.AddMelonCategory(ModSettings.Hidden_Foldout_DebugCategory);
debugCategory.AddMelonToggle(ModSettings.Debug_NetworkInbound);
debugCategory.AddMelonToggle(ModSettings.Debug_NetworkOutbound);
}
}

View file

@ -0,0 +1,24 @@
using BTKUILib;
using BTKUILib.UIObjects;
using BTKUILib.UIObjects.Components;
using NAK.Stickers.Utilities;
namespace NAK.Stickers.Integrations;
public static partial class BTKUIAddon
{
private static void Setup_OtherOptionsCategory()
{
Category debugCategory = _rootPage.AddMelonCategory(ModSettings.Hidden_Foldout_MiscCategory);
debugCategory.AddMelonToggle(ModSettings.Debug_NetworkInbound);
debugCategory.AddMelonToggle(ModSettings.Debug_NetworkOutbound);
debugCategory.AddMelonToggle(ModSettings.Entry_FriendsOnly);
debugCategory.AddButton("Clear Thumbnail Cache", "Stickers-rubbish-bin", "Clear the cache of all loaded stickers.", ButtonStyle.TextWithIcon)
.OnPress += () => QuickMenuAPI.ShowConfirm("Clear Thumbnail Cache", "Are you sure you want to clear the Cohtml thumbnail cache for all stickers?",
() =>
{
StickerCache.ClearCache();
QuickMenuAPI.ShowAlertToast("Thumbnail cache cleared.", 2);
});
}
}

View file

@ -36,8 +36,8 @@ public static partial class BTKUIAddon
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 openMultiSelectionButton = _ourCategory.AddButton("Sticker SFX", "Stickers-headset", "Choose the SFX used when a sticker is placed.", ButtonStyle.TextWithIcon);
openMultiSelectionButton.OnPress += () => QuickMenuAPI.OpenMultiSelect(_sfxSelection);
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);

View file

@ -66,7 +66,7 @@ public static partial class BTKUIAddon
Setup_StickersModCategory();
Setup_StickerSelectionCategory();
Setup_DebugOptionsCategory();
Setup_OtherOptionsCategory();
}
#endregion Setup

View file

@ -18,6 +18,7 @@ public static partial class BTKUIAddon
private static Category _fileCategory;
private static Category _folderCategory;
private static TextBlock _noFilesTextBlock;
private const int MAX_BUTTONS = 512; // cohtml literally will start to explode
private static Button[] _fileButtons = new Button[80]; // 100 files, will resize if needed
@ -49,10 +50,12 @@ public static partial class BTKUIAddon
// Create page
_ourDirectoryBrowserPage = Page.GetOrCreatePage(ModSettings.ModName, "Directory Browser");
QuickMenuAPI.AddRootPage(_ourDirectoryBrowserPage);
// Setup categories
_folderCategory = _ourDirectoryBrowserPage.AddCategory("Subdirectories");
_fileCategory = _ourDirectoryBrowserPage.AddCategory("Images");
_noFilesTextBlock = _fileCategory.AddTextBlock("No images found in this directory. You can add your own images and subfolders to the `UserData/Stickers/` folder.");
_noFilesTextBlock.Hidden = true;
SetupFolderButtons();
SetupFileButtons();
@ -88,6 +91,7 @@ public static partial class BTKUIAddon
string absolutePath = Path.Combine(_curDirectoryInfo.FullName, button.ButtonTooltip[5..]);
string relativePath = Path.GetRelativePath(_initialDirectory, absolutePath);
StickerSystem.Instance.LoadImage(relativePath, _curSelectedSticker);
_rootPage.OpenPage(true); // close the directory browser to artificially limit loading speed
};
_fileButtons[i] = button;
}
@ -162,12 +166,16 @@ public static partial class BTKUIAddon
return;
}
_stickerSelectionButtonDoubleClickTime = Time.time;
// quick menu notification
QuickMenuAPI.ShowAlertToast($"Selected sticker slot {index + 1}", 1);
}
private static void OpenStickerSelectionForSlot(int index)
{
if (IsPopulatingPage) return;
_curSelectedSticker = index;
_initialDirectory = StickerSystem.GetStickersFolderPath(); // creates folder if needed (lazy fix)
_curDirectoryInfo = new DirectoryInfo(_initialDirectory);
_ourDirectoryBrowserPage.OpenPage(false, true);
}
@ -203,8 +211,9 @@ public static partial class BTKUIAddon
_folderCategory.Hidden = foldersCount == 0;
_folderCategory.CategoryName = $"Subdirectories ({foldersCount})";
_fileCategory.Hidden = filesCount == 0;
//_fileCategory.Hidden = filesCount == 0;
_fileCategory.CategoryName = $"Images ({filesCount})";
_noFilesTextBlock.Hidden = filesCount > 0;
});
PopulateFolders(directories);