mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
Move many mods to Deprecated folder, fix spelling
This commit is contained in:
parent
5e822cec8d
commit
0042590aa6
539 changed files with 7475 additions and 3120 deletions
99
.Deprecated/AvatarScaleMod/Integrations/BTKUI/BtkUiAddon.cs
Normal file
99
.Deprecated/AvatarScaleMod/Integrations/BTKUI/BtkUiAddon.cs
Normal file
|
@ -0,0 +1,99 @@
|
|||
using ABI_RC.Core.Player;
|
||||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using NAK.AvatarScaleMod.AvatarScaling;
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static Page _asmRootPage;
|
||||
private static string _rootPageElementID;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
Prepare_Icons();
|
||||
Setup_AvatarScaleModTab();
|
||||
Setup_PlayerSelectPage();
|
||||
}
|
||||
|
||||
#region Initialization
|
||||
|
||||
private static void Prepare_Icons()
|
||||
{
|
||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "ASM_Icon_AvatarHeightConfig",
|
||||
GetIconStream("ASM_Icon_AvatarHeightConfig.png"));
|
||||
QuickMenuAPI.PrepareIcon(ModSettings.ModName, "ASM_Icon_AvatarHeightCopy",
|
||||
GetIconStream("ASM_Icon_AvatarHeightCopy.png"));
|
||||
}
|
||||
|
||||
private static void Setup_AvatarScaleModTab()
|
||||
{
|
||||
_asmRootPage = new Page(ModSettings.ModName, ModSettings.ASM_SettingsCategory, true, "ASM_Icon_AvatarHeightConfig")
|
||||
{
|
||||
MenuTitle = ModSettings.ASM_SettingsCategory,
|
||||
MenuSubtitle = "Everything Avatar Scaling!"
|
||||
};
|
||||
|
||||
_rootPageElementID = _asmRootPage.ElementID;
|
||||
QuickMenuAPI.OnTabChange += OnTabChange;
|
||||
QuickMenuAPI.UserJoin += OnUserJoinLeave;
|
||||
QuickMenuAPI.UserLeave += OnUserJoinLeave;
|
||||
QuickMenuAPI.OnWorldLeave += OnWorldLeave;
|
||||
|
||||
// Avatar Scale Mod
|
||||
Setup_AvatarScaleModCategory(_asmRootPage);
|
||||
|
||||
// Avatar Scale Tool
|
||||
Setup_AvatarScaleToolCategory(_asmRootPage);
|
||||
|
||||
// Universal Scaling Settings
|
||||
Setup_UniversalScalingSettings(_asmRootPage);
|
||||
|
||||
// Debug Options
|
||||
Setup_DebugOptionsCategory(_asmRootPage);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Player Count Display
|
||||
|
||||
private static void OnWorldLeave()
|
||||
=> UpdatePlayerCountDisplay();
|
||||
|
||||
private static void OnUserJoinLeave(CVRPlayerEntity _)
|
||||
=> UpdatePlayerCountDisplay();
|
||||
|
||||
private static void UpdatePlayerCountDisplay()
|
||||
{
|
||||
if (_asmRootPage == null)
|
||||
return;
|
||||
|
||||
int modUserCount = AvatarScaleManager.Instance.GetNetworkHeightScalerCount();
|
||||
int playerCount = CVRPlayerManager.Instance.NetworkPlayers.Count;
|
||||
_asmRootPage.MenuSubtitle = $"Everything Avatar Scaling! :: ({modUserCount}/{playerCount} players using ASM)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Double-Click Reset Height
|
||||
|
||||
private static DateTime lastTime = DateTime.Now;
|
||||
|
||||
private static void OnTabChange(string newTab, string previousTab)
|
||||
{
|
||||
if (newTab == _rootPageElementID)
|
||||
{
|
||||
UpdatePlayerCountDisplay();
|
||||
TimeSpan timeDifference = DateTime.Now - lastTime;
|
||||
if (timeDifference.TotalSeconds <= 0.5)
|
||||
{
|
||||
AvatarScaleManager.Instance.Setting_UniversalScaling = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
lastTime = DateTime.Now;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using BTKUILib.UIObjects;
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static void Setup_AvatarScaleModCategory(Page page)
|
||||
{
|
||||
Category avScaleModCategory = AddMelonCategory(ref page, ModSettings.Hidden_Foldout_ASM_SettingsCategory);
|
||||
|
||||
AddMelonToggle(ref avScaleModCategory, ModSettings.EntryScaleGestureEnabled);
|
||||
AddMelonToggle(ref avScaleModCategory, ModSettings.EntryScaleKeybindingsEnabled);
|
||||
AddMelonToggle(ref avScaleModCategory, ModSettings.EntryPersistentHeight);
|
||||
AddMelonToggle(ref avScaleModCategory, ModSettings.EntryPersistThroughRestart);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
using BTKUILib.UIObjects;
|
||||
using BTKUILib.UIObjects.Components;
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static void Setup_AvatarScaleToolCategory(Page page)
|
||||
{
|
||||
Category avScaleToolCategory = AddMelonCategory(ref page, ModSettings.Hidden_Foldout_AST_SettingsCategory);
|
||||
|
||||
AddMelonStringInput(ref avScaleToolCategory, ModSettings.EntryASTScaleParameter, "icon");
|
||||
AddMelonNumberInput(ref avScaleToolCategory, ModSettings.EntryASTMinHeight, "icon");
|
||||
AddMelonNumberInput(ref avScaleToolCategory, ModSettings.EntryASTMaxHeight, "icon");
|
||||
avScaleToolCategory.AddButton("Reset Overrides", "", "Reset to Avatar Scale Tool default values.", ButtonStyle.TextOnly)
|
||||
.OnPress += () =>{
|
||||
ModSettings.EntryASTScaleParameter.ResetToDefault();
|
||||
ModSettings.EntryASTMinHeight.ResetToDefault();
|
||||
ModSettings.EntryASTMaxHeight.ResetToDefault();
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
using BTKUILib.UIObjects;
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static void Setup_DebugOptionsCategory(Page page)
|
||||
{
|
||||
Category debugCategory = AddMelonCategory(ref page, ModSettings.Hidden_Foldout_DEBUG_SettingsCategory);
|
||||
|
||||
AddMelonToggle(ref debugCategory, ModSettings.Debug_NetworkInbound);
|
||||
AddMelonToggle(ref debugCategory, ModSettings.Debug_NetworkOutbound);
|
||||
AddMelonToggle(ref debugCategory, ModSettings.Debug_ComponentSearchTime);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using BTKUILib.UIObjects.Components;
|
||||
using NAK.AvatarScaleMod.AvatarScaling;
|
||||
using System.Collections.Generic; // Added for list support
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static readonly List<QMUIElement> USM_QmUiElements = new();
|
||||
|
||||
private static void Setup_UniversalScalingSettings(Page page)
|
||||
{
|
||||
Category uniScalingCategory = AddMelonCategory(ref page, ModSettings.Hidden_Foldout_USM_SettingsCategory);
|
||||
|
||||
SliderFloat scaleSlider = AddMelonSlider(ref uniScalingCategory, ModSettings.EntryHiddenAvatarHeight, AvatarScaleManager.DefaultMinHeight, AvatarScaleManager.DefaultMaxHeight);
|
||||
|
||||
Button resetHeightButton = uniScalingCategory.AddButton(ModSettings.EntryUseUniversalScaling.DisplayName, "icon", ModSettings.EntryUseUniversalScaling.Description, ButtonStyle.TextOnly);
|
||||
resetHeightButton.OnPress += () =>
|
||||
{
|
||||
if (ModSettings.EntryUseUniversalScaling.Value)
|
||||
{
|
||||
ModSettings.EntryUseUniversalScaling.Value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
QuickMenuAPI.ShowConfirm("Use Universal Scaling?",
|
||||
"Universal scaling only works when other users also have the mod! Are you sure you want to use Universal Scaling?",
|
||||
() => ModSettings.EntryUseUniversalScaling.Value = true);
|
||||
};
|
||||
|
||||
// Elements that should be disabled when universal scaling is disabled
|
||||
USM_QmUiElements.AddRange(new QMUIElement[]
|
||||
{
|
||||
scaleSlider,
|
||||
AddMelonToggle(ref uniScalingCategory, ModSettings.EntryScaleComponents),
|
||||
AddMelonToggle(ref uniScalingCategory, ModSettings.EntryAnimationScalingOverride)
|
||||
});
|
||||
|
||||
// Events for the slider
|
||||
scaleSlider.OnValueUpdated += OnAvatarHeightSliderChanged;
|
||||
scaleSlider.OnSliderReset += OnAvatarHeightSliderReset;
|
||||
AvatarScaleEvents.OnLocalAvatarAnimatedHeightChanged.AddListener((scaler) =>
|
||||
{
|
||||
scaleSlider.SetSliderValue(scaler.GetTargetHeight());
|
||||
scaleSlider.DefaultValue = scaler.GetAnimatedHeight();
|
||||
});
|
||||
|
||||
// Initial values
|
||||
OnUniversalScalingChanged(ModSettings.EntryUseUniversalScaling.Value);
|
||||
ModSettings.EntryUseUniversalScaling.OnEntryValueChanged.Subscribe((_, newValue) => OnUniversalScalingChanged(newValue));
|
||||
}
|
||||
|
||||
private static void OnUniversalScalingChanged(bool value)
|
||||
{
|
||||
foreach (QMUIElement uiElement in USM_QmUiElements)
|
||||
uiElement.Disabled = !value;
|
||||
}
|
||||
|
||||
#region Slider Events
|
||||
|
||||
private static void OnAvatarHeightSliderChanged(float height)
|
||||
{
|
||||
AvatarScaleManager.Instance.SetTargetHeight(height);
|
||||
}
|
||||
|
||||
private static void OnAvatarHeightSliderReset()
|
||||
{
|
||||
AvatarScaleManager.Instance.Setting_UniversalScaling = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using BTKUILib.UIObjects.Components;
|
||||
using NAK.AvatarScaleMod.AvatarScaling;
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
private static Button _playerHasModElement;
|
||||
private static string _selectedPlayer;
|
||||
|
||||
private static void Setup_PlayerSelectPage()
|
||||
{
|
||||
QuickMenuAPI.OnPlayerSelected += OnPlayerSelected;
|
||||
|
||||
Category category = QuickMenuAPI.PlayerSelectPage.AddCategory(ModSettings.ASM_SettingsCategory, ModSettings.ModName);
|
||||
|
||||
_playerHasModElement = category.AddButton("PLAYER_HAS_MOD", "ASM_Icon_AvatarHeightCopy", "PLAYER_HAS_MOD_TOOLTIP");
|
||||
|
||||
Button button = category.AddButton("Copy Height", "ASM_Icon_AvatarHeightCopy", "Copy selected players Eye Height.");
|
||||
button.OnPress += OnCopyPlayerHeight;
|
||||
}
|
||||
|
||||
#region QM Events
|
||||
|
||||
private static void OnPlayerSelected(string _, string id)
|
||||
{
|
||||
_selectedPlayer = id;
|
||||
UpdatePlayerHasModIcon();
|
||||
}
|
||||
|
||||
private static void OnCopyPlayerHeight()
|
||||
{
|
||||
float networkHeight = AvatarScaleManager.Instance.GetNetworkHeight(_selectedPlayer);
|
||||
if (networkHeight < 0) return;
|
||||
AvatarScaleManager.Instance.SetTargetHeight(networkHeight);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private static void UpdatePlayerHasModIcon()
|
||||
{
|
||||
if (_playerHasModElement == null)
|
||||
return;
|
||||
|
||||
if (AvatarScaleManager.Instance.DoesNetworkHeightScalerExist(_selectedPlayer))
|
||||
{
|
||||
_playerHasModElement.ButtonIcon = "ASM_Icon_AvatarHeightCopy";
|
||||
_playerHasModElement.ButtonText = "Player Has Mod";
|
||||
_playerHasModElement.ButtonTooltip = "This player has the Avatar Scale Mod installed!";
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerHasModElement.ButtonIcon = "ASM_Icon_AvatarHeightConfig";
|
||||
_playerHasModElement.ButtonText = "Player Does Not Have Mod";
|
||||
_playerHasModElement.ButtonTooltip = "This player does not have the Avatar Scale Mod installed!";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
using System.Reflection;
|
||||
using BTKUILib;
|
||||
using BTKUILib.UIObjects;
|
||||
using BTKUILib.UIObjects.Components;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.AvatarScaleMod.Integrations;
|
||||
|
||||
public static partial class BtkUiAddon
|
||||
{
|
||||
#region Melon Preference Helpers
|
||||
|
||||
private static ToggleButton AddMelonToggle(ref Category category, MelonPreferences_Entry<bool> entry)
|
||||
{
|
||||
ToggleButton toggle = category.AddToggle(entry.DisplayName, entry.Description, entry.Value);
|
||||
toggle.OnValueUpdated += b => entry.Value = b;
|
||||
return toggle;
|
||||
}
|
||||
|
||||
private static SliderFloat AddMelonSlider(ref Category category, MelonPreferences_Entry<float> entry, float min,
|
||||
float max, int decimalPlaces = 2, bool allowReset = true)
|
||||
{
|
||||
SliderFloat slider = category.AddSlider(entry.DisplayName, entry.Description,
|
||||
Mathf.Clamp(entry.Value, min, max), min, max, decimalPlaces, entry.DefaultValue, allowReset);
|
||||
slider.OnValueUpdated += f => entry.Value = f;
|
||||
return slider;
|
||||
}
|
||||
|
||||
private static Button AddMelonStringInput(ref Category category, MelonPreferences_Entry<string> entry, string buttonIcon = "", ButtonStyle buttonStyle = ButtonStyle.TextOnly)
|
||||
{
|
||||
Button button = category.AddButton(entry.DisplayName, buttonIcon, entry.Description, buttonStyle);
|
||||
button.OnPress += () => QuickMenuAPI.OpenKeyboard(entry.Value, s => entry.Value = s);
|
||||
return button;
|
||||
}
|
||||
|
||||
private static Button AddMelonNumberInput(ref Category category, MelonPreferences_Entry<float> entry, string buttonIcon = "", ButtonStyle buttonStyle = ButtonStyle.TextOnly)
|
||||
{
|
||||
Button button = category.AddButton(entry.DisplayName, buttonIcon, entry.Description, buttonStyle);
|
||||
button.OnPress += () => QuickMenuAPI.OpenNumberInput(entry.DisplayName, entry.Value, f => entry.Value = f);
|
||||
return button;
|
||||
}
|
||||
|
||||
// private static SliderFloat AddMelonSlider(ref Page page, MelonPreferences_Entry<float> entry, float min, float max, int decimalPlaces = 2, bool allowReset = true)
|
||||
// {
|
||||
// SliderFloat slider = page.AddSlider(entry.DisplayName, entry.Description, Mathf.Clamp(entry.Value, min, max), min, max, decimalPlaces, entry.DefaultValue, allowReset);
|
||||
// slider.OnValueUpdated += f => entry.Value = f;
|
||||
// return slider;
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to create a category that saves its collapsed state to a MelonPreferences entry.
|
||||
/// </summary>
|
||||
/// <param name="page"></param>
|
||||
/// <param name="entry"></param>
|
||||
/// <param name="showHeader"></param>
|
||||
/// <returns></returns>
|
||||
private static Category AddMelonCategory(ref Page page, MelonPreferences_Entry<bool> entry, bool showHeader = true)
|
||||
{
|
||||
Category category = page.AddCategory(entry.DisplayName, showHeader, true, entry.Value);
|
||||
category.OnCollapse += b => entry.Value = b;
|
||||
return category;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Icon Utils
|
||||
|
||||
private static Stream GetIconStream(string iconName)
|
||||
{
|
||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
||||
string assemblyName = assembly.GetName().Name;
|
||||
return assembly.GetManifestResourceStream($"{assemblyName}.resources.{iconName}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue