Exemple #1
0
        // Draws current collection of screens and components
        public static void Draw(GameTime gameTime, ComponentPredicate DrawPredicate)
        {
            Engine.GameTime = gameTime;
            List<GameScreen> drawing = new List<GameScreen>();

            // Clear back buffer
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // Populate temp list if screen is visible
            foreach (GameScreen screen in GameScreens)
                if (screen.Visible)
                    drawing.Add(screen);

            // BlocksDraw and OverrideDrawBlocked logic
            for (int i = GameScreens.Count - 1; i >= 0; i--)
                if (GameScreens[i].BlocksDraw)
                {
                    if (i > 0)
                        for (int j = i - 1; j >= 0; j--)
                        {
                            if (!GameScreens[j].OverrideDrawBlocked)
                                drawing.Remove(GameScreens[j]);
                        }
                    break;
                }

            // Draw the remaining screens
            foreach (GameScreen screen in drawing)
            {
                if (screen.Initialized)
                    screen.Draw(DrawPredicate);
                if (screen.Equals(Engine.BackgroundScreen))
                    blur.Draw();
            }
        }
Exemple #2
0
        // Draw screen and its components.
        // Accepts ComponentType to tell what kind of components to draw.
        // Useful for drawing a reflection into a render target without
        // 2D components getting in the way
        public virtual void Draw(ComponentPredicate DrawPredicate)
        {
            //position of cursor
            //if (IsMouseVisible)
            //{

            //    Vector2 position = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
            //    cursor.Begin();
            //    cursor.Draw(cursorTexture, position, Color.White);
            //    cursor.End();

            //}

            // Temp list
            List<Component> drawing = new List<Component>();

            foreach (Component component in Components.InDrawOrder)
                if (DrawPredicate.IsComponentEligible(component))
                    drawing.Add(component);

            // Keep list of components that are 2D so we can draw them
            // on top of 3D components
            List<Component> defer2D = new List<Component>();

            foreach (Component component in drawing)
                if (component.Visible && component.Initialized)
                {
                    if (component is I2DComponent)
                        defer2D.Add(component);
                    else
                        component.Draw();
                }

            // Draw 2D components
            foreach (Component component in defer2D)
                component.Draw();
        }