Skip to content

Commit

Permalink
fix erorr
Browse files Browse the repository at this point in the history
  • Loading branch information
XtraCube committed Sep 25, 2024
1 parent 833585f commit 2a3c8fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
5 changes: 4 additions & 1 deletion MiraAPI/GameOptions/OptionTypes/ModdedEnumOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ public override int GetValueFromOptionBehaviour(OptionBehaviour optionBehaviour)
/// <inheritdoc />
protected override void OnValueChanged(int newValue)
{
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(newValue), false);
if (HudManager.InstanceExists)
{
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, Data.GetValueString(newValue), false);
}
if (!OptionBehaviour)
{
return;
Expand Down
11 changes: 7 additions & 4 deletions MiraAPI/GameOptions/OptionTypes/ModdedNumberOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,13 @@ public override float GetValueFromOptionBehaviour(OptionBehaviour optionBehaviou
protected override void OnValueChanged(float newValue)
{
Value = Mathf.Clamp(newValue, Min, Max);
HudManager.Instance.Notifier.AddSettingsChangeMessage(
StringName,
Data?.GetValueString(Value),
false);
if (HudManager.InstanceExists)
{
HudManager.Instance.Notifier.AddSettingsChangeMessage(
StringName,
Data.GetValueString(Value),
false);
}

if (OptionBehaviour is NumberOption opt)
{
Expand Down
5 changes: 4 additions & 1 deletion MiraAPI/GameOptions/OptionTypes/ModdedToggleOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public override bool GetValueFromOptionBehaviour(OptionBehaviour optionBehaviour
/// <inheritdoc />
protected override void OnValueChanged(bool newValue)
{
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, newValue ? "On" : "Off", false);
if (HudManager.InstanceExists)
{
HudManager.Instance.Notifier.AddSettingsChangeMessage(StringName, newValue ? "On" : "Off", false);
}
if (!OptionBehaviour)
{
return;
Expand Down

0 comments on commit 2a3c8fe

Please sign in to comment.