Window
A class in Root.Township, Alta.Meta.UI.
Client: a menu screen made of panels. Shows one panel at a time plus popups (confirm, options, loading).
- Listed in Menus, UI and platforms
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
Window() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private ConfirmPopupPanel confirmPopup | The panel used by ShowConfirmPopup. |
private TaskCompletionSource<bool> confirmPopupTask | Task for the open confirm popup's answer. |
private bool isAutoStarting | Whether the window opens its starting panel on Start. |
private LoadingUI loadingUI | Loading indicator toggled by SetLoadingActive. |
private static Logger logger | NLog logger for panel switches. |
private UnityEvent onStarted | Inspector event raised when the window starts. |
private OptionsPanel optionsPanel | Panel used by ShowOptions. |
private SimpleTextPanel simpleTextPanel | Panel used by ShowTextPanel. |
private Panel startingPanel | Panel shown when the window starts. |
Properties
| Member | What it is |
|---|---|
Panel CurrentPanel { get; private set; } | The panel being shown. |
Panel CurrentPopup { get; private set; } | The popup being shown, such as the confirm popup. Null when none is open. |
Events
| Member | What it is |
|---|---|
event Action<Window> Started | Raised when StartWindow runs. |
Methods
| Member | What it is |
|---|---|
void CloseAllPopups() | Hides the current popup and the options panel. |
void SetLoadingActive(bool loadingState) | Shows or hides the loading UI. |
Task<bool> ShowConfirmPopup(string message, string confirm = "Confirm", string cancel = "Cancel", Action confirmAction = null, Action cancelAction = null) | Shows a confirm popup with the given text and button labels. The task returns true if confirmed, false if cancelled. |
async Task<T> ShowLoadingForTask<T>(Task<T> task) | Shows the loading UI until the task finishes. Errors are logged, and only rethrown if asked. |
async Task ShowLoadingForTask(Task task, bool propogateErrors = false) | Shows the loading UI until the task finishes. Errors are logged, and only rethrown if asked. |
void ShowOptions(IEnumerable<OptionsConfig> optionsConfig, string message = null) | Shows the options panel with the given choices and an optional message. |
void ShowTextPanel(string text) | Sets the text of the simple text panel. |
void StartWindow() | Switches to the starting panel and raises Started. Called on Start unless auto start is off. |
void StopWindow() | Hides the current panel. |
void SwitchToPanel(Panel panel) | Closes popups, hides the current panel and shows the new one once the old one has finished hiding. |
6 private and internal methods
| Member | What it is |
|---|---|
private void CloseCurrentPopupCancelled(ConfirmPopupPanel obj) | Clears the popup and completes the confirm task with false. |
private void CloseCurrentPopupConfirmed(ConfirmPopupPanel obj) | Clears the popup and completes the confirm task with true. |
private void FinishPopupSwitch(Panel panel) | Shows the new popup after the old one has closed. |
private void FinishSwitch(Panel panel) | Shows the new panel after the old one has closed. |
private void ShowAsPopup(Panel panel) | Closes the current popup if any, then shows the given panel as the popup. |
private void Start() | Starts the window if isAutoStarting is set. |
Used in
Members of other types that take, return or hold a Window: