Ejemplo n.º 1
0
 /// <summary>
 /// Invoked when the dialog is closed.
 /// </summary>
 /// <param name="action">The action key taken.</param>
 private void OnOptionsSelected(string action)
 {
     if (action == "ok")
     {
         // Save changes to mod options
         WriteOptions();
         if (options != null)
         {
             // Check for [RestartRequired]
             string rr = typeof(RestartRequiredAttribute).FullName;
             bool   restartRequired = false;
             foreach (var attr in options.GetType().GetCustomAttributes(true))
             {
                 if (attr.GetType().FullName == rr)
                 {
                     restartRequired = true;
                     break;
                 }
             }
             if (restartRequired)
             {
                 // Prompt user to restart
                 PUIElements.ShowConfirmDialog(null, POptions.RESTART_REQUIRED,
                                               App.instance.Restart, null, POptions.RESTART_OK, POptions.
                                               RESTART_CANCEL);
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Shows a confirmation dialog to force update the specified mod(s).
        /// </summary>
        internal void TryUpdateMods(GameObject _)
        {
            var controller = Global.Instance.GetInputManager()?.GetDefaultController();

            // Check for SHIFT - bypass dialog
            if (activeModifiers != null && (activeModifiers.GetValue(controller) is Modifier
                                            modifier) && modifier == Modifier.Shift)
            {
                UpdateMods();
            }
            else
            {
                var modList = new StringBuilder(256);
                // Add up to the limit to avoid making a dialog larger than the screen
                int n = 0;
                foreach (var mod in Mods)
                {
                    modList.AppendFormat(ModUpdateDateStrings.CONFIRM_LINE, mod.Title);
                    n++;
                    // (and N more...)
                    if (n >= ModUpdateDateStrings.MAX_LINES)
                    {
                        modList.AppendFormat(ModUpdateDateStrings.CONFIRM_MORE, Mods.Count -
                                             n);
                        break;
                    }
                }
                PUIElements.ShowConfirmDialog(null, string.Format(ModUpdateDateStrings.
                                                                  CONFIRM_UPDATE, modList.ToString()), UpdateMods, null,
                                              ModUpdateDateStrings.CONFIRM_OK, ModUpdateDateStrings.CONFIRM_CANCEL);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Shows a confirmation dialog to force update the specified mod(s).
        /// </summary>
        internal void TryUpdateMods(GameObject _)
        {
            var controller = Global.Instance.GetInputManager()?.GetDefaultController();
            var modifier   = Modifier.None;

            try {
                modifier = ACTIVE_MODIFIERS.Get(controller);
            } catch (DetourException) { }
            // Check for SHIFT - bypass dialog
            if (modifier == Modifier.Shift)
            {
                UpdateMods();
            }
            else
            {
                var modList = new StringBuilder(256);
                // Add up to the limit to avoid making a dialog larger than the screen
                int n = 0;
                foreach (var mod in Mods)
                {
                    modList.AppendFormat(UISTRINGS.CONFIRM_LINE, mod.Title);
                    n++;
                    // (and N more...)
                    if (n >= ModUpdateDateStrings.MAX_LINES)
                    {
                        modList.AppendFormat(UISTRINGS.CONFIRM_MORE, Mods.Count - n);
                        break;
                    }
                }
                PUIElements.ShowConfirmDialog(null, string.Format(UISTRINGS.CONFIRM_UPDATE,
                                                                  modList.ToString()), UpdateMods, null, UISTRINGS.CONFIRM_OK, UISTRINGS.
                                              CONFIRM_CANCEL);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Checks the mod config class for the [RestartRequired] attribute, and brings up a
 /// restart dialog if necessary.
 /// </summary>
 private void CheckForRestart()
 {
     if (options != null && options.GetType().
         GetCustomAttribute <RestartRequiredAttribute>() != null)
     {
         // Prompt user to restart
         PUIElements.ShowConfirmDialog(null, PLibStrings.RESTART_REQUIRED,
                                       SaveAndRestart, null, PLibStrings.RESTART_OK, PLibStrings.RESTART_CANCEL);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Applied after OnPrefabInit runs.
 /// </summary>
 internal static void Postfix(MainMenu __instance)
 {
     if (__instance != null)
     {
         var go = __instance.gameObject;
         if (SafeMode)
         {
             PUIElements.ShowConfirmDialog(go, string.Format(ModUpdateDateStrings.
                                                             UI.MODUPDATER.SAFE_MODE, ModVersion.FILE_VERSION, ModVersion.
                                                             BUILD_VERSION), OnOpenGithub, null, ModUpdateDateStrings.UI.
                                           MODUPDATER.SAFE_MODE_GITHUB);
         }
         else if (ModUpdateInfo.Settings?.ShowMainMenuWarning == true)
         {
             go.AddOrGet <MainMenuWarning>();
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Checks the mod config class for the [RestartRequired] attribute, and brings up a
 /// restart dialog if necessary.
 /// </summary>
 private void CheckForRestart()
 {
     if (options != null)
     {
         string rr = typeof(RestartRequiredAttribute).FullName;
         bool   restartRequired = false;
         // Check for [RestartRequired]
         foreach (var attr in options.GetType().GetCustomAttributes(true))
         {
             if (attr.GetType().FullName == rr)
             {
                 restartRequired = true;
                 break;
             }
         }
         if (restartRequired)
         {
             // Prompt user to restart
             PUIElements.ShowConfirmDialog(null, PUIStrings.RESTART_REQUIRED,
                                           SaveAndRestart, null, PUIStrings.RESTART_OK, PUIStrings.
                                           RESTART_CANCEL);
         }
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Shows the summary text once all mods get updated.
        /// </summary>
        internal void OnComplete()
        {
            bool errors = false, configFail = false;
            int  updated = 0, nominal = 0, n = 0;
            var  resultText = new StringBuilder(512);

            resultText.Append(ModUpdateDateStrings.UPDATE_HEADER);
            Results.Sort();
            foreach (var result in Results)
            {
                // Update cumulative status
                if (result.Status == ModDownloadStatus.ConfigError)
                {
                    configFail = true;
                    updated++;
                }
                else if (result.Status == ModDownloadStatus.OK)
                {
                    updated++;
                }
                else
                {
                    errors = true;
                }
                // Reduce clutter from no-config mods successfully updated
                if (result.Status == ModDownloadStatus.OK && result.ConfigsRestored == 0)
                {
                    nominal++;
                }
                else
                {
                    // Only add the maximum number of lines
                    if (n < ModUpdateDateStrings.MAX_LINES)
                    {
                        AddText(resultText, result);
                    }
                    n++;
                }
            }
            if (n > ModUpdateDateStrings.MAX_LINES)
            {
                // (and N more...)
                resultText.AppendFormat(ModUpdateDateStrings.CONFIRM_MORE, n -
                                        ModUpdateDateStrings.MAX_LINES);
            }
            if (nominal > 0)
            {
                if (Results.Count == 1)
                {
                    // Specify mod that was updated with no errors
                    resultText.AppendFormat(ModUpdateDateStrings.UPDATE_SINGLE, Results[0].
                                            Title);
                }
                else
                {
                    // N other mod(s) were updated with no errors
                    resultText.AppendFormat(nominal == 1 ? ModUpdateDateStrings.UPDATE_REST_1 :
                                            ModUpdateDateStrings.UPDATE_REST, nominal);
                }
            }
            if (updated > 0)
            {
                // Success text
                resultText.AppendFormat(ModUpdateDateStrings.UPDATE_FOOTER_OK, updated > 1 ?
                                        ModUpdateDateStrings.UPDATE_MULTIPLE : ModUpdateDateStrings.UPDATE_ONE);
            }
            if (errors)
            {
                // Error text
                resultText.Append(ModUpdateDateStrings.UPDATE_FOOTER_ERROR);
            }
            if (configFail)
            {
                // Config warning text
                resultText.Append(ModUpdateDateStrings.UPDATE_FOOTER_CONFIG);
            }
            PUIElements.ShowConfirmDialog(null, resultText.ToString(), SaveAndRestart,
                                          null, STRINGS.UI.FRONTEND.MOD_DIALOGS.RESTART.OK, STRINGS.UI.FRONTEND.
                                          MOD_DIALOGS.RESTART.CANCEL);
        }