示例#1
0
        protected virtual TextureFile EnhancedTexture_Getter(int textureID)
        {
            try
            {
                if (Globals.Instance.EnhancedAssets != null)
                {
                    byte[] data = Globals.Instance.EnhancedAssets.GetTexture(textureID);

                    if (data != null)
                    {
                        string name = String.Format("0x{0:X}", textureID);

                        if (Globals.Instance.Clilocs != null)
                        {
                            int    cliloc     = UltimaItemGenerator.GetClilocFromItemID(textureID);
                            string clilocText = Globals.Instance.Clilocs.GetString(cliloc);

                            if (!String.IsNullOrEmpty(clilocText))
                            {
                                name = String.Format("{0} - {1}", name, clilocText);
                            }
                        }

                        TextureFile texture = new TextureFile();
                        texture.ID    = textureID;
                        texture.Name  = name;
                        texture.Data  = data;
                        texture.Image = DDS.FromMemory(data).GetTextureAsBitmapSource();

                        return(texture);
                    }
                }
            }
            catch (Exception ex)
            {
                App.Window.ShowNotification(NotificationType.Error, ex);
            }

            return(GetDefaultTexture(textureID, true));
        }
示例#2
0
        /// <summary>
        /// Analyzes item.
        /// </summary>
        /// <param name="serial">Item serial.</param>
        /// <param name="itemID">Item ID.</param>
        /// <param name="hue">Item hue.</param>
        /// <param name="amount">Item amount.</param>
        /// <param name="properties">Item properties.</param>
        public void AnalyzeItem(uint serial, int itemID, int hue, int amount, QueryPropertiesResponsePacket properties)
        {
            // Get item cliloc
            int    cliloc = 0;
            string name   = null;

            if (properties != null && properties.Properties.Count > 0)
            {
                // Get name from name property
                QueryPropertiesProperty nameProperty = properties.Properties[0];

                if (UltimaItemGenerator.IsStackable(nameProperty.Cliloc))
                {
                    // Get name from stackable cliloc
                    UltimaClilocArgumentParser nameArguments = new UltimaClilocArgumentParser(nameProperty.Arguments);
                    int nameCliloc = nameArguments.GetCliloc(1);

                    if (nameCliloc > 0)
                    {
                        cliloc = nameCliloc;
                    }
                    else
                    {
                        name = nameArguments[1];
                    }
                }
                else
                {
                    // Get name from name cliloc
                    if (!UltimaItemGenerator.IsString(nameProperty.Cliloc))
                    {
                        cliloc = nameProperty.Cliloc;
                    }
                    else
                    {
                        name = nameProperty.Arguments;
                    }
                }
            }
            else
            {
                // Get name from item ID
                cliloc = UltimaItemGenerator.GetClilocFromItemID(itemID);
            }

            // Count
            UltimaItemCounter      counter = null;
            UltimaStringCollection clilocs = Globals.Instance.Clilocs;

            if (name == null)
            {
                if (clilocs != null)
                {
                    name = clilocs.GetString(cliloc);
                }

                if (String.IsNullOrEmpty(name))
                {
                    name = cliloc.ToString();
                }
            }

            if (!_Items.TryGetValue(name, out counter))
            {
                counter = new UltimaItemCounter(serial, name);
                _Items.Add(name, counter);
            }

            if (UltimaItemGenerator.IsStackable(cliloc))
            {
                amount = Math.Max(amount, 1);
            }
            else
            {
                amount = 1;
            }

            counter.Gotcha(hue, amount);
            _Counter.Gotcha(1);
        }