Пример #1
0
        public static HUDItem Read(BinaryReader c)
        {
            HUDItem item = new HUDItem();

            //Get the starting position of the item
            item.Position = c.BaseStream.Position;
            //Read all bytes of the item (items end in 0xDB, 0xBF, 0xEF, 0x19, 0x10)
            item.Bytes = ReadToPattern(c, new byte[5] { 0xDB, 0xBF, 0xEF, 0x19, 0x10 });

            //Read the bytes using a binary reader
            using (BinaryReader b = new BinaryReader(new MemoryStream(item.Bytes)))
            {
                byte ItemLength = b.ReadByte();
                b.ReadByte(); //Always 0
                item.Name = Encoding.ASCII.GetString(b.ReadBytes(ItemLength));
                b.ReadBytes(5); //Always E0 AC 91 8E 10
                byte CategoryLength = b.ReadByte();
                b.ReadByte(); //Always 0
                item.Category = Encoding.ASCII.GetString(b.ReadBytes(CategoryLength));

                //This is still broken ish - just my guess! Seems to kind of work
                ReadToPattern(b, new byte[4] { 0xBC, 0xF0, 0x8F, 0x0D });
                var x1 = BitConverter.ToInt32(b.ReadBytes(4), 0);
                var y1 = BitConverter.ToInt32(b.ReadBytes(4), 0);
                var x2 = BitConverter.ToInt32(b.ReadBytes(4), 0);
                var y2 = BitConverter.ToInt32(b.ReadBytes(4), 0);

                //set the item data to be manipulated later
                item.X = new Tuple<int, int>(x1, x2);
                item.Y = new Tuple<int, int>(y1, y2);
            }

            return item;
        }
 private void ItemComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     foreach (var item in _hudItems)
     {
         if (item.Category == (string)CategoryComboBox.SelectedItem && item.Name == (string)ItemComboBox.SelectedItem)
         {
             _selectedItem = item;
             XOnePos.Byte = item.X.Item1;
             XTwoPos.Byte = item.X.Item2;
             YOnePos.Byte = item.Y.Item1;
             YTwoPos.Byte = item.Y.Item2;
             return;
         }
     }
 }