コード例 #1
0
        /// <summary>Saves the strings for the selected entities into a new file.</summary>
        /// <param name="parts">The parts to export the strings from.</param>
        /// <param name="assemblies">The mod assemblies to export teh strinsg from.</param>
        void GuiActionExportStrings(IEnumerable <PartsRecord> parts,
                                    IEnumerable <AssemblyRecord> assemblies)
        {
            var partsLocs = parts
                            .SelectMany(x => x.parts)
                            .Select(Extractor.EmitItemsForPart)
                            .SelectMany(x => x)
                            .ToList();
            var modulesLocs = assemblies
                              .SelectMany(x => x.assembly.GetTypes())
                              .Select(Extractor.EmitItemsForType)
                              .SelectMany(x => x)
                              .ToList();

            Debug.LogWarningFormat("Export {0} parts strings and {1} modules strings",
                                   partsLocs.Count, modulesLocs.Count);
            var locItems = partsLocs.Union(modulesLocs);
            var fileName = "strings.cfg";

            if (assemblies.Count() == 1)
            {
                fileName = assemblies.First().assembly.GetName().Name + "_" + fileName;
            }
            var filePath = KspPaths.GetModsDataFilePath(this, "Lang/" + fileName);

            Directory.CreateDirectory(Path.GetDirectoryName(filePath));
            ConfigStore.WriteLocItems(locItems, Localizer.CurrentLanguage, filePath);
            Debug.LogWarningFormat("Strings are written into: {0}", filePath);
            ShowCompletionDialog(StringsExportedDlgTitle, FileSavedTxt.Format(filePath));
        }
コード例 #2
0
        /// <summary>Saves the strings for the selected entities into a new file.</summary>
        /// <param name="parts">The parts to export the strings from.</param>
        /// <param name="assemblies">The mod assemblies to export teh strinsg from.</param>
        void GuiActionExportStrings(IEnumerable <PartsRecord> parts,
                                    IEnumerable <AssemblyRecord> assemblies)
        {
            var partsLocs = parts
                            .SelectMany(x => x.parts)
                            .Select(Extractor.EmitItemsForPart)
                            .SelectMany(x => x)
                            .ToList();
            var modulesLocs = assemblies
                              .SelectMany(x => x.assembly.GetTypes())
                              .Select(Extractor.EmitItemsForType)
                              .SelectMany(x => x)
                              .ToList();

            Debug.LogWarningFormat("Export {0} parts strings and {1} modules strings",
                                   partsLocs.Count, modulesLocs.Count);
            var locItems = partsLocs.Union(modulesLocs);
            var filename = KspPaths.GetModsDataFilePath(this, "export.cfg", createMissingDirs: true);

            ConfigStore.WriteLocItems(locItems, Localizer.CurrentLanguage, filename);
            Debug.LogWarningFormat("Strings are written into: {0}", filename);
        }