public void Show() { if (messages.Count > 0) { PopupData mess = messages.First(); if (mess != null) { displaying = true; messages.Remove(mess); ShowPopup(mess); Action action = mess.btnAction; Action tempAction = () => { action?.Invoke(); Show(); }; mess.btnAction = tempAction; } else { messages.Remove(mess); } } else { displaying = false; Close(); } }
public static void ShowScheduledPopup(PopupData message) { if (!Instance.messages.Contains(message)) { Instance.messages.Add(message); if (!Instance.displaying) { Instance.Show(); } } }
public static void ShowScheduledPopup(ILootLockerPopupData data) { PopupData message = new PopupData(); message.btnAction = data.btnAction; message.buttonText = data.buttonText; message.header = data.header; message.normalText = data.normalText; message.sprite = data.sprite; message.ignoreCurrentSprite = data.ignoreCurrentSprite; message.url = data.url; if (!Instance.messages.Contains(message)) { Instance.messages.Add(message); if (!Instance.displaying) { Instance.Show(); } } }
public static void ShowPopup(PopupData popupData) { Instance.currentPopup = popupData; Instance?.button?.onClick?.RemoveAllListeners(); Instance?.button?.onClick?.AddListener(() => { popupData?.btnAction(); }); Instance.normalText.text = ""; Instance.headerText.color = Color.black; if (popupData.normalText != null) { foreach (var data in popupData.normalText) { Instance.normalText.text += popupData.withKey ? data.Key + " : " + data.Value + "\n" : data.Value + "\n"; } } Instance.btnText.text = popupData.buttonText; Instance.headerText.text = popupData.header; Instance.headerText.color = popupData.isError ? Color.red : Color.black; Instance.GetComponent <ScreenOpener>()?.Open(); popupData.preview = Instance.image; TexturesSaver.QueueForDownload(popupData); }
public static void ShowPopup(string header, Dictionary <string, string> normalText, string buttonText, Action btnAction, string url = null, bool withKey = true, bool isError = false) { PopupData popupData = new PopupData(header, normalText, buttonText, btnAction, url, withKey, isError); ShowPopup(popupData); }
private void SelectPlayer(Grant grant, List <LootLockerRewardObject> rewardObjects = null) { string header = ""; string normalTextMessage = ""; Dictionary <string, string> data = new Dictionary <string, string>(); string icon = grant == Grant.Credits ? creditsSprite : xpSprite; LootLockerSDKManager.StartSession(LootLockerConfig.current.deviceID, (response) => { LoadingManager.HideLoadingScreen(); if (response.success) { header = "Success"; if (grant == Grant.Credits) { normalTextMessage = "Successfully granted Credits."; } if (grant == Grant.XP) { normalTextMessage = "Successfully granted XP."; } data.Clear(); //Preparing data to display or error messages we have data.Add("1", normalTextMessage); StagesManager.instance.GoToStage(StagesManager.StageID.Home, response); if (rewardObjects != null && rewardObjects.Count > 0) { for (int i = 0; i < rewardObjects.Count; i++) { PopupData PopupData = new PopupData(); PopupData.buttonText = "Ok"; PopupData.url = rewardObjects[i].asset.links.thumbnail; PopupData.withKey = true; PopupData.normalText = new Dictionary <string, string>() { { "Reward", rewardObjects[i].asset.name } }; PopupData.header = "You got a reward"; PopupSystem.ShowScheduledPopup(PopupData); } } } else { header = "Failed"; string correctedResponse = response.Error.First() == '{' ? response.Error : response.Error.Substring(response.Error.IndexOf('{')); ResponseError errorMessage = new ResponseError(); errorMessage = JsonConvert.DeserializeObject <ResponseError>(correctedResponse); normalTextMessage = errorMessage.messages[0]; data.Clear(); //Preparing data to display or error messages we have data.Add("1", normalTextMessage); } PopupSystem.ShowApprovalFailPopUp(header, data, icon); }); }