More fixes

This commit is contained in:
Tercio Jose
2023-05-05 21:32:42 -03:00
parent b369f51e30
commit 0a4c35b304
8 changed files with 232 additions and 246 deletions
+5
View File
@@ -309,6 +309,9 @@
---@field RegisterEvent fun(self: detailseventlistener, event: "DETAILS_INSTANCE_OPEN"|"DETAILS_INSTANCE_CLOSE"|"DETAILS_INSTANCE_SIZECHANGED"|"DETAILS_INSTANCE_STARTRESIZE"|"DETAILS_INSTANCE_ENDRESIZE"|"DETAILS_INSTANCE_STARTSTRETCH"|"DETAILS_INSTANCE_ENDSTRETCH"|"DETAILS_INSTANCE_CHANGESEGMENT"|"DETAILS_INSTANCE_CHANGEATTRIBUTE"|"DETAILS_INSTANCE_CHANGEMODE"|"DETAILS_INSTANCE_NEWROW"|"DETAILS_OPTIONS_MODIFIED"|"DETAILS_DATA_RESET"|"DETAILS_DATA_SEGMENTREMOVED"|"COMBAT_ENCOUNTER_START"|"COMBAT_ENCOUNTER_END"|"COMBAT_PLAYER_ENTER"|"COMBAT_PLAYER_LEAVE"|"COMBAT_PLAYER_TIMESTARTED"|"COMBAT_BOSS_WIPE"|"COMBAT_BOSS_DEFEATED"|"COMBAT_BOSS_FOUND"|"COMBAT_INVALID"|"COMBAT_PREPOTION_UPDATED"|"COMBAT_CHARTTABLES_CREATING"|"COMBAT_CHARTTABLES_CREATED"|"COMBAT_ENCOUNTER_PHASE_CHANGED"|"COMBAT_ARENA_START"|"COMBAT_ARENA_END"|"COMBAT_MYTHICDUNGEON_START"|"COMBAT_MYTHICDUNGEON_END"|"GROUP_ONENTER"|"GROUP_ONLEAVE"|"ZONE_TYPE_CHANGED"|"REALM_CHANNEL_ENTER"|"REALM_CHANNEL_LEAVE"|"COMM_EVENT_RECEIVED"|"COMM_EVENT_SENT"|"UNIT_SPEC"|"UNIT_TALENTS"|"PLAYER_TARGET"|"DETAILS_PROFILE_APPLYED", callback: function)
---@field UnregisterEvent fun(self: detailseventlistener, event: "DETAILS_INSTANCE_OPEN"|"DETAILS_INSTANCE_CLOSE"|"DETAILS_INSTANCE_SIZECHANGED"|"DETAILS_INSTANCE_STARTRESIZE"|"DETAILS_INSTANCE_ENDRESIZE"|"DETAILS_INSTANCE_STARTSTRETCH"|"DETAILS_INSTANCE_ENDSTRETCH"|"DETAILS_INSTANCE_CHANGESEGMENT"|"DETAILS_INSTANCE_CHANGEATTRIBUTE"|"DETAILS_INSTANCE_CHANGEMODE"|"DETAILS_INSTANCE_NEWROW"|"DETAILS_OPTIONS_MODIFIED"|"DETAILS_DATA_RESET"|"DETAILS_DATA_SEGMENTREMOVED"|"COMBAT_ENCOUNTER_START"|"COMBAT_ENCOUNTER_END"|"COMBAT_PLAYER_ENTER"|"COMBAT_PLAYER_LEAVE"|"COMBAT_PLAYER_TIMESTARTED"|"COMBAT_BOSS_WIPE"|"COMBAT_BOSS_DEFEATED"|"COMBAT_BOSS_FOUND"|"COMBAT_INVALID"|"COMBAT_PREPOTION_UPDATED"|"COMBAT_CHARTTABLES_CREATING"|"COMBAT_CHARTTABLES_CREATED"|"COMBAT_ENCOUNTER_PHASE_CHANGED"|"COMBAT_ARENA_START"|"COMBAT_ARENA_END"|"COMBAT_MYTHICDUNGEON_START"|"COMBAT_MYTHICDUNGEON_END"|"GROUP_ONENTER"|"GROUP_ONLEAVE"|"ZONE_TYPE_CHANGED"|"REALM_CHANNEL_ENTER"|"REALM_CHANNEL_LEAVE"|"COMM_EVENT_RECEIVED"|"COMM_EVENT_SENT"|"UNIT_SPEC"|"UNIT_TALENTS"|"PLAYER_TARGET"|"DETAILS_PROFILE_APPLYED")
---@class savedspelldata : {key1: number, key2: string, key3: number}
---@class alternatepowertable : {last: number, total: number}
---@class combat : table
---@field amountCasts {[string]: table<string, number>}
---@field end_time number
@@ -317,6 +320,7 @@
---@field is_mythic_dungeon_run_id number
---@field is_mythic_dungeon_segment boolean
---@field trinketProcs table<actorname, table<spellid, {cooldown: number, total: number}>>
---@field alternate_power table<actorname, alternatepowertable>
---@field GetCombatTime fun(combat) : number
---@field GetDeaths fun(combat) : table --get the table which contains the deaths of the combat
---@field GetStartTime fun(combat: combat) : number
@@ -330,6 +334,7 @@
---@field GetSpellCastTable fun(combat: combat, actorName: string|nil) : table
---@field GetSpellUptime fun(combat: combat, actorName: string, spellId: number, auraType: string|nil) : number get the uptime of a buff or debuff
---@field GetActor fun(combat: combat, attribute: number, playerName: string) : actor
---@field CreateAlternatePowerTable fun(combat: combat, actorName: string) : alternatepowertable
---@class actorcontainer : table
---@field _ActorTable table
+9 -8
View File
@@ -385,18 +385,19 @@ local canRunCallbackFunctionForOption = function(canRunCallback, optionTable, dr
end
end
--if onlyShown is true it'll first create a table with visible options that has .shown and then select in this table the index passed (if byOptionNumber)
--@optionName: value or string shown in the name of the option
--@byOptionNumber: the option name is considered a number and selects the index of the menu
--@onlyShown: the selected option index when selecting by option number must be visible
--@runCallback: run the callback (onclick) function after selecting the option
function DropDownMetaFunctions:Select(optionName, byOptionNumber, onlyShown, runCallback)
---if bOnlyShown is true it'll first create a table with visible options that has .shown and then select in this table the index passed (if byOptionNumber)
---@param optionName string value or string shown in the name of the option
---@param byOptionNumber number the option name is considered a number and selects the index of the menu
---@param bOnlyShown boolean the selected option index when selecting by option number must be visible
---@param runCallback function run the callback (onclick) function after selecting the option
---@return boolean
function DropDownMetaFunctions:Select(optionName, byOptionNumber, bOnlyShown, runCallback)
if (type(optionName) == "boolean" and not optionName) then
self:NoOptionSelected()
return false
end
local optionsTable = DF:Dispatch(self.func, self)
local optionsTable = DF:Dispatch(self.func, self) --399
if (#optionsTable == 0) then
self:NoOption(true)
@@ -408,7 +409,7 @@ function DropDownMetaFunctions:Select(optionName, byOptionNumber, onlyShown, run
if (byOptionNumber and type(optionName) == "number") then
local optionIndex = optionName
if (onlyShown) then
if (bOnlyShown) then
local onlyShownOptions = {}
for i = 1, #optionsTable do
+1 -1
View File
@@ -1,6 +1,6 @@
local dversion = 424
local dversion = 425
local major, minor = "DetailsFramework-1.0", dversion
local DF, oldminor = LibStub:NewLibrary(major, minor)
+9 -1
View File
@@ -1603,12 +1603,20 @@ function DF.Language.CreateLanguageSelector(addonId, parent, callback, selectedL
end)
end
---build a table with the all languageIDs registered to show as options in the dropdown
---@return table
local buildOptionsFunc = function()
---@type {value: string, label: string, onclick: function, font: string}
local resultTable = {}
for languageId in pairs(allLanguagesRegistered) do
local languageIdInfo = languagesAvailable[languageId]
resultTable[#resultTable+1] = {value = languageId, label = languageIdInfo.text, onclick = onSelectLanguage, font = languageIdInfo.font}
if (not languageIdInfo) then
--for debug
print("DetailsFramework: languageId is registered but has no languageInfo:", languageId)
else
resultTable[#resultTable+1] = {value = languageId, label = languageIdInfo.text, onclick = onSelectLanguage, font = languageIdInfo.font}
end
end
return resultTable
+35 -10
View File
@@ -452,10 +452,14 @@
return 0
end
function classCombat:CreateAlternatePowerTable (actorName)
local t = {last = 0, total = 0}
self.alternate_power [actorName] = t
return t
---create an alternate power table for the given actor
---@param actorName string
---@return alternatepowertable
function classCombat:CreateAlternatePowerTable(actorName)
---@type alternatepowertable
local alternatePowerTable = {last = 0, total = 0}
self.alternate_power[actorName] = alternatePowerTable
return alternatePowerTable
end
--delete an actor from the combat ~delete ~erase ~remove
@@ -855,8 +859,11 @@
end
---add combat2 data into combat1
---@param combate1 combat
---@param combate2 combat
---@return combat
classCombat.__add = function(combate1, combate2)
local all_containers = {combate2 [class_type_dano]._ActorTable, combate2 [class_type_cura]._ActorTable, combate2 [class_type_e_energy]._ActorTable, combate2 [class_type_misc]._ActorTable}
local custom_combat
if (combate1 ~= Details.tabela_overall) then
@@ -886,12 +893,30 @@
--alternate power
local overallPowerTable = combate1.alternate_power
for actorName, powerTable in pairs(combate2.alternate_power) do
local power = overallPowerTable [actorName]
if (not power) then
power = combate1:CreateAlternatePowerTable (actorName)
local alternatePowerTable = overallPowerTable[actorName]
if (not alternatePowerTable) then
alternatePowerTable = combate1:CreateAlternatePowerTable(actorName)
end
alternatePowerTable.total = alternatePowerTable.total + powerTable.total
combate2.alternate_power[actorName].last = 0
end
--cast amount
local combat1CastData = combate1.amountCasts
for actorName, castData in pairs(combate2.amountCasts) do
local playerCastTable = combat1CastData[actorName]
if (not playerCastTable) then
playerCastTable = {}
combat1CastData[actorName] = playerCastTable
end
for spellName, amountOfCasts in pairs(castData) do
local spellAmount = playerCastTable[spellName]
if (not spellAmount) then
spellAmount = 0
playerCastTable[spellName] = spellAmount
end
playerCastTable[spellName] = spellAmount + amountOfCasts
end
power.total = power.total + powerTable.total
combate2.alternate_power [actorName].last = 0
end
return combate1
+15 -9
View File
@@ -3689,6 +3689,7 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
sourceName = "[*] " .. spellName
end
---@type actor, actor
local sourceActor, ownerActor = misc_cache[sourceSerial] or misc_cache_pets[sourceSerial] or misc_cache[sourceName], misc_cache_petsOwners[sourceSerial]
if (not sourceActor) then
sourceActor, ownerActor, sourceName = _current_misc_container:PegarCombatente (sourceSerial, sourceName, sourceFlags, true)
@@ -3719,6 +3720,10 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
amountOfCasts = amountOfCasts + 1
_current_combat.amountCasts[sourceName][spellName] = amountOfCasts
--if (sourceSerial == UnitGUID("player")) then
-- print(sourceName, spellName, amountOfCasts)
--end
------------------------------------------------------------------------------------------------
--record cooldowns cast which can't track with buff applyed
--a player is the caster
@@ -3741,18 +3746,20 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
--enemy successful casts (not interrupted)
if (bitBand(sourceFlags, 0x00000040) ~= 0 and sourceName) then --byte 2 = 4 (enemy)
--damager
local este_jogador = damage_cache [sourceSerial]
if (not este_jogador) then
este_jogador = _current_damage_container:PegarCombatente (sourceSerial, sourceName, sourceFlags, true)
---@type actor
local enemyActorObject = damage_cache[sourceSerial]
if (not enemyActorObject) then
enemyActorObject = _current_damage_container:PegarCombatente(sourceSerial, sourceName, sourceFlags, true)
end
if (este_jogador) then
if (enemyActorObject) then
--actor spells table
local spell = este_jogador.spells._ActorTable [spellId] --line where the actor was nil
if (not spell) then
spell = este_jogador.spells:PegaHabilidade (spellId, true, token)
---@type spelltable
local spellTable = enemyActorObject.spells._ActorTable[spellId]
if (not spellTable) then
spellTable = enemyActorObject.spells:PegaHabilidade(spellId, true, token)
end
spell.successful_casted = spell.successful_casted + 1
spellTable.successful_casted = spellTable.successful_casted + 1
end
--add the spellId in the enemy_cast_cache table to store the time the enemy successfully cast a spell
@@ -3765,7 +3772,6 @@ local SPELL_POWER_PAIN = SPELL_POWER_PAIN or (PowerEnum and PowerEnum.Pain) or 1
enemy_cast_cache[time][3] = enemy_cast_cache[time][3] + 1
end
end
return
end
end
+153 -217
View File
@@ -1,37 +1,36 @@
--[[ Spell Cache store all spells shown on frames and make able to change spells name, icons, etc... ]]
do
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--On The Fly SpellCache
local Details = _G.Details
local Loc = LibStub("AceLocale-3.0"):GetLocale ( "Details" )
local addonName, Details222 = ...
local _
local rawget = rawget
local rawset = rawset
local setmetatable = setmetatable
local _GetSpellInfo = GetSpellInfo
local _unpack = unpack
local rawget = rawget
local rawset = rawset
local setmetatable = setmetatable
local GetSpellInfo = GetSpellInfo
local unpack = unpack
local tinsert = tinsert
local tremove = tremove
local C_Timer = C_Timer
--is this a timewalking exp?
local is_classic_exp = DetailsFramework.IsClassicWow()
local bIsClassicWow = DetailsFramework.IsClassicWow()
--default container
Details.spellcache = {}
local unknowSpell = {Loc ["STRING_UNKNOWSPELL"], _, "Interface\\Icons\\Ability_Druid_Eclipse"} --localize-me
--default spell cache container
Details.spellcache = {}
local unknowSpell = {Loc ["STRING_UNKNOWSPELL"], _, "Interface\\Icons\\Ability_Druid_Eclipse"}
local AllSpellNames
if (is_classic_exp) then
AllSpellNames = {}
local GetSpellInfo = GetSpellInfo
for i = 1, 60000 do
local name, _, icon = GetSpellInfo(i)
if name and icon and icon ~= 136235 and not AllSpellNames[name] then
AllSpellNames[name] = icon
local allSpellNames
--check if this is running in classic wow and build a cache with spell names poiting to their icons
if (bIsClassicWow) then
allSpellNames = {}
local maxSpellIdInClassic = 60000
for i = 1, maxSpellIdInClassic do
local spellName, _, spellIcon = GetSpellInfo(i)
if spellName and spellIcon and spellIcon ~= 136235 and not allSpellNames[spellName] then
allSpellNames[spellName] = spellIcon
end
end
end
@@ -56,60 +55,95 @@ do
end
if (not spellName) then
return spell, _, AllSpellNames [spell] or defaultSpellIcon
return spell, _, (allSpellNames[spell] or [[Interface\ICONS\INV_Sword_04]])
end
return spellName, _, AllSpellNames [spell] or spellIcon
return spellName, _, (allSpellNames[spell] or spellIcon)
end
--reset spell cache
--reset spell cache, called from the loaddata.lua and when the segments container get cleared
function Details:ClearSpellCache()
Details.spellcache = setmetatable({},
{__index = function(tabela, valor)
local esta_magia = rawget (tabela, valor)
if (esta_magia) then
return esta_magia
end
--should save only icon and name, other values are not used
if (valor) then --check if spell is valid before
local cache
if (is_classic_exp) then
cache = {GetSpellInfoClassic(valor)}
else
cache = {_GetSpellInfo(valor)}
{__index = function(spellCache, key)
if (key) then
do
--check if the spell is already in the cache, if so, return it
local spellInfo = rawget(spellCache, key)
if (spellInfo) then
return spellInfo
end
tabela [valor] = cache
return cache
else
return unknowSpell
end
end})
local spellInfo
if (bIsClassicWow) then
spellInfo = {GetSpellInfoClassic(key)}
else
spellInfo = {GetSpellInfo(key)}
end
--default overwrites
--rawset (_detalhes.spellcache, 1, {Loc ["STRING_MELEE"], 1, "Interface\\AddOns\\Details\\images\\melee.tga"})
--rawset (_detalhes.spellcache, 2, {Loc ["STRING_AUTOSHOT"], 1, "Interface\\AddOns\\Details\\images\\autoshot.tga"})
spellCache[key] = spellInfo
return spellInfo
else
return unknowSpell
end
end}
)
--built-in overwrites
for spellId, spellTable in pairs(Details.SpellOverwrite) do
local name, _, icon = _GetSpellInfo(spellId)
rawset (Details.spellcache, spellId, {spellTable.name or name, 1, spellTable.icon or icon})
local spellName, _, spellIcon = GetSpellInfo(spellId)
rawset(Details.spellcache, spellId, {spellTable.name or spellName, 1, spellTable.icon or spellIcon})
end
--user overwrites
-- [1] spellid [2] spellname [3] spellicon
for index, spellTable in ipairs(Details.savedCustomSpells) do
rawset (Details.spellcache, spellTable [1], {spellTable [2], 1, spellTable [3]})
rawset(Details.spellcache, spellTable[1], {spellTable[2], 1, spellTable[3]})
end
end
local lightOfTheMartyr_Name, _, lightOfTheMartyr_Icon = _GetSpellInfo(196917)
local lightOfTheMartyr_Name, _, lightOfTheMartyr_Icon = GetSpellInfo(196917)
lightOfTheMartyr_Name = lightOfTheMartyr_Name or "Deprecated Spell - Light of the Martyr"
lightOfTheMartyr_Icon = lightOfTheMartyr_Icon or ""
local defaultSpellCustomization = {}
local itemData_Retail = {
[394453] = {itemId = 195480, isPassive = true}, --ring: Seal of Diurna's Chosen
[382135] = {itemId = 194308}, --trinket: Manic Grieftorch
[382058] = {itemId = 194299}, --trinket: Decoration of Flame (shield)
[382056] = {itemId = 194299}, --trinket: Decoration of Flame
[382090] = {itemId = 194302}, --trinket: Storm-Eater's Boon
[381967] = {itemId = 194305}, --trinket: Controlled Current Technique
[382426] = {itemId = 194309, isPassive = true}, --trinket: Spiteful Storm
[377455] = {itemId = 194304}, --trinket: Iceblood Deathsnare
[377451] = {itemId = 194300}, --trinket: Conjured Chillglobe
[382097] = {itemId = 194303}, --trinket: Rumbling Ruby
[385903] = {itemId = 193639, isPassive = true}, --trinket: Umbrelskul's Fractured Heart
[381475] = {itemId = 193769}, --trinket: Erupting Spear Fragment
[388739] = {itemId = 193660, isPassive = true}, --trinket: Idol of Pure Decay
[388855] = {itemId = 193678}, --trinket: Miniature Singing Stone
[388755] = {itemId = 193677, isPassive = true}, --trinket: Furious Ragefeather
[383934] = {itemId = 193736}, --trinket: Water's Beating Heart
[214052] = {itemId = 133641, isPassive = true}, --trinket: Eye of Skovald
[214200] = {itemId = 133646}, --trinket: Mote of Sanctification
[387036] = {itemId = 193748}, --trinket: Kyrakka's Searing Embers (heal)
[397376] = {itemId = 193748, isPassive = true}, --trinket: Kyrakka's Searing Embers (damage)
[214985] = {itemId = 137486}, --trinket: Windscar Whetstone
[384004] = {itemId = 193815}, --trinket: Homeland Raid Horn
[377459] = {itemId = 194306}, --trinket: All-Totem of the Master
[408815] = {itemId = 202569}, --weapon: Djaruun, Pillar of the Elder Flame
[407961] = {itemId = 203996, isPassive = true}, --trinket: Igneous Flowstone
[408682] = {itemId = 202610}, --trinket: Dragonfire Bomb Dispenser
[401324] = {itemId = 202617, isPassive = true}, --trinket: Elementium Pocket Anvil
[401306] = {itemId = 202617}, --trinket: Elementium Pocket Anvil (use)
[402583] = {itemId = 203963}, --trinket: Beacon to the Beyond
[384325] = {itemId = 193672, isPassive = true}, --trinket: Frenzying Signoll Flare
[384290] = {itemId = 193672, isPassive = true}, --trinket: Frenzying Signoll Flare (dot)
[388948] = {itemId = 193732}, --trinket: Globe of Jagged Ice
[381760] = {itemId = 193786, isPassive = true}, --trinket: Mutated Magmammoth Scale (melee)
}
if (DetailsFramework.IsClassicWow()) then
defaultSpellCustomization = {
[1] = {name = Loc ["STRING_MELEE"], icon = [[Interface\ICONS\INV_Sword_04]]},
@@ -183,7 +217,6 @@ do
[277185] = {name = GetSpellInfo(277185) .. " (Trinket)"}, --[Dread Gladiator's Badge]
[278057] = {name = GetSpellInfo(278057) .. " (Trinket)"}, --[Vigilant's Bloodshaper]
}
else
--retail
local iconSize = 14 --icon size
@@ -197,6 +230,10 @@ do
local itemIcon = C_Item.GetItemIconByID(itemId)
local itemName = C_Item.GetItemNameByID(itemId)
if (itemName == "") then
itemName = "@notloaded@"
end
if (itemIcon and itemName) then
result = "" .. CreateTextureMarkup(itemIcon, iconSize, iconSize, iconSize, iconSize, unpack(coords)) .. " " .. itemName .. ""
end
@@ -216,14 +253,12 @@ do
[98021] = {name = Loc ["STRING_SPIRIT_LINK_TOTEM"]},
[108271] = {name = GetSpellInfo(108271), icon = "Interface\\Addons\\Details\\images\\icon_astral_shift"},
[196917] = {name = lightOfTheMartyr_Name .. " (" .. Loc ["STRING_DAMAGE"] .. ")", icon = lightOfTheMartyr_Icon},
[77535] = {name = GetSpellInfo(77535), icon = "Interface\\Addons\\Details\\images\\icon_blood_shield"},
}
if (GetSpellInfo(394453)) then
if (GetSpellInfo(394453)) then --this is running at load time, this data could not be available at player logon
local dragonflightTrinkets = {
[394453] = {name = formatTextForItem(195480), isPassive = true, itemId = 195480}, --ring: Seal of Diurna's Chosen
[382135] = {name = formatTextForItem(194308)}, --trinket: Manic Grieftorch
[382058] = {name = formatTextForItem(194299)}, --trinket: Decoration of Flame (shield)
[382056] = {name = formatTextForItem(194299)}, --trinket: Decoration of Flame
@@ -233,7 +268,6 @@ do
[377455] = {name = formatTextForItem(194304)}, --trinket: Iceblood Deathsnare
[377451] = {name = formatTextForItem(194300)}, --trinket: Conjured Chillglobe
[382097] = {name = formatTextForItem(194303)}, --trinket: Rumbling Ruby
[385903] = {name = formatTextForItem(193639), isPassive = true, itemId = 193639}, --trinket: Umbrelskul's Fractured Heart
[381475] = {name = formatTextForItem(193769)}, --trinket: Erupting Spear Fragment
[388739] = {name = formatTextForItem(193660), isPassive = true, itemId = 193660}, --trinket: Idol of Pure Decay
@@ -247,13 +281,6 @@ do
[214985] = {name = formatTextForItem(137486)}, --trinket: Windscar Whetstone
[384004] = {name = formatTextForItem(193815)}, --trinket: Homeland Raid Horn
[377459] = {name = formatTextForItem(194306)}, --trinket: All-Totem of the Master
--[] = {name = GetSpellInfo() .. formatTextForItem(193757), isPassive = true}, --trinket: Ruby Whelp Shell
--to check an item : /dump C_Item.GetItemNameByID(137486)
--get the itemId from default tooltip using /code > script name > "SpellID on Tooltip"
--spellId is from details breakdown
--/de trinket on the spell icon on the breakdown, trinket equipped
[408815] = {name = formatTextForItem(202569)}, --weapon: Djaruun, Pillar of the Elder Flame
[407961] = {name = formatTextForItem(203996), isPassive = true, itemId = 203996}, --trinket: Igneous Flowstone
[408682] = {name = formatTextForItem(202610)}, --trinket: Dragonfire Bomb Dispenser
@@ -266,6 +293,12 @@ do
[381760] = {name = formatTextForItem(193786), isPassive = true, itemId = 193786}, --trinket: Mutated Magmammoth Scale (melee)
}
--[] = {name = GetSpellInfo() .. formatTextForItem(193757), isPassive = true}, --trinket: Ruby Whelp Shell
--to check an item : /dump C_Item.GetItemNameByID(137486)
--get the itemId from default tooltip using /code > script name > "SpellID on Tooltip"
--spellId is from details breakdown
--/de trinket on the spell icon on the breakdown, trinket equipped
for spellId, spellCustomization in pairs(dragonflightTrinkets) do
defaultSpellCustomization[spellId] = spellCustomization
end
@@ -274,9 +307,9 @@ do
if (LIB_OPEN_RAID_SPELL_CUSTOM_NAMES) then
for spellId, customTable in pairs(LIB_OPEN_RAID_SPELL_CUSTOM_NAMES) do
local name = customTable.name
if (name) then
defaultSpellCustomization[spellId] = name
local customName = customTable.name
if (customName) then
defaultSpellCustomization[spellId] = customName
end
end
end
@@ -285,88 +318,88 @@ do
return defaultSpellCustomization
end
function Details:UserCustomSpellUpdate (index, name, icon)
local t = Details.savedCustomSpells[index]
if (t) then
t [2], t [3] = name or t [2], icon or t [3]
return rawset (Details.spellcache, t [1], {t [2], 1, t [3]})
function Details:UserCustomSpellUpdate(index, spellName, spellIcon)
---@type savedspelldata
local savedSpellData = Details.savedCustomSpells[index]
if (savedSpellData) then
savedSpellData[2], savedSpellData[3] = spellName or savedSpellData[2], spellIcon or savedSpellData[3]
return rawset (Details.spellcache, savedSpellData[1], {savedSpellData[2], 1, savedSpellData[3]})
else
return false
end
end
function Details:UserCustomSpellReset (index)
local t = Details.savedCustomSpells[index]
if (t) then
local spellid = t [1]
local name, _, icon = _GetSpellInfo(spellid)
function Details:UserCustomSpellReset(index)
---@type savedspelldata
local savedSpellData = Details.savedCustomSpells[index]
if (savedSpellData) then
local spellId = savedSpellData [1]
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (defaultSpellCustomization [spellid]) then
name = defaultSpellCustomization [spellid].name
icon = defaultSpellCustomization [spellid].icon or icon or [[Interface\InventoryItems\WoWUnknownItem01]]
if (defaultSpellCustomization[spellId]) then
spellName = defaultSpellCustomization[spellId].name
spellIcon = defaultSpellCustomization[spellId].icon or spellIcon or [[Interface\InventoryItems\WoWUnknownItem01]]
end
if (not name) then
name = "Unknown"
if (not spellName) then
spellName = "Unknown"
end
if (not icon) then
icon = [[Interface\InventoryItems\WoWUnknownItem01]]
if (not spellIcon) then
spellIcon = [[Interface\InventoryItems\WoWUnknownItem01]]
end
rawset (Details.spellcache, spellid, {name, 1, icon})
rawset(Details.spellcache, spellId, {spellName, 1, spellIcon})
t[2] = name
t[3] = icon
savedSpellData[2] = spellName
savedSpellData[3] = spellIcon
end
end
function Details:FillUserCustomSpells()
for spellid, spellTable in pairs(defaultSpellCustomization) do
local spellName, _, spellIcon = Details.GetSpellInfo(spellid)
Details:UserCustomSpellAdd(spellid, spellTable.name or spellName or "Unknown", spellTable.icon or spellIcon or [[Interface\InventoryItems\WoWUnknownItem01]])
for spellId, spellTable in pairs(defaultSpellCustomization) do
local spellName, _, spellIcon = Details.GetSpellInfo(spellId)
Details:UserCustomSpellAdd(spellId, spellTable.name or spellName or "Unknown", spellTable.icon or spellIcon or [[Interface\InventoryItems\WoWUnknownItem01]])
end
for i = #Details.savedCustomSpells, 1, -1 do
local spelltable = Details.savedCustomSpells [i]
local spellid = spelltable [1]
if (spellid > 10) then
local exists = _GetSpellInfo(spellid)
if (not exists) then
---@type savedspelldata
local savedSpellData = Details.savedCustomSpells[i]
local spellId = savedSpellData[1]
if (spellId > 10) then
local doesSpellExists = GetSpellInfo(spellId)
if (not doesSpellExists) then
tremove(Details.savedCustomSpells, i)
end
end
end
end
C_Timer.After(0, function()
Details:FillUserCustomSpells()
end)
function Details:UserCustomSpellAdd(spellid, name, icon)
function Details:UserCustomSpellAdd(spellId, spellName, spellIcon)
local isOverwrite = false
for index, spellTable in ipairs(Details.savedCustomSpells) do
if (spellTable[1] == spellid) then
spellTable[2] = name
spellTable[3] = icon
for index, savedSpellData in ipairs(Details.savedCustomSpells) do
if (savedSpellData[1] == spellId) then
savedSpellData[2] = spellName
savedSpellData[3] = spellIcon
isOverwrite = true
break
end
end
if (not isOverwrite) then
tinsert(Details.savedCustomSpells, {spellid, name, icon})
tinsert(Details.savedCustomSpells, {spellId, spellName, spellIcon})
end
return rawset(Details.spellcache, spellid, {name, 1, icon})
return rawset(Details.spellcache, spellId, {spellName, 1, spellIcon})
end
function Details:UserCustomSpellRemove (index)
local t = Details.savedCustomSpells [index]
if (t) then
local spellid = t [1]
local name, _, icon = _GetSpellInfo(spellid)
if (name) then
rawset (Details.spellcache, spellid, {name, 1, icon})
function Details:UserCustomSpellRemove(index)
---@type savedspelldata
local savedSpellData = Details.savedCustomSpells[index]
if (savedSpellData) then
local spellId = savedSpellData[1]
local spellName, _, spellIcon = GetSpellInfo(spellId)
if (spellName) then
rawset(Details.spellcache, spellId, {spellName, 1, spellIcon})
end
return tremove(Details.savedCustomSpells, index)
end
@@ -375,120 +408,23 @@ do
end
--overwrite for API GetSpellInfo function
Details.getspellinfo = function(spellid) return _unpack(Details.spellcache[spellid]) end
Details.getspellinfo = function(spellId)
return unpack(Details.spellcache[spellId])
end
Details.GetSpellInfo = Details.getspellinfo
--overwrite SpellInfo if the spell is a DoT, so Details.GetSpellInfo will return the name modified
function Details:SpellIsDot(spellid)
function Details:SpellIsDot(spellId)
--do nothing if this spell already has a customization
if (defaultSpellCustomization[spellid]) then
if (defaultSpellCustomization[spellId]) then
return
end
local spellName, rank, spellIcon = _GetSpellInfo(spellid)
local spellName, rank, spellIcon = GetSpellInfo(spellId)
if (spellName) then
rawset (Details.spellcache, spellid, {spellName .. Loc ["STRING_DOT"], rank, spellIcon})
rawset (Details.spellcache, spellId, {spellName .. Loc ["STRING_DOT"], rank, spellIcon})
else
rawset (Details.spellcache, spellid, {"Unknown DoT Spell? " .. Loc ["STRING_DOT"], rank, [[Interface\InventoryItems\WoWUnknownItem01]]})
rawset (Details.spellcache, spellId, {"Unknown DoT Spell? " .. Loc ["STRING_DOT"], rank, [[Interface\InventoryItems\WoWUnknownItem01]]})
end
end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--Cache All Spells
function Details:BuildSpellListSlow() -- this is not in use
local load_frame = _G.DetailsLoadSpellCache
if (load_frame and (load_frame.completed or load_frame.inprogress)) then
return false
end
local step = 1
local max = 160000
if (not load_frame) then
load_frame = CreateFrame("frame", "DetailsLoadSpellCache", UIParent)
load_frame:SetFrameStrata("DIALOG")
local progress_label = load_frame:CreateFontString("DetailsLoadSpellCacheProgress", "overlay", "GameFontHighlightSmall")
progress_label:SetText("Loading Spells: 0%")
function Details:BuildSpellListSlowTick()
progress_label:SetText("Loading Spells: " .. load_frame:GetProgress() .. "%")
end
load_frame.tick = Details:ScheduleRepeatingTimer ("BuildSpellListSlowTick", 1)
function load_frame:GetProgress()
return math.floor(step / max * 100)
end
end
local SpellCache = {a={}, b={}, c={}, d={}, e={}, f={}, g={}, h={}, i={}, j={}, k={}, l={}, m={}, n={}, o={}, p={}, q={}, r={}, s={}, t={}, u={}, v={}, w={}, x={}, y={}, z={}}
local _string_lower = string.lower
local _string_sub = string.sub
local blizzGetSpellInfo = GetSpellInfo
load_frame.inprogress = true
Details.spellcachefull = SpellCache
load_frame:SetScript("OnUpdate", function()
for spellid = step, step+500 do
local name, _, icon = blizzGetSpellInfo (spellid)
if (name) then
local LetterIndex = _string_lower (_string_sub (name, 1, 1)) --get the first letter
local CachedIndex = SpellCache [LetterIndex]
if (CachedIndex) then
CachedIndex [spellid] = {name, icon}
end
end
end
step = step + 500
if (step > max) then
step = max
_G.DetailsLoadSpellCache.completed = true
_G.DetailsLoadSpellCache.inprogress = false
Details:CancelTimer(_G.DetailsLoadSpellCache.tick)
DetailsLoadSpellCacheProgress:Hide()
load_frame:SetScript("OnUpdate", nil)
end
end)
return true
end
function Details:BuildSpellList()
local SpellCache = {a={}, b={}, c={}, d={}, e={}, f={}, g={}, h={}, i={}, j={}, k={}, l={}, m={}, n={}, o={}, p={}, q={}, r={}, s={}, t={}, u={}, v={}, w={}, x={}, y={}, z={}}
local _string_lower = string.lower
local _string_sub = string.sub
local blizzGetSpellInfo = GetSpellInfo
for spellid = 1, 160000 do
local name, rank, icon = blizzGetSpellInfo (spellid)
if (name) then
local index = _string_lower (_string_sub (name, 1, 1))
local CachedIndex = SpellCache [index]
if (CachedIndex) then
CachedIndex [spellid] = {name, icon, rank}
end
end
end
Details.spellcachefull = SpellCache
return true
end
function Details:ClearSpellList()
Details.spellcachefull = nil
collectgarbage()
end
end
end
+5
View File
@@ -374,6 +374,11 @@ function Details:StartMeUp()
Details:AddDefaultCustomDisplays()
end
C_Timer.After(1, function()
--load custom spells on every login
Details:FillUserCustomSpells()
end)
local lowerInstanceId = Details:GetLowerInstanceNumber()
if (lowerInstanceId) then
local instance = Details:GetInstance(lowerInstanceId)