public static void CleanupTranslationFiles()
        {
            LoadedLanguage curLang = LanguageDatabase.activeLanguage;
            LoadedLanguage english = LanguageDatabase.defaultLanguage;

            if (curLang == english)
            {
                return;
            }
            IEnumerable <ModMetaData> activeModsInLoadOrder = ModsConfig.ActiveModsInLoadOrder;

            if (!activeModsInLoadOrder.Any((ModMetaData x) => x.IsCoreMod) || activeModsInLoadOrder.Any((ModMetaData x) => !x.Official))
            {
                Messages.Message("MessageDisableModsBeforeCleaningTranslationFiles".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                return;
            }
            if (LanguageDatabase.activeLanguage.AllDirectories.Any((Tuple <VirtualDirectory, ModContentPack, string> x) => x.Item1 is TarDirectory))
            {
                Messages.Message("MessageUnpackBeforeCleaningTranslationFiles".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                return;
            }
            LongEventHandler.QueueLongEvent(delegate
            {
                if (curLang.anyKeyedReplacementsXmlParseError || curLang.anyDefInjectionsXmlParseError)
                {
                    string value = curLang.lastKeyedReplacementsXmlParseErrorInFile ?? curLang.lastDefInjectionsXmlParseErrorInFile;
                    Messages.Message("MessageCantCleanupTranslationFilesBeucaseOfXmlError".Translate(value), MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    english.LoadData();
                    curLang.LoadData();
                    Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmCleanupTranslationFiles".Translate(curLang.FriendlyNameNative), delegate
                    {
                        LongEventHandler.QueueLongEvent(DoCleanupTranslationFiles, "CleaningTranslationFiles".Translate(), doAsynchronously: true, null);
                    }, destructive: true);
                    dialog_MessageBox.buttonAText = "ConfirmCleanupTranslationFiles_Confirm".Translate();
                    Find.WindowStack.Add(dialog_MessageBox);
                }
            }, null, doAsynchronously: false, null);
        }
        public static void CleanupTranslationFiles()
        {
            LoadedLanguage curLang = LanguageDatabase.activeLanguage;
            LoadedLanguage english = LanguageDatabase.defaultLanguage;

            if (curLang == english)
            {
                return;
            }
            IEnumerable <ModMetaData> activeModsInLoadOrder = ModsConfig.ActiveModsInLoadOrder;

            if (activeModsInLoadOrder.Count <ModMetaData>() != 1 || !activeModsInLoadOrder.First <ModMetaData>().IsCoreMod)
            {
                Messages.Message("MessageDisableModsBeforeCleaningTranslationFiles".Translate(), MessageTypeDefOf.RejectInput, false);
                return;
            }
            LongEventHandler.QueueLongEvent(delegate
            {
                if (curLang.anyKeyedReplacementsXmlParseError || curLang.anyDefInjectionsXmlParseError)
                {
                    string text = curLang.lastKeyedReplacementsXmlParseErrorInFile ?? curLang.lastDefInjectionsXmlParseErrorInFile;
                    Messages.Message("MessageCantCleanupTranslationFilesBeucaseOfXmlError".Translate(new object[]
                    {
                        text
                    }), MessageTypeDefOf.RejectInput, false);
                    return;
                }
                english.LoadData();
                curLang.LoadData();
                Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmCleanupTranslationFiles".Translate(new object[]
                {
                    curLang.FriendlyNameNative
                }), delegate
                {
                    LongEventHandler.QueueLongEvent(new Action(TranslationFilesCleaner.DoCleanupTranslationFiles), "CleaningTranslationFiles".Translate(), true, null);
                }, true, null);
                dialog_MessageBox.buttonAText = "ConfirmCleanupTranslationFiles_Confirm".Translate();
                Find.WindowStack.Add(dialog_MessageBox);
            }, null, false, null);
        }
        public static void CleanupTranslationFiles()
        {
            LoadedLanguage curLang = LanguageDatabase.activeLanguage;
            LoadedLanguage english = LanguageDatabase.defaultLanguage;

            if (curLang != english)
            {
                IEnumerable <ModMetaData> activeModsInLoadOrder = ModsConfig.ActiveModsInLoadOrder;
                if (activeModsInLoadOrder.Count() != 1 || !activeModsInLoadOrder.First().IsCoreMod)
                {
                    Messages.Message("MessageDisableModsBeforeCleaningTranslationFiles".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    LongEventHandler.QueueLongEvent(delegate
                    {
                        if (curLang.anyKeyedReplacementsXmlParseError || curLang.anyDefInjectionsXmlParseError)
                        {
                            string value = curLang.lastKeyedReplacementsXmlParseErrorInFile ?? curLang.lastDefInjectionsXmlParseErrorInFile;
                            Messages.Message("MessageCantCleanupTranslationFilesBeucaseOfXmlError".Translate(value), MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else
                        {
                            english.LoadData();
                            curLang.LoadData();
                            Dialog_MessageBox dialog_MessageBox = Dialog_MessageBox.CreateConfirmation("ConfirmCleanupTranslationFiles".Translate(curLang.FriendlyNameNative), delegate
                            {
                                LongEventHandler.QueueLongEvent(DoCleanupTranslationFiles, "CleaningTranslationFiles".Translate(), doAsynchronously: true, null);
                            }, destructive: true);
                            dialog_MessageBox.buttonAText = "ConfirmCleanupTranslationFiles_Confirm".Translate();
                            Find.WindowStack.Add(dialog_MessageBox);
                        }
                    }, null, doAsynchronously: false, null);
                }
            }
        }
        public override void DoWindowContents(Rect selectorInner)
        {
            Profiler.BeginSample("PackageEditorOnGUI");
            Text.Font = GameFont.Tiny;
            float  width = (selectorInner.width - 4f) / 2f;
            Rect   rect  = new Rect(0f, 0f, width, 24f);
            string str   = this.curMod.ToString();

            if (Widgets.ButtonText(rect, "Editing: " + str, true, false, true))
            {
                Messages.Message("Mod changing not implemented - it's always Core for now.", MessageTypeDefOf.RejectInput, false);
            }
            TooltipHandler.TipRegion(rect, "Change the mod being edited.");
            Rect   rect2 = new Rect(rect.xMax + 4f, 0f, width, 24f);
            string label = "No package loaded";

            if (this.curPackage != null)
            {
                label = this.curPackage.fileName;
            }
            if (Widgets.ButtonText(rect2, label, true, false, true))
            {
                Find.WindowStack.Add(new Dialog_PackageSelector(delegate(DefPackage pack)
                {
                    if (pack != this.curPackage)
                    {
                        this.curPackage = pack;
                    }
                }, this.curMod, this.relFolder));
            }
            TooltipHandler.TipRegion(rect2, "Open a Def package for editing.");
            WidgetRow widgetRow = new WidgetRow(0f, 28f, UIDirection.RightThenUp, 99999f, 4f);

            if (widgetRow.ButtonIcon(TexButton.NewFile, "Create a new Def package.", null))
            {
                string     name       = DefPackage.UnusedPackageName(this.relFolder, this.curMod);
                DefPackage defPackage = new DefPackage(name, this.relFolder);
                this.curMod.AddDefPackage(defPackage);
                this.curPackage = defPackage;
            }
            if (this.curPackage != null)
            {
                if (widgetRow.ButtonIcon(TexButton.Save, "Save the current Def package.", null))
                {
                    this.curPackage.SaveIn(this.curMod);
                }
                if (widgetRow.ButtonIcon(TexButton.RenameDev, "Rename the current Def package.", null))
                {
                    Find.WindowStack.Add(new Dialog_RenamePackage(this.curPackage));
                }
            }
            float num   = 56f;
            Rect  rect3 = new Rect(0f, num, selectorInner.width, selectorInner.height - num);
            Rect  rect4 = new Rect(0f, 0f, rect3.width - 16f, this.viewHeight);

            Widgets.DrawMenuSection(rect3);
            Widgets.BeginScrollView(rect3, ref this.scrollPosition, rect4, true);
            Rect rect5 = rect4.ContractedBy(4f);

            rect5.height = 9999f;
            Listing_Standard listing_Standard = new Listing_Standard();

            listing_Standard.Begin(rect5);
            Text.Font = GameFont.Tiny;
            if (this.curPackage == null)
            {
                listing_Standard.Label("(no package open)", -1f, null);
            }
            else
            {
                if (this.curPackage.defs.Count == 0)
                {
                    listing_Standard.Label("(package is empty)", -1f, null);
                }
                else
                {
                    Def deletingDef = null;
                    using (List <Def> .Enumerator enumerator = this.curPackage.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Def def = enumerator.Current;
                            if (listing_Standard.SelectableDef(def.defName, false, delegate
                            {
                                deletingDef = def;
                            }))
                            {
                                bool        flag        = false;
                                WindowStack windowStack = Find.WindowStack;
                                for (int i = 0; i < windowStack.Count; i++)
                                {
                                    EditWindow_DefEditor editWindow_DefEditor = windowStack[i] as EditWindow_DefEditor;
                                    if (editWindow_DefEditor != null && editWindow_DefEditor.def == def)
                                    {
                                        flag = true;
                                    }
                                }
                                if (!flag)
                                {
                                    Find.WindowStack.Add(new EditWindow_DefEditor(def));
                                }
                            }
                        }
                    }
                    if (deletingDef != null)
                    {
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("Really delete Def " + deletingDef.defName + "?", delegate
                        {
                            this.curPackage.RemoveDef(deletingDef);
                        }, true, null));
                    }
                }
                if (listing_Standard.ButtonImage(TexButton.Add, 24f, 24f))
                {
                    Def def2 = Activator.CreateInstance <TNewDef>();
                    def2.defName = "New" + typeof(TNewDef).Name;
                    this.curPackage.AddDef(def2);
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                this.viewHeight = listing_Standard.CurHeight;
            }
            listing_Standard.End();
            Widgets.EndScrollView();
            Profiler.EndSample();
        }
Exemple #5
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() + ")");
                if (ScribeMetaHeaderUtility.lastMode == ScribeMetaHeaderUtility.ScribeHeaderMode.Map)
                {
                    text = "SaveGameIncompatibleWarningText".Translate(new object[]
                    {
                        text3,
                        VersionControl.CurrentVersionString
                    });
                }
                else if (ScribeMetaHeaderUtility.lastMode == ScribeMetaHeaderUtility.ScribeHeaderMode.World)
                {
                    text = "WorldFileVersionMismatch".Translate(new object[]
                    {
                        text3,
                        VersionControl.CurrentVersionString
                    });
                }
                else
                {
                    text = "FileIncompatibleWarning".Translate(new object[]
                    {
                        text3,
                        VersionControl.CurrentVersionString
                    });
                }
            }
            bool   flag = false;
            string text4;
            string text5;

            if (!ScribeMetaHeaderUtility.LoadedModsMatchesActiveMods(out text4, out text5))
            {
                flag = true;
                string text6 = "ModsMismatchWarningText".Translate(new object[]
                {
                    text4,
                    text5
                });
                if (text == null)
                {
                    text = text6;
                }
                else
                {
                    text = text + "\n\n" + text6;
                }
                if (text2 == null)
                {
                    text2 = "ModsMismatchWarningTitle".Translate();
                }
            }
            if (text != null)
            {
                ScribeMetaHeaderUtility.< TryCreateDialogsForVersionMismatchWarnings > c__AnonStorey0 <TryCreateDialogsForVersionMismatchWarnings> c__AnonStorey = new ScribeMetaHeaderUtility.< TryCreateDialogsForVersionMismatchWarnings > c__AnonStorey0();
                ScribeMetaHeaderUtility.< TryCreateDialogsForVersionMismatchWarnings > c__AnonStorey0 arg_152_0 = < TryCreateDialogsForVersionMismatchWarnings > c__AnonStorey;
                string text7 = text;
                string title = text2;
                arg_152_0.dialog = Dialog_MessageBox.CreateConfirmation(text7, confirmedAction, false, title);