private static void Save(string id, object value) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNode settingGroup = root.SelectSingleNode("AppSettings"); if (settingGroup == null) { settingGroup = xmlDoc.CreateElement("AppSettings"); root.AppendChild(settingGroup); } XmlElement iSetting = (XmlElement)root.SelectSingleNode(string.Format(@"AppSettings/Setting[@Key=""{0}""]", id)); if (iSetting == null) { iSetting = xmlDoc.CreateElement("Setting"); settingGroup.AppendChild(iSetting); } iSetting.SetAttribute("Key", id); iSetting.SetAttribute("Value", value.ToString()); xmlDoc.Save(WOTHelper.GetSettingsFile()); }
private static object GetDetails(string id) { object retValue = null; XmlDocument xmlDoc = new XmlDocument(); XmlNode node = null; try { xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; node = root.SelectSingleNode(string.Format(@"AppSettings/Setting[@Key=""{0}""]", id)); } catch { return(null); } if (node != null) { retValue = node.Attributes["Value"] == null ? null : node.Attributes["Value"].Value; } else { retValue = null; } return(retValue); }
public CountryDescriptions(MessageQueue message) { _message = message; try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Countries").ChildNodes; foreach (XmlNode node in nodes) { _countries.Add(int.Parse(node.Attributes["Code"].Value), Translations.TranslationGet(node.Attributes["Code"].Value, "DE", node.InnerText)); } } catch (Exception) { File.Copy(Path.Combine(WOTHelper.GetEXEPath(), "settings.xml"), WOTHelper.GetSettingsFile()); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Countries").ChildNodes; foreach (XmlNode node in nodes) { _countries.Add(int.Parse(node.Attributes["Code"].Value), Translations.TranslationGet(node.Attributes["Code"].Value, "DE", node.InnerText)); } } }
public TankDescriptions(MessageQueue message) { _message = message; _tankTypeDescriptions = new TankTypeDescription(message); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Tanks").ChildNodes; foreach (XmlNode node in nodes) { TankKey tKey = new TankKey() { CountryID = int.Parse(node.Attributes["Country"].Value), TankID = int.Parse(node.Attributes["Code"].Value) }; TankValue tValue = new TankValue() { Description = Translations.TranslationGet(node.Attributes["Country"].Value + "_" + node.Attributes["Code"].Value, "DE", node.InnerText), Tier = int.Parse(node.Attributes["Tier"].Value), Premium = int.Parse(node.Attributes["Premium"].Value), Active = (node.Attributes["Active"] == null ? true : bool.Parse(node.Attributes["Active"].Value)), TankType = node.Attributes["TankType"].Value }; _tanks.Add(tKey, tValue); } }
public TankTypeDescription(MessageQueue message) { _message = message; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"TankTypes").ChildNodes; foreach (XmlNode node in nodes) { _tankTypes.Add(node.Attributes["Code"].Value, Translations.TranslationGet(node.Attributes["Code"].Value, "DE", node.InnerText)); } }
public TankDescriptions(MessageQueue message, string playerDBFile) { _message = message; _tankTypeDescriptions = new TankTypeDescription(message); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Tanks").ChildNodes; //TODO DataTable dt = getMyTanks(playerDBFile); bool gotIt = false; foreach (XmlNode node in nodes) { //TODO gotIt = false; string strExpr = "cmCountryID = " + int.Parse(node.Attributes["Country"].Value) + " AND cmTankID = " + int.Parse(node.Attributes["Code"].Value); var match = dt.Select(strExpr); if (match.Length > 0) { gotIt = true; } // TankKey tKey = new TankKey() { CountryID = int.Parse(node.Attributes["Country"].Value), TankID = int.Parse(node.Attributes["Code"].Value) }; TankValue tValue = new TankValue() { Description = Translations.TranslationGet(node.Attributes["Country"].Value + "_" + node.Attributes["Code"].Value, "DE", node.InnerText), Tier = int.Parse(node.Attributes["Tier"].Value), Premium = int.Parse(node.Attributes["Premium"].Value), Active = (node.Attributes["Active"] == null ? true : bool.Parse(node.Attributes["Active"].Value)), TankType = node.Attributes["TankType"].Value, //TODO GotIt = gotIt }; _tanks.Add(tKey, tValue); } }
public Achievements() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(WOTHelper.GetSettingsFile()); XmlElement root = xmlDoc.DocumentElement; XmlNodeList nodes = root.SelectSingleNode(@"Achievements").ChildNodes; foreach (XmlNode node in nodes) { string trKey = node.Attributes["Key"] == null ? "" : node.Attributes["Key"].Value; _achievements.Add(int.Parse(node.Attributes["Order"].Value), new Achievement() { Name = Translations.TranslationGet(trKey, "DE", node.Attributes["Name"].Value), Value = Convert.ToInt16(node.Attributes["Value"].Value), Tanks = node.Attributes["Tanks"].Value.Split('|') }); } }