Exemple #1
0
        public void SaveDocument()
        {
            if (!CurrentDocument.HasFilename)
            {
                throw new Exception("No filepath set for document yet.");
            }

            ProtobufSaver.SaveDocument(CurrentDocument);
            ExportSceneSpritesheet();
            CurrentDocument.MarkSaved();
            _messageBus.Publish(new CurrentDocumentSaved());
        }
Exemple #2
0
        private static void SaveData(string filename, Spritesheet spritesheet)
        {
            var protoSpritesheet = new Persistence.Spritesheet
            {
                Width  = (uint)spritesheet.Width,
                Height = (uint)spritesheet.Height
            };

            foreach (var sprite in spritesheet.Sprites)
            {
                var spriteInfo = (SpriteInfo)sprite.Sprite.Reference;
                protoSpritesheet.Sprites.Add(new Persistence.Sprite
                {
                    Key    = spriteInfo.Key,
                    X      = (uint)sprite.X,
                    Y      = (uint)sprite.Y,
                    Width  = (uint)sprite.Sprite.Width,
                    Height = (uint)sprite.Sprite.Height
                });
            }

            ProtobufSaver.Save(protoSpritesheet, filename);
        }