public BioCodexMap ToCodexMap() { var codexMap = new BioCodexMap { Pages = CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value), Sections = CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value) }; return(codexMap); }
public void SaveToPcc(PCCPackage pcc) { var index = pcc.FindClass("BioCodexMap"); if (index == 0) { return; } var exportIndex = pcc.Exports.FindIndex(entry => entry.idxClass == index); if (exportIndex < 0) { return; } var codexMapData = pcc.Exports[exportIndex].Data; var codexMapProperties = PropertyReader.getPropList(pcc, codexMapData); if (codexMapProperties.Count <= 0) { return; } var codexMapProperty = codexMapProperties.Find(property => property.TypeVal == PropertyReader.Type.None); var codexMapDataOffset = codexMapProperty.offend; byte[] bytes; var codexMap = new BioCodexMap(CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value), CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value)); // CodexMap using (var stream = new MemoryStream()) { ((BinaryBioCodexMap)codexMap).Save(stream); bytes = stream.ToArray(); } Array.Resize(ref codexMapData, codexMapDataOffset + bytes.Length); bytes.CopyTo(codexMapData, codexMapDataOffset); var temp = pcc.Exports[exportIndex]; Array.Resize(ref temp.Data, codexMapData.Length); codexMapData.CopyTo(temp.Data, 0); pcc.Exports[exportIndex] = temp; }
// Does not replace existing public void AddCodexSection(int id, BioCodexSection codexSection = null) { if (CodexSections == null) { CodexSections = InitCollection <KeyValuePair <int, BioCodexSection> >(); } if (CodexSections.Any(pair => pair.Key == id)) { return; } var codexSectionPair = new KeyValuePair <int, BioCodexSection>(id, codexSection ?? new BioCodexSection()); CodexSections.Add(codexSectionPair); SelectedCodexSection = codexSectionPair; }
public void SaveToPcc(IMEPackage pcc) { IExportEntry export; try { export = pcc.Exports.First(exp => exp.ClassName == "BioCodexMap"); } catch { return; } var codexMapData = export.Data; var codexMapProperties = PropertyReader.getPropList(export); if (codexMapProperties.Count <= 0) { return; } var codexMapProperty = codexMapProperties.Find(property => property.TypeVal == PropertyType.None); var codexMapDataOffset = codexMapProperty.offend; byte[] bytes; var codexMap = new BioCodexMap(CodexSections.ToDictionary(pair => pair.Key, pair => pair.Value), CodexPages.ToDictionary(pair => pair.Key, pair => pair.Value)); // CodexMap using (var stream = new MemoryStream()) { ((BinaryBioCodexMap)codexMap).Save(stream); bytes = stream.ToArray(); } Array.Resize(ref codexMapData, codexMapDataOffset + bytes.Length); bytes.CopyTo(codexMapData, codexMapDataOffset); export.Data = codexMapData; }
public void RemoveCodexSection() { if (CodexSections == null || SelectedCodexSection.Value == null) { return; } var index = CodexSections.IndexOf(SelectedCodexSection); if (!CodexSections.Remove(SelectedCodexSection)) { return; } if (CodexSections.Any()) { SelectedCodexSection = ((index - 1) >= 0) ? CodexSections[index - 1] : CodexSections.First(); } }
public void ChangeCodexSectionId() { if (SelectedCodexSection.Value == null) { return; } var dlg = new ChangeObjectIdDialog { ContentText = string.Format("Change id of codex section #{0}", SelectedCodexSection.Key), ObjectId = SelectedCodexSection.Key }; if (dlg.ShowDialog() == false || dlg.ObjectId < 0 || dlg.ObjectId == SelectedCodexSection.Key) { return; } var codexSection = SelectedCodexSection.Value; CodexSections.Remove(SelectedCodexSection); AddCodexSection(dlg.ObjectId, codexSection); }
private int GetMaxCodexSectionId() { return(CodexSections.Any() ? CodexSections.Max(pair => pair.Key) : -1); }