diff --git a/NEG/UI/UnityUi/Buttons/Behaviours.meta b/NEG/UI/UnityUi/Buttons/Behaviours.meta new file mode 100644 index 0000000..0c789ee --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 953c3353e3af44258625fe607ede632b +timeCreated: 1683915598 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs b/NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs new file mode 100644 index 0000000..e6a9b7f --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs @@ -0,0 +1,21 @@ +using NEG.UI.UnityUi.Buttons.Settings; +using System; + +namespace NEG.UI.UnityUi.Buttons.Behaviours +{ + public abstract class ButtonElementBehaviour : IDisposable + { + protected readonly BaseButton button; + protected SettingData baseData; + + public ButtonElementBehaviour(BaseButton baseButton, SettingData settingData) + { + button = baseButton; + baseData = settingData; + } + + public abstract void Dispose(); + + public virtual void ChangeData(SettingData newData) => baseData = newData; + } +} \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs.meta b/NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs.meta new file mode 100644 index 0000000..1d19cfd --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a5e3decad6424cb288eff3e6f7e0d28e +timeCreated: 1683919740 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Behaviours/ChangeTextColorBehaviour.cs b/NEG/UI/UnityUi/Buttons/Behaviours/ChangeTextColorBehaviour.cs new file mode 100644 index 0000000..872990e --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours/ChangeTextColorBehaviour.cs @@ -0,0 +1,41 @@ +using NEG.UI.UnityUi.Buttons.Settings; +using NEG.Utils; +using UnityEngine; + +namespace NEG.UI.UnityUi.Buttons.Behaviours +{ + public class ChangeTextColorBehaviour : ButtonElementBehaviour + { + private ColorData data; + + public ChangeTextColorBehaviour(BaseButton baseButton, ColorData data) : base(baseButton, data) + { + if (baseButton.Text == null) + return; + + baseButton.OnSelected += OnButtonSelected; + baseButton.OnDeselected += OnButtonDeselected; + ChangeData(data); + } + + public override void ChangeData(SettingData newData) + { + base.ChangeData(newData); + Debug.Assert(newData is ColorData, "newData is not ColorData"); + data = (ColorData)newData; + } + + public override void Dispose() + { + button.OnSelected -= OnButtonSelected; + button.OnDeselected -= OnButtonDeselected; + } + + [FactoryRegistration] + private static void RegisterInFactory() => + MonoUiManager.Instance.BehavioursFactory.Register("ChangeTextColor", typeof(ChangeTextColorBehaviour)); + + private void OnButtonSelected(bool _) => button.Text.color = data.SelectedColor; + private void OnButtonDeselected(bool _) => button.Text.color = data.DeselectedColor; + } +} \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Behaviours/ChangeTextColorBehaviour.cs.meta b/NEG/UI/UnityUi/Buttons/Behaviours/ChangeTextColorBehaviour.cs.meta new file mode 100644 index 0000000..c279ffe --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours/ChangeTextColorBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f2079225d6e34001ae85f74a0a418d68 +timeCreated: 1683919878 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs b/NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs new file mode 100644 index 0000000..c23bba5 --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs @@ -0,0 +1,21 @@ +#if FMOD +namespace NEG.UI.UnityUi.Buttons.Behaviours +{ + public class SimpleSoundBehaviour : ButtonElementBehaviour + { + public SimpleSoundBehaviour(BaseButton baseButton, FmodSoundData data) : base(baseButton, data) + { + //TODO: use silnet to not play sound + } + + [FactoryRegistration] + private static void RegisterInFactory() => + MonoUiManager.Instance.BehavioursFactory.Register("SimpleSound", typeof(SimpleSoundBehaviour)); + + public override void ChangeData(SettingData newData) => throw new System.NotImplementedException(); + + public override void Dispose() => throw new System.NotImplementedException(); + } +} + +#endif \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs.meta b/NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs.meta new file mode 100644 index 0000000..80fe7c7 --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d75c0d86eeab47a1a6340f0b03b83de0 +timeCreated: 1684002680 \ No newline at end of file