public bool LoadChecklists() { try { if (WernherChecker.Instance.Settings.cfgLoaded) { availableChecklists.Clear(); foreach (ConfigNode checklistNode in WernherChecker.Instance.Settings.cfg.GetNodes("CHECKLIST")) { Log.Info("Parsing checklist - " + checklistNode.GetValue("name")); Checklist parsedChecklist = new Checklist(); parsedChecklist.items = new List <ChecklistItem>(); parsedChecklist.name = checklistNode.GetValue("name"); if (checklistNode.HasValue("scene")) { var scene = checklistNode.GetValue("scene"); parsedChecklist.editorOnly = (scene == "editor"); parsedChecklist.flightOnly = (scene == "flight"); } ///Begining item cycle foreach (ConfigNode itemNode in checklistNode.GetNodes("CHECKLIST_ITEM")) { //Log.Info("parsing item " + itemNode.GetValue("name")); ChecklistItem parsedItem = new ChecklistItem(); parsedItem.criteria = new List <Criterion>(); parsedItem.name = itemNode.GetValue("name"); if (itemNode.HasValue("scene")) { var scene = itemNode.GetValue("scene"); parsedItem.editorOnly = (scene == "editor"); parsedItem.flightOnly = (scene == "flight"); } if (!bool.TryParse(itemNode.GetValue("isManual"), out parsedItem.isManual)) { parsedItem.isManual = false; } if (!bool.TryParse(itemNode.GetValue("allRequired"), out parsedItem.allRequired)) { parsedItem.allRequired = true; } ; //Begining criterion cycle foreach (ConfigNode criterionNode in itemNode.GetNodes("CRITERION")) { //Log.Info("parsing criterion of type " + criterionNode.GetValue("type")); Criterion parsedCriterion = new Criterion(criterionNode); if (parsedCriterion.valid) { parsedItem.criteria.Add(parsedCriterion); } } if (parsedItem.criteria.Count() > 0 || parsedItem.isManual) { parsedChecklist.items.Add(parsedItem); } } availableChecklists.Add(parsedChecklist); } } return(true); } catch { Log.Warning("Error loading checklist. Please, check your cfg file."); return(false); } }
public bool LoadChecklists() { try { if (WernherChecker.Instance.Settings.cfgLoaded) { availableChecklists.Clear(); foreach (ConfigNode checklistNode in WernherChecker.Instance.Settings.cfg.GetNodes("CHECKLIST")) { Debug.Log("[WernherChecker]: Parsing checklist - " + checklistNode.GetValue("name")); Checklist parsedChecklist = new Checklist(); parsedChecklist.items = new List<ChecklistItem>(); parsedChecklist.name = checklistNode.GetValue("name"); ///Begining item cycle foreach (ConfigNode itemNode in checklistNode.GetNodes("CHECKLIST_ITEM")) { //Debug.Log("parsing item " + itemNode.GetValue("name")); ChecklistItem parsedItem = new ChecklistItem(); parsedItem.criteria = new List<Criterion>(); parsedItem.name = itemNode.GetValue("name"); if (!bool.TryParse(itemNode.GetValue("isManual"), out parsedItem.isManual)) parsedItem.isManual = false; if(!bool.TryParse(itemNode.GetValue("allRequired"), out parsedItem.allRequired)) parsedItem.allRequired = true; ; //Begining criterion cycle foreach (ConfigNode criterionNode in itemNode.GetNodes("CRITERION")) { //Debug.Log("parsing criterion of type " + criterionNode.GetValue("type")); Criterion parsedCriterion = new Criterion(criterionNode); parsedItem.criteria.Add(parsedCriterion); } parsedChecklist.items.Add(parsedItem); } availableChecklists.Add(parsedChecklist); } } return true; } catch { Debug.LogWarning("[WernherChecker]: Error loading checklist. Please, check your cfg file."); return false; } }