public static void Load()
 {
     try
     {
         if (_instance == null)
         {
             _instance = new KPrivacyPrefs();
         }
         string path = GetPath();
         if (File.Exists(path))
         {
             string readText = File.ReadAllText(path);
             _instance = YamlIO.Parse <KPrivacyPrefs>(readText, path, null, null);
             if (_instance == null)
             {
                 LogError("Exception while loading privacy prefs:" + path);
                 _instance = new KPrivacyPrefs();
             }
         }
     }
     catch (Exception ex)
     {
         LogError(ex.ToString());
     }
 }
예제 #2
0
        private void UpdateWorldCache(string path, List <YamlIO.Error> errors)
        {
            ListPool <FileHandle, Worlds> .PooledList pooledList = ListPool <FileHandle, Worlds> .Allocate();

            FileSystem.GetFiles(FileSystem.Normalize(System.IO.Path.Combine(path, "worlds")), "*.yaml", pooledList);
            foreach (FileHandle item in pooledList)
            {
                FileHandle world_file = item;
                World      world      = YamlIO.LoadFile <World>(world_file.full_path, delegate(YamlIO.Error error, bool force_log_as_warning)
                {
                    error.file = world_file;
                    errors.Add(error);
                }, null);
                if (world == null)
                {
                    DebugUtil.LogWarningArgs("Failed to load world: ", world_file.full_path);
                }
                else if (!world.skip)
                {
                    world.filePath             = GetWorldName(world_file.full_path);
                    worldCache[world.filePath] = world;
                }
            }
            pooledList.Recycle();
        }
예제 #3
0
파일: Yaml.cs 프로젝트: egladil/oni-mods
        public static List <T> CollectFromYAML <T>(string path)
        {
            List <T> list  = new List <T>();
            var      files = ListPool <FileHandle, Yaml> .Allocate();

            FileSystem.GetFiles(FileSystem.Normalize(path), "*.yaml", files);
            FileSystem.GetFiles(FileSystem.Normalize(path), "*.yml", files);
            var errors = ListPool <YamlIO.Error, Yaml> .Allocate();

            Log.Info($"Loading {files.Count} files from {path}");

            foreach (FileHandle file in files)
            {
                Log.Info($"Loading {file.full_path} files");

                T obj = YamlIO.LoadFile <T>(file.full_path, delegate(YamlIO.Error error, bool force_log_as_warning)
                {
                    errors.Add(error);
                });
                if (obj != null)
                {
                    list.Add(obj);
                }
            }
            files.Recycle();
            if (Global.Instance != null && Global.Instance.modManager != null)
            {
                Global.Instance.modManager.HandleErrors(errors);
            }
            errors.Recycle();
            return(list);
        }
예제 #4
0
        /// <summary>
        /// Loads codex entries from the specified directory.
        /// </summary>
        /// <param name="entries">The location where the data will be placed.</param>
        /// <param name="dir">The directory to load.</param>
        /// <param name="category">The category to assign to each entry thus loaded.</param>
        private static void LoadFromDirectory(ICollection <CodexEntry> entries, string dir,
                                              string category)
        {
            string[] codexFiles = new string[0];
            try {
                // List codex data files in the codex directory
                codexFiles = Directory.GetFiles(dir, CODEX_FILES);
            } catch (UnauthorizedAccessException ex) {
                PUtil.LogExcWarn(ex);
            } catch (IOException ex) {
                PUtil.LogExcWarn(ex);
            }
            var widgetTagMappings = WIDGET_TAG_MAPPINGS?.GetValue(null) as WidgetMappingList;

            if (widgetTagMappings == null)
            {
                PDatabaseUtils.LogDatabaseWarning("Unable to load codex files: no tag mappings found");
            }
            foreach (string str in codexFiles)
            {
                try {
                    string filename   = str;
                    var    codexEntry = YamlIO.LoadFile <CodexEntry>(filename, YamlParseErrorCB,
                                                                     widgetTagMappings);
                    if (codexEntry != null)
                    {
                        codexEntry.category = category;
                        entries.Add(codexEntry);
                    }
                } catch (IOException ex) {
                    PDatabaseUtils.LogDatabaseWarning("Unable to load codex files from {0}:".
                                                      F(dir));
                    PUtil.LogExcWarn(ex);
                }
            }
예제 #5
0
        internal static int CollectElements(string dir, List <ElementLoader.ElementEntry> results)
        {
            if (!Directory.Exists(dir))
            {
                return(0);
            }

            var foundElements = new List <string>();
            var files         = Array.FindAll(Directory.GetFiles(dir), f => PLUtil.PATTERN_YAML.IsMatch(f));

            foreach (var file in files)
            {
                PipLib.Logger.Debug("loading elements from: {0}", file);
                var elementCollection = YamlIO.Parse <ElementEntryExtended.Collection>(File.ReadAllText(file), Klei.FileSystem.FindFileHandle(Path.GetFileName(file)));
                if (elementCollection != null && elementCollection.elements != null)
                {
                    results.AddRange(elementCollection.elements);
                    loadedElements.AddRange(elementCollection.elements);
                    foundElements.AddRange(Array.ConvertAll(elementCollection.elements, e => e.elementId));
                }
            }

            if (foundElements.Count > 0)
            {
                Logger.Info("Loaded {0} element(s) from '{1}': {2}", foundElements.Count, Path.GetDirectoryName(dir), string.Join(",", foundElements.ToArray()));
            }
            return(foundElements.Count);
        }
예제 #6
0
        private void Subscribe(string id, long timestamp, IFileSource file_source)
        {
            string text   = file_source.Read("mod.yaml");
            Header header = (!string.IsNullOrEmpty(text)) ? YamlIO.Parse <Header>(text, file_source.GetRoot() + "\\mod.yaml", null, null) : null;

            if (header == null)
            {
                Header header2 = new Header();
                header2.title       = id;
                header2.description = id;
                header = header2;
            }
            Label label = default(Label);

            label.id = id;
            label.distribution_platform = distribution_platform;
            label.version = id.GetHashCode();
            label.title   = header.title;
            Label label2 = label;
            Mod   mod    = new Mod(label2, header.description, file_source, UI.FRONTEND.MODS.TOOLTIPS.MANAGE_LOCAL_MOD, delegate
            {
                Application.OpenURL("file://" + file_source.GetRoot());
            });

            if (file_source.GetType() == typeof(Directory))
            {
                mod.status = Mod.Status.Installed;
            }
            Global.Instance.modManager.Subscribe(mod, this);
        }
    public static List <ElementEntry> CollectElementsFromYAML()
    {
        List <ElementEntry> list = new List <ElementEntry>();

        ListPool <FileHandle, ElementLoader> .PooledList pooledList = ListPool <FileHandle, ElementLoader> .Allocate();

        FileSystem.GetFiles(FileSystem.Normalize(path), "*.yaml", pooledList);
        ListPool <YamlIO.Error, ElementLoader> .PooledList errors = ListPool <YamlIO.Error, ElementLoader> .Allocate();

        foreach (FileHandle item in pooledList)
        {
            FileHandle             file = item;
            ElementEntryCollection elementEntryCollection = YamlIO.LoadFile <ElementEntryCollection>(file.full_path, delegate(YamlIO.Error error, bool force_log_as_warning)
            {
                error.file = file;
                errors.Add(error);
            }, null);
            if (elementEntryCollection != null)
            {
                list.AddRange(elementEntryCollection.elements);
            }
        }
        pooledList.Recycle();
        if ((UnityEngine.Object)Global.Instance != (UnityEngine.Object)null && Global.Instance.modManager != null)
        {
            Global.Instance.modManager.HandleErrors(errors);
        }
        errors.Recycle();
        return(list);
    }
예제 #8
0
    public static NoiseNodeCanvas CreateInstance()
    {
        NoiseNodeCanvas noiseNodeCanvas = ScriptableObject.CreateInstance <NoiseNodeCanvas>();

        noiseNodeCanvas.ntf = YamlIO.LoadFile <NoiseTreeFiles>(NoiseTreeFiles.GetPath(), null, null);
        return(noiseNodeCanvas);
    }
        private static string LoadFeature(string longName, List <YamlIO.Error> errors)
        {
            string name = string.Empty;

            if (!GetPathAndName(GetPath(), longName, out name))
            {
                Debug.LogWarning("LoadFeature GetPathAndName: Attempting to load feature: " + name + " failed");
                return(longName);
            }
            if (!featuresettings.ContainsKey(name))
            {
                FeatureSettings featureSettings = YamlIO.LoadFile <FeatureSettings>(GetPath() + name + ".yaml", null, null);
                if (featureSettings != null)
                {
                    featuresettings.Add(name, featureSettings);
                    if (featureSettings.forceBiome != null)
                    {
                        LoadBiome(featureSettings.forceBiome, errors);
                        DebugUtil.Assert(biomes.BiomeBackgroundElementBandConfigurations.ContainsKey(featureSettings.forceBiome), longName, "(feature) referenced a missing biome named", featureSettings.forceBiome);
                    }
                }
                else
                {
                    Debug.LogWarning("WorldGen: Attempting to load feature: " + name + " failed");
                }
            }
            return(name);
        }
예제 #10
0
            private static void Postfix(ref List <ElementLoader.ElementEntry> __result)
            {
                Strings.Add($"STRINGS.ELEMENTS.{CorundumElement.Id.ToUpper()}.NAME", CorundumElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{CorundumElement.Id.ToUpper()}.DESC", CorundumElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{KyaniteElement.Id.ToUpper()}.NAME", KyaniteElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{KyaniteElement.Id.ToUpper()}.DESC", KyaniteElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{SodaliteElement.Id.ToUpper()}.NAME", SodaliteElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{SodaliteElement.Id.ToUpper()}.DESC", SodaliteElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{PolishedCorundumElement.Id.ToUpper()}.NAME", PolishedCorundumElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{PolishedCorundumElement.Id.ToUpper()}.DESC", PolishedCorundumElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{PolishedKyaniteElement.Id.ToUpper()}.NAME", PolishedKyaniteElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{PolishedKyaniteElement.Id.ToUpper()}.DESC", PolishedKyaniteElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{PolishedSodaliteElement.Id.ToUpper()}.NAME", PolishedSodaliteElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{PolishedSodaliteElement.Id.ToUpper()}.DESC", PolishedSodaliteElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{AluminumSaltElement.Id.ToUpper()}.NAME", AluminumSaltElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{AluminumSaltElement.Id.ToUpper()}.DESC", AluminumSaltElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{MineralWaterElement.Id.ToUpper()}.NAME", MineralWaterElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{MineralWaterElement.Id.ToUpper()}.DESC", MineralWaterElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{MineralIceElement.Id.ToUpper()}.NAME", MineralIceElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{MineralIceElement.Id.ToUpper()}.DESC", MineralIceElement.Description);
                Strings.Add($"STRINGS.ELEMENTS.{CrystalElement.Id.ToUpper()}.NAME", CrystalElement.Name);
                Strings.Add($"STRINGS.ELEMENTS.{CrystalElement.Id.ToUpper()}.DESC", CrystalElement.Description);

                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(CorundumElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(KyaniteElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(SodaliteElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(PolishedCorundumElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(PolishedKyaniteElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(PolishedSodaliteElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(AluminumSaltElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(MineralWaterElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(MineralIceElement.Data, null).elements);
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(CrystalElement.Data, null).elements);
            }
예제 #11
0
    public static List <SubEntry> CollectSubEntries(string folder)
    {
        List <SubEntry> list = new List <SubEntry>();
        string          path = (!(folder == string.Empty)) ? Path.Combine(baseEntryPath, folder) : baseEntryPath;

        string[] array = new string[0];
        try
        {
            array = Directory.GetFiles(path, "*.yaml", SearchOption.AllDirectories);
        }
        catch (UnauthorizedAccessException obj)
        {
            Debug.LogWarning(obj);
        }
        string[] array2 = array;
        foreach (string text in array2)
        {
            try
            {
                SubEntry subEntry = YamlIO.LoadFile <SubEntry>(text, YamlParseErrorCB, widgetTagMappings);
                if (subEntry != null)
                {
                    list.Add(subEntry);
                }
            }
            catch (Exception ex)
            {
                DebugUtil.DevLogErrorFormat("CodexCache.CollectSubEntries failed to load [{0}]: {1}", text, ex.ToString());
            }
        }
        list.Sort((SubEntry x, SubEntry y) => x.title.CompareTo(y.title));
        return(list);
    }
예제 #12
0
        public static T LoadConfig <T>(string file = "config.yaml") where T : new()
        {
            var directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (directoryName != null)
            {
                var directoryInfo = new DirectoryInfo(directoryName);
                var config        = Path.Combine(directoryName, file);
                Debug.Log(config);

                var fileInfo = new FileInfo(config);

                if (!fileInfo.Exists)
                {
                    var cfg = new T();
                    YamlIO.Save(cfg, config);
                    return(cfg);
                }

                return(YamlIO.LoadFile <T>(config,
                                           delegate(YamlIO.Error error, bool warning) { Debug.Log($"ERROR - {error}"); }));
            }

            return(new T());
        }
        public static bool LoadFiles(List <YamlIO.Error> errors)
        {
            if (worlds.worldCache.Count > 0)
            {
                return(false);
            }
            worlds.LoadFiles(GetPath(), errors);
            List <FileHandle> list = new List <FileHandle>();

            FileSystem.GetFiles(FileSystem.Normalize(System.IO.Path.Combine(path, "traits")), "*.yaml", list);
            foreach (FileHandle item in list)
            {
                FileHandle trait_file = item;
                WorldTrait worldTrait = YamlIO.LoadFile <WorldTrait>(trait_file.full_path, delegate(YamlIO.Error error, bool force_log_as_warning)
                {
                    error.file = trait_file;
                    errors.Add(error);
                }, null);
                int    num  = FirstUncommonCharacter(path, trait_file.full_path);
                string text = (num <= -1) ? trait_file.full_path : trait_file.full_path.Substring(num);
                text = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(text), System.IO.Path.GetFileNameWithoutExtension(text));
                if (worldTrait == null)
                {
                    DebugUtil.LogWarningArgs("Failed to load trait: ", text);
                }
                else
                {
                    traits[text] = worldTrait;
                }
            }
            foreach (KeyValuePair <string, World> item2 in worlds.worldCache)
            {
                LoadFeatures(item2.Value.globalFeatures, errors);
                LoadSubworlds(item2.Value.subworldFiles, errors);
            }
            foreach (KeyValuePair <string, WorldTrait> trait in traits)
            {
                LoadFeatures(trait.Value.globalFeatureMods, errors);
                LoadSubworlds(trait.Value.additionalSubworldFiles, errors);
            }
            layers = MergeLoad <LevelLayerSettings>(GetPath() + "layers.yaml", errors);
            layers.LevelLayers.ConvertBandSizeToMaxSize();
            rivers = MergeLoad <ComposableDictionary <string, River> >(GetPath() + "rivers.yaml", errors);
            rooms  = MergeLoad <ComposableDictionary <string, Room> >(path + "rooms.yaml", errors);
            foreach (KeyValuePair <string, Room> room in rooms)
            {
                room.Value.name = room.Key;
            }
            temperatures = MergeLoad <ComposableDictionary <Temperature.Range, Temperature> >(GetPath() + "temperatures.yaml", errors);
            borders      = MergeLoad <ComposableDictionary <string, List <WeightedSimHash> > >(GetPath() + "borders.yaml", errors);
            defaults     = YamlIO.LoadFile <DefaultSettings>(GetPath() + "defaults.yaml", null, null);
            mobs         = MergeLoad <MobSettings>(GetPath() + "mobs.yaml", errors);
            foreach (KeyValuePair <string, Mob> item3 in mobs.MobLookupTable)
            {
                item3.Value.name = item3.Key;
            }
            DebugUtil.LogArgs("World settings reload complete!");
            return(true);
        }
예제 #14
0
        public static void Set(PublishedFileId_t item, System.DateTime lastModified)
        {
            InstalledLanguageData installedLanguageData = new InstalledLanguageData();

            installedLanguageData.PublishedFileId = item.m_PublishedFileId;
            installedLanguageData.LastModified    = lastModified.ToFileTimeUtc();
            YamlIO.Save(installedLanguageData, FilePath(), null);
        }
 public static void Save(string path)
 {
     YamlIO.Save(layers, path + "layers.yaml", null);
     YamlIO.Save(rivers, path + "rivers.yaml", null);
     YamlIO.Save(rooms, path + "rooms.yaml", null);
     YamlIO.Save(temperatures, path + "temperatures.yaml", null);
     YamlIO.Save(borders, path + "borders.yaml", null);
     YamlIO.Save(defaults, path + "defaults.yaml", null);
     YamlIO.Save(mobs, path + "mobs.yaml", null);
 }
예제 #16
0
 public static void Save()
 {
     try
     {
         YamlIO.Save(instance, PATH, null);
     }
     catch (Exception ex)
     {
         Debug.LogWarning("Failed to save kplayerprefs: " + ex.ToString());
     }
 }
예제 #17
0
            public static void Postfix(ref List <ElementLoader.ElementEntry> __result)
            {
                Strings.Add($"STRINGS.ELEMENTS.{ToUpperSnakeCase(Antigel.Id)}.NAME", Antigel.Name);
                Strings.Add($"STRINGS.ELEMENTS.{ToUpperSnakeCase(Antigel.Id)}.DESC", Antigel.Description);

                FileHandle nullFile = new FileHandle();

                nullFile.full_path = null;
                nullFile.source    = null;
                __result.AddRange(YamlIO.Parse <ElementLoader.ElementEntryCollection>(Antigel.Data, nullFile).elements);
            }
 public void LoadAllTrees()
 {
     for (int i = 0; i < tree_files.Count; i++)
     {
         Tree tree = YamlIO.LoadFile <Tree>(GetTreeFilePath(tree_files[i]), null, null);
         if (tree != null)
         {
             trees.Add(tree_files[i], tree);
         }
     }
 }
예제 #19
0
 public void Save()
 {
     Debug.Log("Saving Endpoint state: " + ToString());
     try
     {
         YamlIO.Save <EndpointState>(this, Filename());
     }
     catch (Exception ex)
     {
         Debug.LogWarning("Failed to save endpoint_state.yml: " + ex.ToString());
     }
 }
예제 #20
0
            static void Postfix(ref List <ElementLoader.ElementEntry> __result)
            {
                var containsIron = $"Contains traces of {STRINGS.UI.FormatAsLink("cyanide", "IRON")}.";//to add cyanide later

                Strings.Add("STRINGS.ELEMENTS." + ToxicWaterElement.ID.ToUpper() + ".NAME", STRINGS.UI.FormatAsLink("Toxic water", ToxicWaterElement.ID.ToUpper()));
                Strings.Add("STRINGS.ELEMENTS." + ToxicWaterElement.ID.ToUpper() + ".DESC", $"Water preserved from a long time. {containsIron}");
                Strings.Add("STRINGS.ELEMENTS." + ToxicWaterElement.IDFrozen.ToUpper() + ".NAME", STRINGS.UI.FormatAsLink("Toxic ice", ToxicWaterElement.IDFrozen.ToUpper()));
                Strings.Add("STRINGS.ELEMENTS." + ToxicWaterElement.IDFrozen.ToUpper() + ".DESC", $"Frozen toxic water. {containsIron}");

                var elementCollection = YamlIO.Parse <ElementLoader.ElementEntryCollection>(ToxicWaterElement.CONFIG, "ElementLoader.cs");

                __result.AddRange(elementCollection.elements);
            }
예제 #21
0
        static void Postfix(ref List <ElementLoader.ElementEntry> __result)
        {
            var containsIron = $"Contains traces of {STRINGS.UI.FormatAsLink("iron", "IRON")}.";

            Strings.Add("STRINGS.ELEMENTS.BLOOD.NAME", STRINGS.UI.FormatAsLink("Blood", "BLOOD"));
            Strings.Add("STRINGS.ELEMENTS.BLOOD.DESC", $"Bathe in the blood of your enemies! {containsIron}");
            Strings.Add("STRINGS.ELEMENTS.FROZENBLOOD.NAME", STRINGS.UI.FormatAsLink("Frozen Blood", "FROZENBLOOD"));
            Strings.Add("STRINGS.ELEMENTS.FROZENBLOOD.DESC", $"Blood that has been frozen. {containsIron}");

            var elementCollection = YamlIO.Parse <ElementLoader.ElementEntryCollection>(BloodElement.CONFIG, new FileHandle());

            __result.AddRange(elementCollection.elements);
        }
 public Tree GetTree(string name, string path)
 {
     if (!trees.ContainsKey(name))
     {
         Tree tree = YamlIO.LoadFile <Tree>(path + "/" + name + ".yaml", null, null);
         if (tree == null)
         {
             return(null);
         }
         trees.Add(name, tree);
     }
     return(trees[name]);
 }
예제 #23
0
 public static void Get(out PublishedFileId_t item, out System.DateTime lastModified)
 {
     if (Exists())
     {
         InstalledLanguageData installedLanguageData = YamlIO.LoadFile <InstalledLanguageData>(FilePath(), null, null);
         if (installedLanguageData != null)
         {
             lastModified = System.DateTime.FromFileTimeUtc(installedLanguageData.LastModified);
             item         = new PublishedFileId_t(installedLanguageData.PublishedFileId);
             return;
         }
     }
     lastModified = System.DateTime.MinValue;
     item         = PublishedFileId_t.Invalid;
 }
 public static void Save()
 {
     try
     {
         if (!Directory.Exists(GetDirectory()))
         {
             Directory.CreateDirectory(GetDirectory());
         }
         YamlIO.Save(instance, GetPath(), null);
     }
     catch (Exception ex)
     {
         LogError(ex.ToString());
     }
 }
 public Tree LoadTree(string name, string path)
 {
     if (name != null && name.Length > 0)
     {
         if (!trees.ContainsKey(name))
         {
             Tree tree = YamlIO.LoadFile <Tree>(path + name + ".yaml", null, null);
             if (tree != null)
             {
                 trees.Add(name, tree);
             }
         }
         return(trees[name]);
     }
     return(null);
 }
예제 #26
0
    private NodeCanvas Load(string name, CompleteLoadCallback onComplete)
    {
        NodeCanvas nodeCanvas   = null;
        string     treeFilePath = NoiseTreeFiles.GetTreeFilePath(name);
        Tree       tree         = YamlIO.LoadFile <Tree>(treeFilePath, null, null);

        if (tree != null)
        {
            if (tree.settings.name == null || tree.settings.name == string.Empty)
            {
                tree.settings.name = name;
            }
            nodeCanvas = PopulateNoiseNodeEditor(tree);
        }
        onComplete(name, nodeCanvas);
        return(nodeCanvas);
    }
예제 #27
0
        public void HandleErrors(List <YamlIO.Error> world_gen_errors)
        {
            string value = FileSystem.Normalize(GetDirectory());

            ListPool <Mod, Manager> .PooledList pooledList = ListPool <Mod, Manager> .Allocate();

            foreach (YamlIO.Error world_gen_error in world_gen_errors)
            {
                YamlIO.Error current = world_gen_error;
                string       text    = (current.file.source == null) ? string.Empty : FileSystem.Normalize(current.file.source.GetRoot());
                YamlIO.LogError(current, text.Contains(value));
                if (current.severity != YamlIO.Error.Severity.Recoverable && text.Contains(value))
                {
                    foreach (Mod mod in mods)
                    {
                        if (mod.enabled && text.Contains(mod.label.install_path))
                        {
                            events.Add(new Event
                            {
                                event_type = EventType.BadWorldGen,
                                mod        = mod.label,
                                details    = Path.GetFileName(current.file.full_path)
                            });
                            break;
                        }
                    }
                }
            }
            bool flag = IsInDevMode();

            foreach (Mod item in pooledList)
            {
                item.Crash(!flag);
                if (!flag)
                {
                    events.Add(new Event
                    {
                        event_type = EventType.Deactivated,
                        mod        = item.label
                    });
                }
                dirty = true;
            }
            pooledList.Recycle();
            Update(this);
        }
    private static void AddWorldMods(object user_data, List <SettingLevel> levels)
    {
        string path = FileSystem.Normalize(System.IO.Path.Combine(SettingsCache.GetPath(), "worlds"));

        ListPool <string, CustomGameSettings> .PooledList pooledList = ListPool <string, CustomGameSettings> .Allocate();

        FileSystem.GetFiles(path, "*.yaml", pooledList);
        foreach (string item in pooledList)
        {
            ProcGen.World world       = YamlIO.LoadFile <ProcGen.World>(item, null, null);
            string        worldName   = Worlds.GetWorldName(item);
            string        id          = worldName;
            string        name        = world.name;
            string        description = world.description;
            levels.Add(new SettingLevel(id, name, description, 0, user_data));
        }
        pooledList.Recycle();
    }
예제 #29
0
 public static CodexEntry GetTemplate(string templatePath)
 {
     if (!entries.ContainsKey(templatePath))
     {
         entries.Add(templatePath, null);
     }
     if (entries[templatePath] == null)
     {
         string     text       = Path.Combine(baseEntryPath, templatePath);
         CodexEntry codexEntry = YamlIO.LoadFile <CodexEntry>(text + ".yaml", null, widgetTagMappings);
         if (codexEntry == null)
         {
             Debug.LogWarning("Missing template [" + text + ".yaml]");
         }
         entries[templatePath] = codexEntry;
     }
     return(entries[templatePath]);
 }
예제 #30
0
    public static List <CodexEntry> CollectEntries(string folder)
    {
        List <CodexEntry> list = new List <CodexEntry>();
        string            path = (!(folder == string.Empty)) ? Path.Combine(baseEntryPath, folder) : baseEntryPath;

        string[] array = new string[0];
        try
        {
            array = Directory.GetFiles(path, "*.yaml");
        }
        catch (UnauthorizedAccessException obj)
        {
            Debug.LogWarning(obj);
        }
        string category = folder.ToUpper();

        string[] array2 = array;
        foreach (string text in array2)
        {
            try
            {
                CodexEntry codexEntry = YamlIO.LoadFile <CodexEntry>(text, YamlParseErrorCB, widgetTagMappings);
                if (codexEntry != null)
                {
                    codexEntry.category = category;
                    list.Add(codexEntry);
                }
            }
            catch (Exception ex)
            {
                DebugUtil.DevLogErrorFormat("CodexCache.CollectEntries failed to load [{0}]: {1}", text, ex.ToString());
            }
        }
        foreach (CodexEntry item in list)
        {
            if (string.IsNullOrEmpty(item.sortString))
            {
                item.sortString = Strings.Get(item.title);
            }
        }
        list.Sort((CodexEntry x, CodexEntry y) => x.sortString.CompareTo(y.sortString));
        return(list);
    }