Example #1
0
    private static bool ShowDialog <CMD_Type>(Action <int> action, string title, string message, string dialogName = "", AlertManager.ButtonActionType actionType = AlertManager.ButtonActionType.Close, bool isWarningIcon = true, bool useErrorCode = false) where CMD_Type : CMD
    {
        Action <int> action2 = delegate(int i)
        {
            if (action != null)
            {
                action(i);
            }
        };

        if (AlertManager.alertOpenedAction != null)
        {
            AlertManager.alertOpenedAction();
        }
        if (!useErrorCode)
        {
            AlertManager.lastErrorCode = "unknown:" + AlertManager.lastErrorCode;
        }
        PlayerPrefs.SetString("LastErrorInfo", ServerDateTime.Now + ":" + AlertManager.lastErrorCode);
        CMD_Type cmd_Type = GUIMain.ShowCommonDialog(action2, dialogName, null) as CMD_Type;

        if (cmd_Type != null)
        {
            string text = typeof(CMD_Type).ToString();
            if (text != null)
            {
                if (!(text == "CMD_Alert"))
                {
                    if (!(text == "CMD_maintenance"))
                    {
                        if (text == "CMD_ModalMessage")
                        {
                            CMD_ModalMessage cmd_ModalMessage = cmd_Type as CMD_ModalMessage;
                            cmd_ModalMessage.Title = title;
                            cmd_ModalMessage.Info  = message;
                            AlertManager.ExecuteOnCreateAlert(true, null);
                        }
                    }
                    else
                    {
                        CMD_maintenance cmd_maintenance = cmd_Type as CMD_maintenance;
                        cmd_maintenance.Info = message;
                    }
                }
                else
                {
                    CMD_Alert cmd_Alert = cmd_Type as CMD_Alert;
                    cmd_Alert.Title     = title;
                    cmd_Alert.Info      = message;
                    cmd_Alert.IsWarning = isWarningIcon;
                    switch (actionType)
                    {
                    case AlertManager.ButtonActionType.Close:
                        cmd_Alert.SetDisplayButton(CMD_Alert.DisplayButton.CLOSE);
                        break;

                    case AlertManager.ButtonActionType.Retry:
                        cmd_Alert.SetDisplayButton(CMD_Alert.DisplayButton.RETRY);
                        break;

                    case AlertManager.ButtonActionType.TitleAndRetry:
                        cmd_Alert.SetDisplayButton(CMD_Alert.DisplayButton.TITLE_AND_RETRY);
                        break;

                    case AlertManager.ButtonActionType.Title:
                        cmd_Alert.SetDisplayButton(CMD_Alert.DisplayButton.TITLE);
                        break;
                    }
                    AlertManager.ExecuteOnCreateAlert(true, cmd_Alert);
                }
            }
            return(true);
        }
        if (action != null)
        {
            action(0);
        }
        UnityEngine.Debug.Log("Create Failed CMD : " + title + ", " + message);
        return(false);
    }