Exemplo n.º 1
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());
        }
Exemplo n.º 2
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);
 }
Exemplo n.º 4
0
 public static void Save()
 {
     try
     {
         YamlIO.Save(instance, PATH, null);
     }
     catch (Exception ex)
     {
         Debug.LogWarning("Failed to save kplayerprefs: " + ex.ToString());
     }
 }
Exemplo n.º 5
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());
     }
 }
 public static void Save()
 {
     try
     {
         if (!Directory.Exists(GetDirectory()))
         {
             Directory.CreateDirectory(GetDirectory());
         }
         YamlIO.Save(instance, GetPath(), null);
     }
     catch (Exception ex)
     {
         LogError(ex.ToString());
     }
 }
Exemplo n.º 7
0
 public override void AdditionalSaveMethods(string sceneCanvasName, CompleteLoadCallback onComplete)
 {
     GUILayout.BeginHorizontal();
     if (GUILayout.Button(new GUIContent("Load Yaml", "Loads the Canvas from a Yaml Save File")))
     {
         Load(sceneCanvasName, onComplete);
     }
     if (GUILayout.Button(new GUIContent("Save to Yaml", "Saves the Canvas to a Yaml file"), GUILayout.ExpandWidth(false)))
     {
         BeforeSavingCanvas();
         Tree tree = BuildTreeFromCanvas();
         if (tree != null)
         {
             tree.ClearEmptyLists();
             string treeFilePath = NoiseTreeFiles.GetTreeFilePath(sceneCanvasName);
             YamlIO.Save(tree, treeFilePath, null);
         }
     }
     GUILayout.EndHorizontal();
     if (ntf == null)
     {
         ntf = YamlIO.LoadFile <NoiseTreeFiles>(NoiseTreeFiles.GetPath(), null, null);
     }
     if (ntf != null && GUILayout.Button(new GUIContent("Load Tree", "Loads the Canvas from Trees list")))
     {
         GenericMenu genericMenu = new GenericMenu();
         foreach (string tree_file in ntf.tree_files)
         {
             genericMenu.AddItem(new GUIContent(tree_file), false, delegate(object fileName)
             {
                 Load((string)fileName, onComplete);
             }, tree_file);
         }
         genericMenu.Show(lastRectPos.position, 40f);
     }
     if (Event.current.type == EventType.Repaint)
     {
         Rect lastRect = GUILayoutUtility.GetLastRect();
         lastRectPos = new Rect(lastRect.x + 2f, lastRect.yMax + 2f, lastRect.width - 4f, 0f);
     }
 }