From f8a4f04fe6f68518ebf3a5165949d47d3914068a Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Sun, 26 Nov 2023 02:13:45 +0100 Subject: [PATCH] start of buttons + fixes --- Assets/Scenes/Editor.unity | 105 +++++++++++++----- .../EventSelector/GridGameSelector.cs | 75 ++++++++++--- .../EventSelector/NewGameSelectionEvent.cs | 36 ++++++ .../NewGameSelectionEvent.cs.meta | 11 ++ .../UI/SettingsDialog/Tabs/EditorSettings.cs | 4 +- 5 files changed, 182 insertions(+), 49 deletions(-) create mode 100644 Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs create mode 100644 Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs.meta diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index 71e7162fa..67fae6384 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -371,9 +371,9 @@ RectTransform: m_Father: {fileID: 574002313} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: -21} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 32, y: 32} m_Pivot: {x: 0, y: 0.5} --- !u!114 &9435782 @@ -3519,9 +3519,9 @@ RectTransform: m_Father: {fileID: 539838476} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 32, y: -21} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 32, y: 32} m_Pivot: {x: 1, y: 0.5} --- !u!114 &121871281 @@ -3664,9 +3664,9 @@ RectTransform: m_Father: {fileID: 539838476} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 72, y: -21} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 32, y: 32} m_Pivot: {x: 1, y: 0.5} --- !u!114 &129013734 @@ -3786,9 +3786,9 @@ RectTransform: m_Father: {fileID: 539838476} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 112, y: -21} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 32, y: 32} m_Pivot: {x: 1, y: 0.5} --- !u!114 &151246938 @@ -5567,15 +5567,15 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: m_Padding: - m_Left: 45 + m_Left: 8 m_Right: 0 m_Top: 25 m_Bottom: 0 m_ChildAlignment: 0 - m_Spacing: 0 + m_Spacing: 2 m_ChildForceExpandWidth: 1 m_ChildForceExpandHeight: 0 - m_ChildControlWidth: 1 + m_ChildControlWidth: 0 m_ChildControlHeight: 0 m_ChildScaleWidth: 0 m_ChildScaleHeight: 0 @@ -21550,8 +21550,8 @@ MonoBehaviour: m_TargetGraphic: {fileID: 1589389272} m_HandleRect: {fileID: 1589389271} m_Direction: 2 - m_Value: 0 - m_Size: 1 + m_Value: 1 + m_Size: 0.9997085 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: @@ -24479,6 +24479,8 @@ GameObject: m_Component: - component: {fileID: 1062374753} - component: {fileID: 1062374754} + - component: {fileID: 1062374756} + - component: {fileID: 1062374755} m_Layer: 8 m_Name: Event m_TagString: Untagged @@ -24505,8 +24507,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 45, y: -60.003906} - m_SizeDelta: {x: 380, y: 35} + m_AnchoredPosition: {x: 7.9999995, y: -60} + m_SizeDelta: {x: 380, y: 50} m_Pivot: {x: 0, y: 0} --- !u!222 &1062374754 CanvasRenderer: @@ -24516,6 +24518,50 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1062374752} m_CullTransparentMesh: 1 +--- !u!114 &1062374755 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1062374752} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.2627451, g: 0.2627451, b: 0.2627451, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 1401309272, guid: bd48ded17f064414eb670529c2375358, type: 3} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!114 &1062374756 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1062374752} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e516a0af70289ed41b99296cf8aacbc9, type: 3} + m_Name: + m_EditorClassIdentifier: + _text: {fileID: 1436814487} + _gearIcon: {fileID: 954812100} --- !u!1 &1063174878 GameObject: m_ObjectHideFlags: 0 @@ -26484,7 +26530,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 0, y: 199.0612} + m_AnchoredPosition: {x: 0, y: 199.06108} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 1} --- !u!222 &1154875945 @@ -26546,6 +26592,7 @@ MonoBehaviour: ignoreSelectCount: 2 _newGameEventSelector: {fileID: 516264814} _newEventsParent: {fileID: 219152398} + _newEventRef: {fileID: 1062374752} --- !u!114 &1154875948 MonoBehaviour: m_ObjectHideFlags: 0 @@ -28234,7 +28281,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 15.7 + m_fontSize: 13.9 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -30566,9 +30613,9 @@ RectTransform: m_Father: {fileID: 574002313} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 40, y: -21} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 32, y: 32} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1345846031 @@ -31974,7 +32021,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchoredPosition: {x: 3.8, y: 0} m_SizeDelta: {x: -66, y: 0} m_Pivot: {x: 0, y: 0} --- !u!114 &1436814487 @@ -32024,7 +32071,7 @@ MonoBehaviour: m_faceColor: serializedVersion: 2 rgba: 4294967295 - m_fontSize: 15.7 + m_fontSize: 16.65 m_fontSizeBase: 24 m_fontWeight: 400 m_enableAutoSizing: 1 @@ -38560,9 +38607,9 @@ RectTransform: m_Father: {fileID: 574002313} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 80, y: -21} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 32, y: 32} m_Pivot: {x: 0, y: 0.5} --- !u!114 &1783491359 diff --git a/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs b/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs index 83a1863f0..bbf85b6a0 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/GridGameSelector.cs @@ -54,7 +54,6 @@ namespace HeavenStudio.Editor eventsParent = EventRef.transform.parent.GetChild(2).GetComponent(); SelectedMinigame = EventCaller.instance.GetMinigame(fxActive[0].name); SwitchGameSelectionType(PersistentDataManager.gameSettings.useOldGameEventSelectionSystem); - EditorSettings.onUseOldChanged += SwitchGameSelectionType; } private void Update() @@ -86,10 +85,6 @@ namespace HeavenStudio.Editor //moved here so this updates dynamically with window scale UpdateScrollPosition(); } - else - { - - } } #region Functions @@ -159,22 +154,19 @@ namespace HeavenStudio.Editor EventParameterManager.instance.Disable(); gameOpen = true; - if (_usingOld) SelectGameOld(gameName, index); - else SelectGameNew(gameName, index); + if (_usingOld) SelectGameOld(index); + else SelectGameNew(index); + Editor.instance?.SetGameEventTitle($"Select game event for {SelectedMinigame.displayName.Replace("\n", "")}"); + SelectedGameIcon = transform.Find(gameName).gameObject; + SelectedGameIcon.GetComponent().ClickIcon(); } - private void SelectGameOld(string gameName, int index = 0) + private void SelectGameOld(int index = 0) { DestroyEvents(); AddEvents(index); - - SelectedGameIcon = transform.Find(gameName).gameObject; - SelectedGameIcon.GetComponent().ClickIcon(); - currentEventIndex = index; UpdateIndex(index, false); - - Editor.instance?.SetGameEventTitle($"Select game event for {SelectedMinigame.displayName.Replace("\n", "")}"); } private void AddEvents(int index = 0) @@ -467,6 +459,7 @@ namespace HeavenStudio.Editor [Header("New Game Event Selection")] [SerializeField] private GameObject _newGameEventSelector; [SerializeField] private RectTransform _newEventsParent; + [SerializeField] private GameObject _newEventRef; private bool _usingOld = false; @@ -476,7 +469,7 @@ namespace HeavenStudio.Editor if (!gameOpen) return; if (old) { - // destroy events here + NewDestroyEvents(); } else { @@ -485,9 +478,57 @@ namespace HeavenStudio.Editor SelectGame(SelectedMinigame.name); } - private void SelectGameNew(string gameName, int index) + private void SelectGameNew(int index) { + NewDestroyEvents(); + NewAddEvents(); + } + private void NewAddEvents(int index = 0) + { + if (!EventCaller.FXOnlyGames().Contains(SelectedMinigame)) + { + NewGameSelectionEvent sg = Instantiate(_newEventRef, _newEventsParent).GetComponent(); + sg.SetText("Switch Game"); + sg.gameObject.SetActive(true); + if (index == 0) sg.SetTextColor(EditorTheme.theme.properties.EventSelectedCol.Hex2RGB()); + } + else + { + index++; + if (SelectedMinigame.name == "gameManager") index++; + } + + for (var i = 0; i < SelectedMinigame.actions.Count; i++) + { + var action = SelectedMinigame.actions[i]; + if (action.actionName == "switchGame" || action.hidden) continue; + + NewGameSelectionEvent g = Instantiate(_newEventRef, _newEventsParent).GetComponent(); + g.SetText(action.displayName); + + if (action.parameters != null && action.parameters.Count > 0) + g.SetActiveGearIcon(true); + + if (index - 1 == i) + g.SetTextColor(EditorTheme.theme.properties.EventSelectedCol.Hex2RGB()); + + g.gameObject.SetActive(true); + + } + } + + private void NewDestroyEvents() + { + for (int i = 0; i < transform.childCount; i++) + { + transform.GetChild(i).GetChild(0).gameObject.SetActive(false); + } + + for (int i = 0; i < _newEventsParent.childCount; i++) + { + Destroy(_newEventsParent.GetChild(i).gameObject); + } } public void Disable() @@ -498,7 +539,7 @@ namespace HeavenStudio.Editor } else { - + NewDestroyEvents(); } gameOpen = false; } diff --git a/Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs b/Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs new file mode 100644 index 000000000..5d5692c82 --- /dev/null +++ b/Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using TMPro; +using UnityEngine; + +namespace HeavenStudio.Editor +{ + public class NewGameSelectionEvent : MonoBehaviour + { + [NonSerialized] public int index; + [SerializeField] private TMP_Text _text; + [SerializeField] private GameObject _gearIcon; + + public void SetText(string text) + { + _text.text = text; + } + + public void SetTextColor(Color color) + { + _text.color = color; + } + + public void SetActiveGearIcon(bool a) + { + _gearIcon.SetActive(a); + } + + public void Drag() + { + if (Conductor.instance.NotStopped() || Editor.instance.inAuthorativeMenu) return; + } + } +} + diff --git a/Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs.meta b/Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs.meta new file mode 100644 index 000000000..0d297f488 --- /dev/null +++ b/Assets/Scripts/LevelEditor/EventSelector/NewGameSelectionEvent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e516a0af70289ed41b99296cf8aacbc9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/SettingsDialog/Tabs/EditorSettings.cs b/Assets/Scripts/UI/SettingsDialog/Tabs/EditorSettings.cs index 2396333ff..81119e045 100644 --- a/Assets/Scripts/UI/SettingsDialog/Tabs/EditorSettings.cs +++ b/Assets/Scripts/UI/SettingsDialog/Tabs/EditorSettings.cs @@ -15,8 +15,6 @@ namespace HeavenStudio.Editor public Toggle scaleWSS; [SerializeField] private Toggle useOldCheckbox; - public static event Action onUseOldChanged; - private void Start() { cursorCheckbox.isOn = PersistentDataManager.gameSettings.editorCursorEnable; @@ -97,7 +95,7 @@ namespace HeavenStudio.Editor public void OnUseOldChanged() { PersistentDataManager.gameSettings.useOldGameEventSelectionSystem = useOldCheckbox.isOn; - onUseOldChanged?.Invoke(useOldCheckbox.isOn); + GridGameSelector.instance.SwitchGameSelectionType(useOldCheckbox.isOn); } } } \ No newline at end of file