private void ImportListButton_Click(object sender, EventArgs e) { Windows.SelectFilePopup popup = new Windows.SelectFilePopup(); popup.Center(); popup.Closed += (s, e2) => { if (popup.DialogResult) { var editor = (Editors.SceneEditor)MainScreen.Instance.ActiveEditor; Dictionary <string, Hotspot> titleKeys = new Dictionary <string, Hotspot>(); List <Hotspot> loadedSpots = (List <Hotspot>)popup.SelectedLoader.Load(popup.SelectedFile); var titleCount = loadedSpots.Select(h => h.Title).Intersect(editor.Hotspots.Select(h => h.Title)).Count(); if (titleCount != 0) { titleKeys = editor.Hotspots.ToDictionary((h) => h.Title, (h) => h); Window.Prompt(new ColoredString($"{titleCount} will be overwritten, continue?"), "Yes", "No", (result) => { if (result) { RunImportLogic(loadedSpots, titleKeys); } }); } else { RunImportLogic(loadedSpots, titleKeys); } } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Hotspots() }; popup.Show(true); }
public void Save() { var popup = new Windows.SelectFilePopup(); popup.Center(); popup.SkipFileExistCheck = true; popup.Closed += (s, e) => { if (popup.DialogResult) { Scene scene = new Scene(surface, new LayeredSurfaceRenderer()); scene.Objects = Objects.Select(g => g.GameObject).ToList(); scene.Zones = new List <Zone>( this.Zones.Select( z => new Zone() { Area = new Rectangle(z.GameObject.Position.X, z.GameObject.Position.Y, z.GameObject.Animation.Width, z.GameObject.Animation.Height), DebugAppearance = new Cell(Color.White, z.GameObject.Animation.Cells[0].Background, 0), Title = z.GameObject.Name })); scene.Hotspots = this.Hotspots; popup.SelectedLoader.Save(scene, popup.SelectedFile); } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Scene() }; popup.SelectButtonText = "Save"; popup.Show(true); }
void _exportListButton_Click(object sender, EventArgs e) { var editor = (Editors.SceneEditor)MainScreen.Instance.ActiveEditor; if (editor.Hotspots.Count == 0) { return; } Windows.SelectFilePopup popup = new Windows.SelectFilePopup(); popup.Center(); popup.Closed += (s, e2) => { if (popup.DialogResult) { List <Hotspot> clonedSpots = new List <Hotspot>(editor.Hotspots.Count); foreach (var spot in editor.Hotspots) { Hotspot newSpot = new Hotspot(); newSpot.Title = spot.Title; spot.DebugAppearance.CopyAppearanceTo(newSpot.DebugAppearance); newSpot.Settings = new Dictionary <string, string>(spot.Settings); clonedSpots.Add(newSpot); } popup.SelectedLoader.Save(clonedSpots, popup.SelectedFile); } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Hotspots() }; popup.SkipFileExistCheck = true; popup.SelectButtonText = "Save"; popup.Show(true); }
public void Save() { var popup = new Windows.SelectFilePopup(); popup.Center(); popup.SkipFileExistCheck = true; popup.Closed += (s, e) => { if (popup.DialogResult) { popup.SelectedLoader.Save(gameObject, popup.SelectedFile); } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.GameObject() }; popup.SelectButtonText = "Save"; popup.Show(true); }
public void Save() { var popup = new Windows.SelectFilePopup(); popup.Center(); popup.SkipFileExistCheck = true; popup.Closed += (s, e) => { if (popup.DialogResult) { SadConsole.Game.Scene scene = new Scene(textSurface); scene.Objects = new GameObjectCollection(this.Objects.Select(g => g.GameObject).ToArray()); scene.Zones = new List<Zone>( this.Zones.Select( z => new Zone() { Area = new Rectangle(z.GameObject.Position.X, z.GameObject.Position.Y, z.GameObject.Width, z.GameObject.Height), DebugAppearance = new CellAppearance(Color.White, z.GameObject.RenderCells[0].Background, 0), Title = z.GameObject.Name })); scene.Hotspots = this.Hotspots; popup.SelectedLoader.Save(scene, popup.SelectedFile); } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Scene() }; popup.SelectButtonText = "Save"; popup.Show(true); }
public void Save() { var popup = new Windows.SelectFilePopup(); popup.Center(); popup.SkipFileExistCheck = true; popup.Closed += (s, e) => { if (popup.DialogResult) popup.SelectedLoader.Save(textSurface, popup.SelectedFile); }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.LayeredTextSurface() }; popup.SelectButtonText = "Save"; popup.Show(true); }
void _exportListButton_ButtonClicked(object sender, EventArgs e) { var editor = (Editors.SceneEditor)EditorConsoleManager.ActiveEditor; if (editor.Hotspots.Count == 0) return; Windows.SelectFilePopup popup = new Windows.SelectFilePopup(); popup.Center(); popup.Closed += (s, e2) => { if (popup.DialogResult) { List<Hotspot> clonedSpots = new List<Hotspot>(editor.Hotspots.Count); foreach (var spot in editor.Hotspots) { Hotspot newSpot = new Hotspot(); newSpot.Title = spot.Title; spot.DebugAppearance.CopyAppearanceTo(newSpot.DebugAppearance); newSpot.Settings = new Dictionary<string, string>(spot.Settings); clonedSpots.Add(newSpot); } popup.SelectedLoader.Save(clonedSpots, popup.SelectedFile); } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Hotspots() }; popup.SkipFileExistCheck = true; popup.SelectButtonText = "Save"; popup.Show(true); }
private void ImportListButton_ButtonClicked(object sender, EventArgs e) { Windows.SelectFilePopup popup = new Windows.SelectFilePopup(); popup.Center(); popup.Closed += (s, e2) => { if (popup.DialogResult) { var editor = (Editors.SceneEditor)EditorConsoleManager.ActiveEditor; Dictionary<string, Hotspot> titleKeys = new Dictionary<string, Hotspot>(); List<Hotspot> loadedSpots = (List<Hotspot>)popup.SelectedLoader.Load(popup.SelectedFile); var titleCount = loadedSpots.Select(h => h.Title).Intersect(editor.Hotspots.Select(h => h.Title)).Count(); if (titleCount != 0) { titleKeys = editor.Hotspots.ToDictionary((h) => h.Title, (h) => h); Window.Prompt(new ColoredString($"{titleCount} will be overwritten, continue?"), "Yes", "No", (result) => { if (result) RunImportLogic(loadedSpots, titleKeys); }); } else RunImportLogic(loadedSpots, titleKeys); } }; popup.FileLoaderTypes = new FileLoaders.IFileLoader[] { new FileLoaders.Hotspots() }; popup.Show(true); }