void DumpGMO(ActionProgramRun ap, string nprefix, EliteDangerousCore.EDSM.GalacticMapObject g) { ap[nprefix + "Name"] = g.name; ap[nprefix + "Type"] = g.type; ap[nprefix + "Search"] = g.galMapSearch; ap[nprefix + "MapURL"] = g.galMapUrl; ap[nprefix + "Description"] = g.description; ap[nprefix + "Group"] = g.galMapType.Group.ToString(); if (g.points != null) { for (int i = 0; i < g.points.Count; i++) { string p = nprefix + "Vertex_" + (i + 1).ToStringInvariant() + "_"; ap[p + "X"] = g.points[i].X.ToStringInvariant("0.##"); ap[p + "Y"] = g.points[i].Y.ToStringInvariant("0.##"); ap[p + "Z"] = g.points[i].Z.ToStringInvariant("0.##"); } } }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.Functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "G_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in GMO"); return(true); } cmdname = sp.NextWord(); } if (cmdname != null) { EDDiscoveryForm discoveryform = (ap.ActionController as ActionController).DiscoveryForm; if (cmdname.Equals("LIST", StringComparison.InvariantCultureIgnoreCase)) { string wildcard = sp.NextQuotedWord() ?? "*"; int count = 1; foreach (var g in discoveryform.galacticMapping.galacticMapObjects) { if (g.name.WildCardMatch(wildcard)) { string nprefix = prefix + (count++).ToStringInvariant() + "_"; DumpGMO(ap, nprefix, g); } } ap[prefix + "MatchCount"] = (count - 1).ToStringInvariant(); ap[prefix + "TotalCount"] = discoveryform.galacticMapping.galacticMapObjects.Count.ToStringInvariant(); } else { string name = sp.NextQuotedWord(); if (name != null) { if (cmdname.Equals("EXISTS", StringComparison.InvariantCultureIgnoreCase)) { EliteDangerousCore.EDSM.GalacticMapObject gmo = discoveryform.galacticMapping.Find(name, false); ap[prefix + "Exists"] = (gmo != null).ToStringIntValue(); if (gmo != null) { DumpGMO(ap, prefix, gmo); } } else { ap.ReportError("Unknown GMO command"); } } else { ap.ReportError("Missing name in command"); } } } else { ap.ReportError("Missing GMO command"); } } else { ap.ReportError(res); } return(true); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "T_"; string cmdname = sp.NextWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Target"); return(true); } cmdname = sp.NextWord(); } if (cmdname != null) { if (cmdname.Equals("GET", StringComparison.InvariantCultureIgnoreCase)) { bool tset = EliteDangerousCore.DB.TargetClass.IsTargetSet(); ap[prefix + "TargetSet"] = tset.ToStringIntValue(); if (tset) { EliteDangerousCore.DB.TargetClass.GetTargetPosition(out string name, out double x, out double y, out double z); ap[prefix + "TargetType"] = EliteDangerousCore.DB.TargetClass.GetTargetType().ToString(); ap[prefix + "TargetPositionFullName"] = name; ap[prefix + "TargetPositionName"] = EliteDangerousCore.DB.TargetClass.GetNameWithoutPrefix(name); if (!double.IsNaN(x) && !double.IsNaN(y) && !double.IsNaN(z)) { ap[prefix + "TargetPositionX"] = x.ToStringInvariant("0.##"); ap[prefix + "TargetPositionY"] = y.ToStringInvariant("0.##"); ap[prefix + "TargetPositionZ"] = z.ToStringInvariant("0.##"); } } } else if (cmdname.Equals("CLEAR", StringComparison.InvariantCultureIgnoreCase)) { bool tset = EliteDangerousCore.DB.TargetClass.IsTargetSet(); ap[prefix + "TargetClear"] = tset.ToStringIntValue(); if (tset) { TargetClass.ClearTarget(); } } else { string name = sp.NextQuotedWord(); if (name != null) { EDDiscoveryForm discoveryform = (ap.actioncontroller as ActionController).DiscoveryForm; if (cmdname.Equals("BOOKMARK", StringComparison.InvariantCultureIgnoreCase)) { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(name); // has it been bookmarked? if (bk != null) { TargetClass.SetTargetBookmark(name, bk.id, bk.x, bk.y, bk.z); discoveryform.NewTargetSet(this); } else { ap.ReportError("Bookmark '" + name + "' not found"); } } else if (cmdname.Equals("GMO", StringComparison.InvariantCultureIgnoreCase)) { EliteDangerousCore.EDSM.GalacticMapObject gmo = discoveryform.galacticMapping.Find(name, true, true); if (gmo != null) { TargetClass.SetTargetGMO("G:" + gmo.name, gmo.id, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z); discoveryform.NewTargetSet(this); } else { ap.ReportError("GMO '" + name + "' not found"); } } else if (cmdname.Equals("NOTE", StringComparison.InvariantCultureIgnoreCase)) { SystemNoteClass nc = SystemNoteClass.GetNoteOnSystem(name); // has it got a note? ISystem sc = discoveryform.history.FindSystem(name); if (sc != null && sc.HasCoordinate && nc != null) { TargetClass.SetTargetNotedSystem(name, nc.id, sc.X, sc.Y, sc.Z); discoveryform.NewTargetSet(this); } else { ap.ReportError("No Note found on entries in system '" + name + "'"); } } else { ap.ReportError("Unknown TARGET command"); } } else { ap.ReportError("Missing name in command"); } } } else { ap.ReportError("Missing TARGET command"); } } else { ap.ReportError(res); } return(true); }