Ejemplo n.º 1
0
 public void Process(XnaGraphics xna, MouseState mouse)
 {
     if (this.m_PulseValue >= 1)
     {
         this.m_PulseModeUp = false;
     }
     else if (this.m_PulseValue <= 0)
     {
         this.m_PulseModeUp = true;
     }
     this.m_PulseValue += this.m_PulseModeUp ? 0.01 : -0.01;
     if (this.m_Area.Contains(mouse.X, mouse.Y))
     {
         if (mouse.LeftButton == ButtonState.Pressed)
         {
             this.m_IsDown = true;
         }
         if (this.m_IsDown && mouse.LeftButton != ButtonState.Pressed)
         {
             this.m_OnClick();
             this.m_IsDown = false;
         }
     }
     if (this.m_Area.Contains(mouse.X, mouse.Y))
     {
         xna.FillRectangle(this.m_Area, new Color(1f, 1f, 1f, 0.25f + (float)(this.m_PulseValue / 2.0)).ToPremultiplied());
     }
     else
     {
         xna.FillRectangle(this.m_Area, new Color(1f, 1f, 1f, 0.1f + (float)(this.m_PulseValue / 32.0)).ToPremultiplied());
     }
     xna.DrawStringCentered(this.m_Area.X + this.m_Area.Width / 2, this.m_Area.Y + 4, this.m_Text, "ButtonFont");
 }
Ejemplo n.º 2
0
        public override void DrawBelow(GameContext context)
        {
            this.AdjustButtons(context);

            // Draw background effects.
            XnaGraphics xna = new XnaGraphics(context);

            xna.FillRectangle(
                context.ScreenBounds,
                Color.Black);
        }
Ejemplo n.º 3
0
        protected override void Paint(PPaintContext paintContext)
        {
            if (Brush != Color.Transparent)
            {
                XnaGraphics g = paintContext.Graphics;

                RectangleFx bounds = UnionOfChildrenBounds;
                bounds = new RectangleFx(bounds.X - INDENT, bounds.Y - INDENT, bounds.Width + 2 * INDENT, bounds.Height + 2 * INDENT);
                g.FillRectangle(Brush, bounds);
            }
        }
 protected override void Paint(PPaintContext paintContext)
 {
     if (fIsPressed)
     {
         XnaGraphics g = paintContext.Graphics;
         g.FillRectangle(this.Brush, this.Bounds);
     }
     else
     {
         base.Paint(paintContext);
     }
 }
Ejemplo n.º 5
0
 protected override void Paint(PPaintContext paintContext)
 {
     if (paintContext.Camera == lens.Camera)
     {
         XnaGraphics g = paintContext.Graphics;
         g.FillRectangle(Color.Red, Bounds);
     }
     else
     {
         base.Paint(paintContext);
     }
 }
Ejemplo n.º 6
0
        public override void DrawAbove(GameContext context)
        {
            // Are we waiting for players?
#if MULTIPLAYER
            if (this.m_GlobalSession.Waiting || (this.m_GlobalSession.LoadingInitialData && !LocalNode.Singleton.IsServer))
#else
            if (this.m_GlobalSession.Waiting)
#endif
            {
                XnaGraphics graphics = new XnaGraphics(context);
                graphics.FillRectangle(new Rectangle(0, 0, context.Graphics.GraphicsDevice.Viewport.Width, context.Graphics.GraphicsDevice.Viewport.Height), Color.Black);
                int dialogX = context.Graphics.GraphicsDevice.Viewport.X + context.Graphics.GraphicsDevice.Viewport.Width / 2 - 300;
                int dialogY = context.Graphics.GraphicsDevice.Viewport.Y + context.Graphics.GraphicsDevice.Viewport.Height / 2 - 200;
                graphics.FillRectangle(new Rectangle(dialogX, dialogY, 600, 400), Color.DarkSlateGray);
                graphics.DrawStringCentered(dialogX + 300, dialogY + 8, this.m_GlobalSession.LobbyMessage, "BigArial");
                graphics.DrawStringCentered(dialogX + 300, dialogY + 32, "Press enter to toggle ready status.");
                int a = 0;
                for (int i = 0; i < this.m_GlobalSession.Players.Count; i++)
                {
                    Player p = this.m_GlobalSession.Players[i];
                    if (p.Ready)
                    {
                        graphics.DrawStringLeft(dialogX + 8, dialogY + 48 + a * 16, "Player " + a + " (" + p.PlayerID + ") ready.");
                    }
                    else
                    {
                        graphics.DrawStringLeft(dialogX + 8, dialogY + 48 + a * 16, "Player " + a + " (" + p.PlayerID + ") not ready.");
                    }
                    a++;
                }
                return;
            }

            // Handle game normally.
            if (this.m_ActiveLevel != null)
            {
                this.m_ActiveLevel.DrawAbove(context);
            }
            this.m_UiManager.Draw(this, context, new XnaGraphics(context));
        }
Ejemplo n.º 7
0
        public static void Draw(GameContext context, RPGWorld world)
        {
            XnaGraphics g = new XnaGraphics(context);

            g.FillRectangle(new Rectangle(0, 0, 300, 200), Color.Black);
            g.DrawRectangle(new Rectangle(0, 0, 300, 200), Color.Gray);
            g.DrawStringLeft(20, 20, "Render targets used: " + RenderTargetFactory.RenderTargetsUsed);
            g.DrawStringLeft(20, 20 + 16, "Render targets memory: " + RenderTargetFactory.RenderTargetMemory / (1 * 1024 * 1024) + "MB");
            if (world != null)
            {
                TimeSpan ts = new TimeSpan((long)((RPGWorld.AUTOSAVE_LIMIT - world.m_AutoSave) / 60.0 * 10000000.0));
                g.DrawStringLeft(20, 20 + 32, "Autosave counter: " + ts.Minutes + "m" + ts.Seconds + "s");
            }
        }
Ejemplo n.º 8
0
        public override void DrawAbove(GameContext context)
        {
            if (this.m_FadeAmount < 1.0f)
            {
                base.DrawAbove(context);
            }

            var graphics = new XnaGraphics(context);

            graphics.FillRectangle(
                context.ScreenBounds,
                new Color(0, 0, 0, this.m_FadeAmount));
            this.m_FadeAmount -= 0.01f;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Overridden.  See <see cref="PNode.Paint">PNode.Paint</see>.
        /// </summary>
        protected override void Paint(PPaintContext paintContext)
        {
            XnaGraphics g = paintContext.Graphics;

            float  x         = X;
            float  y         = Y;
            float  width     = Width;
            float  height    = Height;
            Matrix transform = g.Transform;

            float[] elements = MatrixExtensions.GetElements(transform);
            float   magX     = elements[0];
            float   magY     = elements[3];
            float   dx       = (float)(1.0 / magX);
            float   dy       = (float)(1.0 / magY);

            g.FillRectangle(Brush, Bounds);

            path.Reset();
            path.AddLine((float)(x + width), (float)y, (float)x, (float)y);
            path.AddLine((float)x, (float)y, (float)x, (float)(y + height));
            pen.Color = System.Drawing.Color.FromArgb(topLeftOuterColor.A, topLeftOuterColor.R, topLeftOuterColor.G, topLeftOuterColor.B);
            g.DrawPath(pen, path);

            path.Reset();
            path.AddLine((float)(x + width), (float)(y + dy), (float)(x + dx), (float)(y + dy));
            path.AddLine((float)(x + dx), (float)(y + dy), (float)(x + dx), (float)(y + height));
            pen.Color = System.Drawing.Color.FromArgb(topLeftInnerColor.A, topLeftInnerColor.R, topLeftInnerColor.G, topLeftInnerColor.B);
            g.DrawPath(pen, path);

            path.Reset();
            path.AddLine((float)(x + width), (float)(y), (float)(x + width), (float)(y + height));
            path.AddLine((float)(x + width), (float)(y + height), (float)(x), (float)(y + height));
            pen.Color = System.Drawing.Color.FromArgb(bottomRightOuterColor.A, bottomRightOuterColor.R, bottomRightOuterColor.G, bottomRightOuterColor.B);
            g.DrawPath(pen, path);

            path.Reset();
            path.AddLine((float)(x + width - dx), (float)(y + dy), (float)(x + width - dx), (float)(y + height - dy));
            path.AddLine((float)(x + width - dx), (float)(y + height - dy), (float)(x), (float)(y + height - dy));
            pen.Color = System.Drawing.Color.FromArgb(bottomRightInnerColor.A, bottomRightInnerColor.R, bottomRightInnerColor.G, bottomRightInnerColor.B);
            g.DrawPath(pen, path);
        }
Ejemplo n.º 10
0
        //****************************************************************
        // Painting - Methods for painting a PText.
        //****************************************************************

        /// <summary>
        /// Overridden.  See <see cref="PNode.Paint">PNode.Paint</see>.
        /// </summary>
        protected override void Paint(XnaPiccolo.Util.PPaintContext paintContext)
        {
            //Font font = new Font("Arial", 12);
            //XnaGraphics gg = paintContext.Graphics;
            //gg.DrawString("Before BasePaint", font, Brushes.Red, new PointF(10, 50));
            //gg.Flush();

            base.Paint(paintContext);

            if (text != null && textBrush != null && font != null)
            {
                XnaGraphics g = paintContext.Graphics;

                float renderedFontSize = font.MeasureString(text).Y * 1.0f;
                //float renderedFontSize = font.SizeInPoints * paintContext.Scale;
                if (renderedFontSize < PUtil.GreekThreshold)
                {
                    // .NET bug: DrawString throws a generic gdi+ exception when
                    // the scaled font size is very small.  So, we will render
                    // the text as a simple rectangle for small fonts
                    g.FillRectangle(textBrush, Bounds);
                }
                else if (renderedFontSize < PUtil.MaxFontSize)
                {
                    SpriteFont renderFont = font;

                    // The font needs to be adjusted for printing.
                    if (g.DpiY != GRAPHICS.DpiY)
                    {
                        float fPrintedFontRatio = GRAPHICS.DpiY / 100;
                        //renderFont = new Font(font.Name, font.Size * fPrintedFontRatio,
                        //	font.Style, font.Unit);
                    }

                    g.DrawString(text, renderFont, textBrush, Bounds, stringFormat);
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Override this method to change the way the full bounds are painted when the debug
        /// full bounds flag is set.
        /// </summary>
        /// <param name="paintContext">The paint context to use for painting debug information.</param>
        /// <param name="fullBoundsBrush">The brush to use for painting the full bounds of a node.</param>
        /// <param name="nodeBounds">The full bounds of the node to paint.</param>
        protected virtual void PaintDebugFullBounds(PPaintContext paintContext, Color fullBoundsBrush, RectangleFx nodeBounds)
        {
            XnaGraphics g = paintContext.Graphics;

            g.FillRectangle(fullBoundsBrush, nodeBounds);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Override this method to change the way the clipping region is painted when the debug
 /// region management flag is set.
 /// </summary>
 /// <param name="brush">The brush to use for painting the clipping region.</param>
 public virtual void PaintClipRegion(Color brush)
 {
     graphics.FillRectangle(brush, graphics.ClipBounds);
 }