From 85dee79cc86e9d29efdba0b9a6a14a2a47df0221 Mon Sep 17 00:00:00 2001 From: BitterSmile Date: Sun, 3 Mar 2024 15:38:40 +0100 Subject: [PATCH] Cleanup --- NEG/UI/UnityUi/Buttons/BaseButton.cs | 8 +++- NEG/UI/UnityUi/Buttons/Reaction.meta | 3 -- .../Reaction/ButtonElementBehaviour.cs | 21 ---------- .../Reaction/ButtonElementBehaviour.cs.meta | 3 -- .../Reaction/ChangeTextColorBehaviour.cs | 41 ------------------- .../Reaction/ChangeTextColorBehaviour.cs.meta | 3 -- .../Buttons/Reaction/SimpleSoundBehaviour.cs | 21 ---------- .../Reaction/SimpleSoundBehaviour.cs.meta | 3 -- NEG/UI/UnityUi/Buttons/Reactions.meta | 3 ++ .../Buttons/{ => Reactions}/ButtonReaction.cs | 0 .../{ => Reactions}/ButtonReaction.cs.meta | 0 .../ChangeScene.cs} | 4 +- .../ChangeScene.cs.meta} | 0 .../{ => Reactions}/CloseAllWindows.cs | 2 +- .../{ => Reactions}/CloseAllWindows.cs.meta | 0 .../Buttons/{ => Reactions}/CloseWindow.cs | 2 +- .../{ => Reactions}/CloseWindow.cs.meta | 0 NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs | 15 +++++++ .../Buttons/Reactions/ExitGame.cs.meta | 3 ++ .../{ => Reactions}/OpenAsCurrentMainChild.cs | 2 +- .../OpenAsCurrentMainChild.cs.meta | 0 .../Buttons/{ => Reactions}/OpenWindow.cs | 2 +- .../{ => Reactions}/OpenWindow.cs.meta | 0 NEG/UI/UnityUi/MonoUiManager.cs | 2 +- RequireInterface.meta | 8 ---- RequireInterface/Editor.meta | 8 ---- 26 files changed, 34 insertions(+), 120 deletions(-) delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction.meta delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs.meta delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs.meta delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs delete mode 100644 NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs.meta create mode 100644 NEG/UI/UnityUi/Buttons/Reactions.meta rename NEG/UI/UnityUi/Buttons/{ => Reactions}/ButtonReaction.cs (100%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/ButtonReaction.cs.meta (100%) rename NEG/UI/UnityUi/Buttons/{ChangeSceneButton.cs => Reactions/ChangeScene.cs} (84%) rename NEG/UI/UnityUi/Buttons/{ChangeSceneButton.cs.meta => Reactions/ChangeScene.cs.meta} (100%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/CloseAllWindows.cs (77%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/CloseAllWindows.cs.meta (100%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/CloseWindow.cs (91%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/CloseWindow.cs.meta (100%) create mode 100644 NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs create mode 100644 NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs.meta rename NEG/UI/UnityUi/Buttons/{ => Reactions}/OpenAsCurrentMainChild.cs (87%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/OpenAsCurrentMainChild.cs.meta (100%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/OpenWindow.cs (91%) rename NEG/UI/UnityUi/Buttons/{ => Reactions}/OpenWindow.cs.meta (100%) delete mode 100644 RequireInterface.meta delete mode 100644 RequireInterface/Editor.meta diff --git a/NEG/UI/UnityUi/Buttons/BaseButton.cs b/NEG/UI/UnityUi/Buttons/BaseButton.cs index 4253e94..2e414af 100644 --- a/NEG/UI/UnityUi/Buttons/BaseButton.cs +++ b/NEG/UI/UnityUi/Buttons/BaseButton.cs @@ -1,5 +1,5 @@ using KBCore.Refs; -using NEG.UI.UnityUi.Buttons.Reaction; +using NEG.UI.UnityUi.Buttons.Behaviours; using NEG.UI.UnityUi.Buttons.Settings; using System; using System.Collections.Generic; @@ -43,7 +43,11 @@ namespace NEG.UI.UnityUi.Buttons private void Start() => OnDeselect(null); - private void OnValidate() => this.ValidateRefs(); + private void OnValidate() + { + this.ValidateRefs(); + text.text = gameObject.name; + } public void OnDeselect(BaseEventData eventData) => OnDeselected?.Invoke(eventData is SilentEventData); diff --git a/NEG/UI/UnityUi/Buttons/Reaction.meta b/NEG/UI/UnityUi/Buttons/Reaction.meta deleted file mode 100644 index 0c789ee..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 953c3353e3af44258625fe607ede632b -timeCreated: 1683915598 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs b/NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs deleted file mode 100644 index c5f4204..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs +++ /dev/null @@ -1,21 +0,0 @@ -using NEG.UI.UnityUi.Buttons.Settings; -using System; - -namespace NEG.UI.UnityUi.Buttons.Reaction -{ - 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/Reaction/ButtonElementBehaviour.cs.meta b/NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs.meta deleted file mode 100644 index 1d19cfd..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction/ButtonElementBehaviour.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a5e3decad6424cb288eff3e6f7e0d28e -timeCreated: 1683919740 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs b/NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs deleted file mode 100644 index 228b388..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs +++ /dev/null @@ -1,41 +0,0 @@ -using NEG.UI.UnityUi.Buttons.Settings; -using NEG.Utils; -using UnityEngine; - -namespace NEG.UI.UnityUi.Buttons.Reaction -{ - 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/Reaction/ChangeTextColorBehaviour.cs.meta b/NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs.meta deleted file mode 100644 index c279ffe..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction/ChangeTextColorBehaviour.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: f2079225d6e34001ae85f74a0a418d68 -timeCreated: 1683919878 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs b/NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs deleted file mode 100644 index 13386d7..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs +++ /dev/null @@ -1,21 +0,0 @@ -#if FMOD -namespace NEG.UI.UnityUi.Buttons.Reaction -{ - 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/Reaction/SimpleSoundBehaviour.cs.meta b/NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs.meta deleted file mode 100644 index 80fe7c7..0000000 --- a/NEG/UI/UnityUi/Buttons/Reaction/SimpleSoundBehaviour.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d75c0d86eeab47a1a6340f0b03b83de0 -timeCreated: 1684002680 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Reactions.meta b/NEG/UI/UnityUi/Buttons/Reactions.meta new file mode 100644 index 0000000..bee9e71 --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Reactions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ccaf0d2f63be41f6956471dcd9c210d9 +timeCreated: 1709465582 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/ButtonReaction.cs b/NEG/UI/UnityUi/Buttons/Reactions/ButtonReaction.cs similarity index 100% rename from NEG/UI/UnityUi/Buttons/ButtonReaction.cs rename to NEG/UI/UnityUi/Buttons/Reactions/ButtonReaction.cs diff --git a/NEG/UI/UnityUi/Buttons/ButtonReaction.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/ButtonReaction.cs.meta similarity index 100% rename from NEG/UI/UnityUi/Buttons/ButtonReaction.cs.meta rename to NEG/UI/UnityUi/Buttons/Reactions/ButtonReaction.cs.meta diff --git a/NEG/UI/UnityUi/Buttons/ChangeSceneButton.cs b/NEG/UI/UnityUi/Buttons/Reactions/ChangeScene.cs similarity index 84% rename from NEG/UI/UnityUi/Buttons/ChangeSceneButton.cs rename to NEG/UI/UnityUi/Buttons/Reactions/ChangeScene.cs index 7518523..df70ccb 100644 --- a/NEG/UI/UnityUi/Buttons/ChangeSceneButton.cs +++ b/NEG/UI/UnityUi/Buttons/Reactions/ChangeScene.cs @@ -1,10 +1,10 @@ using UnityEngine; using UnityEngine.SceneManagement; -namespace NEG.UI.UnityUi.Buttons +namespace NEG.UI.UnityUi.Buttons.Reactions { [RequireComponent(typeof(BaseButton))] - public class ChangeSceneButton : ButtonReaction + public class ChangeScene : ButtonReaction { [Header("Leave empty to use int value")] [SerializeField] private string sceneName; diff --git a/NEG/UI/UnityUi/Buttons/ChangeSceneButton.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/ChangeScene.cs.meta similarity index 100% rename from NEG/UI/UnityUi/Buttons/ChangeSceneButton.cs.meta rename to NEG/UI/UnityUi/Buttons/Reactions/ChangeScene.cs.meta diff --git a/NEG/UI/UnityUi/Buttons/CloseAllWindows.cs b/NEG/UI/UnityUi/Buttons/Reactions/CloseAllWindows.cs similarity index 77% rename from NEG/UI/UnityUi/Buttons/CloseAllWindows.cs rename to NEG/UI/UnityUi/Buttons/Reactions/CloseAllWindows.cs index 071ad86..9456d63 100644 --- a/NEG/UI/UnityUi/Buttons/CloseAllWindows.cs +++ b/NEG/UI/UnityUi/Buttons/Reactions/CloseAllWindows.cs @@ -1,4 +1,4 @@ -namespace NEG.UI.UnityUi.Buttons +namespace NEG.UI.UnityUi.Buttons.Reactions { public class CloseAllWindows : ButtonReaction { diff --git a/NEG/UI/UnityUi/Buttons/CloseAllWindows.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/CloseAllWindows.cs.meta similarity index 100% rename from NEG/UI/UnityUi/Buttons/CloseAllWindows.cs.meta rename to NEG/UI/UnityUi/Buttons/Reactions/CloseAllWindows.cs.meta diff --git a/NEG/UI/UnityUi/Buttons/CloseWindow.cs b/NEG/UI/UnityUi/Buttons/Reactions/CloseWindow.cs similarity index 91% rename from NEG/UI/UnityUi/Buttons/CloseWindow.cs rename to NEG/UI/UnityUi/Buttons/Reactions/CloseWindow.cs index 2eb8407..4624218 100644 --- a/NEG/UI/UnityUi/Buttons/CloseWindow.cs +++ b/NEG/UI/UnityUi/Buttons/Reactions/CloseWindow.cs @@ -2,7 +2,7 @@ using NEG.UI.Window; using UnityEngine; -namespace NEG.UI.UnityUi.Buttons +namespace NEG.UI.UnityUi.Buttons.Reactions { [RequireComponent(typeof(BaseButton))] public class CloseWindow : ButtonReaction diff --git a/NEG/UI/UnityUi/Buttons/CloseWindow.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/CloseWindow.cs.meta similarity index 100% rename from NEG/UI/UnityUi/Buttons/CloseWindow.cs.meta rename to NEG/UI/UnityUi/Buttons/Reactions/CloseWindow.cs.meta diff --git a/NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs b/NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs new file mode 100644 index 0000000..f870bb6 --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs @@ -0,0 +1,15 @@ +using UnityEngine; + +namespace NEG.UI.UnityUi.Buttons.Reactions +{ + public class ExitGame : ButtonReaction + { + protected override void OnClicked() + { +#if UNITY_EDITOR + UnityEditor.EditorApplication.isPlaying = false; +#endif + Application.Quit(); + } + } +} \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs.meta new file mode 100644 index 0000000..2ccc8f2 --- /dev/null +++ b/NEG/UI/UnityUi/Buttons/Reactions/ExitGame.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 185f765a5bf7487ab85a7d95fc0ef2c7 +timeCreated: 1709473462 \ No newline at end of file diff --git a/NEG/UI/UnityUi/Buttons/OpenAsCurrentMainChild.cs b/NEG/UI/UnityUi/Buttons/Reactions/OpenAsCurrentMainChild.cs similarity index 87% rename from NEG/UI/UnityUi/Buttons/OpenAsCurrentMainChild.cs rename to NEG/UI/UnityUi/Buttons/Reactions/OpenAsCurrentMainChild.cs index af5302e..5c56abd 100644 --- a/NEG/UI/UnityUi/Buttons/OpenAsCurrentMainChild.cs +++ b/NEG/UI/UnityUi/Buttons/Reactions/OpenAsCurrentMainChild.cs @@ -2,7 +2,7 @@ using NEG.UI.Window; using UnityEngine; -namespace NEG.UI.UnityUi.Buttons +namespace NEG.UI.UnityUi.Buttons.Reactions { public class OpenAsCurrentMainChild : ButtonReaction { diff --git a/NEG/UI/UnityUi/Buttons/OpenAsCurrentMainChild.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/OpenAsCurrentMainChild.cs.meta similarity index 100% rename from NEG/UI/UnityUi/Buttons/OpenAsCurrentMainChild.cs.meta rename to NEG/UI/UnityUi/Buttons/Reactions/OpenAsCurrentMainChild.cs.meta diff --git a/NEG/UI/UnityUi/Buttons/OpenWindow.cs b/NEG/UI/UnityUi/Buttons/Reactions/OpenWindow.cs similarity index 91% rename from NEG/UI/UnityUi/Buttons/OpenWindow.cs rename to NEG/UI/UnityUi/Buttons/Reactions/OpenWindow.cs index 45b0cbf..0056446 100644 --- a/NEG/UI/UnityUi/Buttons/OpenWindow.cs +++ b/NEG/UI/UnityUi/Buttons/Reactions/OpenWindow.cs @@ -3,7 +3,7 @@ using NEG.UI.UnityUi.WindowSlot; using NEG.UI.Window; using UnityEngine; -namespace NEG.UI.UnityUi.Buttons +namespace NEG.UI.UnityUi.Buttons.Reactions { [RequireComponent(typeof(BaseButton))] public class OpenWindow : ButtonReaction diff --git a/NEG/UI/UnityUi/Buttons/OpenWindow.cs.meta b/NEG/UI/UnityUi/Buttons/Reactions/OpenWindow.cs.meta similarity index 100% rename from NEG/UI/UnityUi/Buttons/OpenWindow.cs.meta rename to NEG/UI/UnityUi/Buttons/Reactions/OpenWindow.cs.meta diff --git a/NEG/UI/UnityUi/MonoUiManager.cs b/NEG/UI/UnityUi/MonoUiManager.cs index a3e7fb5..9bb5742 100644 --- a/NEG/UI/UnityUi/MonoUiManager.cs +++ b/NEG/UI/UnityUi/MonoUiManager.cs @@ -1,6 +1,6 @@ using NEG.UI.Area; using NEG.UI.Popup; -using NEG.UI.UnityUi.Buttons.Reaction; +using NEG.UI.UnityUi.Buttons.Behaviours; using NEG.UI.UnityUi.Buttons.Settings; using NEG.UI.UnityUi.Popup; using NEG.UI.UnityUi.Window; diff --git a/RequireInterface.meta b/RequireInterface.meta deleted file mode 100644 index f1a1fa6..0000000 --- a/RequireInterface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: da80835a1611a5e4d908f51f09e8d3bc -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/RequireInterface/Editor.meta b/RequireInterface/Editor.meta deleted file mode 100644 index 89239d9..0000000 --- a/RequireInterface/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 849242dbc213969488426f85222a43a9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: