public Notes_ContractContainer(Notes_ContractContainer copy, List<Guid> id, Notes_Container n)
 {
     activeContracts = copy.activeContracts;
     completedContracts = copy.completedContracts;
     activeContractIDs = id;
     completedContractIDs = id;
     root = n;
     vessel = n.NotesVessel;
 }
 public Notes_ContractContainer(Notes_ContractContainer copy, List<Guid> id, Notes_Archive_Container n)
 {
     activeContracts = copy.activeContracts;
     completedContracts = copy.completedContracts;
     activeContractIDs = id;
     completedContractIDs = id;
     archive_Root = n;
     vessel = null;
     archived = true;
 }
 public Notes_Archive_Container(Guid gid, string name, double time, double m, VesselType t)
 {
     id = gid;
     vesselName = name;
     recoveryTime = time;
     met = m;
     vtype = t;
     container = this;
     log = new Notes_VesselLog(container);
     notes = new Notes_TextContainer(container);
     checkList = new Notes_CheckListContainer(container);
     contracts = new Notes_ContractContainer(container);
     data = new Notes_DataContainer(container);
     crew = new Notes_Archived_Crew_Container(container);
 }
        private void saveContracts(ConfigNode node, Notes_ContractContainer c)
        {
            ConfigNode contracts = new ConfigNode("VESSEL_CONTRACTS");

            if (c.activeContractCount > 0)
                contracts.AddValue("CONTRACTS", c.getAllActiveContractIDs.stringConcat());

            if (c.completedContractCount > 0)
                contracts.AddValue("COMPLETED_CONTRACTS", c.getAllCompletedContractIDs.stringConcat());

            node.AddNode(contracts);
        }
        public override void OnLoad(ConfigNode node)
        {
            if (core == null)
                return;

            ConfigNode vessels = node.GetNode("VESSELS");

            if (vessels != null)
            {
                for (int i = 0; i < vessels.GetNodes("VESSEL_NOTES").Length; i++)
                {
                    ConfigNode vesselNotes = vessels.GetNodes("VESSEL_NOTES")[i];

                    if (vesselNotes == null)
                        continue;

                    Vessel v;

                    try
                    {
                        Guid vID = new Guid(vesselNotes.GetValue("VESSEL_ID"));

                        if (vID == null)
                            continue;

                        v = FlightGlobals.Vessels.FirstOrDefault(a => a.id == vID);

                        if (v == null)
                            continue;
                    }
                    catch (Exception e)
                    {
                        v = null;
                        Debug.LogError("BetterNotes; error while loading vessel\n" + e);
                        continue;
                    }

                    Notes_Container n = new Notes_Container(v);

                    ConfigNode vesselStats = vesselNotes.GetNode("VESSEL_STATS");

                    if (vesselStats != null)
                    {
                        n.loadVitalStats(loadStats(vesselStats));
                    }

                    ConfigNode contracts = vesselNotes.GetNode("VESSEL_CONTRACTS");

                    if (contracts != null)
                    {
                        Notes_ContractContainer c = new Notes_ContractContainer();

                        if (contracts.HasValue("CONTRACTS"))
                            n.loadContracts(c, loadContracts(contracts));

                        if (contracts.HasValue("COMPLETED_CONTRACTS"))
                            n.loadContracts(c, loadCompletedContracts(contracts));
                    }

                    ConfigNode dataNotes = vesselNotes.GetNode("VESSEL_SCIENCE_DATA");

                    if (dataNotes != null)
                    {
                        n.loadDataNotes(loadData(dataNotes));
                    }

                    ConfigNode textNotes = vesselNotes.GetNode("VESSEL_TEXT_NOTES");

                    if (textNotes != null)
                    {
                        n.loadTextNotes(loadTextNotes(textNotes));
                    }

                    ConfigNode checkList = vesselNotes.GetNode("CHECK_LIST");

                    if (checkList != null)
                    {
                        n.loadCheckList(loadCheckList(checkList, false));
                    }

                    ConfigNode vesselLog = vesselNotes.GetNode("VESSEL_LOG");

                    if (vesselLog != null)
                    {
                        n.loadVesselLog(loadLog(vesselLog));
                    }

                    core.addNotes(n);
                }
            }

            ConfigNode archivedVessels = node.GetNode("ARCHIVED_VESSELS");

            if (archivedVessels != null)
            {
                for (int i = 0; i < archivedVessels.GetNodes("ARCHIVED_VESSEL_NOTES").Length; i++)
                {
                    ConfigNode vesselNotes = archivedVessels.GetNodes("ARCHIVED_VESSEL_NOTES")[i];

                    if (vesselNotes == null)
                        continue;

                    Guid vID;

                    try
                    {
                        vID = new Guid(vesselNotes.GetValue("VESSEL_ID"));
                    }
                    catch (Exception e)
                    {
                        Debug.LogError("BetterNotes; error while loading archived vessel\n" + e);
                        continue;
                    }

                    if (vID == null)
                        continue;

                    string name = vesselNotes.parse("VESSEL_NAME", "");
                    double rTime = vesselNotes.parse("RECOVERY_TIME", 0d);
                    double mTime = vesselNotes.parse("MISSION_TIME", 0d);
                    VesselType vT = vesselNotes.parse("VESSEL_TYPE", VesselType.Unknown);

                    Notes_Archive_Container n = new Notes_Archive_Container(vID, name, rTime, mTime, vT);

                    ConfigNode crew = vesselNotes.GetNode("ARCHIVED_CREW");

                    if (crew != null)
                    {
                        n.loadCrewNotes(loadCrew(crew));
                    }

                    ConfigNode contracts = vesselNotes.GetNode("VESSEL_CONTRACTS");

                    if (contracts != null)
                    {
                        Notes_ContractContainer c = new Notes_ContractContainer();

                        if (contracts.HasValue("CONTRACTS"))
                            n.loadContracts(c, loadContracts(contracts));

                        if (contracts.HasValue("COMPLETED_CONTRACTS"))
                            n.loadContracts(c, loadCompletedContracts(contracts));
                    }

                    ConfigNode dataNotes = vesselNotes.GetNode("VESSEL_SCIENCE_DATA");

                    if (dataNotes != null)
                    {
                        n.loadDataNotes(loadData(dataNotes));
                    }

                    ConfigNode textNotes = vesselNotes.GetNode("VESSEL_TEXT_NOTES");

                    if (textNotes != null)
                    {
                        n.loadTextNotes(loadTextNotes(textNotes));
                    }

                    ConfigNode checkList = vesselNotes.GetNode("CHECK_LIST");

                    if (checkList != null)
                    {
                        n.loadCheckList(loadCheckList(checkList, true));
                    }

                    ConfigNode vesselLog = vesselNotes.GetNode("VESSEL_LOG");

                    if (vesselLog != null)
                    {
                        n.loadVesselLog(loadLog(vesselLog));
                    }

                    core.addArchivedNotes(n);
                }
            }
        }
 public void loadContracts(Notes_ContractContainer c, List<Guid> ids)
 {
     contracts = new Notes_ContractContainer(c, ids, this);
 }
 public Notes_ContractShell(contractContainer c, Notes_ContractContainer r)
 {
     contract = c;
     root = r;
 }