Exemple #1
0
        public bool Write(StreamWriter writer, Game game)
        {
            var writerText = new SaveWriterTextSection("game", 0);

            game.WriteTo(writerText);

            return(writerText.Write(writer));
        }
Exemple #2
0
        public override SaveWriterText AddSection(string subName, uint subNumber)
        {
            var section = new SaveWriterTextSection(subName, subNumber);

            sections.Add(section);

            return(section);
        }
Exemple #3
0
        /* Generic save/load function that will try to detect the right
         * format on load and save to the best format on write. */
        public bool Save(string path, Game game)
        {
            path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            path = path.ReplaceInvalidPathChars('_');

            var writer = new SaveWriterTextSection("game", 0);

            game.WriteTo(writer);

            try
            {
                bool success = writer.Save(path);

                LastOperationResult = success ? LastOperationStatus.SaveSuccess : LastOperationStatus.SaveFail;

                return(success);
            }
            catch
            {
                LastOperationResult = LastOperationStatus.SaveFail;

                throw;
            }
        }