Exemplo n.º 1
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

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

                if (drawLoc != Location)
                {
                    Texture2D previewColor = Textures.GetTexture(Color.Silver);
                    ResetHueVector();
                    _hueVector.Z = 0.5f;
                    batcher.Draw2D(previewColor, drawLoc.X, drawLoc.Y, Width, Height, ref _hueVector);

                    _hueVector.Z = 0;
                    // double rectangle for thicker "stroke"
                    batcher.DrawRectangle(previewColor, drawLoc.X, drawLoc.Y, Width, Height, ref _hueVector);
                    batcher.DrawRectangle(previewColor, drawLoc.X + 1, drawLoc.Y + 1, Width - 2, Height - 2, ref _hueVector);
                }
            }

            return(true);
        }
Exemplo n.º 2
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 : 0.0f;

            _vectorHue.X = mobile != null?Notoriety.GetHue(mobile.NotorietyFlag) : Notoriety.GetHue(NotorietyFlag.Gray);

            _vectorHue.Y = 1;
            _vectorHue.Z = alpha;

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


            const int MULTIPLER = 1;

            batcher.Draw2D(_background_texture,
                           x, y,
                           _background_texture.Width * MULTIPLER,
                           _background_texture.Height * MULTIPLER,
                           ref _vectorHue);


            _vectorHue.X = 0x21;



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

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

                batcher.Draw2DTiled(_hp_texture,
                                    x + per * MULTIPLER - offset, y,
                                    (BAR_WIDTH - per) * MULTIPLER - offset / 2,
                                    _hp_texture.Height * MULTIPLER,
                                    ref _vectorHue);
            }

            ushort hue = 90;

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

                _vectorHue.X = hue;


                batcher.Draw2DTiled(_hp_texture,
                                    x, y,
                                    per * MULTIPLER,
                                    _hp_texture.Height * MULTIPLER,
                                    ref _vectorHue);
            }
        }
Exemplo n.º 3
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);
            }

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true);
            }
            else if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    FontsLoader.Instance.SetUseHTML(true);
                    FontsLoader.Instance.RecalculateWidthByInfo = true;

                    int width = FontsLoader.Instance.GetWidthUnicode(1, Text);

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

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

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

                    _renderedText.MaxWidth = width;

                    FontsLoader.Instance.RecalculateWidthByInfo = false;
                    FontsLoader.Instance.SetUseHTML(false);
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Text = _textHTML;
            }

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

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

            Vector3 hue = Vector3.Zero;

            ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true);

            batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);

            return(_renderedText.Draw(batcher, x + 3, y));
        }
Exemplo n.º 4
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.3f;
            ushort hue   = 0xFFFF;
            float  zoom  = 1;

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

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

                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)
            {
                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 = Vector3.Zero;

            ShaderHueTranslator.GetHueVector(ref hue_vec, 0, false, alpha);

            batcher.Draw2D
            (
                SolidColorTextureCache.GetTexture(Color.Black),
                x - 4,
                y - 2,
                z_width * zoom,
                z_height * zoom,
                ref hue_vec
            );

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

            hue_vec.X = 0;
            hue_vec.Y = 0;
            hue_vec.Z = 0;

            return(batcher.Draw2D
                   (
                       _renderedText.Texture,
                       x + 3,
                       y + 3,
                       z_width * zoom,
                       z_height * zoom,
                       0,
                       0,
                       z_width,
                       z_height,
                       ref hue_vec
                   ));
        }
Exemplo n.º 5
0
        private void DrawInternal(UltimaBatcher2D batcher, int x, int y, Vector3 color)
        {
            for (int i = 0; i < 9; i++)
            {
                SpriteTexture t          = _gumpTexture[i];
                int           drawWidth  = t.Width;
                int           drawHeight = t.Height;
                int           drawX      = x;
                int           drawY      = y;

                switch (i)
                {
                case 0:
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 1:
                    drawX    += _gumpTexture[0].Width;
                    drawWidth = Width - _gumpTexture[0].Width - _gumpTexture[2].Width;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 2:
                    drawX += Width - drawWidth;
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 3:
                    drawY     += _gumpTexture[0].Height;
                    drawHeight = Height - _gumpTexture[0].Height - _gumpTexture[5].Height;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 4:
                    drawX     += Width - drawWidth /*- offsetRight*/;
                    drawY     += _gumpTexture[2].Height;
                    drawHeight = Height - _gumpTexture[2].Height - _gumpTexture[7].Height;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 5:
                    drawY += Height - drawHeight;
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 6:
                    drawX    += _gumpTexture[5].Width;
                    drawY    += Height - drawHeight /*- offsetBottom*/;
                    drawWidth = Width - _gumpTexture[5].Width - _gumpTexture[7].Width;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 7:
                    drawX += Width - drawWidth;
                    drawY += Height - drawHeight;
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 8:
                    drawX     += _gumpTexture[0].Width;
                    drawY     += _gumpTexture[0].Height;
                    drawWidth  = Width - _gumpTexture[0].Width - _gumpTexture[2].Width;
                    drawHeight = Height - _gumpTexture[2].Height - _gumpTexture[7].Height;

                    //if (!OnlyCenterTransparent)
                    Vector3 c = color;

                    if (OnlyCenterTransparent)
                    {
                        c.Z = 1;
                    }

                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref c);

                    break;
                }
            }
        }
Exemplo n.º 6
0
        private void DrawInternal(UltimaBatcher2D batcher, int x, int y, ref Vector3 color)
        {
            int offsetTop    = Math.Max(_gumpTexture[0].Height, _gumpTexture[2].Height) - _gumpTexture[1].Height;
            int offsetBottom = Math.Max(_gumpTexture[5].Height, _gumpTexture[7].Height) - _gumpTexture[6].Height;
            int offsetLeft   = Math.Max(_gumpTexture[0].Width, _gumpTexture[5].Width) - _gumpTexture[3].Width;
            int offsetRight  = Math.Max(_gumpTexture[2].Width, _gumpTexture[7].Width) - _gumpTexture[4].Width;

            for (int i = 0; i < 9; i++)
            {
                UOTexture t          = _gumpTexture[i];
                int       drawWidth  = t.Width;
                int       drawHeight = t.Height;
                int       drawX      = x;
                int       drawY      = y;

                switch (i)
                {
                case 0:

                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);
                    break;

                case 1:
                    drawX    += _gumpTexture[0].Width;
                    drawWidth = Width - _gumpTexture[0].Width - _gumpTexture[2].Width;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 2:
                    drawX += Width - drawWidth;
                    drawY += offsetTop;
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 3:
                    drawX     += offsetLeft;
                    drawY     += _gumpTexture[0].Height;
                    drawHeight = Height - _gumpTexture[0].Height - _gumpTexture[5].Height;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 4:
                    drawX     += Width - drawWidth - offsetRight;
                    drawY     += _gumpTexture[2].Height;
                    drawHeight = Height - _gumpTexture[2].Height - _gumpTexture[7].Height;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 5:
                    drawY += Height - drawHeight;
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 6:
                    drawX    += _gumpTexture[5].Width;
                    drawY    += Height - drawHeight - offsetBottom;
                    drawWidth = Width - _gumpTexture[5].Width - _gumpTexture[7].Width;
                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 7:
                    drawX += Width - drawWidth;
                    drawY += Height - drawHeight;
                    batcher.Draw2D(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;

                case 8:
                    drawX     += _gumpTexture[0].Width;
                    drawY     += _gumpTexture[0].Height;
                    drawWidth  = Width - _gumpTexture[0].Width - _gumpTexture[2].Width;
                    drawHeight = Height - _gumpTexture[2].Height - _gumpTexture[7].Height;

                    if (OnlyCenterTransparent)
                    {
                        color.Z = 1;
                    }

                    batcher.Draw2DTiled(t, drawX, drawY, drawWidth, drawHeight, ref color);

                    break;
                }
            }
        }
Exemplo n.º 7
0
            internal void DrawSelection(UltimaBatcher2D batcher, int x, int y, int starty, int endy)
            {
                ResetHueVector();
                HueVector.Z = 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.Draw2D
                                    (
                                        SolidColorTextureCache.GetTexture(SELECTION_COLOR), x + drawX, y + drawY - starty, endX,
                                        info.MaxHeight + 1, ref HueVector
                                    );
                                }

                                break;
                            }


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

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

                        start += info.CharCount;
                        drawY += info.MaxHeight;
                        info   = info.Next;
                    }
                }
            }
Exemplo n.º 8
0
        private void DrawInternal(UltimaBatcher2D batcher, int x, int y, ref Vector3 color)
        {
            int th_0_width = _gumpTexture[0]?.Width ?? 0;

            int th_0_height = _gumpTexture[0]?.Height ?? 0;

            int th_1_width = _gumpTexture[1]?.Width ?? 0;

            int th_1_height = _gumpTexture[1]?.Height ?? 0;

            int th_2_width = _gumpTexture[2]?.Width ?? 0;

            int th_2_height = _gumpTexture[2]?.Height ?? 0;

            int th_3_width = _gumpTexture[3]?.Width ?? 0;

            int th_3_height = _gumpTexture[3]?.Height ?? 0;

            int th_4_width = _gumpTexture[4]?.Width ?? 0;

            int th_4_height = _gumpTexture[4]?.Height ?? 0;

            int th_5_width = _gumpTexture[5]?.Width ?? 0;

            int th_5_height = _gumpTexture[5]?.Height ?? 0;

            int th_6_width = _gumpTexture[6]?.Width ?? 0;

            int th_6_height = _gumpTexture[6]?.Height ?? 0;

            int th_7_width = _gumpTexture[7]?.Width ?? 0;

            int th_7_height = _gumpTexture[7]?.Height ?? 0;

            int th_8_width = _gumpTexture[8]?.Width ?? 0;

            int th_8_height = _gumpTexture[8]?.Height ?? 0;


            int offsetTop    = Math.Max(th_0_height, th_2_height) - th_1_height;
            int offsetBottom = Math.Max(th_5_height, th_7_height) - th_6_height;
            int offsetLeft   = Math.Max(th_0_width, th_5_width) - th_2_width;
            int offsetRight  = Math.Max(th_2_width, th_7_width) - th_4_width;


            for (int i = 0; i < 9; i++)
            {
                UOTexture t = _gumpTexture[i];

                if (t == null)
                {
                    continue;
                }

                int drawWidth  = t.Width;
                int drawHeight = t.Height;
                int drawX      = x;
                int drawY      = y;

                switch (i)
                {
                case 0:

                    batcher.Draw2D
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 1:
                    drawX    += th_0_width;
                    drawWidth = Width - th_0_width - th_2_width;

                    batcher.Draw2DTiled
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 2:
                    drawX += Width - drawWidth;
                    drawY += offsetTop;

                    batcher.Draw2D
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 3:
                    drawX     += offsetLeft;
                    drawY     += th_0_height;
                    drawHeight = Height - th_0_height - th_5_height;

                    batcher.Draw2DTiled
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 4:
                    drawX     += Width - drawWidth - offsetRight;
                    drawY     += th_2_height;
                    drawHeight = Height - th_2_height - th_7_height;

                    batcher.Draw2DTiled
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 5:
                    drawY += Height - drawHeight;

                    batcher.Draw2D
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 6:
                    drawX    += th_5_width;
                    drawY    += Height - drawHeight - offsetBottom;
                    drawWidth = Width - th_5_width - th_7_width;

                    batcher.Draw2DTiled
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 7:
                    drawX += Width - drawWidth;
                    drawY += Height - drawHeight;

                    batcher.Draw2D
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;

                case 8:
                    drawX     += th_0_width;
                    drawY     += th_0_height;
                    drawWidth  = Width - th_0_width - th_2_width;
                    drawHeight = Height - th_2_height - th_7_height;

                    batcher.Draw2DTiled
                    (
                        t,
                        drawX,
                        drawY,
                        drawWidth,
                        drawHeight,
                        ref color
                    );

                    break;
                }
            }
        }
Exemplo n.º 9
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (_gameObject != null && _hash != _gameObject.PropertiesHash)
            {
                _hash = _gameObject.PropertiesHash;
                Text  = ReadProperties(_gameObject, out _textHTML);
            }

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

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

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true);
            }
            else if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    FileManager.Fonts.SetUseHTML(true);
                    FileManager.Fonts.RecalculateWidthByInfo = true;

                    int width = FileManager.Fonts.GetWidthUnicode(1, Text);

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

                    width = FileManager.Fonts.GetWidthExUnicode(1, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder);

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

                    _renderedText.MaxWidth = width;

                    FileManager.Fonts.RecalculateWidthByInfo = false;
                    FileManager.Fonts.SetUseHTML(false);
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Text = _textHTML;
            }

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Engine.WindowWidth - (_renderedText.Width + 8))
            {
                x = Engine.WindowWidth - (_renderedText.Width + 8);
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Engine.WindowHeight - (_renderedText.Height + 8))
            {
                y = Engine.WindowHeight - (_renderedText.Height + 8);
            }

            Vector3 hue = Vector3.Zero;

            ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true);

            batcher.Draw2D(Textures.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);

            return(_renderedText.Draw(batcher, x, y));
        }
Exemplo n.º 10
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(rectangle))
            {
                batcher.EnableScissorTest(true);

                ResetHueVector();

                if (ProfileManager.Current != null && ProfileManager.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.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();
            }

            return(true);
        }
Exemplo n.º 11
0
        //TEXTURES END
        public void Draw(UltimaBatcher2D batcher)
        {
            if (!IsEnabled)
            {
                return;
            }

            if (World.Player == null)
            {
                return;
            }

            foreach (Mobile mobile in World.Mobiles)
            {
                //SKIP FOR PLAYER
                if (mobile == World.Player)
                {
                    continue;
                }

                _hueVector.Z = 0f;

                //CALC WHERE MOBILE IS
                Point pm = mobile.RealScreenPosition;
                pm.X += (int)mobile.Offset.X + 22;
                pm.Y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22;
                Point p1 = pm;

                if (IsHalosEnabled && (HaloOrange != null || HaloGreen != null || HaloPurple != null || HaloRed != null))
                {
                    _hueVector.Y = ShaderHueTranslator.SHADER_LIGHTS;

                    //Move from center by texture width
                    pm.X = pm.X - HaloOrange.Width / 2;

                    batcher.SetBlendState(_blend);

                    //PURPLE HALO FOR: LAST ATTACK, LASTTARGET
                    if (TargetManager.LastAttack == mobile.Serial || TargetManager.LastTargetInfo.Serial == mobile.Serial)
                    {
                        batcher.Draw2D(HaloPurple, pm.X, pm.Y - 15, HaloPurple.Width, HaloPurple.Height, ref _hueVector);
                    }

                    //GREEN HALO FOR: ALLYS AND PARTY
                    else if ((mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial)) && mobile != World.Player)
                    {
                        batcher.Draw2D(HaloGreen, pm.X, pm.Y - 15, HaloGreen.Width, HaloGreen.Height, ref _hueVector);
                    }

                    //RED HALO FOR: CRIMINALS, GRAY, MURDERER
                    else if (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Gray || mobile.NotorietyFlag == NotorietyFlag.Murderer)
                    {
                        batcher.Draw2D(HaloRed, pm.X, pm.Y - 15, HaloRed.Width, HaloRed.Height, ref _hueVector);
                    }

                    //ORANGE HALO FOR: ENEMY
                    else if (mobile.NotorietyFlag == NotorietyFlag.Enemy)
                    {
                        batcher.Draw2D(HaloOrange, pm.X, pm.Y - 15, HaloOrange.Width, HaloOrange.Height, ref _hueVector);
                    }

                    batcher.SetBlendState(null);
                }
                //HALO TEXTURE

                //ARROW TEXTURE
                if (!IsArrowEnabled)
                {
                    return;
                }

                //CALC MOBILE HEIGHT FROM ANIMATION
                AnimationsLoader.Instance.GetAnimationDimensions(mobile.AnimIndex,
                                                                 mobile.GetGraphicForAnimation(),
                                                                 /*(byte) m.GetDirectionForAnimation()*/ 0,
                                                                 /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0,
                                                                 mobile.IsMounted,
                                                                 /*(byte) m.AnimIndex*/ 0,
                                                                 out int centerX,
                                                                 out int centerY,
                                                                 out int width,
                                                                 out int height);

                p1.Y -= height + centerY + 8 + 22;

                if (mobile.IsGargoyle && mobile.IsFlying)
                {
                    p1.Y -= 22;
                }
                else if (!mobile.IsMounted)
                {
                    p1.Y += 22;
                }

                p1.X -= ArrowRed.Width / 2;
                p1.Y -= ArrowRed.Height / 1;

                if (mobile.ObjectHandlesOpened)
                {
                    p1.Y -= 22;
                }

                /* MAYBE USE THIS INCASE IT SHOWS OUTSIDE OF GAMESCREEN?
                 * if (!(p1.X < 0 || p1.X > screenW - mobile.HitsTexture.Width || p1.Y < 0 || p1.Y > screenH))
                 *          {
                 *              mobile.HitsTexture.Draw(batcher, p1.X, p1.Y);
                 *          }
                 */

                //ARROW TEXTURE
                if (IsArrowEnabled && (ArrowGreen != null || ArrowRed != null || ArrowPurple != null || ArrowOrange != null))
                {
                    _hueVector.Y = ShaderHueTranslator.SHADER_LIGHTS;

                    batcher.SetBlendState(_blend);

                    //PURPLE ARROW FOR: LAST ATTACK, LASTTARGET
                    if (TargetManager.LastAttack == mobile.Serial || TargetManager.LastTargetInfo.Serial == mobile.Serial)
                    {
                        batcher.Draw2D(ArrowPurple, p1.X, p1.Y, ArrowPurple.Width, ArrowPurple.Height, ref _hueVector);
                    }

                    //GREEN ARROW FOR: ALLYS AND PARTY
                    else if ((mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial)) && mobile != World.Player)
                    {
                        batcher.Draw2D(ArrowGreen, p1.X, p1.Y, ArrowGreen.Width, ArrowGreen.Height, ref _hueVector);
                    }

                    //RED ARROW FOR: CRIMINALS, GRAY, MURDERER
                    else if (mobile.NotorietyFlag == NotorietyFlag.Criminal || mobile.NotorietyFlag == NotorietyFlag.Gray || mobile.NotorietyFlag == NotorietyFlag.Murderer)
                    {
                        batcher.Draw2D(ArrowRed, p1.X, p1.Y, ArrowRed.Width, ArrowRed.Height, ref _hueVector);
                    }

                    //ORANGE ARROW FOR: ENEMY
                    else if (mobile.NotorietyFlag == NotorietyFlag.Enemy)
                    {
                        batcher.Draw2D(ArrowOrange, p1.X, p1.Y, ArrowOrange.Width, ArrowOrange.Height, ref _hueVector);
                    }

                    batcher.SetBlendState(null);
                }
                //ARROW TEXTURE
            }
        }
Exemplo n.º 12
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            if (ShowLock)
            {
                ResetHueVector();

                UOTexture lock_texture = GumpsLoader.Instance.GetTexture(0x082C);

                if (lock_texture != null)
                {
                    lock_texture.Ticks = Time.Ticks;

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

                    batcher.Draw2D(lock_texture, x + (Width - lock_texture.Width), y, ref HueVector);
                }
            }

            ResetHueVector();

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

                if (drawLoc != Location)
                {
                    Texture2D previewColor = SolidColorTextureCache.GetTexture(Color.Silver);
                    ResetHueVector();
                    HueVector.Z = 0.5f;

                    batcher.Draw2D
                    (
                        previewColor,
                        drawLoc.X,
                        drawLoc.Y,
                        Width,
                        Height,
                        ref HueVector
                    );

                    HueVector.Z = 0;

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

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

            return(true);
        }
Exemplo n.º 13
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();

            int centerWidth = Width - _frame[0].Width - _frame[2].Width;

            int centerHeight = Height - _frame[0].Height - _frame[6].Height;

            int line2Y = y + _frame[0].Height;

            int line3Y = y + Height - _frame[6].Height;

            // top row
            batcher.Draw2D(_frame[0], x, y, ref HueVector);

            batcher.Draw2DTiled
            (
                _frame[1],
                x + _frame[0].Width,
                y,
                centerWidth,
                _frame[0].Height,
                ref HueVector
            );

            batcher.Draw2D(_frame[2], x + Width - _frame[2].Width, y, ref HueVector);

            // middle
            batcher.Draw2DTiled
            (
                _frame[3],
                x,
                line2Y,
                _frame[3].Width,
                centerHeight,
                ref HueVector
            );

            batcher.Draw2DTiled
            (
                _frame[4],
                x + _frame[3].Width,
                line2Y,
                centerWidth,
                centerHeight,
                ref HueVector
            );

            batcher.Draw2DTiled
            (
                _frame[5],
                x + Width - _frame[5].Width,
                line2Y,
                _frame[5].Width,
                centerHeight,
                ref HueVector
            );

            // bottom
            batcher.Draw2D(_frame[6], x, line3Y, ref HueVector);

            batcher.Draw2DTiled
            (
                _frame[7],
                x + _frame[6].Width,
                line3Y,
                centerWidth,
                _frame[6].Height,
                ref HueVector
            );

            batcher.Draw2D(_frame[8], x + Width - _frame[8].Width, line3Y, ref HueVector);

            return(base.Draw(batcher, x, y));
        }
Exemplo n.º 14
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (_gumpTexture == null || _gumpTexture.IsDisposed || IsDisposed)
            {
                return(false);
            }

            ResetHueVector();

            batcher.Draw2D(_gumpTexture, x, y, ref _hueVector);
            CreateMiniMapTexture();
            batcher.Draw2D(_mapTexture, x, y, ref _hueVector);

            if (_draw)
            {
                if (_playerIndicator == null)
                {
                    _playerIndicator = new Texture2D(batcher.GraphicsDevice, 1, 1);

                    _playerIndicator.SetData
                    (
                        new uint[1]
                    {
                        0xFFFFFFFF
                    }
                    );

                    _mobilesIndicator = new Texture2D(batcher.GraphicsDevice, 1, 1);
                    _mobilesIndicator.SetData(new[] { Color.White });
                }

                int w = Width >> 1;
                int h = Height >> 1;

                foreach (Mobile mob in World.Mobiles)
                {
                    if (mob == World.Player)
                    {
                        continue;
                    }

                    int xx = mob.X - World.Player.X;
                    int yy = mob.Y - World.Player.Y;

                    int gx = xx - yy;
                    int gy = xx + yy;

                    _hueVector.Z = 0;

                    ShaderHueTranslator.GetHueVector(ref _hueVector, Notoriety.GetHue(mob.NotorietyFlag));

                    batcher.Draw2D(_mobilesIndicator, x + w + gx, y + h + gy, 2, 2, ref _hueVector);
                }

                //DRAW DOT OF PLAYER
                ResetHueVector();
                batcher.Draw2D(_playerIndicator, x + w, y + h, 2, 2, ref _hueVector);
            }

            return(base.Draw(batcher, x, y));
        }
Exemplo n.º 15
0
        // ## BEGIN - END ## //  -- CODE BELOW IS 1:1 LIKE DrawHealthLine()
        private void DrawOldHealthLine(UltimaBatcher2D batcher, Entity entity, int x, int y, bool passive)
        {
            if (entity == null)
            {
                return;
            }

            Mobile mobile = entity as Mobile;

            int per = mobile.HitsMax;

            if (per > 0)
            {
                per = mobile.Hits * 100 / per;

                if (per > 100)
                {
                    per = 100;
                }

                if (per < 1)
                {
                    per = 0;
                }
                else
                {
                    per = 34 * per / 100;
                }
            }
            // ## BEGIN - END ## //   -- CODE ABOVE IS 1:1 LIKE DrawHealthLine()
            Color color;

            if (ProfileManager.CurrentProfile.MultipleUnderlinesSelfParty && mobile == World.Player || ProfileManager.CurrentProfile.MultipleUnderlinesSelfParty && World.Party.Contains(mobile))
            {
                if (ProfileManager.CurrentProfile.MultipleUnderlinesSelfPartyBigBars)
                {
                    //LAYOUT BIGBAR
                    BIGBAR_WIDTH      = 50;
                    BIGBAR_HEIGHT     = 4;
                    BIGBAR_WIDTH_HALF = BIGBAR_WIDTH / 2 - 14;
                    YSPACING          = 1;
                }
                else
                {
                    BIGBAR_WIDTH      = 28;
                    BIGBAR_HEIGHT     = 3;
                    BIGBAR_WIDTH_HALF = BIGBAR_WIDTH / 2 - 14; // = BAR_WIDTH >> 1;
                    YSPACING          = 1;
                }

                (Color hpcolor, int maxhp, int maxmana, int maxstam) = UOClassicCombatCollection.CalcUnderlines(mobile);

                //HP BAR
                batcher.Draw2D(_edgeHealth, x - 1 - BIGBAR_WIDTH_HALF, y - 1, BIGBAR_WIDTH + 2, BIGBAR_HEIGHT + 1, ref _vectorHue);
                batcher.Draw2D(_backHealth, x - BIGBAR_WIDTH_HALF + maxhp, y, BIGBAR_WIDTH - maxhp, BIGBAR_HEIGHT, ref _vectorHue);
                batcher.Draw2D(SolidColorTextureCache.GetTexture(hpcolor), x - BIGBAR_WIDTH_HALF, y, maxhp, BIGBAR_HEIGHT, ref _vectorHue);

                //MANA BAR
                batcher.Draw2D(_edgeMana, x - 1 - BIGBAR_WIDTH_HALF, y + BIGBAR_HEIGHT + YSPACING - 1, BIGBAR_WIDTH + 2, BIGBAR_HEIGHT + 1, ref _vectorHue);
                batcher.Draw2D(_backMana, x - BIGBAR_WIDTH_HALF + maxmana, y + BIGBAR_HEIGHT + YSPACING, BIGBAR_WIDTH - maxmana, BIGBAR_HEIGHT, ref _vectorHue);
                batcher.Draw2D(SolidColorTextureCache.GetTexture(Color.CornflowerBlue * _alphamodifier), x - BIGBAR_WIDTH_HALF, y + BIGBAR_HEIGHT + YSPACING, maxmana, BIGBAR_HEIGHT, ref _vectorHue);

                //STAM BAR
                batcher.Draw2D(_edgeStamina, x - 1 - BIGBAR_WIDTH_HALF, y + BIGBAR_HEIGHT + BIGBAR_HEIGHT + YSPACING + YSPACING - 1, BIGBAR_WIDTH + 2, BIGBAR_HEIGHT + 2, ref _vectorHue);
                batcher.Draw2D(_backStamina, x - BIGBAR_WIDTH_HALF + maxstam, y + BIGBAR_HEIGHT + BIGBAR_HEIGHT + YSPACING + YSPACING, BIGBAR_WIDTH - maxstam, BIGBAR_HEIGHT, ref _vectorHue);
                batcher.Draw2D(SolidColorTextureCache.GetTexture(Color.CornflowerBlue * _alphamodifier), x - BIGBAR_WIDTH_HALF, y + BIGBAR_HEIGHT + BIGBAR_HEIGHT + YSPACING + YSPACING, maxstam, BIGBAR_HEIGHT, ref _vectorHue);
            }
            else
            {
                batcher.Draw2D(_edge, x - 1, y - 1, BAR_WIDTH + 2, OLD_BAR_HEIGHT + 2, ref _vectorHue);
                batcher.Draw2D(_back, x, y, BAR_WIDTH, OLD_BAR_HEIGHT, ref _vectorHue);

                if (mobile.IsParalyzed)
                {
                    color = Color.AliceBlue;
                }
                else if (mobile.IsYellowHits)
                {
                    color = Color.Orange;
                }
                else if (mobile.IsPoisoned)
                {
                    color = Color.LimeGreen;
                }
                else
                {
                    color = Color.CornflowerBlue;
                }

                batcher.Draw2D(SolidColorTextureCache.GetTexture(color), x, y, per, OLD_BAR_HEIGHT, ref _vectorHue);
            }
        }
Exemplo n.º 16
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (_gumpTexture == null || _gumpTexture.IsDisposed || IsDisposed)
            {
                return(false);
            }

            ResetHueVector();

            batcher.Draw2D(_gumpTexture, x, y, ref HueVector);
            CreateMiniMapTexture();
            batcher.Draw2D(_mapTexture, x, y, ref HueVector);

            if (_draw)
            {
                int w = Width >> 1;
                int h = Height >> 1;

                Texture2D mobilesTextureDot = SolidColorTextureCache.GetTexture(Color.Red);

                foreach (Mobile mob in World.Mobiles)
                {
                    if (mob == World.Player)
                    {
                        continue;
                    }

                    int xx = mob.X - World.Player.X;
                    int yy = mob.Y - World.Player.Y;

                    int gx = xx - yy;
                    int gy = xx + yy;

                    HueVector.Z = 0;

                    ShaderHueTranslator.GetHueVector(ref HueVector, Notoriety.GetHue(mob.NotorietyFlag));

                    batcher.Draw2D
                    (
                        mobilesTextureDot,
                        x + w + gx,
                        y + h + gy,
                        2,
                        2,
                        ref HueVector
                    );
                }

                //DRAW DOT OF PLAYER
                ResetHueVector();

                batcher.Draw2D
                (
                    SolidColorTextureCache.GetTexture(Color.White),
                    x + w,
                    y + h,
                    2,
                    2,
                    ref HueVector
                );
            }

            return(base.Draw(batcher, x, y));
        }
Exemplo n.º 17
0
        public void Draw(UltimaBatcher2D batcher, float scale)
        {
            if (!IsEnabled)
            {
                return;
            }

            const int BAR_WIDTH  = 27;
            const int BAR_HEIGHT = 3;

            int screenX = Engine.Profile.Current.GameWindowPosition.X;
            int screenY = Engine.Profile.Current.GameWindowPosition.Y;
            int screenW = Engine.Profile.Current.GameWindowSize.X;
            int screenH = Engine.Profile.Current.GameWindowSize.Y;


            Texture2D black = Textures.GetTexture(Color.Black);
            Texture2D red   = Textures.GetTexture(Color.Red);

            Color color;

            foreach (Mobile mobile in World.Mobiles)
            {
                int x = screenX + mobile.RealScreenPosition.X;
                int y = screenY + mobile.RealScreenPosition.Y;


                x += (int)mobile.Offset.X + 22;
                y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22 + 5;

                x += 5;

                x -= BAR_WIDTH >> 1;
                y -= BAR_HEIGHT >> 1;

                x  = (int)(x / scale);
                y  = (int)(y / scale);
                x -= (int)(screenX / scale);
                y -= (int)(screenY / scale);
                x += screenX;
                y += screenY;


                if (x < screenX || x > screenX + screenW - BAR_WIDTH)
                {
                    continue;
                }

                if (y < screenY || y > screenY + screenH - BAR_HEIGHT)
                {
                    continue;
                }

                int current = mobile.Hits;
                int max     = mobile.HitsMax;


                if (max > 0)
                {
                    max = current * 100 / max;

                    if (max > 100)
                    {
                        max = 100;
                    }

                    if (max > 1)
                    {
                        max = BAR_WIDTH * max / 100;
                    }
                }


                batcher.Draw2D(black, x - 1, y - 1, BAR_WIDTH + 2, BAR_HEIGHT + 2, ref _vectorHue);
                batcher.Draw2D(red, x, y, BAR_WIDTH, BAR_HEIGHT, ref _vectorHue);

                if (mobile.IsParalyzed)
                {
                    color = Color.AliceBlue;
                }
                else if (mobile.IsYellowHits)
                {
                    color = Color.Orange;
                }
                else if (mobile.IsPoisoned)
                {
                    color = Color.LimeGreen;
                }
                else
                {
                    color = Color.CornflowerBlue;
                }

                batcher.Draw2D(Textures.GetTexture(color), x, y, max, BAR_HEIGHT, ref _vectorHue);
            }
        }
Exemplo n.º 18
0
        private void DrawHealthLine(UltimaBatcher2D batcher, Mobile mobile, int x, int y, bool passive)
        {
            if (mobile == null)
            {
                return;
            }

            int per = mobile.HitsMax;

            if (per > 0)
            {
                per = mobile.Hits * 100 / per;

                if (per > 100)
                {
                    per = 100;
                }

                if (per < 1)
                {
                    per = 0;
                }
                else
                {
                    per = 34 * per / 100;
                }
            }

            _vectorHue.X = 0;
            _vectorHue.Y = 0;
            _vectorHue.Z = 0;

            float alpha = passive ? 0.5f : 0.0f;

            ShaderHuesTraslator.GetHueVector(ref _vectorHue, Notoriety.GetHue(mobile.NotorietyFlag), false, alpha);

            batcher.Draw2D(_background_texture,
                           x, y,
                           _background_texture.Width,
                           _background_texture.Height,
                           ref _vectorHue);

            _vectorHue.X = 0;
            _vectorHue.Y = 0;
            _vectorHue.Z = 0;

            ushort hue = 23;

            alpha = passive ? 0.5f : 0.0f;

            ShaderHuesTraslator.GetHueVector(ref _vectorHue, hue, false, alpha);

            batcher.Draw2DTiled(_hp_texture,
                                x, y,
                                BAR_WIDTH,
                                _hp_texture.Height,
                                ref _vectorHue);

            _vectorHue.X = 0;
            _vectorHue.Y = 0;
            _vectorHue.Z = 0;


            if (mobile.IsPoisoned)
            {
                hue = 63;
            }
            else if (mobile.IsYellowHits)
            {
                hue = 53;
            }
            else
            {
                hue = 90;
            }

            ShaderHuesTraslator.GetHueVector(ref _vectorHue, hue, false, alpha);

            batcher.Draw2DTiled(_hp_texture,
                                x, y,
                                per,
                                _hp_texture.Height,
                                ref _vectorHue);
        }
Exemplo n.º 19
0
 public override bool Draw(UltimaBatcher2D batcher, int x, int y)
 {
     return(batcher.Draw2D(Texture, x, y, Width, Height, ref _zero));
 }
Exemplo n.º 20
0
        public void Draw(UltimaBatcher2D batcher, float scale)
        {
            if (!IsEnabled)
            {
                return;
            }

            const int BAR_WIDTH       = 28;
            const int BAR_HEIGHT      = 3;
            const int BAR_WIDTH_HALF  = BAR_WIDTH >> 1;
            const int BAR_HEIGHT_HALF = BAR_HEIGHT >> 1;

            int screenX = ProfileManager.Current.GameWindowPosition.X;
            int screenY = ProfileManager.Current.GameWindowPosition.Y;
            int screenW = ProfileManager.Current.GameWindowSize.X;
            int screenH = ProfileManager.Current.GameWindowSize.Y;



            Color color;

            int mode = ProfileManager.Current.MobileHPType;

            if (mode < 0)
            {
                return;
            }

            int showWhen = ProfileManager.Current.MobileHPShowWhen;

            foreach (Mobile mobile in World.Mobiles)
            {
                //if (World.Party.Contains(mobile) && mobile.Tile == null)
                //    continue;

                int current = mobile.Hits;
                int max     = mobile.HitsMax;

                if (showWhen == 1 && current == max)
                {
                    continue;
                }

                int x = screenX + mobile.RealScreenPosition.X;
                int y = screenY + mobile.RealScreenPosition.Y;

                x += (int)mobile.Offset.X + 22;
                y += (int)(mobile.Offset.Y - mobile.Offset.Z) + 22;

                x  = (int)(x / scale);
                y  = (int)(y / scale);
                x -= (int)(screenX / scale);
                y -= (int)(screenY / scale);
                x += screenX;
                y += screenY;

                x += 5;
                y += 5;

                x -= BAR_WIDTH_HALF;
                y -= BAR_HEIGHT_HALF;

                if (mode != 1 && !mobile.IsDead)
                {
                    if ((showWhen == 2 && current != max) || showWhen <= 1)
                    {
                        int xx = x;
                        int yy = y;

                        if (!mobile.IsMounted)
                        {
                            yy += (int)(22 / scale);
                        }


                        UOFileManager.Animations.GetAnimationDimensions(mobile.AnimIndex,
                                                                        mobile.GetGraphicForAnimation(),
                                                                        /*(byte) m.GetDirectionForAnimation()*/ 0,
                                                                        /*Mobile.GetGroupForAnimation(m, isParent:true)*/ 0,
                                                                        mobile.IsMounted,
                                                                        /*(byte) m.AnimIndex*/ 0,
                                                                        out int centerX,
                                                                        out int centerY,
                                                                        out int width,
                                                                        out int height);


                        yy -= (int)((height + centerY + 28) / scale);


                        int ww = mobile.HitsMax;

                        if (ww > 0)
                        {
                            ww = mobile.Hits * 100 / ww;

                            if (ww > 100)
                            {
                                ww = 100;
                            }
                            else if (ww < 1)
                            {
                                ww = 0;
                            }

                            mobile.UpdateHits((byte)ww);
                        }

                        if (mobile.HitsPercentage != 0)
                        {
                            xx -= (mobile.HitsTexture.Width >> 1) + 3;
                            xx += 22;
                            yy -= mobile.HitsTexture.Height / 1;
                            if (mobile.ObjectHandlesOpened)
                            {
                                yy -= 22;
                            }

                            if (!(xx < screenX || xx > screenX + screenW - mobile.HitsTexture.Width || yy < screenY || yy > screenY + screenH))
                            {
                                mobile.HitsTexture.Draw(batcher, xx, yy);
                            }
                        }
                    }
                }

                if (x < screenX || x > screenX + screenW - BAR_WIDTH)
                {
                    continue;
                }

                if (y < screenY || y > screenY + screenH - BAR_HEIGHT)
                {
                    continue;
                }

                if (mode >= 1 && TargetManager.LastTarget != mobile)
                {
                    if (max > 0)
                    {
                        max = current * 100 / max;

                        if (max > 100)
                        {
                            max = 100;
                        }

                        if (max > 1)
                        {
                            max = BAR_WIDTH * max / 100;
                        }
                    }

                    batcher.Draw2D(_edge, x - 1, y - 1, BAR_WIDTH + 2, BAR_HEIGHT + 2, ref _vectorHue);
                    batcher.Draw2D(_back, x, y, BAR_WIDTH, BAR_HEIGHT, ref _vectorHue);

                    if (mobile.IsParalyzed)
                    {
                        color = Color.AliceBlue;
                    }
                    else if (mobile.IsYellowHits)
                    {
                        color = Color.Orange;
                    }
                    else if (mobile.IsPoisoned)
                    {
                        color = Color.LimeGreen;
                    }
                    else
                    {
                        color = Color.CornflowerBlue;
                    }

                    batcher.Draw2D(Textures.GetTexture(color), x, y, max, BAR_HEIGHT, ref _vectorHue);
                }
            }
        }
Exemplo n.º 21
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (Height <= 0 || !IsVisible)
            {
                return(false);
            }

            ResetHueVector();

            // draw scrollbar background
            int middleHeight = Height - _textureUpButton[0]
                               .Height - _textureDownButton[0]
                               .Height - _textureBackground[0]
                               .Height - _textureBackground[2]
                               .Height;

            if (middleHeight > 0)
            {
                batcher.Draw2D
                (
                    _textureBackground[0], x, y + _textureUpButton[0]
                    .Height, ref _hueVector
                );

                batcher.Draw2DTiled
                (
                    _textureBackground[1], x, y + _textureUpButton[0]
                    .Height + _textureBackground[0]
                    .Height, _textureBackground[0]
                    .Width, middleHeight, ref _hueVector
                );

                batcher.Draw2D
                (
                    _textureBackground[2], x, y + Height - _textureDownButton[0]
                    .Height - _textureBackground[2]
                    .Height, ref _hueVector
                );
            }
            else
            {
                middleHeight = Height - _textureUpButton[0]
                               .Height - _textureDownButton[0]
                               .Height;

                batcher.Draw2DTiled
                (
                    _textureBackground[1], x, y + _textureUpButton[0]
                    .Height, _textureBackground[0]
                    .Width, middleHeight, ref _hueVector
                );
            }

            // draw up button
            batcher.Draw2D(_btUpClicked ? _textureUpButton[1] : _textureUpButton[0], x, y, ref _hueVector);

            // draw down button
            batcher.Draw2D
            (
                _btDownClicked ? _textureDownButton[1] : _textureDownButton[0], x, y + Height - _textureDownButton[0]
                .Height, ref _hueVector
            );

            // draw slider
            if (MaxValue > MinValue && middleHeight > 0)
            {
                batcher.Draw2D
                (
                    _textureSlider, x + ((_textureBackground[0]
                                          .Width - _textureSlider.Width) >> 1), y + _textureUpButton[0]
                    .Height + _sliderPosition, ref _hueVector
                );
            }

            return(base.Draw(batcher, x, y));
        }
Exemplo n.º 22
0
        public void Draw(UltimaBatcher2D batcher, int x, int y)
        {
            bool removeEffects = false;

            if (Timer < Engine.Ticks)
            {
                if (CurrentCount == 0)
                {
                    return;
                }

                removeEffects = true;
            }
            else if (Type == 0xFF || Type == 0xFE)
            {
                return;
            }

            uint passed = Engine.Ticks - LastTick;

            if (passed > 7000)
            {
                LastTick = Engine.Ticks;
                passed   = 25;
            }

            bool windChanged = false;

            if (WindTimer < Engine.Ticks)
            {
                if (WindTimer == 0)
                {
                    windChanged = true;
                }

                WindTimer = Engine.Ticks + (uint)(RandomHelper.GetValue(7, 13) * 1000);

                sbyte lastWind = Wind;

                Wind = (sbyte)RandomHelper.GetValue(0, 4);

                if (RandomHelper.GetValue(0, 2) != 0)
                {
                    Wind *= -1;
                }

                if (Wind < 0 && lastWind > 0)
                {
                    Wind = 0;
                }
                else if (Wind > 0 && lastWind < 0)
                {
                    Wind = 0;
                }

                if (lastWind != Wind)
                {
                    windChanged = true;
                }
            }

            //switch ((WEATHER_TYPE) Type)
            //{
            //    case WEATHER_TYPE.WT_RAIN:
            //    case WEATHER_TYPE.WT_FIERCE_STORM:
            //        // TODO: set color
            //        break;
            //    case WEATHER_TYPE.WT_SNOW:
            //    case WEATHER_TYPE.WT_STORM:
            //        // TODO: set color
            //        break;
            //    default:
            //        break;
            //}

            Point winpos  = Engine.Profile.Current.GameWindowPosition;
            Point winsize = Engine.Profile.Current.GameWindowSize;

            for (int i = 0; i < Effects.Count; i++)
            {
                var effect = Effects[i];

                if (effect.X < x || effect.X > x + winsize.X ||
                    effect.Y < y || effect.Y > y + winsize.Y)
                {
                    if (removeEffects)
                    {
                        Effects.RemoveAt(i--);

                        if (CurrentCount > 0)
                        {
                            CurrentCount--;
                        }
                        else
                        {
                            CurrentCount = 0;
                        }

                        continue;
                    }

                    effect.X = x + RandomHelper.GetValue(0, winsize.X);
                    effect.Y = y + RandomHelper.GetValue(0, winsize.Y);
                }


                switch ((WEATHER_TYPE)Type)
                {
                case WEATHER_TYPE.WT_RAIN:
                    float scaleRation = effect.ScaleRatio;
                    effect.SpeedX = -4.5f - scaleRation;
                    effect.SpeedY = 5.0f + scaleRation;
                    break;

                case WEATHER_TYPE.WT_FIERCE_STORM:
                    effect.SpeedX = Wind;
                    effect.SpeedY = 6.0f;
                    break;

                case WEATHER_TYPE.WT_SNOW:
                case WEATHER_TYPE.WT_STORM:

                    if (Type == (byte)WEATHER_TYPE.WT_SNOW)
                    {
                        effect.SpeedX = Wind;
                        effect.SpeedY = 1.0f;
                    }
                    else
                    {
                        effect.SpeedX = Wind * 1.5f;
                        effect.SpeedY = 1.5f;
                    }

                    if (windChanged)
                    {
                        effect.SpeedAngle     = MathHelper.ToDegrees((float)Math.Atan2(effect.SpeedX, effect.SpeedY));
                        effect.SpeedMagnitude =
                            (float)Math.Sqrt(Math.Pow(effect.SpeedX, 2) + Math.Pow(effect.SpeedY, 2));
                    }

                    float speed_angle     = effect.SpeedAngle;
                    float speed_magnitude = effect.SpeedMagnitude;

                    speed_magnitude += effect.ScaleRatio;

                    speed_angle += SinOscillate(0.4f, 20, Engine.Ticks + effect.ID);

                    var rad = MathHelper.ToRadians(speed_angle);
                    effect.SpeedX = speed_magnitude * (float)Math.Sin(rad);
                    effect.SpeedY = speed_magnitude * (float)Math.Cos(rad);

                    break;

                default:
                    break;
                }

                float speedOffset = passed / SimulationRation;

                switch ((WEATHER_TYPE)Type)
                {
                case WEATHER_TYPE.WT_RAIN:
                case WEATHER_TYPE.WT_FIERCE_STORM:

                    int oldX = (int)effect.X;
                    int oldY = (int)effect.Y;

                    float ofsx = effect.SpeedX * speedOffset;
                    float ofsy = effect.SpeedY * speedOffset;

                    effect.X += ofsx;
                    effect.Y += ofsy;

                    const float MAX_OFFSET_XY = 5.0f;

                    if (ofsx >= MAX_OFFSET_XY)
                    {
                        oldX = (int)(effect.X - MAX_OFFSET_XY);
                    }
                    else if (ofsx <= -MAX_OFFSET_XY)
                    {
                        oldX = (int)(effect.X + MAX_OFFSET_XY);
                    }

                    if (ofsy >= MAX_OFFSET_XY)
                    {
                        oldY = (int)(effect.Y - MAX_OFFSET_XY);
                    }
                    else if (oldY <= -MAX_OFFSET_XY)
                    {
                        oldY = (int)(effect.Y + MAX_OFFSET_XY);
                    }

                    batcher.DrawLine(Textures.GetTexture(Color.Gray), x + oldX, y + oldY,
                                     x + (int)effect.X, y + (int)effect.Y, 0, 0);
                    break;

                case WEATHER_TYPE.WT_SNOW:
                case WEATHER_TYPE.WT_STORM:

                    effect.X += effect.SpeedX * speedOffset;
                    effect.Y += effect.SpeedY * speedOffset;

                    batcher.Draw2D(Textures.GetTexture(Color.White),
                                   x + (int)effect.X, y + (int)effect.Y, 2, 2, ref _hueVector);

                    break;

                default:
                    break;
                }
            }

            LastTick = Engine.Ticks;
        }
Exemplo n.º 23
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();

            return(batcher.Draw2D(_texture, x, y, Width, Height, ref HueVector));
        }
Exemplo n.º 24
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (Texture == null)
            {
                return(false);
            }

            ResetHueVector();
            ShaderHueTranslator.GetHueVector(ref HueVector, Hue, IsPartial, Alpha);

            if (ScaleTexture)
            {
                if (Texture is ArtTexture artTexture)
                {
                    int       w = Width;
                    int       h = Height;
                    Rectangle r = artTexture.ImageRectangle;

                    if (r.Width < Width)
                    {
                        w  = r.Width;
                        x += (Width >> 1) - (w >> 1);
                    }

                    if (r.Height < Height)
                    {
                        h  = r.Height;
                        y += (Height >> 1) - (h >> 1);
                    }

                    return(batcher.Draw2D
                           (
                               Texture,
                               x,
                               y,
                               w,
                               h,
                               r.X,
                               r.Y,
                               r.Width,
                               r.Height,
                               ref HueVector
                           ));
                }

                return(batcher.Draw2D
                       (
                           Texture,
                           x,
                           y,
                           Width,
                           Height,
                           0,
                           0,
                           Texture.Width,
                           Texture.Height,
                           ref HueVector
                       ));
            }

            return(batcher.Draw2D(Texture, x, y, ref HueVector));
        }