private void OnPopupResult(PopupResult result) { if (result.ResultType == PopupResultType.Positive) #if UNITY_EDITOR { UnityEditor.EditorApplication.isPlaying = false; } #else { UnityEngine.Application.Quit(); } #endif }
public void ButtonEvent(int i) { myResult = (PopupResult)i; if (action != null) action.Invoke(myResult); _anim.SetTrigger(ClosingHash); }
public Task <PopupResult> Do <Popup>() { var tcs = new TaskCompletionSource <PopupResult>(); var view = new Popup(); var model = new PopupResult(); view.DataContext = model; view.Close += (e, o) => tcs.SetResult(model); return(tcs.Task); }
public async void RemoveButton_Click() { PopupResult popResult = await MenuManager.LaunchPopupAsync(PopupType.OKCancel, $"Remove {trait.Name}?"); if (popResult == PopupResult.OK) { Mini.ActiveMini.RemoveTrait(trait); monitor.PopulateGrid(); } }
// Launches a popup with a message (mostly yes/no/ok/cancel) static public async Task <PopupResult> LaunchPopupAsync(PopupType pType, string message, CancellationToken ct = default) { GameObject menu = GameObject.Instantiate(prefabPopup); PopupMonitor monitor = menu.GetComponent <PopupMonitor>(); PopupResult result = await monitor.SetPopupAsync(pType, message, ct); // once result is obtained, destroy the menu GameObject.Destroy(menu); return(result); }
public async void TrashButton_Click() { PopupResult popResult = await MenuManager.LaunchPopupAsync(PopupType.OKCancel, $"Destroying {trait.Name} will remove it from all minis. Proceed?"); if (popResult == PopupResult.OK) { MiniCollection.RemoveTraitFromAllMinis(trait); Trait.RemoveTrait(trait); monitor.PopulateGrid(); } }
// Remove popup from opening list public void ClosePopup(Popup popup) { openingPopup.Remove(popup); switch (popup.type) { case Popup.Type.POPUP_RESULT: popupResult = null; break; case Popup.Type.POPUP_LEAVE_GAME: popupLeaveGame = null; break; case Popup.Type.POPUP_CREATE_ROOM: popupCreateRoom = null; break; case Popup.Type.POPUP_USER_INFO: popupUserInfo = null; break; case Popup.Type.POPUP_FRIENDS: popupFriends = null; break; case Popup.Type.POPUP_INVITE_TO_GAME: popupInviteToGame = null; break; case Popup.Type.POPUP_INVITE_TO_GAME_CONFIRM: popupInviteGameConfirm = null; break; case Popup.Type.POPUP_RELOAD_GAME: popupReloadGame = null; break; case Popup.Type.POPUP_SETTING: popupSetting = null; break; case Popup.Type.POPUP_INBOX: popupInbox = null; break; case Popup.Type.POPUP_PAYOUT: popupPayout = null; break; } }
private IEnumerator WaitForPopupCloseToReshow(string main_message, string ok_btn_text, bool show_not_ok_button, string not_ok_button_text) { while (popupIsShownOrAnimating) { yield return(new WaitForEndOfFrame()); } popupUserSelection = PopupResult.NOT_SELECTED; popupText.text = main_message; okBtnText.text = ok_btn_text; notOkBtnText.text = not_ok_button_text; notOkButton.SetActive(show_not_ok_button); animatorComponent.SetBool("showPopup", true); popupIsShownOrAnimating = true; }
// this task is set up for each button static async Task <PopupResult> PopupButton_ClickAsync(Button button, PopupResult pResult, CancellationToken ct) { ct.ThrowIfCancellationRequested(); // necessary? bool isPressed = false; button.onClick.AddListener(() => isPressed = true); //Debug.Log($"Button {button.name} gives result of {pResult} and is on {button.gameObject.name}"); while (!isPressed) { await Task.Yield(); // let someone else take over, unless pressed } // this only is reached if it is the first task to complete return(pResult); }
//-------------------------------------------------------- public void OnEggFallOut(Egg egg) // configured via Inspector // Update lives (internally) { --lives; // Make egg stop interactions egg.GetComponent <Rigidbody2D>().simulated = false; eggThrower.enabled = false; if (lives >= 0) // Continue playing { this.egg = egg; StartCoroutine(Rebirth()); } else // Game over { InvalidateLives(); PopupResult pr = GameObject.FindObjectOfType <PopupResult>(); if (pr != null) { pr.Show(ScoreHolder.instance.totalScore); } } }
public PopUpResultEventArgs(PopupResult rst) { result = rst; }
public void PopupNOTOKBTN() { popupUserSelection = PopupResult.SELECTED_NOT_OK; animatorComponent.SetBool("showPopup", false); }
// Remove popup from opening list public void ClosePopup(Popup popup) { openingPopup.Remove(popup); switch(popup.type) { case Popup.Type.POPUP_RESULT: popupResult = null; break; case Popup.Type.POPUP_LEAVE_GAME: popupLeaveGame = null; break; case Popup.Type.POPUP_CREATE_ROOM: popupCreateRoom = null; break; case Popup.Type.POPUP_USER_INFO: popupUserInfo = null; break; case Popup.Type.POPUP_FRIENDS: popupFriends = null; break; case Popup.Type.POPUP_INVITE_TO_GAME: popupInviteToGame = null; break; case Popup.Type.POPUP_INVITE_TO_GAME_CONFIRM: popupInviteGameConfirm = null; break; case Popup.Type.POPUP_RELOAD_GAME: popupReloadGame = null; break; case Popup.Type.POPUP_SETTING: popupSetting = null; break; case Popup.Type.POPUP_INBOX: popupInbox = null; break; case Popup.Type.POPUP_PAYOUT: popupPayout = null; break; } }
public void OpenPopup(Popup.Type type, object[] data = null, bool shouldAnimate = true) { Popup tempPopup = null; switch(type) { case Popup.Type.POPUP_RESULT: if (popupResult == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupResult/PopupResult", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupResult"; popupResult = tempGameObject.GetComponent<PopupResult>(); tempPopup = popupResult as Popup; popupResult.Init(data); if (shouldAnimate) { popupResult.Open(); } else { popupResult.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_LEAVE_GAME: if (popupLeaveGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupLeaveGame", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupResult"; popupLeaveGame = tempGameObject.GetComponent<PopupLeaveGame>(); tempPopup = popupLeaveGame as Popup; popupLeaveGame.Init(data); if (shouldAnimate) { popupLeaveGame.Open(); } else { popupLeaveGame.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_CREATE_ROOM: if (popupCreateRoom == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupCreateRoom/PopupCreateRoom", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupCreateRoom"; popupCreateRoom = tempGameObject.GetComponent<PopupCreateRoom>(); tempPopup = popupCreateRoom as Popup; popupCreateRoom.Init(data); if (shouldAnimate) { popupCreateRoom.Open(); } else { popupCreateRoom.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_USER_INFO: if (popupUserInfo == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupUserInfo", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupUserInfo"; popupUserInfo = tempGameObject.GetComponent<PopupUserInfo>(); tempPopup = popupUserInfo as Popup; popupUserInfo.Init(data); if (shouldAnimate) { popupUserInfo.Open(); } else { popupUserInfo.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_FRIENDS: if (popupFriends == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupFriends/PopupFriends", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupFriends"; popupFriends = tempGameObject.GetComponent<PopupFriends>(); tempPopup = popupFriends as Popup; popupFriends.Init(data); if (shouldAnimate) { popupFriends.Open(); } else { popupFriends.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_INBOX: if (popupFriends == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupInbox/PopupInbox", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupInbox"; popupInbox = tempGameObject.GetComponent<PopupInbox>(); tempPopup = popupInbox as Popup; popupInbox.Init(data); if (shouldAnimate) { popupInbox.Open(); } else { popupInbox.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_INVITE_TO_GAME: if (popupInviteToGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupInviteToGame/PopupInviteToGame", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupInviteToGame"; popupInviteToGame = tempGameObject.GetComponent<PopupInviteToGame>(); tempPopup = popupInviteToGame as Popup; popupInviteToGame.Init(data); if (shouldAnimate) { popupInviteToGame.Open(); } else { popupInviteToGame.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_INVITE_TO_GAME_CONFIRM: if (popupInviteGameConfirm == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupInviteGameConfirm", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupInviteGameConfirm"; popupInviteGameConfirm = tempGameObject.GetComponent<PopupInviteGameConfirm>(); tempPopup = popupInviteGameConfirm as Popup; popupInviteGameConfirm.Init(data); if (shouldAnimate) { popupInviteGameConfirm.Open(); } else { popupInviteGameConfirm.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_RELOAD_GAME: if (popupReloadGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupReloadGame", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupReloadGame"; popupReloadGame = tempGameObject.GetComponent<PopupReloadGame>(); tempPopup = popupReloadGame as Popup; popupReloadGame.Init(data); if (shouldAnimate) { popupReloadGame.Open(); } else { popupReloadGame.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_SETTING: if (popupReloadGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupSetting", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupSetting"; popupSetting = tempGameObject.GetComponent<PopupSetting>(); tempPopup = popupSetting as Popup; popupSetting.Init(data); if (shouldAnimate) { popupSetting.Open(); } else { popupSetting.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_PAYOUT: if (popupPayout == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupPayout", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupPayout"; popupPayout = tempGameObject.GetComponent<PopupPayout>(); tempPopup = popupPayout as Popup; popupPayout.Init(data); if (shouldAnimate) { popupPayout.Open(); } else { popupPayout.OpenPopupNoAnimation(); } } break; } if (tempPopup != null) { openingPopup.Add(tempPopup); } }
public PopupClosedEventArgs(PopupResult popupResult) { PopupResult = popupResult; }
private void Cancel_Tap(object sender, System.Windows.Input.GestureEventArgs e) { popup_result = PopupResult.PRCANCEL; CloseMe(); }
protected virtual void OnCtlDismiss(PopupResult rst) { if (OnDisMiss != null) OnDisMiss(this,new PopUpResultEventArgs(rst)); }
public static PopupResult Show(Window owner, string messageText, string caption = "", PopupButton button = PopupButton.OK, PopupImage icon = PopupImage.None, PopupResult defaultResult = PopupResult.None, Style messageBoxStyle = null) { return ShowCore(messageText, caption, button, icon, defaultResult, messageBoxStyle); }
/// <summary> /// Initializes the MessageBox. /// </summary> /// <param name="text">The text.</param> /// <param name="caption">The caption.</param> /// <param name="button">The button.</param> /// <param name="image">The image.</param> /// <param name="defaultResult">The default result.</param> protected void InitializeMessageBox(string text, string caption, PopupButton button, PopupImage image, PopupResult defaultResult) { Header = caption; Content = text; PopupButton = button; PopupImage = image; _defaultResult = defaultResult; }
public void CreateQuestion(string title, string body, PopupResult popupResult, PopupType question, Action<PopupResult> handler) { var newObj = Instantiate(_objects[PopupBoxScript.AsText]); Text[] txtCmp = newObj.GetComponentsInChildren<Text>(); for (int i = 0; i < txtCmp.Length; i++) { var curCmp = txtCmp[i]; if (curCmp.name == "Title") { curCmp.text = title; } if (curCmp.name == "Body") { curCmp.text = body; } } // Set Buttons var btns = newObj.GetComponentsInChildren<Button>(); // Pass in bit field of btnFlags. int btnFlags = (int)popupResult; for (int i = 0; i < btns.Length; i++) { btns[i].gameObject.SetActive((btnFlags & (1 << i)) > 0); } var scrObj = newObj.GetComponent<PopupBoxScript>(); scrObj.action = handler; newObj.SetParent(_canvas.transform, false); }
public async void Debug_Click() { PopupResult pResult = await MenuManager.LaunchPopupAsync(PopupType.YesNo, "This is a test message"); Debug.Log("Result is: " + pResult.ToString()); }
public void OnResultPickedHandler(PopupResult r) { Debug.Log("UIManager says you picked " + r.ToString()); }
private void Confirm_Tap(object sender, System.Windows.Input.GestureEventArgs e) { popup_result = PopupResult.PROK; CloseMe(); }
public PopupWindowEventArgs(PopupResult result) { Result = result; }
public void OpenPopup(Popup.Type type, object[] data = null, bool shouldAnimate = true) { Popup tempPopup = null; switch (type) { case Popup.Type.POPUP_RESULT: if (popupResult == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupResult/PopupResult", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupResult"; popupResult = tempGameObject.GetComponent <PopupResult>(); tempPopup = popupResult as Popup; popupResult.Init(data); if (shouldAnimate) { popupResult.Open(); } else { popupResult.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_LEAVE_GAME: if (popupLeaveGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupLeaveGame", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupResult"; popupLeaveGame = tempGameObject.GetComponent <PopupLeaveGame>(); tempPopup = popupLeaveGame as Popup; popupLeaveGame.Init(data); if (shouldAnimate) { popupLeaveGame.Open(); } else { popupLeaveGame.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_CREATE_ROOM: if (popupCreateRoom == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupCreateRoom/PopupCreateRoom", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupCreateRoom"; popupCreateRoom = tempGameObject.GetComponent <PopupCreateRoom>(); tempPopup = popupCreateRoom as Popup; popupCreateRoom.Init(data); if (shouldAnimate) { popupCreateRoom.Open(); } else { popupCreateRoom.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_USER_INFO: if (popupUserInfo == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupUserInfo", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupUserInfo"; popupUserInfo = tempGameObject.GetComponent <PopupUserInfo>(); tempPopup = popupUserInfo as Popup; popupUserInfo.Init(data); if (shouldAnimate) { popupUserInfo.Open(); } else { popupUserInfo.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_FRIENDS: if (popupFriends == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupFriends/PopupFriends", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupFriends"; popupFriends = tempGameObject.GetComponent <PopupFriends>(); tempPopup = popupFriends as Popup; popupFriends.Init(data); if (shouldAnimate) { popupFriends.Open(); } else { popupFriends.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_INBOX: if (popupFriends == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupInbox/PopupInbox", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupInbox"; popupInbox = tempGameObject.GetComponent <PopupInbox>(); tempPopup = popupInbox as Popup; popupInbox.Init(data); if (shouldAnimate) { popupInbox.Open(); } else { popupInbox.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_INVITE_TO_GAME: if (popupInviteToGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupInviteToGame/PopupInviteToGame", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupInviteToGame"; popupInviteToGame = tempGameObject.GetComponent <PopupInviteToGame>(); tempPopup = popupInviteToGame as Popup; popupInviteToGame.Init(data); if (shouldAnimate) { popupInviteToGame.Open(); } else { popupInviteToGame.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_INVITE_TO_GAME_CONFIRM: if (popupInviteGameConfirm == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupInviteGameConfirm", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupInviteGameConfirm"; popupInviteGameConfirm = tempGameObject.GetComponent <PopupInviteGameConfirm>(); tempPopup = popupInviteGameConfirm as Popup; popupInviteGameConfirm.Init(data); if (shouldAnimate) { popupInviteGameConfirm.Open(); } else { popupInviteGameConfirm.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_RELOAD_GAME: if (popupReloadGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupReloadGame", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupReloadGame"; popupReloadGame = tempGameObject.GetComponent <PopupReloadGame>(); tempPopup = popupReloadGame as Popup; popupReloadGame.Init(data); if (shouldAnimate) { popupReloadGame.Open(); } else { popupReloadGame.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_SETTING: if (popupReloadGame == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupSetting", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupSetting"; popupSetting = tempGameObject.GetComponent <PopupSetting>(); tempPopup = popupSetting as Popup; popupSetting.Init(data); if (shouldAnimate) { popupSetting.Open(); } else { popupSetting.OpenPopupNoAnimation(); } } break; case Popup.Type.POPUP_PAYOUT: if (popupPayout == null) { GameObject tempGameObject = NGUITools.AddChild(root, Resources.Load(Global.POPUP_PATH + "/PopupPayout", typeof(GameObject)) as GameObject); tempGameObject.name = "PopupPayout"; popupPayout = tempGameObject.GetComponent <PopupPayout>(); tempPopup = popupPayout as Popup; popupPayout.Init(data); if (shouldAnimate) { popupPayout.Open(); } else { popupPayout.OpenPopupNoAnimation(); } } break; } if (tempPopup != null) { openingPopup.Add(tempPopup); } }
/// <summary> /// Shows the MessageBox. /// </summary> /// <param name="messageText">The message text.</param> /// <param name="caption">The caption.</param> /// <param name="button">The button.</param> /// <param name="icon">The icon.</param> /// <param name="defaultResult">The default result.</param> /// <param name="messageBoxStyle">The style to be set.</param> /// <returns></returns> /// <exception cref="InvalidOperationException">Static methods for MessageBoxes are not available in XBAP. /// Use the instance ShowMessageBox methods instead.</exception> private static PopupResult ShowCore(string messageText, string caption, PopupButton button, PopupImage icon, PopupResult defaultResult, Style messageBoxStyle) { if (System.Windows.Interop.BrowserInteropHelper.IsBrowserHosted) throw new InvalidOperationException("Static methods for MessageBoxes are not available in XBAP. Use the instance ShowMessageBox methods instead."); var messageBox = new MetroPopup(); messageBox.InitializeMessageBox(messageText, caption, button, icon, defaultResult); // Setting the style to null will inhibit any implicit styles if (messageBoxStyle != null) messageBox.Style = messageBoxStyle; if (Application.Current.MainWindow.Content as Visual == null) return PopupResult.None; var layer = AdornerLayer.GetAdornerLayer(Application.Current.MainWindow.Content as Visual); var contentAd = new ControlAdorner(Application.Current.MainWindow.Content as UIElement) { Child = messageBox }; layer.Add(contentAd); // Disable Closing of window while dialog is shown Application.Current.MainWindow.Closing += MainWindow_Closing; messageBox.ShowDialog(); Application.Current.MainWindow.Closing -= MainWindow_Closing; layer.Remove(contentAd); return messageBox.PopupResult; }
private PopupResult result; // @brief PopupResultクラスの参照用 private void Start() { isCallOnse = false; result = resultPopup.GetComponent <PopupResult>(); }
void Button_OnClick(object sender, ButtonEventArg e) { if (e.Link == "Ok") { Result = PopupResult.Ok; } else if (e.Link == "Yes") { Result = PopupResult.Yes; } else if (e.Link == "No") { Result = PopupResult.No; } FireOnResult(); }