Example #1
0
        public ScrollBar(int x, int y, int height)
        {
            Height           = height;
            Location         = new Point(x, y);
            AcceptMouseInput = true;


            _textureUpButton      = new UOTexture32[2];
            _textureUpButton[0]   = GumpsLoader.Instance.GetTexture(251);
            _textureUpButton[1]   = GumpsLoader.Instance.GetTexture(250);
            _textureDownButton    = new UOTexture32[2];
            _textureDownButton[0] = GumpsLoader.Instance.GetTexture(253);
            _textureDownButton[1] = GumpsLoader.Instance.GetTexture(252);
            _textureBackground    = new UOTexture32[3];
            _textureBackground[0] = GumpsLoader.Instance.GetTexture(257);
            _textureBackground[1] = GumpsLoader.Instance.GetTexture(256);
            _textureBackground[2] = GumpsLoader.Instance.GetTexture(255);
            _textureSlider        = GumpsLoader.Instance.GetTexture(254);
            Width = _textureBackground[0].Width;


            _rectDownButton    = new Rectangle(0, Height - _textureDownButton[0].Height, _textureDownButton[0].Width, _textureDownButton[0].Height);
            _rectUpButton      = new Rectangle(0, 0, _textureUpButton[0].Width, _textureUpButton[0].Height);
            _rectSlider        = new Rectangle((_textureBackground[0].Width - _textureSlider.Width) >> 1, _textureUpButton[0].Height + (int)_sliderPosition, _textureSlider.Width, _textureSlider.Height);
            _emptySpace.X      = 0;
            _emptySpace.Y      = _textureUpButton[0].Height;
            _emptySpace.Width  = _textureSlider.Width;
            _emptySpace.Height = Height - (_textureDownButton[0].Height + _textureUpButton[0].Height);
        }
Example #2
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();

            UOTexture32 texture_flag        = GumpsLoader.Instance.GetTexture(0x0828);
            UOTexture32 texture_button_up   = GumpsLoader.Instance.GetTexture(0x0824);
            UOTexture32 texture_button_down = GumpsLoader.Instance.GetTexture(0x0825);


            if (MaxValue != MinValue && texture_flag != null)
            {
                batcher.Draw2D(texture_flag, x, (int)(y + _sliderPosition), ref _hueVector);
            }

            if (_showButtons)
            {
                if (texture_button_up != null)
                {
                    batcher.Draw2D(texture_button_up, x, y, ref _hueVector);
                }

                if (texture_button_down != null)
                {
                    batcher.Draw2D(texture_button_down, x, y + Height, ref _hueVector);
                }
            }

            return(base.Draw(batcher, x, y));
        }
Example #3
0
        protected static void DrawLand
        (
            UltimaBatcher2D batcher,
            ushort graphic, int x, int y,
            ref Rectangle rectangle,
            ref Vector3 n0, ref Vector3 n1, ref Vector3 n2, ref Vector3 n3,
            ref Vector3 hue
        )
        {
            UOTexture32 texture = TexmapsLoader.Instance.GetTexture
                                  (
                TileDataLoader.Instance.LandData[graphic]
                .TexID
                                  );

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

                batcher.DrawSpriteLand(texture, x, y, ref rectangle, ref n0, ref n1, ref n2, ref n3, ref hue);
            }
            else
            {
                DrawStatic(batcher, graphic, x, y, ref hue);
            }
        }
Example #4
0
 private void CreateMap()
 {
     _gumpTexture = GumpsLoader.Instance.GetTexture(_useLargeMap ? (ushort)5011 : (ushort)5010);
     Width        = _gumpTexture.Width;
     Height       = _gumpTexture.Height;
     CreateMiniMapTexture(true);
 }
Example #5
0
        public ResizePic(ushort graphic)
        {
            CanMove = true;
            CanCloseWithRightClick = true;

            for (int i = 0; i < _gumpTexture.Length; i++)
            {
                UOTexture32 t = GumpsLoader.Instance.GetTexture((ushort)(graphic + i));

                if (t == null)
                {
                    return;
                }

                if (i == 4)
                {
                    _gumpTexture[8] = t;
                }
                else if (i > 4)
                {
                    _gumpTexture[i - 1] = t;
                }
                else
                {
                    _gumpTexture[i] = t;
                }
            }

            Graphic = graphic;
        }
Example #6
0
        public ClickableColorBox(int x, int y, int w, int h, ushort hue, uint color) : base(w, h, hue, color)
        {
            X = x + 3;
            Y = y + 3;
            WantUpdateSize = false;

            _background = GumpsLoader.Instance.GetTexture(0x00D4);
        }
Example #7
0
        public void SetMapTexture(UOTexture32 texture)
        {
            _textureControl.Texture?.Dispose();
            _textureControl.WantUpdateSize = true;
            _textureControl.Texture        = texture;

            WantUpdateSize = true;
        }
Example #8
0
 internal GumpPicTiled(int x, int y, int width, int heigth, UOTexture32 texture)
 {
     CanMove          = true;
     AcceptMouseInput = true;
     X       = x;
     Y       = y;
     Width   = width;
     Height  = heigth;
     Graphic = 0xFFFF;
 }
Example #9
0
        protected static void DrawLand(UltimaBatcher2D batcher, ushort graphic, int x, int y, ref Vector3 hue)
        {
            UOTexture32 texture = ArtLoader.Instance.GetLandTexture(graphic);

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

                batcher.DrawSprite(texture, x, y, false, ref hue);
            }
        }
Example #10
0
        public HSliderBar(int x, int y, int w, int min, int max, int value, HSliderBarStyle style, bool hasText = false, byte font = 0, ushort color = 0, bool unicode = true, bool drawUp = false)
        {
            X = x;
            Y = y;

            if (hasText)
            {
                _text   = RenderedText.Create(string.Empty, color, font, unicode);
                _drawUp = drawUp;
            }

            MinValue         = min;
            MaxValue         = max;
            BarWidth         = w;
            _style           = style;
            AcceptMouseInput = true;


            if (_gumpWidget == null)
            {
                switch (_style)
                {
                case HSliderBarStyle.MetalWidgetRecessedBar:

                    _gumpSpliderBackground = new UOTexture32[3]
                    {
                        GumpsLoader.Instance.GetTexture(213), GumpsLoader.Instance.GetTexture(214), GumpsLoader.Instance.GetTexture(215)
                    };

                    _gumpWidget = GumpsLoader.Instance.GetTexture(216);

                    break;

                case HSliderBarStyle.BlueWidgetNoBar:
                    _gumpWidget = GumpsLoader.Instance.GetTexture(0x845);

                    break;
                }

                Width = BarWidth;

                if (_gumpWidget != null)
                {
                    Height = _gumpWidget.Height;
                }

                //RecalculateSliderX();
                CalculateOffset();
            }

            Value = value;
        }
Example #11
0
        public override bool Contains(int x, int y)
        {
            UOTexture32 texture_flag = GumpsLoader.Instance.GetTexture(0x0828);

            if (texture_flag == null)
            {
                return(false);
            }

            y -= (int)_sliderPosition;

            return(texture_flag.Contains(x, y));
        }
Example #12
0
        private void GenerateVirtualTextures()
        {
            _shopGumpParts = new UOTexture32[12];
            var t = GumpsLoader.Instance.GetTexture(0x0870);

            UOTexture32[][] splits = new UOTexture32[4][];

            splits[0] = Utility.GraphicHelper.SplitTexture16(t,
                                                             new int[3, 4]
            {
                { 0, 0, t.Width, 64 },
                { 0, 64, t.Width, 124 },
                { 0, 124, t.Width, t.Height - 124 }
            });
            t = GumpsLoader.Instance.GetTexture(0x0871);

            splits[1] = Utility.GraphicHelper.SplitTexture16(t,
                                                             new int[3, 4]
            {
                { 0, 0, t.Width, 64 },
                { 0, 64, t.Width, 94 },
                { 0, 94, t.Width, t.Height - 94 }
            });
            t = GumpsLoader.Instance.GetTexture(0x0872);

            splits[2] = Utility.GraphicHelper.SplitTexture16(t,
                                                             new int[3, 4]
            {
                { 0, 0, t.Width, 64 },
                { 0, 64, t.Width, 124 },
                { 0, 124, t.Width, t.Height - 124 }
            });
            t = GumpsLoader.Instance.GetTexture(0x0873);

            splits[3] = Utility.GraphicHelper.SplitTexture16(t,
                                                             new int[3, 4]
            {
                { 0, 0, t.Width, 64 },
                { 0, 64, t.Width, 94 },
                { 0, 94, t.Width, t.Height - 94 }
            });

            for (int i = 0, idx = 0; i < splits.Length; i++)
            {
                for (int ii = 0; ii < splits[i].Length; ii++)
                {
                    _shopGumpParts[idx++] = splits[i][ii];
                }
            }
        }
Example #13
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            ResetHueVector();
            ShaderHueTranslator.GetHueVector(ref _hueVector, Hue);

            UOTexture32 texture = GumpsLoader.Instance.GetTexture(Graphic);

            if (texture != null)
            {
                return(batcher.Draw2DTiled(texture, x, y, Percent, Height, ref _hueVector));
            }

            return(false);
        }
Example #14
0
        public Button(int buttonID, ushort normal, ushort pressed, ushort over = 0, string caption = "", byte font = 0, bool isunicode = true, ushort normalHue = ushort.MaxValue, ushort hoverHue = ushort.MaxValue)
        {
            ButtonID = buttonID;
            _gumpGraphics[NORMAL]  = normal;
            _gumpGraphics[PRESSED] = pressed;
            _gumpGraphics[OVER]    = over;
            _textures[NORMAL]      = GumpsLoader.Instance.GetTexture(normal);
            _textures[PRESSED]     = GumpsLoader.Instance.GetTexture(pressed);

            if (over > 0)
            {
                _textures[OVER] = GumpsLoader.Instance.GetTexture(over);
            }

            UOTexture32 t = _textures[NORMAL];

            if (t == null)
            {
                Dispose();

                return;
            }

            Width    = t.Width;
            Height   = t.Height;
            FontHue  = normalHue == ushort.MaxValue ? (ushort)0 : normalHue;
            HueHover = hoverHue == ushort.MaxValue ? normalHue : hoverHue;

            if (!string.IsNullOrEmpty(caption) && normalHue != ushort.MaxValue)
            {
                _fontTexture = new RenderedText[2];

                _caption = caption;

                _fontTexture[0] = RenderedText.Create(caption, FontHue, font, isunicode);

                if (hoverHue != ushort.MaxValue)
                {
                    _fontTexture[1] = RenderedText.Create(caption, HueHover, font, isunicode);
                }
            }

            CanMove          = false;
            AcceptMouseInput = true;
            //CanCloseWithRightClick = false;
            CanCloseWithEsc = false;
        }
Example #15
0
        public override bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            base.Draw(batcher, x, y);

            if (ShowLock)
            {
                ResetHueVector();

                UOTexture32 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 = Texture2DCache.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);
        }
Example #16
0
        /// <summary>
        ///     Splits a texture into an array of smaller textures of the specified size.
        /// </summary>
        /// <param name="original">The texture to be split into smaller textures</param>
        /// <param name="partXYplusWidthHeight">
        ///     We must specify here an array with size of 'parts' for the first dimension,
        ///     for each part, in the second dimension, we specify:
        ///     starting x and y, plus width and height for that specified part (4 as size in second dimension).
        /// </param>
        internal static UOTexture32[] SplitTexture16(UOTexture32 original, int[,] partXYplusWidthHeight)
        {
            if (partXYplusWidthHeight.GetLength(0) == 0 || partXYplusWidthHeight.GetLength(1) < 4)
            {
                return(null);
            }

            UOTexture32[] r       = new UOTexture32[partXYplusWidthHeight.GetLength(0)];
            int           pwidth  = original.Width;  //((original.Width + 1) >> 1) << 1;
            int           pheight = original.Height; //((original.Height + 1) >> 1) << 1;

            uint[] originalData = original.Data;

            int index = 0;

            for (int p = 0; p < partXYplusWidthHeight.GetLength(0); p++)
            {
                int         x = partXYplusWidthHeight[p, 0], y = partXYplusWidthHeight[p, 1], width = partXYplusWidthHeight[p, 2], height = partXYplusWidthHeight[p, 3];
                UOTexture32 part     = new UOTexture32(width, height);
                uint[]      partData = new uint[width * height];

                for (int py = 0; py < height; py++)
                {
                    for (int px = 0; px < width; px++)
                    {
                        int partIndex = px + py * width;

                        //If a part goes outside of the source texture, then fill the overlapping part with transparent
                        if (y + py >= pheight || x + px >= pwidth)
                        {
                            partData[partIndex] = 0;
                        }
                        else
                        {
                            partData[partIndex] = originalData[x + px + (y + py) * pwidth];
                        }
                    }
                }

                part.PushData(partData);
                r[index++] = part;
            }

            return(r);
        }
Example #17
0
        private static bool PixelsInXY(UOTexture32 texture, int x, int y, int width = 0, int height = 0)
        {
            if (x < 0 || y < 0 || (width > 0 && x >= width) || (height > 0 && y >= height))
            {
                return(false);
            }

            int textureWidth  = texture.Width;
            int textureHeight = texture.Height;

            if (width == 0)
            {
                width = textureWidth;
            }

            if (height == 0)
            {
                height = textureHeight;
            }


            while (x >= textureWidth && width >= textureWidth)
            {
                x     -= textureWidth;
                width -= textureWidth;
            }

            if (x < 0 || x > width)
            {
                return(false);
            }

            while (y >= textureHeight && height >= textureHeight)
            {
                y      -= textureHeight;
                height -= textureHeight;
            }

            if (y < 0 || y > height)
            {
                return(false);
            }

            return(texture.Contains(x, y));
        }
Example #18
0
        public QuestionGump(string message, Action <bool> result) : base(0, 0)
        {
            CanCloseWithRightClick = true;
            Add(new GumpPic(0, 0, 0x0816, 0));

            UOTexture32 t = GumpsLoader.Instance.GetTexture(0x0816);

            Width  = t.Width;
            Height = t.Height;


            Add
            (
                new Label(message, false, 0x0386, 165)
            {
                X = 33, Y = 30
            }
            );

            Add
            (
                new Button((int)Buttons.Cancel, 0x817, 0x818, 0x0819)
            {
                X = 37, Y = 75, ButtonAction = ButtonAction.Activate
            }
            );

            Add
            (
                new Button((int)Buttons.Ok, 0x81A, 0x81B, 0x081C)
            {
                X = 100, Y = 75, ButtonAction = ButtonAction.Activate
            }
            );

            CanMove             = false;
            ControlInfo.IsModal = true;

            X = (Client.Game.Window.ClientBounds.Width - Width) >> 1;
            Y = (Client.Game.Window.ClientBounds.Height - Height) >> 1;

            WantUpdateSize = false;
            _result        = result;
        }
Example #19
0
        public void SetColor(ushort hue, uint pol)
        {
            Hue = hue;

            (byte b, byte g, byte r, byte a) = HuesHelper.GetBGRA(HuesHelper.RgbaToArgb(pol));

            _colorRGBA = new Color(a, b, g, r);

            if (_colorRGBA.A == 0)
            {
                _colorRGBA.A = 0xFF;
            }

            if (Texture == null || Texture.IsDisposed)
            {
                Texture = new UOTexture32(1, 1);
            }
            Texture.SetData(new Color[1] {
                _colorRGBA
            });
        }
Example #20
0
            public override bool Draw(UltimaBatcher2D batcher, int x, int y)
            {
                ResetHueVector();
                ShaderHueTranslator.GetHueVector(ref _hueVector, 0, false, 1.0f - _alpha / 255f, true);

                UOTexture32 texture = GumpsLoader.Instance.GetTexture(Graphic);

                if (texture != null)
                {
                    if (ProfileManager.Current != null && ProfileManager.Current.BuffBarTime)
                    {
                        batcher.Draw2D(texture, x, y, ref _hueVector);

                        return(_gText.Draw(batcher, x - 3, y + texture.Height / 2 - 3, _hueVector.Z));
                    }

                    return(batcher.Draw2D(texture, x, y, ref _hueVector));
                }

                return(false);
            }
Example #21
0
        protected override void OnMouseOver(int x, int y)
        {
            if (_btnSliderClicked)
            {
                if (y != _clickPosition.Y)
                {
                    float sliderY = _sliderPosition + (y - _clickPosition.Y);

                    if (sliderY < 0)
                    {
                        sliderY = 0;
                    }

                    float scrollableArea = GetScrollableArea();

                    if (sliderY > scrollableArea)
                    {
                        sliderY = scrollableArea;
                    }

                    _clickPosition = new Point(x, y);

                    UOTexture32 texture = GumpsLoader.Instance.GetTexture(0x0828);
                    int         height  = texture?.Height ?? 0;


                    if (sliderY == 0 && _clickPosition.Y < height >> 1)
                    {
                        _clickPosition.Y = height >> 1;
                    }
                    else if (sliderY == scrollableArea && _clickPosition.Y > Height - (height >> 1))
                    {
                        _clickPosition.Y = Height - (height >> 1);
                    }

                    _value          = (int)Math.Round(sliderY / scrollableArea * (MaxValue - MinValue) + MinValue);
                    _sliderPosition = sliderY;
                }
            }
        }
Example #22
0
        public ButtonTileArt(List <string> gparams) :
            base(gparams)
        {
            X = int.Parse(gparams[1]);
            Y = int.Parse(gparams[2]);
            ushort graphic = UInt16Converter.Parse(gparams[8]);

            _hue             = UInt16Converter.Parse(gparams[9]);
            _tileX           = int.Parse(gparams[10]);
            _tileY           = int.Parse(gparams[11]);
            ContainsByBounds = true;
            IsFromServer     = true;
            _texture         = ArtLoader.Instance.GetTexture(graphic);

            if (_texture == null)
            {
                Dispose();
                return;
            }

            _isPartial = TileDataLoader.Instance.StaticData[graphic].IsPartialHue;
        }
Example #23
0
        public Checkbox(ushort inactive, ushort active, string text = "", byte font = 0, ushort color = 0, bool isunicode = true, int maxWidth = 0)
        {
            _textures[INACTIVE] = GumpsLoader.Instance.GetTexture(inactive);
            _textures[ACTIVE]   = GumpsLoader.Instance.GetTexture(active);

            if (_textures[0] == null || _textures[1] == null)
            {
                Dispose();

                return;
            }

            UOTexture32 t = _textures[INACTIVE];

            Width = t.Width;

            _text  = RenderedText.Create(text, color, font, isunicode, maxWidth: maxWidth);
            Width += _text.Width;

            Height           = Math.Max(t.Width, _text.Height);
            CanMove          = false;
            AcceptMouseInput = true;
        }
Example #24
0
        public ScrollFlag()
        {
            AcceptMouseInput = true;

            UOTexture32 texture_flag = GumpsLoader.Instance.GetTexture(0x0828);

            if (texture_flag == null)
            {
                Dispose();

                return;
            }

            Width  = texture_flag.Width;
            Height = texture_flag.Height;

            UOTexture32 texture_button_up   = GumpsLoader.Instance.GetTexture(0x0824);
            UOTexture32 texture_button_down = GumpsLoader.Instance.GetTexture(0x0825);

            _rectUpButton   = new Rectangle(0, 0, texture_button_up.Width, texture_button_up.Height);
            _rectDownButton = new Rectangle(0, Height, texture_button_down.Width, texture_button_down.Height);

            WantUpdateSize = false;
        }
Example #25
0
        public static void CalculateContainerPosition(uint serial, ushort g)
        {
            if (UIManager.GetGumpCachePosition(serial, out Point location))
            {
                X = location.X;
                Y = location.Y;
            }
            else
            {
                UOTexture32 texture = GumpsLoader.Instance.GetTexture(g);

                if (texture != null)
                {
                    float scale = UIManager.ContainerScale;

                    int width  = (int)(texture.Width * scale);
                    int height = (int)(texture.Height * scale);

                    if (ProfileManager.Current.OverrideContainerLocation)
                    {
                        switch (ProfileManager.Current.OverrideContainerLocationSetting)
                        {
                        case 0:
                            SetPositionNearGameObject(g, serial, width, height);
                            break;

                        case 1:
                            X = Client.Game.Window.ClientBounds.Width - width;
                            Y = 0;
                            break;

                        case 2:
                        case 3:
                            X = ProfileManager.Current.OverrideContainerLocationPosition.X - (width >> 1);
                            Y = ProfileManager.Current.OverrideContainerLocationPosition.Y - (height >> 1);
                            break;
                        }

                        if ((X + width) > Client.Game.Window.ClientBounds.Width)
                        {
                            X -= width;
                        }

                        if ((Y + height) > Client.Game.Window.ClientBounds.Height)
                        {
                            Y -= height;
                        }
                    }
                    else
                    {
                        int passed = 0;

                        for (int i = 0; i < 4 && passed == 0; i++)
                        {
                            if (X + texture.Width + Constants.CONTAINER_RECT_STEP > Client.Game.Window.ClientBounds.Width)
                            {
                                X = Constants.CONTAINER_RECT_DEFAULT_POSITION;

                                if (Y + texture.Height + Constants.CONTAINER_RECT_LINESTEP > Client.Game.Window.ClientBounds.Height)
                                {
                                    Y = Constants.CONTAINER_RECT_DEFAULT_POSITION;
                                }
                                else
                                {
                                    Y += Constants.CONTAINER_RECT_LINESTEP;
                                }
                            }
                            else if (Y + texture.Height + Constants.CONTAINER_RECT_STEP > Client.Game.Window.ClientBounds.Height)
                            {
                                if (X + texture.Width + Constants.CONTAINER_RECT_LINESTEP > Client.Game.Window.ClientBounds.Width)
                                {
                                    X = Constants.CONTAINER_RECT_DEFAULT_POSITION;
                                }
                                else
                                {
                                    X += Constants.CONTAINER_RECT_LINESTEP;
                                }

                                Y = Constants.CONTAINER_RECT_DEFAULT_POSITION;
                            }
                            else
                            {
                                passed = i + 1;
                            }
                        }

                        if (passed == 0)
                        {
                            X = DefaultX;
                            Y = DefaultY;
                        }
                        else if (passed == 1)
                        {
                            X += Constants.CONTAINER_RECT_STEP;
                            Y += Constants.CONTAINER_RECT_STEP;
                        }
                    }
                }
            }
        }
Example #26
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++)
            {
                UOTexture32 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;
                }
            }
        }
Example #27
0
        private TopBarGump() : base(0, 0)
        {
            CanMove                = true;
            AcceptMouseInput       = true;
            CanCloseWithRightClick = false;

            // little
            Add(new ResizePic(0x13BE)
            {
                Width = 30, Height = 27
            }, 2);
            Add(new Button(0, 0x15A1, 0x15A1, 0x15A1)
            {
                X = 5, Y = 3, ToPage = 1
            }, 2);


            // big
            UOTexture32 th1 = GumpsLoader.Instance.GetTexture(0x098B);
            UOTexture32 th2 = GumpsLoader.Instance.GetTexture(0x098D);

            int smallWidth = 50;

            if (th1 != null)
            {
                smallWidth = th1.Width;
            }

            int largeWidth = 100;

            if (th2 != null)
            {
                largeWidth = th2.Width;
            }

            int[][] textTable =
            {
                new [] { 0, (int)Buttons.Map        },
                new [] { 1, (int)Buttons.Paperdoll  },
                new [] { 1, (int)Buttons.Inventory  },
                new [] { 1, (int)Buttons.Journal    },
                new [] { 0, (int)Buttons.Chat       },
                new [] { 0, (int)Buttons.Help       },
                new [] { 1, (int)Buttons.WorldMap   },
                new [] { 0, (int)Buttons.Info       },
                new [] { 0, (int)Buttons.Debug      },
                new [] { 1, (int)Buttons.NetStats   },

                new [] { 1, (int)Buttons.UOStore    },
                new [] { 1, (int)Buttons.GlobalChat },
            };

            string[] texts = { "Map", "Paperdoll", "Inventory", "Journal", "Chat", "Help", "World Map", "< ? >", "Debug", "NetStats", "UOStore", "Global Chat" };

            bool hasUOStore = Client.Version >= ClientVersion.CV_706400;

            ResizePic background;

            Add(background = new ResizePic(0x13BE)
            {
                Height = 27
            }, 1);

            Add(new Button(0, 0x15A4, 0x15A4, 0x15A4)
            {
                X = 5, Y = 3, ToPage = 2
            }, 1);

            int startX = 30;

            for (int i = 0; i < textTable.Length; i++)
            {
                if (!hasUOStore && i >= (int)Buttons.UOStore)
                {
                    break;
                }

                ushort graphic = (ushort)(textTable[i][0] != 0 ? 0x098D : 0x098B);

                Add(new RighClickableButton(textTable[i][1], graphic, graphic, graphic, texts[i], 1, true, 0, 0x0036)
                {
                    ButtonAction = ButtonAction.Activate,
                    X            = startX,
                    Y            = 1,
                    FontCenter   = true
                }, 1);

                startX          += (textTable[i][0] != 0 ? largeWidth : smallWidth) + 1;
                background.Width = startX;
            }

            background.Width = startX + 1;

            //layer
            ControlInfo.Layer = UILayer.Over;
        }
Example #28
0
        private void CreateMiniMapTexture(bool force = false)
        {
            if (_gumpTexture == null || _gumpTexture.IsDisposed)
            {
                return;
            }

            ushort lastX = World.Player.X;
            ushort lastY = World.Player.Y;


            if (_x != lastX || _y != lastY)
            {
                _x = lastX;
                _y = lastY;
            }
            else if (!force)
            {
                return;
            }

            if (_mapTexture != null && !_mapTexture.IsDisposed)
            {
                _mapTexture.Dispose();
            }
            int blockOffsetX = Width >> 2;
            int blockOffsetY = Height >> 2;
            int gumpCenterX  = Width >> 1;
            //int gumpCenterY = Height >> 1;

            //0xFF080808 - pixel32
            //0x8421 - pixel16
            int minBlockX = ((lastX - blockOffsetX) >> 3) - 1;
            int minBlockY = ((lastY - blockOffsetY) >> 3) - 1;
            int maxBlockX = ((lastX + blockOffsetX) >> 3) + 1;
            int maxBlockY = ((lastY + blockOffsetY) >> 3) + 1;

            if (minBlockX < 0)
            {
                minBlockX = 0;
            }

            if (minBlockY < 0)
            {
                minBlockY = 0;
            }
            int maxBlockIndex  = World.Map.BlocksCount;
            int mapBlockHeight = MapLoader.Instance.MapBlocksSize[World.MapIndex, 1];
            var data           = GumpsLoader.Instance.GetGumpPixels(_useLargeMap ? (uint)5011 : 5010, out _, out _);

            Point[] table = new Point[2]
            {
                new Point(0, 0), new Point(0, 1)
            };

            for (int i = minBlockX; i <= maxBlockX; i++)
            {
                int blockIndexOffset = i * mapBlockHeight;

                for (int j = minBlockY; j <= maxBlockY; j++)
                {
                    int blockIndex = blockIndexOffset + j;

                    if (blockIndex >= maxBlockIndex)
                    {
                        break;
                    }

                    RadarMapBlock?mbbv = MapLoader.Instance.GetRadarMapBlock(World.MapIndex, i, j);

                    if (!mbbv.HasValue)
                    {
                        break;
                    }

                    RadarMapBlock mb         = mbbv.Value;
                    Chunk         block      = World.Map.Chunks[blockIndex];
                    int           realBlockX = i << 3;
                    int           realBlockY = j << 3;

                    for (int x = 0; x < 8; x++)
                    {
                        int px = realBlockX + x - lastX + gumpCenterX;

                        for (int y = 0; y < 8; y++)
                        {
                            int  py     = realBlockY + y - lastY;
                            int  gx     = px - py;
                            int  gy     = px + py;
                            int  color  = mb.Cells[x, y].Graphic;
                            bool island = mb.Cells[x, y].IsLand;

                            if (block != null)
                            {
                                GameObject obj = block.Tiles[x, y];

                                while (obj?.TNext != null)
                                {
                                    obj = obj.TNext;
                                }

                                for (; obj != null; obj = obj.TPrevious)
                                {
                                    if (obj is Multi)
                                    {
                                        if (obj.Hue == 0)
                                        {
                                            color  = obj.Graphic;
                                            island = false;
                                        }
                                        else
                                        {
                                            color = obj.Hue + 0x4000;
                                        }
                                        break;
                                    }
                                }
                            }

                            if (!island)
                            {
                                color += 0x4000;
                            }
                            int tableSize = 2;
                            if (island && color > 0x4000)
                            {
                                color = HuesLoader.Instance.GetColor16(16384, (ushort)(color - 0x4000));//28672 is an arbitrary position in hues.mul, is the 14 position in the range
                            }
                            else
                            {
                                color = HuesLoader.Instance.GetRadarColorData(color);
                            }
                            CreatePixels(data, 0x8000 | color, gx, gy, Width, Height, table, tableSize);
                        }
                    }
                }
            }

            _mapTexture = new UOTexture32(Width, Height);
            _mapTexture.PushData(data);
        }
Example #29
0
 public static bool IsPointInStatic(UOTexture32 texture, int x, int y)
 {
     return(texture != null && texture.Contains(TranslatedMousePositionByViewport.X - x, TranslatedMousePositionByViewport.Y - y));
 }
Example #30
0
 public override void Dispose()
 {
     Texture = null;
     base.Dispose();
 }