mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[AvatarScaleMod] Tweaking settings.
This commit is contained in:
parent
b29e9fbb6f
commit
497b0b0e7a
3 changed files with 64 additions and 90 deletions
|
@ -17,11 +17,23 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
private LocalScaler _localAvatarScaler;
|
||||
private Dictionary<string, NetworkScaler> _networkedScalers;
|
||||
|
||||
public bool Setting_UniversalScaling = true;
|
||||
|
||||
private bool _settingUniversalScaling;
|
||||
public bool Setting_UniversalScaling
|
||||
{
|
||||
get => _settingUniversalScaling;
|
||||
set
|
||||
{
|
||||
if (value != _settingUniversalScaling && value == false)
|
||||
SetHeight(-1f);
|
||||
|
||||
_settingUniversalScaling = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Setting_PersistantHeight;
|
||||
private float _lastTargetHeight = -1;
|
||||
|
||||
|
||||
|
||||
#region Unity Methods
|
||||
|
||||
|
@ -39,6 +51,8 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
private void Start()
|
||||
{
|
||||
_settingUniversalScaling = ModSettings.EntryUseUniversalScaling.Value;
|
||||
|
||||
CVRGameEventSystem.Instance.OnConnected.AddListener(OnInstanceConnected);
|
||||
//SchedulerSystem.AddJob(new SchedulerSystem.Job(ForceHeightUpdate), 0f, 10f, -1);
|
||||
}
|
||||
|
@ -57,12 +71,6 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
{
|
||||
SchedulerSystem.AddJob(ModNetwork.RequestHeightSync, 2f, 1f, 1);
|
||||
}
|
||||
|
||||
public void OnSettingsChanged()
|
||||
{
|
||||
Setting_UniversalScaling = ModSettings.EntryUniversalScaling.Value;
|
||||
SetHeight(Setting_UniversalScaling ? _lastTargetHeight : -1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -81,6 +89,9 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
_localAvatarScaler.OnAvatarInstantiated(playerSetup._avatar, playerSetup._initialAvatarHeight,
|
||||
playerSetup.initialScale);
|
||||
|
||||
if (!_settingUniversalScaling)
|
||||
return;
|
||||
|
||||
SetHeight(Setting_PersistantHeight ? _lastTargetHeight : -1f);
|
||||
}
|
||||
|
@ -93,9 +104,12 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
public void SetHeight(float targetHeight)
|
||||
{
|
||||
if (!_settingUniversalScaling)
|
||||
return;
|
||||
|
||||
if (_localAvatarScaler == null)
|
||||
return;
|
||||
|
||||
|
||||
_lastTargetHeight = targetHeight;
|
||||
|
||||
_localAvatarScaler.SetTargetHeight(targetHeight);
|
||||
|
@ -107,6 +121,9 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
public void ResetHeight()
|
||||
{
|
||||
if (!_settingUniversalScaling)
|
||||
return;
|
||||
|
||||
if (_localAvatarScaler != null)
|
||||
_localAvatarScaler.ResetHeight();
|
||||
ModNetwork.SendNetworkHeight(-1f);
|
||||
|
@ -122,6 +139,9 @@ public class AvatarScaleManager : MonoBehaviour
|
|||
|
||||
public float GetHeightForNetwork()
|
||||
{
|
||||
if (!_settingUniversalScaling)
|
||||
return -1f;
|
||||
|
||||
if (_localAvatarScaler == null)
|
||||
return -1f;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public class AvatarScaleMod : MelonMod
|
|||
InitializeIntegration("BTKUILib", Integrations.BTKUIAddon.Initialize);
|
||||
|
||||
ModNetwork.Subscribe();
|
||||
ModSettings.InitializeModSettings();
|
||||
ModSettings.Initialize();
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
|
|
|
@ -8,90 +8,44 @@ namespace NAK.AvatarScaleMod;
|
|||
|
||||
internal static class ModSettings
|
||||
{
|
||||
// Constants
|
||||
internal const string SettingsCategory = nameof(AvatarScaleMod);
|
||||
|
||||
|
||||
public static readonly MelonPreferences_Category Category =
|
||||
MelonPreferences.CreateCategory(nameof(AvatarScaleMod));
|
||||
MelonPreferences.CreateCategory(SettingsCategory);
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryUseUniversalScaling =
|
||||
Category.CreateEntry("use_universal_scaling", true, display_name: "Use Universal Scaling", description: "Enable or disable universal scaling.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryPersistantHeight =
|
||||
Category.CreateEntry("persistant_height", false, display_name: "Persistant Height", description: "Should the avatar height persist between avatar switches?");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryScaleGestureEnabled =
|
||||
Category.CreateEntry("scale_gesture_enabled", true, display_name: "Scale Gesture Enabled", description: "Enable or disable scale gesture.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryDebugNetworkInbound =
|
||||
Category.CreateEntry("debug_inbound", false, display_name: "Debug Inbound", description: "Log inbound Mod Network height updates.");
|
||||
|
||||
public static MelonPreferences_Entry<bool> PersistantHeight;
|
||||
|
||||
public static MelonPreferences_Entry<bool> Debug_NetworkInbound;
|
||||
public static MelonPreferences_Entry<bool> Debug_NetworkOutbound;
|
||||
|
||||
// AvatarScaleTool supported scaling settings
|
||||
public static readonly MelonPreferences_Entry<bool> EntryEnabled =
|
||||
Category.CreateEntry("AvatarScaleTool Scaling", true, description: "Should there be persistant avatar scaling? This only works properly across supported avatars.");
|
||||
|
||||
// Universal scaling settings (Mod Network, requires others to have mod)
|
||||
public static readonly MelonPreferences_Entry<bool> EntryUniversalScaling =
|
||||
Category.CreateEntry("Force Universal Scaling", false, description: "Should the mod use Mod Network for scaling? This makes it work on all avatars, but others need the mod.");
|
||||
public static readonly MelonPreferences_Entry<bool> EntryScaleConstraints =
|
||||
Category.CreateEntry("Scale Constraints", false, description: "Should constraints be scaled with Universal Scaling?");
|
||||
public static readonly MelonPreferences_Entry<bool> EntryScaleLights =
|
||||
Category.CreateEntry("Scale Lights", false, description: "Should lights be scaled with Universal Scaling?");
|
||||
public static readonly MelonPreferences_Entry<bool> EntryScaleAudioSources =
|
||||
Category.CreateEntry("Scale Audio Sources", false, description: "Should audio sources be scaled with Universal Scaling?");
|
||||
|
||||
// General scaling settings
|
||||
public static readonly MelonPreferences_Entry<bool> EntryUseScaleGesture =
|
||||
Category.CreateEntry("Scale Gesture", false, description: "Use two fists to scale yourself easily.");
|
||||
|
||||
// Internal settings
|
||||
public static readonly MelonPreferences_Entry<float> HiddenLastAvatarScale =
|
||||
Category.CreateEntry("Last Avatar Scale", -1f, is_hidden: true);
|
||||
|
||||
static ModSettings()
|
||||
public static readonly MelonPreferences_Entry<bool> EntryDebugNetworkOutbound =
|
||||
Category.CreateEntry("debug_outbound", false, display_name: "Debug Outbound", description: "Log outbound Mod Network height updates.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<float> EntryHiddenLastAvatarScale =
|
||||
Category.CreateEntry("last_avatar_scale", -1f, is_hidden: true);
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
EntryEnabled.OnEntryValueChanged.Subscribe(OnEntryEnabledChanged);
|
||||
EntryUseScaleGesture.OnEntryValueChanged.Subscribe(OnEntryUseScaleGestureChanged);
|
||||
EntryUniversalScaling.OnEntryValueChanged.Subscribe(OnEntryUniversalScalingChanged);
|
||||
EntryScaleConstraints.OnEntryValueChanged.Subscribe(OnEntryScaleConstraintsChanged);
|
||||
foreach (MelonPreferences_Entry entry in Category.Entries)
|
||||
entry.OnEntryValueChangedUntyped.Subscribe(OnSettingsChanged);
|
||||
}
|
||||
|
||||
private static void OnEntryEnabledChanged(bool oldValue, bool newValue)
|
||||
private static void OnSettingsChanged(object _, object __)
|
||||
{
|
||||
//AvatarScaleManager.UseUniversalScaling = newValue;
|
||||
AvatarScaleManager.Instance.Setting_UniversalScaling = EntryUseUniversalScaling.Value;
|
||||
AvatarScaleManager.Instance.Setting_PersistantHeight = EntryPersistantHeight.Value;
|
||||
|
||||
GestureReconizer.ScaleReconizer.Enabled = EntryScaleGestureEnabled.Value;
|
||||
|
||||
ModNetwork.Debug_NetworkInbound = EntryDebugNetworkInbound.Value;
|
||||
ModNetwork.Debug_NetworkOutbound = EntryDebugNetworkOutbound.Value;
|
||||
}
|
||||
|
||||
private static void OnEntryUseScaleGestureChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
//AvatarScaleGesture.GestureEnabled = newValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void OnEntryUniversalScalingChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void OnEntryScaleConstraintsChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void InitializeModSettings()
|
||||
{
|
||||
PersistantHeight = Category.CreateEntry("Persistant Height", false, description: "Should the avatar height persist between avatar switches?");
|
||||
PersistantHeight.OnEntryValueChanged.Subscribe(OnPersistantHeightChanged);
|
||||
|
||||
Debug_NetworkInbound = Category.CreateEntry("Debug Inbound", false, description: "Log inbound Mod Network height updates.");
|
||||
Debug_NetworkInbound.OnEntryValueChanged.Subscribe(OnDebugNetworkChanged);
|
||||
Debug_NetworkOutbound = Category.CreateEntry("Debug Outbound", false, description: "Log outbound Mod Network height updates.");
|
||||
Debug_NetworkOutbound.OnEntryValueChanged.Subscribe(OnDebugNetworkChanged);
|
||||
|
||||
//AvatarScaleManager.UseUniversalScaling = EntryEnabled.Value;
|
||||
//AvatarScaleGesture.GestureEnabled = EntryUseScaleGesture.Value;
|
||||
}
|
||||
|
||||
private static void OnPersistantHeightChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
AvatarScaleManager.Instance.Setting_PersistantHeight = newValue;
|
||||
}
|
||||
|
||||
private static void OnDebugNetworkChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
ModNetwork.Debug_NetworkInbound = Debug_NetworkInbound.Value;
|
||||
ModNetwork.Debug_NetworkOutbound = Debug_NetworkOutbound.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue