public void ExportDesign(DesignData design, BinaryFileWriter writer) { writer.WriteString(design.Name); writer.WriteString(design.Category); writer.WriteString(design.Subsection); writer.WriteInt(design.Width); writer.WriteInt(design.Height); writer.WriteInt(design.UserWidth); writer.WriteInt(design.UserHeight); // item count writer.WriteInt(design.Items.Count); for (int i = 0; i < design.Items.Count; ++i) { DesignItem item = design.Items[i]; writer.WriteShort(item.ItemID); writer.WriteShort((short)item.X); writer.WriteShort((short)item.Y); writer.WriteShort((short)item.Z); writer.WriteShort(item.Level); writer.WriteShort(item.Hue); } }
public override void Export(DesignData design) { string filename = GetExportFileName(design.Name); if (filename.Length > 0) { if (!design.IsLoaded) { design.Load(); } BinaryFileWriter writer = new BinaryFileWriter(File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.None)); writer.WriteShort(EXPORT_VERSION); writer.WriteString(design.Name); writer.WriteString(design.Category); writer.WriteString(design.Subsection); writer.WriteInt(design.Width); writer.WriteInt(design.Height); writer.WriteInt(design.UserWidth); writer.WriteInt(design.UserHeight); // item count writer.WriteInt(design.Items.Count); for (int i = 0; i < design.Items.Count; ++i) { DesignItem item = design.Items[i]; writer.WriteShort(item.ItemID); writer.WriteShort((short)item.X); writer.WriteShort((short)item.Y); writer.WriteShort((short)item.Z); writer.WriteShort(item.Level); writer.WriteShort(item.Hue); } writer.Close(); } }
private static void WriteUpdatedDesignComponentData(DesignItemCol designItems, BinaryFileWriter binWriter) { for (int i = 0; i < designItems.Count; ++i) { binWriter.WriteInt(COMPONENT_VERSION); binWriter.WriteInt(designItems[i].ItemID); binWriter.WriteInt(designItems[i].X); binWriter.WriteInt(designItems[i].Y); binWriter.WriteInt(designItems[i].Z); binWriter.WriteInt(designItems[i].Level); // level binWriter.WriteInt(designItems[i].Hue); } }
public void Serialize(BinaryFileWriter writer) { writer.WriteInt(Version); switch (Version) { case 0: writer.WriteInt(Index); writer.WriteInt(X); writer.WriteInt(Y); writer.WriteInt(Z); writer.WriteInt(Level); break; } }
private static void WriteHeaderFile() { BinaryFileWriter writer = new BinaryFileWriter(File.Open(TMP_INDEX_FILE, FileMode.Create, FileAccess.Write, FileShare.None)); writer.WriteInt(m_DesignHeaders.Count); // count writer.WriteInt(INDEX_FILE_VERSION); // file version for (int i = 0; i < m_DesignHeaders.Count; ++i) { DesignData header = (DesignData)m_DesignHeaders[i]; writer.WriteString(header.Name); writer.WriteString(header.Category); writer.WriteString(header.Subsection); writer.WriteInt(header.Width); writer.WriteInt(header.Height); writer.WriteInt(header.UserWidth); writer.WriteInt(header.UserHeight); writer.WriteLong(header.FilePosition); writer.WriteInt(header.RecordCount); } writer.Close(); }
private static void WriteSavedComponentData(DesignData header, BinaryFileReader oldFileReader, BinaryFileWriter writer) { int count = header.RecordCount; for (int j = 0; j < count; ++j) { int ver = oldFileReader.ReadInt(); switch (ver) { case 0: writer.WriteInt(ver); // version writer.WriteInt(oldFileReader.ReadInt()); // index writer.WriteInt(oldFileReader.ReadInt()); // x writer.WriteInt(oldFileReader.ReadInt()); // y writer.WriteInt(oldFileReader.ReadInt()); // z writer.WriteInt(oldFileReader.ReadInt()); // level break; case 1: writer.WriteInt(ver); // version writer.WriteInt(oldFileReader.ReadInt()); // index writer.WriteInt(oldFileReader.ReadInt()); // x writer.WriteInt(oldFileReader.ReadInt()); // y writer.WriteInt(oldFileReader.ReadInt()); // z writer.WriteInt(oldFileReader.ReadInt()); // level writer.WriteInt(oldFileReader.ReadInt()); // hue break; } } }