Example #1
0
        private bool ReadMetadata(string filePath)
        {
            if (!System.IO.Directory.Exists(filePath))
            {
                return(false);
            }
            else
            {
                string[] metaFiles = System.IO.Directory.GetFiles(filePath, "*." + MetaData.Extension);

                if (metaFiles.Length > 0)
                {
                    Metadata = FileUtils.LoadJson <MetaData>(metaFiles[0], false, null);
                }
                else
                {
                    Console.Error.WriteLine("Can't load file {0}, no metadata found", filePath);
                    return(false);
                }

                string[] screenshots = System.IO.Directory.GetFiles(filePath, "*.png");

                if (screenshots.Length > 0)
                {
                    Screenshot = TextureManager.LoadInstanceTexture(screenshots[0], false);
                }

                return(true);
            }
        }
Example #2
0
        public  bool ReadFile(string filePath, bool isCompressed, WorldManager world)
        {
            if(!System.IO.Directory.Exists(filePath))
            {
                return false;
            }
            else
            {
                string[] screenshots = SaveData.GetFilesInDirectory(filePath, false, "png", "png");
                string[] metaFiles = SaveData.GetFilesInDirectory(filePath, isCompressed, "MetaData", GameFile.MetaData.CompressedExtension, GameFile.MetaData.Extension);
                string[] cameraFiles = SaveData.GetFilesInDirectory(filePath, false, "json", "json");

                if(metaFiles.Length > 0)
                {
                    Data.Metadata = new MetaData(metaFiles[0], isCompressed);
                    Data.GameID = Data.Metadata.GameID;
                }
                else
                {
                    return false;
                }

                if(cameraFiles.Length > 0)
                {
                    Data.Camera = FileUtils.LoadJson<OrbitCamera>(cameraFiles[0], false, world);
                }
                else
                {
                    return false;
                }

                string[] chunkDirs = System.IO.Directory.GetDirectories(filePath, "Chunks");

                if(chunkDirs.Length > 0)
                {
                    string chunkDir = chunkDirs[0];

                    string[] chunks = SaveData.GetFilesInDirectory(chunkDir, isCompressed, ChunkFile.CompressedExtension, ChunkFile.Extension);
                    Data.ChunkData = new List<ChunkFile>();
                    foreach(string chunk in chunks)
                    {
                        Data.ChunkData.Add(new ChunkFile(chunk, isCompressed, DwarfGame.COMPRESSED_BINARY_SAVES));
                    }
                }
                else
                {
                    return false;
                }

                if(screenshots.Length > 0)
                {
                    string screenshot = screenshots[0];
                    Data.Screenshot = TextureManager.LoadInstanceTexture(screenshot);
                }

                return true;
            }
        }
Example #3
0
        public bool ReadFile(string filePath)
        {
            var worldFilePath = filePath + System.IO.Path.DirectorySeparatorChar + "world.png";
            var metaFilePath  = filePath + System.IO.Path.DirectorySeparatorChar + "meta.txt";

            Data = FileUtils.LoadJson <OverworldData>(metaFilePath, false);

            var worldTexture = TextureManager.LoadInstanceTexture(worldFilePath, false);

            if (worldTexture != null)
            {
                Data.LoadFromTexture(worldTexture);
            }
            else
            {
                Console.Out.WriteLine("Failed to load overworld texture.");
                return(false);
            }
            return(true);
        }