diff options
| author | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
|---|---|---|
| committer | chai <215380520@qq.com> | 2024-05-20 22:36:58 +0800 |
| commit | a22c505984697881f5f911a165ee022087b69e09 (patch) | |
| tree | d3c030aef1ae9b8a01c889dd2902bb1e3324e72b /Thronefall_1_0/Decompile/ThronefallUIElement.cs | |
| parent | 4a4cc82d069b26bc4d4532e73860f86b211ca239 (diff) | |
Diffstat (limited to 'Thronefall_1_0/Decompile/ThronefallUIElement.cs')
| -rw-r--r-- | Thronefall_1_0/Decompile/ThronefallUIElement.cs | 166 |
1 files changed, 0 insertions, 166 deletions
diff --git a/Thronefall_1_0/Decompile/ThronefallUIElement.cs b/Thronefall_1_0/Decompile/ThronefallUIElement.cs deleted file mode 100644 index e2c9d64..0000000 --- a/Thronefall_1_0/Decompile/ThronefallUIElement.cs +++ /dev/null @@ -1,166 +0,0 @@ -using UnityEngine; -using UnityEngine.Events; - -public abstract class ThronefallUIElement : MonoBehaviour -{ - public enum NavigationDirection - { - Right, - Left, - Up, - Down - } - - public enum SelectionState - { - Default, - Focussed, - Selected, - FocussedAndSelected - } - - protected SelectionState currentState; - - protected SelectionState previousState; - - public bool ignoreMouse; - - public bool autoSelectOnFocus; - - public bool cannotBeSelected; - - public ThronefallUIElement leftNav; - - public ThronefallUIElement rightNav; - - public ThronefallUIElement topNav; - - public ThronefallUIElement botNav; - - public UnityEvent onSelectionStateChange = new UnityEvent(); - - public UnityEvent onApply = new UnityEvent(); - - public UnityEvent<NavigationDirection> onEmptyNavigate = new UnityEvent<NavigationDirection>(); - - public SelectionState CurrentState => currentState; - - public SelectionState PreviousState => previousState; - - public virtual bool dragable => false; - - public void Apply() - { - if (!SceneTransitionManager.instance.SceneTransitionIsRunning) - { - onApply.Invoke(); - OnApply(); - } - } - - public void Select() - { - SetState(SelectionState.Selected); - } - - public void Focus() - { - SetState(SelectionState.Focussed); - } - - public void FocusAndSelect() - { - SetState(SelectionState.FocussedAndSelected); - } - - public void Clear() - { - SetState(SelectionState.Default); - } - - public void HardStateSet(SelectionState selectionState) - { - currentState = selectionState; - previousState = selectionState; - OnHardStateSet(selectionState); - } - - protected abstract void OnApply(); - - protected abstract void OnClear(); - - protected abstract void OnSelect(); - - protected abstract void OnFocus(); - - protected abstract void OnFocusAndSelect(); - - protected abstract void OnHardStateSet(SelectionState selectionState); - - private void SetState(SelectionState state) - { - if (state != currentState) - { - previousState = currentState; - currentState = state; - switch (currentState) - { - case SelectionState.Default: - OnClear(); - break; - case SelectionState.Focussed: - OnFocus(); - break; - case SelectionState.Selected: - OnSelect(); - break; - case SelectionState.FocussedAndSelected: - OnFocusAndSelect(); - break; - } - onSelectionStateChange.Invoke(); - } - } - - public ThronefallUIElement TryNavigate(NavigationDirection direction) - { - if (SceneTransitionManager.instance.SceneTransitionIsRunning) - { - return this; - } - ThronefallUIElement thronefallUIElement = null; - switch (direction) - { - case NavigationDirection.Down: - thronefallUIElement = botNav; - break; - case NavigationDirection.Up: - thronefallUIElement = topNav; - break; - case NavigationDirection.Left: - thronefallUIElement = leftNav; - break; - case NavigationDirection.Right: - thronefallUIElement = rightNav; - break; - } - if ((bool)thronefallUIElement && !thronefallUIElement.gameObject.activeInHierarchy) - { - return thronefallUIElement.TryNavigate(direction); - } - onEmptyNavigate.Invoke(direction); - return thronefallUIElement; - } - - public virtual void OnDrag(Vector2 mousePosition) - { - } - - public virtual void OnDragEnd() - { - } - - public virtual void OnDragStart() - { - } -} |
