/// <summary> /// Initializes the new empty Art object. /// </summary> public Art() { mulFile = null; dataStream = Stream.Null; indexFile = new IndexFile(); indexFile.Resize(65536); tileObject = new LandscapeData(this); itemsObject = new ItemsData(this); animationsObject = new AnimationsData(this); }
/// <summary> /// Stores this object to specified files. /// </summary> /// <param name="idxFile">Index file.</param> /// <param name="mulFile">Data file.</param> /// <exception cref="System.ObjectDisposedException">Object has been disposed.</exception> public void Save(string idxFile, string mulFile) { lock (syncRoot) { if (Disposed) { throw new ObjectDisposedException("Skills"); } IndexFile indexFile = null; Stream stream = null; BinaryWriter writer = null; Stream indexStream = null; try { indexStream = File.Open(idxFile, FileMode.Create, FileAccess.Write, FileShare.None); indexFile = new IndexFile(); stream = File.OpenWrite(mulFile); writer = new BinaryWriter(stream); IndexData indexData = new IndexData(); foreach (SkillData skillData in list) { indexData.Lookup = (uint)stream.Position; indexData.Lenght = (uint)skillData.Name.Length + 1; indexData.Extra = skillData.Extra; writer.Write(skillData.Action); writer.Write(Encoding.ASCII.GetBytes(skillData.Name)); indexFile.Add(indexData); } indexFile.Resize(256); indexFile.Save(indexStream); Trace.WriteLine(String.Format("IndexFile: File \"{0}\" succesfully saved.", idxFile), "MulLib"); writer.Flush(); Trace.WriteLine(String.Format("Skills: File \"{0}\" succesfully saved.", mulFile), "MulLib"); } catch (Exception e) { throw new Exception("Error saving Skills.", e); } finally { if (indexFile != null) { indexFile.Dispose(); } if (indexStream != null) { indexStream.Close(); } if (writer != null) { writer.Close(); } if (stream != null) { stream.Close(); } } } }