public void OpenPccFile(string path) { if (path == null) { throw new ArgumentNullException("path"); } if (!File.Exists(path)) { return; } FileName = path; PccPackage = new PCCPackage(path, closestream: true); if (CodexMapViewModel != null) { CodexMapViewModel.Open(PccPackage); } if (QuestMapViewModel != null) { QuestMapViewModel.Open(PccPackage); } if (StateEventMapViewModel != null) { StateEventMapViewModel.Open(PccPackage); } }
public ShellViewModel() { CodexMapViewModel = new CodexMapViewModel(); QuestMapViewModel = new QuestMapViewModel(); StateEventMapViewModel = new StateEventMapViewModel(); FindObjectUsagesViewModel = new FindObjectUsagesViewModel(); WindowTitle = "Natives Editor"; }
public void SaveFile() { if (PccPackage == null) { return; } if (CodexMapViewModel != null) { int exportIndex; int dataOffset; if (CodexMapViewModel.TryFindCodexMap(PccPackage, out exportIndex, out dataOffset)) { var mapData = PccPackage.Exports[exportIndex].Data; byte[] bytes; using (var stream = new MemoryStream()) { var codexMap = CodexMapViewModel.ToCodexMap(); var binaryCodexMap = new BinaryBioCodexMap(codexMap.Sections, codexMap.Pages); binaryCodexMap.Save(stream); bytes = stream.ToArray(); } Array.Resize(ref mapData, dataOffset + bytes.Length); bytes.CopyTo(mapData, dataOffset); var temp = PccPackage.Exports[exportIndex]; Array.Resize(ref temp.Data, mapData.Length); mapData.CopyTo(temp.Data, 0); PccPackage.Exports[exportIndex] = temp; } } if (QuestMapViewModel != null) { int exportIndex; int dataOffset; if (QuestMapViewModel.TryFindQuestMap(PccPackage, out exportIndex, out dataOffset)) { var mapData = PccPackage.Exports[exportIndex].Data; byte[] bytes; using (var stream = new MemoryStream()) { var questMap = QuestMapViewModel.ToQuestMap(); var binaryQuestMap = new BinaryBioQuestMap(questMap.Quests, questMap.BoolTaskEvals, questMap.IntTaskEvals, questMap.FloatTaskEvals); binaryQuestMap.Save(stream); bytes = stream.ToArray(); } Array.Resize(ref mapData, dataOffset + bytes.Length); bytes.CopyTo(mapData, dataOffset); var temp = PccPackage.Exports[exportIndex]; Array.Resize(ref temp.Data, mapData.Length); mapData.CopyTo(temp.Data, 0); PccPackage.Exports[exportIndex] = temp; } } if (StateEventMapViewModel != null) { int exportIndex; int dataOffset; if (StateEventMapViewModel.TryFindStateEventMap(PccPackage, out exportIndex, out dataOffset)) { var mapData = PccPackage.Exports[exportIndex].Data; byte[] bytes; using (var stream = new MemoryStream()) { var stateEventMap = StateEventMapViewModel.ToStateEventMap(); var binaryStateEventMap = new BinaryBioStateEventMap(stateEventMap.StateEvents); binaryStateEventMap.Save(stream); bytes = stream.ToArray(); } Array.Resize(ref mapData, dataOffset + bytes.Length); bytes.CopyTo(mapData, dataOffset); var temp = PccPackage.Exports[exportIndex]; Array.Resize(ref temp.Data, mapData.Length); mapData.CopyTo(temp.Data, 0); PccPackage.Exports[exportIndex] = temp; } } PccPackage.Save(FileName); }