Example #1
0
 public void Initialize(string path)
 {
     m_d2PFile = new D2pFile(path);
     m_icons   = EnumerateIcons().ToDictionary(x => x.Id);
     ErrorIcon = new Icon(-1, m_d2PFile.ReadFile("error.png"));
     EmptyIcon = new Icon(0, m_d2PFile.ReadFile("empty.png"));
 }
        public DlmMap GetDlmMap(int id, string decryptionKey)
        {
            // retrieve the bound entry to the mainLock or find it in the d2p file
            D2pEntry entry;

            lock (m_entriesLinks)
                if (!m_entriesLinks.TryGetValue(id, out entry))
                {
                    var idStr = id.ToString();
                    entry = m_reader.Entries.FirstOrDefault(x => Path.GetFileNameWithoutExtension(x.FileName) == idStr);

                    if (entry == null)
                    {
                        throw new ArgumentException(string.Format("Map id {0} not found", id));
                    }

                    m_entriesLinks.Add(id, entry);
                }

            // then retrieve the data source bound to the entry or create it
            var dlmReader = new DlmReader(m_reader.ReadFile(entry));

            dlmReader.DecryptionKey = decryptionKey;

            return(dlmReader.ReadMap());
        }
Example #3
0
        public Icon GetIcon(int id)
        {
            if (!m_d2PFile.Exists(id + ".png"))
            {
                throw new ArgumentException(string.Format("Item icon {0} not found", id));
            }

            var data = m_d2PFile.ReadFile(id + ".png");

            return(new Icon(id, id + ".png", data));
        }
Example #4
0
        public Icon GetIcon(int id)
        {
            if (id == 0)
            {
                return(EmptyIcon);
            }

            if (!m_icons.ContainsKey(id))
            {
                return(ErrorIcon);
            }

            byte[] data = m_d2PFile.ReadFile(id + ".png");

            return(new Icon(id, data));
        }
Example #5
0
        private IDataSource CreateDataSource(D2pEntry entry, Type type)
        {
            if (type == typeof(DlmMap))
            {
                return(new DLMSource(new DlmReader(new MemoryStream(m_reader.ReadFile(entry)))));
            }

            throw new ArgumentException(string.Format("type {0} not handled", type));
        }
Example #6
0
        public static BitmapSource GetGfx(int id)
        {
            CheckInitialization();

            foreach (var fileType in m_filesTypes)
            {
                var entry = m_gfxFile.TryGetEntry(string.Format("{0}/{1}.{0}", fileType, id));

                if (entry == null)
                {
                    continue;
                }

                var bitmapImage = new BitmapImage();
                bitmapImage.BeginInit();
                bitmapImage.StreamSource = new MemoryStream(m_gfxFile.ReadFile(entry));
                bitmapImage.EndInit();
                return(bitmapImage);
            }

            return(new BitmapImage());
        }