Beispiel #1
0
        protected void RenderElements(Graphics.RenderInfo info)
        {
            if (selectedContent >= 0)
            {
                for (int i = VisibleOptions; i > 0; i--)
                {
                    int index = selectedContent + i;
                    if (index >= Contents.Count && Wrap)
                    {
                        index -= Contents.Count;
                    }
                    if (index < Contents.Count)
                    {
                        Contents[index].Position = this.Position + offset * i;
                        Contents[index].Render(info);
                    }

                    index = selectedContent - i;
                    if (index < 0 && Wrap)
                    {
                        index += Contents.Count;
                    }
                    if (index >= 0)
                    {
                        Contents[index].Position = this.Position - offset * i;
                        Contents[index].Render(info);
                    }
                }


                Contents[selectedContent].Position = this.Position;
                Contents[selectedContent].Render(info);
            }
        }
Beispiel #2
0
        /// <summary>
        /// A simple visualization rendered to the menu's renderer's canvas. But only when the menu's static font has been set
        /// </summary>
        /// <param name="info"></param>
        public override void Render(Graphics.RenderInfo info)
        {
            if (UILayer.Font != null && Visible)
            {
                Color face = Color.Lerp(UILayer.ColorTextBox, UILayer.ColorTextBoxHighLight, this.currentSelected);
                Color text = Color.Lerp(UILayer.ColorText, UILayer.ColorTextHighLight, this.currentSelected);

                if (!Enabled)
                {
                    face = UILayer.ColorFaceDisabled;
                    text = UILayer.ColorTextDisabled;
                }

                PhantomUtils.DrawShape(info, this.Position, this.Shape, face, UILayer.ColorShadow, 2);
                //PhantomUtils.DrawShape(info, this.Position - Vector2.One * down, this.Shape, face, UILayer.ColorShadow, 2);
                Vector2 p = Position;
                p.Y -= h * UILayer.DefaultFontScale;
                p.X -= w;
                p.X  = (float)Math.Round(p.X);
                p.Y  = (float)Math.Round(p.Y);
                string s = Text;
                if (timer % 0.5f > 0.2f)
                {
                    s += "_";
                }
                //info.Batch.DrawString(UILayer.Font, s, p, text);
                UILayer.Font.DrawString(info, s, p, text, UILayer.DefaultFontScale, 0, new Vector2(0, 0));

                if (Caption != null)
                {
                    UILayer.Font.DrawString(info, Caption, p + CaptionPosition, text, UILayer.DefaultFontScale, 0, new Vector2(0, 0));
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// A simple visualization rendered to the menu's renderer's canvas. But only when the menu's static font has been set
        /// </summary>
        /// <param name="info"></param>
        public override void Render(Graphics.RenderInfo info)
        {
            if (UILayer.Font != null && Visible)
            {
                Vector2 size = UILayer.Font.MeasureString(Caption);
                Color   face = UILayer.ColorFace;
                Color   text = Color.Lerp(UILayer.ColorShadow, UILayer.ColorFaceHighLight, this.currentSelected);

                if (!Enabled)
                {
                    face = UILayer.ColorFaceDisabled;
                    text = UILayer.ColorFace;
                }

                PhantomUtils.DrawShape(info, this.Position, this.Shape, face, text, 2);

                size.X *= 0.5f;
                size.Y  = -this.Shape.RoughWidth * 0.5f;
                //info.Batch.DrawString(UILayer.Font, Caption, Position + size, text);
                UILayer.Font.DrawString(info, Caption, Position, text, UILayer.DefaultFontScale, 0, size);
            }
            if (content != null)
            {
                content.Position = this.Position;
            }
            base.Render(info);
        }
        public override void Render(Graphics.RenderInfo info)
        {
            if (UILayer.Font != null && Visible)
            {
                Vector2 size = UILayer.Font.MeasureString(Caption);
                Color   text = Color.Lerp(UILayer.ColorShadow, UILayer.ColorFaceHighLight, this.currentSelected);

                if (!Enabled)
                {
                    text = UILayer.ColorFace;
                }

                PhantomUtils.DrawShape(info, this.Position, this.Shape, Color.Transparent, text, 2);

                size.X *= 0.5f;
                size.Y  = -this.Shape.RoughWidth * 0.5f;
                UILayer.Font.DrawString(info, Caption, Position, text, UILayer.DefaultFontScale, 0, size);

                for (int y = 0; y < this.Height; y++)
                {
                    for (int x = 0; x < this.Width; x++)
                    {
                        Vector2 p = Position;
                        p.X += (x - this.Width * 0.5f + 0.5f) * this.SlotSize.X;
                        p.Y += (y - this.Height * 0.5f + 0.5f) * this.SlotSize.Y;
                        RenderSlot(info, p, x, y);
                    }
                }
            }
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].Render(info);
            }
        }
Beispiel #5
0
        /// <summary>
        /// A simple visualization rendered to the menu's renderer's canvas. But only when the menu's static font has been set
        /// </summary>
        /// <param name="info"></param>
        public override void Render(Graphics.RenderInfo info)
        {
            if (UILayer.Font != null && Visible)
            {
                string c = Caption;
                if (Count > 1)
                {
                    c = (c + " " + Count).Trim();
                }
                Vector2 size = UILayer.Font.MeasureString(c);
                Color   face = Color.Lerp(UILayer.ColorFaceDisabled, UILayer.ColorFaceHighLight, this.currentSelected);
                Color   text = UILayer.ColorFaceHighLight;

                if (!Enabled)
                {
                    face = UILayer.ColorFace;
                    text = UILayer.ColorFace;
                }

                PhantomUtils.DrawShape(info, this.Position, this.Shape, face, Color.Transparent, 0);

                size.X *= 0.5f;
                size.Y  = -this.Shape.RoughWidth * 0.5f;
                if (this.currentSelected > 0.5f && Enabled)
                {
                    UILayer.Font.DrawString(info, c, Position, text);
                    UILayer.Font.DrawString(info, c, Position, text, UILayer.DefaultFontScale, 0, size);
                }
            }
        }
Beispiel #6
0
        protected void RenderElements(Graphics.RenderInfo info)
        {
            if (selectedElement >= 0)
            {
                for (int i = VisibleOptions; i > 0; i--)
                {
                    int index = selectedElement + i;
                    if (index >= elements.Count && Wrap)
                    {
                        index -= elements.Count;
                    }
                    if (index < elements.Count)
                    {
                        elements[index].Position = this.Position + offset * i * (float)Math.Pow(fallOff, i);
                        elements[index].Render(info);
                    }

                    index = selectedElement - i;
                    if (index < 0 && Wrap)
                    {
                        index += elements.Count;
                    }
                    if (index >= 0)
                    {
                        elements[index].Position = this.Position - offset * i * (float)Math.Pow(fallOff, i);
                        elements[index].Render(info);
                    }
                }


                elements[selectedElement].Position = this.Position;
                elements[selectedElement].Render(info);
            }
        }
Beispiel #7
0
 public override void Render(Graphics.RenderInfo info)
 {
     base.Render(info);
     if (UILayer.Font != null && info.Pass == info.Renderer.Passes - 1)
     {
         info.Canvas.FillColor = Color.Black;
         info.Canvas.FillRect(this.Position, size * 0.5f, 0);
         UILayer.Font.DrawString(info, label, this.Position, Color.White, 1, 0, size * 0.5f);
     }
 }
Beispiel #8
0
 public override void Render(Graphics.RenderInfo info)
 {
     base.Render(info);
     if (selecting)
     {
         info.Canvas.StrokeColor = Color.White;
         info.Canvas.LineWidth   = 2;
         Vector2 hs = mousePosition - mouseDownPosition;
         hs *= 0.5f;
         info.Canvas.StrokeRect(mouseDownPosition + hs, hs, 0);
     }
 }
Beispiel #9
0
 public override void Render(Graphics.RenderInfo info)
 {
     base.Render(info);
     if (Visible && UILayer.Font != null)
     {
         Vector2 size = UILayer.Font.MeasureString(this.Name);
         if (!this.centered)
         {
             size.X = 0;
         }
         UILayer.Font.DrawString(info, this.Name, this.Position, color, UILayer.DefaultFontScale, 0, size * 0.5f);
     }
 }
Beispiel #10
0
        public override void Render(Graphics.RenderInfo info)
        {
            Canvas c = info.Canvas;

            for (int i = 0; i < debug.Count; i += 2)
            {
                c.Begin();
                c.MoveTo(debug[i].Position.Flatten());
                c.LineTo(debug[i + 1].Position.Flatten());
                c.StrokeColor = debug[i].Color;
                c.LineWidth   = 3;
                c.Stroke();
            }
            debug.Clear();

            base.Render(info);
        }
Beispiel #11
0
        public override void Render(Graphics.RenderInfo info)
        {
            if (Visible)
            {
                Color border = Color.Lerp(UILayer.ColorFace, UILayer.ColorFaceHighLight, this.currentSelected);

                if (!Enabled)
                {
                    border = UILayer.ColorFaceDisabled;
                }

                PhantomUtils.DrawShape(info, this.Position, this.Shape, Color.Transparent, border, 2);


                RenderElements(info);
            }
        }
Beispiel #12
0
        /// <summary>
        /// A simple rendering routine for the slider
        /// </summary>
        /// <param name="info"></param>
        public override void Render(Graphics.RenderInfo info)
        {
            base.Render(info);

            if (Visible)
            {
                //Vector2 size = Menu.Font.MeasureString(Caption);
                Color face = Color.Lerp(UILayer.ColorFace, UILayer.ColorFaceHighLight, this.currentSelected);
                Color text = Color.Lerp(UILayer.ColorText, UILayer.ColorTextHighLight, this.currentSelected);

                if (!Enabled)
                {
                    face = UILayer.ColorFaceDisabled;
                    text = UILayer.ColorTextDisabled;
                }

                Vector2 p = Position;
                if (sliderOrientation == SliderOrientation.Horizontal)
                {
                    info.Canvas.FillColor = face;
                    info.Canvas.FillRect(p, new Vector2(rect.HalfSize.X, 3), 0);
                    info.Canvas.FillColor = UILayer.ColorShadow;
                    info.Canvas.FillRect(p, new Vector2(rect.HalfSize.X - 2, 1), 0);

                    p.X += ((currentValue - minValue) / (maxValue - minValue) - 0.5f) * (rect.HalfSize.X - HandleWidth * 0.5f) * 2;
                }
                else
                {
                    info.Canvas.FillColor = face;
                    info.Canvas.FillRect(p, new Vector2(3, rect.HalfSize.Y), 0);
                    info.Canvas.FillColor = UILayer.ColorShadow;
                    info.Canvas.FillRect(p, new Vector2(1, rect.HalfSize.Y - 2), 0);

                    p.Y -= ((currentValue - minValue) / (maxValue - minValue) - 0.5f) * (rect.HalfSize.Y - HandleHeight * 0.5f) * 2;
                }
                info.Canvas.FillColor = UILayer.ColorShadow;
                info.Canvas.FillRect(p, new Vector2(HandleWidth * 0.5f, HandleHeight * 0.5f), 0);
                info.Canvas.FillColor = face;
                info.Canvas.FillRect(p, new Vector2(HandleWidth * 0.5f - 2, HandleHeight * 0.5f - 2), 0);

                if (UILayer.Font != null && caption != null)
                {
                    UILayer.Font.DrawString(info, caption, Position - rect.HalfSize, text, UILayer.DefaultFontScale, 0, Vector2.Zero);
                }
            }
        }
        protected virtual void RenderSlot(Graphics.RenderInfo info, Vector2 position, int x, int y)
        {
            Color empty = UILayer.ColorFace;
            Color full  = UILayer.ColorFaceDisabled;

            Vector2 s = SlotSize * 0.5f;

            s.X -= 1;
            s.Y -= 1;

            if (!Enabled)
            {
                empty = UILayer.ColorFaceDisabled;
            }

            info.Canvas.FillColor = (Slots[x, y] == null) ? empty : full;

            info.Canvas.FillRect(position, s, 0);
        }
Beispiel #14
0
        /// <summary>
        /// A simple visualization rendered to the menu's renderer's canvas. But only when the menu's static font has been set
        /// </summary>
        /// <param name="info"></param>
        public override void Render(Graphics.RenderInfo info)
        {
            if (UILayer.Font != null && Visible)
            {
                Vector2 size = UILayer.Font.MeasureString(Caption);
                Color   face = Color.Lerp(UILayer.ColorFace, UILayer.ColorFaceHighLight, this.currentSelectedTool);
                Color   text = Color.Lerp(UILayer.ColorText, UILayer.ColorTextHighLight, this.currentSelected);

                if (!Enabled)
                {
                    face = UILayer.ColorFaceDisabled;
                    text = UILayer.ColorTextDisabled;
                }

                PhantomUtils.DrawShape(info, this.Position, this.Shape, Color.Transparent, UILayer.ColorShadow, 2);
                float down = this.pressed > 0 ? 0 : 2;
                down = Math.Min(2 - currentSelectedTool, down);
                PhantomUtils.DrawShape(info, this.Position - Vector2.One * down, this.Shape, face, UILayer.ColorShadow, 2);

                UILayer.Font.DrawString(info, Caption, Position - Vector2.One * down, text, UILayer.DefaultFontScale, 0, size * 0.5f);
            }
        }
Beispiel #15
0
        public override void Render(Graphics.RenderInfo info)
        {
            info       = new RenderInfo();
            info.Batch = this.batch;

            float padding = this.Settings.Padding;
            Color color   = this.Settings.Color;

            float lineSpace = this.font.LineSpacing;

            if (!this.Visible && this.transition <= 0)
            {
                if (this.echoQueue.Count > 0)
                {
                    float ey = padding;
                    this.batch.Begin(SpriteSortMode.Deferred, Settings.FontBlendState, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);
                    lock (this.echoQueue)
                    {
                        foreach (EchoLine echo in this.echoQueue)
                        {
                            this.font.DrawString(info, echo.Line, new Vector2(padding, ey) + Vector2.One, new Color(0, 0, 0, 200));
                            this.font.DrawString(info, echo.Line, new Vector2(padding, ey), color);
                            ey += lineSpace;
                        }
                    }
                    this.batch.End();
                }
                return;
            }

            float transitionScale = Math.Max(0, this.transition / this.Settings.TransitionTime);

            if (this.Visible)
            {
                transitionScale = 1 - transitionScale;
            }

            GraphicsDevice graphicsDevice = PhantomGame.Game.GraphicsDevice;
            Viewport       resolution     = PhantomGame.Game.Resolution;
            float          height         = padding * 2 + lineSpace * (this.Settings.LineCount + 1);

            this.effect.World      = Matrix.Identity;
            this.effect.Projection = Matrix.CreateOrthographicOffCenter(
                0, 1, 1f / (height / resolution.Height * transitionScale), 0,
                0, 1);
            this.effect.DiffuseColor = this.Settings.BackgroundColor.ToVector3();
            this.effect.Alpha        = this.Settings.Alpha;

            this.effect.CurrentTechnique.Passes[0].Apply();
            graphicsDevice.SetVertexBuffer(this.backgroundBuffer);
            graphicsDevice.Indices = this.backgroundIndex;
            graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, 4, 0, 2);

            this.batch.Begin(SpriteSortMode.Deferred, Settings.FontBlendState, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);
            float y = height * transitionScale - padding - lineSpace;

            this.font.DrawString(info, this.Settings.Prompt + this.input, new Vector2(padding, y), color);
            if (this.input.Length == 0)
            {
                this.font.DrawString(info, Konsoul.WELCOME, new Vector2(padding + promptWidth, y), new Color(.2f, .2f, .2f, this.Settings.Alpha * .5f));
            }
            y -= lineSpace;

            int count = this.lines.Count;

            this.scrollOffset = (int)MathHelper.Clamp(this.scrollOffset, 0, count - this.Settings.LineCount);
            int index = 1 + this.scrollOffset;

            while ((index - this.scrollOffset) <= this.Settings.LineCount && count - index >= 0)
            {
                string line = this.lines[count - index];
                if (line.Length > 0)
                {
                    IList <string> chunks = WordWrap(line, resolution.Width - padding * 2);
                    for (int i = 0; i < chunks.Count; i++)
                    {
                        this.font.DrawString(info, chunks[i], new Vector2(padding, y), color);
                        y -= lineSpace;
                    }
                }
                else
                {
                    y -= lineSpace;
                }
                index++;
            }

            this.batch.End();

            // Render cursor:
            if (this.blinkTimer % 2 < 1)
            {
                Vector2 cursorPosition = this.font.MeasureString(this.input.Substring(0, this.cursor)) + new Vector2(this.Settings.Padding + this.promptWidth, 0);
                cursorPosition.Y = height * transitionScale - lineSpace - padding;

                this.effect.World      = Matrix.CreateTranslation(cursorPosition.X, cursorPosition.Y, 0);
                this.effect.Projection = Matrix.CreateOrthographicOffCenter(
                    0, resolution.Width, resolution.Height, 0,
                    0, 1);
                this.effect.DiffuseColor = this.Settings.Color.ToVector3();
                this.effect.Alpha        = 1;

                this.effect.CurrentTechnique.Passes[0].Apply();
                graphicsDevice.SetVertexBuffer(this.cursorBuffer);
                graphicsDevice.DrawPrimitives(PrimitiveType.LineList, 0, 1);
            }
            base.Render(info);
        }