renamed UILock to align with property naming conventions, add docs for UIStance/UIGroup enums, predict more UIStance items (rename Play to PlayAdjust)

This commit is contained in:
Xevion
2020-05-23 00:17:19 -05:00
parent 26031f4870
commit 5a8ead9bf3
+22 -8
View File
@@ -34,7 +34,7 @@ public class UIController : MonoBehaviour {
private Rect _canvasRect; private Rect _canvasRect;
private float _scaleFactor; private float _scaleFactor;
private int _activeTweens; private int _activeTweens;
private bool _UILock => _activeTweens > 0; private bool UILock => _activeTweens > 0;
// Element Displacements // Element Displacements
private Vector3 _aboutDiff; private Vector3 _aboutDiff;
@@ -43,13 +43,27 @@ public class UIController : MonoBehaviour {
private Vector3 _settingsDiff; private Vector3 _settingsDiff;
private Vector3 _adjustmentsDiff; private Vector3 _adjustmentsDiff;
/// <summary> <c>UIStance</c> describes difference 'stances', or UI configurations.
/// <see cref="UIController.ChangeStance"/> allows easy change between different stances with the <see cref="UIController.MoveElements"/>
/// method. Note, this enum is similar but different from the <see cref="UIGroup"/> Enum.
/// </summary>
/// <seealso cref="UIController.ChangeStance"/>
/// <seealso cref="UIController.MoveElements"/>
private enum UIStance { private enum UIStance {
Title, Title,
Play, PlayAdjust,
PlayHelp,
PlayHidden,
Settings, Settings,
About About
} }
/// <summary> <c>UIGroup</c> describes distinct groups of UI elements.
/// This Enum is used within <see cref="UIController.MoveElements"/> in order to describe specific portions of the application
/// compared to a 'UI Stance'.
/// <remarks>This Enum may be removed and be functionally replaced with <see cref="UIStance"/> later on.</remarks>
/// </summary>
/// <seealso cref="UIController.MoveElements"/>
private enum UIGroup { private enum UIGroup {
TitleScreen, TitleScreen,
AdjustmentsScreen, AdjustmentsScreen,
@@ -65,7 +79,7 @@ public class UIController : MonoBehaviour {
_scaleFactor = Screen.width / _scaler.referenceResolution.x; _scaleFactor = Screen.width / _scaler.referenceResolution.x;
// Add stance change functionality to buttons // Add stance change functionality to buttons
startButton.onClick.AddListener(() => ChangeStance(UIStance.Play)); startButton.onClick.AddListener(() => ChangeStance(UIStance.PlayAdjust));
aboutButton.onClick.AddListener(() => ChangeStance(UIStance.About)); aboutButton.onClick.AddListener(() => ChangeStance(UIStance.About));
aboutCloseButton.onClick.AddListener(() => ChangeStance(UIStance.Title)); aboutCloseButton.onClick.AddListener(() => ChangeStance(UIStance.Title));
settingsButton.onClick.AddListener(() => ChangeStance(UIStance.Settings)); settingsButton.onClick.AddListener(() => ChangeStance(UIStance.Settings));
@@ -102,7 +116,7 @@ public class UIController : MonoBehaviour {
/// <seealso cref="StartTween"/> /// <seealso cref="StartTween"/>
private void TweenEnd() { private void TweenEnd() {
_activeTweens -= 1; _activeTweens -= 1;
if (!_UILock) if (!UILock)
Debug.Log("Unlocking Stance Changes"); Debug.Log("Unlocking Stance Changes");
} }
@@ -114,7 +128,7 @@ public class UIController : MonoBehaviour {
/// <returns>returns the <see cref="TweenEnd"/> action for a deconstructing callback</returns> /// <returns>returns the <see cref="TweenEnd"/> action for a deconstructing callback</returns>
/// <seealso cref="TweenEnd"/> /// <seealso cref="TweenEnd"/>
private Action StartTween() { private Action StartTween() {
if (!_UILock) if (!UILock)
Debug.Log("Locking Stance Changes"); Debug.Log("Locking Stance Changes");
_activeTweens += 1; _activeTweens += 1;
return TweenEnd; return TweenEnd;
@@ -128,7 +142,7 @@ public class UIController : MonoBehaviour {
/// <exception cref="ArgumentOutOfRangeException"></exception> /// <exception cref="ArgumentOutOfRangeException"></exception>
private void ChangeStance(UIStance stance) { private void ChangeStance(UIStance stance) {
// Quit early if UI is currently "locked" due to an active tween // Quit early if UI is currently "locked" due to an active tween
if (_UILock || stance == _currentUI) if (UILock || stance == _currentUI)
return; return;
Debug.Log($"UI Transition: {_currentUI} -> {stance}"); Debug.Log($"UI Transition: {_currentUI} -> {stance}");
@@ -140,13 +154,13 @@ public class UIController : MonoBehaviour {
MoveElements(UIGroup.SettingsScreen, false); MoveElements(UIGroup.SettingsScreen, false);
else if (stance == UIStance.About) else if (stance == UIStance.About)
MoveElements(UIGroup.AboutScreen, false); MoveElements(UIGroup.AboutScreen, false);
else if (stance == UIStance.Play) else if (stance == UIStance.PlayAdjust)
MoveElements(UIGroup.AdjustmentsScreen, false); MoveElements(UIGroup.AdjustmentsScreen, false);
} }
// Settings/About/Play -> Title // Settings/About/Play -> Title
else if (stance == UIStance.Title) { else if (stance == UIStance.Title) {
MoveElements(UIGroup.TitleScreen, false); MoveElements(UIGroup.TitleScreen, false);
if (_currentUI == UIStance.Play) if (_currentUI == UIStance.PlayAdjust)
MoveElements(UIGroup.AdjustmentsScreen, true); MoveElements(UIGroup.AdjustmentsScreen, true);
else if (_currentUI == UIStance.Settings) else if (_currentUI == UIStance.Settings)
MoveElements(UIGroup.SettingsScreen, true); MoveElements(UIGroup.SettingsScreen, true);