Skip to main content

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).

Constructors​

MemberWhat it is
Window()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

9 private and internal fields
MemberWhat it is
private ConfirmPopupPanel confirmPopupThe panel used by ShowConfirmPopup.
private TaskCompletionSource<bool> confirmPopupTaskTask for the open confirm popup's answer.
private bool isAutoStartingWhether the window opens its starting panel on Start.
private LoadingUI loadingUILoading indicator toggled by SetLoadingActive.
private static Logger loggerNLog logger for panel switches.
private UnityEvent onStartedInspector event raised when the window starts.
private OptionsPanel optionsPanelPanel used by ShowOptions.
private SimpleTextPanel simpleTextPanelPanel used by ShowTextPanel.
private Panel startingPanelPanel shown when the window starts.

Properties​

MemberWhat 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​

MemberWhat it is
event Action<Window> StartedRaised when StartWindow runs.

Methods​

MemberWhat 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
MemberWhat 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: