Esempio n. 1
0
 /// <summary>
 /// Creates a new Scene from an existing <see cref="LayeredTextSurface"/>.
 /// </summary>
 /// <param name="surface">The surface for the scene.</param>
 public Scene(LayeredTextSurface surface)
 {
     baseConsole = new Console(surface);
     backgroundSurface = surface;
     Objects = new GameObjectCollection();
     Zones = new List<Zone>();
     Hotspots = new List<Hotspot>();
 }
Esempio n. 2
0
 public static LayerMetadata Create(string name, bool moveable, bool removeable, bool renamable, LayeredTextSurface.Layer layer)
 {
     LayerMetadata meta = new LayerMetadata();
     meta.Name = name;
     meta.IsMoveable = moveable;
     meta.IsRenamable = renamable;
     meta.IsRemoveable = removeable;
     layer.Metadata = meta;
     return meta;
 }
Esempio n. 3
0
        public void Resize(int width, int height)
        {
            var oldSurface = textSurface;
            var newSurface = new LayeredTextSurface(width, height, Settings.Config.ScreenFont, oldSurface.LayerCount);

            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;
            }

            consoleWrapper.TextSurface = textSurface = newSurface;
            layerManagementPanel.SetLayeredTextSurface(textSurface);
            toolsPanel.SelectedTool = toolsPanel.SelectedTool;

            if (EditorConsoleManager.ActiveEditor == this)
            {
                EditorConsoleManager.CenterEditor();
                EditorConsoleManager.UpdateBorder(consoleWrapper.Position);
            }
        }
Esempio n. 4
0
        public void New(Color foreground, Color background, int width, int height)
        {
            // Create the new text surface
            textSurface = new LayeredTextSurface(width, height, 1);

            // Update metadata
            LayerMetadata.Create("main", false, false, true, textSurface.GetLayer(0));
            textSurface.SetActiveLayer(0);
            textSurface.Font = Settings.Config.ScreenFont;

            // Update the layer management panel
            layerManagementPanel.SetLayeredTextSurface(textSurface);

            // Set the text surface as the one we're displaying
            consoleWrapper.TextSurface = textSurface;

            // Update the border
            if (EditorConsoleManager.ActiveEditor == this)
                EditorConsoleManager.UpdateBorder(consoleWrapper.Position);
        }
Esempio n. 5
0
        public void Load(string file, FileLoaders.IFileLoader loader)
        {
            ClearEntities();
            ClearZones();
            ClearHotspots();

            if (loader is FileLoaders.Scene)
            {
                var scene = (SadConsole.Game.Scene)loader.Load(file);
                textSurface = scene.BackgroundSurface;
                consoleWrapper.TextSurface = textSurface;

                foreach (var item in scene.Objects)
                    LoadEntity(item);

                foreach (var zone in scene.Zones)
                    LoadZone(zone);

                foreach (var spot in scene.Hotspots)
                    LoadHotspot(spot);

                if (EditorConsoleManager.ActiveEditor == this)
                    EditorConsoleManager.UpdateBorder(consoleWrapper.Position);
            }

            textSurface.Font = Settings.Config.ScreenFont;
            Title = Path.GetFileName(file);

            // Update the layer management panel
            layerManagementPanel.SetLayeredTextSurface(textSurface);
        }
Esempio n. 6
0
        public void SetLayeredTextSurface(LayeredTextSurface surface)
        {
            this.surface = surface;

            // Do updates
            RebuildListBox();
        }
        public void Load(string file, FileLoaders.IFileLoader loader)
        {
            if (loader is FileLoaders.TextSurface)
            {
                // Load the plain surface
                TextSurface surface = (TextSurface)loader.Load(file);

                // Load up a new layered text surface
                textSurface = new LayeredTextSurface(surface.Width, surface.Height, 1);

                // Setup metadata
                LayerMetadata.Create("main", false, false, true, textSurface.GetLayer(0));

                // Use the loaded surface
                textSurface.ActiveLayer.Cells = surface.Cells;
                textSurface.SetActiveLayer(0);

                // Set the text surface as the one we're displaying
                consoleWrapper.TextSurface = textSurface;

                // Update the border
                if (EditorConsoleManager.ActiveEditor == this)
                    EditorConsoleManager.UpdateBorder(consoleWrapper.Position);
            }
            else if (loader is FileLoaders.LayeredTextSurface)
            {
                textSurface = (LayeredTextSurface)loader.Load(file);
                consoleWrapper.TextSurface = textSurface;

                if (EditorConsoleManager.ActiveEditor == this)
                    EditorConsoleManager.UpdateBorder(consoleWrapper.Position);
            }

            textSurface.Font = Settings.Config.ScreenFont;
            Title = System.IO.Path.GetFileName(file);

            // Update the layer management panel
            layerManagementPanel.SetLayeredTextSurface(textSurface);
        }
        private void SelectedAnimationChanged(AnimatedTextSurface animation)
        {
            selectedAnimation = animation;

            consoleWrapper.TextSurface = textSurface = new LayeredTextSurface(animation.Width, animation.Height, Settings.Config.ScreenFont, 4);

            SyncSpecialLayerToAnimation();

            ((LayeredTextSurface)consoleWrapper.TextSurface).SetActiveLayer(0);

            // inform the outer box we've changed size
            if (EditorConsoleManager.ActiveEditor == this)
                EditorConsoleManager.UpdateBorder(consoleWrapper.Position);

            framesPanel.SetAnimation(animation);
            SelectedTool = selectedTool;
        }