internal void Save() { Dispatcher.BeginInvoke(new Action(() => { if (MainSkills.Count == 0 && SecondarySkills.Count == 0 && HiddenSkills.Count == 0) { return; } var root = new XElement("Skills"); MainSkills.ToList().ForEach(mainSkill => { var tag = mainSkill.CooldownType.ToString(); root.Add(new XElement(tag, new XAttribute("id", mainSkill.Skill.Id), new XAttribute("row", 1), new XAttribute("name", mainSkill.Skill.ShortName))); }); SecondarySkills.ToList().ForEach(secSkill => { var tag = secSkill.CooldownType.ToString(); root.Add(new XElement(tag, new XAttribute("id", secSkill.Skill.Id), new XAttribute("row", 2), new XAttribute("name", secSkill.Skill.ShortName))); }); HiddenSkills.ToList().ForEach(sk => { var tag = sk.CooldownType.ToString(); root.Add(new XElement(tag, new XAttribute("id", sk.Skill.Id), new XAttribute("row", 3), new XAttribute("name", sk.Skill.ShortName))); }); if (SessionManager.CurrentPlayer.Class > (Class)12) { return; } root.Save(Path.Combine(App.ResourcesPath, "config/skills", $"{TccUtils.ClassEnumToString(SessionManager.CurrentPlayer.Class).ToLower()}-skills.xml")); })); }
public void LoadSkills(Class c) { if (c == Class.None) { return; } var filename = TccUtils.ClassEnumToString(c).ToLower() + "-skills.xml"; SkillConfigParser sp; //Dispatcher.Invoke(() => //{ if (!File.Exists(Path.Combine(App.ResourcesPath, "config/skills", filename))) { SkillUtils.BuildDefaultSkillConfig(filename, c); } try { sp = new SkillConfigParser(filename, c); } catch (Exception) { var res = TccMessageBox.Show("TCC", $"There was an error while reading {filename}. Manually correct the error and press Ok to try again, else press Cancel to build a default config file.", MessageBoxButton.OKCancel, MessageBoxImage.Warning); if (res == MessageBoxResult.Cancel) { File.Delete(Path.Combine(App.ResourcesPath, "config/skills/", filename)); } LoadSkills(c); return; } foreach (var sk in sp.Main) { MainSkills.Add(sk); } foreach (var sk in sp.Secondary) { SecondarySkills.Add(sk); } foreach (var sk in sp.Hidden) { HiddenSkills.Add(sk); } Dispatcher.Invoke(() => SkillsView = CollectionViewUtils.InitLiveView(null, SkillsDatabase.SkillsForClass, new string[] { }, new SortDescription[] { })); ((ICollectionView)SkillsView).CollectionChanged += GcStahp; N(nameof(SkillsView)); N(nameof(MainSkills)); N(nameof(SecondarySkills)); SkillsLoaded?.Invoke(); //}); }
public object Convert(object?value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { value = Class.Common; } var ret = TccUtils.ClassEnumToString((Class)value); var toLower = System.Convert.ToBoolean(parameter); return(toLower ? ret.ToLower() : ret); }