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"));
     }));
 }
示例#2
0
        public void LoadSkills(string filename, Class c)
        {
            SkillConfigParser sp;

            Dispatcher.Invoke(() =>
            {
                if (!File.Exists("resources/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);

                    if (res == MessageBoxResult.Cancel)
                    {
                        File.Delete("resources/config/skills/" + filename);
                    }
                    LoadSkills(filename, 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.Skill);
                }

                Dispatcher.Invoke(() =>
                {
                    SkillChoiceList.Clear();
                    foreach (var skill in SkillsDatabase.SkillsForClass)
                    {
                        SkillChoiceList.Add(skill);
                    }

                    SkillsView = Utils.InitLiveView(null, SkillChoiceList, new string[] { }, new SortDescription[] { });
                });
                NPC(nameof(SkillsView));
                NPC(nameof(MainSkills));
                NPC(nameof(SecondarySkills));
                SkillsLoaded?.Invoke();
            });
        }
示例#3
0
 private void MainSkills_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action != NotifyCollectionChangedAction.Remove)
     {
         return;
     }
     MainSkills.InvalidateMeasure();
     MainSkills.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
     CooldownWindowViewModel.Instance.Save();
 }
示例#4
0
 public void ClearSkills()
 {
     ShortSkills.Clear();
     LongSkills.Clear();
     MainSkills.Clear();
     SecondarySkills.Clear();
     OtherSkills.Clear();
     ItemSkills.Clear();
     HiddenSkills.Clear();
 }
        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();
            //});
        }
        //internal void AddHiddenSkill(Cooldown context)
        //{
        //    HiddenSkills.Add(context.Skill);
        //    Save();
        //}

        internal void DeleteFixedSkill(Cooldown context)
        {
            if (MainSkills.Contains(context))
            {
                MainSkills.Remove(context);
            }
            else if (SecondarySkills.Contains(context))
            {
                SecondarySkills.Remove(context);
            }

            Save();
        }
示例#7
0
        private void FixedMode_Update(SkillCooldown sk)
        {
            if (Settings.ClassWindowSettings.Enabled && ClassManager.StartSpecialSkill(sk))
            {
                return;
            }
            if (!Settings.CooldownWindowSettings.Enabled)
            {
                return;
            }

            var hSkill = HiddenSkills.ToSyncArray().FirstOrDefault(x => x.IconName == sk.Skill.IconName);

            if (hSkill != null)
            {
                return;
            }

            var skill = MainSkills.FirstOrDefault(x => x.Skill.IconName == sk.Skill.IconName);

            if (skill != null)
            {
                if (sk.Pre)
                {
                    skill.Start(sk.Cooldown, CooldownMode.Pre);
                }
                else
                {
                    skill.Start(sk.Cooldown);
                }
                return;
            }
            skill = SecondarySkills.ToSyncArray().FirstOrDefault(x => x.Skill.IconName == sk.Skill.IconName);
            if (skill != null)
            {
                if (sk.Pre)
                {
                    skill.Start(sk.Cooldown, CooldownMode.Pre);
                }
                else
                {
                    skill.Start(sk.Cooldown);
                }
                return;
            }


            UpdateOther(sk);
        }
示例#8
0
        public void ResetSkill(Skill skill)
        {
            if (!Settings.CooldownWindowSettings.Enabled)
            {
                return;
            }
            if (Settings.CooldownBarMode == CooldownBarMode.Normal)
            {
                return;
            }

            var sk = MainSkills.FirstOrDefault(x => x.Skill.IconName == skill.IconName) ?? SecondarySkills.FirstOrDefault(x => x.Skill.IconName == skill.IconName);

            sk?.ProcReset();
        }
        public void ClearSkills()
        {
            ShortSkills.ToList().ForEach(sk => sk.Dispose());
            LongSkills.ToList().ForEach(sk => sk.Dispose());
            MainSkills.ToList().ForEach(sk => sk.Dispose());
            SecondarySkills.ToList().ForEach(sk => sk.Dispose());
            OtherSkills.ToList().ForEach(sk => sk.Dispose());
            ItemSkills.ToList().ForEach(sk => sk.Dispose());

            ShortSkills.Clear();
            LongSkills.Clear();
            MainSkills.Clear();
            SecondarySkills.Clear();
            OtherSkills.Clear();
            ItemSkills.Clear();
            HiddenSkills.Clear();
        }
        private void FixedMode_Remove(Skill sk)
        {
            //sk.SetDispatcher(Dispatcher);
            if (!SettingsHolder.CooldownWindowSettings.Enabled)
            {
                return;
            }

            var skill = MainSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.IconName);

            if (skill != null)
            {
                skill.Refresh(sk.Id, 0, CooldownMode.Normal);
                return;
            }
            skill = SecondarySkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.IconName);
            if (skill != null)
            {
                skill.Refresh(sk.Id, 0, CooldownMode.Normal);
                return;
            }

            var item = ItemSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.IconName);

            if (item != null)
            {
                ItemSkills.Remove(item);
                item.Dispose();
                return;
            }

            try
            {
                var otherSkill = OtherSkills.ToSyncList().FirstOrDefault(x => x.Skill.Name == sk.Name);
                if (otherSkill != null)
                {
                    OtherSkills.Remove(otherSkill);
                    otherSkill.Dispose();
                }
            }
            catch
            {
                // ignored
            }
        }
        private void FixedMode_Change(Skill sk, uint cd)
        {
            if (!SettingsHolder.CooldownWindowSettings.Enabled)
            {
                return;
            }
            if (SettingsHolder.ClassWindowSettings.Enabled && ClassManager.ChangeSpecialSkill(sk, cd))
            {
                return;
            }

            var hSkill = HiddenSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.IconName);

            if (hSkill != null)
            {
                return;
            }


            var skill = MainSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.IconName);

            if (skill != null)
            {
                skill.Refresh(sk.Id, cd, CooldownMode.Normal);
                return;
            }
            skill = SecondarySkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.IconName);
            if (skill != null)
            {
                skill.Refresh(sk.Id, cd, CooldownMode.Normal);
                return;
            }
            try
            {
                var otherSkill = OtherSkills.ToSyncList().FirstOrDefault(x => x.Skill.Name == sk.Name); //TODO: shouldn't this check on IconName???
                //OtherSkills.Remove(otherSkill);
                otherSkill?.Refresh(sk.Id, cd, CooldownMode.Normal);
            }
            catch
            {
                // ignored
            }
        }
示例#12
0
        private void FixedMode_Change(Skill sk, uint cd)
        {
            if (!Settings.CooldownWindowSettings.Enabled)
            {
                return;
            }
            if (Settings.ClassWindowSettings.Enabled && ClassManager.ChangeSpecialSkill(sk, cd))
            {
                return;
            }

            var hSkill = HiddenSkills.ToSyncArray().FirstOrDefault(x => x.IconName == sk.IconName);

            if (hSkill != null)
            {
                return;
            }


            var skill = MainSkills.ToSyncArray().FirstOrDefault(x => x.Skill.IconName == sk.IconName);

            if (skill != null)
            {
                skill.Refresh(cd);
                return;
            }
            skill = SecondarySkills.ToSyncArray().FirstOrDefault(x => x.Skill.IconName == sk.IconName);
            if (skill != null)
            {
                skill.Refresh(cd);
                return;
            }
            try
            {
                var otherSkill = OtherSkills.ToSyncArray().FirstOrDefault(x => x.Skill.Name == sk.Name);
                //OtherSkills.Remove(otherSkill);
                otherSkill?.Refresh(cd);
            }
            catch
            {
                // ignored
            }
        }
        private bool FixedMode_Update(Cooldown sk)
        {
            if (SettingsHolder.ClassWindowSettings.Enabled && ClassManager.StartSpecialSkill(sk))
            {
                return(false);
            }

            if (!SettingsHolder.CooldownWindowSettings.Enabled)
            {
                return(false);
            }

            var hSkill = HiddenSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.Skill.IconName);

            if (hSkill != null)
            {
                return(false);
            }

            var skill = MainSkills.FirstOrDefault(x => x.Skill.IconName == sk.Skill.IconName);

            if (skill != null)
            {
                if (skill.Duration == sk.Duration && !skill.IsAvailable && sk.Mode == skill.Mode)
                {
                    return(false);
                }
                skill.Start(sk);
                return(true);
            }
            skill = SecondarySkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == sk.Skill.IconName);
            if (skill != null)
            {
                if (skill.Duration == sk.Duration && !skill.IsAvailable && sk.Mode == skill.Mode)
                {
                    return(false);
                }
                skill.Start(sk);
                return(true);
            }
            return(UpdateOther(sk));
        }
        public void ClearSkills()
        {
            Dispatcher.BeginInvoke(new Action(() =>
            {
                ShortSkills.ToList().ForEach(sk => sk.Dispose());
                LongSkills.ToList().ForEach(sk => sk.Dispose());
                MainSkills.ToList().ForEach(sk => sk.Dispose());
                SecondarySkills.ToList().ForEach(sk => sk.Dispose());
                OtherSkills.ToList().ForEach(sk => sk.Dispose());
                ItemSkills.ToList().ForEach(sk => sk.Dispose());

                ShortSkills.Clear();
                LongSkills.Clear();
                MainSkills.Clear();
                SecondarySkills.Clear();
                OtherSkills.Clear();
                ItemSkills.Clear();
                HiddenSkills.Clear();
            }));
        }
 public void ResetSkill(Skill skill)
 {
     if (!SettingsHolder.CooldownWindowSettings.Enabled)
     {
         return;
     }
     if (SettingsHolder.CooldownBarMode == CooldownBarMode.Normal)
     {
         return;
     }
     Dispatcher.BeginInvoke(new Action(() =>
     {
         if (ClassManager.ResetSpecialSkill(skill))
         {
             return;
         }
         var sk = MainSkills.FirstOrDefault(x => x.Skill.IconName == skill.IconName) ?? SecondarySkills.FirstOrDefault(x => x.Skill.IconName == skill.IconName);
         sk?.ProcReset();
     }));
 }
示例#16
0
        internal void Save()
        {
            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 =>
            {
                root.Add(new XElement("Skill", new XAttribute("id", sk.Id), new XAttribute("row", 3), new XAttribute("name", sk.ShortName)));
            });
            if (SessionManager.CurrentPlayer.Class > (Class)12)
            {
                return;
            }
            root.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "resources/config/skills", $"{Utils.ClassEnumToString(SessionManager.CurrentPlayer.Class).ToLower()}-skills.xml"));
        }
示例#17
0
 private void MainSkills_OnDrop(object sender, DragEventArgs e)
 {
     MainSkills.InvalidateArrange();
     MainSkills.InvalidateMeasure();
     MainSkills.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
 }
示例#18
0
 private void MainSkills_OnDrop(object sender, DragEventArgs e)
 {
     MainSkills.InvalidateArrange();
     RefreshMeasure(MainSkills);
 }