private void CreateDefaultFile() { settingsPath = @"WoWCloner_SETTINGS.xml"; if (!File.Exists(settingsPath) || File.ReadAllText(settingsPath).Length < 50) { XDocument doc = new XDocument(new XElement("QS_PathSetting")); doc.Root.Add(new XElement("StartTab", "Mini")); doc.Root.Add(new XElement("Mini_pathSource", @"Z:\VM\wow1")); doc.Root.Add(new XElement("Mini_pathDest", @"C:\wow")); doc.Root.Add(new XElement("Mini_pathHB", @"Z:\VM\zzzx")); doc.Root.Add(new XElement("Mini_pathVM", @"Z:\VM")); doc.Root.Add(new XElement("Full_pathSource", @"D:\VM\wow1")); doc.Root.Add(new XElement("Full_pathDest", @"D:\GAMES\wow")); doc.Root.Add(new XElement("Full_pathHB", @"D:\VM\zzzx")); doc.Root.Add(new XElement("Full_pathVM", @"D:\VM")); doc.Save(settingsPath); Logg.Log($"Стандартный {settingsPath} файл создан."); } else { Logg.Log("Файл настроек существует."); } }
public void LoadQSfromFile(string fullPath) { var doc = XDocument.Load(fullPath); if (doc.Root == null) { Logg.Log("Не удалось загрузить настройки из файла, файл пуст."); return; } if (doc.Root.Element("emailFull") != null) { this.emailFull = doc.Root.Element("emailFull").Value; } if (doc.Root.Element("WoWX") != null) { this.WoWX = doc.Root.Element("WoWX").Value; } if (doc.Root.Element("Password") != null) { this.Password = doc.Root.Element("Password").Value; } if (doc.Root.Element("Nick") != null) { this.Nick = doc.Root.Element("Nick").Value; } if (doc.Root.Element("Realm") != null) { this.Realm = doc.Root.Element("Realm").Value; } if (doc.Root.Element("proxyIP").Value != null) { this.proxyIP = doc.Root.Element("proxyIP").Value; } }
//private string PathHB = ""; static public void MakeSettings_Single(Character character, string pathHB) { pathHB = pathHB + "\\"; Create_CharacterSettings(character, pathHB); Create_SingularSettings(character, pathHB); Create_DungeonBuddySettings(character, pathHB, character.IsLeader); Logg.Log("Character Settings добавлен."); }
public void Load(string fullPath) { settingsPath = fullPath; if (!File.Exists(settingsPath)) { CreateDefaultFile(); } Thread.Sleep(50); doc = XDocument.Load(settingsPath); if (doc.Root == null) { Logg.Log("Не удалось загрузить настройки из файла, файл пуст."); return; } if (doc.Root.Element("StartTab") != null) { this.StartTab = doc.Root.Element("StartTab").Value; } if (doc.Root.Element("Mini_pathSource") != null) { this.Mini_pathSource = doc.Root.Element("Mini_pathSource").Value; } if (doc.Root.Element("Mini_pathDest") != null) { this.Mini_pathDest = doc.Root.Element("Mini_pathDest").Value; } if (doc.Root.Element("Mini_pathHB") != null) { this.Mini_pathHB = doc.Root.Element("Mini_pathHB").Value; } if (doc.Root.Element("Mini_pathVM") != null) { this.Mini_pathVM = doc.Root.Element("Mini_pathVM").Value; } if (doc.Root.Element("Full_pathSource") != null) { this.Full_pathSource = doc.Root.Element("Full_pathSource").Value; } if (doc.Root.Element("Full_pathDest") != null) { this.Full_pathDest = doc.Root.Element("Full_pathDest").Value; } if (doc.Root.Element("Full_pathHB") != null) { this.Full_pathHB = doc.Root.Element("Full_pathHB").Value; } if (doc.Root.Element("Full_pathVM") != null) { this.Full_pathVM = doc.Root.Element("Full_pathVM").Value; } }
public void Save(string startTab, string Mini_pathSource, string Mini_pathDest, string Mini_pathHB, string Mini_pathVM, string Full_pathSource, string Full_pathDest, string Full_pathHB, string Full_pathVM) { XDocument doc = new XDocument(new XElement("QS_PathSetting")); doc.Root.Add(new XElement("StartTab", startTab)); doc.Root.Add(new XElement("Mini_pathSource", Mini_pathSource)); doc.Root.Add(new XElement("Mini_pathDest", Mini_pathDest)); doc.Root.Add(new XElement("Mini_pathHB", Mini_pathHB)); doc.Root.Add(new XElement("Mini_pathVM", Mini_pathVM)); doc.Root.Add(new XElement("Full_pathSource", Full_pathSource)); doc.Root.Add(new XElement("Full_pathDest", Full_pathDest)); doc.Root.Add(new XElement("Full_pathHB", Full_pathHB)); doc.Root.Add(new XElement("Full_pathVM", Full_pathVM)); doc.Save(settingsPath); Logg.Log($"{settingsPath} файл создан."); }
static void Create_SingularSettings(Character character, string PathHB) { if (File.Exists(PathHB + $@"Settings\{character.Realm}\{character.Nick}\SingularSettings.xml")) { Logg.Log("SingularSettings.xml уже существует."); return; } XDocument doc = new XDocument(); XElement root = new XElement("SingularSettings"); doc.Add(root); //добавляем необходимые значения root.Add(new XElement("MoveToTargetTimeout", "15")); root.Add(new XElement("MinHealth", "40")); root.Add(new XElement("MinMana", "30")); root.Add(new XElement("PotionHealth", "30")); root.Add(new XElement("PotionMana", "20")); root.Add(new XElement("KiteAllow", "False")); root.Add(new XElement("KiteHealth", "60")); root.Add(new XElement("KiteMobCount", "4")); /* *остальные элементы добавляем по аналогии */ //сохраняем наш документ if (!Directory.Exists(PathHB + $@"Settings")) { Directory.CreateDirectory(PathHB + $@"Settings"); } if (!Directory.Exists(PathHB + $@"Settings\{character.Realm}")) { Directory.CreateDirectory(PathHB + $@"Settings\{character.Realm}"); } if (!Directory.Exists(PathHB + $@"Settings\{character.Realm}\{character.Nick}")) { Directory.CreateDirectory(PathHB + $@"Settings\{character.Realm}\{character.Nick}"); } doc.Save(PathHB + $@"Settings\{character.Realm}\{character.Nick}\SingularSettings.xml"); }
static public void MakeSettings_Multiple(List <Character> membersList, string pathHB) { pathHB = pathHB + "\\"; foreach (var member in membersList) { Create_CharacterSettings(member, pathHB); Create_SingularSettings(member, pathHB); string leaderName = null; string member2 = null; string member3 = null; string member4 = null; string member5 = null; if (member.IsLeader) { List <Character> membs = new List <Character>(); foreach (var memb in membersList) { if (member.Nick != memb.Nick) { membs.Add(memb); } } leaderName = null; if (membs.Count > 0) { if (member.Realm != membs.First().Realm) { member2 = $"{membs.First().Nick}-{membs.First().Realm.Replace(" ", "")}"; } else { member2 = membs.First().Nick; } membs.RemoveAt(0); } if (membs.Count > 0) { if (member.Realm != membs.First().Realm) { member3 = $"{membs.First().Nick}-{membs.First().Realm.Replace(" ", "")}"; } else { member3 = membs.First().Nick; } membs.RemoveAt(0); } if (membs.Count > 0) { if (member.Realm != membs.First().Realm) { member4 = $"{membs.First().Nick}-{membs.First().Realm.Replace(" ", "")}"; } else { member4 = membs.First().Nick; } membs.RemoveAt(0); } if (membs.Count > 0) { if (member.Realm != membs.First().Realm) { member5 = $"{membs.First().Nick}-{membs.First().Realm.Replace(" ", "")}"; } else { member5 = membs.First().Nick; } membs.RemoveAt(0); } } else if (membersList.Any(a => a.IsLeader)) { Character leaderCharacter = membersList.First(a => a.IsLeader); if (member.Realm != leaderCharacter.Realm) { leaderName = $"{leaderCharacter.Nick}-{leaderCharacter.Realm.Replace(" ", "")}"; } else { leaderName = leaderCharacter.Nick; } } Create_DungeonBuddySettings(member, pathHB, member.IsLeader, leaderName, member2, member3, member4, member5); } Logg.Log("Character Settings добавлены."); }
static void Create_CharacterSettings(Character character, string PathHB) { if (File.Exists(PathHB + $@"Settings\{character.Realm}\{character.Nick}\CharacterSettings.xml")) { Logg.Log("CharacterSettings.xml уже существует."); return; } XDocument doc = new XDocument(); XElement root = new XElement("CharacterSettings"); doc.Add(root); //добавляем необходимые значения root.Add(new XElement("SelectTalents", "True")); root.Add(new XElement("ClassProfileName", "")); //character.ClassSpec root.Add(new XElement("RollOnItems", "True")); root.Add(new XElement("RollDisenchantWhenGreed", "False")); root.Add(new XElement("TicksPerSecond", "12")); root.Add(new XElement("FoodAmount", "0")); root.Add(new XElement("DrinkAmount", "0")); root.Add(new XElement("SellGrey", "True")); root.Add(new XElement("SellWhite", "True")); root.Add(new XElement("SellGreen", "True")); root.Add(new XElement("SellBlue", "True")); root.Add(new XElement("SellPurple", "False")); root.Add(new XElement("Use", "Questing")); root.Add(new XElement("UseFlightPaths", "True")); root.Add(new XElement("FindMountAutomatically", "True")); root.Add(new XElement("UseRandomMount", "True")); root.Add(new XElement("LootMobs", "True")); root.Add(new XElement("SkinMobs", "True")); root.Add(new XElement("NinjaSkin", "True")); root.Add(new XElement("LootChests", "True")); root.Add(new XElement("HarvestMinerals", "True")); root.Add(new XElement("HarvestHerbs", "True")); root.Add(new XElement("UseMount", "True")); root.Add(new XElement("PullDistance", "30")); root.Add(new XElement("LootRadius", "40")); root.Add(new XElement("LastUsedPath", PathHB + @"Default Profiles\Questing Profile Pack\Auto Loader - v2.xml")); root.Add(new XElement("RessAtSpiritHealers", "False")); /* *остальные элементы добавляем по аналогии */ //сохраняем наш документ if (!Directory.Exists(PathHB + $@"Settings")) { Directory.CreateDirectory(PathHB + $@"Settings"); } if (!Directory.Exists(PathHB + $@"Settings\{character.Realm}")) { Directory.CreateDirectory(PathHB + $@"Settings\{character.Realm}"); } if (!Directory.Exists(PathHB + $@"Settings\{character.Realm}\{character.Nick}")) { Directory.CreateDirectory(PathHB + $@"Settings\{character.Realm}\{character.Nick}"); } doc.Save(PathHB + $@"Settings\{character.Realm}\{character.Nick}\CharacterSettings.xml"); }