-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3bf7a90
commit 8406ff7
Showing
68 changed files
with
911 additions
and
253 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace SCHIZO.Options; | ||
|
||
partial class ConfigurableValue<TRaw, TModOption> | ||
{ | ||
public virtual TRaw GetValue() | ||
{ | ||
return isHardCoded ? value : modOption.Value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
partial class ConfigurableValueFloat | ||
{ | ||
public override float GetValue() | ||
{ | ||
return calculateMode switch | ||
{ | ||
CalculateMode.OneOf => base.GetValue(), | ||
CalculateMode.Min => Mathf.Min(value, modOption.Value), | ||
CalculateMode.Max => Mathf.Max(value, modOption.Value), | ||
_ => throw new ArgumentOutOfRangeException() | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Nautilus.Handlers; | ||
using Nautilus.Options; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
partial class ModOption<T> | ||
{ | ||
protected string PlayerPrefsKey => $"SCHIZO_ModOption_{id}"; | ||
|
||
public T Value | ||
{ | ||
get => ValueInternal; | ||
set | ||
{ | ||
ValueInternal = value; | ||
OnValueChanged?.Invoke(value); | ||
} | ||
} | ||
protected abstract T ValueInternal { get; set; } | ||
|
||
public event Action<T> OnValueChanged; | ||
} | ||
|
||
partial class ModOption | ||
{ | ||
public static Dictionary<OptionItem, ModOption> OptionItems { get; } = new(); | ||
|
||
public OptionItem GetOptionItem() | ||
{ | ||
OptionItem result = GetOptionItemInternal(); | ||
OptionItems[result] = this; | ||
return result; | ||
} | ||
|
||
protected abstract OptionItem GetOptionItemInternal(); | ||
|
||
public virtual void AddRealtimeUpdater(GameObject optionObject) | ||
{ | ||
RealtimeOptionUpdater updater = optionObject.AddComponent<RealtimeOptionUpdater>(); | ||
updater.modOption = this; | ||
updater.OnEnable(); | ||
|
||
foreach (ToggleModOption toggleModOption in disableIfAnyFalse) | ||
{ | ||
toggleModOption.OnValueChanged += _ => | ||
{ | ||
if (updater) updater.OnEnable(); | ||
}; | ||
} | ||
|
||
foreach (ToggleModOption toggleModOption in disableIfAnyTrue) | ||
{ | ||
toggleModOption.OnValueChanged += _ => | ||
{ | ||
if (updater) updater.OnEnable(); | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Nautilus.Handlers; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
partial class ModOptionPanel | ||
{ | ||
protected override void Register() | ||
{ | ||
OptionsPanelHandler.RegisterModOptions(new RuntimeModOptions(options)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
public sealed class RealtimeOptionUpdater : MonoBehaviour | ||
{ | ||
public ModOption modOption; | ||
|
||
public void OnEnable() | ||
{ | ||
if (!modOption) return; | ||
|
||
if (modOption.disableIfAnyFalse.Any(o => !o.Value) || modOption.disableIfAnyTrue.Any(o => o.Value)) gameObject.SetActive(false); | ||
else gameObject.SetActive(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections.Generic; | ||
using Nautilus.Options; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
public sealed class RuntimeModOptions : ModOptions | ||
{ | ||
public RuntimeModOptions(List<ModOption> options) : base("Neuro-sama Mod") | ||
{ | ||
foreach (ModOption option in options) | ||
{ | ||
AddItem(option.GetOptionItem()); | ||
} | ||
|
||
GameObjectCreated += OnGameObjectCreated; | ||
} | ||
|
||
private void OnGameObjectCreated(object _, GameObjectCreatedEventArgs evt) | ||
{ | ||
ModOption modOption = ModOption.OptionItems[_options[evt.Id]]; | ||
modOption.AddRealtimeUpdater(evt.Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Nautilus.Options; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
partial class SliderModOption | ||
{ | ||
protected override float ValueInternal | ||
{ | ||
get => PlayerPrefs.GetFloat(PlayerPrefsKey, defaultValue); | ||
set => PlayerPrefs.SetFloat(PlayerPrefsKey, value); | ||
} | ||
|
||
protected override OptionItem GetOptionItemInternal() | ||
{ | ||
ModSliderOption option = ModSliderOption.Create(id, label, min, max, Value, defaultValue, valueFormat, step, tooltip); | ||
option.OnChanged += (_, args) => Value = args.Value; | ||
|
||
OnValueChanged += value => | ||
{ | ||
if (option.OptionGameObject) option.OptionGameObject.GetComponentInChildren<uGUI_SnappingSlider>().SetValueWithoutNotify(value); | ||
}; | ||
|
||
return option; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Nautilus.Options; | ||
using Nautilus.Utility; | ||
using UnityEngine.UI; | ||
|
||
namespace SCHIZO.Options; | ||
|
||
partial class ToggleModOption | ||
{ | ||
protected override bool ValueInternal | ||
{ | ||
get => PlayerPrefsExtra.GetBool(PlayerPrefsKey, defaultValue); | ||
set => PlayerPrefsExtra.SetBool(PlayerPrefsKey, value); | ||
} | ||
|
||
protected override OptionItem GetOptionItemInternal() | ||
{ | ||
ModToggleOption option = ModToggleOption.Create(id, label, Value, tooltip); | ||
option.OnChanged += (_, args) => Value = args.Value; | ||
|
||
OnValueChanged += value => | ||
{ | ||
if (option.OptionGameObject) option.OptionGameObject.GetComponentInChildren<Toggle>().SetIsOnWithoutNotify(value); | ||
}; | ||
|
||
return option; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.