public void Load(string file, FileLoaders.IFileLoader loader) { ClearEntities(); ClearZones(); ClearHotspots(); if (loader is FileLoaders.Scene) { var scene = (SadConsole.GameHelpers.Scene)loader.Load(file); surface = (LayeredSurface)scene.Surface.TextSurface; int renderWidth = Math.Min(MainScreen.Instance.InnerEmptyBounds.Width, surface.Width); int renderHeight = Math.Min(MainScreen.Instance.InnerEmptyBounds.Height, surface.Height); surface.RenderArea = new Rectangle(0, 0, renderWidth, renderHeight); hotspotSurface = new BasicSurface(renderWidth, renderHeight, Settings.Config.ScreenFont); foreach (var item in scene.Objects) { LoadEntity(item); } foreach (var zone in scene.Zones) { LoadZone(zone); } foreach (var spot in scene.Hotspots) { LoadHotspot(spot); } } surface.Font = Settings.Config.ScreenFont; Title = Path.GetFileName(file); }
public void Resize(int width, int height) { int renderWidth = Math.Min(MainScreen.Instance.InnerEmptyBounds.Width, width); int renderHeight = Math.Min(MainScreen.Instance.InnerEmptyBounds.Height, height); var oldSurface = surface; var newSurface = new LayeredSurface(width, height, Settings.Config.ScreenFont, new Rectangle(0, 0, renderWidth, renderHeight), oldSurface.LayerCount); hotspotSurface = new BasicSurface(renderWidth, renderHeight, Settings.Config.ScreenFont); for (int i = 0; i < oldSurface.LayerCount; i++) { var oldLayer = oldSurface.GetLayer(i); var newLayer = newSurface.GetLayer(i); oldSurface.SetActiveLayer(i); newSurface.SetActiveLayer(i); oldSurface.Copy(newSurface); newLayer.Metadata = oldLayer.Metadata; newLayer.IsVisible = oldLayer.IsVisible; } surface = newSurface; layerManagementPanel.SetLayeredSurface(surface); toolsPanel.SelectedTool = toolsPanel.SelectedTool; if (MainScreen.Instance.ActiveEditor == this) { MainScreen.Instance.RefreshBorder(); } }
public void New(Color foreground, Color background, int width, int height) { int renderWidth = Math.Min(MainScreen.Instance.InnerEmptyBounds.Width, width); int renderHeight = Math.Min(MainScreen.Instance.InnerEmptyBounds.Height, height); hotspotSurface = new BasicSurface(renderWidth, renderHeight, Settings.Config.ScreenFont); // Create the new text surface surface = new LayeredSurface(width, height, new Rectangle(0, 0, renderWidth, renderHeight), 1); // Update metadata LayerMetadata.Create("main", false, false, true, surface.GetLayer(0)); surface.SetActiveLayer(0); surface.Font = Settings.Config.ScreenFont; // Update the layer management panel layerManagementPanel.SetLayeredSurface(surface); // Set the text surface as the one we're displaying // Update the border if (MainScreen.Instance.ActiveEditor == this) { MainScreen.Instance.RefreshBorder(); } }
public void Load(string file, IFileLoader loader) { if (loader is FileLoaders.LayeredSurface) { Reset(); surface = (SadConsole.Surfaces.LayeredSurface)loader.Load(file); surface.RenderArea = new Rectangle(0, 0, Math.Min(MainScreen.Instance.InnerEmptyBounds.Width, surface.RenderArea.Width), Math.Min(MainScreen.Instance.InnerEmptyBounds.Height, surface.RenderArea.Height)); layerManagementPanel.SetLayeredSurface(surface); Title = System.IO.Path.GetFileName(file); } }
public void New(Color foreground, Color background, int width, int height) { Reset(); int renderWidth = Math.Min(MainScreen.Instance.InnerEmptyBounds.Width, width); int renderHeight = Math.Min(MainScreen.Instance.InnerEmptyBounds.Height, height); surface = new SadConsole.Surfaces.LayeredSurface(width, height, SadConsoleEditor.Settings.Config.ScreenFont, new Rectangle(0, 0, renderWidth, renderHeight), 1); LayerMetadata.Create("Root", true, false, true, surface.ActiveLayer); var editor = new SurfaceEditor(surface); editor.FillWithRandomGarbage(); layerManagementPanel.SetLayeredSurface(surface); layerManagementPanel.IsCollapsed = true; }
private void SelectedAnimationChanged(AnimatedSurface animation) { selectedAnimation = animation; surface = new LayeredSurface(animation.Width, animation.Height, Settings.Config.ScreenFont, 4); SyncSpecialLayerToAnimation(); surface.SetActiveLayer(0); // inform the outer box we've changed size if (MainScreen.Instance.ActiveEditor == this) { MainScreen.Instance.RefreshBorder(); } framesPanel.SetAnimation(animation); SelectedTool = selectedTool; }
public void Resize(int width, int height) { Reset(); int renderWidth = Math.Min(MainScreen.Instance.InnerEmptyBounds.Width, width); int renderHeight = Math.Min(MainScreen.Instance.InnerEmptyBounds.Height, height); var oldSurface = surface; surface = new SadConsole.Surfaces.LayeredSurface(width, height, SadConsoleEditor.Settings.Config.ScreenFont, new Rectangle(0, 0, renderWidth, renderHeight), 1); for (var index = 0; index < oldSurface.LayerCount; index++) { oldSurface.SetActiveLayer(index); surface.SetActiveLayer(index); oldSurface.Copy(surface); surface.GetLayer(index).Metadata = oldSurface.GetLayer(index).Metadata; } layerManagementPanel.SetLayeredSurface(surface); MainScreen.Instance.RefreshBorder(); }