diff --git a/modules/corelib/table.lua b/modules/corelib/table.lua index 02a1f8aa..4b9cf4f2 100644 --- a/modules/corelib/table.lua +++ b/modules/corelib/table.lua @@ -182,3 +182,14 @@ function table.collect(t, func) return res end +function table.equals(t, comp) + local equals = false + if type(t) == "table" and type(comp) == "table" then + for k,v in pairs(t) do + if v == comp[k] then + equals = true + end + end + end + return equals +end \ No newline at end of file diff --git a/modules/corelib/ui/uicombobox.lua b/modules/corelib/ui/uicombobox.lua index 47154e0b..37d92a76 100644 --- a/modules/corelib/ui/uicombobox.lua +++ b/modules/corelib/ui/uicombobox.lua @@ -28,25 +28,29 @@ function UIComboBox:getOption(text) end end -function UIComboBox:setCurrentOption(text) +function UIComboBox:setCurrentOption(text, dontSignal) if not self.options then return end for i,v in ipairs(self.options) do if v.text == text and self.currentIndex ~= i then self.currentIndex = i self:setText(text) - signalcall(self.onOptionChange, self, text, v.data) + if not dontSignal then + signalcall(self.onOptionChange, self, text, v.data) + end return end end end -function UIComboBox:setCurrentOptionByData(data) +function UIComboBox:setCurrentOptionByData(data, dontSignal) if not self.options then return end for i,v in ipairs(self.options) do if v.data == data and self.currentIndex ~= i then self.currentIndex = i self:setText(v.text) - signalcall(self.onOptionChange, self, v.text, v.data) + if not dontSignal then + signalcall(self.onOptionChange, self, v.text, v.data) + end return end end diff --git a/modules/gamelib/spells.lua b/modules/gamelib/spells.lua index 223ff32e..2eff68c0 100644 --- a/modules/gamelib/spells.lua +++ b/modules/gamelib/spells.lua @@ -141,7 +141,7 @@ SpellInfo = { ['Stone Shower'] = {id = 116, words = 'adori mas tera', exhaustion = 2000, premium = false, type = 'Conjure', icon = 'stoneshower', mana = 430, level = 28, soul = 3, group = {[3] = 2000}, vocations = {2, 6}}, ['Thunderstorm'] = {id = 117, words = 'adori mas vis', exhaustion = 2000, premium = false, type = 'Conjure', icon = 'thunderstorm', mana = 430, level = 28, soul = 3, group = {[3] = 2000}, vocations = {1, 5}}, ['Holy Missile'] = {id = 130, words = 'adori san', exhaustion = 2000, premium = false, type = 'Conjure', icon = 'holymissile', mana = 350, level = 27, soul = 3, group = {[3] = 2000}, vocations = {3, 7}} - }, + }--[[, ['Sample'] = { ['Wind Walk'] = {id = 1, words = 'windwalk', description = 'Run at enormous speed.', exhaustion = 2000, premium = false, type = 'Instant', icon = 1, mana = 50, level = 10, soul = 0, group = {[3] = 2000}, vocations = {1, 2}}, @@ -149,7 +149,7 @@ SpellInfo = { ['Moonglaives'] = {id = 3, words = 'moonglaives', description = 'Throw moonglaives around you.', exhaustion = 2000, premium = false, type = 'Instant', icon = 3, mana = 90, level = 55, soul = 0, group = {[1] = 2000}, vocations = {3, 7}}, ['Critical Strike'] = {id = 4, words = 'criticalstrike', description = 'Land a critical strike.', exhaustion = 2000, premium = false, type = 'Instant', icon = 4, mana = 350, level = 27, soul = 0, group = {[1] = 2000}, vocations = {3, 4, 7, 8}}, ['Firefly'] = {id = 5, words = 'firefly', description = 'Summon a angry firefly', exhaustion = 2000, premium = false, type = 'Instant', icon = 5, mana = 350, level = 27, soul = 0, group = {[1] = 2000}, vocations = {1, 2, 5, 6}} - } + }]] } -- ['const_name'] = {client_id, TFS_id} @@ -402,6 +402,37 @@ function Spells.getSpellProfileByName(spellName) return nil end +function Spells.getSpellsByVocationId(vocId) + local spells = {} + for profile,data in pairs(SpellInfo) do + for k,spell in pairs(data) do + if table.contains(spell.vocations, vocId) then + table.insert(spells, spell) + end + end + end + return spells +end + +function Spells.filterSpellsByGroups(spells, groups) + local filtered = {} + for v,spell in pairs(spells) do + local spellGroups = Spells.getGroupIds(spell) + if table.equals(spellGroups, groups) then + table.insert(filtered, spell) + end + end + return filtered +end + +function Spells.getGroupIds(spell) + local groups = {} + for k,_ in pairs(spell.group) do + table.insert(groups, k) + end + return groups +end + function Spells.getImageClip(id, profile) return (((id-1)%12)*SpelllistSettings[profile].iconSize.width) .. ' ' .. ((math.ceil(id/12)-1)*SpelllistSettings[profile].iconSize.height) .. ' '