initial commit
This commit is contained in:
30
Modules/DataTexts/Agility.lua
Normal file
30
Modules/DataTexts/Agility.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...))
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local UnitStat = UnitStat
|
||||
local ITEM_MOD_AGILITY_SHORT = ITEM_MOD_AGILITY_SHORT
|
||||
local LE_UNIT_STAT_AGILITY = LE_UNIT_STAT_AGILITY
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
if E.global.datatexts.settings.Agility.NoLabel then
|
||||
self.text:SetFormattedText(displayString, UnitStat('player', LE_UNIT_STAT_AGILITY))
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Agility.Label ~= '' and E.global.datatexts.settings.Agility.Label or ITEM_MOD_AGILITY_SHORT..': ', UnitStat('player', LE_UNIT_STAT_AGILITY))
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Agility.NoLabel and '' or '%s', hex, '%d|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Agility', STAT_CATEGORY_ATTRIBUTES, {'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE'}, OnEvent, nil, nil, nil, nil, ITEM_MOD_AGILITY_SHORT, nil, ValueColorUpdate)
|
||||
55
Modules/DataTexts/Armor.lua
Normal file
55
Modules/DataTexts/Armor.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local select = select
|
||||
local format = format
|
||||
local strjoin = strjoin
|
||||
local UnitLevel = UnitLevel
|
||||
local UnitArmor = UnitArmor
|
||||
local PaperDollFrame_GetArmorReduction = PaperDollFrame_GetArmorReduction
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
local ARMOR = ARMOR
|
||||
|
||||
local chanceString = '%.2f%%'
|
||||
local displayString, lastPanel, effectiveArmor = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
effectiveArmor = select(2, UnitArmor('player'))
|
||||
|
||||
if E.global.datatexts.settings.Armor.NoLabel then
|
||||
self.text:SetFormattedText(displayString, effectiveArmor)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Armor.Label ~= '' and E.global.datatexts.settings.Armor.Label or ARMOR..': ', effectiveArmor)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
DT.tooltip:AddLine(L["Mitigation By Level: "])
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
local playerlvl = E.mylevel + 3
|
||||
for _ = 1, 4 do
|
||||
local armorReduction = PaperDollFrame_GetArmorReduction(effectiveArmor, playerlvl)
|
||||
DT.tooltip:AddDoubleLine(playerlvl,format(chanceString, armorReduction),1,1,1)
|
||||
playerlvl = playerlvl - 1
|
||||
end
|
||||
local lv = UnitLevel('target')
|
||||
if lv and lv > 0 and (lv > playerlvl + 3 or lv < playerlvl) then
|
||||
local armorReduction = PaperDollFrame_GetArmorReduction(effectiveArmor, lv)
|
||||
DT.tooltip:AddDoubleLine(lv, format(chanceString, armorReduction),1,1,1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Armor.NoLabel and '' or '%s', hex, '%d|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Armor', STAT_CATEGORY_ATTRIBUTES, {'UNIT_STATS', 'UNIT_RESISTANCES', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE'}, OnEvent, nil, nil, OnEnter, nil, ARMOR, nil, ValueColorUpdate)
|
||||
117
Modules/DataTexts/Avoidance.lua
Normal file
117
Modules/DataTexts/Avoidance.lua
Normal file
@@ -0,0 +1,117 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local format, strjoin, abs = format, strjoin, abs
|
||||
local GetBlockChance = GetBlockChance
|
||||
local GetBonusBarOffset = GetBonusBarOffset
|
||||
local GetDodgeChance = GetDodgeChance
|
||||
local GetInventoryItemID = GetInventoryItemID
|
||||
local GetInventorySlotInfo = GetInventorySlotInfo
|
||||
local GetItemInfo = GetItemInfo
|
||||
local GetParryChance = GetParryChance
|
||||
local UnitLevel = UnitLevel
|
||||
local BOSS = BOSS
|
||||
local BLOCK_CHANCE = BLOCK_CHANCE
|
||||
local DODGE_CHANCE = DODGE_CHANCE
|
||||
local MISS_CHANCE = MISS_CHANCE
|
||||
local PARRY_CHANCE = PARRY_CHANCE
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
|
||||
local displayString, lastPanel, targetlv, playerlv
|
||||
local basemisschance, leveldifference, dodge, parry, block, unhittable
|
||||
local AVD_DECAY_RATE, chanceString = 1.5, '%.2f%%'
|
||||
|
||||
local function IsWearingShield()
|
||||
local slotID = GetInventorySlotInfo('SecondaryHandSlot')
|
||||
local itemID = GetInventoryItemID('player', slotID)
|
||||
|
||||
if itemID then
|
||||
local _, _, _, _, _, _, _, _, itemEquipLoc = GetItemInfo(itemID)
|
||||
return itemEquipLoc == 'INVTYPE_SHIELD'
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
targetlv, playerlv = UnitLevel('target'), E.mylevel
|
||||
|
||||
basemisschance = E.myrace == 'NightElf' and 7 or 5
|
||||
if targetlv == -1 then
|
||||
leveldifference = 3
|
||||
elseif targetlv > playerlv then
|
||||
leveldifference = (targetlv - playerlv)
|
||||
elseif targetlv < playerlv and targetlv > 0 then
|
||||
leveldifference = (targetlv - playerlv)
|
||||
else
|
||||
leveldifference = 0
|
||||
end
|
||||
|
||||
if leveldifference >= 0 then
|
||||
dodge = (GetDodgeChance() - leveldifference * AVD_DECAY_RATE)
|
||||
parry = (GetParryChance() - leveldifference * AVD_DECAY_RATE)
|
||||
block = (GetBlockChance() - leveldifference * AVD_DECAY_RATE)
|
||||
basemisschance = (basemisschance - leveldifference * AVD_DECAY_RATE)
|
||||
else
|
||||
dodge = (GetDodgeChance() + abs(leveldifference * AVD_DECAY_RATE))
|
||||
parry = (GetParryChance() + abs(leveldifference * AVD_DECAY_RATE))
|
||||
block = (GetBlockChance() + abs(leveldifference * AVD_DECAY_RATE))
|
||||
basemisschance = (basemisschance+ abs(leveldifference * AVD_DECAY_RATE))
|
||||
end
|
||||
|
||||
local unhittableMax = 100
|
||||
local numAvoidances = 4
|
||||
if dodge <= 0 then dodge = 0 end
|
||||
if parry <= 0 then parry = 0 end
|
||||
if block <= 0 then block = 0 end
|
||||
|
||||
if E.myclass == 'DRUID' and GetBonusBarOffset() == 3 then
|
||||
parry = 0
|
||||
numAvoidances = numAvoidances - 1
|
||||
end
|
||||
|
||||
if not IsWearingShield() then
|
||||
block = 0
|
||||
numAvoidances = numAvoidances - 1
|
||||
end
|
||||
|
||||
unhittableMax = unhittableMax + ((AVD_DECAY_RATE * leveldifference) * numAvoidances)
|
||||
|
||||
local avoided = (dodge+parry+basemisschance) --First roll on hit table determining if the hit missed
|
||||
local blocked = (100 - avoided)*block/100 --If the hit landed then the second roll determines if the his was blocked
|
||||
local avoidance = (avoided+blocked)
|
||||
unhittable = avoidance - unhittableMax
|
||||
|
||||
if E.global.datatexts.settings.Avoidance.NoLabel then
|
||||
self.text:SetFormattedText(displayString, avoidance)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Avoidance.Label ~= '' and E.global.datatexts.settings.Avoidance.Label or L["AVD: "], avoidance)
|
||||
end
|
||||
|
||||
--print(unhittableMax) -- should report 102.4 for a level differance of +3 for shield classes, 101.2 for druids, 101.8 for monks and dks
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local rightString = targetlv > 1 and strjoin('', ' (', L["lvl"], ' ', targetlv, ')') or targetlv == -1 and strjoin('', ' (', BOSS, ')') or strjoin('', ' (', L["lvl"], ' ', playerlv, ')')
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], rightString)
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
DT.tooltip:AddDoubleLine(DODGE_CHANCE, format(chanceString, dodge), 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(PARRY_CHANCE, format(chanceString, parry), 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(BLOCK_CHANCE, format(chanceString, block), 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(MISS_CHANCE, format(chanceString, basemisschance), 1, 1, 1)
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Unhittable:"], (unhittable > 0 and '+' or '')..format(chanceString, unhittable), 1, 1, 1, (unhittable < 0 and 1 or 0), (unhittable > 0 and 1 or 0), 0)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Avoidance.NoLabel and '' or '%s', hex, '%.'..E.global.datatexts.settings.Avoidance.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Avoidance', STAT_CATEGORY_ENHANCEMENTS, {'UNIT_TARGET', 'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE', 'PLAYER_EQUIPMENT_CHANGED'}, OnEvent, nil, nil, OnEnter, nil, L["Avoidance Breakdown"], nil, ValueColorUpdate)
|
||||
98
Modules/DataTexts/Bags.lua
Normal file
98
Modules/DataTexts/Bags.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local format = format
|
||||
local GetContainerNumFreeSlots = GetContainerNumFreeSlots
|
||||
local GetContainerNumSlots = GetContainerNumSlots
|
||||
local ToggleAllBags = ToggleAllBags
|
||||
local CURRENCY = CURRENCY
|
||||
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
|
||||
local MAX_WATCHED_TOKENS = MAX_WATCHED_TOKENS
|
||||
local GetBagName = GetBagName
|
||||
local GetInventoryItemQuality = GetInventoryItemQuality
|
||||
local GetItemQualityColor = GetItemQualityColor
|
||||
local GetInventoryItemTexture = GetInventoryItemTexture
|
||||
local C_CurrencyInfo_GetBackpackCurrencyInfo = C_CurrencyInfo.GetBackpackCurrencyInfo
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
local iconString = '|T%s:14:14:0:0:64:64:4:60:4:60|t %s'
|
||||
local bagIcon = 'Interface/Buttons/Button-Backpack-Up'
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
local free, total, used = 0, 0
|
||||
for i = 0, NUM_BAG_SLOTS do
|
||||
free, total = free + GetContainerNumFreeSlots(i), total + GetContainerNumSlots(i)
|
||||
end
|
||||
used = total - free
|
||||
|
||||
local textFormat = E.global.datatexts.settings.Bags.textFormat
|
||||
|
||||
if textFormat == "FREE" then
|
||||
self.text:SetFormattedText(displayString, L["Bags"]..": ", free)
|
||||
elseif textFormat == "USED" then
|
||||
self.text:SetFormattedText(displayString, L["Bags"]..": ", used)
|
||||
elseif textFormat == "FREE_TOTAL" then
|
||||
self.text:SetFormattedText(displayString, L["Bags"]..": ", free, total)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, L["Bags"]..": ", used, total)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
ToggleAllBags()
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
for i = 0, NUM_BAG_SLOTS do
|
||||
local bagName = GetBagName(i)
|
||||
if bagName then
|
||||
local numSlots = GetContainerNumSlots(i)
|
||||
local freeSlots = GetContainerNumFreeSlots(i)
|
||||
local usedSlots, sumNum = numSlots - freeSlots, 19 + i
|
||||
|
||||
local r2, g2, b2 = E:ColorGradient(usedSlots / numSlots, .1,1,.1, 1,1,.1, 1,.1,.1)
|
||||
local r, g, b, icon
|
||||
|
||||
if i > 0 then
|
||||
r, g, b = GetItemQualityColor(GetInventoryItemQuality('player', sumNum) or 1)
|
||||
icon = GetInventoryItemTexture('player', sumNum)
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(format(iconString, icon or bagIcon, bagName), format('%d / %d', usedSlots, numSlots), r or 1, g or 1, b or 1, r2, g2, b2)
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, MAX_WATCHED_TOKENS do
|
||||
local info = C_CurrencyInfo_GetBackpackCurrencyInfo(i)
|
||||
if info then
|
||||
if i == 1 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(CURRENCY)
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
if info.quantity then
|
||||
DT.tooltip:AddDoubleLine(format(iconString, info.iconFileID, info.name), info.quantity, 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
local textFormat = E.global.datatexts.settings.Bags.textFormat
|
||||
if textFormat == "FREE" or textFormat == "USED" then
|
||||
displayString = strjoin('', '%s', hex, '%d|r')
|
||||
else
|
||||
displayString = strjoin('', '%s', hex, '%d/%d|r')
|
||||
end
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Bags', nil, {'BAG_UPDATE'}, OnEvent, nil, OnClick, OnEnter, nil, L["Bags"], nil, ValueColorUpdate)
|
||||
118
Modules/DataTexts/BattleStats.lua
Normal file
118
Modules/DataTexts/BattleStats.lua
Normal file
@@ -0,0 +1,118 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local sort = sort
|
||||
local ipairs = ipairs
|
||||
local strlen = strlen
|
||||
local strjoin = strjoin
|
||||
local C_PvP_GetMatchPVPStatColumns = C_PvP.GetMatchPVPStatColumns
|
||||
local GetNumBattlefieldScores = GetNumBattlefieldScores
|
||||
local GetBattlefieldStatData = GetBattlefieldStatData
|
||||
local GetBattlefieldScore = GetBattlefieldScore
|
||||
local BATTLEGROUND = BATTLEGROUND
|
||||
|
||||
local displayString = ''
|
||||
local holder = {
|
||||
LEFT = { data = {}, _G.KILLS, _G.KILLING_BLOWS, _G.DEATHS },
|
||||
RIGHT = { data = {}, _G.DAMAGE, _G.SHOW_COMBAT_HEALING, _G.HONOR }
|
||||
}
|
||||
|
||||
DT.BattleStats = holder
|
||||
function DT:UpdateBattlePanel(which)
|
||||
local info = which and holder[which]
|
||||
|
||||
local panel = info and info.panel
|
||||
if not panel then return end
|
||||
|
||||
for i, name in ipairs(info) do
|
||||
local dt = panel[i]
|
||||
if dt and dt.text then
|
||||
dt.text:SetFormattedText(displayString, name, info.data[i] or 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local myIndex
|
||||
local LEFT = holder.LEFT.data
|
||||
local RIGHT = holder.RIGHT.data
|
||||
function DT:UPDATE_BATTLEFIELD_SCORE()
|
||||
myIndex = nil
|
||||
|
||||
for i = 1, GetNumBattlefieldScores() do
|
||||
local name, kb, hks, deaths, honor, _, _, _, _, dmg, heals = GetBattlefieldScore(i)
|
||||
if name == E.myname then
|
||||
LEFT[1], LEFT[2], LEFT[3] = E:ShortValue(hks), E:ShortValue(kb), E:ShortValue(deaths)
|
||||
RIGHT[1], RIGHT[2], RIGHT[3] = E:ShortValue(dmg), E:ShortValue(heals), E:ShortValue(honor)
|
||||
myIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if myIndex then
|
||||
DT:UpdateBattlePanel('LEFT')
|
||||
DT:UpdateBattlePanel('RIGHT')
|
||||
end
|
||||
end
|
||||
|
||||
local function columnSort(lhs,rhs)
|
||||
return lhs.orderIndex < rhs.orderIndex
|
||||
end
|
||||
|
||||
function DT:HoverBattleStats() -- OnEnter
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
if myIndex and DT.ShowingBattleStats == 'pvp' then
|
||||
local columns = C_PvP_GetMatchPVPStatColumns()
|
||||
if columns then
|
||||
sort(columns, columnSort)
|
||||
|
||||
local firstLine
|
||||
local classColor = E:ClassColor(E.myclass)
|
||||
DT.tooltip:AddDoubleLine(BATTLEGROUND, E.MapInfo.name, 1,1,1, classColor.r, classColor.g, classColor.b)
|
||||
|
||||
-- Add extra statistics to watch based on what BG you are in.
|
||||
for i, stat in ipairs(columns) do
|
||||
local name = stat.name
|
||||
if name and strlen(name) > 0 then
|
||||
if not firstLine then
|
||||
DT.tooltip:AddLine(' ')
|
||||
firstLine = true
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(name, GetBattlefieldStatData(myIndex, i), 1,1,1)
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:ToggleBattleStats()
|
||||
if DT.ForceHideBGStats then
|
||||
DT.ForceHideBGStats = nil
|
||||
E:Print(L["Battleground datatexts will now show again if you are inside a battleground."])
|
||||
else
|
||||
DT.ForceHideBGStats = true
|
||||
E:Print(L["Battleground datatexts temporarily hidden, to show type /bgstats"])
|
||||
end
|
||||
|
||||
DT:UpdatePanelInfo('LeftChatDataPanel')
|
||||
DT:UpdatePanelInfo('RightChatDataPanel')
|
||||
|
||||
if DT.ShowingBattleStats then
|
||||
DT:UpdateBattlePanel('LEFT')
|
||||
DT:UpdateBattlePanel('RIGHT')
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%s|r')
|
||||
|
||||
if DT.ShowingBattleStats then
|
||||
DT:UpdateBattlePanel('LEFT')
|
||||
DT:UpdateBattlePanel('RIGHT')
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
172
Modules/DataTexts/CallToArms.lua
Normal file
172
Modules/DataTexts/CallToArms.lua
Normal file
@@ -0,0 +1,172 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local strjoin = strjoin
|
||||
|
||||
local GetLFGRandomDungeonInfo = GetLFGRandomDungeonInfo
|
||||
local GetLFGRoleShortageRewards = GetLFGRoleShortageRewards
|
||||
local GetNumRandomDungeons = GetNumRandomDungeons
|
||||
local GetNumRFDungeons = GetNumRFDungeons
|
||||
local GetRFDungeonInfo = GetRFDungeonInfo
|
||||
local PVEFrame_ToggleFrame = PVEFrame_ToggleFrame
|
||||
local LFG_ROLE_NUM_SHORTAGE_TYPES = LFG_ROLE_NUM_SHORTAGE_TYPES
|
||||
local BATTLEGROUND_HOLIDAY = BATTLEGROUND_HOLIDAY
|
||||
local DUNGEONS = DUNGEONS
|
||||
local RAID_FINDER = RAID_FINDER
|
||||
|
||||
local TANK_ICON = E:TextureString(E.Media.Textures.Tank, ':14:14')
|
||||
local HEALER_ICON = E:TextureString(E.Media.Textures.Healer, ':14:14')
|
||||
local DPS_ICON = E:TextureString(E.Media.Textures.DPS, ':14:14')
|
||||
local enteredFrame, lastPanel = false
|
||||
local displayString = ''
|
||||
|
||||
local function MakeIconString(tank, healer, damage)
|
||||
local str = ''
|
||||
if tank then
|
||||
str = str..TANK_ICON
|
||||
end
|
||||
if healer then
|
||||
str = str..HEALER_ICON
|
||||
end
|
||||
if damage then
|
||||
str = str..DPS_ICON
|
||||
end
|
||||
|
||||
return str
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local tankReward = false
|
||||
local healerReward = false
|
||||
local dpsReward = false
|
||||
local unavailable = true
|
||||
|
||||
--Dungeons
|
||||
for i = 1, GetNumRandomDungeons() do
|
||||
local id = GetLFGRandomDungeonInfo(i)
|
||||
for x = 1, LFG_ROLE_NUM_SHORTAGE_TYPES do
|
||||
local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
|
||||
if eligible and forTank and itemCount > 0 then tankReward = true; unavailable = false; end
|
||||
if eligible and forHealer and itemCount > 0 then healerReward = true; unavailable = false; end
|
||||
if eligible and forDamage and itemCount > 0 then dpsReward = true; unavailable = false; end
|
||||
end
|
||||
end
|
||||
|
||||
--LFR
|
||||
for i = 1, GetNumRFDungeons() do
|
||||
local id = GetRFDungeonInfo(i)
|
||||
for x = 1, LFG_ROLE_NUM_SHORTAGE_TYPES do
|
||||
local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
|
||||
if eligible and forTank and itemCount > 0 then tankReward = true; unavailable = false; end
|
||||
if eligible and forHealer and itemCount > 0 then healerReward = true; unavailable = false; end
|
||||
if eligible and forDamage and itemCount > 0 then dpsReward = true; unavailable = false; end
|
||||
end
|
||||
end
|
||||
|
||||
if E.global.datatexts.settings.CallToArms.NoLabel then
|
||||
self.text:SetFormattedText(displayString, unavailable and 'N/A' or MakeIconString(tankReward, healerReward, dpsReward))
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.CallToArms.Label ~= '' and E.global.datatexts.settings.CallToArms.Label or BATTLEGROUND_HOLIDAY..": ", unavailable and 'N/A' or MakeIconString(tankReward, healerReward, dpsReward))
|
||||
end
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
PVEFrame_ToggleFrame('GroupFinderFrame', _G.LFDParentFrame)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.CallToArms.NoLabel and '' or '%s', hex, '%s|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
enteredFrame = true
|
||||
|
||||
local numCTA = 0
|
||||
local addTooltipHeader, addTooltipSeparator = true
|
||||
for i = 1, GetNumRandomDungeons() do
|
||||
local id, name = GetLFGRandomDungeonInfo(i)
|
||||
local tankReward = false
|
||||
local healerReward = false
|
||||
local dpsReward = false
|
||||
local unavailable = true
|
||||
for x = 1, LFG_ROLE_NUM_SHORTAGE_TYPES do
|
||||
local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
|
||||
if eligible then unavailable = false end
|
||||
if eligible and forTank and itemCount > 0 then tankReward = true end
|
||||
if eligible and forHealer and itemCount > 0 then healerReward = true end
|
||||
if eligible and forDamage and itemCount > 0 then dpsReward = true end
|
||||
end
|
||||
|
||||
if not unavailable then
|
||||
local rolesString = MakeIconString(tankReward, healerReward, dpsReward)
|
||||
if rolesString ~= '' then
|
||||
if addTooltipHeader then
|
||||
DT.tooltip:AddLine(DUNGEONS)
|
||||
addTooltipHeader = false
|
||||
addTooltipSeparator = true
|
||||
end
|
||||
DT.tooltip:AddDoubleLine(name..':', rolesString, 1, 1, 1)
|
||||
end
|
||||
if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
|
||||
end
|
||||
end
|
||||
|
||||
addTooltipHeader = true
|
||||
for i = 1, GetNumRFDungeons() do
|
||||
local id, name = GetRFDungeonInfo(i)
|
||||
local tankReward = false
|
||||
local healerReward = false
|
||||
local dpsReward = false
|
||||
local unavailable = true
|
||||
|
||||
for x = 1, LFG_ROLE_NUM_SHORTAGE_TYPES do
|
||||
local eligible, forTank, forHealer, forDamage, itemCount = GetLFGRoleShortageRewards(id, x)
|
||||
if eligible then unavailable = false end
|
||||
if eligible and forTank and itemCount > 0 then tankReward = true end
|
||||
if eligible and forHealer and itemCount > 0 then healerReward = true end
|
||||
if eligible and forDamage and itemCount > 0 then dpsReward = true end
|
||||
end
|
||||
|
||||
if not unavailable then
|
||||
local rolesString = MakeIconString(tankReward, healerReward, dpsReward)
|
||||
if rolesString ~= '' then
|
||||
if addTooltipHeader then
|
||||
if addTooltipSeparator then DT.tooltip:AddLine(' ') end
|
||||
DT.tooltip:AddLine(RAID_FINDER)
|
||||
addTooltipHeader = false
|
||||
end
|
||||
DT.tooltip:AddDoubleLine(name..':', rolesString, 1, 1, 1)
|
||||
end
|
||||
if tankReward or healerReward or dpsReward then numCTA = numCTA + 1 end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local updateInterval = 10
|
||||
local function Update(self, elapsed)
|
||||
if self.timeSinceUpdate and self.timeSinceUpdate > updateInterval then
|
||||
OnEvent(self)
|
||||
|
||||
if enteredFrame then
|
||||
OnEnter(self)
|
||||
end
|
||||
|
||||
self.timeSinceUpdate = 0
|
||||
else
|
||||
self.timeSinceUpdate = (self.timeSinceUpdate or 0) + elapsed
|
||||
end
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
enteredFrame = false
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('CallToArms', nil, {"LFG_UPDATE_RANDOM_INFO"}, OnEvent, Update, OnClick, OnEnter, OnLeave, BATTLEGROUND_HOLIDAY, nil, ValueColorUpdate)
|
||||
55
Modules/DataTexts/CombatTime.lua
Normal file
55
Modules/DataTexts/CombatTime.lua
Normal file
@@ -0,0 +1,55 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local floor, format, strjoin = floor, format, strjoin
|
||||
local GetInstanceInfo = GetInstanceInfo
|
||||
local GetTime = GetTime
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
local timerText, timer, startTime = L["Combat"], 0, 0
|
||||
|
||||
local function UpdateText()
|
||||
return format(E.global.datatexts.settings.Combat.TimeFull and '%02d:%02d:%02d' or '%02d:%02d', floor(timer/60), timer % 60, (timer - floor(timer)) * 100)
|
||||
end
|
||||
|
||||
local function OnUpdate(self)
|
||||
timer = GetTime() - startTime
|
||||
self.text:SetFormattedText(displayString, timerText, UpdateText())
|
||||
end
|
||||
|
||||
local function DelayOnUpdate(self, elapsed)
|
||||
startTime = startTime - elapsed
|
||||
if startTime <= 0 then
|
||||
timer, startTime = 0, GetTime()
|
||||
self:SetScript('OnUpdate', OnUpdate)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, _, timeSeconds)
|
||||
local _, instanceType = GetInstanceInfo()
|
||||
local isInArena = instanceType == 'arena'
|
||||
|
||||
if event == 'START_TIMER' and isInArena then
|
||||
timerText, timer, startTime = L["Arena"], 0, timeSeconds
|
||||
self.text:SetFormattedText(displayString, timerText, '00:00:00')
|
||||
self:SetScript('OnUpdate', DelayOnUpdate)
|
||||
elseif event == 'PLAYER_REGEN_ENABLED' and not isInArena then
|
||||
self:SetScript('OnUpdate', nil)
|
||||
elseif event == 'PLAYER_REGEN_DISABLED' and not isInArena then
|
||||
timerText, timer, startTime = L["Combat"], 0, GetTime()
|
||||
self:SetScript('OnUpdate', OnUpdate)
|
||||
elseif not self.text:GetText() then
|
||||
self.text:SetFormattedText(displayString, timerText, 'N/A')
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%s|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Combat', nil, {'START_TIMER', 'PLAYER_REGEN_DISABLED', 'PLAYER_REGEN_ENABLED'}, OnEvent, nil, nil, nil, nil, L["Combat/Arena Time"], nil, ValueColorUpdate)
|
||||
59
Modules/DataTexts/ConfigElvUI.lua
Normal file
59
Modules/DataTexts/ConfigElvUI.lua
Normal file
@@ -0,0 +1,59 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local pairs, strjoin = pairs, strjoin
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local ReloadUI = ReloadUI
|
||||
|
||||
local displayString = ''
|
||||
local configText = 'ElvUI'
|
||||
local reloadText = RELOADUI
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.ElvUI.Label ~= '' and E.global.datatexts.settings.ElvUI.Label or configText)
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
DT.tooltip:AddDoubleLine(L["Left Click:"], L["Toggle Configuration"], 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(L["Hold Shift + Right Click:"], reloadText, 1, 1, 1)
|
||||
|
||||
if E.Libs.EP.registeredPrefix then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddDoubleLine('Plugins:', 'Version:')
|
||||
|
||||
for _, plugin in pairs(E.Libs.EP.plugins) do
|
||||
if not plugin.isLib then
|
||||
local r, g, b = E:HexToRGB(plugin.old and 'ff3333' or '33ff33')
|
||||
DT.tooltip:AddDoubleLine(plugin.title, plugin.version, 1, 1, 1, r/255, g/255, b/255)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnClick(_, button)
|
||||
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
|
||||
|
||||
if button == 'LeftButton' then
|
||||
E:ToggleOptionsUI()
|
||||
elseif button == 'RightButton' and IsShiftKeyDown() then
|
||||
ReloadUI()
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', hex, '%s|r')
|
||||
|
||||
if lastPanel then
|
||||
OnEvent(lastPanel, 'ELVUI_COLOR_UPDATE')
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('ElvUI', nil, nil, OnEvent, nil, OnClick, OnEnter, nil, L['ElvUI Config'], nil, ValueColorUpdate)
|
||||
43
Modules/DataTexts/Coordinates.lua
Normal file
43
Modules/DataTexts/Coordinates.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local strjoin = strjoin
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
|
||||
local displayString = ''
|
||||
local inRestrictedArea = false
|
||||
local mapInfo = E.MapInfo
|
||||
|
||||
local function Update(self, elapsed)
|
||||
if inRestrictedArea or not mapInfo.coordsWatching then return end
|
||||
|
||||
self.timeSinceUpdate = (self.timeSinceUpdate or 0) + elapsed
|
||||
|
||||
if self.timeSinceUpdate > 0.1 then
|
||||
self.text:SetFormattedText(displayString, mapInfo.xText or 0, mapInfo.yText or 0)
|
||||
self.timeSinceUpdate = 0
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
if mapInfo.x and mapInfo.y then
|
||||
inRestrictedArea = false
|
||||
self.text:SetFormattedText(displayString, mapInfo.xText or 0, mapInfo.yText or 0)
|
||||
else
|
||||
inRestrictedArea = true
|
||||
self.text:SetText('N/A')
|
||||
end
|
||||
end
|
||||
|
||||
local function Click()
|
||||
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
|
||||
_G.ToggleFrame(_G.WorldMapFrame)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', hex, '%.2f|r', ' | ', hex, '%.2f|r')
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Coords', nil, {'LOADING_SCREEN_DISABLED', 'ZONE_CHANGED', 'ZONE_CHANGED_INDOORS', 'ZONE_CHANGED_NEW_AREA'}, OnEvent, Update, Click, nil, nil, L["Coords"], mapInfo, ValueColorUpdate)
|
||||
96
Modules/DataTexts/Crit.lua
Normal file
96
Modules/DataTexts/Crit.lua
Normal file
@@ -0,0 +1,96 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local min = min
|
||||
local format, strjoin = format, strjoin
|
||||
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local GetCritChance = GetCritChance
|
||||
local GetRangedCritChance = GetRangedCritChance
|
||||
local GetSpellCritChance = GetSpellCritChance
|
||||
local GetCritChanceProvidesParryEffect = GetCritChanceProvidesParryEffect
|
||||
local GetCombatRatingBonusForCombatRatingValue = GetCombatRatingBonusForCombatRatingValue
|
||||
local CR_CRIT_MELEE = CR_CRIT_MELEE
|
||||
local CR_CRIT_RANGED = CR_CRIT_RANGED
|
||||
local CR_CRIT_SPELL = CR_CRIT_SPELL
|
||||
local CR_PARRY = CR_PARRY
|
||||
local MAX_SPELL_SCHOOLS = MAX_SPELL_SCHOOLS
|
||||
local CRIT_ABBR = CRIT_ABBR
|
||||
local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE
|
||||
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
|
||||
local MELEE_CRIT_CHANCE = MELEE_CRIT_CHANCE
|
||||
local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
|
||||
local RANGED_CRIT_CHANCE = RANGED_CRIT_CHANCE
|
||||
local SPELL_CRIT_CHANCE = SPELL_CRIT_CHANCE
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
local CR_CRIT_PARRY_RATING_TOOLTIP = CR_CRIT_PARRY_RATING_TOOLTIP
|
||||
local CR_CRIT_TOOLTIP = CR_CRIT_TOOLTIP
|
||||
local displayString, lastPanel = ''
|
||||
local rating, spellCrit, rangedCrit, meleeCrit, critChance
|
||||
local extraCritChance, extraCritRating
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local tooltip, critText
|
||||
if spellCrit >= rangedCrit and spellCrit >= meleeCrit then
|
||||
critText = SPELL_CRIT_CHANCE
|
||||
elseif rangedCrit >= meleeCrit then
|
||||
critText = RANGED_CRIT_CHANCE
|
||||
else
|
||||
critText = MELEE_CRIT_CHANCE;
|
||||
end
|
||||
|
||||
if GetCritChanceProvidesParryEffect() then
|
||||
tooltip = format(CR_CRIT_PARRY_RATING_TOOLTIP, BreakUpLargeNumbers(extraCritRating), extraCritChance, GetCombatRatingBonusForCombatRatingValue(CR_PARRY, extraCritRating));
|
||||
else
|
||||
tooltip = format(CR_CRIT_TOOLTIP, BreakUpLargeNumbers(extraCritRating), extraCritChance);
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, critText)..' '..format('%.2f%%', critChance)..FONT_COLOR_CODE_CLOSE, nil, 1, 1, 1)
|
||||
DT.tooltip:AddLine(tooltip, nil, nil, nil, true)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local minCrit = GetSpellCritChance(2)
|
||||
for i = 3, MAX_SPELL_SCHOOLS do
|
||||
spellCrit = GetSpellCritChance(i);
|
||||
minCrit = min(minCrit, spellCrit);
|
||||
end
|
||||
spellCrit = minCrit
|
||||
rangedCrit = GetRangedCritChance();
|
||||
meleeCrit = GetCritChance();
|
||||
|
||||
if spellCrit >= rangedCrit and spellCrit >= meleeCrit then
|
||||
critChance = spellCrit;
|
||||
rating = CR_CRIT_SPELL;
|
||||
elseif rangedCrit >= meleeCrit then
|
||||
critChance = rangedCrit;
|
||||
rating = CR_CRIT_RANGED;
|
||||
else
|
||||
critChance = meleeCrit;
|
||||
rating = CR_CRIT_MELEE;
|
||||
end
|
||||
|
||||
extraCritChance, extraCritRating = GetCombatRatingBonus(rating), GetCombatRating(rating)
|
||||
|
||||
if E.global.datatexts.settings.Crit.NoLabel then
|
||||
self.text:SetFormattedText(displayString, critChance)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Crit.Label ~= '' and E.global.datatexts.settings.Crit.Label or CRIT_ABBR..': ', critChance)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Crit.NoLabel and '' or '%s', hex, '%.'..E.global.datatexts.settings.Crit.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Crit', STAT_CATEGORY_ENHANCEMENTS, {'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE', 'PLAYER_DAMAGE_DONE_MODS'}, OnEvent, nil, nil, OnEnter, nil, _G.STAT_CRITICAL_STRIKE, nil, ValueColorUpdate)
|
||||
104
Modules/DataTexts/Currencies.lua
Normal file
104
Modules/DataTexts/Currencies.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local format, tonumber = format, tonumber
|
||||
local type, ipairs, unpack = type, ipairs, unpack
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local GetMoney = GetMoney
|
||||
|
||||
local C_CurrencyInfo_GetBackpackCurrencyInfo = C_CurrencyInfo.GetBackpackCurrencyInfo
|
||||
local C_CurrencyInfo_GetCurrencyInfo = C_CurrencyInfo.GetCurrencyInfo
|
||||
local BONUS_ROLL_REWARD_MONEY = BONUS_ROLL_REWARD_MONEY
|
||||
|
||||
local iconString = '|T%s:16:16:0:0:64:64:4:60:4:60|t'
|
||||
DT.CurrencyList = { GOLD = BONUS_ROLL_REWARD_MONEY, BACKPACK = 'Backpack' }
|
||||
|
||||
local function OnClick()
|
||||
_G.ToggleCharacter('TokenFrame')
|
||||
end
|
||||
|
||||
local function GetInfo(id)
|
||||
local info = C_CurrencyInfo_GetCurrencyInfo(id)
|
||||
if info then
|
||||
return info.name, info.quantity, (info.iconFileID and format(iconString, info.iconFileID)) or '136012'
|
||||
else
|
||||
return '', '', '136012'
|
||||
end
|
||||
end
|
||||
|
||||
local function AddInfo(id)
|
||||
local name, num, icon = GetInfo(id)
|
||||
if name then
|
||||
DT.tooltip:AddDoubleLine(format('%s %s', icon, name), BreakUpLargeNumbers(num), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
local goldText
|
||||
local function OnEvent(self)
|
||||
goldText = E:FormatMoney(GetMoney(), E.global.datatexts.settings.Currencies.goldFormat or 'BLIZZARD', not E.global.datatexts.settings.Currencies.goldCoins)
|
||||
|
||||
local displayed = E.global.datatexts.settings.Currencies.displayedCurrency
|
||||
if displayed == 'BACKPACK' then
|
||||
local displayString = ''
|
||||
for i = 1, 3 do
|
||||
local info = C_CurrencyInfo_GetBackpackCurrencyInfo(i)
|
||||
if info and info.quantity then
|
||||
displayString = (i > 1 and displayString..' ' or displayString)..format('%s %s', format(iconString, info.iconFileID), E:ShortValue(info.quantity))
|
||||
end
|
||||
end
|
||||
|
||||
self.text:SetText(displayString == '' and goldText or displayString)
|
||||
elseif displayed == 'GOLD' then
|
||||
self.text:SetText(goldText)
|
||||
else
|
||||
local id = tonumber(displayed)
|
||||
if not id then return end
|
||||
|
||||
local name, num, icon = GetInfo(id)
|
||||
if not name then return end
|
||||
|
||||
local style = E.global.datatexts.settings.Currencies.displayStyle
|
||||
if style == 'ICON' then
|
||||
self.text:SetFormattedText('%s %s', icon, E:ShortValue(num))
|
||||
elseif style == 'ICON_TEXT' then
|
||||
self.text:SetFormattedText('%s %s %s', icon, name, E:ShortValue(num))
|
||||
else --ICON_TEXT_ABBR
|
||||
self.text:SetFormattedText('%s %s %s', icon, E:AbbreviateString(name), E:ShortValue(num))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local addLine, goldSpace
|
||||
for _, info in ipairs(E.global.datatexts.settings.Currencies.tooltipData) do
|
||||
local name, id, _, enabled = unpack(info)
|
||||
if id and enabled then
|
||||
if type(id) == 'number' then
|
||||
AddInfo(id)
|
||||
end
|
||||
|
||||
goldSpace = true
|
||||
elseif enabled then
|
||||
if addLine then
|
||||
DT.tooltip:AddLine(' ')
|
||||
else
|
||||
addLine = true
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(name)
|
||||
goldSpace = true
|
||||
end
|
||||
end
|
||||
|
||||
if goldSpace then
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Gold"]..':', goldText, nil, nil, nil, 1, 1, 1)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Currencies', nil, {'PLAYER_MONEY', 'SEND_MAIL_MONEY_CHANGED', 'SEND_MAIL_COD_CHANGED', 'PLAYER_TRADE_MONEY', 'TRADE_MONEY_CHANGED', 'CHAT_MSG_CURRENCY', 'CURRENCY_DISPLAY_UPDATE'}, OnEvent, nil, OnClick, OnEnter, nil, _G.CURRENCY)
|
||||
155
Modules/DataTexts/CustomCurrency.lua
Normal file
155
Modules/DataTexts/CustomCurrency.lua
Normal file
@@ -0,0 +1,155 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local ipairs, pairs, format = ipairs, pairs, format
|
||||
local tinsert, tremove, next = tinsert, tremove, next
|
||||
local C_CurrencyInfo_GetCurrencyInfo = C_CurrencyInfo.GetCurrencyInfo
|
||||
local C_CurrencyInfo_GetCurrencyListInfo = C_CurrencyInfo.GetCurrencyListInfo
|
||||
local C_CurrencyInfo_GetCurrencyListSize = C_CurrencyInfo.GetCurrencyListSize
|
||||
|
||||
local CustomCurrencies = {}
|
||||
local CurrencyListNameToIndex = {}
|
||||
|
||||
local function OnEvent(self)
|
||||
local currency = CustomCurrencies[self.name]
|
||||
if currency then
|
||||
local info = C_CurrencyInfo_GetCurrencyInfo(currency.ID)
|
||||
if not info then return end
|
||||
|
||||
if currency.DISPLAY_STYLE == 'ICON' then
|
||||
if currency.SHOW_MAX then
|
||||
self.text:SetFormattedText('%s %d / %d', currency.ICON, info.quantity, info.maxQuantity)
|
||||
else
|
||||
self.text:SetFormattedText('%s %d', currency.ICON, info.quantity)
|
||||
end
|
||||
elseif currency.DISPLAY_STYLE == 'ICON_TEXT' then
|
||||
if currency.SHOW_MAX then
|
||||
self.text:SetFormattedText('%s %s %d / %d', currency.ICON, currency.NAME, info.quantity, info.maxQuantity)
|
||||
else
|
||||
self.text:SetFormattedText('%s %s %d', currency.ICON, currency.NAME, info.quantity)
|
||||
end
|
||||
else --ICON_TEXT_ABBR
|
||||
if currency.SHOW_MAX then
|
||||
self.text:SetFormattedText('%s %s %d / %d', currency.ICON, E:AbbreviateString(currency.NAME), info.quantity, info.maxQuantity)
|
||||
else
|
||||
self.text:SetFormattedText('%s %s %d', currency.ICON, E:AbbreviateString(currency.NAME), info.quantity)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local currency = CustomCurrencies[self.name]
|
||||
if not currency or not currency.USE_TOOLTIP then return end
|
||||
|
||||
local index = CurrencyListNameToIndex[self.name]
|
||||
if not index then return end
|
||||
DT.tooltip:SetCurrencyToken(index)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function AddCurrencyNameToIndex(name)
|
||||
for index = 1, C_CurrencyInfo_GetCurrencyListSize() do
|
||||
local info = C_CurrencyInfo_GetCurrencyListInfo(index)
|
||||
if info.name == name then
|
||||
CurrencyListNameToIndex[name] = index
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function RegisterNewDT(currencyID)
|
||||
local info = C_CurrencyInfo_GetCurrencyInfo(currencyID)
|
||||
if info.discovered then
|
||||
local name = info.name
|
||||
|
||||
--Add to internal storage, stored with name as key
|
||||
CustomCurrencies[name] = {NAME = name, ID = currencyID, ICON = format('|T%s:16:16:0:0:64:64:4:60:4:60|t', info.iconFileID), DISPLAY_STYLE = 'ICON', USE_TOOLTIP = true, SHOW_MAX = false, DISPLAY_IN_MAIN_TOOLTIP = true}
|
||||
--Register datatext
|
||||
DT:RegisterDatatext(name, _G.CURRENCY, {'CHAT_MSG_CURRENCY', 'CURRENCY_DISPLAY_UPDATE'}, OnEvent, nil, nil, OnEnter, nil, name)
|
||||
--Save info to persistent storage, stored with ID as key
|
||||
E.global.datatexts.customCurrencies[currencyID] = CustomCurrencies[name]
|
||||
--Get the currency index for this currency, so we can use it for a tooltip
|
||||
AddCurrencyNameToIndex(name)
|
||||
|
||||
--Set the HyperDT
|
||||
local menuIndex = DT:GetMenuListCategory(_G.CURRENCY)
|
||||
local hyperList = DT.HyperList[menuIndex]
|
||||
if hyperList then
|
||||
local menuList = hyperList.menuList
|
||||
|
||||
tinsert(menuList, {
|
||||
text = name,
|
||||
checked = function() return DT.EasyMenu.MenuGetItem(DT.SelectedDatatext, name) end,
|
||||
func = function() DT.EasyMenu.MenuSetItem(DT.SelectedDatatext, name) end
|
||||
})
|
||||
|
||||
DT:SortMenuList(menuList)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:UpdateCustomCurrencySettings(currencyName, option, value)
|
||||
if not currencyName or not option then return end
|
||||
|
||||
if option == 'DISPLAY_STYLE' then
|
||||
CustomCurrencies[currencyName].DISPLAY_STYLE = value
|
||||
elseif option == 'USE_TOOLTIP' then
|
||||
CustomCurrencies[currencyName].USE_TOOLTIP = value
|
||||
elseif option == 'SHOW_MAX' then
|
||||
CustomCurrencies[currencyName].SHOW_MAX = value
|
||||
elseif option == 'DISPLAY_IN_MAIN_TOOLTIP' then
|
||||
CustomCurrencies[currencyName].DISPLAY_IN_MAIN_TOOLTIP = value
|
||||
end
|
||||
end
|
||||
|
||||
function DT:RegisterCustomCurrencyDT(currencyID)
|
||||
if currencyID then
|
||||
--We added a new datatext through the config
|
||||
if not next(CustomCurrencies) then -- add Currency category if one didn't already exist
|
||||
tinsert(DT.HyperList, { text = _G.CURRENCY, notCheckable = true, hasArrow = true, menuList = {} } )
|
||||
DT:SortMenuList(DT.HyperList)
|
||||
end
|
||||
|
||||
RegisterNewDT(currencyID)
|
||||
else
|
||||
--We called this in DT:Initialize, so load all the stored currency datatexts
|
||||
for _, info in pairs(E.global.datatexts.customCurrencies) do
|
||||
CustomCurrencies[info.NAME] = {NAME = info.NAME, ID = info.ID, ICON = info.ICON, DISPLAY_STYLE = info.DISPLAY_STYLE, USE_TOOLTIP = info.USE_TOOLTIP, SHOW_MAX = info.SHOW_MAX}
|
||||
DT:RegisterDatatext(info.NAME, _G.CURRENCY, {'CHAT_MSG_CURRENCY', 'CURRENCY_DISPLAY_UPDATE'}, OnEvent, nil, nil, OnEnter, nil, info.NAME)
|
||||
--Get the currency index for this currency, so we can use it for a tooltip
|
||||
AddCurrencyNameToIndex(info.NAME)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:RemoveCustomCurrency(currencyName)
|
||||
--Remove from internal storage
|
||||
CustomCurrencies[currencyName] = nil
|
||||
|
||||
if not next(CustomCurrencies) then
|
||||
for i, menu in ipairs(DT.HyperList) do
|
||||
if menu.text == _G.CURRENCY then
|
||||
tremove(DT.HyperList, i)
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
local menuIndex = DT:GetMenuListCategory(_G.CURRENCY)
|
||||
local hyperList = DT.HyperList[menuIndex]
|
||||
if hyperList then
|
||||
local menuList = hyperList.menuList
|
||||
|
||||
for i, info in ipairs(menuList) do
|
||||
if info.text == currencyName then
|
||||
tremove(menuList, i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT:SortMenuList(DT.HyperList)
|
||||
end
|
||||
82
Modules/DataTexts/DPS.lua
Normal file
82
Modules/DataTexts/DPS.lua
Normal file
@@ -0,0 +1,82 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local time, max, strjoin = time, max, strjoin
|
||||
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
|
||||
local UnitGUID = UnitGUID
|
||||
|
||||
local lastSegment, petGUID = 0
|
||||
local timeStamp, combatTime, DMGTotal, lastDMGAmount = 0, 0, 0, 0
|
||||
local displayString, lastPanel = ''
|
||||
local events = {
|
||||
SWING_DAMAGE = true,
|
||||
RANGE_DAMAGE = true,
|
||||
SPELL_DAMAGE = true,
|
||||
SPELL_PERIODIC_DAMAGE = true,
|
||||
DAMAGE_SHIELD = true,
|
||||
DAMAGE_SPLIT = true,
|
||||
SPELL_EXTRA_ATTACKS = true
|
||||
}
|
||||
|
||||
local function Reset()
|
||||
timeStamp, combatTime, DMGTotal, lastDMGAmount = 0, 0, 0, 0
|
||||
end
|
||||
|
||||
local function GetDPS(self)
|
||||
local DPS
|
||||
if DMGTotal == 0 or combatTime == 0 then
|
||||
DPS = 0
|
||||
else
|
||||
DPS = DMGTotal / combatTime
|
||||
end
|
||||
self.text:SetFormattedText(displayString, L["DPS"], E:ShortValue(DPS))
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
lastPanel = self
|
||||
|
||||
if event == 'UNIT_PET' then
|
||||
petGUID = UnitGUID('pet')
|
||||
elseif event == 'PLAYER_REGEN_DISABLED' or event == 'PLAYER_LEAVE_COMBAT' then
|
||||
local now = time()
|
||||
if now - lastSegment > 20 then --time since the last segment
|
||||
Reset()
|
||||
end
|
||||
lastSegment = now
|
||||
elseif event == 'COMBAT_LOG_EVENT_UNFILTERED' then
|
||||
local timestamp, Event, _, sourceGUID, _, _, _, _, _, _, _, arg12, _, _, arg15, arg16 = CombatLogGetCurrentEventInfo()
|
||||
if not events[Event] then return end
|
||||
|
||||
-- only use events from the player
|
||||
local overKill
|
||||
|
||||
if sourceGUID == E.myguid or sourceGUID == petGUID then
|
||||
if timeStamp == 0 then timeStamp = timestamp end
|
||||
lastSegment = timeStamp
|
||||
combatTime = timestamp - timeStamp
|
||||
if Event == 'SWING_DAMAGE' then
|
||||
lastDMGAmount = arg12
|
||||
else
|
||||
lastDMGAmount = arg15
|
||||
end
|
||||
if arg16 == nil then overKill = 0 else overKill = arg16 end
|
||||
DMGTotal = DMGTotal + max(0, lastDMGAmount - overKill)
|
||||
end
|
||||
end
|
||||
|
||||
GetDPS(self)
|
||||
end
|
||||
|
||||
local function OnClick(self)
|
||||
Reset()
|
||||
GetDPS(self)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%s')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('DPS', nil, {'UNIT_PET', 'COMBAT_LOG_EVENT_UNFILTERED', 'PLAYER_LEAVE_COMBAT', 'PLAYER_REGEN_DISABLED'}, OnEvent, nil, OnClick, nil, nil, _G.STAT_DPS_SHORT, nil, ValueColorUpdate)
|
||||
848
Modules/DataTexts/DataTexts.lua
Normal file
848
Modules/DataTexts/DataTexts.lua
Normal file
@@ -0,0 +1,848 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
local TT = E:GetModule('Tooltip')
|
||||
local LDB = E.Libs.LDB
|
||||
local LSM = E.Libs.LSM
|
||||
|
||||
local _G = _G
|
||||
local tostring, format, type, pcall = tostring, format, type, pcall
|
||||
local tinsert, ipairs, pairs, wipe, sort = tinsert, ipairs, pairs, wipe, sort
|
||||
local next, strfind, strlen, strsplit = next, strfind, strlen, strsplit
|
||||
local CloseDropDownMenus = CloseDropDownMenus
|
||||
local CreateFrame = CreateFrame
|
||||
local EasyMenu = EasyMenu
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local IsInInstance = IsInInstance
|
||||
local MouseIsOver = MouseIsOver
|
||||
local RegisterStateDriver = RegisterStateDriver
|
||||
local UIDropDownMenu_SetAnchor = UIDropDownMenu_SetAnchor
|
||||
local UnregisterStateDriver = UnregisterStateDriver
|
||||
local C_CurrencyInfo_GetCurrencyInfo = C_CurrencyInfo.GetCurrencyInfo
|
||||
local C_CurrencyInfo_GetCurrencyListSize = C_CurrencyInfo.GetCurrencyListSize
|
||||
local C_CurrencyInfo_GetCurrencyListInfo = C_CurrencyInfo.GetCurrencyListInfo
|
||||
local C_CurrencyInfo_GetCurrencyListLink = C_CurrencyInfo.GetCurrencyListLink
|
||||
local C_CurrencyInfo_GetCurrencyIDFromLink = C_CurrencyInfo.GetCurrencyIDFromLink
|
||||
local C_CurrencyInfo_ExpandCurrencyList = C_CurrencyInfo.ExpandCurrencyList
|
||||
local GetNumSpecializations = GetNumSpecializations
|
||||
local GetSpecializationInfo = GetSpecializationInfo
|
||||
local MISCELLANEOUS = MISCELLANEOUS
|
||||
|
||||
local LFG_TYPE_DUNGEON = LFG_TYPE_DUNGEON
|
||||
local expansion = _G['EXPANSION_NAME'..GetExpansionLevel()]
|
||||
local ActivateHyperMode
|
||||
local HyperList = {}
|
||||
|
||||
DT.tooltip = CreateFrame('GameTooltip', 'DataTextTooltip', E.UIParent, 'GameTooltipTemplate')
|
||||
DT.EasyMenu = CreateFrame('Frame', 'DataTextEasyMenu', E.UIParent, 'UIDropDownMenuTemplate')
|
||||
|
||||
DT.SelectedDatatext = nil
|
||||
DT.HyperList = HyperList
|
||||
DT.RegisteredPanels = {}
|
||||
DT.RegisteredDataTexts = {}
|
||||
DT.LoadedInfo = {}
|
||||
DT.PanelPool = {
|
||||
InUse = {},
|
||||
Free = {},
|
||||
Count = 0
|
||||
}
|
||||
|
||||
DT.FontStrings = {}
|
||||
DT.AssignedDatatexts = {}
|
||||
DT.UnitEvents = {
|
||||
UNIT_AURA = true,
|
||||
UNIT_RESISTANCES = true,
|
||||
UNIT_STATS = true,
|
||||
UNIT_ATTACK_POWER = true,
|
||||
UNIT_RANGED_ATTACK_POWER = true,
|
||||
UNIT_TARGET = true,
|
||||
UNIT_SPELL_HASTE = true
|
||||
}
|
||||
|
||||
DT.SPECIALIZATION_CACHE = {}
|
||||
|
||||
function DT:SetEasyMenuAnchor(menu, dt)
|
||||
local point = E:GetScreenQuadrant(dt)
|
||||
local bottom = point and strfind(point, 'BOTTOM')
|
||||
local left = point and strfind(point, 'LEFT')
|
||||
|
||||
local anchor1 = (bottom and left and 'BOTTOMLEFT') or (bottom and 'BOTTOMRIGHT') or (left and 'TOPLEFT') or 'TOPRIGHT'
|
||||
local anchor2 = (bottom and left and 'TOPLEFT') or (bottom and 'TOPRIGHT') or (left and 'BOTTOMLEFT') or 'BOTTOMRIGHT'
|
||||
|
||||
UIDropDownMenu_SetAnchor(menu, 0, 0, anchor1, dt, anchor2)
|
||||
end
|
||||
|
||||
--> [HyperDT Credits] <--
|
||||
--> Original Work: NihilisticPandemonium
|
||||
--> Modified by Azilroka! :)
|
||||
|
||||
function DT:SingleHyperMode(_, key, active)
|
||||
if DT.SelectedDatatext and (key == 'LALT' or key == 'RALT') then
|
||||
if active == 1 and MouseIsOver(DT.SelectedDatatext) then
|
||||
DT:OnLeave()
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, DT.SelectedDatatext)
|
||||
EasyMenu(HyperList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
elseif _G.DropDownList1:IsShown() and not _G.DropDownList1:IsMouseOver() then
|
||||
CloseDropDownMenus()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:HyperClick()
|
||||
DT.SelectedDatatext = self
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, DT.SelectedDatatext)
|
||||
EasyMenu(HyperList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
end
|
||||
|
||||
function DT:EnableHyperMode(Panel)
|
||||
DT:OnLeave()
|
||||
|
||||
if Panel then
|
||||
for _, dt in pairs(Panel.dataPanels) do
|
||||
dt.overlay:Show()
|
||||
dt:SetScript('OnEnter', nil)
|
||||
dt:SetScript('OnLeave', nil)
|
||||
dt:SetScript('OnClick', DT.HyperClick)
|
||||
end
|
||||
else
|
||||
for _, panel in pairs(DT.RegisteredPanels) do
|
||||
for _, dt in pairs(panel.dataPanels) do
|
||||
dt.overlay:Show()
|
||||
dt:SetScript('OnEnter', nil)
|
||||
dt:SetScript('OnLeave', nil)
|
||||
dt:SetScript('OnClick', DT.HyperClick)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:OnEnter()
|
||||
if E.db.datatexts.noCombatHover and InCombatLockdown() then return end
|
||||
|
||||
if self.parent then
|
||||
DT.SelectedDatatext = self
|
||||
DT:SetupTooltip(self)
|
||||
end
|
||||
|
||||
if self.MouseEnters then
|
||||
for _, func in ipairs(self.MouseEnters) do
|
||||
func(self)
|
||||
end
|
||||
end
|
||||
|
||||
DT.MouseEnter(self)
|
||||
end
|
||||
|
||||
function DT:OnLeave()
|
||||
if self.MouseLeaves then
|
||||
for _, func in ipairs(self.MouseLeaves) do
|
||||
func(self)
|
||||
end
|
||||
end
|
||||
|
||||
DT.MouseLeave(self)
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
function DT:MouseEnter()
|
||||
local frame = self.parent or self
|
||||
if frame.db and frame.db.mouseover then
|
||||
E:UIFrameFadeIn(frame, 0.2, frame:GetAlpha(), 1)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:MouseLeave()
|
||||
local frame = self.parent or self
|
||||
if frame.db and frame.db.mouseover then
|
||||
E:UIFrameFadeOut(frame, 0.2, frame:GetAlpha(), 0)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:FetchFrame(givenName)
|
||||
local panelExists = DT.PanelPool.InUse[givenName]
|
||||
if panelExists then return panelExists end
|
||||
|
||||
local count = DT.PanelPool.Count
|
||||
local name = 'ElvUI_DTPanel' .. count
|
||||
local frame
|
||||
|
||||
local poolName, poolFrame = next(DT.PanelPool.Free)
|
||||
if poolName then
|
||||
frame = poolFrame
|
||||
DT.PanelPool.Free[poolName] = nil
|
||||
else
|
||||
frame = CreateFrame('Frame', name, E.UIParent, 'BackdropTemplate')
|
||||
DT.PanelPool.Count = DT.PanelPool.Count + 1
|
||||
end
|
||||
|
||||
DT.PanelPool.InUse[givenName] = frame
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
function DT:EmptyPanel(panel)
|
||||
panel:Hide()
|
||||
|
||||
for _, dt in ipairs(panel.dataPanels) do
|
||||
dt:UnregisterAllEvents()
|
||||
dt:SetScript('OnUpdate', nil)
|
||||
dt:SetScript('OnEvent', nil)
|
||||
dt:SetScript('OnEnter', nil)
|
||||
dt:SetScript('OnLeave', nil)
|
||||
dt:SetScript('OnClick', nil)
|
||||
end
|
||||
|
||||
UnregisterStateDriver(panel, 'visibility')
|
||||
E:DisableMover(panel.moverName)
|
||||
end
|
||||
|
||||
function DT:ReleasePanel(givenName)
|
||||
local panel = DT.PanelPool.InUse[givenName]
|
||||
if panel then
|
||||
DT:EmptyPanel(panel)
|
||||
DT.PanelPool.Free[givenName] = panel
|
||||
DT.PanelPool.InUse[givenName] = nil
|
||||
DT.RegisteredPanels[givenName] = nil
|
||||
E.db.movers[panel.moverName] = nil
|
||||
end
|
||||
end
|
||||
|
||||
function DT:BuildPanelFrame(name, db, fromInit)
|
||||
db = db or E.global.datatexts.customPanels[name] or DT:Panel_DefaultGlobalSettings(name)
|
||||
|
||||
local Panel = DT:FetchFrame(name)
|
||||
Panel:ClearAllPoints()
|
||||
Panel:SetPoint('CENTER')
|
||||
Panel:SetSize(db.width, db.height)
|
||||
|
||||
local MoverName = 'DTPanel'..name..'Mover'
|
||||
Panel.moverName = MoverName
|
||||
Panel.givenName = name
|
||||
|
||||
local holder = E:GetMoverHolder(MoverName)
|
||||
if holder then
|
||||
E:SetMoverPoints(MoverName, Panel)
|
||||
else
|
||||
E:CreateMover(Panel, MoverName, name, nil, nil, nil, nil, nil, 'datatexts,panels')
|
||||
end
|
||||
|
||||
DT:RegisterPanel(Panel, db.numPoints, db.tooltipAnchor, db.tooltipXOffset, db.tooltipYOffset, db.growth == 'VERTICAL')
|
||||
|
||||
if not fromInit then
|
||||
DT:UpdatePanelAttributes(name, db)
|
||||
end
|
||||
end
|
||||
|
||||
local LDBhex, LDBna = '|cffFFFFFF', {['N/A'] = true, ['n/a'] = true, ['N/a'] = true}
|
||||
function DT:BuildPanelFunctions(name, obj)
|
||||
local panel
|
||||
|
||||
local function OnEnter(dt)
|
||||
DT.tooltip:ClearLines()
|
||||
if obj.OnTooltipShow then obj.OnTooltipShow(DT.tooltip) end
|
||||
if obj.OnEnter then obj.OnEnter(dt) end
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnLeave(dt)
|
||||
if obj.OnLeave then obj.OnLeave(dt) end
|
||||
end
|
||||
|
||||
local function OnClick(dt, button)
|
||||
if obj.OnClick then
|
||||
obj.OnClick(dt, button)
|
||||
end
|
||||
end
|
||||
|
||||
local function UpdateText(_, Name, _, Value)
|
||||
if not Value or (strlen(Value) >= 3) or (Value == Name or LDBna[Value]) then
|
||||
panel.text:SetText((not LDBna[Value] and Value) or Name)
|
||||
else
|
||||
panel.text:SetFormattedText('%s: %s%s|r', Name, LDBhex, Value)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnCallback(Hex)
|
||||
if name and obj then
|
||||
LDBhex = Hex
|
||||
LDB.callbacks:Fire('LibDataBroker_AttributeChanged_'..name..'_text', name, nil, obj.text, obj)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(dt)
|
||||
panel = dt
|
||||
LDB:RegisterCallback('LibDataBroker_AttributeChanged_'..name..'_text', UpdateText)
|
||||
LDB:RegisterCallback('LibDataBroker_AttributeChanged_'..name..'_value', UpdateText)
|
||||
OnCallback(LDBhex)
|
||||
end
|
||||
|
||||
return OnEnter, OnLeave, OnClick, OnCallback, OnEvent, UpdateText
|
||||
end
|
||||
|
||||
function DT:SetupObjectLDB(name, obj)
|
||||
local onEnter, onLeave, onClick, onCallback, onEvent = DT:BuildPanelFunctions(name, obj)
|
||||
local data = DT:RegisterDatatext(name, 'Data Broker', nil, onEvent, nil, onClick, onEnter, onLeave)
|
||||
E.valueColorUpdateFuncs[onCallback] = true
|
||||
data.isLibDataBroker = true
|
||||
|
||||
-- Update config if it has been loaded
|
||||
if DT.PanelLayoutOptions then
|
||||
DT:PanelLayoutOptions()
|
||||
end
|
||||
end
|
||||
|
||||
function DT:RegisterLDB()
|
||||
for name, obj in LDB:DataObjectIterator() do
|
||||
DT:SetupObjectLDB(name, obj)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:GetDataPanelPoint(panel, i, numPoints, vertical)
|
||||
if numPoints == 1 then
|
||||
return 'CENTER', panel, 'CENTER'
|
||||
else
|
||||
local point, relativePoint, xOffset, yOffset = 'LEFT', i == 1 and 'LEFT' or 'RIGHT', 4, 0
|
||||
if vertical then
|
||||
point, relativePoint, xOffset, yOffset = 'TOP', i == 1 and 'TOP' or 'BOTTOM', 0, -4
|
||||
end
|
||||
|
||||
local lastPanel = (i == 1 and panel) or panel.dataPanels[i - 1]
|
||||
return point, lastPanel, relativePoint, xOffset, yOffset
|
||||
end
|
||||
end
|
||||
|
||||
function DT:SetupTooltip(panel)
|
||||
local parent = panel:GetParent()
|
||||
DT.tooltip:SetOwner(panel, parent.anchor, parent.xOff, parent.yOff)
|
||||
|
||||
if not _G.GameTooltip:IsForbidden() then
|
||||
_G.GameTooltip:Hide() -- WHY??? BECAUSE FUCK GAMETOOLTIP, THATS WHY!!
|
||||
end
|
||||
end
|
||||
|
||||
function DT:RegisterPanel(panel, numPoints, anchor, xOff, yOff, vertical)
|
||||
local realName = panel:GetName()
|
||||
local name = panel.givenName or realName
|
||||
|
||||
if not name then
|
||||
E:Print('DataTexts: Requires a panel name.')
|
||||
return
|
||||
end
|
||||
|
||||
DT.RegisteredPanels[name] = panel
|
||||
|
||||
panel:SetScript('OnEnter', DT.OnEnter)
|
||||
panel:SetScript('OnLeave', DT.OnLeave)
|
||||
panel:SetScript('OnSizeChanged', DT.PanelSizeChanged)
|
||||
|
||||
panel.dataPanels = panel.dataPanels or {}
|
||||
panel.numPoints = numPoints
|
||||
panel.xOff = xOff
|
||||
panel.yOff = yOff
|
||||
panel.anchor = anchor
|
||||
panel.vertical = vertical
|
||||
end
|
||||
|
||||
function DT:Panel_DefaultGlobalSettings(name)
|
||||
local db = E:CopyTable({}, G.datatexts.newPanelInfo)
|
||||
|
||||
E.global.datatexts.customPanels[name] = db
|
||||
|
||||
return db
|
||||
end
|
||||
|
||||
function DT:AssignPanelToDataText(dt, data, event, ...)
|
||||
dt.name = data.name or '' -- This is needed for Custom Currencies
|
||||
|
||||
if data.events then
|
||||
for _, ev in pairs(data.events) do
|
||||
if data.eventFunc then
|
||||
if data.objectEvent then
|
||||
if not dt.objectEventFunc then
|
||||
dt.objectEvent = data.objectEvent
|
||||
dt.objectEventFunc = function(_, ...)
|
||||
if data.eventFunc then
|
||||
data.eventFunc(dt, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not E:HasFunctionForObject(ev, data.objectEvent, dt.objectEventFunc) then
|
||||
E:RegisterEventForObject(ev, data.objectEvent, dt.objectEventFunc)
|
||||
end
|
||||
elseif DT.UnitEvents[ev] then
|
||||
pcall(dt.RegisterUnitEvent, dt, ev, 'player')
|
||||
else
|
||||
pcall(dt.RegisterEvent, dt, ev)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ev = event or 'ELVUI_FORCE_UPDATE'
|
||||
if data.eventFunc then
|
||||
if not data.objectEvent then
|
||||
dt:SetScript('OnEvent', data.eventFunc)
|
||||
end
|
||||
|
||||
data.eventFunc(dt, ev, ...)
|
||||
end
|
||||
|
||||
if data.onUpdate then
|
||||
dt:SetScript('OnUpdate', data.onUpdate)
|
||||
data.onUpdate(dt, 20000)
|
||||
end
|
||||
|
||||
if data.onClick then
|
||||
dt:SetScript('OnClick', function(p, button)
|
||||
if E.db.datatexts.noCombatClick and InCombatLockdown() then return end
|
||||
data.onClick(p, button)
|
||||
DT.tooltip:Hide()
|
||||
end)
|
||||
end
|
||||
|
||||
if data.onEnter then
|
||||
tinsert(dt.MouseEnters, data.onEnter)
|
||||
end
|
||||
if data.onLeave then
|
||||
tinsert(dt.MouseLeaves, data.onLeave)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:ForceUpdate_DataText(name)
|
||||
for dtSlot, dtName in pairs(DT.AssignedDatatexts) do
|
||||
if dtName.name == name then
|
||||
if dtName.colorUpdate then
|
||||
dtName.colorUpdate(E.media.hexvaluecolor)
|
||||
end
|
||||
if dtName.eventFunc then
|
||||
dtName.eventFunc(dtSlot, 'ELVUI_FORCE_UPDATE')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:GetTextAttributes(panel, db)
|
||||
local panelWidth, panelHeight = panel:GetSize()
|
||||
local numPoints = db and db.numPoints or panel.numPoints or 1
|
||||
local vertical = db and db.vertical or panel.vertical
|
||||
|
||||
local width, height = (panelWidth / numPoints) - 4, panelHeight - 4
|
||||
if vertical then width, height = panelWidth - 4, (panelHeight / numPoints) - 4 end
|
||||
|
||||
return width, height, vertical, numPoints
|
||||
end
|
||||
|
||||
function DT:UpdatePanelInfo(panelName, panel, ...)
|
||||
if not panel then panel = DT.RegisteredPanels[panelName] end
|
||||
local db = panel.db or P.datatexts.panels[panelName] and DT.db.panels[panelName]
|
||||
if not db then return end
|
||||
|
||||
local info = DT.LoadedInfo
|
||||
local font, fontSize, fontOutline = info.font, info.fontSize, info.fontOutline
|
||||
if db and db.fonts and db.fonts.enable then
|
||||
font, fontSize, fontOutline = LSM:Fetch('font', db.fonts.font), db.fonts.fontSize, db.fonts.fontOutline
|
||||
end
|
||||
|
||||
local chatPanel = panelName == 'LeftChatDataPanel' or panelName == 'RightChatDataPanel'
|
||||
local battlePanel = info.isInBattle and chatPanel and (not DT.ForceHideBGStats and E.db.datatexts.battleground)
|
||||
if battlePanel then
|
||||
DT:RegisterEvent('UPDATE_BATTLEFIELD_SCORE')
|
||||
DT.ShowingBattleStats = info.instanceType
|
||||
elseif chatPanel and DT.ShowingBattleStats then
|
||||
DT:UnregisterEvent('UPDATE_BATTLEFIELD_SCORE')
|
||||
DT.ShowingBattleStats = nil
|
||||
end
|
||||
|
||||
local width, height, vertical, numPoints = DT:GetTextAttributes(panel, db)
|
||||
|
||||
for i = 1, numPoints do
|
||||
local dt = panel.dataPanels[i]
|
||||
if not dt then
|
||||
dt = CreateFrame('Button', panelName..'_DataText'..i, panel)
|
||||
dt.MouseEnters = {}
|
||||
dt.MouseLeaves = {}
|
||||
dt:RegisterForClicks('AnyUp')
|
||||
|
||||
local text = dt:CreateFontString(nil, 'ARTWORK')
|
||||
text:SetAllPoints()
|
||||
text:SetJustifyV('MIDDLE')
|
||||
dt.text = text
|
||||
DT.FontStrings[text] = true
|
||||
|
||||
local overlay = dt:CreateTexture(nil, 'OVERLAY')
|
||||
overlay:SetTexture(E.media.blankTex)
|
||||
overlay:SetVertexColor(0.3, 0.9, 0.3, .3)
|
||||
overlay:SetAllPoints()
|
||||
dt.overlay = overlay
|
||||
|
||||
panel.dataPanels[i] = dt
|
||||
end
|
||||
end
|
||||
|
||||
--Note: some plugins dont have db.border, we need the nil checks
|
||||
panel.forcedBorderColors = (db.border == false and {0,0,0,0}) or nil
|
||||
panel:SetTemplate(db.backdrop and (db.panelTransparency and 'Transparent' or 'Default') or 'NoBackdrop', true)
|
||||
|
||||
--Show Border option
|
||||
if db.border ~= nil then
|
||||
if panel.iborder then panel.iborder:SetShown(db.border) end
|
||||
if panel.oborder then panel.oborder:SetShown(db.border) end
|
||||
end
|
||||
|
||||
--Restore Panels
|
||||
for i, dt in ipairs(panel.dataPanels) do
|
||||
dt:SetShown(i <= numPoints)
|
||||
dt:SetSize(width, height)
|
||||
dt:ClearAllPoints()
|
||||
dt:SetPoint(DT:GetDataPanelPoint(panel, i, numPoints, vertical))
|
||||
dt:UnregisterAllEvents()
|
||||
dt:EnableMouseWheel(false)
|
||||
dt:SetScript('OnUpdate', nil)
|
||||
dt:SetScript('OnEvent', nil)
|
||||
dt:SetScript('OnClick', nil)
|
||||
dt:SetScript('OnEnter', DT.OnEnter)
|
||||
dt:SetScript('OnLeave', DT.OnLeave)
|
||||
wipe(dt.MouseEnters)
|
||||
wipe(dt.MouseLeaves)
|
||||
|
||||
dt.overlay:Hide()
|
||||
dt.pointIndex = i
|
||||
dt.parent = panel
|
||||
dt.parentName = panelName
|
||||
dt.battleStats = battlePanel
|
||||
dt.db = db
|
||||
|
||||
E:StopFlash(dt)
|
||||
|
||||
if dt.objectEvent and dt.objectEventFunc then
|
||||
E:UnregisterAllEventsForObject(dt.objectEvent, dt.objectEventFunc)
|
||||
dt.objectEvent, dt.objectEventFunc = nil, nil
|
||||
end
|
||||
|
||||
dt.text:FontTemplate(font, fontSize, fontOutline)
|
||||
dt.text:SetJustifyH(db.textJustify or 'CENTER')
|
||||
dt.text:SetWordWrap(DT.db.wordWrap)
|
||||
dt.text:SetText()
|
||||
|
||||
if battlePanel then
|
||||
dt:SetScript('OnClick', DT.ToggleBattleStats)
|
||||
tinsert(dt.MouseEnters, DT.HoverBattleStats)
|
||||
else
|
||||
local assigned = DT.RegisteredDataTexts[ DT.db.panels[panelName][i] ]
|
||||
DT.AssignedDatatexts[dt] = assigned
|
||||
if assigned then DT:AssignPanelToDataText(dt, assigned, ...) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:LoadDataTexts(...)
|
||||
local data = DT.LoadedInfo
|
||||
data.font, data.fontSize, data.fontOutline = LSM:Fetch('font', DT.db.font), DT.db.fontSize, DT.db.fontOutline
|
||||
data.inInstance, data.instanceType = IsInInstance()
|
||||
data.isInBattle = data.inInstance and data.instanceType == 'pvp'
|
||||
|
||||
for panel, db in pairs(E.global.datatexts.customPanels) do
|
||||
DT:UpdatePanelAttributes(panel, db, true)
|
||||
end
|
||||
|
||||
for panelName, panel in pairs(DT.RegisteredPanels) do
|
||||
local db = DT.db.panels[panelName]
|
||||
if db and db.enable then
|
||||
DT:UpdatePanelInfo(panelName, panel, ...)
|
||||
end
|
||||
end
|
||||
|
||||
if DT.ShowingBattleStats then
|
||||
DT:UPDATE_BATTLEFIELD_SCORE()
|
||||
end
|
||||
end
|
||||
|
||||
function DT:PanelSizeChanged()
|
||||
if not self.dataPanels then return end
|
||||
local db = self.db or P.datatexts.panels[self.name] and DT.db.panels[self.name]
|
||||
local width, height, vertical, numPoints = DT:GetTextAttributes(self, db)
|
||||
|
||||
for i, dt in ipairs(self.dataPanels) do
|
||||
dt:SetSize(width, height)
|
||||
dt:ClearAllPoints()
|
||||
dt:SetPoint(DT:GetDataPanelPoint(self, i, numPoints, vertical))
|
||||
end
|
||||
end
|
||||
|
||||
function DT:UpdatePanelAttributes(name, db, fromLoad)
|
||||
local Panel = DT.PanelPool.InUse[name]
|
||||
DT.OnLeave(Panel)
|
||||
|
||||
Panel.db = db
|
||||
Panel.name = name
|
||||
Panel.numPoints = db.numPoints
|
||||
Panel.xOff = db.tooltipXOffset
|
||||
Panel.yOff = db.tooltipYOffset
|
||||
Panel.anchor = db.tooltipAnchor
|
||||
Panel.vertical = db.growth == 'VERTICAL'
|
||||
Panel:SetSize(db.width, db.height)
|
||||
Panel:SetFrameStrata(db.frameStrata)
|
||||
Panel:SetFrameLevel(db.frameLevel)
|
||||
|
||||
E:UIFrameFadeIn(Panel, 0.2, Panel:GetAlpha(), db.mouseover and 0 or 1)
|
||||
|
||||
if not DT.db.panels[name] or type(DT.db.panels[name]) ~= 'table' then
|
||||
DT.db.panels[name] = { enable = false }
|
||||
end
|
||||
|
||||
for i = 1, (E.global.datatexts.customPanels[name].numPoints or 1) do
|
||||
if not DT.db.panels[name][i] then
|
||||
DT.db.panels[name][i] = ''
|
||||
end
|
||||
end
|
||||
|
||||
if DT.db.panels[name].enable then
|
||||
E:EnableMover(Panel.moverName)
|
||||
RegisterStateDriver(Panel, 'visibility', db.visibility)
|
||||
|
||||
if not fromLoad then
|
||||
DT:UpdatePanelInfo(name, Panel)
|
||||
end
|
||||
else
|
||||
DT:EmptyPanel(Panel)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:GetMenuListCategory(category)
|
||||
for i, info in ipairs(HyperList) do
|
||||
if info.text == category then
|
||||
return i
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
do
|
||||
local function menuSort(a, b)
|
||||
if a.order and b.order then
|
||||
return a.order < b.order
|
||||
end
|
||||
|
||||
return a.text < b.text
|
||||
end
|
||||
|
||||
function DT:SortMenuList(list)
|
||||
for _, menu in pairs(list) do
|
||||
if menu.menuList then
|
||||
DT:SortMenuList(menu.menuList)
|
||||
end
|
||||
end
|
||||
|
||||
sort(list, menuSort)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:HyperDT()
|
||||
if ActivateHyperMode then
|
||||
ActivateHyperMode = nil
|
||||
DT:LoadDataTexts()
|
||||
else
|
||||
ActivateHyperMode = true
|
||||
DT:EnableHyperMode()
|
||||
end
|
||||
end
|
||||
|
||||
function DT:RegisterHyperDT()
|
||||
for name, info in pairs(DT.RegisteredDataTexts) do
|
||||
local category = DT:GetMenuListCategory(info.category or MISCELLANEOUS)
|
||||
if not category then
|
||||
category = #HyperList + 1
|
||||
tinsert(HyperList, { order = 0, text = info.category or MISCELLANEOUS, notCheckable = true, hasArrow = true, menuList = {} } )
|
||||
end
|
||||
|
||||
tinsert(HyperList[category].menuList, {
|
||||
text = info.localizedName or name,
|
||||
checked = function() return DT.EasyMenu.MenuGetItem(DT.SelectedDatatext, name) end,
|
||||
func = function() DT.EasyMenu.MenuSetItem(DT.SelectedDatatext, name) end
|
||||
})
|
||||
end
|
||||
|
||||
tinsert(HyperList, {
|
||||
order = 100, text = L["NONE"],
|
||||
checked = function() return DT.EasyMenu.MenuGetItem(DT.SelectedDatatext, '') end,
|
||||
func = function() DT.EasyMenu.MenuSetItem(DT.SelectedDatatext, '') end
|
||||
})
|
||||
|
||||
DT:SortMenuList(HyperList)
|
||||
DT:RegisterEvent('MODIFIER_STATE_CHANGED', 'SingleHyperMode')
|
||||
end
|
||||
|
||||
function DT:PopulateData()
|
||||
local Collapsed = {}
|
||||
local listSize, i = C_CurrencyInfo_GetCurrencyListSize(), 1
|
||||
|
||||
local headerIndex
|
||||
while listSize >= i do
|
||||
local info = C_CurrencyInfo_GetCurrencyListInfo(i)
|
||||
if info.isHeader and not info.isHeaderExpanded then
|
||||
C_CurrencyInfo_ExpandCurrencyList(i, true)
|
||||
listSize = C_CurrencyInfo_GetCurrencyListSize()
|
||||
Collapsed[info.name] = true
|
||||
end
|
||||
if info.isHeader then
|
||||
G.datatexts.settings.Currencies.tooltipData[i] = { info.name, nil, nil, (info.name == expansion or info.name == MISCELLANEOUS) or strfind(info.name, LFG_TYPE_DUNGEON) }
|
||||
E.global.datatexts.settings.Currencies.tooltipData[i] = E.global.datatexts.settings.Currencies.tooltipData[i] or { info.name, nil, nil, G.datatexts.settings.Currencies.tooltipData[i][4] }
|
||||
E.global.datatexts.settings.Currencies.tooltipData[i][1] = info.name
|
||||
|
||||
headerIndex = i
|
||||
end
|
||||
if not info.isHeader then
|
||||
local currencyLink = C_CurrencyInfo_GetCurrencyListLink(i)
|
||||
local currencyID = currencyLink and C_CurrencyInfo_GetCurrencyIDFromLink(currencyLink)
|
||||
if currencyID then
|
||||
DT.CurrencyList[tostring(currencyID)] = info.name
|
||||
G.datatexts.settings.Currencies.tooltipData[i] = { info.name, currencyID, headerIndex, G.datatexts.settings.Currencies.tooltipData[headerIndex][4] }
|
||||
E.global.datatexts.settings.Currencies.tooltipData[i] = E.global.datatexts.settings.Currencies.tooltipData[i] or { info.name, currencyID, headerIndex, G.datatexts.settings.Currencies.tooltipData[headerIndex][4] }
|
||||
E.global.datatexts.settings.Currencies.tooltipData[i][1] = info.name
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
||||
for k = 1, listSize do
|
||||
local info = C_CurrencyInfo_GetCurrencyListInfo(k)
|
||||
if not info then
|
||||
break
|
||||
elseif info.isHeader and info.isHeaderExpanded and Collapsed[info.name] then
|
||||
C_CurrencyInfo_ExpandCurrencyList(k, false)
|
||||
end
|
||||
end
|
||||
|
||||
wipe(Collapsed)
|
||||
|
||||
for index = 1, GetNumSpecializations() do
|
||||
local id, name, _, icon, _, statID = GetSpecializationInfo(index)
|
||||
|
||||
if id then
|
||||
DT.SPECIALIZATION_CACHE[index] = { id = id, name = name, icon = icon, statID = statID }
|
||||
DT.SPECIALIZATION_CACHE[id] = { name = name, icon = icon }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:CURRENCY_DISPLAY_UPDATE(_, currencyType)
|
||||
if currencyType and not DT.CurrencyList[tostring(currencyType)] then
|
||||
local info = C_CurrencyInfo_GetCurrencyInfo(currencyType)
|
||||
if info and info.name then
|
||||
DT.CurrencyList[tostring(currencyType)] = info.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:PLAYER_ENTERING_WORLD()
|
||||
DT:LoadDataTexts()
|
||||
end
|
||||
|
||||
function DT:Initialize()
|
||||
DT.Initialized = true
|
||||
DT.db = E.db.datatexts
|
||||
|
||||
DT.EasyMenu:SetClampedToScreen(true)
|
||||
DT.EasyMenu:EnableMouse(true)
|
||||
DT.EasyMenu.MenuSetItem = function(dt, value)
|
||||
DT.db.panels[dt.parentName][dt.pointIndex] = value
|
||||
DT:UpdatePanelInfo(dt.parentName, dt.parent)
|
||||
|
||||
if ActivateHyperMode then
|
||||
DT:EnableHyperMode(dt.parent)
|
||||
end
|
||||
|
||||
DT.SelectedDatatext = nil
|
||||
CloseDropDownMenus()
|
||||
end
|
||||
DT.EasyMenu.MenuGetItem = function(dt, value)
|
||||
return dt and (DT.db.panels[dt.parentName] and DT.db.panels[dt.parentName][dt.pointIndex] == value)
|
||||
end
|
||||
|
||||
if E.private.skins.blizzard.enable and E.private.skins.blizzard.tooltip then
|
||||
TT:SetStyle(DT.tooltip)
|
||||
end
|
||||
|
||||
-- Ignore header font size on DatatextTooltip
|
||||
local font = LSM:Fetch('font', E.db.tooltip.font)
|
||||
local fontOutline = E.db.tooltip.fontOutline
|
||||
local textSize = E.db.tooltip.textFontSize
|
||||
_G.DataTextTooltipTextLeft1:FontTemplate(font, textSize, fontOutline)
|
||||
_G.DataTextTooltipTextRight1:FontTemplate(font, textSize, fontOutline)
|
||||
|
||||
LDB.RegisterCallback(E, 'LibDataBroker_DataObjectCreated', DT.SetupObjectLDB)
|
||||
DT:RegisterLDB() -- LibDataBroker
|
||||
DT:RegisterCustomCurrencyDT() -- Register all the user created currency datatexts from the 'CustomCurrency' DT.
|
||||
|
||||
for name, db in pairs(E.global.datatexts.customPanels) do
|
||||
DT:BuildPanelFrame(name, db, true)
|
||||
end
|
||||
|
||||
do -- we need to register the panels to access them for the text
|
||||
DT.BattleStats.LEFT.panel = _G.LeftChatDataPanel.dataPanels
|
||||
DT.BattleStats.RIGHT.panel = _G.RightChatDataPanel.dataPanels
|
||||
end
|
||||
|
||||
DT:PopulateData()
|
||||
DT:RegisterHyperDT()
|
||||
DT:RegisterEvent('PLAYER_ENTERING_WORLD')
|
||||
DT:RegisterEvent('CURRENCY_DISPLAY_UPDATE')
|
||||
end
|
||||
|
||||
--[[
|
||||
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc, onLeaveFunc, localizedName)
|
||||
|
||||
name - name of the datatext (required)
|
||||
category - name of the category the datatext belongs to.
|
||||
events - must be a table with string values of event names to register
|
||||
eventFunc - function that gets fired when an event gets triggered
|
||||
updateFunc - onUpdate script target function
|
||||
click - function to fire when clicking the datatext
|
||||
onEnterFunc - function to fire OnEnter
|
||||
onLeaveFunc - function to fire OnLeave, if not provided one will be set for you that hides the tooltip.
|
||||
localizedName - localized name of the datetext
|
||||
objectEvent - register events on an object, using E.RegisterEventForObject instead of panel.RegisterEvent
|
||||
colorUpdate - function that fires when called from the config when you change the dt options.
|
||||
]]
|
||||
function DT:RegisterDatatext(name, category, events, eventFunc, updateFunc, clickFunc, onEnterFunc, onLeaveFunc, localizedName, objectEvent, colorUpdate)
|
||||
if not name then return end
|
||||
if type(category) ~= 'string' and category ~= nil then return E:Print(format('%s is an invalid DataText.', name)) end
|
||||
|
||||
local data = { name = name, category = category }
|
||||
|
||||
if type(events) == 'function' then
|
||||
return E:Print(format('%s is an invalid DataText. Events must be registered as a table or a string.', name))
|
||||
else
|
||||
data.events = type(events) == 'string' and { strsplit('[, ]', events) } or events
|
||||
data.eventFunc = eventFunc
|
||||
data.objectEvent = objectEvent
|
||||
end
|
||||
|
||||
if updateFunc and type(updateFunc) == 'function' then
|
||||
data.onUpdate = updateFunc
|
||||
end
|
||||
|
||||
if clickFunc and type(clickFunc) == 'function' then
|
||||
data.onClick = clickFunc
|
||||
end
|
||||
|
||||
if onEnterFunc and type(onEnterFunc) == 'function' then
|
||||
data.onEnter = onEnterFunc
|
||||
end
|
||||
|
||||
if onLeaveFunc and type(onLeaveFunc) == 'function' then
|
||||
data.onLeave = onLeaveFunc
|
||||
end
|
||||
|
||||
if localizedName and type(localizedName) == 'string' then
|
||||
data.localizedName = localizedName
|
||||
end
|
||||
|
||||
if colorUpdate and type(colorUpdate) == 'function' then
|
||||
data.colorUpdate = colorUpdate
|
||||
end
|
||||
|
||||
DT.RegisteredDataTexts[name] = data
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
E:RegisterModule(DT:GetName())
|
||||
30
Modules/DataTexts/Date.lua
Normal file
30
Modules/DataTexts/Date.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local date = date
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local FormatShortDate = FormatShortDate
|
||||
|
||||
local hexColor, lastPanel
|
||||
|
||||
local function OnClick()
|
||||
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
|
||||
_G.GameTimeFrame:Click()
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local dateTable = date('*t')
|
||||
|
||||
self.text:SetText(FormatShortDate(dateTable.day, dateTable.month, dateTable.year):gsub('([/.])', hexColor..'%1|r'))
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
hexColor = hex
|
||||
|
||||
if lastPanel ~= nil then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Date', nil, {'UPDATE_INSTANCE_INFO'}, OnEvent, nil, OnClick, nil, nil, nil, nil, ValueColorUpdate)
|
||||
142
Modules/DataTexts/Difficulty.lua
Normal file
142
Modules/DataTexts/Difficulty.lua
Normal file
@@ -0,0 +1,142 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local pairs = pairs
|
||||
local format = format
|
||||
local GetDungeonDifficultyID, GetRaidDifficultyID, GetLegacyRaidDifficultyID = GetDungeonDifficultyID, GetRaidDifficultyID, GetLegacyRaidDifficultyID
|
||||
local SetDungeonDifficultyID, SetRaidDifficultyID, SetLegacyRaidDifficultyID = SetDungeonDifficultyID, SetRaidDifficultyID, SetLegacyRaidDifficultyID
|
||||
local GetInstanceInfo, GetDifficultyInfo, ResetInstances = GetInstanceInfo, GetDifficultyInfo, ResetInstances
|
||||
local C_ChallengeMode_GetActiveChallengeMapID = C_ChallengeMode.GetActiveChallengeMapID
|
||||
local C_ChallengeMode_GetActiveKeystoneInfo = C_ChallengeMode.GetActiveKeystoneInfo
|
||||
local C_ChallengeMode_IsChallengeModeActive = C_ChallengeMode.IsChallengeModeActive
|
||||
local C_MythicPlus_IsMythicPlusActive = C_MythicPlus.IsMythicPlusActive
|
||||
|
||||
local DungeonTexture, RaidTexture, LegacyTexture = CreateAtlasMarkup('Dungeon', 20, 20), CreateAtlasMarkup('Raid', 20, 20), CreateAtlasMarkup('worldquest-icon-raid', 20, 20)
|
||||
local DungeonDifficultyID, RaidDifficultyID, LegacyRaidDifficultyID = GetDungeonDifficultyID(), GetRaidDifficultyID(), GetLegacyRaidDifficultyID()
|
||||
|
||||
local RightClickMenu, DiffLabel = {
|
||||
{ text = _G.DUNGEON_DIFFICULTY, isTitle = true, notCheckable = true },
|
||||
{ text = _G.PLAYER_DIFFICULTY1, checked = function() return GetDungeonDifficultyID() == 1 end, func = function() SetDungeonDifficultyID(1) end },
|
||||
{ text = _G.PLAYER_DIFFICULTY2, checked = function() return GetDungeonDifficultyID() == 2 end, func = function() SetDungeonDifficultyID(2) end },
|
||||
{ text = _G.PLAYER_DIFFICULTY6, checked = function() return GetDungeonDifficultyID() == 23 end, func = function() SetDungeonDifficultyID(23) end },
|
||||
{ text = '', isTitle = true, notCheckable = true };
|
||||
{ text = _G.RAID_DIFFICULTY, isTitle = true, notCheckable = true},
|
||||
{ text = _G.PLAYER_DIFFICULTY1, checked = function() return GetRaidDifficultyID() == 14 end, func = function() SetRaidDifficultyID(14) end },
|
||||
{ text = _G.PLAYER_DIFFICULTY2, checked = function() return GetRaidDifficultyID() == 15 end, func = function() SetRaidDifficultyID(15) end },
|
||||
{ text = _G.PLAYER_DIFFICULTY6, checked = function() return GetRaidDifficultyID() == 16 end, func = function() SetRaidDifficultyID(16) end },
|
||||
{ text = '', isTitle = true, notCheckable = true };
|
||||
{ text = _G.UNIT_FRAME_DROPDOWN_SUBSECTION_TITLE_LEGACY_RAID, isTitle = true, notCheckable = true },
|
||||
{ text = _G.RAID_DIFFICULTY1, checked = function() return GetLegacyRaidDifficultyID() == 3 end, func = function() SetLegacyRaidDifficultyID(3) end },
|
||||
{ text = _G.RAID_DIFFICULTY1..' '.._G.PLAYER_DIFFICULTY2, checked = function() return GetLegacyRaidDifficultyID() == 5 end, func = function() SetLegacyRaidDifficultyID(5) end },
|
||||
{ text = _G.RAID_DIFFICULTY2, checked = function() return GetLegacyRaidDifficultyID() == 4 end, func = function() SetLegacyRaidDifficultyID(4) end },
|
||||
{ text = _G.RAID_DIFFICULTY2..' '.._G.PLAYER_DIFFICULTY2, checked = function() return GetLegacyRaidDifficultyID() == 6 end, func = function() SetLegacyRaidDifficultyID(6) end },
|
||||
{ text = '', isTitle = true, notCheckable = true };
|
||||
{ text = _G.RESET_INSTANCES, notCheckable = true, func = function() ResetInstances() end},
|
||||
}, {}
|
||||
|
||||
|
||||
for i = 1, 200 do
|
||||
if GetDifficultyInfo(i) then
|
||||
local Name = GetDifficultyInfo(i)
|
||||
if not DiffLabel[i] then DiffLabel[i] = Name end
|
||||
end
|
||||
end
|
||||
|
||||
local DiffIDLabel = {
|
||||
['N'] = { 1, 14, 38 },
|
||||
['H'] = { 2, 15, 39 },
|
||||
['M'] = { 16, 23, 40 },
|
||||
['10N'] = { 3 },
|
||||
['25N'] = { 4 },
|
||||
['10H'] = { 5 },
|
||||
['25H'] = { 6 },
|
||||
['LFR'] = { 7, 17 },
|
||||
['CM'] = { 8 },
|
||||
['40'] = { 9 },
|
||||
['TW'] = { 24, 33, 151 },
|
||||
['S'] = { 11, 12, 20, 152, 153 },
|
||||
['E'] = { 18, 19, 30 },
|
||||
['PvP'] = { 25, 29, 32, 34, 45 },
|
||||
['WF'] = { 147 },
|
||||
['WFH'] = { 149 },
|
||||
}
|
||||
|
||||
local IDTexture = {
|
||||
LEGACY = { 3, 4, 5, 6, 9 },
|
||||
RAID = { 14, 15, 16 },
|
||||
}
|
||||
|
||||
local Garrison = {
|
||||
[1152] = true,
|
||||
[1330] = true,
|
||||
[1153] = true,
|
||||
[1154] = true,
|
||||
[1158] = true,
|
||||
[1331] = true,
|
||||
[1159] = true,
|
||||
[1160] = true,
|
||||
}
|
||||
|
||||
local function GetDiffIDLabel(ID)
|
||||
for Name, Info in pairs(DiffIDLabel) do
|
||||
for _, Num in pairs(Info) do
|
||||
if Num == ID then
|
||||
return Name
|
||||
end
|
||||
end
|
||||
end
|
||||
return ID
|
||||
end
|
||||
|
||||
local function GetLabelTexture(ID)
|
||||
for Name, Info in pairs(IDTexture) do
|
||||
for _, Num in pairs(Info) do
|
||||
if Num == ID then
|
||||
return Name == 'LEGACY' and LegacyTexture or RaidTexture
|
||||
end
|
||||
end
|
||||
end
|
||||
return DungeonTexture
|
||||
end
|
||||
|
||||
local function OnClick(self)
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(RightClickMenu, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local name, instanceType, difficultyID, _, _, _, _, instanceID = GetInstanceInfo()
|
||||
local keyStoneLevel = C_MythicPlus_IsMythicPlusActive() and C_ChallengeMode_GetActiveChallengeMapID() and C_ChallengeMode_IsChallengeModeActive() and C_ChallengeMode_GetActiveKeystoneInfo()
|
||||
|
||||
if keyStoneLevel then
|
||||
self.text:SetFormattedText('%s %s +%s', GetLabelTexture(difficultyID), name, keyStoneLevel)
|
||||
elseif instanceType ~= 'none' and difficultyID and not Garrison[instanceID] then
|
||||
self.text:SetFormattedText('%s %s %s', GetLabelTexture(difficultyID), name, GetDiffIDLabel(difficultyID))
|
||||
else
|
||||
DungeonDifficultyID, RaidDifficultyID, LegacyRaidDifficultyID = GetDungeonDifficultyID(), GetRaidDifficultyID(), GetLegacyRaidDifficultyID()
|
||||
self.text:SetFormattedText('%s %s %s %s %s %s', DungeonTexture, GetDiffIDLabel(DungeonDifficultyID), RaidTexture, GetDiffIDLabel(RaidDifficultyID), LegacyTexture, GetDiffIDLabel(LegacyRaidDifficultyID))
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
if not (DungeonDifficultyID or RaidDifficultyID or LegacyRaidDifficultyID) then return end
|
||||
|
||||
DT.tooltip:ClearLines()
|
||||
DT.tooltip:SetText(L["Current Difficulties:"])
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
if DungeonDifficultyID then
|
||||
DT.tooltip:AddLine(format('%s %s', DungeonTexture, DiffLabel[DungeonDifficultyID]), 1, 1, 1)
|
||||
end
|
||||
if RaidDifficultyID then
|
||||
DT.tooltip:AddLine(format('%s %s', RaidTexture, DiffLabel[RaidDifficultyID]), 1, 1, 1)
|
||||
end
|
||||
if LegacyRaidDifficultyID then
|
||||
DT.tooltip:AddLine(format('%s %s', LegacyTexture, DiffLabel[LegacyRaidDifficultyID]), 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Difficulty', nil, {'CHAT_MSG_SYSTEM', 'LOADING_SCREEN_DISABLED'}, OnEvent, nil, OnClick, OnEnter, nil, 'Difficulty')
|
||||
87
Modules/DataTexts/Durability.lua
Normal file
87
Modules/DataTexts/Durability.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local select = select
|
||||
local wipe = wipe
|
||||
local format, pairs = format, pairs
|
||||
local GetInventoryItemDurability = GetInventoryItemDurability
|
||||
local ToggleCharacter = ToggleCharacter
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local GetInventoryItemTexture = GetInventoryItemTexture
|
||||
local GetInventoryItemLink = GetInventoryItemLink
|
||||
local GetMoneyString = GetMoneyString
|
||||
|
||||
local DURABILITY = DURABILITY
|
||||
local REPAIR_COST = REPAIR_COST
|
||||
local displayString = DURABILITY..': %s%d%%|r'
|
||||
local tooltipString = '%d%%'
|
||||
local totalDurability = 0
|
||||
local invDurability = {}
|
||||
local totalRepairCost
|
||||
|
||||
local slots = {
|
||||
[1] = _G.INVTYPE_HEAD,
|
||||
[3] = _G.INVTYPE_SHOULDER,
|
||||
[5] = _G.INVTYPE_CHEST,
|
||||
[6] = _G.INVTYPE_WAIST,
|
||||
[7] = _G.INVTYPE_LEGS,
|
||||
[8] = _G.INVTYPE_FEET,
|
||||
[9] = _G.INVTYPE_WRIST,
|
||||
[10] = _G.INVTYPE_HAND,
|
||||
[16] = _G.INVTYPE_WEAPONMAINHAND,
|
||||
[17] = _G.INVTYPE_WEAPONOFFHAND,
|
||||
}
|
||||
|
||||
local function OnEvent(self)
|
||||
totalDurability = 100
|
||||
totalRepairCost = 0
|
||||
|
||||
wipe(invDurability)
|
||||
|
||||
for index in pairs(slots) do
|
||||
local currentDura, maxDura = GetInventoryItemDurability(index)
|
||||
if currentDura and maxDura > 0 then
|
||||
local perc = (currentDura/maxDura)*100
|
||||
invDurability[index] = perc
|
||||
|
||||
if perc < totalDurability then
|
||||
totalDurability = perc
|
||||
end
|
||||
|
||||
totalRepairCost = totalRepairCost + select(3, E.ScanTooltip:SetInventoryItem('player', index))
|
||||
end
|
||||
end
|
||||
|
||||
local r, g, b = E:ColorGradient(totalDurability * .01, 1, .1, .1, 1, 1, .1, .1, 1, .1)
|
||||
local hex = E:RGBToHex(r, g, b)
|
||||
self.text:SetFormattedText(displayString, hex, totalDurability)
|
||||
|
||||
if totalDurability <= E.global.datatexts.settings.Durability.percThreshold then
|
||||
E:Flash(self, 0.53, true)
|
||||
else
|
||||
E:StopFlash(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function Click()
|
||||
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
|
||||
ToggleCharacter('PaperDollFrame')
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
for slot, durability in pairs(invDurability) do
|
||||
DT.tooltip:AddDoubleLine(format('|T%s:14:14:0:0:64:64:4:60:4:60|t %s', GetInventoryItemTexture('player', slot), GetInventoryItemLink('player', slot)), format(tooltipString, durability), 1, 1, 1, E:ColorGradient(durability * 0.01, 1, .1, .1, 1, 1, .1, .1, 1, .1))
|
||||
end
|
||||
|
||||
if totalRepairCost > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddDoubleLine(REPAIR_COST, GetMoneyString(totalRepairCost), .6, .8, 1, 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Durability', nil, {'UPDATE_INVENTORY_DURABILITY', 'MERCHANT_SHOW'}, OnEvent, nil, Click, OnEnter, nil, DURABILITY)
|
||||
80
Modules/DataTexts/Experience.lua
Normal file
80
Modules/DataTexts/Experience.lua
Normal file
@@ -0,0 +1,80 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local format = format
|
||||
local UnitXP, UnitXPMax = UnitXP, UnitXPMax
|
||||
local IsXPUserDisabled, GetXPExhaustion = IsXPUserDisabled, GetXPExhaustion
|
||||
local IsPlayerAtEffectiveMaxLevel = IsPlayerAtEffectiveMaxLevel
|
||||
|
||||
local CurrentXP, XPToLevel, RestedXP, PercentRested
|
||||
local PercentXP, RemainXP, RemainTotal, RemainBars
|
||||
|
||||
local function OnEvent(self)
|
||||
local displayString = ''
|
||||
if IsXPUserDisabled() then
|
||||
displayString = L["Disabled"]
|
||||
elseif IsPlayerAtEffectiveMaxLevel() then
|
||||
displayString = L["Max Level"]
|
||||
else
|
||||
CurrentXP, XPToLevel, RestedXP = UnitXP('player'), UnitXPMax('player'), GetXPExhaustion()
|
||||
if XPToLevel <= 0 then XPToLevel = 1 end
|
||||
|
||||
local remainXP = XPToLevel - CurrentXP
|
||||
local remainPercent = remainXP / XPToLevel
|
||||
|
||||
-- values we also use in OnEnter
|
||||
RemainTotal, RemainBars = remainPercent * 100, remainPercent * 20
|
||||
PercentXP, RemainXP = (CurrentXP / XPToLevel) * 100, E:ShortValue(remainXP)
|
||||
|
||||
local textFormat = E.global.datatexts.settings.Experience.textFormat
|
||||
if textFormat == 'PERCENT' then
|
||||
displayString = format('%.2f%%', PercentXP)
|
||||
elseif textFormat == 'CURMAX' then
|
||||
displayString = format('%s - %s', E:ShortValue(CurrentXP), E:ShortValue(XPToLevel))
|
||||
elseif textFormat == 'CURPERC' then
|
||||
displayString = format('%s - %.2f%%', E:ShortValue(CurrentXP), PercentXP)
|
||||
elseif textFormat == 'CUR' then
|
||||
displayString = format('%s', E:ShortValue(CurrentXP))
|
||||
elseif textFormat == 'REM' then
|
||||
displayString = format('%s', RemainXP)
|
||||
elseif textFormat == 'CURREM' then
|
||||
displayString = format('%s - %s', E:ShortValue(CurrentXP), RemainXP)
|
||||
elseif textFormat == 'CURPERCREM' then
|
||||
displayString = format('%s - %.2f%% (%s)', E:ShortValue(CurrentXP), PercentXP, RemainXP)
|
||||
end
|
||||
|
||||
if RestedXP and RestedXP > 0 then
|
||||
PercentRested = (RestedXP / XPToLevel) * 100
|
||||
|
||||
if textFormat == 'PERCENT' then
|
||||
displayString = format('%s R:%.2f%%', displayString, PercentRested)
|
||||
elseif textFormat == 'CURPERC' then
|
||||
displayString = format('%s R:%s [%.2f%%]', displayString, E:ShortValue(RestedXP), PercentRested)
|
||||
elseif textFormat ~= 'NONE' then
|
||||
displayString = format('%s R:%s', displayString, E:ShortValue(RestedXP))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.text:SetText(displayString)
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
if IsXPUserDisabled() or IsPlayerAtEffectiveMaxLevel() then return end
|
||||
|
||||
DT.tooltip:ClearLines()
|
||||
DT.tooltip:AddLine(L["Experience"])
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["XP:"], format(' %d / %d (%.2f%%)', CurrentXP, XPToLevel, PercentXP), 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(L["Remaining:"], format(' %s (%.2f%% - %d '..L["Bars"]..')', RemainXP, RemainTotal, RemainBars), 1, 1, 1)
|
||||
|
||||
if RestedXP and RestedXP > 0 then
|
||||
DT.tooltip:AddDoubleLine(L["Rested:"], format('+%d (%.2f%%)', RestedXP, PercentRested), 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Experience', nil, {'PLAYER_XP_UPDATE', 'DISABLE_XP_GAIN', 'ENABLE_XP_GAIN', 'UPDATE_EXHAUSTION'}, OnEvent, nil, nil, OnEnter, nil, _G.COMBAT_XP_GAIN)
|
||||
589
Modules/DataTexts/Friends.lua
Normal file
589
Modules/DataTexts/Friends.lua
Normal file
@@ -0,0 +1,589 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local type, ipairs, pairs, select = type, ipairs, pairs, select
|
||||
local sort, next, wipe, tremove, tinsert = sort, next, wipe, tremove, tinsert
|
||||
local format, gsub, strfind, strjoin, strmatch = format, gsub, strfind, strjoin, strmatch
|
||||
|
||||
local BNet_GetValidatedCharacterName = BNet_GetValidatedCharacterName
|
||||
local GetMouseFocus = GetMouseFocus
|
||||
local BNGetInfo = BNGetInfo
|
||||
local BNGetNumFriends = BNGetNumFriends
|
||||
local BNInviteFriend = BNInviteFriend
|
||||
local BNRequestInviteFriend = BNRequestInviteFriend
|
||||
local BNSetCustomMessage = BNSetCustomMessage
|
||||
local GetDisplayedInviteType = GetDisplayedInviteType
|
||||
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
||||
local IsChatAFK = IsChatAFK
|
||||
local IsChatDND = IsChatDND
|
||||
local IsAltKeyDown = IsAltKeyDown
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local SendChatMessage = SendChatMessage
|
||||
local SetItemRef = SetItemRef
|
||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local C_FriendList_GetNumFriends = C_FriendList.GetNumFriends
|
||||
local C_FriendList_GetNumOnlineFriends = C_FriendList.GetNumOnlineFriends
|
||||
local C_FriendList_GetFriendInfoByIndex = C_FriendList.GetFriendInfoByIndex
|
||||
local ChatFrame_SendBNetTell = ChatFrame_SendBNetTell
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local C_BattleNet_GetFriendAccountInfo = C_BattleNet.GetFriendAccountInfo
|
||||
local C_BattleNet_GetFriendNumGameAccounts = C_BattleNet.GetFriendNumGameAccounts
|
||||
local C_BattleNet_GetFriendGameAccountInfo = C_BattleNet.GetFriendGameAccountInfo
|
||||
local C_PartyInfo_RequestInviteFromUnit = C_PartyInfo.RequestInviteFromUnit
|
||||
local C_PartyInfo_InviteUnit = C_PartyInfo.InviteUnit
|
||||
local PRIEST_COLOR = RAID_CLASS_COLORS.PRIEST
|
||||
|
||||
-- create a popup
|
||||
E.PopupDialogs.SET_BN_BROADCAST = {
|
||||
text = _G.BN_BROADCAST_TOOLTIP,
|
||||
button1 = _G.ACCEPT,
|
||||
button2 = _G.CANCEL,
|
||||
hasEditBox = 1,
|
||||
editBoxWidth = 350,
|
||||
maxLetters = 127,
|
||||
OnAccept = function(self) BNSetCustomMessage(self.editBox:GetText()) end,
|
||||
OnShow = function(self) self.editBox:SetText(select(4, BNGetInfo()) ) self.editBox:SetFocus() end,
|
||||
OnHide = _G.ChatEdit_FocusActiveWindow,
|
||||
EditBoxOnEnterPressed = function(self) BNSetCustomMessage(self:GetText()) self:GetParent():Hide() end,
|
||||
EditBoxOnEscapePressed = function(self) self:GetParent():Hide() end,
|
||||
timeout = 0,
|
||||
exclusive = 1,
|
||||
whileDead = 1,
|
||||
hideOnEscape = 1,
|
||||
preferredIndex = 3
|
||||
}
|
||||
|
||||
local menuList = {
|
||||
{ text = _G.OPTIONS_MENU, isTitle = true, notCheckable=true},
|
||||
{ text = _G.INVITE, hasArrow = true, notCheckable=true, },
|
||||
{ text = _G.CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable=true, },
|
||||
{ text = _G.PLAYER_STATUS, hasArrow = true, notCheckable=true,
|
||||
menuList = {
|
||||
{ text = '|cff2BC226'.._G.AVAILABLE..'|r', notCheckable=true, func = function() if IsChatAFK() then SendChatMessage('', 'AFK') elseif IsChatDND() then SendChatMessage('', 'DND') end end },
|
||||
{ text = '|cffE7E716'.._G.DND..'|r', notCheckable=true, func = function() if not IsChatDND() then SendChatMessage('', 'DND') end end },
|
||||
{ text = '|cffFF0000'.._G.AFK..'|r', notCheckable=true, func = function() if not IsChatAFK() then SendChatMessage('', 'AFK') end end },
|
||||
},
|
||||
},
|
||||
{ text = _G.BN_BROADCAST_TOOLTIP, notCheckable=true, func = function() E:StaticPopup_Show('SET_BN_BROADCAST') end },
|
||||
}
|
||||
|
||||
local function inviteClick(_, name, guid)
|
||||
DT.EasyMenu:Hide()
|
||||
|
||||
if not (name and name ~= '') then return end
|
||||
local isBNet = type(name) == 'number'
|
||||
|
||||
if guid then
|
||||
local inviteType = GetDisplayedInviteType(guid)
|
||||
if inviteType == 'INVITE' or inviteType == 'SUGGEST_INVITE' then
|
||||
if isBNet then
|
||||
BNInviteFriend(name)
|
||||
else
|
||||
C_PartyInfo_InviteUnit(name)
|
||||
end
|
||||
elseif inviteType == 'REQUEST_INVITE' then
|
||||
if isBNet then
|
||||
BNRequestInviteFriend(name)
|
||||
else
|
||||
C_PartyInfo_RequestInviteFromUnit(name)
|
||||
end
|
||||
end
|
||||
else
|
||||
-- if for some reason guid isnt here fallback and just try to invite them
|
||||
-- this is unlikely but having a fallback doesnt hurt
|
||||
if isBNet then
|
||||
BNInviteFriend(name)
|
||||
else
|
||||
C_PartyInfo_InviteUnit(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function whisperClick(_, name, battleNet)
|
||||
DT.EasyMenu:Hide()
|
||||
|
||||
if battleNet then
|
||||
ChatFrame_SendBNetTell(name)
|
||||
else
|
||||
SetItemRef( 'player:'..name, format('|Hplayer:%1$s|h[%1$s]|h',name), 'LeftButton' )
|
||||
end
|
||||
end
|
||||
|
||||
local levelNameString = '|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r'
|
||||
local levelNameClassString = '|cff%02x%02x%02x%d|r %s%s%s'
|
||||
local characterFriend = _G.CHARACTER_FRIEND
|
||||
local battleNetString = _G.BATTLENET_OPTIONS_LABEL
|
||||
local totalOnlineString = strjoin('', _G.FRIENDS_LIST_ONLINE, ': %s/%s')
|
||||
local tthead = {r=0.4, g=0.78, b=1}
|
||||
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
|
||||
local displayString = ''
|
||||
local friendTable, BNTable, tableList = {}, {}, {}
|
||||
local friendOnline, friendOffline = gsub(_G.ERR_FRIEND_ONLINE_SS,'\124Hplayer:%%s\124h%[%%s%]\124h',''), gsub(_G.ERR_FRIEND_OFFLINE_S,'%%s','')
|
||||
local wowString = _G.BNET_CLIENT_WOW
|
||||
local retailID = _G.WOW_PROJECT_ID
|
||||
local WOW_CLASSIC = _G.BNET_FRIEND_TOOLTIP_WOW_CLASSIC
|
||||
local dataValid, lastPanel = false
|
||||
local statusTable = {
|
||||
AFK = ' |cffFFFFFF[|r|cffFF9900'..L["AFK"]..'|r|cffFFFFFF]|r',
|
||||
DND = ' |cffFFFFFF[|r|cffFF3333'..L["DND"]..'|r|cffFFFFFF]|r'
|
||||
}
|
||||
|
||||
-- Makro for get the client: /run for i,v in pairs(_G) do if type(i)=='string' and i:match('BNET_CLIENT_') then print(i,'=',v) end end
|
||||
local clientSorted = {}
|
||||
local clientTags = {
|
||||
[_G.BNET_CLIENT_WOW] = 'WoW',
|
||||
[_G.BNET_CLIENT_D3] = 'D3',
|
||||
[_G.BNET_CLIENT_WTCG] = 'HS',
|
||||
[_G.BNET_CLIENT_HEROES] = 'HotS',
|
||||
[_G.BNET_CLIENT_OVERWATCH] = 'OW',
|
||||
[_G.BNET_CLIENT_SC] = 'SC',
|
||||
[_G.BNET_CLIENT_SC2] = 'SC2',
|
||||
[_G.BNET_CLIENT_COD] = 'BO4',
|
||||
[_G.BNET_CLIENT_COD_MW] = 'MW',
|
||||
[_G.BNET_CLIENT_COD_MW2] = 'MW2',
|
||||
[_G.BNET_CLIENT_COD_BOCW] = 'CW',
|
||||
BSAp = L["Mobile"],
|
||||
}
|
||||
|
||||
local clientIndex = {
|
||||
[_G.BNET_CLIENT_WOW] = 1,
|
||||
[_G.BNET_CLIENT_D3] = 2,
|
||||
[_G.BNET_CLIENT_WTCG] = 3,
|
||||
[_G.BNET_CLIENT_HEROES] = 4,
|
||||
[_G.BNET_CLIENT_OVERWATCH] = 5,
|
||||
[_G.BNET_CLIENT_SC] = 6,
|
||||
[_G.BNET_CLIENT_SC2] = 7,
|
||||
[_G.BNET_CLIENT_COD] = 8,
|
||||
[_G.BNET_CLIENT_COD_MW] = 9,
|
||||
[_G.BNET_CLIENT_COD_MW2] = 10,
|
||||
[_G.BNET_CLIENT_COD_BOCW] = 11,
|
||||
App = 12,
|
||||
BSAp = 13,
|
||||
}
|
||||
|
||||
local function inGroup(name, realmName)
|
||||
if realmName and realmName ~= '' and realmName ~= E.myrealm then
|
||||
name = name..'-'..realmName
|
||||
end
|
||||
|
||||
return (UnitInParty(name) or UnitInRaid(name)) and '|cffaaaaaa*|r' or ''
|
||||
end
|
||||
|
||||
local function SortAlphabeticName(a, b)
|
||||
if a.name and b.name then
|
||||
return a.name < b.name
|
||||
end
|
||||
end
|
||||
|
||||
local function BuildFriendTable(total)
|
||||
wipe(friendTable)
|
||||
for i = 1, total do
|
||||
local info = C_FriendList_GetFriendInfoByIndex(i)
|
||||
if info and info.connected then
|
||||
local className = E:UnlocalizedClassName(info.className) or ''
|
||||
local status = (info.afk and statusTable.AFK) or (info.dnd and statusTable.DND) or ''
|
||||
friendTable[i] = {
|
||||
name = info.name, --1
|
||||
level = info.level, --2
|
||||
class = className, --3
|
||||
zone = info.area, --4
|
||||
online = info.connected, --5
|
||||
status = status, --6
|
||||
notes = info.notes, --7
|
||||
guid = info.guid --8
|
||||
}
|
||||
end
|
||||
end
|
||||
if next(friendTable) then
|
||||
sort(friendTable, SortAlphabeticName)
|
||||
end
|
||||
end
|
||||
|
||||
--Sort: client-> (WoW: project-> faction-> name) ELSE:btag
|
||||
local function Sort(a, b)
|
||||
if a.client and b.client then
|
||||
if (a.client == b.client) then
|
||||
if (a.client == wowString) and a.wowProjectID and b.wowProjectID then
|
||||
if (a.wowProjectID == b.wowProjectID) and a.faction and b.faction then
|
||||
if (a.faction == b.faction) and a.characterName and b.characterName then
|
||||
return a.characterName < b.characterName
|
||||
end
|
||||
return a.faction < b.faction
|
||||
end
|
||||
return a.wowProjectID < b.wowProjectID
|
||||
elseif (a.battleTag and b.battleTag) then
|
||||
return a.battleTag < b.battleTag
|
||||
end
|
||||
end
|
||||
return a.client < b.client
|
||||
end
|
||||
end
|
||||
|
||||
--Sort client by statically given index (this is a `pairs by keys` sorting method)
|
||||
local function clientSort(a, b)
|
||||
if a and b then
|
||||
if clientIndex[a] and clientIndex[b] then
|
||||
return clientIndex[a] < clientIndex[b]
|
||||
end
|
||||
return a < b
|
||||
end
|
||||
end
|
||||
|
||||
local function AddToBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, wowProjectID, realmName, faction, race, className, zoneName, level, guid, gameText)
|
||||
className = E:UnlocalizedClassName(className) or ''
|
||||
characterName = BNet_GetValidatedCharacterName(characterName, battleTag, client) or ''
|
||||
|
||||
local obj = {
|
||||
accountID = bnetIDAccount, --1
|
||||
accountName = accountName, --2
|
||||
battleTag = battleTag, --3
|
||||
characterName = characterName, --4
|
||||
gameID = bnetIDGameAccount, --5
|
||||
client = client, --6
|
||||
isOnline = isOnline, --7
|
||||
isBnetAFK = isBnetAFK, --8
|
||||
isBnetDND = isBnetDND, --9
|
||||
noteText = noteText, --10
|
||||
wowProjectID = wowProjectID, --11
|
||||
realmName = realmName, --12
|
||||
faction = faction, --13
|
||||
race = race, --14
|
||||
className = className, --15
|
||||
zoneName = zoneName, --16
|
||||
level = level, --17
|
||||
guid = guid, --18
|
||||
gameText = gameText --19
|
||||
}
|
||||
|
||||
if strmatch(gameText, WOW_CLASSIC) then
|
||||
obj.classicText, obj.realmName = strmatch(gameText, '(.-)%s%-%s(.+)')
|
||||
end
|
||||
|
||||
BNTable[bnIndex] = obj
|
||||
|
||||
if tableList[client] then
|
||||
tableList[client][#tableList[client]+1] = BNTable[bnIndex]
|
||||
else
|
||||
tableList[client] = {}
|
||||
tableList[client][1] = BNTable[bnIndex]
|
||||
end
|
||||
end
|
||||
|
||||
local function PopulateBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, wowProjectID, realmName, faction, race, class, zoneName, level, guid, gameText, hasFocus)
|
||||
-- `hasFocus` is not added to BNTable[i]; we only need this to keep our friends datatext in sync with the friends list
|
||||
for i = 1, bnIndex do
|
||||
local isAdded, bnInfo = 0, BNTable[i]
|
||||
if bnInfo and (bnInfo.accountID == bnetIDAccount) then
|
||||
if bnInfo.client == 'BSAp' then
|
||||
if client == 'BSAp' then -- unlikely to happen
|
||||
isAdded = 1
|
||||
elseif client == 'App' then
|
||||
isAdded = (hasFocus and 2) or 1
|
||||
else -- Mobile -> Game
|
||||
isAdded = 2 --swap data
|
||||
end
|
||||
elseif bnInfo.client == 'App' then
|
||||
if client == 'App' then -- unlikely to happen
|
||||
isAdded = 1
|
||||
elseif client == 'BSAp' then
|
||||
isAdded = (hasFocus and 2) or 1
|
||||
else -- App -> Game
|
||||
isAdded = 2 --swap data
|
||||
end
|
||||
elseif bnInfo.client then -- Game
|
||||
if client == 'BSAp' or client == 'App' then -- ignore Mobile and App
|
||||
isAdded = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
if isAdded == 2 then -- swap data
|
||||
if bnInfo.client and tableList[bnInfo.client] then
|
||||
for n, y in ipairs(tableList[bnInfo.client]) do
|
||||
if y == bnInfo then
|
||||
tremove(tableList[bnInfo.client], n)
|
||||
break -- remove the old one from tableList
|
||||
end
|
||||
end
|
||||
end
|
||||
AddToBNTable(i, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, wowProjectID, realmName, faction, race, class, zoneName, level, guid, gameText)
|
||||
end
|
||||
if isAdded ~= 0 then
|
||||
return bnIndex
|
||||
end
|
||||
end
|
||||
|
||||
bnIndex = bnIndex + 1 --bump the index one for a new addition
|
||||
AddToBNTable(bnIndex, bnetIDAccount, accountName, battleTag, characterName, bnetIDGameAccount, client, isOnline, isBnetAFK, isBnetDND, noteText, wowProjectID, realmName, faction, race, class, zoneName, level, guid, gameText)
|
||||
|
||||
return bnIndex
|
||||
end
|
||||
|
||||
local function BuildBNTable(total)
|
||||
for _, v in pairs(tableList) do wipe(v) end
|
||||
wipe(BNTable)
|
||||
wipe(clientSorted)
|
||||
|
||||
local bnIndex = 0
|
||||
|
||||
for i = 1, total do
|
||||
local accountInfo = C_BattleNet_GetFriendAccountInfo(i)
|
||||
if accountInfo and accountInfo.gameAccountInfo and accountInfo.gameAccountInfo.isOnline then
|
||||
local numGameAccounts = C_BattleNet_GetFriendNumGameAccounts(i)
|
||||
if numGameAccounts and numGameAccounts > 0 then
|
||||
for y = 1, numGameAccounts do
|
||||
local gameAccountInfo = C_BattleNet_GetFriendGameAccountInfo(i, y)
|
||||
bnIndex = PopulateBNTable(bnIndex, accountInfo.bnetAccountID, accountInfo.accountName, accountInfo.battleTag, gameAccountInfo.characterName, gameAccountInfo.gameAccountID, gameAccountInfo.clientProgram, gameAccountInfo.isOnline, accountInfo.isAFK or gameAccountInfo.isGameAFK, accountInfo.isDND or gameAccountInfo.isGameBusy, accountInfo.note, accountInfo.gameAccountInfo.wowProjectID, gameAccountInfo.realmName, gameAccountInfo.factionName, gameAccountInfo.raceName, gameAccountInfo.className, gameAccountInfo.areaName, gameAccountInfo.characterLevel, gameAccountInfo.playerGuid, gameAccountInfo.richPresence, gameAccountInfo.hasFocus)
|
||||
end
|
||||
else
|
||||
bnIndex = PopulateBNTable(bnIndex, accountInfo.bnetAccountID, accountInfo.accountName, accountInfo.battleTag, accountInfo.gameAccountInfo.characterName, accountInfo.gameAccountInfo.gameAccountID, accountInfo.gameAccountInfo.clientProgram, accountInfo.gameAccountInfo.isOnline, accountInfo.isAFK, accountInfo.isDND, accountInfo.note, accountInfo.gameAccountInfo.wowProjectID)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if next(BNTable) then
|
||||
sort(BNTable, Sort)
|
||||
end
|
||||
for c, v in pairs(tableList) do
|
||||
if next(v) then
|
||||
sort(v, Sort)
|
||||
end
|
||||
tinsert(clientSorted, c)
|
||||
end
|
||||
if next(clientSorted) then
|
||||
sort(clientSorted, clientSort)
|
||||
end
|
||||
end
|
||||
|
||||
local function Click(self, btn)
|
||||
if btn == 'RightButton' then
|
||||
local menuCountWhispers = 0
|
||||
local menuCountInvites = 0
|
||||
|
||||
menuList[2].menuList = {}
|
||||
menuList[3].menuList = {}
|
||||
|
||||
if not E.global.datatexts.settings.Friends.hideWoW then
|
||||
for _, info in ipairs(friendTable) do
|
||||
if info.online then
|
||||
local shouldSkip = false
|
||||
if (info.status == statusTable.AFK) and E.global.datatexts.settings.Friends.hideAFK then
|
||||
shouldSkip = true
|
||||
elseif (info.status == statusTable.DND) and E.global.datatexts.settings.Friends.hideDND then
|
||||
shouldSkip = true
|
||||
end
|
||||
if not shouldSkip then
|
||||
local classc, levelc = E:ClassColor(info.class), GetQuestDifficultyColor(info.level)
|
||||
if not classc then classc = levelc end
|
||||
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info.level,classc.r*255,classc.g*255,classc.b*255,info.name), arg1 = info.name, notCheckable=true, func = whisperClick}
|
||||
|
||||
if inGroup(info.name) == '' then
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info.level,classc.r*255,classc.g*255,classc.b*255,info.name), arg1 = info.name, arg2 = info.guid, notCheckable=true, func = inviteClick}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, info in ipairs(BNTable) do
|
||||
if info.isOnline then
|
||||
local shouldSkip = false
|
||||
if (info.isBnetAFK == true) and E.global.datatexts.settings.Friends.hideAFK then
|
||||
shouldSkip = true
|
||||
elseif (info.isBnetDND == true) and E.global.datatexts.settings.Friends.hideDND then
|
||||
shouldSkip = true
|
||||
end
|
||||
if info.client and E.global.datatexts.settings.Friends['hide'..info.client] then
|
||||
shouldSkip = true
|
||||
end
|
||||
if not shouldSkip then
|
||||
local realID, hasBnet = info.accountName, false
|
||||
|
||||
for _, z in ipairs(menuList[3].menuList) do
|
||||
if z and z.text and (z.text == realID) then
|
||||
hasBnet = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not hasBnet then -- hasBnet will make sure only one is added to whispers but still allow us to add multiple into invites
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
menuList[3].menuList[menuCountWhispers] = {text = realID, arg1 = realID, arg2 = true, notCheckable=true, func = whisperClick}
|
||||
end
|
||||
|
||||
if (info.client and info.client == wowString) and (E.myfaction == info.faction) and inGroup(info.characterName, info.realmName) == '' then
|
||||
local classc, levelc = E:ClassColor(info.className), GetQuestDifficultyColor(info.level)
|
||||
if not classc then classc = levelc end
|
||||
|
||||
if info.wowProjectID == retailID then
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString,levelc.r*255,levelc.g*255,levelc.b*255,info.level,classc.r*255,classc.g*255,classc.b*255,info.characterName), arg1 = info.gameID, arg2 = info.guid, notCheckable=true, func = inviteClick}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
elseif InCombatLockdown() then
|
||||
_G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT)
|
||||
else
|
||||
ToggleFriendsFrame(1)
|
||||
end
|
||||
end
|
||||
|
||||
local lastTooltipXLineHeader
|
||||
local function TooltipAddXLine(X, header, ...)
|
||||
X = (X == true and 'AddDoubleLine') or 'AddLine'
|
||||
if lastTooltipXLineHeader ~= header then
|
||||
DT.tooltip[X](DT.tooltip, ' ')
|
||||
DT.tooltip[X](DT.tooltip, header)
|
||||
lastTooltipXLineHeader = header
|
||||
end
|
||||
DT.tooltip[X](DT.tooltip, ...)
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
lastTooltipXLineHeader = nil
|
||||
|
||||
local onlineFriends = C_FriendList_GetNumOnlineFriends()
|
||||
local numberOfFriends = C_FriendList_GetNumFriends()
|
||||
local totalBNet, numBNetOnline = BNGetNumFriends()
|
||||
local totalonline = onlineFriends + numBNetOnline
|
||||
|
||||
-- no friends online, quick exit
|
||||
if totalonline == 0 then return end
|
||||
|
||||
if not dataValid then
|
||||
-- only retrieve information for all on-line members when we actually view the tooltip
|
||||
if numberOfFriends > 0 then BuildFriendTable(numberOfFriends) end
|
||||
if totalBNet > 0 then BuildBNTable(totalBNet) end
|
||||
dataValid = true
|
||||
end
|
||||
|
||||
local totalfriends = numberOfFriends + totalBNet
|
||||
local zonec, classc, levelc, realmc
|
||||
local shiftDown = IsShiftKeyDown()
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Friends List"], format(totalOnlineString, totalonline, totalfriends),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
|
||||
if (onlineFriends > 0) and not E.global.datatexts.settings.Friends.hideWoW then
|
||||
for _, info in ipairs(friendTable) do
|
||||
if info.online then
|
||||
local shouldSkip = false
|
||||
if (info.status == statusTable.AFK) and E.global.datatexts.settings.Friends.hideAFK then
|
||||
shouldSkip = true
|
||||
elseif (info.status == statusTable.DND) and E.global.datatexts.settings.Friends.hideDND then
|
||||
shouldSkip = true
|
||||
end
|
||||
if not shouldSkip then
|
||||
if E.MapInfo.zoneText and (E.MapInfo.zoneText == info.zone) then zonec = activezone else zonec = inactivezone end
|
||||
classc, levelc = E:ClassColor(info.class), GetQuestDifficultyColor(info.level)
|
||||
if not classc then classc = levelc end
|
||||
|
||||
TooltipAddXLine(true, characterFriend, format(levelNameClassString,levelc.r*255,levelc.g*255,levelc.b*255,info.level,info.name,inGroup(info.name),info.status),info.zone,classc.r,classc.g,classc.b,zonec.r,zonec.g,zonec.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if numBNetOnline > 0 then
|
||||
local status
|
||||
for _, client in ipairs(clientSorted) do
|
||||
local Table = tableList[client]
|
||||
local shouldSkip = E.global.datatexts.settings.Friends['hide'..client]
|
||||
if not shouldSkip then
|
||||
for _, info in ipairs(Table) do
|
||||
if info.isOnline then
|
||||
shouldSkip = false
|
||||
if info.isBnetAFK == true then
|
||||
if E.global.datatexts.settings.Friends.hideAFK then
|
||||
shouldSkip = true
|
||||
end
|
||||
status = statusTable.AFK
|
||||
elseif info.isBnetDND == true then
|
||||
if E.global.datatexts.settings.Friends.hideDND then
|
||||
shouldSkip = true
|
||||
end
|
||||
status = statusTable.DND
|
||||
else
|
||||
status = ''
|
||||
end
|
||||
|
||||
if not shouldSkip then
|
||||
local header = format('%s (%s)', battleNetString, info.classicText or clientTags[client] or client)
|
||||
if info.client and info.client == wowString then
|
||||
classc = E:ClassColor(info.className)
|
||||
if info.level and info.level ~= '' then
|
||||
levelc = GetQuestDifficultyColor(info.level)
|
||||
else
|
||||
classc, levelc = PRIEST_COLOR, PRIEST_COLOR
|
||||
end
|
||||
|
||||
--Sometimes the friend list is fubar with level 0 unknown friends
|
||||
if not classc then classc = PRIEST_COLOR end
|
||||
|
||||
TooltipAddXLine(true, header, format(levelNameString..'%s%s',levelc.r*255,levelc.g*255,levelc.b*255,info.level,classc.r*255,classc.g*255,classc.b*255,info.characterName,inGroup(info.characterName, info.realmName),status),info.accountName,238,238,238,238,238,238)
|
||||
if shiftDown then
|
||||
if E.MapInfo.zoneText and (E.MapInfo.zoneText == info.zoneName) then zonec = activezone else zonec = inactivezone end
|
||||
if E.myrealm == info.realmName then realmc = activezone else realmc = inactivezone end
|
||||
TooltipAddXLine(true, header, info.zoneName, info.realmName, zonec.r, zonec.g, zonec.b, realmc.r, realmc.g, realmc.b)
|
||||
end
|
||||
else
|
||||
TooltipAddXLine(true, header, info.characterName..status, info.accountName, .9, .9, .9, .9, .9, .9)
|
||||
if shiftDown and (info.gameText and info.gameText ~= '') and (info.client and info.client ~= 'App' and info.client ~= 'BSAp') then
|
||||
TooltipAddXLine(false, header, info.gameText, inactivezone.r, inactivezone.g, inactivezone.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, message)
|
||||
local onlineFriends = C_FriendList_GetNumOnlineFriends()
|
||||
local _, numBNetOnline = BNGetNumFriends()
|
||||
|
||||
-- special handler to detect friend coming online or going offline
|
||||
-- when this is the case, we invalidate our buffered table and update the
|
||||
-- datatext information
|
||||
if event == 'CHAT_MSG_SYSTEM' then
|
||||
if not (strfind(message, friendOnline) or strfind(message, friendOffline)) then return end
|
||||
end
|
||||
-- force update when showing tooltip
|
||||
dataValid = false
|
||||
|
||||
if not IsAltKeyDown() and event == 'MODIFIER_STATE_CHANGED' and GetMouseFocus() == self then
|
||||
OnEnter(self)
|
||||
end
|
||||
|
||||
if E.global.datatexts.settings.Friends.NoLabel then
|
||||
self.text:SetFormattedText(displayString, onlineFriends + numBNetOnline)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Friends.Label ~= '' and E.global.datatexts.settings.Friends.Label or _G.FRIENDS..': ', onlineFriends + numBNetOnline)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Friends.NoLabel and '' or '%s', hex, '%d|r')
|
||||
|
||||
if lastPanel then
|
||||
OnEvent(lastPanel, 'ELVUI_COLOR_UPDATE')
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Friends', _G.SOCIAL_LABEL, {'BN_FRIEND_ACCOUNT_ONLINE', 'BN_FRIEND_ACCOUNT_OFFLINE', 'BN_FRIEND_INFO_CHANGED', 'FRIENDLIST_UPDATE', 'CHAT_MSG_SYSTEM', 'MODIFIER_STATE_CHANGED'}, OnEvent, nil, Click, OnEnter, nil, _G.FRIENDS, nil, ValueColorUpdate)
|
||||
209
Modules/DataTexts/Gold.lua
Normal file
209
Modules/DataTexts/Gold.lua
Normal file
@@ -0,0 +1,209 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local type, wipe, pairs, ipairs, sort = type, wipe, pairs, ipairs, sort
|
||||
local format, strjoin, tinsert = format, strjoin, tinsert
|
||||
|
||||
local GetMoney = GetMoney
|
||||
local IsControlKeyDown = IsControlKeyDown
|
||||
local IsLoggedIn = IsLoggedIn
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local C_WowTokenPublic_UpdateMarketPrice = C_WowTokenPublic.UpdateMarketPrice
|
||||
local C_WowTokenPublic_GetCurrentMarketPrice = C_WowTokenPublic.GetCurrentMarketPrice
|
||||
local C_Timer_NewTicker = C_Timer.NewTicker
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
-- GLOBALS: ElvDB
|
||||
|
||||
local Ticker
|
||||
local CURRENCY = CURRENCY
|
||||
local MAX_WATCHED_TOKENS = MAX_WATCHED_TOKENS
|
||||
local Profit, Spent = 0, 0
|
||||
local resetCountersFormatter = strjoin('', '|cffaaaaaa', L["Reset Session Data: Hold Ctrl + Right Click"], '|r')
|
||||
local resetInfoFormatter = strjoin('', '|cffaaaaaa', L["Reset Character Data: Hold Shift + Right Click"], '|r')
|
||||
local PRIEST_COLOR = RAID_CLASS_COLORS.PRIEST
|
||||
local C_CurrencyInfo_GetBackpackCurrencyInfo = C_CurrencyInfo.GetBackpackCurrencyInfo
|
||||
|
||||
local iconString = '|T%s:16:16:0:0:64:64:4:60:4:60|t'
|
||||
|
||||
local menuList = {}
|
||||
|
||||
local function sortFunction(a, b)
|
||||
return a.amount > b.amount
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
if not IsLoggedIn() then return end
|
||||
|
||||
if not Ticker then
|
||||
C_WowTokenPublic_UpdateMarketPrice()
|
||||
Ticker = C_Timer_NewTicker(60, C_WowTokenPublic_UpdateMarketPrice)
|
||||
end
|
||||
|
||||
ElvDB = ElvDB or {}
|
||||
|
||||
ElvDB.gold = ElvDB.gold or {}
|
||||
ElvDB.gold[E.myrealm] = ElvDB.gold[E.myrealm] or {}
|
||||
|
||||
ElvDB.class = ElvDB.class or {}
|
||||
ElvDB.class[E.myrealm] = ElvDB.class[E.myrealm] or {}
|
||||
ElvDB.class[E.myrealm][E.myname] = E.myclass
|
||||
|
||||
ElvDB.faction = ElvDB.faction or {}
|
||||
ElvDB.faction[E.myrealm] = ElvDB.faction[E.myrealm] or {}
|
||||
ElvDB.faction[E.myrealm][E.myname] = E.myfaction
|
||||
|
||||
ElvDB.serverID = ElvDB.serverID or {}
|
||||
ElvDB.serverID[E.serverID] = ElvDB.serverID[E.serverID] or {}
|
||||
ElvDB.serverID[E.serverID][E.myrealm] = true
|
||||
|
||||
--prevent an error possibly from really old profiles
|
||||
local oldMoney = ElvDB.gold[E.myrealm][E.myname]
|
||||
if oldMoney and type(oldMoney) ~= 'number' then
|
||||
ElvDB.gold[E.myrealm][E.myname] = nil
|
||||
oldMoney = nil
|
||||
end
|
||||
|
||||
local NewMoney = GetMoney()
|
||||
ElvDB.gold[E.myrealm][E.myname] = NewMoney
|
||||
|
||||
local OldMoney = oldMoney or NewMoney
|
||||
local Change = NewMoney-OldMoney -- Positive if we gain money
|
||||
if OldMoney>NewMoney then -- Lost Money
|
||||
Spent = Spent - Change
|
||||
else -- Gained Moeny
|
||||
Profit = Profit + Change
|
||||
end
|
||||
|
||||
self.text:SetText(E:FormatMoney(NewMoney, E.global.datatexts.settings.Gold.goldFormat or "BLIZZARD", not E.global.datatexts.settings.Gold.goldCoins))
|
||||
end
|
||||
|
||||
local function deleteCharacter(self, realm, name)
|
||||
ElvDB.gold[realm][name] = nil
|
||||
ElvDB.class[realm][name] = nil
|
||||
ElvDB.faction[realm][name] = nil
|
||||
|
||||
if name == E.myname and realm == E.myrealm then
|
||||
OnEvent(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function Click(self, btn)
|
||||
if btn == 'RightButton' then
|
||||
if IsShiftKeyDown() then
|
||||
wipe(menuList)
|
||||
tinsert(menuList, { text = 'Delete Character', isTitle = true, notCheckable = true })
|
||||
|
||||
for realm in pairs(ElvDB.serverID[E.serverID]) do
|
||||
for name in pairs(ElvDB.gold[realm]) do
|
||||
tinsert(menuList, {
|
||||
text = format('%s - %s', name, realm),
|
||||
notCheckable = true,
|
||||
func = function()
|
||||
deleteCharacter(self, realm, name)
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
elseif IsControlKeyDown() then
|
||||
Profit = 0
|
||||
Spent = 0
|
||||
end
|
||||
else
|
||||
_G.ToggleAllBags()
|
||||
end
|
||||
end
|
||||
|
||||
local myGold = {}
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local textOnly = not E.global.datatexts.settings.Gold.goldCoins and true or false
|
||||
local style = E.global.datatexts.settings.Gold.goldFormat or 'BLIZZARD'
|
||||
|
||||
DT.tooltip:AddLine(L["Session:"])
|
||||
DT.tooltip:AddDoubleLine(L["Earned:"], E:FormatMoney(Profit, style, textOnly), 1, 1, 1, 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(L["Spent:"], E:FormatMoney(Spent, style, textOnly), 1, 1, 1, 1, 1, 1)
|
||||
if Profit < Spent then
|
||||
DT.tooltip:AddDoubleLine(L["Deficit:"], E:FormatMoney(Profit-Spent, style, textOnly), 1, 0, 0, 1, 1, 1)
|
||||
elseif (Profit-Spent)>0 then
|
||||
DT.tooltip:AddDoubleLine(L["Profit:"], E:FormatMoney(Profit-Spent, style, textOnly), 0, 1, 0, 1, 1, 1)
|
||||
end
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
local totalGold, totalHorde, totalAlliance = 0, 0, 0
|
||||
DT.tooltip:AddLine(L["Character: "])
|
||||
|
||||
wipe(myGold)
|
||||
for realm in pairs(ElvDB.serverID[E.serverID]) do
|
||||
for k, _ in pairs(ElvDB.gold[realm]) do
|
||||
if ElvDB.gold[realm][k] then
|
||||
local color = E:ClassColor(ElvDB.class[realm][k]) or PRIEST_COLOR
|
||||
tinsert(myGold,
|
||||
{
|
||||
name = k,
|
||||
realm = realm,
|
||||
amount = ElvDB.gold[realm][k],
|
||||
amountText = E:FormatMoney(ElvDB.gold[realm][k], style, textOnly),
|
||||
faction = ElvDB.faction[realm][k] or '',
|
||||
r = color.r, g = color.g, b = color.b,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
if ElvDB.faction[realm][k] == 'Alliance' then
|
||||
totalAlliance = totalAlliance+ElvDB.gold[realm][k]
|
||||
elseif ElvDB.faction[realm][k] == 'Horde' then
|
||||
totalHorde = totalHorde+ElvDB.gold[realm][k]
|
||||
end
|
||||
|
||||
totalGold = totalGold+ElvDB.gold[realm][k]
|
||||
end
|
||||
end
|
||||
|
||||
sort(myGold, sortFunction)
|
||||
|
||||
for _, g in ipairs(myGold) do
|
||||
local nameLine = ''
|
||||
if g.faction ~= '' and g.faction ~= 'Neutral' then
|
||||
nameLine = format('|TInterface/FriendsFrame/PlusManz-%s:14|t ', g.faction)
|
||||
end
|
||||
|
||||
local toonName = format('%s%s%s', nameLine, g.name, (g.realm and g.realm ~= E.myrealm and ' - '..g.realm) or '')
|
||||
DT.tooltip:AddDoubleLine((g.name == E.myname and toonName..' |TInterface/COMMON/Indicator-Green:14|t') or toonName, g.amountText, g.r, g.g, g.b, 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(L["Server: "])
|
||||
if totalAlliance > 0 and totalHorde > 0 then
|
||||
if totalAlliance ~= 0 then DT.tooltip:AddDoubleLine(L["Alliance: "], E:FormatMoney(totalAlliance, style, textOnly), 0, .376, 1, 1, 1, 1) end
|
||||
if totalHorde ~= 0 then DT.tooltip:AddDoubleLine(L["Horde: "], E:FormatMoney(totalHorde, style, textOnly), 1, .2, .2, 1, 1, 1) end
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
DT.tooltip:AddDoubleLine(L["Total: "], E:FormatMoney(totalGold, style, textOnly), 1, 1, 1, 1, 1, 1)
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddDoubleLine(L["WoW Token:"], E:FormatMoney(C_WowTokenPublic_GetCurrentMarketPrice() or 0, style, textOnly), 0, .8, 1, 1, 1, 1)
|
||||
|
||||
for i = 1, MAX_WATCHED_TOKENS do
|
||||
local info = C_CurrencyInfo_GetBackpackCurrencyInfo(i)
|
||||
if info then
|
||||
if i == 1 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(CURRENCY)
|
||||
end
|
||||
if info.quantity then
|
||||
DT.tooltip:AddDoubleLine(format('%s %s', format(iconString, info.iconFileID), info.name), BreakUpLargeNumbers(info.quantity), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(resetCountersFormatter)
|
||||
DT.tooltip:AddLine(resetInfoFormatter)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Gold', nil, {'PLAYER_MONEY', 'SEND_MAIL_MONEY_CHANGED', 'SEND_MAIL_COD_CHANGED', 'PLAYER_TRADE_MONEY', 'TRADE_MONEY_CHANGED'}, OnEvent, nil, Click, OnEnter, nil, L["Gold"])
|
||||
318
Modules/DataTexts/Guild.lua
Normal file
318
Modules/DataTexts/Guild.lua
Normal file
@@ -0,0 +1,318 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local ipairs, select, sort, unpack, wipe, ceil = ipairs, select, sort, unpack, wipe, ceil
|
||||
local format, strfind, strjoin, strsplit, strmatch = format, strfind, strjoin, strsplit, strmatch
|
||||
|
||||
local GetDisplayedInviteType = GetDisplayedInviteType
|
||||
local GetGuildFactionInfo = GetGuildFactionInfo
|
||||
local GetGuildInfo = GetGuildInfo
|
||||
local GetGuildRosterInfo = GetGuildRosterInfo
|
||||
local GetGuildRosterMOTD = GetGuildRosterMOTD
|
||||
local GetMouseFocus = GetMouseFocus
|
||||
local GetNumGuildApplicants = GetNumGuildApplicants
|
||||
local GetNumGuildMembers = GetNumGuildMembers
|
||||
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
||||
local C_GuildInfo_GuildRoster = C_GuildInfo.GuildRoster
|
||||
local IsInGuild = IsInGuild
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local LoadAddOn = LoadAddOn
|
||||
local SetItemRef = SetItemRef
|
||||
local ToggleGuildFrame = ToggleGuildFrame
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local IsAltKeyDown = IsAltKeyDown
|
||||
|
||||
local C_PartyInfo_InviteUnit = C_PartyInfo.InviteUnit
|
||||
local C_PartyInfo_RequestInviteFromUnit = C_PartyInfo.RequestInviteFromUnit
|
||||
|
||||
local COMBAT_FACTION_CHANGE = COMBAT_FACTION_CHANGE
|
||||
local REMOTE_CHAT = REMOTE_CHAT
|
||||
local GUILD_MOTD = GUILD_MOTD
|
||||
local GUILD = GUILD
|
||||
|
||||
local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
|
||||
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
|
||||
local displayString = ''
|
||||
local noGuildString = ''
|
||||
local guildInfoString = '%s'
|
||||
local guildInfoString2 = GUILD..': %d/%d'
|
||||
local guildMotDString = '%s |cffaaaaaa- |cffffffff%s'
|
||||
local levelNameString = '|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r'
|
||||
local levelNameStatusString = '|cff%02x%02x%02x%d|r %s%s %s'
|
||||
local nameRankString = '%s |cff999999-|cffffffff %s'
|
||||
local standingString = E:RGBToHex(ttsubh.r, ttsubh.g, ttsubh.b)..'%s:|r |cFFFFFFFF%s/%s (%s%%)'
|
||||
local moreMembersOnlineString = strjoin('', '+ %d ', _G.FRIENDS_LIST_ONLINE, '...')
|
||||
local noteString = strjoin('', '|cff999999 ', _G.LABEL_NOTE, ':|r %s')
|
||||
local officerNoteString = strjoin('', '|cff999999 ', _G.GUILD_RANK1_DESC, ':|r %s')
|
||||
local guildTable, guildMotD, lastPanel = {}, ''
|
||||
|
||||
local function sortByRank(a, b)
|
||||
if a and b then
|
||||
if a.rankIndex == b.rankIndex then
|
||||
return a.name < b.name
|
||||
end
|
||||
return a.rankIndex < b.rankIndex
|
||||
end
|
||||
end
|
||||
|
||||
local function sortByName(a, b)
|
||||
if a and b then
|
||||
return a.name < b.name
|
||||
end
|
||||
end
|
||||
|
||||
local function SortGuildTable(shift)
|
||||
if shift then
|
||||
sort(guildTable, sortByRank)
|
||||
else
|
||||
sort(guildTable, sortByName)
|
||||
end
|
||||
end
|
||||
|
||||
local onlinestatusstring = '|cffFFFFFF[|r|cffFF0000%s|r|cffFFFFFF]|r'
|
||||
local onlinestatus = {
|
||||
[0] = '',
|
||||
[1] = format(onlinestatusstring, L["AFK"]),
|
||||
[2] = format(onlinestatusstring, L["DND"]),
|
||||
}
|
||||
local mobilestatus = {
|
||||
[0] = [[|TInterface\ChatFrame\UI-ChatIcon-ArmoryChat:14:14:0:0:16:16:0:16:0:16:73:177:73|t]],
|
||||
[1] = [[|TInterface\ChatFrame\UI-ChatIcon-ArmoryChat-AwayMobile:14:14:0:0:16:16:0:16:0:16|t]],
|
||||
[2] = [[|TInterface\ChatFrame\UI-ChatIcon-ArmoryChat-BusyMobile:14:14:0:0:16:16:0:16:0:16|t]],
|
||||
}
|
||||
|
||||
local function inGroup(name)
|
||||
return (UnitInParty(name) or UnitInRaid(name)) and '|cffaaaaaa*|r' or ''
|
||||
end
|
||||
|
||||
local function BuildGuildTable()
|
||||
wipe(guildTable)
|
||||
|
||||
local totalMembers = GetNumGuildMembers()
|
||||
for i = 1, totalMembers do
|
||||
local name, rank, rankIndex, level, _, zone, note, officerNote, connected, memberstatus, className, _, _, isMobile, _, _, guid = GetGuildRosterInfo(i)
|
||||
if not name then return end
|
||||
|
||||
local statusInfo = isMobile and mobilestatus[memberstatus] or onlinestatus[memberstatus]
|
||||
zone = (isMobile and not connected) and REMOTE_CHAT or zone
|
||||
|
||||
if connected or isMobile then
|
||||
guildTable[#guildTable + 1] = {
|
||||
name = E:StripMyRealm(name), --1
|
||||
rank = rank, --2
|
||||
level = level, --3
|
||||
zone = zone, --4
|
||||
note = note, --5
|
||||
officerNote = officerNote, --6
|
||||
online = connected, --7
|
||||
status = statusInfo, --8
|
||||
class = className, --9
|
||||
rankIndex = rankIndex, --10
|
||||
isMobile = isMobile, --11
|
||||
guid = guid --12
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function UpdateGuildMessage()
|
||||
guildMotD = GetGuildRosterMOTD()
|
||||
end
|
||||
|
||||
local FRIEND_ONLINE = select(2, strsplit(' ', _G.ERR_FRIEND_ONLINE_SS, 2))
|
||||
local resendRequest = false
|
||||
local eventHandlers = {
|
||||
PLAYER_GUILD_UPDATE = C_GuildInfo_GuildRoster,
|
||||
CHAT_MSG_SYSTEM = function(_, arg1)
|
||||
if FRIEND_ONLINE ~= nil and arg1 and strfind(arg1, FRIEND_ONLINE) then
|
||||
resendRequest = true
|
||||
end
|
||||
end,
|
||||
-- when we enter the world and guildframe is not available then
|
||||
-- load guild frame, update guild message and guild xp
|
||||
PLAYER_ENTERING_WORLD = function()
|
||||
if not _G.GuildFrame and IsInGuild() then
|
||||
LoadAddOn('Blizzard_GuildUI')
|
||||
C_GuildInfo_GuildRoster()
|
||||
end
|
||||
end,
|
||||
-- Guild Roster updated, so rebuild the guild table
|
||||
GUILD_ROSTER_UPDATE = function(self)
|
||||
if resendRequest then
|
||||
resendRequest = false
|
||||
return C_GuildInfo_GuildRoster()
|
||||
else
|
||||
BuildGuildTable()
|
||||
UpdateGuildMessage()
|
||||
if GetMouseFocus() == self then
|
||||
self:GetScript('OnEnter')(self, nil, true)
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- our guild message of the day changed
|
||||
GUILD_MOTD = function(_, arg1)
|
||||
guildMotD = arg1
|
||||
end
|
||||
}
|
||||
|
||||
local menuList = {
|
||||
{ text = _G.OPTIONS_MENU, isTitle = true, notCheckable=true},
|
||||
{ text = _G.INVITE, hasArrow = true, notCheckable=true,},
|
||||
{ text = _G.CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable=true,}
|
||||
}
|
||||
|
||||
local function inviteClick(_, name, guid)
|
||||
DT.EasyMenu:Hide()
|
||||
|
||||
if not (name and name ~= '') then return end
|
||||
|
||||
if guid then
|
||||
local inviteType = GetDisplayedInviteType(guid)
|
||||
if inviteType == 'INVITE' or inviteType == 'SUGGEST_INVITE' then
|
||||
C_PartyInfo_InviteUnit(name)
|
||||
elseif inviteType == 'REQUEST_INVITE' then
|
||||
C_PartyInfo_RequestInviteFromUnit(name)
|
||||
end
|
||||
else
|
||||
-- if for some reason guid isnt here fallback and just try to invite them
|
||||
-- this is unlikely but having a fallback doesnt hurt
|
||||
C_PartyInfo_InviteUnit(name)
|
||||
end
|
||||
end
|
||||
|
||||
local function whisperClick(_, playerName)
|
||||
DT.EasyMenu:Hide()
|
||||
SetItemRef( 'player:'..playerName, format('|Hplayer:%1$s|h[%1$s]|h',playerName), 'LeftButton' )
|
||||
end
|
||||
|
||||
local function Click(self, btn)
|
||||
if btn == 'RightButton' and IsInGuild() then
|
||||
local menuCountWhispers = 0
|
||||
local menuCountInvites = 0
|
||||
|
||||
menuList[2].menuList = {}
|
||||
menuList[3].menuList = {}
|
||||
|
||||
for _, info in ipairs(guildTable) do
|
||||
if (info.online or info.isMobile) and info.name ~= E.myname then
|
||||
local classc, levelc = E:ClassColor(info.class), GetQuestDifficultyColor(info.level)
|
||||
if not classc then classc = levelc end
|
||||
|
||||
local name = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info.level, classc.r*255,classc.g*255,classc.b*255, info.name)
|
||||
if inGroup(info.name) ~= '' then
|
||||
name = name..' |cffaaaaaa*|r'
|
||||
elseif not (info.isMobile and info.zone == REMOTE_CHAT) then
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
menuList[2].menuList[menuCountInvites] = {text = name, arg1 = info.name, arg2 = info.guid, notCheckable=true, func = inviteClick}
|
||||
end
|
||||
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
menuList[3].menuList[menuCountWhispers] = {text = name, arg1 = info.name, notCheckable=true, func = whisperClick}
|
||||
end
|
||||
end
|
||||
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
elseif InCombatLockdown() then
|
||||
_G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT)
|
||||
else
|
||||
ToggleGuildFrame()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(_, _, noUpdate)
|
||||
if not IsInGuild() then return end
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local shiftDown = IsShiftKeyDown()
|
||||
local total, _, online = GetNumGuildMembers()
|
||||
if #guildTable == 0 then BuildGuildTable() end
|
||||
|
||||
SortGuildTable(shiftDown)
|
||||
|
||||
local guildName, guildRank = GetGuildInfo('player')
|
||||
local applicants = GetNumGuildApplicants()
|
||||
|
||||
if guildName and guildRank then
|
||||
DT.tooltip:AddDoubleLine(format(guildInfoString, guildName), format(guildInfoString2..(applicants > 0 and ' |cFFFFFFFF(|cff33ff33%d|r|cFFFFFFFF)|r' or ''), online, total, applicants), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
|
||||
DT.tooltip:AddLine(guildRank, unpack(tthead))
|
||||
end
|
||||
|
||||
if guildMotD ~= '' then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(format(guildMotDString, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
|
||||
end
|
||||
|
||||
local _, _, standingID, barMin, barMax, barValue = GetGuildFactionInfo()
|
||||
if standingID ~= 8 then -- Not Max Rep
|
||||
barMax = barMax - barMin
|
||||
barValue = barValue - barMin
|
||||
DT.tooltip:AddLine(format(standingString, COMBAT_FACTION_CHANGE, E:ShortValue(barValue), E:ShortValue(barMax), ceil((barValue / barMax) * 100)))
|
||||
end
|
||||
|
||||
local zonec
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
for i, info in ipairs(guildTable) do
|
||||
-- if more then 30 guild members are online, we don't Show any more, but inform user there are more
|
||||
if 30 - i < 1 then
|
||||
if online - 30 > 1 then DT.tooltip:AddLine(format(moreMembersOnlineString, online - 30), ttsubh.r, ttsubh.g, ttsubh.b) end
|
||||
break
|
||||
end
|
||||
|
||||
if E.MapInfo.zoneText and (E.MapInfo.zoneText == info.zone) then zonec = activezone else zonec = inactivezone end
|
||||
|
||||
local classc, levelc = E:ClassColor(info.class), GetQuestDifficultyColor(info.level)
|
||||
if not classc then classc = levelc end
|
||||
|
||||
if shiftDown then
|
||||
DT.tooltip:AddDoubleLine(format(nameRankString, info.name, info.rank), info.zone, classc.r, classc.g, classc.b, zonec.r, zonec.g, zonec.b)
|
||||
if info.note ~= '' then DT.tooltip:AddLine(format(noteString, info.note), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
|
||||
if info.officerNote ~= '' then DT.tooltip:AddLine(format(officerNoteString, info.officerNote), ttoff.r, ttoff.g, ttoff.b, 1) end
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, info.level, strmatch(info.name,'([^%-]+).*'), inGroup(info.name), info.status), info.zone, classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
|
||||
end
|
||||
end
|
||||
|
||||
if not noUpdate then
|
||||
C_GuildInfo_GuildRoster()
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
lastPanel = self
|
||||
|
||||
if IsInGuild() then
|
||||
local func = eventHandlers[event]
|
||||
if func then func(self, ...) end
|
||||
|
||||
if not IsAltKeyDown() and event == 'MODIFIER_STATE_CHANGED' and GetMouseFocus() == self then
|
||||
OnEnter(self)
|
||||
end
|
||||
|
||||
if E.global.datatexts.settings.Guild.NoLabel then
|
||||
self.text:SetFormattedText(displayString, #guildTable)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Guild.Label ~= '' and E.global.datatexts.settings.Guild.Label or GUILD..': ', #guildTable)
|
||||
end
|
||||
else
|
||||
self.text:SetText(noGuildString)
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Guild.NoLabel and '' or '%s', hex, '%d|r')
|
||||
noGuildString = hex..L["No Guild"]
|
||||
|
||||
if lastPanel then
|
||||
OnEvent(lastPanel, 'ELVUI_COLOR_UPDATE')
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Guild', _G.SOCIAL_LABEL, {'CHAT_MSG_SYSTEM', 'GUILD_ROSTER_UPDATE', 'PLAYER_GUILD_UPDATE', 'GUILD_MOTD', 'MODIFIER_STATE_CHANGED'}, OnEvent, nil, Click, OnEnter, nil, GUILD, nil, ValueColorUpdate)
|
||||
65
Modules/DataTexts/HPS.lua
Normal file
65
Modules/DataTexts/HPS.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local time, max, strjoin = time, max, strjoin
|
||||
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
|
||||
local UnitGUID = UnitGUID
|
||||
|
||||
local timeStamp, combatTime, healTotal = 0, 0, 0
|
||||
local lastSegment, petGUID = 0
|
||||
local displayString, lastPanel = ''
|
||||
local events = {SPELL_HEAL = true, SPELL_PERIODIC_HEAL = true}
|
||||
|
||||
local function Reset()
|
||||
timeStamp, combatTime, healTotal = 0, 0, 0
|
||||
end
|
||||
|
||||
local function GetHPS(self)
|
||||
local hps
|
||||
if healTotal == 0 or combatTime == 0 then
|
||||
hps = 0
|
||||
else
|
||||
hps = healTotal / combatTime
|
||||
end
|
||||
self.text:SetFormattedText(displayString, L["HPS"], E:ShortValue(hps))
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
lastPanel = self
|
||||
|
||||
if event == 'UNIT_PET' then
|
||||
petGUID = UnitGUID('pet')
|
||||
elseif event == 'PLAYER_REGEN_DISABLED' or event == 'PLAYER_LEAVE_COMBAT' then
|
||||
local now = time()
|
||||
if now - lastSegment > 20 then
|
||||
Reset()
|
||||
end
|
||||
lastSegment = now
|
||||
elseif event == 'COMBAT_LOG_EVENT_UNFILTERED' then
|
||||
local timestamp, Event, _, sourceGUID, _, _, _, _, _, _, _, _, _, _, lastHealAmount, overHeal = CombatLogGetCurrentEventInfo()
|
||||
if not events[Event] then return end
|
||||
|
||||
if sourceGUID == E.myguid or sourceGUID == petGUID then
|
||||
if timeStamp == 0 then timeStamp = timestamp end
|
||||
lastSegment = timeStamp
|
||||
combatTime = timestamp - timeStamp
|
||||
healTotal = healTotal + max(0, lastHealAmount - overHeal)
|
||||
end
|
||||
end
|
||||
|
||||
GetHPS(self)
|
||||
end
|
||||
|
||||
local function OnClick(self)
|
||||
Reset()
|
||||
GetHPS(self)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%s')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('HPS', nil, {'UNIT_PET', 'COMBAT_LOG_EVENT_UNFILTERED', 'PLAYER_LEAVE_COMBAT', 'PLAYER_REGEN_DISABLED'}, OnEvent, nil, OnClick, nil, nil, L["HPS"], nil, ValueColorUpdate)
|
||||
65
Modules/DataTexts/Haste.lua
Normal file
65
Modules/DataTexts/Haste.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local format, strjoin = format, strjoin
|
||||
local GetHaste = GetHaste
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local GetPVPGearStatRules = GetPVPGearStatRules
|
||||
local STAT_HASTE = STAT_HASTE
|
||||
local CR_HASTE_MELEE = CR_HASTE_MELEE
|
||||
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
|
||||
local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE
|
||||
local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
|
||||
local STAT_HASTE_TOOLTIP = STAT_HASTE_TOOLTIP
|
||||
local STAT_HASTE_BASE_TOOLTIP = STAT_HASTE_BASE_TOOLTIP
|
||||
local RED_FONT_COLOR_CODE = RED_FONT_COLOR_CODE
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local rating = CR_HASTE_MELEE
|
||||
local classTooltip = _G['STAT_HASTE_'..E.myclass..'_TOOLTIP']
|
||||
local haste = GetHaste()
|
||||
|
||||
local hasteFormatString
|
||||
if haste < 0 and not GetPVPGearStatRules() then
|
||||
hasteFormatString = RED_FONT_COLOR_CODE..'%s'..FONT_COLOR_CODE_CLOSE
|
||||
else
|
||||
hasteFormatString = '%s'
|
||||
end
|
||||
|
||||
if not classTooltip then
|
||||
classTooltip = STAT_HASTE_TOOLTIP
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_HASTE)..' '..format(hasteFormatString, format('%.2F%%', haste))..FONT_COLOR_CODE_CLOSE)
|
||||
DT.tooltip:AddLine(classTooltip..format(STAT_HASTE_BASE_TOOLTIP, BreakUpLargeNumbers(GetCombatRating(rating)), GetCombatRatingBonus(rating)))
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local haste = GetHaste()
|
||||
|
||||
if E.global.datatexts.settings.Haste.NoLabel then
|
||||
self.text:SetFormattedText(displayString, haste)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Haste.Label ~= '' and E.global.datatexts.settings.Haste.Label or STAT_HASTE..': ', haste)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Haste.NoLabel and '' or '%s', hex, '%.'..E.global.datatexts.settings.Haste.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Haste', STAT_CATEGORY_ENHANCEMENTS, {'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE', 'UNIT_SPELL_HASTE'}, OnEvent, nil, nil, OnEnter, nil, STAT_HASTE, nil, ValueColorUpdate)
|
||||
27
Modules/DataTexts/Intellect.lua
Normal file
27
Modules/DataTexts/Intellect.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local UnitStat = UnitStat
|
||||
local ITEM_MOD_INTELLECT_SHORT = ITEM_MOD_INTELLECT_SHORT
|
||||
local LE_UNIT_STAT_INTELLECT = LE_UNIT_STAT_INTELLECT
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
self.text:SetFormattedText(displayString, ITEM_MOD_INTELLECT_SHORT, UnitStat('player', LE_UNIT_STAT_INTELLECT))
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%.f|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Intellect', STAT_CATEGORY_ATTRIBUTES, { 'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE' }, OnEvent, nil, nil, nil, nil, ITEM_MOD_INTELLECT_SHORT, nil, ValueColorUpdate)
|
||||
|
||||
65
Modules/DataTexts/ItemLevel.lua
Normal file
65
Modules/DataTexts/ItemLevel.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local ipairs = ipairs
|
||||
local strjoin = strjoin
|
||||
local format = format
|
||||
local pi = math.pi
|
||||
|
||||
local ITEM_LEVEL_ABBR = ITEM_LEVEL_ABBR
|
||||
local LFG_LIST_ITEM_LEVEL_INSTR_PVP_SHORT = LFG_LIST_ITEM_LEVEL_INSTR_PVP_SHORT
|
||||
local STAT_AVERAGE_ITEM_LEVEL = STAT_AVERAGE_ITEM_LEVEL
|
||||
local GMSURVEYRATING3 = GMSURVEYRATING3
|
||||
local GetAverageItemLevel= GetAverageItemLevel
|
||||
local GetInventoryItemLink = GetInventoryItemLink
|
||||
local GetInventoryItemTexture = GetInventoryItemTexture
|
||||
|
||||
local iconString = '|T%s:13:15:0:0:50:50:4:46:4:46|t %s'
|
||||
local slotID = { 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }
|
||||
local title, lastPanel = ''
|
||||
|
||||
local function colorize(num)
|
||||
if num >= 0 then
|
||||
return .1, 1, .1
|
||||
else
|
||||
return E:ColorGradient(-(pi/num), 1, .1, .1, 1, 1, .1, .1, 1, .1)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local avg, avgEquipped = GetAverageItemLevel()
|
||||
local same = avg == avgEquipped
|
||||
self.text:SetFormattedText(title .. (same and '%0.2f|r' or '%0.2f / %0.2f|r'), ITEM_LEVEL_ABBR, avgEquipped, (not same and avg) or '0')
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local avg, avgEquipped, avgPvp = GetAverageItemLevel()
|
||||
DT.tooltip:AddDoubleLine(STAT_AVERAGE_ITEM_LEVEL, format('%0.2f', avg), 1, 1, 1, .1, 1, .1)
|
||||
DT.tooltip:AddDoubleLine(GMSURVEYRATING3, format('%0.2f', avgEquipped), 1, 1, 1, colorize(avgEquipped - avg))
|
||||
DT.tooltip:AddDoubleLine(LFG_LIST_ITEM_LEVEL_INSTR_PVP_SHORT, format('%0.2f', avgPvp), 1, 1, 1, colorize(avgPvp - avg))
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
for _, k in ipairs(slotID) do
|
||||
local info = E:GetGearSlotInfo('player', k)
|
||||
local ilvl = (info and info ~= 'tooSoon') and info.iLvl
|
||||
if ilvl then
|
||||
local link = GetInventoryItemLink('player', k)
|
||||
local icon = GetInventoryItemTexture('player', k)
|
||||
DT.tooltip:AddDoubleLine(format(iconString, icon, link), ilvl, 1, 1, 1, colorize(ilvl - avg))
|
||||
end
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
title = strjoin('', '%s: ', hex)
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Item Level', 'Stats', {'PLAYER_AVG_ITEM_LEVEL_UPDATE'}, OnEvent, nil, nil, OnEnter, nil, _G.LFG_LIST_ITEM_LEVEL_INSTR_SHORT, nil, ValueColorUpdate)
|
||||
44
Modules/DataTexts/Leech.lua
Normal file
44
Modules/DataTexts/Leech.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local format, strjoin = format, strjoin
|
||||
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local GetLifesteal = GetLifesteal
|
||||
local CR_LIFESTEAL = CR_LIFESTEAL
|
||||
local CR_LIFESTEAL_TOOLTIP = CR_LIFESTEAL_TOOLTIP
|
||||
local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE
|
||||
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
|
||||
local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
local STAT_LIFESTEAL = STAT_LIFESTEAL
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local text = HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_LIFESTEAL)..' '..format('%.2F%%', GetLifesteal())..FONT_COLOR_CODE_CLOSE
|
||||
local tooltip = format(CR_LIFESTEAL_TOOLTIP, BreakUpLargeNumbers(GetCombatRating(CR_LIFESTEAL)), GetCombatRatingBonus(CR_LIFESTEAL))
|
||||
|
||||
DT.tooltip:AddDoubleLine(text, nil, 1, 1, 1)
|
||||
DT.tooltip:AddLine(tooltip, nil, nil, nil, true)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local lifesteal = GetLifesteal()
|
||||
self.text:SetFormattedText(displayString, STAT_LIFESTEAL, lifesteal)
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%.2f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Leech', STAT_CATEGORY_ENHANCEMENTS, {'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE', 'PLAYER_DAMAGE_DONE_MODS'}, OnEvent, nil, nil, OnEnter, nil, STAT_LIFESTEAL, nil, ValueColorUpdate)
|
||||
44
Modules/DataTexts/Load_DataTexts.xml
Normal file
44
Modules/DataTexts/Load_DataTexts.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<Ui xmlns='http://www.blizzard.com/wow/ui/'>
|
||||
<Script file='DataTexts.lua'/>
|
||||
|
||||
<Script file='Agility.lua'/>
|
||||
<Script file='Armor.lua'/>
|
||||
<Script file='Avoidance.lua'/>
|
||||
<Script file='Bags.lua'/>
|
||||
<Script file='BattleStats.lua'/>
|
||||
<Script file='CallToArms.lua'/>
|
||||
<Script file='CombatTime.lua'/>
|
||||
<Script file='ConfigElvUI.lua'/>
|
||||
<Script file='Coordinates.lua'/>
|
||||
<Script file='Crit.lua'/>
|
||||
<Script file='Currencies.lua'/>
|
||||
<Script file='CustomCurrency.lua'/>
|
||||
<Script file='Date.lua'/>
|
||||
<Script file='Difficulty.lua'/>
|
||||
<Script file='DPS.lua'/>
|
||||
<Script file='Durability.lua'/>
|
||||
<Script file='Experience.lua'/>
|
||||
<Script file='Friends.lua'/>
|
||||
<Script file='Gold.lua'/>
|
||||
<Script file='Guild.lua'/>
|
||||
<Script file='Haste.lua'/>
|
||||
<Script file='HPS.lua'/>
|
||||
<Script file='Intellect.lua'/>
|
||||
<Script file='ItemLevel.lua'/>
|
||||
<Script file='Leech.lua'/>
|
||||
<Script file='Mail.lua'/>
|
||||
<Script file='ManaRegen.lua'/>
|
||||
<Script file='Mastery.lua'/>
|
||||
<Script file='Missions.lua'/>
|
||||
<Script file='MovementSpeed.lua'/>
|
||||
<Script file='PrimaryStat.lua'/>
|
||||
<Script file='Quickjoin.lua'/>
|
||||
<Script file='Reputation.lua'/>
|
||||
<Script file='SpecSwitch.lua'/>
|
||||
<Script file='Speed.lua'/>
|
||||
<Script file='Stamina.lua'/>
|
||||
<Script file='Strength.lua'/>
|
||||
<Script file='System.lua'/>
|
||||
<Script file='Time.lua'/>
|
||||
<Script file='Versatility.lua'/>
|
||||
</Ui>
|
||||
42
Modules/DataTexts/Mail.lua
Normal file
42
Modules/DataTexts/Mail.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local next = next
|
||||
local pairs = pairs
|
||||
local strjoin = strjoin
|
||||
local HasNewMail = HasNewMail
|
||||
local GetLatestThreeSenders = GetLatestThreeSenders
|
||||
local HAVE_MAIL_FROM = HAVE_MAIL_FROM
|
||||
local MAIL_LABEL = MAIL_LABEL
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
self.text:SetFormattedText(displayString, HasNewMail() and 'New Mail' or 'No Mail')
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local senders = { GetLatestThreeSenders() }
|
||||
if not next(senders) then return end
|
||||
|
||||
DT.tooltip:AddLine(HasNewMail() and HAVE_MAIL_FROM or MAIL_LABEL, 1, 1, 1)
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
for _, sender in pairs(senders) do
|
||||
DT.tooltip:AddLine(sender)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin(hex, '%s|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Mail', nil, {'MAIL_INBOX_UPDATE', 'UPDATE_PENDING_MAIL', 'MAIL_CLOSED', 'MAIL_SHOW'}, OnEvent, nil, nil, OnEnter, nil, MAIL_LABEL, nil, ValueColorUpdate)
|
||||
30
Modules/DataTexts/ManaRegen.lua
Normal file
30
Modules/DataTexts/ManaRegen.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local GetManaRegen = GetManaRegen
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
local MANA_REGEN = MANA_REGEN
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
local baseMR, castingMR = GetManaRegen()
|
||||
if InCombatLockdown() then
|
||||
self.text:SetFormattedText(displayString, MANA_REGEN, castingMR*5)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, MANA_REGEN, baseMR*5)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s: ', hex, '%.2f|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Mana Regen', STAT_CATEGORY_ATTRIBUTES, {'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE'}, OnEvent, nil, nil, nil, nil, MANA_REGEN, nil, ValueColorUpdate)
|
||||
49
Modules/DataTexts/Mastery.lua
Normal file
49
Modules/DataTexts/Mastery.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local GetMasteryEffect = GetMasteryEffect
|
||||
local GetSpecialization = GetSpecialization
|
||||
local GetSpecializationMasterySpells = GetSpecializationMasterySpells
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
local STAT_MASTERY = STAT_MASTERY
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local primaryTalentTree = GetSpecialization()
|
||||
if primaryTalentTree then
|
||||
local masterySpell, masterySpell2 = GetSpecializationMasterySpells(primaryTalentTree)
|
||||
if masterySpell then
|
||||
DT.tooltip:AddSpellByID(masterySpell)
|
||||
end
|
||||
if masterySpell2 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddSpellByID(masterySpell2)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
local masteryRating = GetMasteryEffect()
|
||||
if E.global.datatexts.settings.Mastery.NoLabel then
|
||||
self.text:SetFormattedText(displayString, masteryRating)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Mastery.Label ~= '' and E.global.datatexts.settings.Mastery.Label or STAT_MASTERY..': ', masteryRating)
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Mastery.NoLabel and '' or '%s', hex, '%.'..E.global.datatexts.settings.Mastery.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Mastery', STAT_CATEGORY_ENHANCEMENTS, {'MASTERY_UPDATE'}, OnEvent, nil, nil, OnEnter, nil, STAT_MASTERY, nil, ValueColorUpdate)
|
||||
357
Modules/DataTexts/Missions.lua
Normal file
357
Modules/DataTexts/Missions.lua
Normal file
@@ -0,0 +1,357 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local next, wipe, ipairs = next, wipe, ipairs
|
||||
local format, sort, select = format, sort, select
|
||||
local GetMouseFocus = GetMouseFocus
|
||||
local HideUIPanel = HideUIPanel
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local ShowGarrisonLandingPage = ShowGarrisonLandingPage
|
||||
local C_Garrison_HasGarrison = C_Garrison.HasGarrison
|
||||
local C_Garrison_GetBuildings = C_Garrison.GetBuildings
|
||||
local C_Garrison_GetInProgressMissions = C_Garrison.GetInProgressMissions
|
||||
local C_Garrison_GetLandingPageShipmentInfo = C_Garrison.GetLandingPageShipmentInfo
|
||||
local C_Garrison_GetCompleteTalent = C_Garrison.GetCompleteTalent
|
||||
local C_Garrison_GetFollowerShipments = C_Garrison.GetFollowerShipments
|
||||
local C_Garrison_GetLandingPageShipmentInfoByContainerID = C_Garrison.GetLandingPageShipmentInfoByContainerID
|
||||
local C_Garrison_RequestLandingPageShipmentInfo = C_Garrison.RequestLandingPageShipmentInfo
|
||||
local C_Garrison_GetCompleteMissions = C_Garrison.GetCompleteMissions
|
||||
local C_Garrison_GetLooseShipments = C_Garrison.GetLooseShipments
|
||||
local C_Garrison_GetTalentTreeIDsByClassID = C_Garrison.GetTalentTreeIDsByClassID
|
||||
local C_Garrison_GetTalentTreeInfo = C_Garrison.GetTalentTreeInfo
|
||||
local C_QuestLog_IsQuestFlaggedCompleted = C_QuestLog.IsQuestFlaggedCompleted
|
||||
local C_IslandsQueue_GetIslandsWeeklyQuestID = C_IslandsQueue.GetIslandsWeeklyQuestID
|
||||
local C_CurrencyInfo_GetCurrencyInfo = C_CurrencyInfo.GetCurrencyInfo
|
||||
local C_Covenants_GetActiveCovenantID = C_Covenants.GetActiveCovenantID
|
||||
local C_CovenantCallings_AreCallingsUnlocked = C_CovenantCallings.AreCallingsUnlocked
|
||||
local CovenantCalling_Create = CovenantCalling_Create
|
||||
local GetMaxLevelForExpansionLevel = GetMaxLevelForExpansionLevel
|
||||
local GetQuestObjectiveInfo = GetQuestObjectiveInfo
|
||||
local SecondsToTime = SecondsToTime
|
||||
local IsAltKeyDown = IsAltKeyDown
|
||||
|
||||
local GARRISON_LANDING_NEXT = GARRISON_LANDING_NEXT
|
||||
local CAPACITANCE_WORK_ORDERS = CAPACITANCE_WORK_ORDERS
|
||||
local FOLLOWERLIST_LABEL_TROOPS = FOLLOWERLIST_LABEL_TROOPS
|
||||
local GARRISON_EMPTY_IN_PROGRESS_LIST = GARRISON_EMPTY_IN_PROGRESS_LIST
|
||||
local GARRISON_LANDING_SHIPMENT_COUNT = GARRISON_LANDING_SHIPMENT_COUNT
|
||||
local GOAL_COMPLETED = GOAL_COMPLETED
|
||||
local GREEN_FONT_COLOR = GREEN_FONT_COLOR
|
||||
local ISLANDS_HEADER = ISLANDS_HEADER
|
||||
local ISLANDS_QUEUE_FRAME_TITLE = ISLANDS_QUEUE_FRAME_TITLE
|
||||
local ISLANDS_QUEUE_WEEKLY_QUEST_PROGRESS = ISLANDS_QUEUE_WEEKLY_QUEST_PROGRESS
|
||||
local LE_EXPANSION_BATTLE_FOR_AZEROTH = LE_EXPANSION_BATTLE_FOR_AZEROTH
|
||||
local LE_FOLLOWER_TYPE_GARRISON_6_0 = Enum.GarrisonFollowerType.FollowerType_6_0
|
||||
local LE_FOLLOWER_TYPE_GARRISON_7_0 = Enum.GarrisonFollowerType.FollowerType_7_0
|
||||
local LE_FOLLOWER_TYPE_GARRISON_8_0 = Enum.GarrisonFollowerType.FollowerType_8_0
|
||||
local LE_FOLLOWER_TYPE_GARRISON_6_2 = Enum.GarrisonFollowerType.FollowerType_6_2
|
||||
local LE_FOLLOWER_TYPE_GARRISON_9_0 = Enum.GarrisonFollowerType.FollowerType_9_0
|
||||
local LE_GARRISON_TYPE_6_0 = Enum.GarrisonType.Type_6_0
|
||||
local LE_GARRISON_TYPE_7_0 = Enum.GarrisonType.Type_7_0
|
||||
local LE_GARRISON_TYPE_8_0 = Enum.GarrisonType.Type_8_0
|
||||
local LE_GARRISON_TYPE_9_0 = Enum.GarrisonType.Type_9_0
|
||||
local RESEARCH_TIME_LABEL = RESEARCH_TIME_LABEL
|
||||
local DATE_COMPLETED = DATE_COMPLETED:gsub('(%%s)', '|cFF33FF33%1|r') -- 'Completed: |cFF33FF33%s|r'
|
||||
local EXPANSION_NAME5 = EXPANSION_NAME5 -- 'Warlords of Draenor'
|
||||
local EXPANSION_NAME6 = EXPANSION_NAME6 -- 'Legion'
|
||||
local EXPANSION_NAME7 = EXPANSION_NAME7 -- 'Battle for Azeroth'
|
||||
local EXPANSION_NAME8 = EXPANSION_NAME8 -- 'Shadowlands'
|
||||
|
||||
local MAIN_CURRENCY = 1813
|
||||
local iconString = '|T%s:16:16:0:0:64:64:4:60:4:60|t'
|
||||
local numMissions = 0
|
||||
local callingsData = {}
|
||||
local covenantTreeIDs = {
|
||||
[1] = {308, 312, 316, 320, 327},
|
||||
[2] = {309, 314, 317, 324, 326},
|
||||
[3] = {307, 311, 315, 319, 328},
|
||||
[4] = {310, 313, 318, 321, 329}
|
||||
}
|
||||
|
||||
local function sortFunction(a, b)
|
||||
return a.missionEndTime < b.missionEndTime
|
||||
end
|
||||
|
||||
local function LandingPage(_, ...)
|
||||
if not C_Garrison_HasGarrison(...) then
|
||||
return
|
||||
end
|
||||
|
||||
HideUIPanel(_G.GarrisonLandingPage)
|
||||
ShowGarrisonLandingPage(...)
|
||||
end
|
||||
|
||||
local menuList = {
|
||||
{text = _G.GARRISON_LANDING_PAGE_TITLE, func = LandingPage, arg1 = LE_GARRISON_TYPE_6_0, notCheckable = true},
|
||||
{text = _G.ORDER_HALL_LANDING_PAGE_TITLE, func = LandingPage, arg1 = LE_GARRISON_TYPE_7_0, notCheckable = true},
|
||||
{text = _G.WAR_CAMPAIGN, func = LandingPage, arg1 = LE_GARRISON_TYPE_8_0, notCheckable = true},
|
||||
{text = _G.GARRISON_TYPE_9_0_LANDING_PAGE_TITLE, func = LandingPage, arg1 = LE_GARRISON_TYPE_9_0, notCheckable = true},
|
||||
}
|
||||
|
||||
local data = {}
|
||||
local function AddInProgressMissions(garrisonType)
|
||||
wipe(data)
|
||||
|
||||
C_Garrison_GetInProgressMissions(data, garrisonType)
|
||||
|
||||
if next(data) then
|
||||
sort(data, sortFunction) -- Sort by time left, lowest first
|
||||
|
||||
for _, mission in ipairs(data) do
|
||||
local timeLeft = mission.timeLeftSeconds
|
||||
local r, g, b = 1, 1, 1
|
||||
if mission.isRare then
|
||||
r, g, b = 0.09, 0.51, 0.81
|
||||
end
|
||||
|
||||
if timeLeft and timeLeft == 0 then
|
||||
DT.tooltip:AddDoubleLine(mission.name, GOAL_COMPLETED, r, g, b, GREEN_FONT_COLOR:GetRGB())
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(mission.name, SecondsToTime(timeLeft), r, g, b, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
else
|
||||
DT.tooltip:AddLine(GARRISON_EMPTY_IN_PROGRESS_LIST, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
local function AddFollowerInfo(garrisonType)
|
||||
data = C_Garrison_GetFollowerShipments(garrisonType)
|
||||
|
||||
if next(data) then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(FOLLOWERLIST_LABEL_TROOPS) -- 'Troops'
|
||||
for _, followerShipments in ipairs(data) do
|
||||
local name, _, _, shipmentsReady, shipmentsTotal, _, _, timeleftString = C_Garrison_GetLandingPageShipmentInfoByContainerID(followerShipments)
|
||||
if name and shipmentsReady and shipmentsTotal then
|
||||
if timeleftString then
|
||||
DT.tooltip:AddDoubleLine(name, format(GARRISON_LANDING_SHIPMENT_COUNT, shipmentsReady, shipmentsTotal) .. ' ' .. format(GARRISON_LANDING_NEXT,timeleftString), 1, 1, 1, 1, 1, 1)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(name, format(GARRISON_LANDING_SHIPMENT_COUNT, shipmentsReady, shipmentsTotal), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local covenantInfo = {}
|
||||
local function AddTalentInfo(garrisonType, currentCovenant)
|
||||
if garrisonType == LE_GARRISON_TYPE_9_0 then
|
||||
local current = covenantTreeIDs[currentCovenant]
|
||||
if current then
|
||||
wipe(covenantInfo)
|
||||
data = E:CopyTable(covenantInfo, current)
|
||||
else
|
||||
wipe(data)
|
||||
end
|
||||
else
|
||||
data = C_Garrison_GetTalentTreeIDsByClassID(garrisonType, E.myClassID)
|
||||
end
|
||||
|
||||
if next(data) then
|
||||
-- This is a talent that has completed, but has not been seen in the talent UI yet.
|
||||
-- No longer provide relevant output in SL. Still used by old content.
|
||||
local completeTalentID = C_Garrison_GetCompleteTalent(garrisonType)
|
||||
if completeTalentID > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(RESEARCH_TIME_LABEL) -- 'Research Time:'
|
||||
|
||||
for _, treeID in ipairs(data) do
|
||||
local treeInfo = C_Garrison_GetTalentTreeInfo(treeID)
|
||||
for _, talent in ipairs(treeInfo.talents) do
|
||||
if talent.isBeingResearched or (talent.id == completeTalentID and garrisonType ~= LE_GARRISON_TYPE_9_0)then
|
||||
if talent.timeRemaining and talent.timeRemaining == 0 then
|
||||
DT.tooltip:AddDoubleLine(talent.name, GOAL_COMPLETED, 1, 1, 1, GREEN_FONT_COLOR:GetRGB())
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(talent.name, SecondsToTime(talent.timeRemaining), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function GetInfo(id)
|
||||
local info = C_CurrencyInfo_GetCurrencyInfo(id)
|
||||
return info.quantity, info.name, (info.iconFileID and format(iconString, info.iconFileID)) or '136012'
|
||||
end
|
||||
|
||||
local function AddInfo(id)
|
||||
local quantity, _, icon = GetInfo(id)
|
||||
return format('%s %s', icon, BreakUpLargeNumbers(quantity))
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
DT.tooltip:AddLine(EXPANSION_NAME8, 1, .5, 0)
|
||||
DT.tooltip:AddDoubleLine(L["Mission(s) Report:"], AddInfo(1813), nil, nil, nil, 1, 1, 1)
|
||||
AddInProgressMissions(LE_FOLLOWER_TYPE_GARRISON_9_0)
|
||||
|
||||
if C_CovenantCallings_AreCallingsUnlocked() then
|
||||
local questNum = 0
|
||||
for _, calling in ipairs(callingsData) do
|
||||
local callingObj = CovenantCalling_Create(calling)
|
||||
if callingObj:GetState() == 0 then
|
||||
questNum = questNum + 1
|
||||
end
|
||||
end
|
||||
if questNum > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(format('%s %s', questNum, L["Calling Quest(s) available."]))
|
||||
end
|
||||
end
|
||||
|
||||
local currentCovenant = C_Covenants_GetActiveCovenantID()
|
||||
if currentCovenant and currentCovenant > 0 then
|
||||
AddTalentInfo(LE_GARRISON_TYPE_9_0, currentCovenant)
|
||||
end
|
||||
|
||||
if IsShiftKeyDown() then
|
||||
-- Battle for Azeroth
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(EXPANSION_NAME7, 1, .5, 0)
|
||||
DT.tooltip:AddDoubleLine(L["Mission(s) Report:"], AddInfo(1560), nil, nil, nil, 1, 1, 1)
|
||||
AddInProgressMissions(LE_FOLLOWER_TYPE_GARRISON_8_0)
|
||||
|
||||
-- Island Expeditions
|
||||
if E.mylevel >= GetMaxLevelForExpansionLevel(LE_EXPANSION_BATTLE_FOR_AZEROTH) then
|
||||
local questID = C_IslandsQueue_GetIslandsWeeklyQuestID()
|
||||
if questID then
|
||||
local _, _, finished, numFulfilled, numRequired = GetQuestObjectiveInfo(questID, 1, false)
|
||||
local text, r1, g1, b1
|
||||
|
||||
if finished or C_QuestLog_IsQuestFlaggedCompleted(questID) then
|
||||
text = GOAL_COMPLETED
|
||||
r1, g1, b1 = GREEN_FONT_COLOR:GetRGB()
|
||||
else
|
||||
text = ISLANDS_QUEUE_WEEKLY_QUEST_PROGRESS:format(numFulfilled, numRequired)
|
||||
r1, g1, b1 = 1, 1, 1
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(ISLANDS_HEADER .. ':')
|
||||
DT.tooltip:AddDoubleLine(ISLANDS_QUEUE_FRAME_TITLE, text, 1, 1, 1, r1, g1, b1)
|
||||
end
|
||||
end
|
||||
|
||||
AddFollowerInfo(LE_GARRISON_TYPE_7_0)
|
||||
AddTalentInfo(LE_GARRISON_TYPE_7_0)
|
||||
|
||||
-- Legion
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(EXPANSION_NAME6, 1, .5, 0)
|
||||
DT.tooltip:AddDoubleLine(L["Mission(s) Report:"], AddInfo(1220), nil, nil, nil, 1, 1, 1)
|
||||
|
||||
AddInProgressMissions(LE_FOLLOWER_TYPE_GARRISON_7_0)
|
||||
AddFollowerInfo(LE_GARRISON_TYPE_7_0)
|
||||
|
||||
-- 'Loose Work Orders' (i.e. research, equipment)
|
||||
data = C_Garrison_GetLooseShipments(LE_GARRISON_TYPE_7_0)
|
||||
if next(data) then
|
||||
DT.tooltip:AddLine(CAPACITANCE_WORK_ORDERS) -- 'Work Orders'
|
||||
|
||||
for _, looseShipments in ipairs(data) do
|
||||
local name, _, _, shipmentsReady, shipmentsTotal, _, _, timeleftString = C_Garrison_GetLandingPageShipmentInfoByContainerID(looseShipments)
|
||||
if name then
|
||||
if timeleftString then
|
||||
DT.tooltip:AddDoubleLine(name, format(GARRISON_LANDING_SHIPMENT_COUNT, shipmentsReady, shipmentsTotal) .. ' ' .. format(GARRISON_LANDING_NEXT,timeleftString), 1, 1, 1, 1, 1, 1)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(name, format(GARRISON_LANDING_SHIPMENT_COUNT, shipmentsReady, shipmentsTotal), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
AddTalentInfo(LE_GARRISON_TYPE_7_0)
|
||||
|
||||
-- Warlords of Draenor
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(EXPANSION_NAME5, 1, .5, 0)
|
||||
DT.tooltip:AddDoubleLine(L["Mission(s) Report:"], AddInfo(824), nil, nil, nil, 1, 1, 1)
|
||||
AddInProgressMissions(LE_FOLLOWER_TYPE_GARRISON_6_0)
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddDoubleLine(L["Naval Mission(s) Report:"], AddInfo(1101), nil, nil, nil, 1, 1 , 1)
|
||||
AddInProgressMissions(LE_FOLLOWER_TYPE_GARRISON_6_2)
|
||||
|
||||
--Buildings
|
||||
data = C_Garrison_GetBuildings(LE_GARRISON_TYPE_6_0)
|
||||
if next(data) then
|
||||
local AddLine = true
|
||||
for _, buildings in ipairs(data) do
|
||||
local name, _, _, shipmentsReady, shipmentsTotal, _, _, timeleftString = C_Garrison_GetLandingPageShipmentInfo(buildings.buildingID)
|
||||
if name and shipmentsTotal then
|
||||
if AddLine then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(L["Building(s) Report:"])
|
||||
AddLine = false
|
||||
end
|
||||
|
||||
if timeleftString then
|
||||
DT.tooltip:AddDoubleLine(name, format(GARRISON_LANDING_SHIPMENT_COUNT, shipmentsReady, shipmentsTotal) .. ' ' .. format(GARRISON_LANDING_NEXT,timeleftString), 1, 1, 1, 1, 1, 1)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(name, format(GARRISON_LANDING_SHIPMENT_COUNT, shipmentsReady, shipmentsTotal), 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine('Hold Shift - Show Previous Expansion', .66, .66, .66)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnClick(self)
|
||||
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
|
||||
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
if event == 'CURRENCY_DISPLAY_UPDATE' and select(1, ...) ~= MAIN_CURRENCY then
|
||||
return
|
||||
end
|
||||
|
||||
if event == 'COVENANT_CALLINGS_UPDATED' then
|
||||
wipe(callingsData)
|
||||
callingsData = ...
|
||||
end
|
||||
|
||||
if event == 'GARRISON_SHIPMENT_RECEIVED' or (event == 'SHIPMENT_UPDATE' and select(1, ...) == true) then
|
||||
C_Garrison_RequestLandingPageShipmentInfo()
|
||||
end
|
||||
|
||||
if event == 'GARRISON_MISSION_NPC_OPENED' then
|
||||
self:RegisterEvent('GARRISON_MISSION_LIST_UPDATE')
|
||||
elseif event == 'GARRISON_MISSION_NPC_CLOSED' then
|
||||
self:UnregisterEvent('GARRISON_MISSION_LIST_UPDATE')
|
||||
end
|
||||
|
||||
if event == 'GARRISON_LANDINGPAGE_SHIPMENTS' or event == 'GARRISON_MISSION_FINISHED' or event == 'GARRISON_MISSION_NPC_CLOSED' or event == 'GARRISON_MISSION_LIST_UPDATE' then
|
||||
numMissions = #C_Garrison_GetCompleteMissions(LE_FOLLOWER_TYPE_GARRISON_9_0)
|
||||
+ #C_Garrison_GetCompleteMissions(LE_FOLLOWER_TYPE_GARRISON_8_0)
|
||||
+ #C_Garrison_GetCompleteMissions(LE_FOLLOWER_TYPE_GARRISON_7_0)
|
||||
+ #C_Garrison_GetCompleteMissions(LE_FOLLOWER_TYPE_GARRISON_6_0)
|
||||
+ #C_Garrison_GetCompleteMissions(LE_FOLLOWER_TYPE_GARRISON_6_2)
|
||||
end
|
||||
|
||||
if numMissions > 0 then
|
||||
self.text:SetFormattedText(DATE_COMPLETED, numMissions)
|
||||
else
|
||||
self.text:SetText(AddInfo(MAIN_CURRENCY))
|
||||
end
|
||||
|
||||
if event == 'MODIFIER_STATE_CHANGED' and not IsAltKeyDown() and GetMouseFocus() == self then
|
||||
OnEnter(self)
|
||||
end
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Missions', nil, {'CURRENCY_DISPLAY_UPDATE', 'GARRISON_LANDINGPAGE_SHIPMENTS', 'GARRISON_TALENT_UPDATE', 'GARRISON_TALENT_COMPLETE', 'GARRISON_SHIPMENT_RECEIVED', 'SHIPMENT_UPDATE', 'GARRISON_MISSION_FINISHED', 'GARRISON_MISSION_NPC_CLOSED', 'GARRISON_MISSION_NPC_OPENED', 'MODIFIER_STATE_CHANGED', 'COVENANT_CALLINGS_UPDATED'}, OnEvent, nil, OnClick, OnEnter, nil, _G.GARRISON_MISSIONS)
|
||||
65
Modules/DataTexts/MovementSpeed.lua
Normal file
65
Modules/DataTexts/MovementSpeed.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local IsFalling = IsFalling
|
||||
local IsFlying = IsFlying
|
||||
local IsSwimming = IsSwimming
|
||||
local GetUnitSpeed = GetUnitSpeed
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
local BASE_MOVEMENT_SPEED = BASE_MOVEMENT_SPEED
|
||||
local STAT_MOVEMENT_SPEED = STAT_MOVEMENT_SPEED
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
local beforeFalling, wasFlying
|
||||
|
||||
local delayed
|
||||
local function DelayUpdate()
|
||||
if not lastPanel then return end
|
||||
|
||||
local _, runSpeed, flightSpeed, swimSpeed = GetUnitSpeed('player')
|
||||
local speed
|
||||
|
||||
if IsSwimming() then
|
||||
speed = swimSpeed
|
||||
wasFlying = false
|
||||
elseif IsFlying() then
|
||||
speed = flightSpeed
|
||||
wasFlying = true
|
||||
else
|
||||
speed = runSpeed
|
||||
wasFlying = false
|
||||
end
|
||||
|
||||
if IsFalling() and wasFlying and beforeFalling then
|
||||
speed = beforeFalling
|
||||
else
|
||||
beforeFalling = speed
|
||||
end
|
||||
|
||||
local percent = speed / BASE_MOVEMENT_SPEED * 100
|
||||
if E.global.datatexts.settings.MovementSpeed.NoLabel then
|
||||
lastPanel.text:SetFormattedText(displayString, percent)
|
||||
else
|
||||
lastPanel.text:SetFormattedText(displayString, E.global.datatexts.settings.MovementSpeed.Label ~= '' and E.global.datatexts.settings.MovementSpeed.Label or STAT_MOVEMENT_SPEED, percent)
|
||||
end
|
||||
|
||||
delayed = nil
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
if not delayed then
|
||||
delayed = E:Delay(0.05, DelayUpdate)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.MovementSpeed.NoLabel and '' or '%s: ', hex, '%.'..E.global.datatexts.settings.MovementSpeed.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('MovementSpeed', STAT_CATEGORY_ENHANCEMENTS, {'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE', 'UNIT_SPELL_HASTE'}, OnEvent, nil, nil, nil, nil, STAT_MOVEMENT_SPEED, nil, ValueColorUpdate)
|
||||
31
Modules/DataTexts/PrimaryStat.lua
Normal file
31
Modules/DataTexts/PrimaryStat.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local strjoin = strjoin
|
||||
local UnitStat = UnitStat
|
||||
local GetSpecialization = GetSpecialization
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
local PRIMARY_STAT = SPEC_FRAME_PRIMARY_STAT:gsub('[::%s]-%%s$','')
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
local StatID = DT.SPECIALIZATION_CACHE[GetSpecialization()] and DT.SPECIALIZATION_CACHE[GetSpecialization()].statID
|
||||
|
||||
local name = StatID and _G['SPELL_STAT'..StatID..'_NAME']
|
||||
if name then
|
||||
self.text:SetFormattedText(displayString, name..': ', UnitStat('player', StatID))
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', '%s', hex, '%.f|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Primary Stat', STAT_CATEGORY_ATTRIBUTES, { 'UNIT_STATS', 'UNIT_AURA', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_TALENT_UPDATE' }, OnEvent, nil, nil, nil, nil, PRIMARY_STAT, nil, ValueColorUpdate)
|
||||
125
Modules/DataTexts/Quickjoin.lua
Normal file
125
Modules/DataTexts/Quickjoin.lua
Normal file
@@ -0,0 +1,125 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
local CH = E:GetModule('Chat')
|
||||
|
||||
local next, pairs, select, type = next, pairs, select, type
|
||||
local format, strjoin, wipe, gsub = format, strjoin, wipe, gsub
|
||||
local ToggleQuickJoinPanel = ToggleQuickJoinPanel
|
||||
local SocialQueueUtil_GetQueueName = SocialQueueUtil_GetQueueName
|
||||
local SocialQueueUtil_GetRelationshipInfo = SocialQueueUtil_GetRelationshipInfo
|
||||
local C_SocialQueue_GetAllGroups = C_SocialQueue.GetAllGroups
|
||||
local C_SocialQueue_GetGroupMembers = C_SocialQueue.GetGroupMembers
|
||||
local C_SocialQueue_GetGroupQueues = C_SocialQueue.GetGroupQueues
|
||||
local C_LFGList_GetSearchResultInfo = C_LFGList.GetSearchResultInfo
|
||||
local UNKNOWN, QUICK_JOIN = UNKNOWN, QUICK_JOIN
|
||||
|
||||
local displayString = ''
|
||||
local quickJoin = {}
|
||||
|
||||
local function OnEnter()
|
||||
if not next(quickJoin) then return end
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
DT.tooltip:AddLine(QUICK_JOIN, nil, nil, nil, true)
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
for name, activity in pairs(quickJoin) do
|
||||
DT.tooltip:AddDoubleLine(name, activity, nil, nil, nil, 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function Update(self)
|
||||
wipe(quickJoin)
|
||||
|
||||
if not self then return end
|
||||
|
||||
local quickJoinGroups = C_SocialQueue_GetAllGroups()
|
||||
for _, guid in pairs(quickJoinGroups) do
|
||||
local players = C_SocialQueue_GetGroupMembers(guid)
|
||||
if players then
|
||||
local firstMember, numMembers, extraCount = players[1], #players, ''
|
||||
local playerName, nameColor = SocialQueueUtil_GetRelationshipInfo(firstMember.guid, nil, firstMember.clubId)
|
||||
if numMembers > 1 then extraCount = format(' +%s', numMembers - 1) end
|
||||
|
||||
local queues = C_SocialQueue_GetGroupQueues(guid)
|
||||
local firstQueue, numQueues = queues and queues[1], queues and #queues or 0
|
||||
local isLFGList = firstQueue and firstQueue.queueData and firstQueue.queueData.queueType == 'lfglist'
|
||||
local coloredName = (playerName and playerName ~= '' and format('%s%s|r%s', nameColor, playerName, extraCount)) or format('{%s%s}', UNKNOWN, extraCount)
|
||||
|
||||
local activity
|
||||
if isLFGList and firstQueue and firstQueue.eligible then
|
||||
local activityName, isLeader, leaderName
|
||||
if firstQueue.queueData.lfgListID then
|
||||
local searchResultInfo = C_LFGList_GetSearchResultInfo(firstQueue.queueData.lfgListID)
|
||||
if searchResultInfo then
|
||||
activityName, leaderName = searchResultInfo.name, searchResultInfo.leaderName
|
||||
isLeader = CH:SocialQueueIsLeader(playerName, leaderName)
|
||||
end
|
||||
end
|
||||
|
||||
if isLeader then
|
||||
coloredName = format([[|TInterface\GroupFrame\UI-Group-LeaderIcon:16:16|t%s]], coloredName)
|
||||
end
|
||||
|
||||
activity = activityName or UNKNOWN
|
||||
if numQueues > 1 then
|
||||
activity = format('[+%s]%s', numQueues - 1, activity)
|
||||
end
|
||||
elseif firstQueue then
|
||||
local output, queueCount = '', 0
|
||||
for _, queue in pairs(queues) do
|
||||
if type(queue) == 'table' and queue.eligible then
|
||||
local queueName = (queue.queueData and SocialQueueUtil_GetQueueName(queue.queueData)) or ''
|
||||
if queueName ~= '' then
|
||||
if output == '' then
|
||||
output = gsub(queueName,'\n.+','') -- grab only the first queue name
|
||||
queueCount = queueCount + select(2, gsub(queueName,'\n','')) -- collect additional on single queue
|
||||
else
|
||||
queueCount = queueCount + 1 + select(2, gsub(queueName,'\n','')) -- collect additional on additional queues
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if output ~= '' then
|
||||
if queueCount > 0 then
|
||||
activity = format('%s[+%s]', output, queueCount)
|
||||
else
|
||||
activity = output
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
quickJoin[coloredName] = activity
|
||||
end
|
||||
end
|
||||
|
||||
if E.global.datatexts.settings.QuickJoin.NoLabel then
|
||||
self.text:SetFormattedText(displayString, #quickJoinGroups)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.QuickJoin.Label ~= '' and E.global.datatexts.settings.QuickJoin.Label or QUICK_JOIN..': ', #quickJoinGroups)
|
||||
end
|
||||
end
|
||||
|
||||
local delayed, lastPanel
|
||||
local function throttle()
|
||||
if lastPanel then Update(lastPanel) end
|
||||
delayed = nil
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
if lastPanel ~= self then lastPanel = self end
|
||||
if delayed then return end
|
||||
|
||||
-- use a nonarg passing function, so that it goes through c_timer instead of the waitframe
|
||||
delayed = E:Delay(event == 'ELVUI_FORCE_UPDATE' and 0 or 1, throttle)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.QuickJoin.NoLabel and '' or '%s', hex, '%d|r')
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
DT:RegisterDatatext('QuickJoin', _G.SOCIAL_LABEL, {"SOCIAL_QUEUE_UPDATE"}, OnEvent, nil, ToggleQuickJoinPanel, OnEnter, nil, QUICK_JOIN, nil, ValueColorUpdate)
|
||||
114
Modules/DataTexts/Reputation.lua
Normal file
114
Modules/DataTexts/Reputation.lua
Normal file
@@ -0,0 +1,114 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local format = format
|
||||
local C_Reputation_GetFactionParagonInfo = C_Reputation.GetFactionParagonInfo
|
||||
local C_Reputation_IsFactionParagon = C_Reputation.IsFactionParagon
|
||||
local GetFriendshipReputation = GetFriendshipReputation
|
||||
local ToggleCharacter = ToggleCharacter
|
||||
local GetWatchedFactionInfo = GetWatchedFactionInfo
|
||||
local REPUTATION, STANDING = REPUTATION, STANDING
|
||||
|
||||
local function OnEvent(self)
|
||||
local name, reaction, min, max, value, factionID = GetWatchedFactionInfo()
|
||||
if not name then return end
|
||||
|
||||
local friendshipID = GetFriendshipReputation(factionID);
|
||||
local isFriend, friendText, standingLabel
|
||||
local isCapped
|
||||
|
||||
if friendshipID then
|
||||
local _, friendRep, _, _, _, _, friendTextLevel, friendThreshold, nextFriendThreshold = GetFriendshipReputation(factionID);
|
||||
isFriend, reaction, friendText = true, 5, friendTextLevel
|
||||
if nextFriendThreshold then
|
||||
min, max, value = friendThreshold, nextFriendThreshold, friendRep;
|
||||
else
|
||||
isCapped = true;
|
||||
end
|
||||
elseif C_Reputation_IsFactionParagon(factionID) then
|
||||
local currentValue, threshold, _, hasRewardPending = C_Reputation_GetFactionParagonInfo(factionID)
|
||||
if currentValue and threshold then
|
||||
min, max = 0, threshold
|
||||
value = currentValue % threshold
|
||||
if hasRewardPending then
|
||||
value = value + threshold
|
||||
end
|
||||
end
|
||||
else
|
||||
if reaction == _G.MAX_REPUTATION_REACTION then
|
||||
isCapped = true
|
||||
end
|
||||
end
|
||||
|
||||
local color = _G.FACTION_BAR_COLORS[reaction]
|
||||
local text = ''
|
||||
local textFormat = E.global.datatexts.settings.Reputation.textFormat
|
||||
|
||||
standingLabel = E:RGBToHex(color.r, color.g, color.b, nil, _G['FACTION_STANDING_LABEL'..reaction]..'|r')
|
||||
|
||||
--Prevent a division by zero
|
||||
local maxMinDiff = max - min
|
||||
if maxMinDiff == 0 then
|
||||
maxMinDiff = 1
|
||||
end
|
||||
|
||||
if isCapped then
|
||||
text = format('%s: [%s]', name, isFriend and friendText or standingLabel)
|
||||
else
|
||||
if textFormat == 'PERCENT' then
|
||||
text = format('%s: %d%% [%s]', name, ((value - min) / (maxMinDiff) * 100), isFriend and friendText or standingLabel)
|
||||
elseif textFormat == 'CURMAX' then
|
||||
text = format('%s: %s - %s [%s]', name, E:ShortValue(value - min), E:ShortValue(max - min), isFriend and friendText or standingLabel)
|
||||
elseif textFormat == 'CURPERC' then
|
||||
text = format('%s: %s - %d%% [%s]', name, E:ShortValue(value - min), ((value - min) / (maxMinDiff) * 100), isFriend and friendText or standingLabel)
|
||||
elseif textFormat == 'CUR' then
|
||||
text = format('%s: %s [%s]', name, E:ShortValue(value - min), isFriend and friendText or standingLabel)
|
||||
elseif textFormat == 'REM' then
|
||||
text = format('%s: %s [%s]', name, E:ShortValue((max - min) - (value-min)), isFriend and friendText or standingLabel)
|
||||
elseif textFormat == 'CURREM' then
|
||||
text = format('%s: %s - %s [%s]', name, E:ShortValue(value - min), E:ShortValue((max - min) - (value-min)), isFriend and friendText or standingLabel)
|
||||
elseif textFormat == 'CURPERCREM' then
|
||||
text = format('%s: %s - %d%% (%s) [%s]', name, E:ShortValue(value - min), ((value - min) / (maxMinDiff) * 100), E:ShortValue((max - min) - (value-min)), isFriend and friendText or standingLabel)
|
||||
end
|
||||
end
|
||||
|
||||
self.text:SetText(text)
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local name, reaction, min, max, value, factionID = GetWatchedFactionInfo()
|
||||
if factionID and C_Reputation_IsFactionParagon(factionID) then
|
||||
local currentValue, threshold, _, hasRewardPending = C_Reputation_GetFactionParagonInfo(factionID)
|
||||
if currentValue and threshold then
|
||||
min, max = 0, threshold
|
||||
value = currentValue % threshold
|
||||
if hasRewardPending then
|
||||
value = value + threshold
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if name then
|
||||
DT.tooltip:AddLine(name)
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
local friendID, friendTextLevel, _
|
||||
if factionID then friendID, _, _, _, _, _, friendTextLevel = GetFriendshipReputation(factionID) end
|
||||
|
||||
DT.tooltip:AddDoubleLine(STANDING..':', (friendID and friendTextLevel) or _G['FACTION_STANDING_LABEL'..reaction], 1, 1, 1)
|
||||
if reaction ~= _G.MAX_REPUTATION_REACTION or C_Reputation_IsFactionParagon(factionID) then
|
||||
DT.tooltip:AddDoubleLine(REPUTATION..':', format('%d / %d (%d%%)', value - min, max - min, (value - min) / ((max - min == 0) and max or (max - min)) * 100), 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
ToggleCharacter('ReputationFrame')
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Reputation', nil, {'UPDATE_FACTION', 'COMBAT_TEXT_UPDATE'}, OnEvent, nil, OnClick, OnEnter, nil, REPUTATION)
|
||||
160
Modules/DataTexts/SpecSwitch.lua
Normal file
160
Modules/DataTexts/SpecSwitch.lua
Normal file
@@ -0,0 +1,160 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local ipairs, wipe = ipairs, wipe
|
||||
local format, next, strjoin = format, next, strjoin
|
||||
local GetLootSpecialization = GetLootSpecialization
|
||||
local GetNumSpecializations = GetNumSpecializations
|
||||
local GetPvpTalentInfoByID = GetPvpTalentInfoByID
|
||||
local GetSpecialization = GetSpecialization
|
||||
local GetSpecializationInfo = GetSpecializationInfo
|
||||
local GetTalentInfo = GetTalentInfo
|
||||
local HideUIPanel = HideUIPanel
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local SetLootSpecialization = SetLootSpecialization
|
||||
local SetSpecialization = SetSpecialization
|
||||
local ShowUIPanel = ShowUIPanel
|
||||
local LOOT = LOOT
|
||||
local TALENTS = TALENTS
|
||||
local PVP_TALENTS = PVP_TALENTS
|
||||
local SELECT_LOOT_SPECIALIZATION = SELECT_LOOT_SPECIALIZATION
|
||||
local LOOT_SPECIALIZATION_DEFAULT = LOOT_SPECIALIZATION_DEFAULT
|
||||
local C_SpecializationInfo_GetAllSelectedPvpTalentIDs = C_SpecializationInfo.GetAllSelectedPvpTalentIDs
|
||||
|
||||
local displayString, lastPanel, active = ''
|
||||
local activeString = strjoin('', '|cff00FF00' , _G.ACTIVE_PETS, '|r')
|
||||
local inactiveString = strjoin('', '|cffFF0000', _G.FACTION_INACTIVE, '|r')
|
||||
local menuList = {
|
||||
{ text = SELECT_LOOT_SPECIALIZATION, isTitle = true, notCheckable = true },
|
||||
{ checked = function() return GetLootSpecialization() == 0 end, func = function() SetLootSpecialization(0) end },
|
||||
}
|
||||
|
||||
local specList = {
|
||||
{ text = _G.SPECIALIZATION, isTitle = true, notCheckable = true },
|
||||
}
|
||||
|
||||
local mainIcon = '|T%s:16:16:0:0:64:64:4:60:4:60|t'
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
if #menuList == 2 then
|
||||
for index = 1, GetNumSpecializations() do
|
||||
local id, name, _, icon = GetSpecializationInfo(index)
|
||||
if id then
|
||||
menuList[index + 2] = { text = name, checked = function() return GetLootSpecialization() == id end, func = function() SetLootSpecialization(id) end }
|
||||
specList[index + 1] = { text = format('|T%s:14:14:0:0:64:64:4:60:4:60|t %s', icon, name), checked = function() return GetSpecialization() == index end, func = function() SetSpecialization(index) end }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local specIndex = GetSpecialization()
|
||||
local specialization = GetLootSpecialization()
|
||||
local info = DT.SPECIALIZATION_CACHE[specIndex]
|
||||
|
||||
if not info then
|
||||
self.text:SetText('N/A')
|
||||
return
|
||||
end
|
||||
|
||||
active = specIndex
|
||||
|
||||
local spec = format(mainIcon, info.icon)
|
||||
|
||||
if specialization == 0 or info.id == specialization then
|
||||
self.text:SetFormattedText('%s %s', spec, info.name)
|
||||
else
|
||||
info = DT.SPECIALIZATION_CACHE[specialization]
|
||||
self.text:SetFormattedText('%s: %s %s: %s', L["Spec"], spec, LOOT, format(mainIcon, info.icon))
|
||||
end
|
||||
end
|
||||
|
||||
local listIcon = '|T%s:16:16:0:0:50:50:4:46:4:46|t'
|
||||
local function AddTexture(texture)
|
||||
return texture and format(listIcon, texture) or ''
|
||||
end
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
for i, info in ipairs(DT.SPECIALIZATION_CACHE) do
|
||||
DT.tooltip:AddLine(strjoin(' ', format(displayString, info.name), AddTexture(info.icon), (i == active and activeString or inactiveString)), 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
|
||||
local specialization = GetLootSpecialization()
|
||||
local sameSpec = specialization == 0 and GetSpecialization()
|
||||
local specIndex = DT.SPECIALIZATION_CACHE[sameSpec or specialization]
|
||||
if specIndex and specIndex.name then
|
||||
DT.tooltip:AddLine(format('|cffFFFFFF%s:|r %s', SELECT_LOOT_SPECIALIZATION, sameSpec and format(LOOT_SPECIALIZATION_DEFAULT, specIndex.name) or specIndex.name))
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(TALENTS, 0.69, 0.31, 0.31)
|
||||
|
||||
for i = 1, _G.MAX_TALENT_TIERS do
|
||||
for j = 1, 3 do
|
||||
local _, name, icon, selected = GetTalentInfo(i, j, 1)
|
||||
if selected then
|
||||
DT.tooltip:AddLine(AddTexture(icon)..' '..name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local pvpTalents = C_SpecializationInfo_GetAllSelectedPvpTalentIDs()
|
||||
if next(pvpTalents) then
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(PVP_TALENTS, 0.69, 0.31, 0.31)
|
||||
|
||||
for i, talentID in next, pvpTalents do
|
||||
if i > 4 then break end
|
||||
local _, name, icon, _, _, _, unlocked = GetPvpTalentInfoByID(talentID)
|
||||
if name and unlocked then
|
||||
DT.tooltip:AddLine(AddTexture(icon)..' '..name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
DT.tooltip:AddLine(L["|cffFFFFFFLeft Click:|r Change Talent Specialization"])
|
||||
DT.tooltip:AddLine(L["|cffFFFFFFShift + Left Click:|r Show Talent Specialization UI"])
|
||||
DT.tooltip:AddLine(L["|cffFFFFFFRight Click:|r Change Loot Specialization"])
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnClick(self, button)
|
||||
local specIndex = GetSpecialization()
|
||||
if not specIndex then return end
|
||||
|
||||
if button == 'LeftButton' then
|
||||
if not _G.PlayerTalentFrame then
|
||||
_G.LoadAddOn('Blizzard_TalentUI')
|
||||
end
|
||||
if IsShiftKeyDown() then
|
||||
if not _G.PlayerTalentFrame:IsShown() then
|
||||
ShowUIPanel(_G.PlayerTalentFrame)
|
||||
else
|
||||
HideUIPanel(_G.PlayerTalentFrame)
|
||||
end
|
||||
else
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(specList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
end
|
||||
else
|
||||
local _, specName = GetSpecializationInfo(specIndex)
|
||||
menuList[2].text = format(LOOT_SPECIALIZATION_DEFAULT, specName)
|
||||
|
||||
DT:SetEasyMenuAnchor(DT.EasyMenu, self)
|
||||
_G.EasyMenu(menuList, DT.EasyMenu, nil, nil, nil, 'MENU')
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate()
|
||||
displayString = strjoin('', '|cffFFFFFF%s:|r ')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Talent/Loot Specialization', nil, {'CHARACTER_POINTS_CHANGED', 'PLAYER_TALENT_UPDATE', 'ACTIVE_TALENT_GROUP_CHANGED', 'PLAYER_LOOT_SPEC_UPDATED'}, OnEvent, nil, OnClick, OnEnter, nil, L["Talent/Loot Specialization"])
|
||||
49
Modules/DataTexts/Speed.lua
Normal file
49
Modules/DataTexts/Speed.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local format, strjoin = format, strjoin
|
||||
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local GetSpeed = GetSpeed
|
||||
local CR_SPEED = CR_SPEED
|
||||
local CR_SPEED_TOOLTIP = CR_SPEED_TOOLTIP
|
||||
local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE
|
||||
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
|
||||
local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
|
||||
local STAT_SPEED = STAT_SPEED
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local text = HIGHLIGHT_FONT_COLOR_CODE..format(PAPERDOLLFRAME_TOOLTIP_FORMAT, STAT_SPEED)..' '..format('%.2F%%', GetSpeed())..FONT_COLOR_CODE_CLOSE
|
||||
local tooltip = format(CR_SPEED_TOOLTIP, BreakUpLargeNumbers(GetCombatRating(CR_SPEED)), GetCombatRatingBonus(CR_SPEED))
|
||||
|
||||
DT.tooltip:AddDoubleLine(text, nil, 1, 1, 1)
|
||||
DT.tooltip:AddLine(tooltip, nil, nil, nil, true)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local speed = GetSpeed()
|
||||
if E.global.datatexts.settings.Speed.NoLabel then
|
||||
self.text:SetFormattedText(displayString, speed)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Speed.Label ~= '' and E.global.datatexts.settings.Speed.Label or STAT_SPEED, speed)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Speed.NoLabel and '' or '%s:', hex, '%.'..E.global.datatexts.settings.Speed.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Speed', STAT_CATEGORY_ENHANCEMENTS, {"UNIT_STATS", "UNIT_AURA", "ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE", "PLAYER_DAMAGE_DONE_MODS"}, OnEvent, nil, nil, OnEnter, nil, STAT_SPEED, nil, ValueColorUpdate)
|
||||
30
Modules/DataTexts/Stamina.lua
Normal file
30
Modules/DataTexts/Stamina.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...))
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local UnitStat = UnitStat
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
local ITEM_MOD_STAMINA_SHORT = ITEM_MOD_STAMINA_SHORT
|
||||
local LE_UNIT_STAT_STAMINA = LE_UNIT_STAT_STAMINA
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
if E.global.datatexts.settings.Stamina.NoLabel then
|
||||
self.text:SetFormattedText(displayString, UnitStat("player", LE_UNIT_STAT_STAMINA))
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Stamina.Label ~= '' and E.global.datatexts.settings.Stamina.Label or ITEM_MOD_STAMINA_SHORT..': ', UnitStat("player", LE_UNIT_STAT_STAMINA))
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Stamina.NoLabel and '' or '%s', hex, '%d|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Stamina', STAT_CATEGORY_ATTRIBUTES, { "UNIT_STATS", "UNIT_AURA", "ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE" }, OnEvent, nil, nil, nil, nil, ITEM_MOD_STAMINA_SHORT, nil, ValueColorUpdate)
|
||||
30
Modules/DataTexts/Strength.lua
Normal file
30
Modules/DataTexts/Strength.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...))
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local strjoin = strjoin
|
||||
local UnitStat = UnitStat
|
||||
local ITEM_MOD_STRENGTH_SHORT = ITEM_MOD_STRENGTH_SHORT
|
||||
local LE_UNIT_STAT_STRENGTH = LE_UNIT_STAT_STRENGTH
|
||||
local STAT_CATEGORY_ATTRIBUTES = STAT_CATEGORY_ATTRIBUTES
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEvent(self)
|
||||
if E.global.datatexts.settings.Strength.NoLabel then
|
||||
self.text:SetFormattedText(displayString, UnitStat("player", LE_UNIT_STAT_STRENGTH))
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Strength.Label ~= '' and E.global.datatexts.settings.Strength.Label or ITEM_MOD_STRENGTH_SHORT..': ', UnitStat("player", LE_UNIT_STAT_STRENGTH))
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Strength.NoLabel and '' or '%s', hex, '%d|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Strength', STAT_CATEGORY_ATTRIBUTES, { "UNIT_STATS", "UNIT_AURA", "ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE" }, OnEvent, nil, nil, nil, nil, ITEM_MOD_STRENGTH_SHORT, nil, ValueColorUpdate)
|
||||
271
Modules/DataTexts/System.lua
Normal file
271
Modules/DataTexts/System.lua
Normal file
@@ -0,0 +1,271 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local collectgarbage = collectgarbage
|
||||
local tremove, tinsert, sort, wipe, type = tremove, tinsert, sort, wipe, type
|
||||
local ipairs, pairs, floor, format, strmatch = ipairs, pairs, floor, format, strmatch
|
||||
local GetAddOnCPUUsage = GetAddOnCPUUsage
|
||||
local GetAddOnInfo = GetAddOnInfo
|
||||
local GetAddOnMemoryUsage = GetAddOnMemoryUsage
|
||||
local GetAvailableBandwidth = GetAvailableBandwidth
|
||||
local GetFileStreamingStatus = GetFileStreamingStatus
|
||||
local GetBackgroundLoadingStatus = GetBackgroundLoadingStatus
|
||||
local GetDownloadedPercentage = GetDownloadedPercentage
|
||||
local SetCVar = SetCVar
|
||||
local GetCVar = GetCVar
|
||||
local ReloadUI = ReloadUI
|
||||
local GetCVarBool = GetCVarBool
|
||||
local GetFramerate = GetFramerate
|
||||
local GetNetIpTypes = GetNetIpTypes
|
||||
local GetNetStats = GetNetStats
|
||||
local GetNumAddOns = GetNumAddOns
|
||||
local IsAddOnLoaded = IsAddOnLoaded
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local IsControlKeyDown = IsControlKeyDown
|
||||
local ResetCPUUsage = ResetCPUUsage
|
||||
local UpdateAddOnCPUUsage = UpdateAddOnCPUUsage
|
||||
local UpdateAddOnMemoryUsage = UpdateAddOnMemoryUsage
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local UNKNOWN = UNKNOWN
|
||||
|
||||
local statusColors = {
|
||||
'|cff0CD809',
|
||||
'|cffE8DA0F',
|
||||
'|cffFF9000',
|
||||
'|cffD80909'
|
||||
}
|
||||
|
||||
local enteredFrame = false
|
||||
local bandwidthString = '%.2f Mbps'
|
||||
local percentageString = '%.2f%%'
|
||||
local homeLatencyString = '%d ms'
|
||||
local kiloByteString = '%d kb'
|
||||
local megaByteString = '%.2f mb'
|
||||
local profilingString = '%s%s|r |cffffffff/|r %s%s|r'
|
||||
local cpuProfiling = GetCVar('scriptProfile') == '1'
|
||||
|
||||
local CombineAddOns = {
|
||||
['DBM-Core'] = '^<DBM>',
|
||||
['DataStore'] = '^DataStore',
|
||||
['Altoholic'] = '^Altoholic',
|
||||
['AtlasLoot'] = '^AtlasLoot',
|
||||
['Details'] = '^Details!',
|
||||
['RaiderIO'] = '^RaiderIO',
|
||||
['BigWigs'] = '^BigWigs',
|
||||
}
|
||||
|
||||
local function formatMem(memory)
|
||||
local mult = 10^1
|
||||
if memory >= 1024 then
|
||||
return format(megaByteString, ((memory/1024) * mult) / mult)
|
||||
else
|
||||
return format(kiloByteString, (memory * mult) / mult)
|
||||
end
|
||||
end
|
||||
|
||||
local infoTable = {}
|
||||
DT.SystemInfo = infoTable
|
||||
|
||||
local function BuildAddonList()
|
||||
local addOnCount = GetNumAddOns()
|
||||
if addOnCount == #infoTable then return end
|
||||
|
||||
wipe(infoTable)
|
||||
|
||||
for i = 1, addOnCount do
|
||||
local name, title, _, loadable, reason = GetAddOnInfo(i)
|
||||
if loadable or reason == 'DEMAND_LOADED' then
|
||||
tinsert(infoTable, {name = name, index = i, title = title})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
if IsShiftKeyDown() then
|
||||
if IsControlKeyDown() then
|
||||
SetCVar('scriptProfile', GetCVarBool('scriptProfile') and 0 or 1)
|
||||
ReloadUI()
|
||||
else
|
||||
collectgarbage('collect')
|
||||
ResetCPUUsage()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function displayData(data, totalMEM, totalCPU)
|
||||
if not data then return end
|
||||
|
||||
local name, mem, cpu = data.title, data.mem, data.cpu
|
||||
if cpu then
|
||||
local memRed, cpuRed = mem / totalMEM, cpu / totalCPU
|
||||
local memGreen, cpuGreen = (1 - memRed) + .5, (1 - cpuRed) + .5
|
||||
DT.tooltip:AddDoubleLine(name, format(profilingString, E:RGBToHex(memRed, memGreen, 0), formatMem(mem), E:RGBToHex(cpuRed, cpuGreen, 0), format(homeLatencyString, cpu)), 1, 1, 1)
|
||||
else
|
||||
local red = mem / totalMEM
|
||||
local green = (1 - red) + .5
|
||||
DT.tooltip:AddDoubleLine(name, formatMem(mem), 1, 1, 1, red or 1, green or 1, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local function displaySort(a, b)
|
||||
return a.sort > b.sort
|
||||
end
|
||||
|
||||
local infoDisplay, ipTypes = {}, {'IPv4', 'IPv6'}
|
||||
local function OnEnter(_, slow)
|
||||
DT.tooltip:ClearLines()
|
||||
enteredFrame = true
|
||||
|
||||
local _, _, homePing, worldPing = GetNetStats()
|
||||
DT.tooltip:AddDoubleLine(L["Home Latency:"], format(homeLatencyString, homePing), .69, .31, .31, .84, .75, .65)
|
||||
DT.tooltip:AddDoubleLine(L["World Latency:"], format(homeLatencyString, worldPing), .69, .31, .31, .84, .75, .65)
|
||||
|
||||
if GetCVarBool('useIPv6') then
|
||||
local ipTypeHome, ipTypeWorld = GetNetIpTypes()
|
||||
DT.tooltip:AddDoubleLine(L["Home Protocol:"], ipTypes[ipTypeHome or 0] or UNKNOWN, .69, .31, .31, .84, .75, .65)
|
||||
DT.tooltip:AddDoubleLine(L["World Protocol:"], ipTypes[ipTypeWorld or 0] or UNKNOWN, .69, .31, .31, .84, .75, .65)
|
||||
end
|
||||
|
||||
local Downloading = GetFileStreamingStatus() ~= 0 or GetBackgroundLoadingStatus() ~= 0
|
||||
if Downloading then
|
||||
DT.tooltip:AddDoubleLine(L["Bandwidth"] , format(bandwidthString, GetAvailableBandwidth()), .69, .31, .31, .84, .75, .65)
|
||||
DT.tooltip:AddDoubleLine(L["Download"] , format(percentageString, GetDownloadedPercentage() * 100), .69, .31, .31, .84, .75, .65)
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
|
||||
if slow == 1 or not slow then
|
||||
UpdateAddOnMemoryUsage()
|
||||
end
|
||||
|
||||
if cpuProfiling and not slow then
|
||||
UpdateAddOnCPUUsage()
|
||||
end
|
||||
|
||||
wipe(infoDisplay)
|
||||
|
||||
local count, totalMEM, totalCPU = 0, 0, 0
|
||||
local showByCPU = cpuProfiling and not IsShiftKeyDown()
|
||||
for _, data in ipairs(infoTable) do
|
||||
local i = data.index
|
||||
if IsAddOnLoaded(i) then
|
||||
local mem = GetAddOnMemoryUsage(i)
|
||||
totalMEM = totalMEM + mem
|
||||
|
||||
local cpu
|
||||
if cpuProfiling then
|
||||
cpu = GetAddOnCPUUsage(i)
|
||||
totalCPU = totalCPU + cpu
|
||||
end
|
||||
|
||||
data.sort = (showByCPU and cpu) or mem
|
||||
data.cpu = showByCPU and cpu
|
||||
data.mem = mem
|
||||
|
||||
count = count + 1
|
||||
infoDisplay[count] = data
|
||||
|
||||
if data.name == 'ElvUI' or data.name == 'ElvUI_OptionsUI' then
|
||||
infoTable[data.name] = data
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["AddOn Memory:"], formatMem(totalMEM), .69, .31, .31, .84, .75, .65)
|
||||
if cpuProfiling then
|
||||
DT.tooltip:AddDoubleLine(L["Total CPU:"], format(homeLatencyString, totalCPU), .69, .31, .31, .84, .75, .65)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
if not E.global.datatexts.settings.System.ShowOthers then
|
||||
displayData(infoTable.ElvUI, totalMEM, totalCPU)
|
||||
displayData(infoTable.ElvUI_OptionsUI, totalMEM, totalCPU)
|
||||
DT.tooltip:AddLine(' ')
|
||||
else
|
||||
for addon, searchString in pairs(CombineAddOns) do
|
||||
local addonIndex, memoryUsage, cpuUsage = 0, 0, 0
|
||||
for i, data in pairs(infoDisplay) do
|
||||
if data and data.name == addon then
|
||||
addonIndex = i
|
||||
break
|
||||
end
|
||||
end
|
||||
for k, data in pairs(infoDisplay) do
|
||||
if type(data) == 'table' then
|
||||
local name, mem, cpu = data.title, data.mem, data.cpu
|
||||
local stripName = E:StripString(data.title)
|
||||
if name and (strmatch(stripName, searchString) or data.name == addon) then
|
||||
if data.name ~= addon and stripName ~= addon then
|
||||
memoryUsage = memoryUsage + mem;
|
||||
if showByCPU and cpuProfiling then
|
||||
cpuUsage = cpuUsage + cpu;
|
||||
end
|
||||
infoDisplay[k] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if addonIndex > 0 and infoDisplay[addonIndex] then
|
||||
if memoryUsage > 0 then infoDisplay[addonIndex].mem = memoryUsage end
|
||||
if cpuProfiling and cpuUsage > 0 then infoDisplay[addonIndex].cpu = cpuUsage end
|
||||
end
|
||||
end
|
||||
|
||||
for i = count, 1, -1 do
|
||||
local data = infoDisplay[i]
|
||||
if type(data) == 'boolean' then
|
||||
tremove(infoDisplay, i)
|
||||
end
|
||||
end
|
||||
|
||||
sort(infoDisplay, displaySort)
|
||||
|
||||
for i = 1, count do
|
||||
displayData(infoDisplay[i], totalMEM, totalCPU)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(' ')
|
||||
if showByCPU then
|
||||
DT.tooltip:AddLine(L["(Hold Shift) Memory Usage"])
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(L["(Shift Click) Collect Garbage"])
|
||||
DT.tooltip:AddLine(L["(Ctrl & Shift Click) Toggle CPU Profiling"])
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
enteredFrame = false
|
||||
end
|
||||
|
||||
local wait, count = 10, 0 -- initial delay for update (let the ui load)
|
||||
local function OnUpdate(self, elapsed)
|
||||
wait = wait - elapsed
|
||||
|
||||
if wait < 0 then
|
||||
wait = 1
|
||||
|
||||
local framerate = floor(GetFramerate())
|
||||
local _, _, _, latency = GetNetStats()
|
||||
|
||||
local fps = framerate >= 30 and 1 or (framerate >= 20 and framerate < 30) and 2 or (framerate >= 10 and framerate < 20) and 3 or 4
|
||||
local ping = latency < 150 and 1 or (latency >= 150 and latency < 300) and 2 or (latency >= 300 and latency < 500) and 3 or 4
|
||||
self.text:SetFormattedText(E.global.datatexts.settings.System.NoLabel and '%s%d|r | %s%d|r' or 'FPS: %s%d|r MS: %s%d|r', statusColors[fps], framerate, statusColors[ping], latency)
|
||||
|
||||
if not enteredFrame then return end
|
||||
|
||||
if InCombatLockdown() then
|
||||
if count > 3 then
|
||||
OnEnter(self)
|
||||
count = 0
|
||||
else
|
||||
OnEnter(self, count)
|
||||
count = count + 1
|
||||
end
|
||||
else
|
||||
OnEnter(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('System', nil, nil, BuildAddonList, OnUpdate, OnClick, OnEnter, OnLeave, L["System"])
|
||||
38
Modules/DataTexts/Template.lua
Normal file
38
Modules/DataTexts/Template.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
----------------------------------------------------------------------------------
|
||||
-- This file is a blank datatext example template, this file will not be loaded.
|
||||
----------------------------------------------------------------------------------
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local function Update(self, t)
|
||||
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
|
||||
end
|
||||
|
||||
local function Click()
|
||||
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT.tooltip:ClearLines()
|
||||
-- code goes here
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
--[[
|
||||
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc, onLeaveFunc, localizedName)
|
||||
|
||||
name - name of the datatext (required)
|
||||
events - must be a table with string values of event names to register
|
||||
eventFunc - function that gets fired when an event gets triggered
|
||||
updateFunc - onUpdate script target function
|
||||
click - function to fire when clicking the datatext
|
||||
onEnterFunc - function to fire OnEnter
|
||||
onLeaveFunc - function to fire OnLeave, if not provided one will be set for you that hides the tooltip.
|
||||
localizedName - localized name of the datetext
|
||||
]]
|
||||
|
||||
DT:RegisterDatatext('DTName', 'Category', {'EVENT1', 'EVENT2', 'EVENT3'}, OnEvent, Update, Click, OnEnter)
|
||||
319
Modules/DataTexts/Time.lua
Normal file
319
Modules/DataTexts/Time.lua
Normal file
@@ -0,0 +1,319 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local _G = _G
|
||||
local next, unpack = next, unpack
|
||||
local format, strjoin = format, strjoin
|
||||
local sort, tinsert = sort, tinsert
|
||||
local date, utf8sub = date, string.utf8sub
|
||||
|
||||
local EJ_GetCurrentTier = EJ_GetCurrentTier
|
||||
local EJ_GetInstanceByIndex = EJ_GetInstanceByIndex
|
||||
local EJ_GetNumTiers = EJ_GetNumTiers
|
||||
local EJ_SelectTier = EJ_SelectTier
|
||||
local GetDifficultyInfo = GetDifficultyInfo
|
||||
local C_DateAndTime_GetCurrentCalendarTime = C_DateAndTime.GetCurrentCalendarTime
|
||||
local GetLocale = GetLocale
|
||||
local GetNumSavedInstances = GetNumSavedInstances
|
||||
local GetNumSavedWorldBosses = GetNumSavedWorldBosses
|
||||
local GetNumWorldPVPAreas = GetNumWorldPVPAreas
|
||||
local GetSavedInstanceInfo = GetSavedInstanceInfo
|
||||
local GetSavedWorldBossInfo = GetSavedWorldBossInfo
|
||||
local GetWorldPVPAreaInfo = GetWorldPVPAreaInfo
|
||||
local RequestRaidInfo = RequestRaidInfo
|
||||
local SecondsToTime = SecondsToTime
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local C_Map_GetAreaInfo = C_Map.GetAreaInfo
|
||||
local QUEUE_TIME_UNAVAILABLE = QUEUE_TIME_UNAVAILABLE
|
||||
local TIMEMANAGER_TOOLTIP_LOCALTIME = TIMEMANAGER_TOOLTIP_LOCALTIME
|
||||
local TIMEMANAGER_TOOLTIP_REALMTIME = TIMEMANAGER_TOOLTIP_REALMTIME
|
||||
local VOICE_CHAT_BATTLEGROUND = VOICE_CHAT_BATTLEGROUND
|
||||
local WINTERGRASP_IN_PROGRESS = WINTERGRASP_IN_PROGRESS
|
||||
local WORLD_BOSSES_TEXT = RAID_INFO_WORLD_BOSS
|
||||
|
||||
local APM = { _G.TIMEMANAGER_PM, _G.TIMEMANAGER_AM }
|
||||
local ukDisplayFormat, europeDisplayFormat = '', ''
|
||||
local europeDisplayFormat_nocolor = strjoin('', '%02d', ':|r%02d')
|
||||
local ukDisplayFormat_nocolor = strjoin('', '', '%d', ':|r%02d', ' %s|r')
|
||||
local lockoutInfoFormat = '%s%s %s |cffaaaaaa(%s, %s/%s)'
|
||||
local lockoutInfoFormatNoEnc = '%s%s %s |cffaaaaaa(%s)'
|
||||
local formatBattleGroundInfo = '%s: '
|
||||
local lockoutColorExtended, lockoutColorNormal = { r=0.3,g=1,b=0.3 }, { r=.8,g=.8,b=.8 }
|
||||
local enteredFrame = false
|
||||
|
||||
local Update, lastPanel
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
europeDisplayFormat = strjoin('', '%02d', hex, ':|r%02d')
|
||||
ukDisplayFormat = strjoin('', '', '%d', hex, ':|r%02d', hex, ' %s|r')
|
||||
|
||||
if lastPanel ~= nil then
|
||||
Update(lastPanel, 20000)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
local function ConvertTime(h, m)
|
||||
local AmPm
|
||||
if E.global.datatexts.settings.Time.time24 == true then
|
||||
return h, m, -1
|
||||
else
|
||||
if h >= 12 then
|
||||
if h > 12 then h = h - 12 end
|
||||
AmPm = 1
|
||||
else
|
||||
if h == 0 then h = 12 end
|
||||
AmPm = 2
|
||||
end
|
||||
end
|
||||
return h, m, AmPm
|
||||
end
|
||||
|
||||
local function CalculateTimeValues(tooltip)
|
||||
if (tooltip and E.global.datatexts.settings.Time.localTime) or (not tooltip and not E.global.datatexts.settings.Time.localTime) then
|
||||
local dateTable = C_DateAndTime_GetCurrentCalendarTime()
|
||||
return ConvertTime(dateTable.hour, dateTable.minute)
|
||||
else
|
||||
local dateTable = date('*t')
|
||||
return ConvertTime(dateTable.hour, dateTable.min)
|
||||
end
|
||||
end
|
||||
|
||||
local function Click()
|
||||
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
|
||||
_G.GameTimeFrame:Click()
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
enteredFrame = false
|
||||
end
|
||||
|
||||
local InstanceNameByID = {
|
||||
-- NOTE: for some reason the instanceID from EJ_GetInstanceByIndex doesn't match,
|
||||
-- the instanceID from GetInstanceInfo, so use the collectIDs to find the ID to add.
|
||||
[749] = C_Map_GetAreaInfo(3845) -- 'The Eye' -> 'Tempest Keep'
|
||||
}
|
||||
|
||||
local locale = GetLocale()
|
||||
if locale == 'deDE' then -- O.O
|
||||
InstanceNameByID[1023] = 'Belagerung von Boralus' -- 'Die Belagerung von Boralus'
|
||||
InstanceNameByID[1041] = 'Königsruh' -- 'Die Königsruh'
|
||||
InstanceNameByID[1021] = 'Kronsteiganwesen' -- 'Das Kronsteiganwesen'
|
||||
end
|
||||
|
||||
local instanceIconByName = {}
|
||||
local collectIDs, collectedIDs = false -- for testing; mouse over the dt to show the tinspect table
|
||||
local function GetInstanceImages(index, raid)
|
||||
local instanceID, name, _, _, buttonImage = EJ_GetInstanceByIndex(index, raid)
|
||||
while instanceID do
|
||||
if collectIDs then
|
||||
if not collectedIDs then
|
||||
collectedIDs = {}
|
||||
end
|
||||
|
||||
collectedIDs[instanceID] = name
|
||||
end
|
||||
|
||||
instanceIconByName[InstanceNameByID[instanceID] or name] = buttonImage
|
||||
index = index + 1
|
||||
instanceID, name, _, _, buttonImage = EJ_GetInstanceByIndex(index, raid)
|
||||
end
|
||||
end
|
||||
|
||||
local krcntw = locale == 'koKR' or locale == 'zhCN' or locale == 'zhTW'
|
||||
local difficultyTag = { -- Raid Finder, Normal, Heroic, Mythic
|
||||
(krcntw and _G.PLAYER_DIFFICULTY3) or utf8sub(_G.PLAYER_DIFFICULTY3, 1, 1), -- R
|
||||
(krcntw and _G.PLAYER_DIFFICULTY1) or utf8sub(_G.PLAYER_DIFFICULTY1, 1, 1), -- N
|
||||
(krcntw and _G.PLAYER_DIFFICULTY2) or utf8sub(_G.PLAYER_DIFFICULTY2, 1, 1), -- H
|
||||
(krcntw and _G.PLAYER_DIFFICULTY6) or utf8sub(_G.PLAYER_DIFFICULTY6, 1, 1) -- M
|
||||
}
|
||||
|
||||
local function sortFunc(a,b) return a[1] < b[1] end
|
||||
|
||||
local collectedInstanceImages = false
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
if not enteredFrame then
|
||||
enteredFrame = true
|
||||
RequestRaidInfo()
|
||||
end
|
||||
|
||||
if not collectedInstanceImages then
|
||||
local numTiers = (EJ_GetNumTiers() or 0)
|
||||
if numTiers > 0 then
|
||||
local currentTier = EJ_GetCurrentTier()
|
||||
|
||||
-- Loop through the expansions to collect the textures
|
||||
for i=1, numTiers do
|
||||
EJ_SelectTier(i)
|
||||
GetInstanceImages(1, false); -- Populate for dungeon icons
|
||||
GetInstanceImages(1, true); -- Populate for raid icons
|
||||
end
|
||||
|
||||
if collectIDs then
|
||||
E:Dump(collectedIDs, true)
|
||||
end
|
||||
|
||||
-- Set it back to the previous tier
|
||||
if currentTier then
|
||||
EJ_SelectTier(currentTier)
|
||||
end
|
||||
|
||||
collectedInstanceImages = true
|
||||
end
|
||||
end
|
||||
|
||||
local addedHeader = false
|
||||
|
||||
for i = 1, GetNumWorldPVPAreas() do
|
||||
local _, localizedName, isActive, _, startTime, canEnter = GetWorldPVPAreaInfo(i)
|
||||
|
||||
if isActive then
|
||||
startTime = WINTERGRASP_IN_PROGRESS
|
||||
elseif not startTime then
|
||||
startTime = QUEUE_TIME_UNAVAILABLE
|
||||
elseif startTime ~= 0 then
|
||||
startTime = SecondsToTime(startTime, false, nil, 3)
|
||||
end
|
||||
|
||||
if canEnter and startTime ~= 0 then
|
||||
if not addedHeader then
|
||||
DT.tooltip:AddLine(VOICE_CHAT_BATTLEGROUND)
|
||||
addedHeader = true
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(format(formatBattleGroundInfo, localizedName), startTime, 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
end
|
||||
end
|
||||
|
||||
local lockedInstances = {raids = {}, dungeons = {}}
|
||||
|
||||
for i = 1, GetNumSavedInstances() do
|
||||
local name, _, _, difficulty, locked, extended, _, isRaid = GetSavedInstanceInfo(i)
|
||||
if (locked or extended) and name then
|
||||
local isLFR, isHeroicOrMythicDungeon = (difficulty == 7 or difficulty == 17), (difficulty == 2 or difficulty == 23)
|
||||
local _, _, isHeroic, _, displayHeroic, displayMythic = GetDifficultyInfo(difficulty)
|
||||
local sortName = name .. (displayMythic and 4 or (isHeroic or displayHeroic) and 3 or isLFR and 1 or 2)
|
||||
local difficultyLetter = (displayMythic and difficultyTag[4] or (isHeroic or displayHeroic) and difficultyTag[3] or isLFR and difficultyTag[1] or difficultyTag[2])
|
||||
local buttonImg = instanceIconByName[name] and format('|T%s:16:16:0:0:96:96:0:64:0:64|t ', instanceIconByName[name]) or ''
|
||||
|
||||
if isRaid then
|
||||
tinsert(lockedInstances.raids, {sortName, difficultyLetter, buttonImg, {GetSavedInstanceInfo(i)}})
|
||||
elseif isHeroicOrMythicDungeon then
|
||||
tinsert(lockedInstances.dungeons, {sortName, difficultyLetter, buttonImg, {GetSavedInstanceInfo(i)}})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if next(lockedInstances.raids) then
|
||||
if DT.tooltip:NumLines() > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
DT.tooltip:AddLine(L["Saved Raid(s)"])
|
||||
|
||||
sort(lockedInstances.raids, sortFunc)
|
||||
|
||||
for i = 1, #lockedInstances.raids do
|
||||
local difficultyLetter = lockedInstances.raids[i][2]
|
||||
local buttonImg = lockedInstances.raids[i][3]
|
||||
local name, _, reset, _, _, extended, _, _, maxPlayers, _, numEncounters, encounterProgress = unpack(lockedInstances.raids[i][4])
|
||||
|
||||
local lockoutColor = extended and lockoutColorExtended or lockoutColorNormal
|
||||
if numEncounters and numEncounters > 0 and (encounterProgress and encounterProgress > 0) then
|
||||
DT.tooltip:AddDoubleLine(format(lockoutInfoFormat, buttonImg, maxPlayers, difficultyLetter, name, encounterProgress, numEncounters), SecondsToTime(reset, false, nil, 3), 1, 1, 1, lockoutColor.r, lockoutColor.g, lockoutColor.b)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(format(lockoutInfoFormatNoEnc, buttonImg, maxPlayers, difficultyLetter, name), SecondsToTime(reset, false, nil, 3), 1, 1, 1, lockoutColor.r, lockoutColor.g, lockoutColor.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if next(lockedInstances.dungeons) then
|
||||
if DT.tooltip:NumLines() > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
DT.tooltip:AddLine(L["Saved Dungeon(s)"])
|
||||
|
||||
sort(lockedInstances.dungeons, sortFunc)
|
||||
|
||||
for i = 1,#lockedInstances.dungeons do
|
||||
local difficultyLetter = lockedInstances.dungeons[i][2]
|
||||
local buttonImg = lockedInstances.dungeons[i][3]
|
||||
local name, _, reset, _, _, extended, _, _, maxPlayers, _, numEncounters, encounterProgress = unpack(lockedInstances.dungeons[i][4])
|
||||
|
||||
local lockoutColor = extended and lockoutColorExtended or lockoutColorNormal
|
||||
if numEncounters and numEncounters > 0 and (encounterProgress and encounterProgress > 0) then
|
||||
DT.tooltip:AddDoubleLine(format(lockoutInfoFormat, buttonImg, maxPlayers, difficultyLetter, name, encounterProgress, numEncounters), SecondsToTime(reset, false, nil, 3), 1, 1, 1, lockoutColor.r, lockoutColor.g, lockoutColor.b)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(format(lockoutInfoFormatNoEnc, buttonImg, maxPlayers, difficultyLetter, name), SecondsToTime(reset, false, nil, 3), 1, 1, 1, lockoutColor.r, lockoutColor.g, lockoutColor.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local addedLine = false
|
||||
local worldbossLockoutList = {}
|
||||
for i = 1, GetNumSavedWorldBosses() do
|
||||
local name, _, reset = GetSavedWorldBossInfo(i)
|
||||
tinsert(worldbossLockoutList, {name, reset})
|
||||
end
|
||||
sort(worldbossLockoutList, sortFunc)
|
||||
for i = 1,#worldbossLockoutList do
|
||||
local name, reset = unpack(worldbossLockoutList[i])
|
||||
if reset then
|
||||
if not addedLine then
|
||||
if DT.tooltip:NumLines() > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
DT.tooltip:AddLine(WORLD_BOSSES_TEXT)
|
||||
addedLine = true
|
||||
end
|
||||
DT.tooltip:AddDoubleLine(name, SecondsToTime(reset, true, nil, 3), 1, 1, 1, 0.8, 0.8, 0.8)
|
||||
end
|
||||
end
|
||||
|
||||
local Hr, Min, AmPm = CalculateTimeValues(true)
|
||||
if DT.tooltip:NumLines() > 0 then
|
||||
DT.tooltip:AddLine(' ')
|
||||
end
|
||||
if AmPm == -1 then
|
||||
DT.tooltip:AddDoubleLine(E.global.datatexts.settings.Time.localTime and TIMEMANAGER_TOOLTIP_REALMTIME or TIMEMANAGER_TOOLTIP_LOCALTIME, format(europeDisplayFormat_nocolor, Hr, Min), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(E.global.datatexts.settings.Time.localTime and TIMEMANAGER_TOOLTIP_REALMTIME or TIMEMANAGER_TOOLTIP_LOCALTIME, format(ukDisplayFormat_nocolor, Hr, Min, APM[AmPm]), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
if event == 'UPDATE_INSTANCE_INFO' and enteredFrame then
|
||||
OnEnter(self)
|
||||
end
|
||||
end
|
||||
|
||||
function Update(self, t)
|
||||
self.timeElapsed = (self.timeElapsed or 5) - t
|
||||
if self.timeElapsed > 0 then return end
|
||||
self.timeElapsed = 5
|
||||
|
||||
if _G.GameTimeFrame.flashInvite then
|
||||
E:Flash(self, 0.53, true)
|
||||
else
|
||||
E:StopFlash(self)
|
||||
end
|
||||
|
||||
if enteredFrame then
|
||||
OnEnter(self)
|
||||
end
|
||||
|
||||
local Hr, Min, AmPm = CalculateTimeValues()
|
||||
|
||||
if AmPm == -1 then
|
||||
self.text:SetFormattedText(europeDisplayFormat, Hr, Min)
|
||||
else
|
||||
self.text:SetFormattedText(ukDisplayFormat, Hr, Min, APM[AmPm])
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
DT:RegisterDatatext('Time', nil, {'UPDATE_INSTANCE_INFO'}, OnEvent, Update, Click, OnEnter, OnLeave, nil, nil, ValueColorUpdate)
|
||||
53
Modules/DataTexts/Versatility.lua
Normal file
53
Modules/DataTexts/Versatility.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule('DataTexts')
|
||||
|
||||
local format, strjoin = format, strjoin
|
||||
local BreakUpLargeNumbers = BreakUpLargeNumbers
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local GetVersatilityBonus = GetVersatilityBonus
|
||||
local CR_VERSATILITY_DAMAGE_DONE = CR_VERSATILITY_DAMAGE_DONE
|
||||
local CR_VERSATILITY_DAMAGE_TAKEN = CR_VERSATILITY_DAMAGE_TAKEN
|
||||
local CR_VERSATILITY_TOOLTIP = CR_VERSATILITY_TOOLTIP
|
||||
local FONT_COLOR_CODE_CLOSE = FONT_COLOR_CODE_CLOSE
|
||||
local HIGHLIGHT_FONT_COLOR_CODE = HIGHLIGHT_FONT_COLOR_CODE
|
||||
local STAT_VERSATILITY = STAT_VERSATILITY
|
||||
local VERSATILITY_TOOLTIP_FORMAT = VERSATILITY_TOOLTIP_FORMAT
|
||||
local STAT_CATEGORY_ENHANCEMENTS = STAT_CATEGORY_ENHANCEMENTS
|
||||
|
||||
local displayString, lastPanel = ''
|
||||
|
||||
local function OnEnter()
|
||||
DT.tooltip:ClearLines()
|
||||
|
||||
local versatility = GetCombatRating(CR_VERSATILITY_DAMAGE_DONE)
|
||||
local versatilityDamageBonus = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE)
|
||||
local versatilityDamageTakenReduction = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_TAKEN) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_TAKEN)
|
||||
|
||||
local text = HIGHLIGHT_FONT_COLOR_CODE..format(VERSATILITY_TOOLTIP_FORMAT, STAT_VERSATILITY, versatilityDamageBonus, versatilityDamageTakenReduction)..FONT_COLOR_CODE_CLOSE
|
||||
local tooltip = format(CR_VERSATILITY_TOOLTIP, versatilityDamageBonus, versatilityDamageTakenReduction, BreakUpLargeNumbers(versatility), versatilityDamageBonus, versatilityDamageTakenReduction)
|
||||
|
||||
DT.tooltip:AddDoubleLine(text, nil, 1, 1, 1)
|
||||
DT.tooltip:AddLine(tooltip, nil, nil, nil, true)
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
local versatility = GetCombatRatingBonus(CR_VERSATILITY_DAMAGE_DONE) + GetVersatilityBonus(CR_VERSATILITY_DAMAGE_DONE)
|
||||
if E.global.datatexts.settings.Versatility.NoLabel then
|
||||
self.text:SetFormattedText(displayString, versatility)
|
||||
else
|
||||
self.text:SetFormattedText(displayString, E.global.datatexts.settings.Versatility.Label ~= '' and E.global.datatexts.settings.Versatility.Label or STAT_VERSATILITY, versatility)
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = strjoin('', E.global.datatexts.settings.Versatility.NoLabel and '' or '%s: ', hex, '%.'..E.global.datatexts.settings.Versatility.decimalLength..'f%%|r')
|
||||
|
||||
if lastPanel then OnEvent(lastPanel) end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext('Versatility', STAT_CATEGORY_ENHANCEMENTS, {"UNIT_STATS", "UNIT_AURA", "ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE", "PLAYER_DAMAGE_DONE_MODS"}, OnEvent, nil, nil, OnEnter, nil, STAT_VERSATILITY, nil, ValueColorUpdate)
|
||||
Reference in New Issue
Block a user