more cleanup
This commit is contained in:
parent
85dee79cc8
commit
e6af704f30
3
NEG/UI/UnityUi/Buttons/Behaviours.meta
Normal file
3
NEG/UI/UnityUi/Buttons/Behaviours.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 953c3353e3af44258625fe607ede632b
|
||||||
|
timeCreated: 1683915598
|
||||||
21
NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs
Normal file
21
NEG/UI/UnityUi/Buttons/Behaviours/ButtonElementBehaviour.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a5e3decad6424cb288eff3e6f7e0d28e
|
||||||
|
timeCreated: 1683919740
|
||||||
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f2079225d6e34001ae85f74a0a418d68
|
||||||
|
timeCreated: 1683919878
|
||||||
21
NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs
Normal file
21
NEG/UI/UnityUi/Buttons/Behaviours/SimpleSoundBehaviour.cs
Normal file
@ -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
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d75c0d86eeab47a1a6340f0b03b83de0
|
||||||
|
timeCreated: 1684002680
|
||||||
Loading…
x
Reference in New Issue
Block a user