Represents item tile data. TileData LandData
Esempio n. 1
0
        private void UpdateDetail(int id)
        {
            Ultima.ItemData item = Ultima.TileData.ItemTable[id];
            Bitmap          bit  = Ultima.Art.GetStatic(id);

            DetailPictureBox.Tag = id;
            if (bit == null)
            {
                splitContainer2.SplitterDistance = 10;
            }
            else
            {
                splitContainer2.SplitterDistance = bit.Size.Height + 10;
            }
            DetailPictureBox.Invalidate();
            DetailTextBox.Clear();
            DetailTextBox.AppendText(String.Format("Name: {0}\n", item.Name));
            DetailTextBox.AppendText(String.Format("Graphic: 0x{0:X4}\n", id));
            DetailTextBox.AppendText(String.Format("Height/Capacity: {0}\n", item.Height));
            DetailTextBox.AppendText(String.Format("Weight: {0}\n", item.Weight));
            DetailTextBox.AppendText(String.Format("Animation: {0}\n", item.Animation));
            DetailTextBox.AppendText(String.Format("Quality/Layer/Light: {0}\n", item.Quality));
            DetailTextBox.AppendText(String.Format("Quantity: {0}\n", item.Quantity));
            DetailTextBox.AppendText(String.Format("Hue: {0}\n", item.Hue));
            DetailTextBox.AppendText(String.Format("StackingOffset/Unk4: {0}\n", item.StackingOffset));
            DetailTextBox.AppendText(String.Format("Flags: {0}\n", item.Flags));
            if ((item.Flags & TileFlag.Animation) != 0)
            {
                Animdata.Data info = Animdata.GetAnimData(id);
                if (info != null)
                {
                    DetailTextBox.AppendText(String.Format("Animation FrameCount: {0} Interval: {1}\n", info.FrameCount, info.FrameInterval));
                }
            }
        }
Esempio n. 2
0
        private void OnClickSelectGump(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count > 0)
            {
                int id = (int)listView1.SelectedItems[0].Tag;
                if (id == -1)
                {
                    id = listView1.SelectedItems[0].Index;
                }

                Ultima.ItemData item = Ultima.TileData.ItemTable[id];
                FiddlerControls.Gump.Select(item.Animation + 50000);
            }
        }
Esempio n. 3
0
        private void onLoad(object sender, EventArgs e)
        {
            this.animateToolStripMenuItem.Visible = false;
            Ultima.ItemData item = Ultima.TileData.ItemTable[index];
            Bitmap          bit  = Ultima.Art.GetStatic(index);

            this.Text = String.Format("Item Detail 0x{0:X} '{1}'", index, item.Name);
            if (bit == null)
            {
                this.splitContainer1.SplitterDistance = 10;
            }
            else
            {
                this.Size = new System.Drawing.Size(300, bit.Size.Height + this.Data.Size.Height + 10);
                this.splitContainer1.SplitterDistance = bit.Size.Height + 10;
                this.Graphic.Size = new System.Drawing.Size(300, bit.Size.Height + 10);
                Graphic.Tag       = bit;
                Graphic.Invalidate();
            }

            this.Data.AppendText(String.Format("Name: {0}\n", item.Name));
            this.Data.AppendText(String.Format("Graphic: 0x{0:X4} ({0})\n", index));
            this.Data.AppendText(String.Format("Height/Capacity: {0}\n", item.Height));
            this.Data.AppendText(String.Format("Weight: {0}\n", item.Weight));
            this.Data.AppendText(String.Format("Animation: {0}\n", item.Animation));
            this.Data.AppendText(String.Format("Quality/Layer/Light: {0}\n", item.Quality));
            this.Data.AppendText(String.Format("Quantity: {0}\n", item.Quantity));
            this.Data.AppendText(String.Format("Hue: {0}\n", item.Hue));
            this.Data.AppendText(String.Format("StackingOffset/Unk4: {0}\n", item.StackingOffset));
            this.Data.AppendText(String.Format("Flags: {0}\n", item.Flags));
            if ((item.Flags & TileFlag.PartialHue) != 0)
            {
                partialHue = true;
            }
            if ((item.Flags & TileFlag.Animation) != 0)
            {
                info = Animdata.GetAnimData(index);
                if (info != null)
                {
                    this.animateToolStripMenuItem.Visible = true;
                    this.Data.AppendText(String.Format("Animation FrameCount: {0} Interval: {1}\n", info.FrameCount, info.FrameInterval));
                }
            }
        }
Esempio n. 4
0
        private void UpdateDetail(int id)
        {
            Ultima.ItemData item = Ultima.TileData.ItemTable[id];
            Bitmap          bit  = Ultima.Art.GetStatic(id);

            if (bit == null)
            {
                splitContainer2.SplitterDistance = 10;
                Bitmap   newbit   = new Bitmap(DetailPictureBox.Size.Width, DetailPictureBox.Size.Height);
                Graphics newgraph = Graphics.FromImage(newbit);
                newgraph.Clear(Color.FromArgb(-1));
                DetailPictureBox.Image = newbit;
            }
            else
            {
                splitContainer2.SplitterDistance = bit.Size.Height + 10;
                Bitmap   newbit   = new Bitmap(DetailPictureBox.Size.Width, DetailPictureBox.Size.Height);
                Graphics newgraph = Graphics.FromImage(newbit);
                newgraph.Clear(Color.FromArgb(-1));
                newgraph.DrawImage(bit, (DetailPictureBox.Size.Width - bit.Width) / 2, 5);
                DetailPictureBox.Image = newbit;
            }

            DetailTextBox.Clear();
            DetailTextBox.AppendText(String.Format("Name: {0}\n", item.Name));
            DetailTextBox.AppendText(String.Format("Graphic: 0x{0:X4}\n", id));
            DetailTextBox.AppendText(String.Format("Height/Capacity: {0}\n", item.Height));
            DetailTextBox.AppendText(String.Format("Weight: {0}\n", item.Weight));
            DetailTextBox.AppendText(String.Format("Animation: {0}\n", item.Animation));
            DetailTextBox.AppendText(String.Format("Quality/Layer/Light: {0}\n", item.Quality));
            DetailTextBox.AppendText(String.Format("Quantity: {0}\n", item.Quantity));
            DetailTextBox.AppendText(String.Format("Hue: {0}\n", item.Hue));
            DetailTextBox.AppendText(String.Format("StackingOffset/Unk4: {0}\n", item.StackingOffset));
            DetailTextBox.AppendText(String.Format("Flags: {0}\n", item.Flags));
            if ((item.Flags & TileFlag.Animation) != 0)
            {
                Animdata.Data info = Animdata.GetAnimData(id);
                if (info != null)
                {
                    DetailTextBox.AppendText(String.Format("Animation FrameCount: {0} Interval: {1}\n", info.FrameCount, info.FrameInterval));
                }
            }
        }
Esempio n. 5
0
 private void OnClickApplyFilterItem(object sender, EventArgs e)
 {
     ItemData item = new ItemData();
     string name = textBoxName.Text;
     if (name.Length > 20)
         name = name.Substring(0, 20);
     item.Name = name;
     byte byteres;
     short shortres;
     if (short.TryParse(textBoxAnim.Text, out shortres))
         item.Animation = shortres;
     if (byte.TryParse(textBoxWeight.Text, out byteres))
         item.Weight = byteres;
     if (byte.TryParse(textBoxQuality.Text, out byteres))
         item.Quality = byteres;
     if (byte.TryParse(textBoxQuantity.Text, out byteres))
         item.Quantity = byteres;
     if (byte.TryParse(textBoxHue.Text, out byteres))
         item.Hue = byteres;
     if (byte.TryParse(textBoxStackOff.Text, out byteres))
         item.StackingOffset = byteres;
     if (byte.TryParse(textBoxValue.Text, out byteres))
         item.Value = byteres;
     if (byte.TryParse(textBoxHeigth.Text, out byteres))
         item.Height = byteres;
     if (short.TryParse(textBoxUnk1.Text, out shortres))
         item.MiscData = shortres;
     if (byte.TryParse(textBoxUnk2.Text, out byteres))
         item.Unk2 = byteres;
     if (byte.TryParse(textBoxUnk3.Text, out byteres))
         item.Unk3 = byteres;
     item.Flags = TileFlag.None;
     Array EnumValues = System.Enum.GetValues(typeof(TileFlag));
     for (int i = 0; i < checkedListBox1.Items.Count; ++i)
     {
         if (checkedListBox1.GetItemChecked(i))
             item.Flags |= (TileFlag)EnumValues.GetValue(i + 1);
     }
     TileDatas.ApplyFilterItem(item);
 }
Esempio n. 6
0
        public static unsafe void Initialize()
        {
            string filePath = Files.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    landheader = new int[512];
                    int j = 0;
                    m_LandData = new LandData[0x4000];

                    byte[] buffer = new byte[fs.Length];
                    GCHandle gc = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    long currpos = 0;
                    try
                    {
                        fs.Read(buffer, 0, buffer.Length);
                        if (Ultima.Art.IsUOHS) // TileData после HS
                        {
                            for (int i = 0; i < 0x4000; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));

                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(LandTileDataMul);
                                    LandTileDataMul cur = (LandTileDataMul)Marshal.PtrToStructure(ptr, typeof(LandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }
                        else // TileData до HS
                        {
                            for (int i = 0; i < 0x4000; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));

                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(LandTileOldDataMul);
                                    LandTileOldDataMul cur = (LandTileOldDataMul)Marshal.PtrToStructure(ptr, typeof(LandTileOldDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }

                        int remaining = (int)(buffer.Length - currpos);
                        int itemlength; // 32 записи длиной 41/37 байт в блоке с шапкой 4 байта
                        itemlength = 32 * remaining / (4 + 32 * (Ultima.Art.IsUOHS ? 41 : 37));
                        itemheader = new int[itemlength / 32];
                        //itemlength = Math.Min(Art.StaticLength, itemlength);

                        m_ItemData = new ItemData[itemlength];
                        m_HeightTable = new int[itemlength];

                        j = 0;
                        if (Ultima.Art.IsUOHS) // TileData после HS
                        {
                            for (int i = 0; i < itemlength; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(ItemTileDataMul);
                                    ItemTileDataMul cur = (ItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(ItemTileDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }
                        else // TileData до HS
                        {
                            for (int i = 0; i < itemlength; i += 32)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                currpos += 4;
                                itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                                for (int count = 0; count < 32; ++count)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                    currpos += sizeof(ItemTileOldDataMul);
                                    ItemTileOldDataMul cur = (ItemTileOldDataMul)Marshal.PtrToStructure(ptr, typeof(ItemTileOldDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }

                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
        }
Esempio n. 7
0
 public static void ApplyFilterItem(ItemData item)
 {
     refMarker.treeViewItem.BeginUpdate();
     refMarker.treeViewItem.Nodes.Clear();
     List<TreeNode> nodes = new List<TreeNode>();
     for (int i = 0; i < TileData.ItemTable.Length; ++i)
     {
         if (!String.IsNullOrEmpty(item.Name))
         {
             if (!TileData.ItemTable[i].Name.ToLower().Contains(item.Name.ToLower()))
                 continue;
         }
         if (item.Animation != 0)
         {
             if (TileData.ItemTable[i].Animation != item.Animation)
                 continue;
         }
         if (item.Weight != 0)
         {
             if (TileData.ItemTable[i].Weight != item.Weight)
                 continue;
         }
         if (item.Quality != 0)
         {
             if (TileData.ItemTable[i].Quality != item.Quality)
                 continue;
         }
         if (item.Quantity != 0)
         {
             if (TileData.ItemTable[i].Quantity != item.Quantity)
                 continue;
         }
         if (item.Hue != 0)
         {
             if (TileData.ItemTable[i].Hue != item.Hue)
                 continue;
         }
         if (item.StackingOffset != 0)
         {
             if (TileData.ItemTable[i].StackingOffset != item.StackingOffset)
                 continue;
         }
         if (item.Value != 0)
         {
             if (TileData.ItemTable[i].Value != item.Value)
                 continue;
         }
         if (item.Height != 0)
         {
             if (TileData.ItemTable[i].Height != item.Height)
                 continue;
         }
         if (item.MiscData != 0)
         {
             if (TileData.ItemTable[i].MiscData != item.MiscData)
                 continue;
         }
         if (item.Unk2 != 0)
         {
             if (TileData.ItemTable[i].Unk2 != item.Unk2)
                 continue;
         }
         if (item.Unk3 != 0)
         {
             if (TileData.ItemTable[i].Unk3 != item.Unk3)
                 continue;
         }
         if (item.Flags != 0)
         {
             if ((TileData.ItemTable[i].Flags & item.Flags) == 0)
                 continue;
         }
         TreeNode node = new TreeNode(String.Format("0x{0:X4} ({0}) {1}", i, TileData.ItemTable[i].Name));
         node.Tag = i;
         nodes.Add(node);
     }
     refMarker.treeViewItem.Nodes.AddRange(nodes.ToArray());
     refMarker.treeViewItem.EndUpdate();
     if (refMarker.treeViewItem.Nodes.Count > 0)
         refMarker.treeViewItem.SelectedNode = refMarker.treeViewItem.Nodes[0];
 }
Esempio n. 8
0
        public static unsafe void Initialize()
        {
            string filePath = Files.GetFilePath("tiledata.mul");

            if (filePath != null)
            {
                using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    bool useNeWTileDataFormat = Art.IsUOAHS();
                    landheader = new int[512];
                    int j = 0;
                    m_LandData = new LandData[0x4000];

                    byte[] buffer = new byte[fs.Length];
                    GCHandle gc = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    long currpos = 0;
                    try
                    {
                        fs.Read(buffer, 0, buffer.Length);
                        for (int i = 0; i < 0x4000; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos += 4;
                            landheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewLandTileDataMul);
                                    NewLandTileDataMul cur = (NewLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                                else
                                {
                                    currpos += sizeof(OldLandTileDataMul);
                                    OldLandTileDataMul cur = (OldLandTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldLandTileDataMul));
                                    m_LandData[i + count] = new LandData(cur);
                                }
                            }
                        }

                        long remaining = buffer.Length - currpos;
                        int structsize = useNeWTileDataFormat ? sizeof(NewItemTileDataMul) : sizeof(OldItemTileDataMul);
                        itemheader = new int[(remaining / ((structsize * 32) + 4))];
                        int itemlength = itemheader.Length * 32;

                        m_ItemData = new ItemData[itemlength];
                        m_HeightTable = new int[itemlength];

                        j = 0;
                        for (int i = 0; i < itemlength; i += 32)
                        {
                            IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                            currpos += 4;
                            itemheader[j++] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));
                            for (int count = 0; count < 32; ++count)
                            {
                                IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);
                                if (useNeWTileDataFormat)
                                {
                                    currpos += sizeof(NewItemTileDataMul);
                                    NewItemTileDataMul cur = (NewItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(NewItemTileDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                                else
                                {
                                    currpos += sizeof(OldItemTileDataMul);
                                    OldItemTileDataMul cur = (OldItemTileDataMul)Marshal.PtrToStructure(ptr, typeof(OldItemTileDataMul));
                                    m_ItemData[i + count] = new ItemData(cur);
                                    m_HeightTable[i + count] = cur.height;
                                }
                            }
                        }
                    }
                    finally
                    {
                        gc.Free();
                    }
                }
            }
        }
Esempio n. 9
0
        static TileData()
        {
            string filePath = Client.GetFilePath( "tiledata.mul" );

            if ( filePath != null )
            {
                using ( FileStream fs = new FileStream( filePath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
                {
                    BinaryReader bin = new BinaryReader( fs );

                    m_LandData = new LandData[0x4000];

                    for ( int i = 0; i < 0x4000; ++i )
                    {
                        if ( (i & 0x1F) == 0 )
                        {
                            bin.ReadInt32(); // header
                        }

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        bin.ReadInt16(); // skip 2 bytes -- textureID

                        m_LandData[i] = new LandData( ReadNameString( bin ), flags );
                    }

                    m_ItemData = new ItemData[0x4000];
                    m_HeightTable = new int[0x4000];

                    for ( int i = 0; i < 0x4000; ++i )
                    {
                        if ( (i & 0x1F) == 0 )
                            bin.ReadInt32(); // header

                        TileFlag flags = (TileFlag)bin.ReadInt32();
                        int weight = bin.ReadByte();
                        int quality = bin.ReadByte();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int quantity = bin.ReadByte();
                        int anim = bin.ReadInt16();
                        bin.ReadInt16();
                        bin.ReadByte();
                        int value = bin.ReadByte();
                        int height = bin.ReadByte();

                        m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height, anim );
                        m_HeightTable[i] = height;
                    }
                }
            }
            else
            {
                throw new FileNotFoundException();
            }
        }