private void AddStartLocation(string name, Coordinates coords, double runDist, bool enabled, int icon) { if (!mStartLocations.ContainsKey(name)) { mStartLocations[name] = new RouteStart(name, RouteStartType.Regular, icon, runDist, coords, SavesPer.All, enabled); } }
private void CheckStartLocation(string name, RouteStartType type, double runDist, int icon, SavesPer savesPer) { RouteStart rs; if ((rs = GetStartLocationByType(type)) != null) { rs.SavesPer = savesPer; } else { mStartLocations[name] = new RouteStart(name, type, icon, runDist, Coordinates.NO_COORDINATES, savesPer, true); } }
public static bool TryParseXml(XmlElement node, out RouteStart startLocation, int characterId, string characterName, int monarchId, string monarchName, string accountName) { startLocation = null; string name; RouteStartType type; double runDistance; int icon; Coordinates coords; SavesPer savesPer; bool enabled; if (!node.HasAttribute("name")) { return(false); } name = node.GetAttribute("name"); if (!Util.TryParseEnum(node.GetAttribute("type"), out type)) { return(false); } if (!double.TryParse(node.GetAttribute("runDistance"), out runDistance)) { return(false); } if (!int.TryParse(node.GetAttribute("icon"), Hex, null, out icon) || ((icon >> 16) != 0x0600)) { icon = Location.LocationTypeInfo(LocationType.Custom).Icon; } if (node.HasAttribute("coords") && node.HasAttribute("enabled")) { Coordinates.TryParse(node.GetAttribute("coords"), true, out coords); bool.TryParse(node.GetAttribute("enabled"), out enabled); savesPer = SavesPer.All; } else { if (!Util.TryParseEnum(node.GetAttribute("savesPer"), out savesPer)) { savesPer = SavesPer.Character; } string xpath; switch (savesPer) { case SavesPer.Account: xpath = "account[@guid='" + accountName + "']"; break; case SavesPer.Monarchy: xpath = "monarch[@guid='" + monarchId.ToString("X") + "']"; break; default: xpath = "character[@guid='" + characterId.ToString("X") + "']"; break; } XmlElement charNode = node.SelectSingleNode(xpath) as XmlElement; if (charNode != null) { Coordinates.TryParse(charNode.GetAttribute("coords"), out coords); bool.TryParse(charNode.GetAttribute("enabled"), out enabled); } else { coords = Coordinates.NO_COORDINATES; enabled = true; } } startLocation = new RouteStart(name, type, icon, runDistance, coords, savesPer, enabled); return(true); }
private void btnStartLocationAdd_Click(object sender, ControlEventArgs e) { try { string name = edtStartLocationName.Text; Coordinates coords; if (!Coordinates.TryParse(edtStartLocationCoords.Text, true, out coords)) { Util.Error("Invalid coordinates"); return; } double runDistance; if (!double.TryParse(edtStartLocationRunDist.Text, out runDistance) && edtStartLocationRunDist.Text != "") { Util.Error("Invalid run distance"); return; } RouteStart loc; ListRow row = null; int rowIndex = -1; if (mStartLocations.TryGetValue(name, out loc)) { loc.Name = name; loc.RunDistance = runDistance; loc.Coords = coords; if (loc.Type == RouteStartType.MansionRecall) { PortalDevice.MansionRunDistance = loc.RunDistance; } for (int r = 0; r < lstStartLocations.RowCount; r++) { if (0 == StringComparer.OrdinalIgnoreCase.Compare(name, lstStartLocations[r][StartLocationsList.Name][0])) { rowIndex = r; row = lstStartLocations[r]; break; } } } else { loc = new RouteStart(name, RouteStartType.Regular, Location.LocationTypeInfo(LocationType.Custom).Icon, runDistance, coords, SavesPer.All, true); mStartLocations[name] = loc; } if (row == null) { int idx = 0; foreach (string nameKey in mStartLocations.Keys) { if (0 == mStartLocations.Comparer.Compare(nameKey, name)) break; idx++; } if (idx == lstStartLocations.RowCount) row = lstStartLocations.Add(); else row = lstStartLocations.Insert(idx); rowIndex = idx; row[StartLocationsList.Icon][1] = loc.Icon; row[StartLocationsList.Delete][1] = DeleteIcon; } loc.Enabled = true; row[StartLocationsList.Enabled][0] = true; row[StartLocationsList.Name][0] = name; row[StartLocationsList.Coords][0] = coords.ToString(true); if (coords != Coordinates.NO_COORDINATES) { row[StartLocationsList.Name].Color = Color.White; row[StartLocationsList.Coords].Color = Color.White; } else { row[StartLocationsList.Name].Color = Color.Gray; row[StartLocationsList.Coords].Color = Color.Gray; } if (btnStartLocationAdd.Text == "Add") { lstStartLocations.ScrollPosition = rowIndex; } edtStartLocationName.Text = ""; edtStartLocationCoords.Text = ""; edtStartLocationRunDist.Text = ""; btnStartLocationAdd.Text = "Add"; } catch (Exception ex) { Util.HandleException(ex); } }
public static bool TryParseXml(XmlElement node, out RouteStart startLocation, int characterId, string characterName, int monarchId, string monarchName, string accountName) { startLocation = null; string name; RouteStartType type; double runDistance; int icon; Coordinates coords; SavesPer savesPer; bool enabled; if (!node.HasAttribute("name")) return false; name = node.GetAttribute("name"); if (!Util.TryParseEnum(node.GetAttribute("type"), out type)) return false; if (!double.TryParse(node.GetAttribute("runDistance"), out runDistance)) return false; if (!int.TryParse(node.GetAttribute("icon"), Hex, null, out icon) || ((icon >> 16) != 0x0600)) icon = Location.LocationTypeInfo(LocationType.Custom).Icon; if (node.HasAttribute("coords") && node.HasAttribute("enabled")) { Coordinates.TryParse(node.GetAttribute("coords"), true, out coords); bool.TryParse(node.GetAttribute("enabled"), out enabled); savesPer = SavesPer.All; } else { if (!Util.TryParseEnum(node.GetAttribute("savesPer"), out savesPer)) savesPer = SavesPer.Character; string xpath; switch (savesPer) { case SavesPer.Account: xpath = "account[@guid='" + accountName + "']"; break; case SavesPer.Monarchy: xpath = "monarch[@guid='" + monarchId.ToString("X") + "']"; break; default: xpath = "character[@guid='" + characterId.ToString("X") + "']"; break; } XmlElement charNode = node.SelectSingleNode(xpath) as XmlElement; if (charNode != null) { Coordinates.TryParse(charNode.GetAttribute("coords"), out coords); bool.TryParse(charNode.GetAttribute("enabled"), out enabled); } else { coords = Coordinates.NO_COORDINATES; enabled = true; } } startLocation = new RouteStart(name, type, icon, runDistance, coords, savesPer, enabled); return true; }