Exemplo n.º 1
0
        /// <summary>
        /// Loads a texture. Can only be called from the main thread.
        /// </summary>
        /// <param name="texturePath">The texture's path</param>
        /// <param name="flip">Indicates if the texture must be vertically flipped. Default is False.</param>
        /// <returns></returns>
        public Texture2D LoadTexture(string texturePath, bool flip = false)
        {
            // Try to get the cached Texture2D.
            Texture2D texture;

            lock (dictionariesLock)
            {
                cachedTextures.TryGetValue(texturePath, out texture);
            }

            // If there is no cached Texture2D.
            if (texture == null)
            {
                // Load the Texture2DInfo.
                Texture2DInfo textureInfo = LoadTextureInfoAndRemoveFromCache(texturePath);

                texture = textureInfo.ToTexture2D();

                lock (dictionariesLock)
                {
                    cachedTextures[texturePath] = texture;
                }
            }

            if (texture != null && flip)
            {
                TextureUtils.FlipTexture2DVertically(texture);
            }

            return(texture);
        }
Exemplo n.º 2
0
        public static void PrintTextures()
        {
            string[]             guids = AssetDatabase.FindAssets("t:texture2D");
            List <Texture2DInfo> list  = new List <Texture2DInfo>();

            foreach (string guid in guids)
            {
                var       path = AssetDatabase.GUIDToAssetPath(guid);
                Texture2D t    = (Texture2D)AssetDatabase.LoadAssetAtPath(path, typeof(Texture2D));
                if (t != null)
                {
                    var info = new Texture2DInfo();
                    info.texture = t;
                    info.path    = path;
                    list.Add(info);
                }
            }

            List <Texture2DInfo> sorted = list.OrderBy(o => (-o.texture.width * o.texture.height)).ToList();

            foreach (Texture2DInfo info in sorted)
            {
                var t = info.texture;
                LogUtil.Debug("path=" + info.path + " size=" + t.width + "x" + t.height + " mipmaps=" + t.mipmapCount + " format=" + t.format);
            }
        }
Exemplo n.º 3
0
        public override void Update(double totalMS, double frameMS)
        {
            if (_gumpWidget == null)
            {
                var provider = Service.Get <IResourceProvider>();
                switch (Style)
                {
                default:
                case HSliderBarStyle.MetalWidgetRecessedBar:
                    _gumpSliderBackground    = new Texture2DInfo[3];
                    _gumpSliderBackground[0] = provider.GetUITexture(213);
                    _gumpSliderBackground[1] = provider.GetUITexture(214);
                    _gumpSliderBackground[2] = provider.GetUITexture(215);
                    _gumpWidget = provider.GetUITexture(216);
                    break;

                case HSliderBarStyle.BlueWidgetNoBar:
                    _gumpWidget = provider.GetUITexture(0x845);
                    break;
                }
                Size = new Vector2Int(BarWidth, _gumpWidget.Height);
                RecalculateSliderX();
            }
            modifyPairedValues(_newValue - Value);
            _value = _newValue;
            base.Update(totalMS, frameMS);
        }
Exemplo n.º 4
0
 internal static Bitmap LoadRawBitmap(Stream inputStream)
 {
     using (var r = new BinaryFileReader(inputStream))
     {
         var header       = r.ReadT <BitmapHeader>(0x10);
         var frameCount   = header.FrameCount;
         var frameOffsets = r.ReadTArray <BitmapFrameOffset>(frameCount * 0x08, frameCount);
         var frames       = new Texture2DInfo[frameCount];
         for (var i = 0; i < frameCount; i++)
         {
             r.Position = frameOffsets[i].Offset;
             var frame         = r.ReadT <BitmapFrame>(0x14);
             var frameHeight   = (int)frame.height;
             var sizeOfFrame   = 0x14 + frameHeight * 0x04;
             var frameDataSize = (int)(frameHeight * frame.width);
             var bitsPerPixel  = (int)((frameOffsets[i].Size - sizeOfFrame) / frameDataSize);
             var offsets       = r.ReadTArray <uint>(frameHeight * 0x04, frameHeight); // Offset to the data for each row relative to the start of the resource.
             if (offsets[0] == 0xCDCDCDCD)                                             //: unknownFrame
             {
                 continue;
             }
             r.Position = frameOffsets[i].Offset + offsets[0];
             var rawData = r.ReadBytes(frameDataSize * bitsPerPixel);
             frames[i] = bitsPerPixel == 1
                 ? new Texture2DInfo((int)frame.width, (int)frame.height, UnityEngine.TextureFormat.RGBA32, false, rawData).From8BitPallet(GetGlobal8BitPallet(), UnityEngine.TextureFormat.RGBA32)
                 : new Texture2DInfo((int)frame.width, (int)frame.height, UnityEngine.TextureFormat.RGBA32, false, rawData).FromABGR555();
         }
         return(new Bitmap
         {
             Header = header,
             Frames = frames,
         });
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Draws a quad on screen with the specified texture and vertices.
        /// </summary>
        /// <param name="texture"></param>
        /// <param name="vertices"></param>
        /// <returns>True if the object was drawn, false otherwise.</returns>
        public bool DrawSprite(Texture2DInfo texture, VertexPositionNormalTextureHue[] vertices, Techniques effect = Techniques.Default)
        {
            var draw = false;

            // Sanity: do not draw if there is no texture to draw with.
            if (texture == null)
            {
                return(false);
            }
            // Check: only draw if the texture is within the visible area.
            for (var i = 0; i < 4; i++) // only draws a 2 triangle tristrip.
            //if (_viewportArea.Contains(vertices[i].Position) == ContainmentType.Contains)
            {
                draw = true;
                break;
            }
            if (!draw)
            {
                return(false);
            }
            // Set the draw position's z value, and increment the z value for the next drawn object.
            vertices[0].Position.z = vertices[1].Position.z = vertices[2].Position.z = vertices[3].Position.z = GetNextUniqueZ();
            // Get the vertex list for this texture. if none exists, dequeue existing or create a new vertex list.
            var vertexList = GetVertexList(texture, effect);

            // Add the drawn object to the vertex list.
            for (var i = 0; i < vertices.Length; i++)
            {
                vertexList.Add(vertices[i]);
            }
            return(true);
        }
Exemplo n.º 6
0
 public HuedTexture(Texture2DInfo texture, Vector2Int offset, RectInt source, int hue)
 {
     _texture    = texture;
     _offset     = offset;
     _sourceRect = source;
     _hue        = hue;
 }
Exemplo n.º 7
0
        /// <summary>
        /// Draws a special 'shadow' sprite, automatically skewing the passed vertices.
        /// </summary>
        /// <param name="texture">The texture to draw with.</param>
        /// <param name="vertices">An array of four vertices. Note: modified by this routine.</param>
        /// <param name="drawPosition">The draw position at which this sprite begins (should be the center of an isometric tile for non-moving sprites).</param>
        /// <param name="flipVertices">See AEntityView.Draw(); this is equivalent to DrawFlip.</param>
        /// <param name="z">The z depth at which the shadow sprite should be placed.</param>
        public void DrawShadow(Texture2DInfo texture, VertexPositionNormalTextureHue[] vertices, Vector2 drawPosition, bool flipVertices, float z)
        {
            // Sanity: do not draw if there is no texture to draw with.
            if (texture == null)
            {
                return;
            }
            // set proper z depth for this shadow.
            vertices[0].Position.z = vertices[1].Position.z = vertices[2].Position.z = vertices[3].Position.z = z;
            // skew texture
            var skewHorizTop    = (vertices[0].Position.y - drawPosition.y) * .5f;
            var skewHorizBottom = (vertices[3].Position.y - drawPosition.y) * .5f;

            vertices[0].Position.x -= skewHorizTop;
            vertices[0].Position.y -= skewHorizTop;
            vertices[flipVertices ? 2 : 1].Position.x -= skewHorizTop;
            vertices[flipVertices ? 2 : 1].Position.y -= skewHorizTop;
            vertices[flipVertices ? 1 : 2].Position.x -= skewHorizBottom;
            vertices[flipVertices ? 1 : 2].Position.y -= skewHorizBottom;
            vertices[3].Position.x -= skewHorizBottom;
            vertices[3].Position.y -= skewHorizBottom;
            var vertexList = GetVertexList(texture, Techniques.ShadowSet);

            for (var i = 0; i < vertices.Length; i++)
            {
                vertexList.Add(vertices[i]);
            }
        }
Exemplo n.º 8
0
        public bool Draw2DTiled(Texture2DInfo texture, RectInt destRect, Vector3 hue)
        {
            var     y = destRect.y;
            var     h = destRect.height;
            RectInt rect;

            while (h > 0)
            {
                int x = destRect.x;
                int w = destRect.width;
                if (h < texture.Height)
                {
                    rect = new RectInt(0, 0, texture.Width, h);
                }
                else
                {
                    rect = new RectInt(0, 0, texture.Width, texture.Height);
                }
                while (w > 0)
                {
                    if (w < texture.Width)
                    {
                        rect.width = w;
                    }
                    Draw2D(texture, new Vector3(x, y, 0), rect, hue);
                    w -= texture.Width;
                    x += texture.Width;
                }
                h -= texture.Height;
                y += texture.Height;
            }
            return(true);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Renders all the elements in the root branch. At the same time, also sets areas for regions and href links.
        /// TODO: code for setting areas for regions / hrefs belongs in layout code in HtmlDocument.
        /// </summary>
        public Texture2DInfo Render(BlockElement root, int ascender, HtmlLinkList links)
        {
            var sb = Service.Get <SpriteBatchUI>();

            if (root == null || root.Width == 0 || root.Height == 0) // empty text string
            {
                return(new Texture2DInfo(1, 1));
            }
            var pixels = new uint[root.Width * root.Height];

            if (root.Err_Cant_Fit_Children)
            {
                for (var i = 0; i < pixels.Length; i++)
                {
                    pixels[i] = 0xffffff00;
                }
                Utils.Error("Err: Block can't fit children.");
            }
            else
            {
                unsafe
                {
                    fixed(uint *ptr = pixels)
                    {
                        DoRenderBlock(root, ascender, links, ptr, root.Width, root.Height);
                    }
                }
            }

            var texture = new Texture2DInfo(root.Width, root.Height, TextureFormat.RGBA32, false);

            //texture.SetData(pixels);
            return(texture);
        }
Exemplo n.º 10
0
        protected override void OnInitialize()
        {
            base.OnInitialize();
            var provider = Service.Get <IResourceProvider>();

            _gumpSlider = provider.GetUITexture(0x0828);
            Size        = new Vector2Int(_gumpSlider.Width, _gumpSlider.Height);
        }
Exemplo n.º 11
0
 public bool Draw2D(Texture2DInfo texture, RectInt destRect, Vector3 hue)
 {
     _allocatedVertices[0]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x, destRect.y, 0), new Vector3(0, 0, 1), new Vector3(0, 0, 0));
     _allocatedVertices[1]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x + destRect.width, destRect.y, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0));
     _allocatedVertices[2]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x, destRect.y + destRect.height, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0));
     _allocatedVertices[3]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x + destRect.width, destRect.y + destRect.height, 0), new Vector3(0, 0, 1), new Vector3(1, 1, 0));
     _allocatedVertices[0].Hue = _allocatedVertices[1].Hue = _allocatedVertices[2].Hue = _allocatedVertices[3].Hue = hue;
     return(DrawSprite(texture, _allocatedVertices));
 }
Exemplo n.º 12
0
 public bool Draw2D(Texture2DInfo texture, Vector3 position, Vector3 hue)
 {
     _allocatedVertices[0]     = new VertexPositionNormalTextureHue(new Vector3(position.x, position.y, 0), new Vector3(0, 0, 1), new Vector3(0, 0, 0));
     _allocatedVertices[1]     = new VertexPositionNormalTextureHue(new Vector3(position.x + texture.Width, position.y, 0), new Vector3(0, 0, 1), new Vector3(1, 0, 0));
     _allocatedVertices[2]     = new VertexPositionNormalTextureHue(new Vector3(position.x, position.y + texture.Height, 0), new Vector3(0, 0, 1), new Vector3(0, 1, 0));
     _allocatedVertices[3]     = new VertexPositionNormalTextureHue(new Vector3(position.x + texture.Width, position.y + texture.Height, 0), new Vector3(0, 0, 1), new Vector3(1, 1, 0));
     _allocatedVertices[0].Hue = _allocatedVertices[1].Hue = _allocatedVertices[2].Hue = _allocatedVertices[3].Hue = hue;
     return(DrawSprite(texture, _allocatedVertices));
 }
Exemplo n.º 13
0
 public override void Update(double totalMS, double frameMS)
 {
     if (_bgGump == null)
     {
         var provider = Service.Get <IResourceProvider>();
         _bgGump = provider.GetUITexture(_gumpID);
     }
     base.Update(totalMS, frameMS);
 }
Exemplo n.º 14
0
 public void Initialize()
 {
     _spriteBatch             = Service.Get <SpriteBatchUI>();
     Texture                  = new Texture2DInfo((int)Stride, (int)Stride);
     _textureData             = new uint[Stride * Stride];
     _blockColors             = new uint[TilesPerBlock];
     _blockCache              = new MiniMapChunk[BlockCacheWidth * BlockCacheHeight];
     _mustRedrawEntireTexture = true;
     _queuedToDrawBlocks      = new List <uint>();
 }
Exemplo n.º 15
0
        static void GetHueData()
        {
            var hueData = getTextureData();

            _hueTexture0 = new Texture2DInfo(_hueTextureWidth, _hueTextureHeight, TextureFormat.Alpha8, false, null);
            _hueTexture1 = new Texture2DInfo(_hueTextureWidth, _hueTextureHeight, TextureFormat.Alpha8, false, null);

            //_hueTexture0.SetData(hueData, 0, _hueTextureWidth * _hueTextureHeight);
            //_hueTexture1.SetData(hueData, _hueTextureWidth * _hueTextureHeight, _hueTextureWidth * _hueTextureHeight);
        }
Exemplo n.º 16
0
 public void DrawStencil(Texture2DInfo texture, VertexPositionNormalTextureHue[] vertices)
 {
     // Sanity: do not draw if there is no texture to draw with.
     if (texture == null)
     {
         return;
     }
     // set proper z depth for this shadow.
     vertices[0].Position.z = vertices[1].Position.z = vertices[2].Position.z = vertices[3].Position.z = GetNextUniqueZ();
 }
Exemplo n.º 17
0
 public override void Update(double totalMS, double frameMS)
 {
     if (_texture == null)
     {
         var provider = Service.Get <IResourceProvider>();
         _texture = provider.GetItemTexture(_tileID);
         Size     = new Vector2Int(_texture.Width, _texture.Height);
     }
     base.Update(totalMS, frameMS);
 }
Exemplo n.º 18
0
 public override void Update(double totalMS, double frameMS)
 {
     if (_texture == null || GumpID != _lastFrameGumpID)
     {
         _lastFrameGumpID = GumpID;
         var provider = Service.Get <IResourceProvider>();
         _texture = provider.GetUITexture(GumpID);
         Size     = new Vector2Int(_texture.Width, _texture.Height);
     }
     base.Update(totalMS, frameMS);
 }
Exemplo n.º 19
0
 protected void CloseChildPicker()
 {
     if (_childColorPicker != null)
     {
         _childColorPicker.Dispose();
         _childColorPicker = null;
         _huesTexture      = HueData.CreateHueSwatch(1, 1, new int[1] {
             _hues[Index]
         });
     }
 }
Exemplo n.º 20
0
        void BuildGumpling(int x, int y, int inactiveID, int activeID, bool initialState, int switchID)
        {
            var provider = Service.Get <IResourceProvider>();

            _inactive   = provider.GetUITexture(inactiveID);
            _active     = provider.GetUITexture(activeID);
            Position    = new Vector2Int(x, y);
            Size        = new Vector2Int(_inactive.Width, _inactive.Height);
            IsChecked   = initialState;
            GumpLocalID = switchID;
        }
Exemplo n.º 21
0
        public static Texture2D LoadDDSTexture2D(Stream inputStream)
        {
            Texture2DInfo info = LoadDDSTexture(inputStream);

            if (info == null)
            {
                return(Texture2D.whiteTexture);
            }

            return(info.ToTexture2D());
        }
Exemplo n.º 22
0
        unsafe void ReadStaticTexture(int index, out Texture2DInfo texture)
        {
            texture = null;
            // get a reader inside Art.Mul
            var r = _fileIndex.Seek(index, out int length, out int extra, out bool patched);

            if (r == null)
            {
                return;
            }
            r.ReadInt(); // don't need this, see Art.mul file format.
            // get the dimensions of the texture
            var width  = r.ReadShort();
            var height = r.ReadShort();

            if (width <= 0 || height <= 0)
            {
                return;
            }
            // read the texture data!
            var lookups  = r.ReadUShorts(height);
            var fileData = r.ReadUShorts(length - lookups.Length * 2 - 8);

            Metrics.ReportDataRead(sizeof(ushort) * (fileData.Length + lookups.Length + 2));
            var pixels = new byte[width * height * 4];

            fixed(byte *pData = pixels)
            {
                uint *dataRef = (uint *)pData;
                int   i;

                for (int y = 0; y < height; y++, dataRef += width)
                {
                    i = lookups[y];
                    uint *start = dataRef;
                    int   count, offset;
                    while (((offset = fileData[i++]) + (count = fileData[i++])) != 0)
                    {
                        start += offset;
                        uint *end = start + count;
                        while (start < end)
                        {
                            uint color   = ConvertUtils.FromBGR555(fileData[i++]);
                            *    start++ = color;
                        }
                    }
                }
            }

            texture = new Texture2DInfo(width, height, TextureFormat.BGRA32, false, pixels);
            _staticPicking.Set(index, width, height, pixels);
            return;
        }
Exemplo n.º 23
0
        public bool Draw2D(Texture2DInfo texture, RectInt destRect, RectInt sourceRect, Vector3 hue)
        {
            float minX = sourceRect.x / (float)texture.Width, maxX = (sourceRect.x + sourceRect.width) / (float)texture.Width;
            float minY = sourceRect.y / (float)texture.Height, maxY = (sourceRect.y + sourceRect.height) / (float)texture.Height;

            _allocatedVertices[0]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x, destRect.y, 0), new Vector3(0, 0, 1), new Vector3(minX, minY, 0));
            _allocatedVertices[1]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x + destRect.width, destRect.y, 0), new Vector3(0, 0, 1), new Vector3(maxX, minY, 0));
            _allocatedVertices[2]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x, destRect.y + destRect.height, 0), new Vector3(0, 0, 1), new Vector3(minX, maxY, 0));
            _allocatedVertices[3]     = new VertexPositionNormalTextureHue(new Vector3(destRect.x + destRect.width, destRect.y + destRect.height, 0), new Vector3(0, 0, 1), new Vector3(maxX, maxY, 0));
            _allocatedVertices[0].Hue = _allocatedVertices[1].Hue = _allocatedVertices[2].Hue = _allocatedVertices[3].Hue = hue;
            return(DrawSprite(texture, _allocatedVertices));
        }
Exemplo n.º 24
0
        unsafe Texture2DInfo ReadLandTexture(int index)
        {
            var r = _fileIndex.Seek(index, out int length, out int extra, out bool patched);

            if (r == null)
            {
                return(null);
            }
            var pixels   = new byte[44 * 44 * 4];
            var fileData = r.ReadUShorts(23 * 44); // land tile textures store only opaque pixels

            Metrics.ReportDataRead(fileData.Length);
            var i = 0;

            fixed(byte *pData = pixels)
            {
                uint *dataRef = (uint *)pData;
                // fill the top half of the tile
                int count  = 2;
                int offset = 21;

                for (int y = 0; y < 22; y++, count += 2, offset--, dataRef += 44)
                {
                    uint *start = dataRef + offset;
                    uint *end   = start + count;
                    while (start < end)
                    {
                        uint color   = ConvertUtils.FromBGR555(fileData[i++]);
                        *    start++ = color;
                    }
                }
                // file the bottom half of the tile
                count  = 44;
                offset = 0;
                for (int y = 0; y < 22; y++, count -= 2, offset++, dataRef += 44)
                {
                    uint *start = dataRef + offset;
                    uint *end   = start + count;
                    while (start < end)
                    {
                        uint color   = ConvertUtils.FromBGR555(fileData[i++]);
                        *    start++ = color;
                    }
                }
            }

            var texture = new Texture2DInfo(44, 44, TextureFormat.BGRA32, false, pixels);

            //texture.Rotate2D(45);
            return(texture);
        }
Exemplo n.º 25
0
 public override void Update(double totalMS, double frameMS)
 {
     if (_gumpTexture == null || _useLargeMap != MiniMap_LargeFormat)
     {
         _useLargeMap = MiniMap_LargeFormat;
         if (_gumpTexture != null)
         {
             _gumpTexture = null;
         }
         var provider = Service.Get <IResourceProvider>();
         _gumpTexture = provider.GetUITexture(_useLargeMap ? 5011 : 5010, true);
         Size         = new Vector2Int(_gumpTexture.Width, _gumpTexture.Height);
     }
     base.Update(totalMS, frameMS);
 }
Exemplo n.º 26
0
        public static Texture2DInfo CreateHueSwatch(int width, int height, int[] hues)
        {
            var pixels = new byte[width * height * 2];

            for (var i = 0; i < pixels.Length; i++)
            {
                var hue   = hues[i];
                var pixel = new byte[1];
                //if (hue < _hueTextureHeight) HueTexture0.GetData(0, new RectInt(31, hue % _hueTextureHeight, 1, 1), pixel, 0, 1);
                //else HueTexture1.GetData(0, new RectInt(31, hue % _hueTextureHeight, 1, 1), pixel, 0, 1);
                pixels[i] = pixel[0];
            }
            var t = new Texture2DInfo(width, height, TextureFormat.Alpha8, false, pixels);

            return(t);
        }
Exemplo n.º 27
0
        public override void Draw(SpriteBatchUI spriteBatch, Vector2Int position, double frameMS)
        {
            IResourceProvider provider = Service.Get <IResourceProvider>();

            _inactive = provider.GetUITexture(210);

            spriteBatch.Draw2D(_inactive, new Vector3(position.x, position.y, 0), Vector3.zero);
            spriteBatch.Draw2D(_huesTexture, new RectInt(position.x + 3, position.y + 3, Width - 2, Height - 1), Vector3.zero);

            if (IsChild && IsMouseOver)
            {
                spriteBatch.Draw2D(_selectedIndicator, new Vector3(
                                       (int)(position.x + (float)(Width / _hueWidth) * ((Index % _hueWidth) + 0.5f) - _selectedIndicator.Width / 2),
                                       (int)(position.y + (float)(Height / _hueHeight) * ((Index / _hueWidth) + 0.5f) - _selectedIndicator.Height / 2),
                                       0), Vector3.zero);
            }
            base.Draw(spriteBatch, position, frameMS);
        }
Exemplo n.º 28
0
 protected override void OnInitialize()
 {
     if (_huesTexture == null)
     {
         if (IsChild) // is a child
         {
             var provider = Service.Get <IResourceProvider>();
             _huesTexture       = HueData.CreateHueSwatch(_hueWidth, _hueHeight, _hues);
             _selectedIndicator = provider.GetUITexture(6000);
         }
         else
         {
             _huesTexture = HueData.CreateHueSwatch(1, 1, new int[1] {
                 _hues[Index]
             });
         }
     }
 }
Exemplo n.º 29
0
        public Task <Texture2DInfo> LoadTextureInfoAsync(string texturePath)
        {
            Texture2DInfo texture = null;

            switch (texturePath.Substring(0, 3))
            {
            case "lnd": texture = _artmulResource.GetLandTexture(int.Parse(texturePath.Substring(3))); break;

            case "sta": texture = _artmulResource.GetStaticTexture(int.Parse(texturePath.Substring(3))); break;

            case "gmp": texture = _gumpMulResource.GetGumpTexture(int.Parse(texturePath.Substring(3))); break;

            case "tex": texture = _texmapResource.GetTexmapTexture(int.Parse(texturePath.Substring(3))); break;

            default: throw new ArgumentOutOfRangeException("texturePath", texturePath);
            }
            return(Task.FromResult(texture));
        }
Exemplo n.º 30
0
        public override void Draw(SpriteBatchUI spriteBatch, Vector2Int position, double frameMS)
        {
            if (_texture == null)
            {
                var provider = Service.Get <IResourceProvider>();
                _texture = provider.GetItemTexture(Item.DisplayItemID);
                Size     = new Vector2Int(_texture.Width, _texture.Height);
            }
            var hue = Utility.GetHueVector(IsMouseOver && HighlightOnMouseOver ? WorldView.MouseOverHue : Item.Hue);

            if (Item.Amount > 1 && Item.ItemData.IsGeneric && Item.DisplayItemID == Item.ItemID)
            {
                var offset = Item.ItemData.Unknown4;
                spriteBatch.Draw2D(_texture, new Vector3(position.X - 5, position.Y - 5, 0), hue);
            }
            spriteBatch.Draw2D(_texture, new Vector3(position.X, position.Y, 0), hue);
            base.Draw(spriteBatch, position, frameMS);
        }