summaryrefslogtreecommitdiff
path: root/Thronefall_v1.0/Decompile/TFUIAudioHelper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Thronefall_v1.0/Decompile/TFUIAudioHelper.cs')
-rw-r--r--Thronefall_v1.0/Decompile/TFUIAudioHelper.cs53
1 files changed, 53 insertions, 0 deletions
diff --git a/Thronefall_v1.0/Decompile/TFUIAudioHelper.cs b/Thronefall_v1.0/Decompile/TFUIAudioHelper.cs
new file mode 100644
index 0000000..39c293e
--- /dev/null
+++ b/Thronefall_v1.0/Decompile/TFUIAudioHelper.cs
@@ -0,0 +1,53 @@
+using UnityEngine;
+
+[RequireComponent(typeof(ThronefallUIElement))]
+public class TFUIAudioHelper : MonoBehaviour
+{
+ public bool playOnColdSelect;
+
+ public ThronefallAudioManager.AudioOneShot onSelect = ThronefallAudioManager.AudioOneShot.ButtonSelect;
+
+ public ThronefallAudioManager.AudioOneShot onApply = ThronefallAudioManager.AudioOneShot.ButtonApply;
+
+ private ThronefallUIElement tfui;
+
+ private bool selected
+ {
+ get
+ {
+ if (tfui.CurrentState == ThronefallUIElement.SelectionState.Selected || tfui.CurrentState == ThronefallUIElement.SelectionState.FocussedAndSelected)
+ {
+ if (tfui.PreviousState != ThronefallUIElement.SelectionState.FocussedAndSelected)
+ {
+ return tfui.PreviousState != ThronefallUIElement.SelectionState.Selected;
+ }
+ return false;
+ }
+ return false;
+ }
+ }
+
+ private void Start()
+ {
+ tfui = GetComponent<ThronefallUIElement>();
+ tfui.onApply.AddListener(PlayApply);
+ tfui.onSelectionStateChange.AddListener(PlaySelect);
+ if (selected && playOnColdSelect)
+ {
+ PlaySelect();
+ }
+ }
+
+ private void PlayApply()
+ {
+ ThronefallAudioManager.Oneshot(onApply);
+ }
+
+ private void PlaySelect()
+ {
+ if (selected)
+ {
+ ThronefallAudioManager.Oneshot(onSelect);
+ }
+ }
+}