Ejemplo n.º 1
0
        public void Save()
        {
#if !AGGREGATE_ITEMS
            using (StreamWriter writer = new StreamWriter(ItemCache.SavedFilePath, false, Encoding.UTF8))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(ItemList));
                serializer.Serialize(writer, new ItemList(AllItems));
                writer.Close();
            }

            LocationFactory.Save(Path.Combine("Data", "ItemSource.xml"));
            ItemFilter.Save(Path.Combine("Data", "ItemFilter.xml"));
#else
            //this is handy for debugging
            foreach (Item item in AllItems)
            {
                try
                {
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Item));
                    StringBuilder          sb     = new StringBuilder();
                    System.IO.StringWriter writer = new System.IO.StringWriter(sb);
                    serializer.Serialize(writer, item);
                    writer.Close();
                    System.IO.File.WriteAllText(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "ItemCache-" + item.Name + ".xml"), sb.ToString());
                }
                catch (System.Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(e.Message);
                }
            }
#endif
        }
Ejemplo n.º 2
0
        public void Load()
        {
            _items = new SortedDictionary <int, Item>();
            List <Item> listItems = new List <Item>();

            if (File.Exists(ItemCache.SavedFilePath))
            {
                try {
                    string xml = System.IO.File.ReadAllText(ItemCache.SavedFilePath).Replace("/images/icons/", "");
                    xml = xml.Replace("<Slot>Weapon</Slot", "<Slot>TwoHand</Slot>").Replace("<Slot>Idol</Slot", "<Slot>Ranged</Slot>").Replace("<Slot>Robe</Slot", "<Slot>Chest</Slot>");
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(ItemList));
                    System.IO.StringReader reader = new System.IO.StringReader(xml);
                    listItems = (List <Item>)serializer.Deserialize(reader);
                    reader.Close();
                } catch (Exception) {
                    Log.Show("Rawr was unable to load the Item Cache. It appears to have been made with a previous incompatible version of Rawr. Please use the ItemCache included with this version of Rawr to start from.");
                }
            }
            foreach (Item item in listItems)
            {
                //item.Stats.ConvertStatsToWotLKEquivalents();
                //item.Sockets.Stats.ConvertStatsToWotLKEquivalents();
                //if (item.Type == ItemType.Leather) UpdateArmorFromWowhead(item);
                AddItem(item, false);
            }

            LocationFactory.Load(Path.Combine("Data", "ItemSource.xml"));
            ItemFilter.Load(Path.Combine("Data", "ItemFilter.xml"));
            Calculations.ModelChanged += new EventHandler(Calculations_ModelChanged);
        }
Ejemplo n.º 3
0
        public void Load()
        {
            _items = new SortedDictionary <string, Item[]>();
            List <Item> listItems = new List <Item>();

            if (File.Exists(ItemCache.SavedFilePath))
            {
                try
                {
                    string xml = System.IO.File.ReadAllText(ItemCache.SavedFilePath).Replace("/images/icons/", "");
                    xml = xml.Replace("<Slot>Weapon</Slot", "<Slot>TwoHand</Slot>").Replace("<Slot>Idol</Slot", "<Slot>Ranged</Slot>").Replace("<Slot>Robe</Slot", "<Slot>Chest</Slot>");
                    System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(List <Item>));
                    System.IO.StringReader reader = new System.IO.StringReader(xml);
                    listItems = (List <Item>)serializer.Deserialize(reader);
                    reader.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("Rawr was unable to load the Item Cache. It appears to have been made with a previous incompatible version of Rawr. Please use the ItemCache included with this version of Rawr to start from.");
                }
            }
            foreach (Item item in listItems)
            {
                AddItem(item, true, false);
            }

            LocationFactory.Load("ItemSource.xml");
            Calculations.ModelChanged += new EventHandler(Calculations_ModelChanged);
        }