Skip to content

Commit

Permalink
CHANGE: Updated package to version '0.9.0-preview.1'.
Browse files Browse the repository at this point in the history
  • Loading branch information
VulpesSoftware committed Mar 9, 2022
1 parent 21bbee8 commit 0ba438b
Show file tree
Hide file tree
Showing 41 changed files with 130 additions and 1,177 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.9.0-preview.1] - 2022-03-09
### Changed
- Renamed 'IMenuDialogue' and 'MenuDialogue' to 'IMenuModal' and 'MenuModal' respectively.
- Renamed 'MenuHandler.Dialogue' to 'MenuHandler.Modal'.
- Removed 'MenuTransition' classes and moved them into their own package 'com.vulpes.transitions'.
- Added 'com.vulpes.transitions' as a package dependency.
- Other updates preparing package for 1.0.0 release.

## [0.6.0-preview.1] - 2021-10-28
### Changed
- Stripped down MenuLoading class.
Expand Down
8 changes: 4 additions & 4 deletions Samples~/Menu Samples/Scripts/MenuScreen_Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ public override void OnActive()

private void OnQuitButtonPressed()
{
MenuHandler.Dialogue.Show("Quit?", "Are you sure you want to quit?", "To Title", "To Desktop", "Cancel").Done((result) =>
MenuHandler.Modal.Show("Quit?", "Are you sure you want to quit?", "To Title", "To Desktop", "Cancel").Done((result) =>
{
switch (result)
{
case MenuDialogueResult.Confirm:
case MenuModalResult.Confirm:
// Pretend to save?
MenuHandler.Alert.Show("Autosaving...", null, 1.5f);
// Pop the screen and go back to the title.
MenuHandler.PopScreen(MenuTransitionOptions.Sequential);
break;
case MenuDialogueResult.Cancel:
case MenuModalResult.Cancel:
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
break;
case MenuDialogueResult.Alternate:
case MenuModalResult.Alternate:
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions Samples~/Menu Samples/Scripts/MenuScreen_Title.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ private void OnOptionsButtonPressed()
private void OnQuitButtonPressed()
{
// Show a popup to see if the user actually wants to quit.
MenuHandler.Dialogue.Show("Quit?", "Are you sure you want to quit?", "Yes", "No")
MenuHandler.Modal.Show("Quit?", "Are you sure you want to quit?", "Yes", "No")
.Then(result =>
{
// Only quit if the user presses the Confirm / Yes button.
if (result == MenuDialogueResult.Confirm)
if (result == MenuModalResult.Confirm)
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
Expand Down
24 changes: 0 additions & 24 deletions Scripts/Runtime/Interfaces/IMenuDialogue.cs

This file was deleted.

16 changes: 8 additions & 8 deletions Scripts/Runtime/Interfaces/IMenuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ public interface IMenuHandler

IMenuAlert Alert { get; }

IMenuDialogue Dialogue { get; }
IMenuModal Modal { get; }

IMenuLoading Loading { get; }

IPromise PushScreen(IMenuScreen menuScreen, in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise PushScreen(IMenuScreen menuScreen, MenuTransitionOptions options = MenuTransitionOptions.Parallel);

IPromise PopScreen(in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise PopScreen(MenuTransitionOptions options = MenuTransitionOptions.Parallel);

IPromise PopPushScreen(IMenuScreen menuScreen, in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise PopPushScreen(IMenuScreen menuScreen, MenuTransitionOptions options = MenuTransitionOptions.Parallel);

IPromise PopToScreen(IMenuScreen menuScreen, in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise PopToScreen(IMenuScreen menuScreen, MenuTransitionOptions options = MenuTransitionOptions.Parallel);

IPromise PopAllScreens(IMenuScreen menuScreen = null, in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise PopAllScreens(IMenuScreen menuScreen = null, MenuTransitionOptions options = MenuTransitionOptions.Parallel);

IPromise SetScreenStack(IMenuScreen menuScreens, in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise SetScreenStack(IMenuScreen menuScreens, MenuTransitionOptions options = MenuTransitionOptions.Parallel);

IPromise SetScreenStack(IMenuScreen[] menuScreens, in MenuTransitionOptions options = MenuTransitionOptions.Parallel);
IPromise SetScreenStack(IMenuScreen[] menuScreens, MenuTransitionOptions options = MenuTransitionOptions.Parallel);

T GetScreen<T>() where T : IMenuScreen;
}
Expand Down
24 changes: 24 additions & 0 deletions Scripts/Runtime/Interfaces/IMenuModal.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using Vulpes.Promises;

namespace Vulpes.Menus
{
public enum MenuModalResult : int
{
/// <summary>The result when the 'Confirm' button is pressed.</summary>
Confirm,
/// <summary>The result when the 'Cancel' button are pressed.</summary>
Cancel,
/// <summary>The result when the 'Alternate' button is pressed.</summary>
Alternate,
}

public interface IMenuModal
{
IPromise<MenuModalResult> Show(in string title, in string body, in string confirm, Action onConfirm = null);

IPromise<MenuModalResult> Show(in string title, in string body, in string confirm, in string cancel, Action onConfirm = null, Action onCancel = null);

IPromise<MenuModalResult> Show(in string title, in string body, in string confirm, in string cancel, in string alternate, Action onConfirm = null, Action onCancel = null, Action onAlternate = null);
}
}
53 changes: 0 additions & 53 deletions Scripts/Runtime/Interfaces/IMenuTransition.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Scripts/Runtime/Interfaces/IMenuTransition.cs.meta

This file was deleted.

27 changes: 14 additions & 13 deletions Scripts/Runtime/MenuAlert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEngine.UI;
using UnityEngine.EventSystems;
using Vulpes.Promises;
using Vulpes.Transitions;

namespace Vulpes.Menus
{
Expand All @@ -15,7 +16,7 @@ public class MenuAlert : UIBehaviour, IMenuAlert
{
[SerializeField] private TextMeshProUGUI alertText = default;
[SerializeField] private Image iconImage = default;
[SerializeField] private MenuTransition transition = default;
[SerializeField] private Transition transition = default;

private IPromise promiseChain;
private PromiseTimer promiseTimer;
Expand Down Expand Up @@ -55,18 +56,18 @@ public IPromise Show(string message, Sprite icon, float duration)
if (promiseChain == null)
{
SetMessageAndIcon(message, icon);
promiseChain = transition.Play(MenuTransitionMode.Forward)
promiseChain = transition.Play(TransitionMode.Forward)
.Then(() => promiseTimer.WaitFor(duration))
.Then(() => transition.Play(MenuTransitionMode.Reverse))
.Then(() => promise.Resolve());
.Then(() => transition.Play(TransitionMode.Reverse))
.Then(promise.Resolve);
} else
{
promiseChain = promiseChain
.Then(() => SetMessageAndIcon(message, icon))
.Then(() => transition.Play(MenuTransitionMode.Forward))
.Then(() => transition.Play(TransitionMode.Forward))
.Then(() => promiseTimer.WaitFor(duration))
.Then(() => transition.Play(MenuTransitionMode.Reverse))
.Then(() => promise.Resolve());
.Then(() => transition.Play(TransitionMode.Reverse))
.Then(promise.Resolve);
}
return promise;
}
Expand All @@ -81,20 +82,20 @@ public IPromise Show(string message, Sprite icon, IPromise onResolved)
if (promiseChain == null)
{
SetMessageAndIcon(message, icon);
promiseChain = transition.Play(MenuTransitionMode.Forward)
promiseChain = transition.Play(TransitionMode.Forward)
.Then(() => onResolved)
.Then(() => promiseTimer.WaitFor(1.0f))
.Then(() => transition.Play(MenuTransitionMode.Reverse))
.Then(() => promise.Resolve());
.Then(() => transition.Play(TransitionMode.Reverse))
.Then(promise.Resolve);
} else
{
promiseChain = promiseChain
.Then(() => SetMessageAndIcon(message, icon))
.Then(() => transition.Play(MenuTransitionMode.Forward))
.Then(() => transition.Play(TransitionMode.Forward))
.Then(() => onResolved)
.Then(() => promiseTimer.WaitFor(1.0f))
.Then(() => transition.Play(MenuTransitionMode.Reverse))
.Then(() => promise.Resolve());
.Then(() => transition.Play(TransitionMode.Reverse))
.Then(promise.Resolve);
}
return promise;
}
Expand Down
26 changes: 13 additions & 13 deletions Scripts/Runtime/MenuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ public bool CursorLocked
public IMenuAlert Alert { get; private set; }

/// <summary>
/// Returns the <see cref="IMenuDialogue"/> if it exists.
/// Returns the <see cref="IMenuModal"/> if it exists.
/// </summary>
public IMenuDialogue Dialogue { get; private set; }
public IMenuModal Modal { get; private set; }

/// <summary>
/// Returns the <see cref="IMenuTooltip"/> if it exists.
Expand Down Expand Up @@ -148,7 +148,7 @@ protected override void Awake()
Screens[i].Initialize(this);
}
ScreenStack = new Stack<IMenuScreen>();
Dialogue = GetComponentInChildren<IMenuDialogue>(true);
Modal = GetComponentInChildren<IMenuModal>(true);
Alert = GetComponentInChildren<IMenuAlert>(true);
Tooltip = GetComponentInChildren<IMenuTooltip>(true);
Loading = GetComponentInChildren<IMenuLoading>(true);
Expand All @@ -168,11 +168,11 @@ protected override void Awake()

public List<RaycastResult> Raycast(Vector2 position)
{
PointerEventData pointerEventData = new PointerEventData(EventSystem.current)
PointerEventData pointerEventData = new(EventSystem.current)
{
position = position
};
List<RaycastResult> results = new List<RaycastResult>();
List<RaycastResult> results = new();
EventSystem.RaycastAll(pointerEventData, results);
return results;
}
Expand Down Expand Up @@ -213,7 +213,7 @@ private void Update()
/// <summary>
/// Pushes a <see cref="IMenuScreen"/> to the stack, transitioning it in and the old one out.
/// </summary>
public IPromise PushScreen(IMenuScreen menuScreen, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise PushScreen(IMenuScreen menuScreen, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
IMenuScreen outScreen = HasScreen ? CurrentScreen : null;
ScreenStack.Push(menuScreen);
Expand All @@ -223,7 +223,7 @@ public IPromise PushScreen(IMenuScreen menuScreen, in MenuTransitionOptions opti
/// <summary>
/// Pops the <see cref="IMenuScreen"/> at the top of the stack off, transitioning it out and the next available one in.
/// </summary>
public IPromise PopScreen(in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise PopScreen(MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
IMenuScreen outScreen = HasScreen ? ScreenStack.Pop() : null;
IMenuScreen inScreen = HasScreen ? CurrentScreen : null;
Expand All @@ -233,7 +233,7 @@ public IPromise PopScreen(in MenuTransitionOptions options = MenuTransitionOptio
/// <summary>
/// Pops the <see cref="IMenuScreen"/> at the top of the stack off, transitioning it out and the requested one in.
/// </summary>
public IPromise PopPushScreen(IMenuScreen menuScreen, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise PopPushScreen(IMenuScreen menuScreen, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
IMenuScreen outScreen = HasScreen ? ScreenStack.Pop() : null;
ScreenStack.Push(menuScreen);
Expand All @@ -243,7 +243,7 @@ public IPromise PopPushScreen(IMenuScreen menuScreen, in MenuTransitionOptions o
/// <summary>
/// Pops to the requested <see cref="IMenuScreen"/> in the stack.
/// </summary>
private void PopToScreen(IMenuScreen menuScreen, IPromise promise, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
private void PopToScreen(IMenuScreen menuScreen, IPromise promise, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
if (CurrentScreen == menuScreen)
{
Expand All @@ -263,7 +263,7 @@ private void PopToScreen(IMenuScreen menuScreen, IPromise promise, in MenuTransi
/// Pops to the requested <see cref="IMenuScreen"/> if it's present in the stack, returns a <see cref="IPromise"/>
/// that will resolve on completion, or reject if the <see cref="IMenuScreen"/> is not in the stack.
/// </summary>
public IPromise PopToScreen(IMenuScreen menuScreen, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise PopToScreen(IMenuScreen menuScreen, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
IPromise promise = Promise.Create();
if (!ScreenStack.Contains(menuScreen))
Expand All @@ -278,7 +278,7 @@ public IPromise PopToScreen(IMenuScreen menuScreen, in MenuTransitionOptions opt
/// <summary>
/// Pops all <see cref="IMenuScreen"/>s off the stack, optionally pushing a new one in their place.
/// </summary>
public IPromise PopAllScreens(IMenuScreen menuScreen = null, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise PopAllScreens(IMenuScreen menuScreen = null, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
IMenuScreen outScreen = HasScreen ? ScreenStack.Pop() : null;
ScreenStack.Clear();
Expand All @@ -292,15 +292,15 @@ public IPromise PopAllScreens(IMenuScreen menuScreen = null, in MenuTransitionOp
/// <summary>
/// Forces the stack into a new state containing only the requested <see cref="IMenuScreen"/>.
/// </summary>
public IPromise SetScreenStack(IMenuScreen menuScreens, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise SetScreenStack(IMenuScreen menuScreens, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
return SetScreenStack(new IMenuScreen[] { menuScreens }, options);
}

/// <summary>
/// Forces the stack into a new state containing the requested <see cref="MenuScreen"/>s (the final <see cref="MenuScreen"/> in the array will be at the top of the stack).
/// </summary>
public IPromise SetScreenStack(IMenuScreen[] menuScreens, in MenuTransitionOptions options = MenuTransitionOptions.Sequential)
public IPromise SetScreenStack(IMenuScreen[] menuScreens, MenuTransitionOptions options = MenuTransitionOptions.Sequential)
{
IMenuScreen outScreen = HasScreen ? ScreenStack.Pop() : null;
ScreenStack.Clear();
Expand Down
Loading

0 comments on commit 0ba438b

Please sign in to comment.