void corpseTracker_ItemAdded(TrackedCorpse item) { try { if (item.Opened) return; HudList.HudListRowAccessor newRow = hudList.InsertRow(1); ((HudStaticText)newRow[0]).Text = item.TimeStamp.ToString("ddd HH:mm"); ((HudStaticText)newRow[1]).Text = item.Description; CoordsObject newCords = Mag.Shared.Util.GetCoords(item.LandBlock, item.LocationX, item.LocationY); ((HudStaticText)newRow[2]).Text = newCords.ToString(); ((HudStaticText)newRow[3]).Text = item.Id.ToString(CultureInfo.InvariantCulture); } catch (Exception ex) { Debug.LogException(ex); } }
public static bool Import(string fileName, out List <TrackedCorpse> items) { items = new List <TrackedCorpse>(); FileInfo fileInfo = new FileInfo(fileName); if (!fileInfo.Exists) { return(false); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(fileName); XmlNode corpsesNode = xmlDocument.SelectSingleNode("Corpses"); if (corpsesNode == null) { return(false); } // Import the Items if (corpsesNode.HasChildNodes) { foreach (XmlNode node in corpsesNode.ChildNodes) { if (node.Attributes == null || node.Attributes.Count == 0) { continue; } XmlAttribute attribute; TrackedCorpse item; if ((attribute = node.Attributes["Id"]) != null) { int value; if (int.TryParse(attribute.Value, out value)) { item = new TrackedCorpse(value); } else { continue; } } else { continue; } if ((attribute = node.Attributes["TimeStamp"]) != null) { long value; if (long.TryParse(attribute.Value, out value)) { item.TimeStamp = new DateTime(value); } } if ((attribute = node.Attributes["LandBlock"]) != null) { int value; if (int.TryParse(attribute.Value, out value)) { item.LandBlock = value; } } if ((attribute = node.Attributes["LocationX"]) != null) { double value; if (double.TryParse(attribute.Value, out value)) { item.LocationX = value; } } if ((attribute = node.Attributes["LocationY"]) != null) { double value; if (double.TryParse(attribute.Value, out value)) { item.LocationY = value; } } if ((attribute = node.Attributes["LocationZ"]) != null) { double value; if (double.TryParse(attribute.Value, out value)) { item.LocationZ = value; } } if ((attribute = node.Attributes["Description"]) != null) { item.Description = attribute.Value; } if ((attribute = node.Attributes["Opened"]) != null) { bool value; if (bool.TryParse(attribute.Value, out value)) { item.Opened = value; } } items.Add(item); } } return(true); }
void RemoveCorpse(TrackedCorpse item) { for (int row = 1; row <= hudList.RowCount; row++) { if (((HudStaticText)hudList[row - 1][3]).Text == item.Id.ToString(CultureInfo.InvariantCulture)) { hudList.RemoveRow(row - 1); row--; } } }
void corpseTracker_ItemRemoved(TrackedCorpse item) { try { RemoveCorpse(item); } catch (Exception ex) { Debug.LogException(ex); } }
void corpseTracker_ItemChanged(TrackedCorpse item) { try { if (item.Opened) RemoveCorpse(item); } catch (Exception ex) { Debug.LogException(ex); } }
public static bool Import(string fileName, out List<TrackedCorpse> items) { items = new List<TrackedCorpse>(); FileInfo fileInfo = new FileInfo(fileName); if (!fileInfo.Exists) return false; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(fileName); XmlNode corpsesNode = xmlDocument.SelectSingleNode("Corpses"); if (corpsesNode == null) return false; // Import the Items if (corpsesNode.HasChildNodes) { foreach (XmlNode node in corpsesNode.ChildNodes) { if (node.Attributes == null || node.Attributes.Count == 0) continue; XmlAttribute attribute; TrackedCorpse item; if ((attribute = node.Attributes["Id"]) != null) { int value; if (int.TryParse(attribute.Value, out value)) item = new TrackedCorpse(value); else continue; } else continue; if ((attribute = node.Attributes["TimeStamp"]) != null) { long value; if (long.TryParse(attribute.Value, out value)) item.TimeStamp = new DateTime(value); } if ((attribute = node.Attributes["LandBlock"]) != null) { int value; if (int.TryParse(attribute.Value, out value)) item.LandBlock = value; } if ((attribute = node.Attributes["LocationX"]) != null) { double value; if (double.TryParse(attribute.Value, out value)) item.LocationX = value; } if ((attribute = node.Attributes["LocationY"]) != null) { double value; if (double.TryParse(attribute.Value, out value)) item.LocationY = value; } if ((attribute = node.Attributes["LocationZ"]) != null) { double value; if (double.TryParse(attribute.Value, out value)) item.LocationZ = value; } if ((attribute = node.Attributes["Description"]) != null) item.Description = attribute.Value; if ((attribute = node.Attributes["Opened"]) != null) { bool value; if (bool.TryParse(attribute.Value, out value)) item.Opened = value; } items.Add(item); } } return true; }