public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;
            Rectangle drawArea;

            int left_width = m_LeftBorderIsRightBorderReversed ? m_Right.Width : m_Left.Width;

            // ##### Draw Left portion ##### //
            drawArea = new Rectangle(
                area.Left,
                area.Top,
                left_width,
                m_Left.Height);
            batch.GUIDrawSprite(Texture, drawArea,
                m_LeftBorderIsRightBorderReversed ? m_Right : m_Left, Color,
                effects: m_LeftBorderIsRightBorderReversed ? SpriteEffects.FlipHorizontally : SpriteEffects.None);

            // ##### Draw Center portion ##### //
            drawArea = new Rectangle(
                area.Left + left_width,
                area.Top,
                area.Width - left_width - m_Right.Width,
                m_Center.Height);
            batch.GUIDrawSprite(Texture, drawArea, m_Center, Color);

            // ##### Draw Right portion ##### //
            drawArea = new Rectangle(
                area.Right - m_Right.Width,
                area.Top,
                m_Right.Width,
                m_Right.Height);
            batch.GUIDrawSprite(Texture, drawArea, m_Right, Color);
        }
Example #2
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            if (Model.DrawHeader)
                Model.FontName = "CenturyGothic11Bold";
            else
                Model.FontName = "CenturyGothic11";

            if (Model.DrawAsRecessed)
            {
                m_RecessedRenderer.Render(spritebatch, Model.ScreenArea);
            }
            else
            {
                if (Model.Parent.GetType() != typeof(Panel))
                {
                    int x = 6;
                    int y = 6;
                    Rectangle shadow_area = new Rectangle(Model.ScreenArea.X - x, Model.ScreenArea.Y - y, Model.ScreenArea.Width + x * 2, Model.ScreenArea.Height + y * 2);
                    m_ShadowRenderer.Render(spritebatch, shadow_area);
                }

                m_PanelRenderer.Render(spritebatch, Model.ScreenArea);

                if (Model.DrawHeader)
                    m_HeaderRenderer.Render(spritebatch, Model.ScreenArea);

                if (Model.Caption != null && Model.Caption != string.Empty)
                {
                    Vector2 position = new Vector2(
                        Model.ScreenArea.X + Model.ChildArea.X + (Model.DrawHeader && Model.HeaderIcon != null ? 28 : 4),
                        Model.ScreenArea.Y + 5);
                    spritebatch.DrawString(Font, Model.Caption, position, 18f, Vector2.Zero, Color.White);
                }
            }
        }
Example #3
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            Color color = Model.IsEnabled ? Color.White : new Color(160, 160, 160, 255);

            Rendering.ARenderer renderer = Model.IsMouseOver ? (Model.IsMouseDown ? m_Down : m_Hover) : m_Normal;
            renderer.Render(spritebatch, Model.ScreenArea, color);
            if (Model.DrawIcon)
            {
                Rectangle icon_area = Model.ScreenArea;
                icon_area.X += 4;
                icon_area.Y += 4;
                icon_area.Width = 36;
                icon_area.Height -= 8;
                m_Icon.Render(spritebatch, icon_area);
            }
            if (Model.Caption != null && Model.Caption != string.Empty)
            {
                if (m_WrappedText == null)
                    m_WrappedText = new WrappedText();
                Rectangle area = Model.ScreenArea;
                area.X += (Model.DrawIcon ? 44 : 4);
                // area.Y += 4;
                area.Width -= (Model.DrawIcon ? 48 : 8);
                // area.Height -= 8;

                m_WrappedText.Draw(spritebatch, Font, area, Model.Caption, Model.FontSize, FontJustification.Center | FontJustification.CenterVertically, color);
            }
        }
Example #4
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            Rectangle area = Model.ScreenArea;
            m_default.Render(spritebatch, area);

            area.X += m_hover.Buffer;

            foreach (MenuElement e in Model.Children)
            {
                bool elementDown = false;
                Vector2 v = Font.MeasureString(e.Label, m_FontSize);

                if (Model.IsMouseOver)
                {
                    Rectangle button = new Rectangle(area.X, area.Y, (int)v.X + m_hover.Buffer * 2, m_MenuHeight);
                    if (e.Enabled && button.Contains(Model.MousePosition))
                        if (Model.IsMouseDown)
                        {
                            m_pressed.Render(spritebatch, button);
                            elementDown = true;
                        }
                        else
                            m_hover.Render(spritebatch, button);
                }
                if (!elementDown)
                    area.Y--;
                Color font_color = e.Enabled ? Color.White : Color.Gray;
                spritebatch.DrawString(Font, e.Label, new Vector2(area.X + m_hover.Buffer, area.Y + (m_MenuHeight - v.Y) / 2f), m_FontSize, color: font_color);
                if (!elementDown)
                    area.Y++;
                area.X += (m_hover.Buffer * 2 + (int)v.X);
                area.Width -= (m_hover.Buffer * 2 + (int)v.X);
            }
        }
Example #5
0
        public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;

            // ##### Draw Background ##### //
            Rectangle drawArea = new Rectangle(
                area.Left + BorderWidth,
                area.Top + BorderWidth,
                area.Width - (2 * BorderWidth),
                area.Height - (2 * BorderWidth));
            batch.GUIDrawSprite(Texture, drawArea, m_BG, Color);

            // ##### Draw Corners ##### //
            drawArea.Width = BorderWidth;
            drawArea.Height = BorderWidth;

            //Top Left
            drawArea.X = area.Left;
            drawArea.Y = area.Top;
            batch.GUIDrawSprite(Texture, drawArea, m_UL, Color);

            //Top Right
            drawArea.X = area.Right - BorderWidth;
            drawArea.Y = area.Top;
            batch.GUIDrawSprite(Texture, drawArea, m_UR, Color);

            //Bottom Right
            drawArea.X = area.Right - BorderWidth;
            drawArea.Y = area.Bottom - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_LR, Color);

            //Bottom Left
            drawArea.X = area.Left;
            drawArea.Y = area.Bottom - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_LL, Color);

            // ##### Draw Edges ##### //

            //Top Edge
            drawArea.X = area.Left + BorderWidth;
            drawArea.Y = area.Top;
            drawArea.Width = area.Width - (2 * BorderWidth);
            batch.GUIDrawSprite(Texture, drawArea, m_T, Color);

            //Bottom Edge
            drawArea.Y = area.Bottom - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_B, Color);

            //Left Edge
            drawArea.X = area.Left;
            drawArea.Y = area.Top + BorderWidth;
            drawArea.Width = BorderWidth;
            drawArea.Height = area.Height - (2 * BorderWidth);
            batch.GUIDrawSprite(Texture, drawArea, m_L, Color);

            //Right Edge
            drawArea.X = area.Right - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_R, Color);
        }
Example #6
0
 public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
 {
     Color Color = (color == null) ? Color.White : color.Value;
     // ##### Draw Icon ##### //
     Rectangle drawArea = new Rectangle(
         area.Left,
         area.Top,
         m_Icon.Width,
         m_Icon.Height);
     batch.GUIDrawSprite(Texture, drawArea, m_Icon, Color);
 }
Example #7
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            Color background = new Color(32, 32, 32, 255);
            Color border = Color.LightGray;

            DrawCommon_FillBackground(spritebatch, background);

            if (Model.Texture != null)
            {
                Rectangle area = Model.ScreenArea;
                area.X += 1;
                area.Y += 1;
                area.Width -= 2;
                area.Height -= 2;
                Texture2D texture = Model.Texture;

                if (Model.StretchImage)
                {
                    spritebatch.GUIDrawSprite(Model.Texture, Model.ScreenArea);
                }
                else if (texture.Width <= area.Width && texture.Height <= area.Height)
                {
                    Point xy = Model.Centered ? new Point(
                        area.X + (area.Width - texture.Width) / 2,
                        area.Y + (area.Height - texture.Height) / 2) :
                        new Point(area.X, area.Y);
                    Rectangle dest = new Rectangle(
                        xy.X, xy.Y,
                        texture.Width,
                        texture.Height);
                    spritebatch.GUIDrawSprite(Model.Texture, dest);
                }
                else
                {
                    float reduce_value = 1f;
                    if (texture.Width >= texture.Height)
                        reduce_value = ((float)area.Width / texture.Width);
                    else
                        reduce_value = ((float)area.Height / texture.Height);
                    Point xy = Model.Centered ? new Point(
                        area.X + area.Width - (int)(texture.Width * reduce_value),
                        area.Y + area.Height - (int)(texture.Height * reduce_value)) :
                        new Point(area.X, area.Y);
                    Rectangle dest = new Rectangle(
                        xy.X, xy.Y,
                        (int)(texture.Width * reduce_value),
                        (int)(texture.Height * reduce_value));
                    spritebatch.GUIDrawSprite(Model.Texture, dest);
                }
            }

            DrawCommon_Border(spritebatch, border);
        }
Example #8
0
 public void Draw(YSpriteBatch spritebatch, YSpriteFont font, Rectangle area, string text, float font_size, FontJustification justification, Color color)
 {
     if (text != null && text != string.Empty)
     {
         // if (m_InternalCaption != text)
         {
             m_InternalCaption = text;
             m_InternalCaptionWithLineBreaks = font.BreakStringIntoLines(m_InternalCaption, area.Width, font_size);
         }
         spritebatch.DrawString(font, m_InternalCaptionWithLineBreaks, new Vector2(area.X, area.Y), font_size, new Vector2(area.Width, area.Height), color: color, justification: justification);
     }
 }
        public override void Render(YSpriteBatch batch, Rectangle destination, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;
            Rectangle drawArea = new Rectangle(destination.Left, destination.Top, m_edge.Width, m_edge.Height);

            batch.GUIDrawSprite(Texture, drawArea, m_edge, Color, SpriteEffects.FlipHorizontally);

            drawArea.X = destination.Right - m_edge.Width;
            batch.GUIDrawSprite(Texture, drawArea, m_edge, Color);

            drawArea.X = destination.Left + m_edge.Width;
            drawArea.Width = destination.Width - (2 * m_edge.Width);
            batch.GUIDrawSprite(Texture, drawArea, m_center, Color);
        }
Example #10
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            Color color = Model.IsEnabled ? Color.White : new Color(160, 160, 160, 255);

            Rendering.ARenderer renderer = Model.IsChecked ? m_Checked : m_Normal;
            renderer.Render(spritebatch, Model.ScreenArea, color);

            if (Model.Caption != null && Model.Caption != string.Empty)
            {
                if (m_WrappedText == null)
                    m_WrappedText = new WrappedText();
                Rectangle area = Model.ScreenArea;
                area.X += 16;
                area.Width -= 16;

                m_WrappedText.Draw(spritebatch, Font, area, Model.Caption, Model.FontSize, FontJustification.Left | FontJustification.Bottom, color);
            }
        }
Example #11
0
        public BaseCore()
        {
            m_SystemGraphics = System.Drawing.Graphics.FromHwnd(this.Window.Handle);
            Settings.ScreenDPI = new Vector2(m_SystemGraphics.DpiX / 96f, m_SystemGraphics.DpiY / 96f);

            m_Graphics = new GraphicsDeviceManager(this);
            m_Graphics.IsFullScreen = false;
            m_Graphics.PreferredBackBufferWidth = 256;
            m_Graphics.PreferredBackBufferHeight = 240;
            m_Graphics.SynchronizeWithVerticalRetrace = false;

            m_Input = new InterXLib.InputState();
            m_Input.Initialize(this.Window.Handle);
            m_Actions = new ActionBinder();

            m_SpriteBatch = new InterXLib.Display.YSpriteBatch(this);
            this.Components.Add(m_SpriteBatch);

            m_XGUI = new GUIManager();
            this.IsMouseVisible = true;
        }
Example #12
0
        public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;
            Rectangle drawArea;

            int x = 0;

            if (DrawTabs)
            {
                // draw bar to the left of the tab area
                if (m_TabSpaceBegin > 0)
                {
                    drawArea = new Rectangle(area.X, area.Y, m_TabSpaceBegin, area.Height);
                    batch.GUIDrawSprite(Texture, drawArea, m_Bar, Color);
                    x += m_TabSpaceBegin;
                }

                // draw the left tab area edge
                drawArea = new Rectangle(area.X + x, area.Y, m_TabAreaEdge.Width, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_TabAreaEdge, effects: SpriteEffects.FlipHorizontally);
                x += m_TabAreaEdge.Width;

                // draw the tab area
                drawArea = new Rectangle(area.X + x, area.Y, m_TabSpaceWidth - m_TabAreaEdge.Width * 2, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_TabArea, Color);
                x += drawArea.Width;

                // draw the right tab area edge
                drawArea = new Rectangle(area.X + x, area.Y, m_TabAreaEdge.Width, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_TabAreaEdge, Color);
                x += m_TabAreaEdge.Width;
            }

            // draw bar over remainder of width
            if (x < area.Width)
            {
                drawArea = new Rectangle(area.X + x, area.Y, area.Width - x, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_Bar, Color);
            }
        }
Example #13
0
 protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
 {
     if (m_WrappedText == null)
         m_WrappedText = new WrappedText();
     m_WrappedText.Draw(spritebatch, Font, Model.ScreenArea, Model.Caption, Model.FontSize, Model.Justification, Model.Color);
 }
Example #14
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            if (Model.TabCount == 0)
            {
                m_TabAreaRenderer.DrawTabs = false;
                m_TabAreaRenderer.Render(spritebatch, Model.ScreenArea);
            }
            else
            {
                int tab_space_begin = 8;
                int tab_space_end = 0;

                // draw the background of the tab space
                m_TabAreaUnderRenderer.Render(spritebatch, Model.ScreenArea);

                // get the width of the tabs
                TabAreas = new Rectangle[Model.TabCount];
                int x = tab_space_begin + 5;
                for (int i = 0; i < Model.TabCount; i++)
                {
                    string caption = Model.GetTabCaption(i);
                    Vector2 caption_size = Font.MeasureString(caption, 18f);
                    TabAreas[i] = new Rectangle(x, Model.ScreenArea.Y + 8, (int)caption_size.X + 16, 28);
                    x += TabAreas[i].Width;
                }

                m_TabAreaRenderer.DrawTabs = true;
                m_TabAreaRenderer.TabSpaceBegin = tab_space_begin;
                m_TabAreaRenderer.TabSpaceWidth = x - 4;
                m_TabAreaRenderer.Render(spritebatch, Model.ScreenArea);

                int up = 0, down = 20, hover = 30;

                for (int i = 0; i < Model.TabCount; i++)
                {
                    Color text_color;
                    Rendering.HorizontalSlidingRenderer renderer;
                    if (Model.SelectedTab == i)
                    {
                        renderer = m_TabSelectedRenderer;
                        text_color = new Color(up, up, up, 255);
                    }
                    else if (Model.HoverTab == i)
                    {
                        renderer = m_TabUnselectedHoverRenderer;
                        text_color = new Color(hover, hover, hover, 255);
                    }
                    else
                    {
                        renderer = m_TabUnselectedRenderer;
                        text_color = new Color(down, down, down, 255);
                    }
                    renderer.Render(spritebatch, TabAreas[i]);
                    spritebatch.DrawString(Font, Model.GetTabCaption(i), new Vector2(TabAreas[i].X + 8, TabAreas[i].Y + 4), 18f,
                        color: text_color);
                }
                tab_space_end = x + 16;
                if (Model.Caption != null)
                {
                    spritebatch.DrawString(Font, Model.Caption, new Vector2(tab_space_end, 11), 18f, color: Color.Black);
                }
            }
        }
Example #15
0
 public override void Draw(YSpriteBatch spritebatch, double frameTime)
 {
     UltimaEngine.UserInterface.Draw(frameTime);
 }
Example #16
0
 internal void Draw(YSpriteBatch spritebatch, double frameTime)
 {
     spritebatch.GUIClipRect = new Rectangle(0, 0, 1024, 768);
     if (m_CurrentScreen != null)
         m_CurrentScreen.GetView().Draw(spritebatch, frameTime);
 }
Example #17
0
 protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
 {
     // nothing to do here.
 }
Example #18
0
 public abstract void Draw(YSpriteBatch spritebatch, double frameTime);
Example #19
0
 public override void Draw(YSpriteBatch spritebatch, double frameTime)
 {
     View.IsometricRenderer.Draw(frameTime);
     UltimaEngine.UserInterface.Draw(frameTime);
 }
Example #20
0
 public abstract void Render(YSpriteBatch spritebatch, Rectangle area, Color? color = null);
Example #21
0
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            spritebatch.GUIClipRect_Push(Model.ScreenArea);

            Color background = new Color(96, 96, 96, 255);
            Color foreground = background * 1.2f;
            Color selected = Color.DarkGray;
            Color border = Color.LightGray;
            Color clrText = Color.White;

            DrawCommon_FillBackground(spritebatch, background);

            // if selection
            //      render selection rect
            spritebatch.DrawString(Font, Model.Value, new Vector2(Model.ScreenArea.X + 2, Model.ScreenArea.Y + 2), Model.FontSize, color: clrText);
            if (m_CursorVisible)
            {
                Vector2 cursor_pos = Vector2.Zero;
                if (Model.CursorPosition > 0)
                    cursor_pos = Font.MeasureString(Model.Value.Substring(0, Model.CursorPosition), Model.FontSize);
                Vector2 cursor_size = Font.MeasureString("|", Model.FontSize);
                spritebatch.DrawString(Font, "|", new Vector2(Model.ScreenArea.X + cursor_pos.X - cursor_size.X, Model.ScreenArea.Y + 2), Model.FontSize, color: clrText);
            }

            DrawCommon_Border(spritebatch, border);

            spritebatch.GUIClipRect_Pop();
        }