Exemple #1
0
        public override bool Draw(Batcher2D batcher, Point position, Vector3?hue = null)
        {
            Children[0].Draw(batcher, new Point(position.X + Children[0].X, position.Y + Children[0].Y));
            _rect.X      = position.X;
            _rect.Y      = position.Y;
            _rect.Width  = Width - 14;
            _rect.Height = Height;
            Rectangle scissor = ScissorStack.CalculateScissors(batcher.TransformMatrix, _rect);

            if (ScissorStack.PushScissors(scissor))
            {
                batcher.EnableScissorTest(true);
                int  height    = 0;
                int  maxheight = _scrollBar.Value + Height;
                bool drawOnly1 = true;

                position = _rect.Location;

                for (int i = 1; i < Children.Count; i++)
                {
                    Control child = Children[i];

                    if (!child.IsVisible)
                    {
                        continue;
                    }

                    child.Y = height - _scrollBar.Value /*+ (_isNormalScroll ? 20 : 0)*/;

                    if (height + child.Height <= _scrollBar.Value)
                    {
                        // do nothing
                    }
                    else if (height + child.Height <= maxheight)
                    {
                        child.Draw(batcher, new Point(position.X + child.X, position.Y + child.Y));
                    }
                    else
                    {
                        if (drawOnly1)
                        {
                            child.Draw(batcher, new Point(position.X + child.X, position.Y + child.Y));
                            drawOnly1 = false;
                        }
                    }

                    height += child.Height;
                }

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            return(true);
        }
Exemple #2
0
        public override bool Draw(Batcher2D batcher, int x, int y)
        {
            var scrollbar = Children[0];

            scrollbar.Draw(batcher, x + scrollbar.X, y + scrollbar.Y);

            Rectangle scissor = ScissorStack.CalculateScissors(batcher.TransformMatrix, x, y, Width - 14, Height);

            if (ScissorStack.PushScissors(scissor))
            {
                batcher.EnableScissorTest(true);
                int  height    = 0;
                int  maxheight = _scrollBar.Value + Height;
                bool drawOnly1 = true;


                for (int i = 1; i < Children.Count; i++)
                {
                    Control child = Children[i];

                    if (!child.IsVisible)
                    {
                        continue;
                    }

                    child.Y = height - _scrollBar.Value /*+ (_isNormalScroll ? 20 : 0)*/;

                    if (height + child.Height <= _scrollBar.Value)
                    {
                        // do nothing
                    }
                    else if (height + child.Height <= maxheight)
                    {
                        child.Draw(batcher, x + child.X, y + child.Y);
                    }
                    else
                    {
                        if (drawOnly1)
                        {
                            child.Draw(batcher, x + child.X, y + child.Y);
                            drawOnly1 = false;
                        }
                    }

                    height += child.Height;
                }

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            return(true);
        }
Exemple #3
0
        public override bool Draw(SpriteBatchUI spriteBatch, Point position, Vector3?hue = null)
        {
            Children[0].Draw(spriteBatch, new Point(position.X + Children[0].X, position.Y + Children[0].Y));
            _rect.X      = position.X;
            _rect.Y      = position.Y;
            _rect.Width  = Width;
            _rect.Height = Height;
            Rectangle scissor = ScissorStack.CalculateScissors(spriteBatch.TransformMatrix, _rect);

            if (ScissorStack.PushScissors(scissor))
            {
                spriteBatch.EnableScissorTest(true);
                int  height    = 0;
                int  maxheight = _scrollBar.Value + _scrollBar.Height;
                bool drawOnly1 = true;

                for (int i = 1; i < Children.Count; i++)
                {
                    GumpControl child = Children[i];

                    if (!child.IsVisible)
                    {
                        continue;
                    }
                    child.Y = height - _scrollBar.Value;

                    if (height + child.Height <= _scrollBar.Value)
                    {
                        // do nothing
                    }
                    else if (height + child.Height <= maxheight)
                    {
                        child.Draw(spriteBatch, new Point(position.X + child.X, position.Y + child.Y));
                    }
                    else
                    {
                        if (drawOnly1)
                        {
                            child.Draw(spriteBatch, new Point(position.X + child.X, position.Y + child.Y));
                            drawOnly1 = false;
                        }
                    }

                    height += child.Height;
                }

                spriteBatch.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            return(true);
        }
Exemple #4
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            Rectangle rectangle = ScissorStack.CalculateScissors(Matrix.Identity, x, y, Width, Height);

            if (ScissorStack.PushScissors(rectangle))
            {
                batcher.EnableScissorTest(true);

                ResetHueVector();

                if (Engine.Profile.Current != null && Engine.Profile.Current.UseXBR)
                {
                    // draw regular world
                    _xBR.SetSize(_scene.ViewportTexture.Width, _scene.ViewportTexture.Height);

                    batcher.End();

                    batcher.Begin(_xBR);
                    batcher.Draw2D(_scene.ViewportTexture, x, y, Width, Height, ref _hueVector);
                    batcher.End();

                    batcher.Begin();
                }
                else
                {
                    batcher.Draw2D(_scene.ViewportTexture, x, y, Width, Height, ref _hueVector);
                }


                // draw lights
                if (_scene.UseLights)
                {
                    batcher.SetBlendState(_blend);
                    batcher.Draw2D(_scene.Darkness, x, y, Width, Height, ref _hueVector);
                    batcher.SetBlendState(null);
                }

                // draw overheads
                _scene.DrawSelection(batcher, x, y);
                _scene.DrawOverheads(batcher, x, y);

                base.Draw(batcher, x, y);

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            return(true);
        }
Exemple #5
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (DoScissor)
            {
                ScissorStack.PushScissors(new Rectangle(x, y, Width, Height));
                batcher.EnableScissorTest(true);
            }
            else
            {
                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            return(true);
        }
Exemple #6
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            var scrollbar = Children[0];

            scrollbar.Draw(batcher, x + scrollbar.X, y + scrollbar.Y);

            Rectangle scissor = ScissorStack.CalculateScissors(Matrix.Identity, x + ScissorRectangle.X, y + ScissorRectangle.Y, (Width - 14) + ScissorRectangle.Width, Height + ScissorRectangle.Height);

            if (ScissorStack.PushScissors(scissor))
            {
                batcher.EnableScissorTest(true);
                int height = ScissorRectangle.Y;

                for (int i = 1; i < Children.Count; i++)
                {
                    Control child = Children[i];

                    if (!child.IsVisible)
                    {
                        continue;
                    }

                    child.Y = height - _scrollBar.Value;

                    if (height + child.Height <= _scrollBar.Value)
                    {
                        // do nothing
                    }
                    else
                    {
                        child.Draw(batcher, x + child.X, y + child.Y);
                    }

                    height += child.Height;
                }

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            return(true);
        }
Exemple #7
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ScrollBarBase scrollbar = (ScrollBarBase)Children[0];

            scrollbar.Draw(batcher, x + scrollbar.X, y + scrollbar.Y);

            Rectangle scissor = ScissorStack.CalculateScissors
                                (
                Matrix.Identity,
                x + ScissorRectangle.X,
                y + ScissorRectangle.Y,
                Width - 14 + ScissorRectangle.Width,
                Height + ScissorRectangle.Height
                                );

            if (ScissorStack.PushScissors(batcher.GraphicsDevice, scissor))
            {
                batcher.EnableScissorTest(true);

                for (int i = 1; i < Children.Count; i++)
                {
                    Control child = Children[i];

                    if (!child.IsVisible)
                    {
                        continue;
                    }

                    int finalY = y + child.Y - scrollbar.Value + ScissorRectangle.Y;

                    //if (finalY + child.Bounds.Height >= scissor.Y && finalY - child.Height < scissor.Bottom)
                    {
                        child.Draw(batcher, x + child.X, finalY);
                    }
                }

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors(batcher.GraphicsDevice);
            }

            return(true);
        }
Exemple #8
0
        public override void Draw(Graphics graphics, float parentAlpha)
        {
            Validate();

            if (transform)
            {
                ApplyTransform(graphics, ComputeTransform());
            }
            if (_firstWidget != null && _firstWidget.IsVisible())
            {
                var scissor = ScissorStack.CalculateScissors(stage?.Camera, graphics.Batcher.TransformMatrix,
                                                             _firstWidgetBounds);
                if (ScissorStack.PushScissors(scissor))
                {
                    graphics.Batcher.EnableScissorTest(true);
                    _firstWidget.Draw(graphics, parentAlpha * color.A);
                    graphics.Batcher.EnableScissorTest(false);
                    ScissorStack.PopScissors();
                }
            }

            if (_secondWidget != null && _secondWidget.IsVisible())
            {
                var scissor = ScissorStack.CalculateScissors(stage?.Camera, graphics.Batcher.TransformMatrix,
                                                             _secondWidgetBounds);
                if (ScissorStack.PushScissors(scissor))
                {
                    graphics.Batcher.EnableScissorTest(true);
                    _secondWidget.Draw(graphics, parentAlpha * color.A);
                    graphics.Batcher.EnableScissorTest(false);
                    ScissorStack.PopScissors();
                }
            }

            _style.Handle.Draw(graphics, _handleBounds.X, _handleBounds.Y, _handleBounds.Width, _handleBounds.Height,
                               new Color(color, (int)(color.A * parentAlpha)));

            if (transform)
            {
                ResetTransform(graphics);
            }
        }
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (IsDisposed)
            {
                return(false);
            }

            ResetHueVector();

            Rectangle scissor = ScissorStack.CalculateScissors
                                (
                Matrix.Identity,
                x,
                y,
                Width,
                Height
                                );

            if (ScissorStack.PushScissors(batcher.GraphicsDevice, scissor))
            {
                batcher.EnableScissorTest(true);
                base.Draw(batcher, x, y);

                _gameText.Draw
                (
                    batcher,
                    Width + ScrollX,
                    Height + ScrollY,
                    x,
                    y,
                    Width,
                    Height,
                    ScrollX,
                    ScrollY
                );

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors(batcher.GraphicsDevice);
            }

            return(true);
        }
Exemple #10
0
        public override void DebugRender(Graphics graphics)
        {
            if (transform)
            {
                ApplyTransform(graphics, ComputeTransform());
            }

            var scissor = ScissorStack.CalculateScissors(stage?.Camera, graphics.Batcher.TransformMatrix, _widgetAreaBounds);

            if (ScissorStack.PushScissors(scissor))
            {
                graphics.Batcher.EnableScissorTest(true);
                DebugRenderChildren(graphics, 1f);
                graphics.Batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            if (transform)
            {
                ResetTransform(graphics);
            }
        }
Exemple #11
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();

            var rect = ScissorStack.CalculateScissors(Matrix.Identity, x, y, Width, Height);

            if (ScissorStack.PushScissors(rect))
            {
                ShaderHuesTraslator.GetHueVector(ref _hueVector, 0, false, Alpha, true);

                batcher.EnableScissorTest(true);

                DrawInternal(batcher, x, y, ref _hueVector);
                base.Draw(batcher, x, y);

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();

                return(true);
            }

            return(false);
        }
Exemple #12
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);
            Rectangle scissor = ScissorStack.CalculateScissors(Matrix.Identity, x, y, Width, Height);

            if (ScissorStack.PushScissors(batcher.GraphicsDevice, scissor))
            {
                batcher.EnableScissorTest(true);
                RenderedText t         = _bookPage.renderedText;
                int          startpage = (ActivePage - 1) * 2;

                if (startpage < BookPageCount)
                {
                    int poy = _bookPage._pageCoords[startpage, 0], phy = _bookPage._pageCoords[startpage, 1];
                    _bookPage.DrawSelection(batcher, x + RIGHT_X, y + UPPER_MARGIN, poy, poy + phy);
                    t.Draw(batcher, x + RIGHT_X, y + UPPER_MARGIN, 0, poy, t.Width, phy);

                    if (startpage == _bookPage._caretPage)
                    {
                        if (_bookPage._caretPos.Y < poy + phy)
                        {
                            if (_bookPage._caretPos.Y >= poy)
                            {
                                if (_bookPage.HasKeyboardFocus)
                                {
                                    _bookPage.renderedCaret.Draw
                                    (
                                        batcher, _bookPage._caretPos.X + x + RIGHT_X,
                                        _bookPage._caretPos.Y + y + UPPER_MARGIN - poy, 0, 0,
                                        _bookPage.renderedCaret.Width, _bookPage.renderedCaret.Height
                                    );
                                }
                            }
                            else
                            {
                                _bookPage._caretPage = _bookPage.GetCaretPage();
                            }
                        }
                        else if (_bookPage._caretPos.Y <= _bookPage.Height)
                        {
                            if (_bookPage._caretPage + 2 < _bookPage._pagesChanged.Length)
                            {
                                _bookPage._focusPage = _bookPage._caretPage++;
                                SetActivePage(_bookPage._caretPage / 2 + 2);
                            }
                        }
                    }
                }

                startpage--;

                if (startpage > 0)
                {
                    int poy = _bookPage._pageCoords[startpage, 0], phy = _bookPage._pageCoords[startpage, 1];
                    _bookPage.DrawSelection(batcher, x + LEFT_X, y + UPPER_MARGIN, poy, poy + phy);
                    t.Draw(batcher, x + LEFT_X, y + UPPER_MARGIN, 0, poy, t.Width, phy);

                    if (startpage == _bookPage._caretPage)
                    {
                        if (_bookPage._caretPos.Y < poy + phy)
                        {
                            if (_bookPage._caretPos.Y >= poy)
                            {
                                if (_bookPage.HasKeyboardFocus)
                                {
                                    _bookPage.renderedCaret.Draw
                                    (
                                        batcher, _bookPage._caretPos.X + x + LEFT_X,
                                        _bookPage._caretPos.Y + y + UPPER_MARGIN - poy, 0, 0,
                                        _bookPage.renderedCaret.Width, _bookPage.renderedCaret.Height
                                    );
                                }
                            }
                            else if (_bookPage._caretPage > 0)
                            {
                                _bookPage._focusPage = _bookPage._caretPage--;
                                SetActivePage(_bookPage._caretPage / 2 + 1);
                            }
                        }
                        else if (_bookPage._caretPos.Y <= _bookPage.Height)
                        {
                            if (_bookPage._caretPage + 2 < _bookPage._pagesChanged.Length)
                            {
                                _bookPage._caretPage++;
                            }
                        }
                    }
                }

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors(batcher.GraphicsDevice);
            }

            return(true);
        }
Exemple #13
0
        public override void Draw(Graphics graphics, float parentAlpha)
        {
            if (_widget == null)
            {
                return;
            }

            Update();
            Validate();

            // setup transform for this group.
            if (transform)
            {
                ApplyTransform(graphics, ComputeTransform());
            }

            if (_scrollX)
            {
                _hKnobBounds.X = _hScrollBounds.X + (int)((_hScrollBounds.Width - _hKnobBounds.Width) * GetVisualScrollPercentX());
            }
            if (_scrollY)
            {
                _vKnobBounds.Y = _vScrollBounds.Y + (int)((_vScrollBounds.Height - _vKnobBounds.Height) * GetVisualScrollPercentY());
            }

            // calculate the widget's position depending on the scroll state and available widget area.
            float eleY = _widgetAreaBounds.Y;

            if (!_scrollY)
            {
                eleY -= _maxY;
            }
            else
            {
                eleY -= _visualAmountY;
            }

            float eleX = _widgetAreaBounds.Y;

            if (_scrollX)
            {
                eleX -= (int)_visualAmountX;
            }

            if (!_fadeScrollBars && _scrollbarsOnTop)
            {
                if (_scrollX && _hScrollOnBottom)
                {
                    var scrollbarHeight = 0f;
                    if (_style.HScrollKnob != null)
                    {
                        scrollbarHeight = _style.HScrollKnob.MinHeight;
                    }
                    if (_style.HScroll != null)
                    {
                        scrollbarHeight = Math.Max(scrollbarHeight, _style.HScroll.MinHeight);
                    }
                    eleY += scrollbarHeight;
                }
                if (_scrollY && !_vScrollOnRight)
                {
                    var scrollbarWidth = 0f;
                    if (_style.HScrollKnob != null)
                    {
                        scrollbarWidth = _style.HScrollKnob.MinWidth;
                    }
                    if (_style.HScroll != null)
                    {
                        scrollbarWidth = Math.Max(scrollbarWidth, _style.HScroll.MinWidth);
                    }
                    eleX += scrollbarWidth;
                }
            }

            _widget.SetPosition(eleX, eleY);

            if (_widget is ICullable)
            {
                var cull = new Rectangle(
                    (int)(-_widget.GetX() + _widgetAreaBounds.X),
                    (int)(-_widget.GetY() + _widgetAreaBounds.Y),
                    _widgetAreaBounds.Width,
                    _widgetAreaBounds.Height);
                ((ICullable)_widget).SetCullingArea(cull);
            }

            // draw the background
            var color = GetColor();

            color = new Color(color, (int)(color.A * parentAlpha));
            if (_style.Background != null)
            {
                _style.Background.Draw(graphics, 0, 0, GetWidth(), GetHeight(), color);
            }

            // caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
            // project those to screen coordinates for OpenGL to consume.
            var scissor = ScissorStack.CalculateScissors(stage?.Camera, graphics.Batcher.TransformMatrix, _widgetAreaBounds);

            if (ScissorStack.PushScissors(scissor))
            {
                graphics.Batcher.EnableScissorTest(true);
                DrawChildren(graphics, parentAlpha);
                graphics.Batcher.EnableScissorTest(false);
                ScissorStack.PopScissors();
            }

            // render scrollbars and knobs on top
            var alpha = (float)color.A;

            color.A = (byte)(alpha * (_fadeAlpha / _fadeAlphaSeconds));
            if (_scrollX && _scrollY)
            {
                if (_style.Corner != null)
                {
                    _style.Corner.Draw(graphics, _hScrollBounds.X + _hScrollBounds.Width, _hScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Y, color);
                }
            }
            if (_scrollX)
            {
                if (_style.HScroll != null)
                {
                    _style.HScroll.Draw(graphics, _hScrollBounds.X, _hScrollBounds.Y, _hScrollBounds.Width, _hScrollBounds.Height, color);
                }
                if (_style.HScrollKnob != null)
                {
                    _style.HScrollKnob.Draw(graphics, _hKnobBounds.X, _hKnobBounds.Y, _hKnobBounds.Width, _hKnobBounds.Height, color);
                }
            }
            if (_scrollY)
            {
                if (_style.VScroll != null)
                {
                    _style.VScroll.Draw(graphics, _vScrollBounds.X, _vScrollBounds.Y, _vScrollBounds.Width, _vScrollBounds.Height, color);
                }
                if (_style.VScrollKnob != null)
                {
                    _style.VScrollKnob.Draw(graphics, _vKnobBounds.X, _vKnobBounds.Y, _vKnobBounds.Width, _vKnobBounds.Height, color);
                }
            }

            if (transform)
            {
                ResetTransform(graphics);
            }
        }
Exemple #14
0
 /// <summary>
 /// Ends clipping begun by clipBegin(Batcher, float, float, float, float)
 /// </summary>
 /// <returns>The end.</returns>
 public void ClipEnd(Batcher batcher)
 {
     batcher.EnableScissorTest(false);
     ScissorStack.PopScissors();
 }
Exemple #15
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (_scene.ViewportTexture == null)
            {
                return(false);
            }

            Rectangle rectangle = ScissorStack.CalculateScissors(Matrix.Identity, x, y, Width, Height);

            if (ScissorStack.PushScissors(batcher.GraphicsDevice, rectangle))
            {
                batcher.EnableScissorTest(true);

                ResetHueVector();

                if (ProfileManager.Current != null && ProfileManager.Current.UseXBR)
                {
                    // draw regular world
                    if (_xBR == null)
                    {
                        _xBR = new XBREffect(batcher.GraphicsDevice);
                    }

                    _xBR.SetSize(_scene.ViewportTexture.Width, _scene.ViewportTexture.Height);

                    batcher.End();

                    batcher.Begin(_xBR);
                    batcher.Draw2D(_scene.ViewportTexture, x, y, Width, Height, ref _hueVector);
                    batcher.End();

                    batcher.Begin();
                }
                else
                {
                    batcher.Draw2D(_scene.ViewportTexture, x, y, Width, Height, ref _hueVector);
                }


                // draw lights
                // if (_scene.UseAltLights)
                // {
                //     batcher.SetBlendState(_altLightsBlend);
                //     _hueVector.Z = 0.5f;
                //     batcher.Draw2D(_scene.LightRenderTarget, x, y, Width, Height, ref _hueVector);
                //     _hueVector.Z = 0;
                //     batcher.SetBlendState(null);
                // }
                // else if (_scene.UseLights)
                // {
                //     batcher.SetBlendState(_darknessBlend);
                //     batcher.Draw2D(_scene.LightRenderTarget, x, y, Width, Height, ref _hueVector);
                //     batcher.SetBlendState(null);
                // }

                // draw overheads
                _scene.DrawSelection(batcher, x, y);
                _scene.DrawOverheads(batcher, x, y);

                base.Draw(batcher, x, y);

                batcher.EnableScissorTest(false);
                ScissorStack.PopScissors(batcher.GraphicsDevice);
            }

            return(true);
        }