Ejemplo n.º 1
0
        public ScrollingConsole(int width, int height, int bufferHeight)
        {
            controlsContainer = new SadConsole.ControlsConsole(1, height);

            mainConsole = new SadConsole.Console(width - 1, bufferHeight);
            mainConsole.TextSurface.RenderArea  = new Microsoft.Xna.Framework.Rectangle(0, 0, width - 1, height);
            mainConsole.VirtualCursor.IsVisible = false;

            scrollBar               = SadConsole.Controls.ScrollBar.Create(System.Windows.Controls.Orientation.Vertical, height);
            scrollBar.IsEnabled     = false;
            scrollBar.ValueChanged += ScrollBar_ValueChanged;

            controlsContainer.Add(scrollBar);
            controlsContainer.Position = new Microsoft.Xna.Framework.Point(1 + mainConsole.TextSurface.Width, Position.Y);

            Children.Add(mainConsole);
            Children.Add(controlsContainer);

            scrollingCounter = 0;

            borderSurface = new SadConsole.Surfaces.BasicSurface(width + 2, height + 2, mainConsole.TextSurface.Font);
            var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface);

            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick();
            box.Width  = borderSurface.Width;
            box.Height = borderSurface.Height;
            box.Draw(editor);
            renderer = new SurfaceRenderer();
            renderer.Render(borderSurface);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Wraps an existing text surface using a <see cref="TextSurfaceRenderer"/> to render.
 /// </summary>
 /// <param name="textData">The backing text surface.</param>
 public Console(ISurface textData) : base(textData)
 {
     Children      = new ScreenCollection(this);
     virtualCursor = new Cursor(this);
     Renderer      = new SurfaceRenderer();
     textSurface   = textData;
 }
Ejemplo n.º 3
0
        public override void Draw(TimeSpan timeElapsed)
        {
            if (IsVisible)
            {
                // Draw the scene.
                SurfaceRenderer.Render(Surface.TextSurface);
                Global.DrawCalls.Add(new DrawCallSurface(Surface.TextSurface, calculatedPosition, UsePixelPositioning));

                // Draw objects
                foreach (var item in Objects)
                {
                    item.Draw(timeElapsed);
                }

                // Draw the children.
                if (Children.Count != 0)
                {
                    var copyList = new List <IScreen>(Children);

                    foreach (var child in copyList)
                    {
                        child.Draw(timeElapsed);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void Render(SurfaceRenderer renderer)
 {
     for (int i = 0; i < Components.Count; i++)
     {
         Components[i].Render(renderer);
     }
 }
Ejemplo n.º 5
0
        private void Initialize()
        {
            graphicsDevice = ScreenManager.GraphicsDevice;
            content        = ScreenManager.Content;
            spriteBatch    = ScreenManager.SpriteBatch;
            font           = ScreenManager.Font;
            MeshManager.InitializeManager(graphicsDevice, content);

            screenWidth  = graphicsDevice.Viewport.Width;
            screenHeight = graphicsDevice.Viewport.Height;

            clearColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);

            // Create Render Targets
            mainRT = new RenderTarget2D(graphicsDevice, screenWidth, screenHeight, false, SurfaceFormat.Color,
                                        DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.PreserveContents);
            reflectionRT = new RenderTarget2D(graphicsDevice, screenWidth / 2, screenHeight / 2, true, SurfaceFormat.Color,
                                              DepthFormat.Depth24Stencil8);
            occlusionRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color,
                                             DepthFormat.None);
            bloomRT = new RenderTarget2D(graphicsDevice, screenWidth / 8, screenHeight / 8, false, SurfaceFormat.Color,
                                         DepthFormat.None);

            postEffects = new PostProcessingEffects(graphicsDevice,
                                                    content.Load <Effect>(@"Effects\PostProcessingEffects"));

            // Create renderers
            lightRenderer = new LightRenderer(graphicsDevice,
                                              content.Load <Effect>(@"Effects\Light"));
            terrainRenderer = new TerrainRenderer(graphicsDevice,
                                                  content.Load <Effect>(@"Effects\Terrain"));
            surfaceRenderer = new SurfaceRenderer(graphicsDevice,
                                                  content.Load <Effect>(@"Effects\Surface"));
            waterRenderer = new WaterRenderer(graphicsDevice,
                                              content.Load <Effect>(@"Effects\Water"));
            billboardRenderer = new BillboardRenderer(graphicsDevice,
                                                      content.Load <Effect>(@"Effects\Billboard"));
            meshRenderer = new MeshRenderer(graphicsDevice,
                                            content.Load <Effect>(@"Effects\Mesh"));

            // Create camera
            camera                 = new FirstPersonCamera();
            camera.AspectRatio     = graphicsDevice.Viewport.AspectRatio;
            camera.AABBSize        = new Vector2(1.0f, 8.0f);
            camera.DrawDistance    = 10000.0f;
            camera.MoveSpeed       = 25.0f;
            camera.FreeFlyEnabled  = false;
            camera.PitchMinDegrees = -75.0f;
            camera.PitchMaxDegrees = 60.0f;
            camera.Projection      = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                                                                         camera.AspectRatio, 0.1f, 10000.0f);

            secretSFX = content.Load <SoundEffect>(@"SoundEffects\shotgun_pump");

            // Load level data
            LoadLevel(@"Levels\" + levelFileName);
        }
Ejemplo n.º 6
0
        public SceneEditor()
        {
            layerManagementPanel = new LayersPanel()
            {
                IsCollapsed = true
            };
            toolsPanel = new ToolsPanel();

            // Fill tools
            tools = new Dictionary <string, Tools.ITool>
            {
                { Tools.PaintTool.ID, new Tools.PaintTool() },
                { Tools.LineTool.ID, new Tools.LineTool() },
                { Tools.CircleTool.ID, new Tools.CircleTool() },
                { Tools.RecolorTool.ID, new Tools.RecolorTool() },
                { Tools.FillTool.ID, new Tools.FillTool() },
                { Tools.BoxTool.ID, new Tools.BoxTool() },
                { Tools.SelectionTool.ID, new Tools.SelectionTool() },
                { Tools.SceneObjectMoveResizeTool.ID, new Tools.SceneObjectMoveResizeTool() },
                { Tools.HotspotTool.ID, new Tools.HotspotTool() }
            };

            toolsPanel.ToolsListBox.Items.Add(tools[Tools.SceneObjectMoveResizeTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.HotspotTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.PaintTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.LineTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.CircleTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.RecolorTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.FillTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.BoxTool.ID]);
            toolsPanel.ToolsListBox.Items.Add(tools[Tools.SelectionTool.ID]);

            toolsPanel.ToolsListBox.SelectedItemChanged += ToolsListBox_SelectedItemChanged;
            toolsPanel.ToolsListBox.SelectedItem         = tools[Tools.PaintTool.ID];

            GameObjectPanel = new Panels.GameObjectManagementPanel();
            ZonesPanel      = new RegionManagementPanel()
            {
                IsCollapsed = true
            };
            HotspotPanel = new HotspotToolPanel()
            {
                IsCollapsed = true
            };

            LinkedGameObjects = new Dictionary <GameObject, GameObject>();
            Objects           = new List <ResizableObject>();
            Zones             = new List <ResizableObject <Zone> >();
            Hotspots          = new List <Hotspot>();

            panels          = new CustomPanel[] { layerManagementPanel, GameObjectPanel, ZonesPanel, HotspotPanel, toolsPanel };
            renderer        = new LayeredSurfaceRenderer();
            hotspotRenderer = new SurfaceRenderer();
        }
Ejemplo n.º 7
0
 public FPSCounterComponent(Microsoft.Xna.Framework.Game game)
     : base(game)
 {
     surface = new BasicSurface(30, 1);
     editor  = new SurfaceEditor(surface);
     surface.DefaultBackground = Color.Black;
     editor.Clear();
     consoleRender = new SurfaceRenderer();
     DrawOrder     = 8;
     Global.GraphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
 }
Ejemplo n.º 8
0
        public static void Render(SurfaceRenderer renderer)
        {
            for (int i = 0; i < entities.Count; i++)
            {
                if (!entities[i].IsActive)
                {
                    continue;
                }

                entities[i].Render(renderer);
            }
        }
Ejemplo n.º 9
0
        public Game(SurfaceRenderer renderer, InputHandler inputHandler)
        {
            if (Instance != null)
            {
                Console.WriteLine("A game is already running !");
                return;
            }

            Renderer = renderer;
            Input    = inputHandler;

            IsRunning = true;

            Instance = this;
        }
Ejemplo n.º 10
0
        public DungeonScreen(int screenX, int screenY, int screenWidth, int screenHeight, Font font)
        {
            Position = new Point(screenX, screenY);
            Width    = screenWidth;
            Height   = screenHeight;

            borderSurface = new SadConsole.Surfaces.BasicSurface(Width + 1, Height + 1, font);
            var editor = new SadConsole.Surfaces.SurfaceEditor(borderSurface);

            SadConsole.Shapes.Box box = SadConsole.Shapes.Box.Thick();
            box.Width  = borderSurface.Width;
            box.Height = borderSurface.Height;
            box.Draw(editor);
            renderer = new SurfaceRenderer();
            renderer.Render(borderSurface);
        }
Ejemplo n.º 11
0
        public override void Render(SurfaceRenderer renderer)
        {
            for (int y = 0; y < frame.Height; y++)
            {
                for (int x = 0; x < frame.Width; x++)
                {
                    Color pixel = frame.GetPixel(x, y);
                    if (pixel.A == 0)
                    {
                        continue;
                    }                               // todo: implement alpha threshold

                    renderer.Render(new RgbSurfaceItem(pixel), destRect.X + x, destRect.Y + y);
                }
            }

            frame.Dispose();
        }
Ejemplo n.º 12
0
        public Game Build(uint flags = 0)
        {
            IntPtr hWnd  = GetConsoleWindow();
            IntPtr hMenu = GetSystemMenu(hWnd, false);

            SetWindowPos(hWnd, IntPtr.Zero, WindowLeft, WindowTop, 0, 0, flags | (uint)SWP.SHOWWINDOW | (uint)SWP.NOSIZE);
            Console.SetWindowSize(WindowWidth, WindowHeight);

            Logger.DebugFolderPath = DebugFolderPath;

            OutputHandlerInfo outputHandlerInfo = new OutputHandlerInfo()
            {
                size       = new COORD(WindowWidth, WindowHeight),
                font       = outputFont,
                frameDelay = 1000 / MaximumFpsCount
            };

            OutputHandler   outputHandler   = (OutputHandler)Activator.CreateInstance(OutputHandlerType, outputHandlerInfo);
            SurfaceRenderer surfaceRenderer = (SurfaceRenderer)Activator.CreateInstance(RendererType, outputHandler, WindowWidth, WindowHeight, true);

            InputHandler inputHandler = new InputHandler();

            inputHandler.Enable();

            DeleteMenu(hMenu, (int)SC.MINIMIZE, (int)MF.BYCOMMAND);
            DeleteMenu(hMenu, (int)SC.MAXIMIZE, (int)MF.BYCOMMAND);
            DeleteMenu(hMenu, (int)SC.SIZE, (int)MF.BYCOMMAND);

            SetConsoleTitle(WindowName);

            Console.CursorVisible = false;

            Thread.Sleep(100);

            return(new Game(surfaceRenderer, inputHandler));
        }
Ejemplo n.º 13
0
 public virtual void Render(SurfaceRenderer renderer)
 {
 }