// For the OKButton On_Click() method
 public void Click_OK()
 {
     AudioManager.Close();
     confirmationEvent.Invoke(true); // Send results of true through event
     Time.timeScale = 1;             // Unpause
     Destroy(gameObject);
 }
Exemplo n.º 2
0
    public static void Confirm(string title = "Title", string confirmationMessage = "Message", string yes = "Yes", string no = "No", ConfirmationEvent yesEvent = null, ConfirmationEvent noEvent = null)
    {
        Instance.titleText.text = title;
        Instance.confirmationMessageText.text = confirmationMessage;
        Instance.yesText.text   = yes;
        Instance.noText.text    = no;
        Instance.titleText.text = title;

        Instance.yesButton.onClick.RemoveAllListeners();
        Instance.noButton.onClick.RemoveAllListeners();
        Instance.yesButton.onClick.AddListener(delegate
        {
            Instance.Hide();

            if (yesEvent != null)
            {
                yesEvent.Invoke();
            }
        });
        Instance.noButton.onClick.AddListener(delegate
        {
            Instance.Hide();

            if (noEvent != null)
            {
                noEvent.Invoke();
            }
        });

        Instance.Display();
    }
Exemplo n.º 3
0
        public Task <bool> ProcessConfirmationAsync(ConfirmationItem confirmation, ConfirmationAction action)
        {
            return(Task.Run(() => {
                confirmation.Status = ConfirmationStatus.Processing;
                bool result = false;
                var actionResult = ConfirmationActionResult.None;
                if (action == ConfirmationAction.Accept)
                {
                    result = App.SteamGuardHelper.CurrentSteamGuard.AcceptConfirmation(confirmation);
                    confirmation.Status = result ? ConfirmationStatus.Accepted : ConfirmationStatus.Unknow;
                    actionResult = result  ? ConfirmationActionResult.Accept : ConfirmationActionResult.Error;
                }
                else if (action == ConfirmationAction.Decline)
                {
                    result = App.SteamGuardHelper.CurrentSteamGuard.DenyConfirmation(confirmation);
                    confirmation.Status = result ? ConfirmationStatus.Declined : ConfirmationStatus.Unknow;
                    actionResult = result ? ConfirmationActionResult.Decline : ConfirmationActionResult.Error;
                }

                App.Logger.Info($"Authenticator.ProcessConfirmationAsync {action.ToString()}: {confirmation}\t" + (result == true ? "[success]" : "[error]"));
                App.History.Write($"{confirmation} {action.ToString()}: {result}");

                ConfirmationEvent.Invoke(this, new AuthenticatorConfirmationEventArgs(actionResult, confirmation));

                return result;
            }));
        }
Exemplo n.º 4
0
        private async Task <bool> GetConfitmations()
        {
            bool success = false;
            int  counter = 0;
            bool isNeedRepeat;

            do
            {
                isNeedRepeat = false;
                if (++counter > 3)
                {
                    App.Logger.Trace($"Authenticator.GetConfitmations Counter: [{counter}]");
                    break;
                }
                try
                {
                    Confirmation[] confirmations = await App.SteamGuardHelper.CurrentSteamGuard.FetchConfirmationsAsync();

                    App.Logger.Info($"Authenticator.GetConfitmations Fetched: {confirmations.Length}");
                    foreach (var confirmation in confirmations)
                    {
                        ConfirmationItem item = new ConfirmationItem(confirmation)
                        {
                            Number = ConfirmationsSource.Count + 1
                        };
                        if (!ConfirmationsSource.Contains(item))
                        {
                            ConfirmationsSource.Add(item);
                            ConfirmationEvent.Invoke(this, new AuthenticatorConfirmationEventArgs(ConfirmationActionResult.Added, item));
                        }
                        App.Logger.Trace($"Authenticator.GetConfitmations Added Confirmation: {item}");
                    }
                    success = true;
                }
                catch (SteamGuardAccount.WGTokenInvalidException ex)
                {
                    App.Logger.Warn($"Authenticator.GetConfitmations WGTokenInvalidException: {ex.Message}");
                    isNeedRepeat = await RefreshSession();
                }
                catch (SteamGuardAccount.WGTokenExpiredException ex)
                {
                    App.Logger.Warn($"Authenticator.GetConfitmations WGTokenExpiredException: {ex.Message}");
                    isNeedRepeat = await RefreshSession();
                }
                catch (WebException ex)
                {
                    App.Logger.Error($"Authenticator.GetConfitmations WebException: {ex.Message}");
                    break;
                }
                catch (Exception ex)
                {
                    App.Logger.Error($"Authenticator.GetConfitmations Exception: {ex.Message}");
                    break;
                }
            } while (isNeedRepeat);

            return(success);
        }