Exemplo n.º 1
0
        public void Enter(Console console, string filepath)
        {
            var Width  = console.Width;
            var Height = console.Height;

            if (File.Exists(filepath))
            {
                try {
                    var sprite = ASECIILoader.DeserializeObject <SpriteModel>(File.ReadAllText(filepath));

                    if (sprite.filepath != filepath)
                    {
                        sprite.filepath = filepath;
                        File.WriteAllText($"{filepath}", ASECIILoader.SerializeObject(sprite));
                    }

                    sprite.OnLoad();
                    Game.Instance.Screen = new EditorMain(Width, Height, sprite);

                    Program.SaveState(new EditorState(filepath));
                } catch {
                    throw;
                }
            }
            else
            {
                var model = new SpriteModel(Width, Height)
                {
                    filepath = filepath
                };
                model.sprite.layers.Add(new Layer());

                File.WriteAllText(filepath, ASECIILoader.SerializeObject(model));
                console.Children.Add(new EditorMain(Width, Height, model));
            }
        }
Exemplo n.º 2
0
 public void AddRecentFile(string s)
 {
     recentFiles.Add(s);
     File.WriteAllText(RECENTFILES, ASECIILoader.SerializeObject(recentFiles));
 }