Ejemplo n.º 1
0
        public static bool TryCreateDialogsForVersionMismatchWarnings(Action confirmedAction)
        {
            string text  = null;
            string text2 = null;

            if (!BackCompatibility.IsSaveCompatibleWith(ScribeMetaHeaderUtility.loadedGameVersion) && !ScribeMetaHeaderUtility.VersionsMatch())
            {
                text2 = "VersionMismatch".Translate();
                string text3 = (!ScribeMetaHeaderUtility.loadedGameVersion.NullOrEmpty()) ? ScribeMetaHeaderUtility.loadedGameVersion : ("(" + "UnknownLower".Translate() + ")");
                text = ((ScribeMetaHeaderUtility.lastMode != ScribeHeaderMode.Map) ? ((ScribeMetaHeaderUtility.lastMode != ScribeHeaderMode.World) ? "FileIncompatibleWarning".Translate(text3, VersionControl.CurrentVersionString) : "WorldFileVersionMismatch".Translate(text3, VersionControl.CurrentVersionString)) : "SaveGameIncompatibleWarningText".Translate(text3, VersionControl.CurrentVersionString));
            }
            bool   flag  = false;
            string text4 = default(string);
            string text5 = default(string);

            if (!ScribeMetaHeaderUtility.LoadedModsMatchesActiveMods(out text4, out text5))
            {
                flag = true;
                string text6 = "ModsMismatchWarningText".Translate(text4, text5);
                text = ((text != null) ? (text + "\n\n" + text6) : text6);
                if (text2 == null)
                {
                    text2 = "ModsMismatchWarningTitle".Translate();
                }
            }
            if (text != null)
            {
                string            text7  = text;
                string            title  = text2;
                Dialog_MessageBox dialog = Dialog_MessageBox.CreateConfirmation(text7, confirmedAction, false, title);
                dialog.buttonAText = "LoadAnyway".Translate();
                if (flag)
                {
                    dialog.buttonCText   = "ChangeLoadedMods".Translate();
                    dialog.buttonCAction = delegate
                    {
                        int num = ModLister.InstalledModsListHash(false);
                        ModsConfig.SetActiveToList(ScribeMetaHeaderUtility.loadedModIdsList);
                        ModsConfig.Save();
                        if (num == ModLister.InstalledModsListHash(false))
                        {
                            IEnumerable <string> items = from id in Enumerable.Range(0, ScribeMetaHeaderUtility.loadedModIdsList.Count)
                                                         where ModLister.GetModWithIdentifier(ScribeMetaHeaderUtility.loadedModIdsList[id]) == null
                                                         select ScribeMetaHeaderUtility.loadedModNamesList[id];
                            Messages.Message(string.Format("{0}: {1}", "MissingMods".Translate(), GenText.ToCommaList(items, true)), MessageTypeDefOf.RejectInput);
                            dialog.buttonCClose = false;
                        }
                        else
                        {
                            ModsConfig.RestartFromChangedMods();
                        }
                    };
                }
                Find.WindowStack.Add(dialog);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool TryCreateDialogsForVersionMismatchWarnings(Action confirmedAction)
        {
            string text  = null;
            string text2 = null;

            if (!BackCompatibility.IsSaveCompatibleWith(loadedGameVersion) && !VersionsMatch())
            {
                text2 = "VersionMismatch".Translate();
                string value = loadedGameVersion.NullOrEmpty() ? ("(" + "UnknownLower".TranslateSimple() + ")") : loadedGameVersion;
                text = ((lastMode == ScribeHeaderMode.Map) ? ((string)"SaveGameIncompatibleWarningText".Translate(value, VersionControl.CurrentVersionString)) : ((lastMode != ScribeHeaderMode.World) ? ((string)"FileIncompatibleWarning".Translate(value, VersionControl.CurrentVersionString)) : ((string)"WorldFileVersionMismatch".Translate(value, VersionControl.CurrentVersionString))));
            }
            bool flag = false;

            if (!LoadedModsMatchesActiveMods(out string loadedModsSummary, out string runningModsSummary))
            {
                flag = true;
                string text3 = "ModsMismatchWarningText".Translate(loadedModsSummary, runningModsSummary);
                text = ((text != null) ? (text + "\n\n" + text3) : text3);
                if (text2 == null)
                {
                    text2 = "ModsMismatchWarningTitle".Translate();
                }
            }
            if (text != null)
            {
                Dialog_MessageBox dialog = Dialog_MessageBox.CreateConfirmation(text, confirmedAction, destructive: false, text2);
                dialog.buttonAText = "LoadAnyway".Translate();
                if (flag)
                {
                    dialog.buttonCText   = "ChangeLoadedMods".Translate();
                    dialog.buttonCAction = delegate
                    {
                        if (Current.ProgramState == ProgramState.Entry)
                        {
                            ModsConfig.SetActiveToList(loadedModIdsList);
                        }
                        ModsConfig.SaveFromList(loadedModIdsList);
                        IEnumerable <string> enumerable = from id in Enumerable.Range(0, loadedModIdsList.Count)
                                                          where ModLister.GetModWithIdentifier(loadedModIdsList[id]) == null
                                                          select loadedModNamesList[id];
                        if (enumerable.Any())
                        {
                            Messages.Message(string.Format("{0}: {1}", "MissingMods".Translate(), enumerable.ToCommaList()), MessageTypeDefOf.RejectInput, historical: false);
                            dialog.buttonCClose = false;
                        }
                        ModsConfig.RestartFromChangedMods();
                    };
                }
                Find.WindowStack.Add(dialog);
                return(true);
            }
            return(false);
        }