void SyncNotes(VesselNotesLogs syncToNote) { for (int n = 0; n < noteList.list.Count; n++) { if (!noteList.list[n].privateNote && !noteList.list[n].locked) { NOTE_LIST syncToNotesList = syncToNote.noteList; var foundNote = syncToNotesList.list.SingleOrDefault(r => r.guid == noteList.list[n].guid); if (foundNote == null) { if (noteList.list[n].noteListGuid == syncToNotesList.listGuid) { syncToNotesList.list.Add(new NOTE( noteList.list[n].title, noteList.list[n].note, noteList.list[n].guid, syncToNotesList.listGuid, false)); } } else { if (!foundNote.privateNote && !foundNote.locked) { Log.Info("guid matches"); foundNote.title = noteList.list[n].title; foundNote.note = noteList.list[n].note; } } } } syncToNote.SetSelectedNote(syncToNote.selectedNote); }
void SyncLogs(VesselNotesLogs syncToNote) { for (int n = 0; n < logList.list.Count; n++) { if (!logList.list[n].privateNote && !logList.list[n].locked) { NOTE_LIST syncToLogList = syncToNote.logList; NOTE foundLog = syncToLogList.list.SingleOrDefault(r => r.guid == logList.list[n].guid); if (foundLog == null) { if (logList.list[n].noteListGuid == syncToLogList.listGuid) { syncToLogList.list.Add(new NOTE( logList.list[n].title, logList.list[n].note, logList.list[n].guid, syncToLogList.listGuid, false)); } } else { foundLog.title = logList.list[n].title; foundLog.note = logList.list[n].note; foundLog.id = logList.list[n].id; } } } syncToNote.SetSelectedLog(syncToNote.selectedLog); }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (HighLogic.CurrentGame == null) { return; } if (!HighLogic.LoadedSceneIsEditor && vessel != null) { if (vessel.protoVessel.protoPartSnapshots[0].partName == "PotatoRoid" || vessel.isEVA) { return; } } noteList = new NOTE_LIST(); ConfigNode vesselNode = node.GetNode(NODENAME); Guid listguid = Guid.Empty; if (node.TryGetValue("LISTGUID", ref listguid)) { noteList.listGuid = listguid; bool log = false; if (node.TryGetValue("AUTOLOG", ref log)) { logList.autolog = log; if (vesselNode != null) { ConfigNode[] nodes = vesselNode.GetNodes("NOTES"); if (nodes != null) { foreach (var n in nodes) { bool privateNote = false; if (n.TryGetValue("PRIVATENOTE", ref privateNote)) { string title = ""; if (n.TryGetValue("TITLE", ref title)) { string note = ""; if (n.TryGetValue("NOTE", ref note)) { note = note.Replace("<EOL>", "\n"); Guid guid = Guid.Empty; if (n.TryGetValue("GUID", ref guid)) { Guid vesselId = Guid.Empty; if (n.TryGetValue("VESSEL_ID", ref vesselId)) { noteList.list.Add(new NOTE(title, note, guid, vesselId, privateNote)); } } } } } } } } } } noteList.lastOnLoad = Planetarium.GetUniversalTime(); ConfigNode[] logs = vesselNode.GetNodes("VESSELLOG"); if (logs != null) { foreach (var n in logs) { bool privateNote = false; if (n.TryGetValue("PRIVATENOTE", ref privateNote)) { string title = ""; if (n.TryGetValue("TITLE", ref title)) { string note = ""; if (n.TryGetValue("NOTE", ref note)) { note = note.Replace("<EOL>", "\n"); Guid guid = Guid.Empty; if (n.TryGetValue("GUID", ref guid)) { Guid vesselId = Guid.Empty; if (n.TryGetValue("VESSEL_ID", ref vesselId)) { logList.list.Add(new NOTE(title, note, guid, vesselId, privateNote)); } } } } } } } }