SetActiveLayer() public method

Changes the active layer, which sets the current cell data for ITextSurfaceRendered.
public SetActiveLayer ( Layer layer ) : void
layer Layer The layer to set active.
return void
示例#1
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);
        }
示例#2
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);
            }
        }
        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);
        }