/// <summary> /// Creates a BoxData object provided the items and mobiles /// </summary> /// <param name="boxItems">A list of BoxItem objects</param> /// <param name="boxMobiles">A list of BoxMobile objects</param> /// <returns>A BoxData object containing a categories structure</returns> public static BoxData Create(ArrayList boxItems, ArrayList boxMobiles) { BoxData data = new BoxData(); // Items foreach (BoxItem item in boxItems) { GenericNode node = data.GetNode(data.m_Items, item.Path); node.Elements.Add(item); } // Mobiles foreach (BoxMobile mobile in boxMobiles) { GenericNode node = data.GetNode(data.m_Mobiles, mobile.Path); node.Elements.Add(mobile); } return(data); }
/// <summary> /// Creates a BoxData object provided the items and mobiles /// </summary> /// <param name="boxItems">A list of BoxItem objects</param> /// <param name="boxMobiles">A list of BoxMobile objects</param> /// <returns>A BoxData object containing a categories structure</returns> public static BoxData Create( ArrayList boxItems, ArrayList boxMobiles ) { BoxData data = new BoxData(); // Items foreach ( BoxItem item in boxItems ) { GenericNode node = data.GetNode( data.m_Items, item.Path ); node.Elements.Add( item ); } // Mobiles foreach ( BoxMobile mobile in boxMobiles ) { GenericNode node = data.GetNode( data.m_Mobiles, mobile.Path ); node.Elements.Add( mobile ); } return data; }
/// <summary> /// Generates the BoxData.xml for the current configuration /// </summary> public static void GenerateData() { World.Broadcast(BoxConfig.MessageHue, false, "Generating datafile for Pandora's Box. Please wait."); DateTime start = DateTime.Now; StringDictionary classes = CategorizeClasses(); ArrayList types = LoadTypes(); ArrayList items = new ArrayList(); ArrayList mobiles = new ArrayList(); ProcessTypes(types, items, mobiles, classes); BoxData data = BoxData.Create(items, mobiles); data.Items.Sort(); data.Mobiles.Sort(); Save(data); TimeSpan duration = DateTime.Now - start; World.Broadcast(BoxConfig.MessageHue, false, "Generation complete. The process took {0} seconds.", duration.TotalSeconds); }
/// <summary> /// Loads the BoxData from file /// </summary> /// <returns></returns> public static BoxData Load() { BoxData data = new BoxData(); string filename = Path.Combine(Pandora.Profile.BaseFolder, "BoxData.xml"); if (File.Exists(filename)) { try { XmlSerializer serializer = new XmlSerializer(typeof(BoxData)); FileStream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); data = serializer.Deserialize(stream) as BoxData; stream.Close(); Pandora.Log.WriteEntry(string.Format("BoxData read correctly from file: {0}", filename)); } catch (Exception err) { Pandora.Log.WriteError(err, string.Format("Cannot read BoxData from file {0}", filename)); } } return(data); }
/// <summary> /// Loads the BoxData from file /// </summary> /// <returns></returns> public static BoxData Load() { BoxData data = new BoxData(); string filename = Path.Combine( Pandora.Profile.BaseFolder, "BoxData.xml" ); if ( File.Exists( filename ) ) { try { XmlSerializer serializer = new XmlSerializer( typeof( BoxData ) ); FileStream stream = new FileStream( filename, FileMode.Open, FileAccess.Read, FileShare.Read ); data = serializer.Deserialize( stream ) as BoxData; stream.Close(); Pandora.Log.WriteEntry( string.Format( "BoxData read correctly from file: {0}", filename ) ); } catch ( Exception err ) { Pandora.Log.WriteError( err, string.Format( "Cannot read BoxData from file {0}", filename ) ); } } return data; }
/// <summary> /// Saves the box data to file /// </summary> private static void Save(BoxData data) { string path = Path.Combine(BoxUtil.BoxFolder, "BoxData.xml"); BoxUtil.XmlSave(data, path); }
/// <summary> /// Saves the box data to file /// </summary> private static void Save( BoxData data ) { string path = Path.Combine( BoxUtil.BoxFolder, "BoxData.xml" ); BoxUtil.XmlSave( data, path ); }