private void OnSkillUpdate(object obj, LuaEventArgs args) { if (_onSkillUpdateTimer.IsFinished) { try { lock (tradeSkillLocker) { UpdateMaterials(); // check if there was any tradeskills added or removed. WoWSkill[] skills = SupportedTradeSkills; bool changed = skills.Count(s => TradeSkillList.Count(l => l.SkillLine == (SkillLine)s.Id) == 1) != TradeSkillList.Count || skills.Length != TradeSkillList.Count; if (changed) { PBLog.Debug("A profession was added or removed. Reloading Tradeskills (OnSkillUpdateTimerCB)"); OnTradeSkillsLoaded += Professionbuddy_OnTradeSkillsLoaded; LoadTradeSkills(); } else { PBLog.Debug("Updated tradeskills from OnSkillUpdateTimerCB"); foreach (TradeSkill ts in TradeSkillList) { ts.PulseSkill(); } if (MainForm.IsValid) { MainForm.Instance.RefreshTradeSkillTabs(); MainForm.Instance.RefreshActionTree(typeof(CastSpellAction)); } } } } catch (Exception ex) { PBLog.Warn(ex.ToString()); } _onSkillUpdateTimer.Reset(); } }
private void OnSkillUpdateTimerCB() { Lua.Events.AttachEvent("SKILL_LINES_CHANGED", OnSkillUpdate); try { UpdateMaterials(); // check if there was any tradeskills added or removed. WoWSkill[] skills = SupportedTradeSkills; bool changed = skills. Count(s => TradeSkillList.Count(l => l.SkillLine == (SkillLine)s.Id) == 1) != TradeSkillList.Count || skills.Length != TradeSkillList.Count; if (changed) { Debug("A profession was added or removed. Reloading Tradeskills (OnSkillUpdateTimerCB)"); OnTradeSkillsLoaded += Professionbuddy_OnTradeSkillsLoaded; LoadTradeSkills(); } else { Debug("Updated tradeskills from OnSkillUpdateTimerCB"); foreach (TradeSkill ts in TradeSkillList) { ts.PulseSkill(); } if (MainForm.IsValid) { MainForm.Instance.RefreshTradeSkillTabs(); MainForm.Instance.RefreshActionTree(typeof(CastSpellAction)); } } } catch (Exception ex) { Err(ex.ToString()); } }