Beispiel #1
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();
            });
        }
 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"));
     }));
 }
        private bool NormalMode_Update(Cooldown sk)
        {
            if (SettingsHolder.ClassWindowSettings.Enabled && ClassManager.StartSpecialSkill(sk))
            {
                return(false);
            }
            if (!SettingsHolder.CooldownWindowSettings.Enabled)
            {
                return(false);
            }

            var other = new Cooldown(sk.Skill, sk.CooldownType == CooldownType.Item ? sk.OriginalDuration / 1000 : sk.OriginalDuration, sk.CooldownType, sk.Mode, Dispatcher);

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

            if (hSkill != null)
            {
                return(false);
            }
            if (other.CooldownType == CooldownType.Item)
            {
                return(FindAndUpdate(ItemSkills, other));
            }

            try
            {
                if (other.Duration < SkillManager.LongSkillTreshold)
                {
                    return(FindAndUpdate(ShortSkills, other));
                }
                else
                {
                    var existing = LongSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == other.Skill.IconName);
                    if (existing == null)
                    {
                        existing = ShortSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == other.Skill.IconName);
                        if (existing == null)
                        {
                            LongSkills.Add(other);
                        }
                        else
                        {
                            existing.Refresh(other);
                        }

                        return(true);
                    }
                    else
                    {
                        existing.Refresh(other);
                    }
                    return(true);
                }
            }
            catch
            {
                Log.All($"[NormalMode_Update] Error in skill: {sk.Skill.Name}");
                return(false);
            }
        }
        public void RemoveHiddenSkill(Cooldown skill)
        {
            var target = HiddenSkills.ToSyncList().FirstOrDefault(x => x.Skill.IconName == skill.Skill.IconName);

            if (target != null)
            {
                HiddenSkills.Remove(target);
            }
        }
        private bool NormalMode_Update(Cooldown sk)
        {
            if (Settings.SettingsHolder.ClassWindowSettings.Enabled && ClassManager.StartSpecialSkill(sk))
            {
                return(false);
            }
            if (!Settings.SettingsHolder.CooldownWindowSettings.Enabled)
            {
                return(false);
            }
            var hSkill = HiddenSkills.ToSyncArray().FirstOrDefault(x => x.Skill.IconName == sk.Skill.IconName);

            if (hSkill != null)
            {
                return(false);
            }
            if (sk.CooldownType == CooldownType.Item)
            {
                return(FindAndUpdate(ItemSkills, sk));
            }

            try
            {
                if (sk.Duration < SkillManager.LongSkillTreshold)
                {
                    return(FindAndUpdate(ShortSkills, sk));
                }
                else
                {
                    var existing = LongSkills.ToSyncArray().FirstOrDefault(x => x.Skill.Name == sk.Skill.Name);
                    if (existing == null)
                    {
                        existing = ShortSkills.ToSyncArray().FirstOrDefault(x => x.Skill.Name == sk.Skill.Name);
                        if (existing == null)
                        {
                            LongSkills.Add(sk);
                        }
                        else
                        {
                            existing.Refresh(sk);
                        }

                        return(true);
                    }
                    else
                    {
                        existing.Refresh(sk);
                    }
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Beispiel #6
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();
            //});
        }
Beispiel #8
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);
        }
        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_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
            }
        }
Beispiel #11
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();
            }));
        }
Beispiel #14
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"));
        }
 internal void AddHiddenSkill(Cooldown context)
 {
     context.Dispose();
     HiddenSkills.Add(context);
     Save();
 }
Beispiel #16
0
 internal void AddHiddenSkill(FixedSkillCooldown context)
 {
     HiddenSkills.Add(context.Skill);
 }