Example #1
0
        public bool LoadFile(string path)
        {
            m_log.Write("Parsing " + path);
            if ( !File.Exists(path) )
            {
                m_log.Write("File " + path + " does not exist!");
                Editor.Settings.RecentFiles.Remove(path);
                return false;
            }

            if (Path.GetExtension(path) == ".dungeon")
            {
                m_activeFile = new JsonParser(path).ParseJson<StarboundDungeon>();

                m_log.Write("  Parsing " + ((StarboundDungeon)m_activeFile).Parts.Count + " parts");
                m_activeFile.ReadableParts.AddRange(((StarboundDungeon)m_activeFile).Parts);

                m_log.Write("  Parsing " + ((StarboundDungeon)m_activeFile).Tiles.Count + " brushes");
                m_activeFile.BlockMap.AddRange(((StarboundDungeon)m_activeFile).Tiles);
            }
            else if (Path.GetExtension(path) == ".structure")
            {
                m_activeFile = new JsonParser(path).ParseJson<StarboundShip>();

                m_log.Write("  Parsing " + ((StarboundShip)m_activeFile).Brushes.Count + " brushes");
                m_activeFile.BlockMap.AddRange(((StarboundShip) m_activeFile).Brushes);
            }

            if (m_activeFile == null)
            {
                m_log.Write("Failed to parse " + path);
                return false;
            }

            ActiveFile.FilePath = path;
            ActiveFile.GenerateBrushAndAssetMaps(this);
            ActiveFile.LoadParts(this);

            m_log.Write("Completed parsing " + path);
            Editor.Settings.RecentFiles.Remove(path);
            Editor.Settings.RecentFiles.Insert(0, path);    // Insert the newest element at the beginning
            while (Editor.Settings.RecentFiles.Count > 10)  // Remove last elements over the max number of recent files
                Editor.Settings.RecentFiles.RemoveAt(Editor.Settings.RecentFiles.Count - 1);
            return true;
        }
Example #2
0
 // clean up all resources
 public void CleanUpResource()
 {
     m_activeFile = null;
     BrushMap.Clear();
 }