예제 #1
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                var texture0 = GumpsLoader.Instance.GetGumpTexture((ushort)(_graphic + 0), out var bounds0);
                var texture1 = GumpsLoader.Instance.GetGumpTexture((ushort)(_graphic + 1), out var bounds1);
                var texture2 = GumpsLoader.Instance.GetGumpTexture((ushort)(_graphic + 2), out var bounds2);

                Vector3 hueVector = ShaderHueTranslator.GetHueVector
                                    (
                    0,
                    false,
                    Alpha,
                    true
                                    );

                int middleWidth = Width - bounds0.Width - bounds2.Width;

                batcher.Draw
                (
                    texture0,
                    new Vector2(x, y),
                    bounds0,
                    hueVector
                );

                batcher.DrawTiled
                (
                    texture1,
                    new Rectangle
                    (
                        x + bounds0.Width,
                        y,
                        middleWidth,
                        bounds1.Height
                    ),
                    bounds1,
                    hueVector
                );

                batcher.Draw
                (
                    texture2,
                    new Vector2(x + Width - bounds2.Width, y),
                    bounds2,
                    hueVector
                );

                return(base.Draw(batcher, x, y));
            }
예제 #2
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            //batcher.SetBlendState(_checkerBlend.Value);
            //batcher.SetStencil(_checkerStencil.Value);

            //batcher.Draw2D(TransparentTexture, new Rectangle(position.X, position.Y, Width, Height), Vector3.Zero /*ShaderHueTranslator.GetHueVector(0, false, 0.5f, false)*/);

            //batcher.SetBlendState(null);
            //batcher.SetStencil(null);

            //return true;

            Vector3 hueVector = ShaderHueTranslator.GetHueVector(0, false, 0.5f);

            //batcher.SetStencil(_checkerStencil.Value);
            batcher.Draw
            (
                SolidColorTextureCache.GetTexture(Color.Black),
                new Rectangle
                (
                    x,
                    y,
                    Width,
                    Height
                ),
                hueVector
            );

            //batcher.SetStencil(null);
            return(true);
        }
        public static void Draw(UltimaBatcher2D batcher, Vector2 pos, ushort hue = 0)
        {
            if (_texture != null)
            {
                pos.X -= _width >> 1;
                pos.Y -= _height >> 1;

                Vector3 hueVector = new Vector3();

                if (hue == 0)
                {
                    hueVector.X = 0;
                    hueVector.Y = 0f;
                }
                else
                {
                    hueVector.X = hue;
                    hueVector.Y = 1f;
                }

                batcher.SetStencil(_stencil.Value);
                batcher.Draw
                (
                    _texture,
                    pos,
                    hueVector
                );
                batcher.SetStencil(null);
            }
        }
예제 #4
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                Vector3 hueVector = ShaderHueTranslator.GetHueVector
                                    (
                    0,
                    false,
                    _alpha / 255f,
                    true
                                    );

                var texture = GumpsLoader.Instance.GetGumpTexture(Graphic, out var bounds);

                if (texture != null)
                {
                    batcher.Draw
                    (
                        texture,
                        new Vector2(x, y),
                        bounds,
                        hueVector
                    );

                    if (ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.BuffBarTime)
                    {
                        _gText.Draw(batcher, x - 3, y + bounds.Height / 2 - 3, hueVector.Z);
                    }
                }

                return(true);
            }
예제 #5
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                if (!string.IsNullOrWhiteSpace(_label.Text) && MouseIsOver)
                {
                    Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

                    batcher.Draw
                    (
                        SolidColorTextureCache.GetTexture(Color.Gray),
                        new Rectangle
                        (
                            x + 2,
                            y + 5,
                            Width - 4,
                            Height - 10
                        ),
                        hueVector
                    );
                }

                base.Draw(batcher, x, y);

                if (_entry.Items != null && _entry.Items.Count != 0)
                {
                    _moreMenuLabel.Draw(batcher, x + Width - _moreMenuLabel.Width, y + (Height >> 1) - (_moreMenuLabel.Height >> 1) - 1);
                }

                return(true);
            }
예제 #6
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (IsDisposed)
            {
                return(false);
            }

            if (MouseIsOver)
            {
                Vector3 hueVector = ShaderHueTranslator.GetHueVector
                                    (
                    0,
                    false,
                    Alpha,
                    true
                                    );

                batcher.Draw
                (
                    _texture,
                    new Vector2(x, y),
                    new Rectangle(0, 0, Width, Height),
                    hueVector
                );
            }

            return(base.Draw(batcher, x, y));
        }
예제 #7
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

            batcher.Draw
            (
                backgroundTexture,
                new Rectangle
                (
                    x,
                    y,
                    Width,
                    Height
                ),
                hueVector
            );

            batcher.DrawRectangle
            (
                SolidColorTextureCache.GetTexture(Color.Gray),
                x,
                y,
                Width,
                Height,
                hueVector
            );

            base.Draw(batcher, x, y);

            return(true);
        }
예제 #8
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

            var textureFlag       = GumpsLoader.Instance.GetGumpTexture(BUTTON_FLAG, out var boundsFlag);
            var textureButtonUp   = GumpsLoader.Instance.GetGumpTexture(BUTTON_UP, out var boundsButtonUp);
            var textureButtonDown = GumpsLoader.Instance.GetGumpTexture(BUTTON_DOWN, out var boundsButtonDown);


            if (MaxValue != MinValue && textureFlag != null)
            {
                batcher.Draw
                (
                    textureFlag,
                    new Vector2(x, y + _sliderPosition),
                    boundsFlag,
                    hueVector
                );
            }

            if (_showButtons)
            {
                if (textureButtonUp != null)
                {
                    batcher.Draw
                    (
                        textureButtonUp,
                        new Vector2(x, y),
                        boundsButtonUp,
                        hueVector
                    );
                }

                if (textureButtonDown != null)
                {
                    batcher.Draw
                    (
                        textureButtonDown,
                        new Vector2(x, y + Height),
                        boundsButtonDown,
                        hueVector
                    );
                }
            }

            return(base.Draw(batcher, x, y));
        }
예제 #9
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                var texture = GumpsLoader.Instance.GetGumpTexture(_graphic, out var bounds);

                Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

                if (_tiled)
                {
                    batcher.DrawTiled
                    (
                        texture,
                        new Rectangle
                        (
                            x,
                            y,
                            Width,
                            Height
                        ),
                        new Rectangle
                        (
                            bounds.X + _rect.X,
                            bounds.Y + _rect.Y,
                            _rect.Width,
                            _rect.Height
                        ),
                        hueVector
                    );
                }
                else
                {
                    batcher.Draw
                    (
                        texture,
                        new Rectangle
                        (
                            x,
                            y,
                            Width,
                            Height
                        ),
                        new Rectangle
                        (
                            bounds.X + _rect.X,
                            bounds.Y + _rect.Y,
                            _rect.Width,
                            _rect.Height
                        ),
                        hueVector
                    );
                }

                return(base.Draw(batcher, x, y));
            }
예제 #10
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            if (Var != InfoBarVars.NameNotoriety && ProfileManager.CurrentProfile.InfoBarHighlightType == 1 && _warningLinesHue != 0x0481)
            {
                Vector3 hueVector = ShaderHueTranslator.GetHueVector(_warningLinesHue);

                batcher.Draw
                (
                    SolidColorTextureCache.GetTexture(Color.White),
                    new Rectangle
                    (
                        _data.ScreenCoordinateX,
                        _data.ScreenCoordinateY,
                        _data.Width,
                        2
                    ),
                    hueVector
                );

                batcher.Draw
                (
                    SolidColorTextureCache.GetTexture(Color.White),
                    new Rectangle
                    (
                        _data.ScreenCoordinateX,
                        _data.ScreenCoordinateY + Parent.Height - 2,
                        _data.Width,
                        2
                    ),
                    hueVector
                );
            }

            return(true);
        }
예제 #11
0
                public override bool Draw(UltimaBatcher2D batcher, int x, int y)
                {
                    if (_graphic != 0)
                    {
                        var texture = ArtLoader.Instance.GetStaticTexture(_graphic, out var bounds);
                        var rect    = ArtLoader.Instance.GetRealArtBounds(_graphic);

                        Vector3 hueVector = ShaderHueTranslator.GetHueVector(_hue, _partial, 1f);

                        Point originalSize = new Point(Width, Height);
                        Point point        = new Point();

                        if (rect.Width < Width)
                        {
                            originalSize.X = rect.Width;
                            point.X        = (Width >> 1) - (originalSize.X >> 1);
                        }

                        if (rect.Height < Height)
                        {
                            originalSize.Y = rect.Height;
                            point.Y        = (Height >> 1) - (originalSize.Y >> 1);
                        }

                        batcher.Draw
                        (
                            texture,
                            new Rectangle
                            (
                                x + point.X,
                                y + point.Y,
                                originalSize.X,
                                originalSize.Y
                            ),
                            new Rectangle
                            (
                                bounds.X + rect.X,
                                bounds.Y + rect.Y,
                                rect.Width,
                                rect.Height
                            ),
                            hueVector
                        );
                    }

                    return(base.Draw(batcher, x, y));
                }
예제 #12
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            Vector3 hueVector = ShaderHueTranslator.GetHueVector(Hue, false, Alpha);

            batcher.Draw
            (
                SolidColorTextureCache.GetTexture(Color.Black),
                new Rectangle
                (
                    x,
                    y,
                    Width,
                    Height
                ),
                hueVector
            );

            return(true);
        }
예제 #13
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            Vector3 hueVector = ShaderHueTranslator.GetHueVector(0, false, Alpha);

            batcher.Draw
            (
                _texture,
                new Rectangle
                (
                    x,
                    y,
                    Width,
                    Height
                ),
                hueVector
            );

            return(true);
        }
예제 #14
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                if (_graphic != 0)
                {
                    var texture = ArtLoader.Instance.GetStaticTexture(_graphic, out var bounds);

                    Vector3 hueVector = ShaderHueTranslator.GetHueVector(_hue, _isPartial, 1f);

                    batcher.Draw
                    (
                        texture,
                        new Vector2(x, y),
                        bounds,
                        hueVector
                    );
                }

                return(base.Draw(batcher, x, y));
            }
예제 #15
0
        protected static void DrawLand(UltimaBatcher2D batcher, ushort graphic, int x, int y, Vector3 hue, float depth)
        {
            var texture = ArtLoader.Instance.GetLandTexture(graphic, out var bounds);

            if (texture != null)
            {
                batcher.Draw
                (
                    texture,
                    new Vector2(x, y),
                    bounds,
                    hue,
                    0f,
                    Vector2.Zero,
                    1f,
                    SpriteEffects.None,
                    depth + 0.5f
                );
            }
        }
예제 #16
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

            batcher.Draw
            (
                _mapTexture,
                new Rectangle(x + _hit.X, y + _hit.Y, _hit.Width, _hit.Height),
                hueVector
            );

            var texture = SolidColorTextureCache.GetTexture(Color.White);

            for (int i = 0; i < _container.Count; i++)
            {
                // HACK: redraw because pins are drawn when calling base.Draw(batcher, x, y);
                _container[i].Draw(batcher, x + _container[i].X, y + _container[i].Y);

                if (i + 1 >= _container.Count)
                {
                    break;
                }

                Control c0 = _container[i];
                Control c1 = _container[i + 1];

                batcher.DrawLine
                (
                    texture,
                    new Vector2(c0.ScreenCoordinateX, c0.ScreenCoordinateY),
                    new Vector2(c1.ScreenCoordinateX, c1.ScreenCoordinateY),
                    hueVector,
                    1
                );
            }

            return(true);
        }
예제 #17
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (DrawBackgroundCurrentIndex && MouseIsOver && !string.IsNullOrWhiteSpace(Text))
            {
                Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

                batcher.Draw
                (
                    SolidColorTextureCache.GetTexture(Color.Gray),
                    new Rectangle
                    (
                        x,
                        y + 2,
                        Width - 4,
                        Height - 4
                    ),
                    hueVector
                );
            }

            return(base.Draw(batcher, x, y));
        }
예제 #18
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            Vector3 hueVector = ShaderHueTranslator.GetHueVector(_hue, _isPartial, 1f);

            var texture = ArtLoader.Instance.GetStaticTexture(_graphic, out var bounds);

            if (texture != null)
            {
                batcher.Draw
                (
                    texture,
                    new Vector2(x + _tileX, y + _tileY),
                    bounds,
                    hueVector
                );

                return(true);
            }

            return(false);
        }
예제 #19
0
        protected static void DrawStatic(UltimaBatcher2D batcher, ushort graphic, int x, int y, Vector3 hue, float depth)
        {
            var texture = ArtLoader.Instance.GetStaticTexture(graphic, out var bounds);

            if (texture != null)
            {
                ref UOFileIndex index = ref ArtLoader.Instance.GetValidRefEntry(graphic + 0x4000);

                x -= index.Width;
                y -= index.Height;

                batcher.Draw
                (
                    texture,
                    new Vector2(x, y),
                    bounds,
                    hue,
                    0f,
                    Vector2.Zero,
                    1f,
                    SpriteEffects.None,
                    depth + 0.5f
                );
            }
예제 #20
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (Children.Count != 0)
            {
                Children[0].Draw(batcher, x, y);
            }

            Vector3 hueVector = ShaderHueTranslator.GetHueVector(Hue);

            batcher.Draw
            (
                SolidColorTextureCache.GetTexture(Color.White),
                new Rectangle
                (
                    x + 3,
                    y + 3,
                    Width - 6,
                    Height - 6
                ),
                hueVector
            );

            return(true);
        }
예제 #21
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (Height <= 0 || !IsVisible)
            {
                return(false);
            }

            Vector3 hueVector = ShaderHueTranslator.GetHueVector(0);

            var textureUp0         = GumpsLoader.Instance.GetGumpTexture(BUTTON_UP_0, out var boundsUp0);
            var textureUp1         = GumpsLoader.Instance.GetGumpTexture(BUTTON_UP_1, out var boundsUp1);
            var textureDown0       = GumpsLoader.Instance.GetGumpTexture(BUTTON_DOWN_0, out var boundsDown0);
            var textureDown1       = GumpsLoader.Instance.GetGumpTexture(BUTTON_DOWN_1, out var boundsDown1);
            var textureBackground0 = GumpsLoader.Instance.GetGumpTexture(BACKGROUND_0, out var boundsBackground0);
            var textureBackground1 = GumpsLoader.Instance.GetGumpTexture(BACKGROUND_1, out var boundsBackground1);
            var textureBackground2 = GumpsLoader.Instance.GetGumpTexture(BACKGROUND_2, out var boundsBackground2);
            var textureSlider      = GumpsLoader.Instance.GetGumpTexture(SLIDER, out var boundsSlider);

            // draw scrollbar background
            int middleHeight = Height - boundsUp0.Height - boundsDown0.Height - boundsBackground0.Height - boundsBackground2.Height;

            if (middleHeight > 0)
            {
                batcher.Draw
                (
                    textureBackground0,
                    new Vector2(x, y + boundsUp0.Height),
                    boundsBackground0,
                    hueVector
                );

                batcher.DrawTiled
                (
                    textureBackground1,
                    new Rectangle
                    (
                        x,
                        y + boundsUp1.Height + boundsBackground0.Height,
                        boundsBackground0.Width,
                        middleHeight
                    ),
                    boundsBackground1,
                    hueVector
                );

                batcher.Draw
                (
                    textureBackground2,
                    new Vector2(x, y + Height - boundsDown0.Height - boundsBackground2.Height),
                    boundsBackground2,
                    hueVector
                );
            }
            else
            {
                middleHeight = Height - boundsUp0.Height - boundsDown0.Height;

                batcher.DrawTiled
                (
                    textureBackground1,
                    new Rectangle
                    (
                        x,
                        y + boundsUp0.Height,
                        boundsBackground0.Width,
                        middleHeight
                    ),
                    boundsBackground1,
                    hueVector
                );
            }

            // draw up button
            if (_btUpClicked)
            {
                batcher.Draw
                (
                    textureUp1,
                    new Vector2(x, y),
                    boundsUp1,
                    hueVector
                );
            }
            else
            {
                batcher.Draw
                (
                    textureUp0,
                    new Vector2(x, y),
                    boundsUp0,
                    hueVector
                );
            }

            // draw down button
            if (_btDownClicked)
            {
                batcher.Draw
                (
                    textureDown1,
                    new Vector2(x, y + Height - boundsDown0.Height),
                    boundsDown1,
                    hueVector
                );
            }
            else
            {
                batcher.Draw
                (
                    textureDown0,
                    new Vector2(x, y + Height - boundsDown0.Height),
                    boundsDown0,
                    hueVector
                );
            }

            // draw slider
            if (MaxValue > MinValue && middleHeight > 0)
            {
                batcher.Draw
                (
                    textureSlider,
                    new Vector2
                    (
                        x + ((boundsBackground0.Width - boundsSlider.Width) >> 1),
                        y + boundsUp0.Height + _sliderPosition
                    ),
                    boundsSlider,
                    hueVector
                );
            }

            return(base.Draw(batcher, x, y));
        }
예제 #22
0
        private void DrawHealthLine(UltimaBatcher2D batcher, Entity entity, int x, int y, bool passive)
        {
            if (entity == null)
            {
                return;
            }

            int per = BAR_WIDTH * entity.HitsPercentage / 100;

            Mobile mobile = entity as Mobile;


            float  alpha = passive ? 0.5f : 1.0f;
            ushort hue   = mobile != null?Notoriety.GetHue(mobile.NotorietyFlag) : Notoriety.GetHue(NotorietyFlag.Gray);

            Vector3 hueVec = ShaderHueTranslator.GetHueVector(hue, false, alpha);

            if (mobile == null)
            {
                y += 22;
            }


            const int MULTIPLER = 1;

            var texture = GumpsLoader.Instance.GetGumpTexture(BACKGROUND_GRAPHIC, out var bounds);


            batcher.Draw
            (
                texture,
                new Rectangle
                (
                    x,
                    y,
                    bounds.Width * MULTIPLER,
                    bounds.Height * MULTIPLER
                ),
                bounds,
                hueVec
            );


            hueVec.X = 0x21;


            if (entity.Hits != entity.HitsMax || entity.HitsMax == 0)
            {
                int offset = 2;

                if (per >> 2 == 0)
                {
                    offset = per;
                }

                texture = GumpsLoader.Instance.GetGumpTexture(HP_GRAPHIC, out bounds);

                batcher.DrawTiled
                (
                    texture,
                    new Rectangle
                    (
                        x + per * MULTIPLER - offset,
                        y,
                        (BAR_WIDTH - per) * MULTIPLER - offset / 2,
                        bounds.Height * MULTIPLER
                    ),
                    bounds,
                    hueVec
                );
            }

            hue = 90;

            if (per > 0)
            {
                if (mobile != null)
                {
                    if (mobile.IsPoisoned)
                    {
                        hue = 63;
                    }
                    else if (mobile.IsYellowHits)
                    {
                        hue = 53;
                    }
                }

                hueVec.X = hue;

                texture = GumpsLoader.Instance.GetGumpTexture(HP_GRAPHIC, out bounds);

                batcher.DrawTiled
                (
                    texture,
                    new Rectangle
                    (
                        x,
                        y,
                        per * MULTIPLER,
                        bounds.Height * MULTIPLER
                    ),
                    bounds,
                    hueVec
                );
            }
        }
예제 #23
0
            internal void DrawSelection(UltimaBatcher2D batcher, int x, int y, int starty, int endy)
            {
                Vector3 hueVector = ShaderHueTranslator.GetHueVector(0, false, 0.5f);

                int selectStart = Math.Min(Stb.SelectStart, Stb.SelectEnd);
                int selectEnd   = Math.Max(Stb.SelectStart, Stb.SelectEnd);

                if (selectStart < selectEnd)
                {
                    MultilinesFontInfo info = _rendererText.GetInfo();

                    int drawY = 1;
                    int start = 0;

                    while (info != null && selectStart < selectEnd)
                    {
                        // ok we are inside the selection
                        if (selectStart >= start && selectStart < start + info.CharCount)
                        {
                            int startSelectionIndex = selectStart - start;

                            // calculate offset x
                            int drawX = 0;

                            for (int i = 0; i < startSelectionIndex; i++)
                            {
                                drawX += _rendererText.GetCharWidth(info.Data[i].Item);
                            }

                            // selection is gone. Bye bye
                            if (selectEnd >= start && selectEnd < start + info.CharCount)
                            {
                                int count = selectEnd - selectStart;

                                int endX = 0;

                                // calculate width
                                for (int k = 0; k < count; k++)
                                {
                                    endX += _rendererText.GetCharWidth(info.Data[startSelectionIndex + k].Item);
                                }

                                if (drawY >= starty && drawY <= endy)
                                {
                                    batcher.Draw
                                    (
                                        SolidColorTextureCache.GetTexture(SELECTION_COLOR),
                                        new Rectangle
                                        (
                                            x + drawX,
                                            y + drawY - starty,
                                            endX,
                                            info.MaxHeight + 1
                                        ),
                                        hueVector
                                    );
                                }

                                break;
                            }


                            // do the whole line
                            if (drawY >= starty && drawY <= endy)
                            {
                                batcher.Draw
                                (
                                    SolidColorTextureCache.GetTexture(SELECTION_COLOR),
                                    new Rectangle
                                    (
                                        x + drawX,
                                        y + drawY - starty,
                                        info.Width - drawX,
                                        info.MaxHeight + 1
                                    ),
                                    hueVector
                                );
                            }

                            // first selection is gone. M
                            selectStart = start + info.CharCount;
                        }

                        start += info.CharCount;
                        drawY += info.MaxHeight;
                        info   = info.Next;
                    }
                }
            }
예제 #24
0
        private void DrawInternal(UltimaBatcher2D batcher, int x, int y, Vector3 color)
        {
            var texture0 = GetTexture(0, out var bounds0);
            var texture1 = GetTexture(1, out var bounds1);
            var texture2 = GetTexture(2, out var bounds2);
            var texture3 = GetTexture(3, out var bounds3);
            var texture4 = GetTexture(4, out var bounds4);
            var texture5 = GetTexture(5, out var bounds5);
            var texture6 = GetTexture(6, out var bounds6);
            var texture7 = GetTexture(7, out var bounds7);
            var texture8 = GetTexture(8, out var bounds8);

            int offsetTop    = Math.Max(bounds0.Height, bounds2.Height) - bounds1.Height;
            int offsetBottom = Math.Max(bounds5.Height, bounds7.Height) - bounds6.Height;
            int offsetLeft   = Math.Abs(Math.Max(bounds0.Width, bounds5.Width) - bounds2.Width);
            int offsetRight  = Math.Max(bounds2.Width, bounds7.Width) - bounds4.Width;



            if (texture0 != null)
            {
                batcher.Draw
                (
                    texture0,
                    new Vector2(x, y),
                    bounds0,
                    color
                );
            }

            if (texture1 != null)
            {
                batcher.DrawTiled
                (
                    texture1,
                    new Rectangle
                    (
                        x + bounds0.Width,
                        y,
                        Width - bounds0.Width - bounds2.Width,
                        bounds1.Height
                    ),
                    bounds1,
                    color
                );
            }

            if (texture2 != null)
            {
                batcher.Draw
                (
                    texture2,
                    new Vector2(x + (Width - bounds2.Width), y + offsetTop),
                    bounds2,
                    color
                );
            }

            if (texture3 != null)
            {
                batcher.DrawTiled
                (
                    texture3,
                    new Rectangle
                    (
                        x,
                        y + bounds0.Height,
                        bounds3.Width,
                        Height - bounds0.Height - bounds5.Height
                    ),
                    bounds3,
                    color
                );
            }

            if (texture4 != null)
            {
                batcher.DrawTiled
                (
                    texture4,
                    new Rectangle
                    (
                        x + (Width - bounds4.Width),
                        y + bounds2.Height,
                        bounds4.Width,
                        Height - bounds2.Height - bounds7.Height
                    ),
                    bounds4,
                    color
                );
            }

            if (texture5 != null)
            {
                batcher.Draw
                (
                    texture5,
                    new Vector2(x, y + (Height - bounds5.Height)),
                    bounds5,
                    color
                );
            }

            if (texture6 != null)
            {
                batcher.DrawTiled
                (
                    texture6,
                    new Rectangle
                    (
                        x + bounds5.Width,
                        y + (Height - bounds6.Height - offsetBottom),
                        Width - bounds5.Width - bounds7.Width,
                        bounds6.Height
                    ),
                    bounds6,
                    color
                );
            }

            if (texture7 != null)
            {
                batcher.Draw
                (
                    texture7,
                    new Vector2(x + (Width - bounds7.Width), y + (Height - bounds7.Height)),
                    bounds7,
                    color
                );
            }

            if (texture8 != null)
            {
                batcher.DrawTiled
                (
                    texture8,
                    new Rectangle
                    (
                        x + bounds0.Width,
                        y + bounds0.Height,
                        (Width - bounds0.Width - bounds2.Width) + (offsetLeft + offsetRight),
                        Height - bounds2.Height - bounds7.Height
                    ),
                    bounds8,
                    color
                );
            }
        }
예제 #25
0
        private static void DrawInternal
        (
            UltimaBatcher2D batcher,
            Mobile owner,
            Item entity,
            int x,
            int y,
            Vector3 hueVec,
            bool mirror,
            byte frameIndex,
            bool hasShadow,
            ushort id,
            byte animGroup,
            byte dir,
            bool isHuman,
            bool isParent,
            bool isMount,
            bool forceUOP,
            float depth,
            sbyte mountOffset,
            ushort overridedHue,
            bool charIsSitting
        )
        {
            if (id >= Constants.MAX_ANIMATIONS_DATA_INDEX_COUNT || owner == null)
            {
                return;
            }

            ushort hueFromFile = overridedHue;

            AnimationDirection direction = AnimationsLoader.Instance.GetBodyAnimationGroup
                                           (
                ref id,
                ref animGroup,
                ref hueFromFile,
                isParent,
                forceUOP
                                           )
                                           .Direction[dir];

            if (direction == null || direction.Address == -1 || direction.FileIndex == -1)
            {
                if (!(charIsSitting && entity == null && !hasShadow))
                {
                    return;
                }
            }

            if (direction == null || (direction.FrameCount == 0 || direction.SpriteInfos == null) && !AnimationsLoader.Instance.LoadAnimationFrames(id, animGroup, dir, ref direction))
            {
                if (!(charIsSitting && entity == null && !hasShadow))
                {
                    return;
                }
            }

            if (direction == null)
            {
                return;
            }

            int fc = direction.FrameCount;

            if (fc > 0 && frameIndex >= fc)
            {
                frameIndex = (byte)(fc - 1);
            }
            else if (frameIndex < 0)
            {
                frameIndex = 0;
            }

            if (frameIndex < direction.FrameCount)
            {
                ref var spriteInfo = ref direction.SpriteInfos[frameIndex % direction.FrameCount];

                if (spriteInfo.Texture == null)
                {
                    if (!(charIsSitting && entity == null && !hasShadow))
                    {
                        return;
                    }

                    goto SKIP;
                }

                if (mirror)
                {
                    x -= spriteInfo.UV.Width - spriteInfo.Center.X;
                }
                else
                {
                    x -= spriteInfo.Center.X;
                }

                y -= spriteInfo.UV.Height + spriteInfo.Center.Y;

SKIP:

                if (hasShadow)
                {
                    batcher.DrawShadow(spriteInfo.Texture, new Vector2(x, y), spriteInfo.UV, mirror, depth);
                }
                else
                {
                    ushort hue        = overridedHue;
                    bool   partialHue = false;

                    if (hue == 0)
                    {
                        hue        = entity?.Hue ?? owner.Hue;
                        partialHue = !isMount && entity != null && entity.ItemData.IsPartialHue;

                        if ((hue & 0x8000) != 0)
                        {
                            partialHue = true;
                            hue       &= 0x7FFF;
                        }

                        if (hue == 0)
                        {
                            hue = hueFromFile;

                            if (hue == 0 && _equipConvData.HasValue)
                            {
                                hue = _equipConvData.Value.Color;
                            }

                            partialHue = false;
                        }
                    }

                    hueVec = ShaderHueTranslator.GetHueVector(hue, partialHue, hueVec.Z);

                    if (spriteInfo.Texture != null)
                    {
                        Vector2   pos  = new Vector2(x, y);
                        Rectangle rect = spriteInfo.UV;

                        if (charIsSitting)
                        {
                            Vector3 mod = CalculateSitAnimation(y, entity, isHuman, ref spriteInfo);

                            batcher.DrawCharacterSitted
                            (
                                spriteInfo.Texture,
                                pos,
                                rect,
                                mod,
                                hueVec,
                                mirror,
                                depth + 1f
                            );
                        }
                        else
                        {
                            //bool isMounted = isHuman && owner.IsMounted;


                            //int diffX = spriteInfo.UV.Width /*- spriteInfo.Center.X*/;

                            //if (isMounted)
                            //{
                            //if (mountOffset != 0)
                            //{
                            //    mountOffset += 10;
                            //}
                            //else
                            //{
                            //mountOffset = (sbyte)Math.Abs(spriteInfo.Center.Y);
                            //}
                            //}

                            //var flags = AnimationsLoader.Instance.DataIndex[id].Flags;
                            //if (AnimationsLoader.Instance.DataIndex[id].Type == ANIMATION_GROUPS_TYPE.HUMAN)
                            //{

                            //}


                            int diffY = (spriteInfo.UV.Height + spriteInfo.Center.Y) - mountOffset;

                            //if (owner.Serial == World.Player.Serial && entity == null)
                            //{

                            //}

                            int value = /*!isMounted && diffX <= 44 ? spriteInfo.UV.Height * 2 :*/ Math.Max(1, diffY);
                            int count = Math.Max((spriteInfo.UV.Height / value) + 1, 2);

                            rect.Height = Math.Min(value, rect.Height);
                            int remains = spriteInfo.UV.Height - rect.Height;

                            int tiles = (byte)owner.Direction % 2 == 0 ? 2 : 2;
                            //tiles = 999;

                            for (int i = 0; i < count; ++i)
                            {
                                //hueVec.Y = 1;
                                //hueVec.X = 0x44 + (i * 20);

                                batcher.Draw
                                (
                                    spriteInfo.Texture,
                                    pos,
                                    rect,
                                    hueVec,
                                    0f,
                                    Vector2.Zero,
                                    1f,
                                    mirror ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                                    depth + 1f + (i * tiles)
                                    //depth + (i * tiles) + (owner.PriorityZ * 0.001f)
                                );

                                pos.Y      += rect.Height;
                                rect.Y     += rect.Height;
                                rect.Height = remains; // Math.Min(value, remains);
                                remains    -= rect.Height;
                            }
                        }

                        int xx = -spriteInfo.Center.X;
                        int yy = -(spriteInfo.UV.Height + spriteInfo.Center.Y + 3);

                        if (mirror)
                        {
                            xx = -(spriteInfo.UV.Width - spriteInfo.Center.X);
                        }

                        if (xx < owner.FrameInfo.X)
                        {
                            owner.FrameInfo.X = xx;
                        }

                        if (yy < owner.FrameInfo.Y)
                        {
                            owner.FrameInfo.Y = yy;
                        }

                        if (owner.FrameInfo.Width < xx + spriteInfo.UV.Width)
                        {
                            owner.FrameInfo.Width = xx + spriteInfo.UV.Width;
                        }

                        if (owner.FrameInfo.Height < yy + spriteInfo.UV.Height)
                        {
                            owner.FrameInfo.Height = yy + spriteInfo.UV.Height;
                        }
                    }

                    if (entity != null && entity.ItemData.IsLight)
                    {
                        Client.Game.GetScene <GameScene>().AddLight(owner, entity, mirror ? x + spriteInfo.UV.Width : x, y);
                    }
                }
            }
예제 #26
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            Vector3 hueVector;

            if (ShowLock)
            {
                hueVector = ShaderHueTranslator.GetHueVector(0);

                var texture = GumpsLoader.Instance.GetGumpTexture(LOCK_GRAPHIC, out var bounds);

                if (texture != null)
                {
                    if (UIManager.MouseOverControl != null && (UIManager.MouseOverControl == this || UIManager.MouseOverControl.RootParent == this))
                    {
                        hueVector.X = 34;
                        hueVector.Y = 1;
                    }

                    batcher.Draw
                    (
                        texture,
                        new Vector2(x + (Width - bounds.Width), y),
                        bounds,
                        hueVector
                    );
                }
            }

            hueVector = ShaderHueTranslator.GetHueVector(0);

            if (_anchorCandidate != null)
            {
                Point drawLoc = UIManager.AnchorManager.GetCandidateDropLocation(this, _anchorCandidate);

                if (drawLoc != Location)
                {
                    Texture2D previewColor = SolidColorTextureCache.GetTexture(Color.Silver);
                    hueVector = ShaderHueTranslator.GetHueVector(0, false, 0.5f);

                    batcher.Draw
                    (
                        previewColor,
                        new Rectangle
                        (
                            drawLoc.X,
                            drawLoc.Y,
                            Width,
                            Height
                        ),
                        hueVector
                    );

                    hueVector.Z = 0;

                    // double rectangle for thicker "stroke"
                    batcher.DrawRectangle
                    (
                        previewColor,
                        drawLoc.X,
                        drawLoc.Y,
                        Width,
                        Height,
                        hueVector
                    );

                    batcher.DrawRectangle
                    (
                        previewColor,
                        drawLoc.X + 1,
                        drawLoc.Y + 1,
                        Width - 2,
                        Height - 2,
                        hueVector
                    );
                }
            }

            return(true);
        }
예제 #27
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                base.Draw(batcher, x, y);

                Item item = World.Items.Get(LocalSerial);

                Vector3 hueVector;

                if (item != null)
                {
                    var texture = ArtLoader.Instance.GetStaticTexture(item.DisplayedGraphic, out var bounds);
                    var rect    = ArtLoader.Instance.GetRealArtBounds(item.DisplayedGraphic);

                    hueVector = ShaderHueTranslator.GetHueVector(item.Hue, item.ItemData.IsPartialHue, 1f);

                    Point originalSize = new Point(_hit.Width, _hit.Height);
                    Point point        = new Point();

                    if (rect.Width < _hit.Width)
                    {
                        originalSize.X = rect.Width;
                        point.X        = (_hit.Width >> 1) - (originalSize.X >> 1);
                    }

                    if (rect.Height < _hit.Height)
                    {
                        originalSize.Y = rect.Height;
                        point.Y        = (_hit.Height >> 1) - (originalSize.Y >> 1);
                    }

                    batcher.Draw
                    (
                        texture,
                        new Rectangle
                        (
                            x + point.X,
                            y + point.Y + _hit.Y,
                            originalSize.X,
                            originalSize.Y
                        ),
                        new Rectangle
                        (
                            bounds.X + rect.X,
                            bounds.Y + rect.Y,
                            rect.Width,
                            rect.Height
                        ),
                        hueVector
                    );
                }

                hueVector = ShaderHueTranslator.GetHueVector(0);

                batcher.DrawRectangle
                (
                    SolidColorTextureCache.GetTexture(Color.Gray),
                    x,
                    y + 15,
                    Width,
                    Height - 15,
                    hueVector
                );

                if (_hit.MouseIsOver)
                {
                    hueVector.Z = 0.7f;

                    batcher.Draw
                    (
                        SolidColorTextureCache.GetTexture(Color.Yellow),
                        new Rectangle
                        (
                            x + 1,
                            y + 15,
                            Width - 1,
                            Height - 15
                        ),
                        hueVector
                    );

                    hueVector.Z = 1;
                }

                return(true);
            }
예제 #28
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(Serial) && World.OPL.TryGetRevision(Serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(Serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }


            byte   font  = 1;
            float  alpha = 0.7f;
            ushort hue   = 0xFFFF;
            float  zoom  = 1;

            if (ProfileManager.CurrentProfile != null)
            {
                font  = ProfileManager.CurrentProfile.TooltipFont;
                alpha = ProfileManager.CurrentProfile.TooltipBackgroundOpacity / 100f;

                if (float.IsNaN(alpha))
                {
                    alpha = 0f;
                }

                hue  = ProfileManager.CurrentProfile.TooltipTextHue;
                zoom = ProfileManager.CurrentProfile.TooltipDisplayZoom / 100f;
            }

            FontsLoader.Instance.SetUseHTML(true);
            FontsLoader.Instance.RecalculateWidthByInfo = true;

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create
                                (
                    null,
                    font: font,
                    isunicode: true,
                    style: FontStyle.BlackBorder,
                    cell: 5,
                    isHTML: true,
                    align: TEXT_ALIGN_TYPE.TS_CENTER,
                    recalculateWidthByInfo: true,
                    hue: hue
                                );
            }

            if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    int width = FontsLoader.Instance.GetWidthUnicode(font, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode
                            (
                        font,
                        Text,
                        width,
                        TEXT_ALIGN_TYPE.TS_CENTER,
                        (ushort)FontStyle.BlackBorder
                            );

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Font = font;
                _renderedText.Hue  = hue;
                _renderedText.Text = _textHTML;
            }

            FontsLoader.Instance.RecalculateWidthByInfo = false;
            FontsLoader.Instance.SetUseHTML(false);

            if (_renderedText.Texture == null || _renderedText.Texture.IsDisposed)
            {
                return(false);
            }

            int z_width  = _renderedText.Width + 8;
            int z_height = _renderedText.Height + 8;

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - z_width)
            {
                x = Client.Game.Window.ClientBounds.Width - z_width;
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - z_height)
            {
                y = Client.Game.Window.ClientBounds.Height - z_height;
            }


            Vector3 hue_vec = ShaderHueTranslator.GetHueVector(0, false, alpha);

            batcher.Draw
            (
                SolidColorTextureCache.GetTexture(Color.Black),
                new Rectangle
                (
                    x - 4,
                    y - 2,
                    (int)(z_width * zoom),
                    (int)(z_height * zoom)
                ),
                hue_vec
            );


            batcher.DrawRectangle
            (
                SolidColorTextureCache.GetTexture(Color.Gray),
                x - 4,
                y - 2,
                (int)(z_width * zoom),
                (int)(z_height * zoom),
                hue_vec
            );

            batcher.Draw
            (
                _renderedText.Texture,
                new Rectangle
                (
                    x + 3,
                    y + 3,
                    (int)(_renderedText.Texture.Width * zoom),
                    (int)(_renderedText.Texture.Height * zoom)
                ),
                null,
                Vector3.UnitZ
            );

            return(true);
        }
예제 #29
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                Vector3 hueVector;

                if (SerialHelper.IsMobile(LocalSerial))
                {
                    ushort             hue2      = Hue;
                    AnimationDirection direction = GetMobileAnimationDirection(Graphic, ref hue2, 1);

                    if (direction != null && direction.SpriteInfos != null && direction.FrameCount != 0)
                    {
                        hueVector = ShaderHueTranslator.GetHueVector(hue2, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f);

                        batcher.Draw
                        (
                            direction.SpriteInfos[0].Texture,
                            new Rectangle
                            (
                                x - 3,
                                y + 5 + 15,
                                Math.Min(direction.SpriteInfos[0].UV.Width, 45),
                                Math.Min(direction.SpriteInfos[0].UV.Height, 45)
                            ),
                            direction.SpriteInfos[0].UV,
                            hueVector
                        );
                    }
                }
                else if (SerialHelper.IsItem(LocalSerial))
                {
                    var texture = ArtLoader.Instance.GetStaticTexture(Graphic, out var bounds);

                    hueVector = ShaderHueTranslator.GetHueVector(Hue, TileDataLoader.Instance.StaticData[Graphic].IsPartialHue, 1f);

                    var rect = ArtLoader.Instance.GetRealArtBounds(Graphic);

                    const int RECT_SIZE = 50;

                    Point originalSize = new Point(RECT_SIZE, Height);
                    Point point        = new Point();

                    if (rect.Width < RECT_SIZE)
                    {
                        originalSize.X = rect.Width;
                        point.X        = (RECT_SIZE >> 1) - (originalSize.X >> 1);
                    }

                    if (rect.Height < Height)
                    {
                        originalSize.Y = rect.Height;
                        point.Y        = (Height >> 1) - (originalSize.Y >> 1);
                    }

                    batcher.Draw
                    (
                        texture,
                        new Rectangle
                        (
                            x + point.X - 5,
                            y + point.Y + 10,
                            originalSize.X,
                            originalSize.Y
                        ),
                        new Rectangle
                        (
                            bounds.X + rect.X,
                            bounds.Y + rect.Y,
                            rect.Width,
                            rect.Height
                        ),
                        hueVector
                    );
                }

                return(base.Draw(batcher, x, y));
            }
예제 #30
0
        private static void DrawLayer
        (
            UltimaBatcher2D batcher,
            int posX,
            int posY,
            Item owner,
            Layer layer,
            byte animIndex,
            bool ishuman,
            ushort color,
            bool flipped,
            float alpha,
            byte animGroup,
            byte dir,
            Vector3 hueVec,
            float depth
        )
        {
            _equipConvData = null;
            bool ispartialhue = false;

            ushort graphic;

            if (layer == Layer.Invalid)
            {
                graphic = owner.GetGraphicForAnimation();
            }
            else if (ishuman)
            {
                Item itemEquip = owner.FindItemByLayer(layer);

                if (itemEquip == null)
                {
                    return;
                }

                graphic      = itemEquip.ItemData.AnimID;
                ispartialhue = itemEquip.ItemData.IsPartialHue;

                if (AnimationsLoader.Instance.EquipConversions.TryGetValue(graphic, out Dictionary <ushort, EquipConvData> map))
                {
                    if (map.TryGetValue(graphic, out EquipConvData data))
                    {
                        _equipConvData = data;
                        graphic        = data.Graphic;
                    }
                }

                color = itemEquip.Hue;
            }
            else
            {
                return;
            }

            ushort newHue = 0;

            AnimationGroup gr = layer == Layer.Invalid ? AnimationsLoader.Instance.GetCorpseAnimationGroup(ref graphic, ref animGroup, ref newHue) : AnimationsLoader.Instance.GetBodyAnimationGroup(ref graphic, ref animGroup, ref newHue);

            if (color == 0)
            {
                color = newHue;
            }

            AnimationDirection direction = gr.Direction[dir];

            if (direction == null)
            {
                return;
            }

            if ((direction.FrameCount == 0 || direction.SpriteInfos == null) && !AnimationsLoader.Instance.LoadAnimationFrames(graphic, animGroup, dir, ref direction))
            {
                return;
            }

            int fc = direction.FrameCount;

            if (fc > 0 && animIndex >= fc)
            {
                animIndex = (byte)(fc - 1);
            }

            if (animIndex < direction.FrameCount)
            {
                ref var spriteInfo = ref direction.SpriteInfos[animIndex];

                if (spriteInfo.Texture == null)
                {
                    return;
                }

                if (flipped)
                {
                    posX -= spriteInfo.UV.Width - spriteInfo.Center.X;
                }
                else
                {
                    posX -= spriteInfo.Center.X;
                }

                posY -= spriteInfo.UV.Height + spriteInfo.Center.Y;


                if (color == 0)
                {
                    if ((color & 0x8000) != 0)
                    {
                        ispartialhue = true;
                        color       &= 0x7FFF;
                    }

                    if (color == 0 && _equipConvData.HasValue)
                    {
                        color        = _equipConvData.Value.Color;
                        ispartialhue = false;
                    }
                }

                if (ProfileManager.CurrentProfile.NoColorObjectsOutOfRange && owner.Distance > World.ClientViewRange)
                {
                    hueVec = ShaderHueTranslator.GetHueVector(Constants.OUT_RANGE_COLOR + 1, false, 1);
                }
                else if (World.Player.IsDead && ProfileManager.CurrentProfile.EnableBlackWhiteEffect)
                {
                    hueVec = ShaderHueTranslator.GetHueVector(Constants.DEAD_RANGE_COLOR + 1, false, 1);
                }
                else
                {
                    if (ProfileManager.CurrentProfile.GridLootType > 0 && SelectedObject.CorpseObject == owner)
                    {
                        color = 0x0034;
                    }
                    else if (ProfileManager.CurrentProfile.HighlightGameObjects && ReferenceEquals(SelectedObject.LastObject, owner))
                    {
                        color = Constants.HIGHLIGHT_CURRENT_OBJECT_HUE;
                    }

                    hueVec = ShaderHueTranslator.GetHueVector(color, ispartialhue, alpha);
                }

                Vector2   pos  = new Vector2(posX, posY);
                Rectangle rect = spriteInfo.UV;

                int diffY = (spriteInfo.UV.Height + spriteInfo.Center.Y);
                int value = /*!isMounted && diffX <= 44 ? spriteInfo.UV.Height * 2 :*/ Math.Max(1, diffY);
                int count = Math.Max((spriteInfo.UV.Height / value) + 1, 2);

                rect.Height = Math.Min(value, rect.Height);
                int remains = spriteInfo.UV.Height - rect.Height;

                int tiles = (byte)owner.Direction % 2 == 0 ? 2 : 2;


                for (int i = 0; i < count; ++i)
                {
                    //hueVec.Y = 1;
                    //hueVec.X = 0x44 + (i * 20);

                    batcher.Draw
                    (
                        spriteInfo.Texture,
                        pos,
                        rect,
                        hueVec,
                        0f,
                        Vector2.Zero,
                        1f,
                        flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None,
                        depth + 1f + (i * tiles)
                        //depth + (i * tiles) + (owner.PriorityZ * 0.001f)
                    );

                    pos.Y      += rect.Height;
                    rect.Y     += rect.Height;
                    rect.Height = remains; // Math.Min(value, remains);
                    remains    -= rect.Height;
                }
            }