init
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetTotalAchievementPoints = GetTotalAchievementPoints
|
||||
local ToggleAchievementFrame = ToggleAchievementFrame
|
||||
local ACHIEVEMENTS = ACHIEVEMENTS
|
||||
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
self.text:SetFormattedText(displayNumberString, GetTotalAchievementPoints())
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
ToggleAchievementFrame()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", ACHIEVEMENTS, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Achievement", {"ACHIEVEMENT_EARNED"}, OnEvent, nil, OnClick, nil, nil, ACHIEVEMENTS)
|
||||
@@ -0,0 +1,58 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local UnitArmor = UnitArmor
|
||||
local UnitLevel = UnitLevel
|
||||
local PaperDollFrame_GetArmorReduction = PaperDollFrame_GetArmorReduction
|
||||
local ARMOR = ARMOR
|
||||
|
||||
local chanceString = "%.2f%%"
|
||||
local displayString = ""
|
||||
local _, effectiveArmor
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
_, effectiveArmor = UnitArmor("player")
|
||||
|
||||
self.text:SetFormattedText(displayString, effectiveArmor)
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
DT.tooltip:AddLine(L["Mitigation By Level: "])
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
local playerLevel = E.mylevel + 3
|
||||
local targetLevel = UnitLevel("target")
|
||||
local armorReduction
|
||||
|
||||
for i = 1, 4 do
|
||||
armorReduction = PaperDollFrame_GetArmorReduction(effectiveArmor, playerLevel)
|
||||
DT.tooltip:AddDoubleLine(playerLevel, format(chanceString, armorReduction), 1, 1, 1)
|
||||
playerLevel = playerLevel - 1
|
||||
end
|
||||
|
||||
if targetLevel and targetLevel > 0 and (targetLevel > playerLevel + 3 or targetLevel < playerLevel) then
|
||||
armorReduction = PaperDollFrame_GetArmorReduction(effectiveArmor, targetLevel)
|
||||
DT.tooltip:AddDoubleLine(targetLevel, format(chanceString, armorReduction), 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", ARMOR, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Armor", {"UNIT_RESISTANCES"}, OnEvent, nil, nil, OnEnter, nil, ARMOR)
|
||||
@@ -0,0 +1,73 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local max = math.max
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local ComputePetBonus = ComputePetBonus
|
||||
local UnitAttackPower = UnitAttackPower
|
||||
local UnitRangedAttackPower = UnitRangedAttackPower
|
||||
local ATTACK_POWER = ATTACK_POWER
|
||||
local ATTACK_POWER_MAGIC_NUMBER = ATTACK_POWER_MAGIC_NUMBER
|
||||
local ATTACK_POWER_TOOLTIP = ATTACK_POWER_TOOLTIP
|
||||
local MELEE_ATTACK_POWER = MELEE_ATTACK_POWER
|
||||
local MELEE_ATTACK_POWER_TOOLTIP = MELEE_ATTACK_POWER_TOOLTIP
|
||||
local PET_BONUS_TOOLTIP_RANGED_ATTACK_POWER = PET_BONUS_TOOLTIP_RANGED_ATTACK_POWER
|
||||
local PET_BONUS_TOOLTIP_SPELLDAMAGE = PET_BONUS_TOOLTIP_SPELLDAMAGE
|
||||
local RANGED_ATTACK_POWER = RANGED_ATTACK_POWER
|
||||
local RANGED_ATTACK_POWER_TOOLTIP = RANGED_ATTACK_POWER_TOOLTIP
|
||||
|
||||
local apower, base, posBuff, negBuff
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
if E.Role == "Ranged" then
|
||||
base, posBuff, negBuff = UnitRangedAttackPower("player")
|
||||
apower = base + posBuff + negBuff
|
||||
else
|
||||
base, posBuff, negBuff = UnitAttackPower("player")
|
||||
apower = base + posBuff + negBuff
|
||||
end
|
||||
|
||||
self.text:SetFormattedText(displayNumberString, apower)
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if E.Role == "Ranged" then
|
||||
local petAPBonus = ComputePetBonus("PET_BONUS_RAP_TO_AP", apower)
|
||||
local petSpellDmgBonus = ComputePetBonus("PET_BONUS_RAP_TO_SPELLDMG", apower)
|
||||
|
||||
DT.tooltip:AddDoubleLine(RANGED_ATTACK_POWER, apower, 1, 1, 1, 1, 1, 1)
|
||||
DT.tooltip:AddLine(format(RANGED_ATTACK_POWER_TOOLTIP, max(0, apower) / ATTACK_POWER_MAGIC_NUMBER), nil, nil, nil, 1)
|
||||
|
||||
if petAPBonus > 0 then
|
||||
DT.tooltip:AddLine(format(PET_BONUS_TOOLTIP_RANGED_ATTACK_POWER, petAPBonus), nil, nil, nil)
|
||||
end
|
||||
|
||||
if petSpellDmgBonus > 0 then
|
||||
DT.tooltip:AddLine(format(PET_BONUS_TOOLTIP_SPELLDAMAGE, petSpellDmgBonus), nil, nil, nil)
|
||||
end
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(MELEE_ATTACK_POWER, apower, 1, 1, 1, 1, 1, 1)
|
||||
DT.tooltip:AddLine(format(MELEE_ATTACK_POWER_TOOLTIP, max(0, apower) / ATTACK_POWER_MAGIC_NUMBER), nil, nil, nil, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", ATTACK_POWER, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Attack Power", {"UNIT_ATTACK_POWER", "UNIT_RANGED_ATTACK_POWER"}, OnEvent, nil, nil, OnEnter, nil, ATTACK_POWER_TOOLTIP)
|
||||
@@ -0,0 +1,122 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local select = select
|
||||
local abs = math.abs
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
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 BLOCK_CHANCE = BLOCK_CHANCE
|
||||
local BOSS = BOSS
|
||||
local DEFENSE = DEFENSE
|
||||
local DODGE_CHANCE = DODGE_CHANCE
|
||||
local PARRY_CHANCE = PARRY_CHANCE
|
||||
|
||||
local displayString = ""
|
||||
local chanceString = "%.2f%%"
|
||||
local chanceString2 = "+%.2f%%"
|
||||
local AVD_DECAY_RATE = 0.2
|
||||
local targetlvl, playerlvl
|
||||
local baseMissChance, levelDifference, dodge, parry, block, avoidance, unhittable
|
||||
local lastPanel
|
||||
|
||||
local function IsWearingShield()
|
||||
local slotID = GetInventorySlotInfo("SecondaryHandSlot")
|
||||
local itemID = GetInventoryItemID("player", slotID)
|
||||
|
||||
if itemID then
|
||||
return select(9, GetItemInfo(itemID))
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
targetlvl, playerlvl = UnitLevel("target"), E.mylevel
|
||||
|
||||
baseMissChance = E.myrace == "NightElf" and 7 or 5
|
||||
if targetlvl == -1 then
|
||||
levelDifference = 3
|
||||
elseif targetlvl > playerlvl then
|
||||
levelDifference = (targetlvl - playerlvl)
|
||||
elseif targetlvl < playerlvl and targetlvl > 0 then
|
||||
levelDifference = (targetlvl - playerlvl)
|
||||
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
|
||||
|
||||
if dodge <= 0 then dodge = 0 end
|
||||
if parry <= 0 then parry = 0 end
|
||||
if block <= 0 then block = 0 end
|
||||
|
||||
if GetBonusBarOffset() == 3 then
|
||||
parry = 0
|
||||
end
|
||||
|
||||
if IsWearingShield() ~= "INVTYPE_SHIELD" then
|
||||
block = 0
|
||||
end
|
||||
|
||||
avoidance = (dodge + parry + block + baseMissChance)
|
||||
unhittable = avoidance - 102.4
|
||||
|
||||
self.text:SetFormattedText(displayString, avoidance)
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if targetlvl > 1 then
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], join("", " (", L["lvl"], " ", targetlvl, ")"))
|
||||
elseif targetlvl == -1 then
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], join("", " (", BOSS, ")"))
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], join("", " (", L["lvl"], " ", playerlvl, ")"))
|
||||
end
|
||||
|
||||
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(L["Miss Chance"], format(chanceString, baseMissChance), 1, 1, 1)
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
if unhittable > 0 then
|
||||
DT.tooltip:AddDoubleLine(L["Unhittable:"], format(chanceString2, unhittable), 1, 1, 1, 0, 1, 0)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(L["Unhittable:"], format(chanceString, unhittable), 1, 1, 1, 1, 0, 0)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", DEFENSE, ": ", hex, "%.2f%%|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Avoidance", {"COMBAT_RATING_UPDATE", "PLAYER_TARGET_CHANGED"}, OnEvent, nil, nil, OnEnter, nil, L["Avoidance Breakdown"])
|
||||
@@ -0,0 +1,91 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local ContainerIDToInventoryID = ContainerIDToInventoryID
|
||||
local GetBackpackCurrencyInfo = GetBackpackCurrencyInfo
|
||||
local GetContainerNumFreeSlots = GetContainerNumFreeSlots
|
||||
local GetContainerNumSlots = GetContainerNumSlots
|
||||
local GetInventoryItemLink = GetInventoryItemLink
|
||||
local GetItemInfo = GetItemInfo
|
||||
local GetItemQualityColor = GetItemQualityColor
|
||||
local BACKPACK_TOOLTIP = BACKPACK_TOOLTIP
|
||||
local CURRENCY = CURRENCY
|
||||
local MAX_WATCHED_TOKENS = MAX_WATCHED_TOKENS
|
||||
local NUM_BAG_SLOTS = NUM_BAG_SLOTS
|
||||
|
||||
local currencyString = "|T%s:14:14:0:0:64:64:4:60:4:60|t %s"
|
||||
local displayString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
local free, total = 0, 0
|
||||
for i = 0, NUM_BAG_SLOTS do
|
||||
free, total = free + GetContainerNumFreeSlots(i), total + GetContainerNumSlots(i)
|
||||
end
|
||||
self.text:SetFormattedText(displayString, total - free, total)
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
OpenAllBags()
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local r, g, b
|
||||
local _, name, quality, link
|
||||
local free, total, used
|
||||
|
||||
for i = 0, NUM_BAG_SLOTS do
|
||||
free, total = GetContainerNumFreeSlots(i), GetContainerNumSlots(i)
|
||||
used = total - free
|
||||
|
||||
if i == 0 then
|
||||
DT.tooltip:AddLine(L["Bags"]..":")
|
||||
DT.tooltip:AddDoubleLine(BACKPACK_TOOLTIP, format("%d / %d", used, total), 1, 1, 1)
|
||||
else
|
||||
link = GetInventoryItemLink("player", ContainerIDToInventoryID(i))
|
||||
if link then
|
||||
name, _, quality = GetItemInfo(link)
|
||||
r, g, b = GetItemQualityColor(quality)
|
||||
DT.tooltip:AddDoubleLine(name, format("%d / %d", used, total), r, g, b)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local count, currencyType, icon
|
||||
for i = 1, MAX_WATCHED_TOKENS do
|
||||
name, count, currencyType, icon = GetBackpackCurrencyInfo(i)
|
||||
if name and i == 1 then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(CURRENCY..":")
|
||||
end
|
||||
|
||||
if name and count then
|
||||
if currencyType == 1 then
|
||||
icon = "Interface\\PVPFrame\\PVP-ArenaPoints-Icon"
|
||||
elseif currencyType == 2 then
|
||||
icon = "Interface\\PVPFrame\\PVP-Currency-"..E.myfaction
|
||||
end
|
||||
DT.tooltip:AddDoubleLine(format(currencyString, icon, name), count, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", L["Bags"], ": ", hex, "%d/%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Bags", {"PLAYER_ENTERING_WORLD", "BAG_UPDATE"}, OnEvent, nil, OnClick, OnEnter, nil, L["Bags"])
|
||||
@@ -0,0 +1,91 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local select = select
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetBattlefieldScore = GetBattlefieldScore
|
||||
local GetBattlefieldStatData = GetBattlefieldStatData
|
||||
local GetBattlefieldStatInfo = GetBattlefieldStatInfo
|
||||
local GetNumBattlefieldScores = GetNumBattlefieldScores
|
||||
local GetNumBattlefieldStats = GetNumBattlefieldStats
|
||||
|
||||
local displayString = ""
|
||||
local lastPanel
|
||||
|
||||
local dataLayout = {
|
||||
["LeftChatDataPanel"] = {
|
||||
["left"] = 11,
|
||||
["middle"] = 5,
|
||||
["right"] = 2
|
||||
},
|
||||
["RightChatDataPanel"] = {
|
||||
["left"] = 4,
|
||||
["middle"] = 3,
|
||||
["right"] = 12
|
||||
}
|
||||
}
|
||||
|
||||
local dataStrings = {
|
||||
[11] = DAMAGE,
|
||||
[5] = HONOR,
|
||||
[2] = KILLING_BLOWS,
|
||||
[4] = DEATHS,
|
||||
[3] = HONORABLE_KILLS,
|
||||
[12] = SHOW_COMBAT_HEALING
|
||||
}
|
||||
|
||||
function DT:UPDATE_BATTLEFIELD_SCORE()
|
||||
lastPanel = self
|
||||
|
||||
local pointIndex = dataLayout[self:GetParent():GetName()][self.pointIndex]
|
||||
for i = 1, GetNumBattlefieldScores() do
|
||||
local name = GetBattlefieldScore(i)
|
||||
if name == E.myname then
|
||||
self.text:SetFormattedText(displayString, dataStrings[pointIndex], E:ShortValue(select(pointIndex, GetBattlefieldScore(i))))
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:BattlegroundStats()
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local numStatInfo = GetNumBattlefieldStats()
|
||||
if numStatInfo then
|
||||
for i = 1, GetNumBattlefieldScores() do
|
||||
local name = GetBattlefieldScore(i)
|
||||
if name and name == E.myname then
|
||||
local classColor = E.media.herocolor
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Stats For:"], name, 1, 1, 1, classColor.r, classColor.g, classColor.b)
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
-- Add extra statistics to watch based on what BG you are in.
|
||||
for j = 1, numStatInfo do
|
||||
DT.tooltip:AddDoubleLine(GetBattlefieldStatInfo(j), GetBattlefieldStatData(i, j), 1, 1, 1)
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
function DT:HideBattlegroundTexts()
|
||||
DT.ForceHideBGStats = true
|
||||
DT:LoadDataTexts()
|
||||
E:Print(L["Battleground datatexts temporarily hidden, to show type /bgstats or right click the 'C' icon near the minimap."])
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", "%s: ", hex, "%s|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
DT.UPDATE_BATTLEFIELD_SCORE(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
@@ -0,0 +1,42 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local floor = math.floor
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local COMBAT = COMBAT
|
||||
|
||||
local timer = 0
|
||||
local displayNumberString = ""
|
||||
|
||||
local lastPanel
|
||||
|
||||
local function OnUpdate(self, elapsed)
|
||||
timer = timer + elapsed
|
||||
self.text:SetFormattedText(displayNumberString, format("%02d:%02d:%02d", floor(timer / 60), timer % 60, (timer - floor(timer)) * 100))
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
if event == "PLAYER_REGEN_DISABLED" then
|
||||
timer = 0
|
||||
self:SetScript("OnUpdate", OnUpdate)
|
||||
elseif event == "PLAYER_REGEN_ENABLED" then
|
||||
self:SetScript("OnUpdate", nil)
|
||||
else
|
||||
self.text:SetFormattedText(displayNumberString, "00:00:00")
|
||||
end
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", COMBAT, ": ", hex, "%s|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Combat Time", {"PLAYER_REGEN_ENABLED", "PLAYER_REGEN_DISABLED"}, OnEvent, nil, nil, nil, nil, L["Combat Time"])
|
||||
@@ -0,0 +1,72 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local pairs = pairs
|
||||
local find, join = string.find, string.join
|
||||
--WoW API / Variables
|
||||
local GetNumAddOns = GetNumAddOns
|
||||
local GetAddOnInfo = GetAddOnInfo
|
||||
local GetAddOnMetadata = GetAddOnMetadata
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local ReloadUI = ReloadUI
|
||||
|
||||
local displayString = ""
|
||||
local configText = "ElvUI"
|
||||
local plugins
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self, event)
|
||||
lastPanel = self
|
||||
|
||||
if not plugins and event == "PLAYER_ENTERING_WORLD" then
|
||||
for i = 1, GetNumAddOns() do
|
||||
local name, title, _, enabled = GetAddOnInfo(i)
|
||||
if enabled and find(name, "ElvUI") and name ~= "ElvUI" then
|
||||
plugins = plugins or {}
|
||||
plugins[title] = GetAddOnMetadata(i, "version")
|
||||
end
|
||||
end
|
||||
|
||||
self:UnregisterEvent(event)
|
||||
end
|
||||
|
||||
self.text:SetFormattedText(displayString, configText)
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Left Click:"], L["Toggle Configuration"], 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(L["Hold Shift + Right Click:"], L["Reload UI"], 1, 1, 1)
|
||||
|
||||
if plugins then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddDoubleLine("Plugins:", "Version:")
|
||||
|
||||
for plugin, version in pairs(plugins) do
|
||||
DT.tooltip:AddDoubleLine(plugin, version, 1, 1, 1, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnClick(_, button)
|
||||
if button == "LeftButton" or (button == "RightButton" and not IsShiftKeyDown()) then
|
||||
E:ToggleOptionsUI()
|
||||
elseif button == "RightButton" and IsShiftKeyDown() then
|
||||
ReloadUI()
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", hex, "%s|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel, "ELVUI_COLOR_UPDATE")
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("ElvUI Config", {"PLAYER_ENTERING_WORLD"}, OnEvent, nil, OnClick, OnEnter)
|
||||
@@ -0,0 +1,36 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetPlayerMapPosition = GetPlayerMapPosition
|
||||
local ToggleFrame = ToggleFrame
|
||||
|
||||
local displayString = ""
|
||||
local x, y = 0, 0
|
||||
|
||||
local timeSinceUpdate = 0
|
||||
|
||||
local function OnUpdate(self, elapsed)
|
||||
timeSinceUpdate = timeSinceUpdate + elapsed
|
||||
|
||||
if timeSinceUpdate > 0.03333 then
|
||||
timeSinceUpdate = 0
|
||||
|
||||
x, y = GetPlayerMapPosition("player")
|
||||
|
||||
self.text:SetFormattedText(displayString, x * 100, y * 100)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
ToggleFrame(WorldMapFrame)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", hex, "%.2f|r", " , ", hex, "%.2f|r")
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Coords", nil, nil, OnUpdate, OnClick, nil, nil, L["Coords"])
|
||||
@@ -0,0 +1,71 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local GetCritChance = GetCritChance
|
||||
local GetRangedCritChance = GetRangedCritChance
|
||||
local GetSpellCritChance = GetSpellCritChance
|
||||
local COMBAT_RATING_NAME11 = COMBAT_RATING_NAME11
|
||||
local CRIT_ABBR = CRIT_ABBR
|
||||
local CR_CRIT_MELEE = CR_CRIT_MELEE
|
||||
local CR_CRIT_MELEE_TOOLTIP = CR_CRIT_MELEE_TOOLTIP
|
||||
local CR_CRIT_RANGED = CR_CRIT_RANGED
|
||||
local CR_CRIT_RANGED_TOOLTIP = CR_CRIT_RANGED_TOOLTIP
|
||||
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 critRating
|
||||
local displayModifierString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
if E.Role == "Caster"then
|
||||
critRating = GetSpellCritChance(2)
|
||||
elseif E.Role == "Ranged" then
|
||||
critRating = GetRangedCritChance()
|
||||
else
|
||||
critRating = GetCritChance()
|
||||
end
|
||||
|
||||
self.text:SetFormattedText(displayModifierString, critRating)
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local text, tooltip
|
||||
if E.Role == "Caster" then
|
||||
text = format("%s %.2f%%", format(PAPERDOLLFRAME_TOOLTIP_FORMAT, SPELL_CRIT_CHANCE), critRating)
|
||||
tooltip = format("%s %d", COMBAT_RATING_NAME11, GetCombatRating(11))
|
||||
elseif E.Role == "Ranged" then
|
||||
text = format("%s %.2f%%", format(PAPERDOLLFRAME_TOOLTIP_FORMAT, RANGED_CRIT_CHANCE), critRating)
|
||||
tooltip = format(CR_CRIT_RANGED_TOOLTIP, GetCombatRating(CR_CRIT_RANGED), GetCombatRatingBonus(CR_CRIT_RANGED))
|
||||
else
|
||||
text = format("%s %.2f%%", format(PAPERDOLLFRAME_TOOLTIP_FORMAT, MELEE_CRIT_CHANCE), critRating)
|
||||
tooltip = format(CR_CRIT_MELEE_TOOLTIP, GetCombatRating(CR_CRIT_MELEE), GetCombatRatingBonus(CR_CRIT_MELEE))
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(text, 1, 1, 1)
|
||||
DT.tooltip:AddLine(tooltip, nil, nil, nil, 1)
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayModifierString = join("", CRIT_ABBR, ": ", hex, "%.2f%%|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Crit Chance", {"ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE", "PLAYER_DAMAGE_DONE_MODS"}, OnEvent, nil, nil, OnEnter, nil, MELEE_CRIT_CHANCE)
|
||||
@@ -0,0 +1,90 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local select = select
|
||||
local time = time
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local UnitGUID = UnitGUID
|
||||
|
||||
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 playerID, petID
|
||||
local dmgTotal, lastDmgAmount = 0, 0
|
||||
local combatTime = 0
|
||||
local timeStamp = 0
|
||||
local lastSegment = 0
|
||||
local lastPanel
|
||||
local displayString = ""
|
||||
|
||||
local function Reset()
|
||||
timeStamp = 0
|
||||
combatTime = 0
|
||||
dmgTotal = 0
|
||||
lastDmgAmount = 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, E:ShortValue(dps))
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
lastPanel = self
|
||||
|
||||
if 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
|
||||
if not events[select(2, ...)] then return end
|
||||
|
||||
local id = select(3, ...)
|
||||
if id == playerID or id == petID then
|
||||
if timeStamp == 0 then
|
||||
timeStamp = ...
|
||||
end
|
||||
|
||||
lastSegment = timeStamp
|
||||
combatTime = (...) - timeStamp
|
||||
|
||||
if select(2, ...) == "SWING_DAMAGE" then
|
||||
lastDmgAmount = select(9, ...)
|
||||
else
|
||||
lastDmgAmount = select(12, ...)
|
||||
end
|
||||
|
||||
dmgTotal = dmgTotal + lastDmgAmount
|
||||
end
|
||||
elseif event == "UNIT_PET" then
|
||||
petID = UnitGUID("pet")
|
||||
elseif event == "PLAYER_ENTERING_WORLD" then
|
||||
playerID = E.myguid
|
||||
self:UnregisterEvent(event)
|
||||
end
|
||||
|
||||
GetDPS(self)
|
||||
end
|
||||
|
||||
local function OnClick(self)
|
||||
Reset()
|
||||
GetDPS(self)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", L["DPS"], ": ", hex, "%s")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("DPS", {"PLAYER_ENTERING_WORLD", "COMBAT_LOG_EVENT_UNFILTERED", "PLAYER_LEAVE_COMBAT", "PLAYER_REGEN_DISABLED", "UNIT_PET"}, OnEvent, nil, OnClick, nil, nil, L["DPS"])
|
||||
@@ -0,0 +1,347 @@
|
||||
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
|
||||
|
||||
--Lua functions
|
||||
local pairs, type, error = pairs, type, error
|
||||
local strlen = strlen
|
||||
--WoW API / Variables
|
||||
local CreateFrame = CreateFrame
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local IsInInstance = IsInInstance
|
||||
|
||||
function DT:Initialize()
|
||||
--if E.db.datatexts.enable ~= true then return end
|
||||
|
||||
self.Initialized = true
|
||||
self.db = E.db.datatexts
|
||||
|
||||
self.tooltip = CreateFrame("GameTooltip", "DatatextTooltip", nil, "GameTooltipTemplate")
|
||||
self.tooltip:SetParent(E.UIParent)
|
||||
self.tooltip:SetFrameStrata("TOOLTIP")
|
||||
TT:HookScript(self.tooltip, "OnShow", "SetStyle")
|
||||
|
||||
-- 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
|
||||
DatatextTooltipTextLeft1:FontTemplate(font, textSize, fontOutline)
|
||||
DatatextTooltipTextRight1:FontTemplate(font, textSize, fontOutline)
|
||||
|
||||
self:RegisterLDB()
|
||||
LDB.RegisterCallback(E, "LibDataBroker_DataObjectCreated", DT.SetupObjectLDB)
|
||||
|
||||
self:LoadDataTexts()
|
||||
|
||||
self:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
end
|
||||
|
||||
DT.RegisteredPanels = {}
|
||||
DT.RegisteredDataTexts = {}
|
||||
|
||||
DT.PointLocation = {
|
||||
[1] = "middle",
|
||||
[2] = "left",
|
||||
[3] = "right"
|
||||
}
|
||||
|
||||
function DT:PLAYER_ENTERING_WORLD()
|
||||
local inInstance, instanceType = IsInInstance()
|
||||
self.isInPVP = inInstance and instanceType == "pvp"
|
||||
|
||||
if (not self.isInPVP and self.ShowingBGStats)
|
||||
or (self.isInPVP and not self.ShowingBGStats and self.db.battleground)
|
||||
then
|
||||
self:LoadDataTexts()
|
||||
self.ShowingBGStats = not self.ShowingBGStats
|
||||
end
|
||||
end
|
||||
|
||||
local LDBHex = "|cffFFFFFF"
|
||||
function DT:SetupObjectLDB(name, obj)
|
||||
local curFrame = nil
|
||||
|
||||
local function OnEnter(dt)
|
||||
DT:SetupTooltip(dt)
|
||||
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
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
local function OnClick(dt, button)
|
||||
if obj.OnClick then
|
||||
obj.OnClick(dt, button)
|
||||
end
|
||||
end
|
||||
|
||||
local function textUpdate(_, Name, _, Value)
|
||||
if Value == nil or (strlen(Value) >= 3) or Value == "n/a" or Name == Value then
|
||||
curFrame.text:SetText(Value ~= "n/a" and Value or Name)
|
||||
else
|
||||
curFrame.text:SetFormattedText("%s: %s%s|r", Name, LDBHex, Value)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnCallback(newHex)
|
||||
if name and obj then
|
||||
LDBHex = newHex
|
||||
LDB.callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_text", name, nil, obj.text, obj)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(dt)
|
||||
curFrame = dt
|
||||
LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..name.."_text", textUpdate)
|
||||
LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..name.."_value", textUpdate)
|
||||
OnCallback(LDBHex)
|
||||
end
|
||||
|
||||
DT:RegisterDatatext(name, {"PLAYER_ENTERING_WORLD"}, OnEvent, nil, OnClick, OnEnter, OnLeave)
|
||||
E.valueColorUpdateFuncs[OnCallback] = 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
|
||||
self:SetupObjectLDB(name, obj)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:GetDataPanelPoint(panel, i, numPoints)
|
||||
if numPoints == 1 then
|
||||
return "CENTER", panel, "CENTER"
|
||||
else
|
||||
if i == 1 then
|
||||
return "CENTER", panel, "CENTER"
|
||||
elseif i == 2 then
|
||||
return "RIGHT", panel.dataPanels.middle, "LEFT", -4, 0
|
||||
elseif i == 3 then
|
||||
return "LEFT", panel.dataPanels.middle, "RIGHT", 4, 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:UpdateAllDimensions()
|
||||
for _, panel in pairs(DT.RegisteredPanels) do
|
||||
local width = (panel:GetWidth() / panel.numPoints) - 4
|
||||
local height = panel:GetHeight() - 4
|
||||
for i = 1, panel.numPoints do
|
||||
local pointIndex = DT.PointLocation[i]
|
||||
panel.dataPanels[pointIndex]:Width(width)
|
||||
panel.dataPanels[pointIndex]:Height(height)
|
||||
panel.dataPanels[pointIndex]:Point(DT:GetDataPanelPoint(panel, i, panel.numPoints))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function DT:Data_OnLeave()
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
function DT:SetupTooltip(panel)
|
||||
local parent = panel:GetParent()
|
||||
self.tooltip:Hide()
|
||||
self.tooltip:SetOwner(parent, parent.anchor, parent.xOff, parent.yOff)
|
||||
self.tooltip:ClearLines()
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
|
||||
function DT:RegisterPanel(panel, numPoints, anchor, xOff, yOff)
|
||||
DT.RegisteredPanels[panel:GetName()] = panel
|
||||
panel.dataPanels = {}
|
||||
panel.numPoints = numPoints
|
||||
|
||||
panel.xOff = xOff
|
||||
panel.yOff = yOff
|
||||
panel.anchor = anchor
|
||||
for i = 1, numPoints do
|
||||
local pointIndex = DT.PointLocation[i]
|
||||
if not panel.dataPanels[pointIndex] then
|
||||
panel.dataPanels[pointIndex] = CreateFrame("Button", "DataText"..i, panel)
|
||||
panel.dataPanels[pointIndex]:RegisterForClicks("AnyUp")
|
||||
panel.dataPanels[pointIndex].text = panel.dataPanels[pointIndex]:CreateFontString(nil, "OVERLAY")
|
||||
panel.dataPanels[pointIndex].text:SetAllPoints()
|
||||
panel.dataPanels[pointIndex].text:FontTemplate()
|
||||
panel.dataPanels[pointIndex].text:SetJustifyH("CENTER")
|
||||
panel.dataPanels[pointIndex].text:SetJustifyV("MIDDLE")
|
||||
end
|
||||
|
||||
panel.dataPanels[pointIndex]:Point(DT:GetDataPanelPoint(panel, i, numPoints))
|
||||
end
|
||||
|
||||
panel:SetScript("OnSizeChanged", DT.UpdateAllDimensions)
|
||||
DT.UpdateAllDimensions(panel)
|
||||
end
|
||||
|
||||
function DT:AssignPanelToDataText(panel, data)
|
||||
panel.name = ""
|
||||
if data.name then
|
||||
panel.name = data.name
|
||||
end
|
||||
|
||||
if data.events then
|
||||
for _, event in pairs(data.events) do
|
||||
panel:RegisterEvent(event)
|
||||
end
|
||||
end
|
||||
|
||||
if data.eventFunc then
|
||||
panel:SetScript("OnEvent", data.eventFunc)
|
||||
data.eventFunc(panel, "ELVUI_FORCE_RUN")
|
||||
end
|
||||
|
||||
if data.onUpdate then
|
||||
panel:SetScript("OnUpdate", data.onUpdate)
|
||||
data.onUpdate(panel, 20000)
|
||||
end
|
||||
|
||||
if data.onClick then
|
||||
panel:SetScript("OnClick", function(p, button)
|
||||
if E.db.datatexts.noCombatClick and InCombatLockdown() then return end
|
||||
data.onClick(p, button)
|
||||
end)
|
||||
end
|
||||
|
||||
if data.onEnter then
|
||||
panel:SetScript("OnEnter", function(p)
|
||||
if E.db.datatexts.noCombatHover and InCombatLockdown() then return end
|
||||
data.onEnter(p)
|
||||
end)
|
||||
end
|
||||
|
||||
if data.onLeave then
|
||||
panel:SetScript("OnLeave", data.onLeave)
|
||||
else
|
||||
panel:SetScript("OnLeave", DT.Data_OnLeave)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:LoadDataTexts()
|
||||
LDB:UnregisterAllCallbacks(self)
|
||||
|
||||
local fontTemplate = LSM:Fetch("font", self.db.font)
|
||||
local enableBGPanel = self.isInPVP and not self.ForceHideBGStats and self.db.battleground
|
||||
local pointIndex, showBGPanel
|
||||
|
||||
if ElvConfigToggle then
|
||||
ElvConfigToggle.text:FontTemplate(fontTemplate, self.db.fontSize, self.db.fontOutline)
|
||||
end
|
||||
|
||||
for panelName, panel in pairs(DT.RegisteredPanels) do
|
||||
showBGPanel = enableBGPanel and (panelName == "LeftChatDataPanel" or panelName == "RightChatDataPanel")
|
||||
|
||||
--Restore Panels
|
||||
for i = 1, panel.numPoints do
|
||||
pointIndex = DT.PointLocation[i]
|
||||
panel.dataPanels[pointIndex]:UnregisterAllEvents()
|
||||
panel.dataPanels[pointIndex]:SetScript("OnUpdate", nil)
|
||||
panel.dataPanels[pointIndex]:SetScript("OnEnter", nil)
|
||||
panel.dataPanels[pointIndex]:SetScript("OnLeave", nil)
|
||||
panel.dataPanels[pointIndex]:SetScript("OnClick", nil)
|
||||
panel.dataPanels[pointIndex].text:FontTemplate(fontTemplate, self.db.fontSize, self.db.fontOutline)
|
||||
panel.dataPanels[pointIndex].text:SetWordWrap(self.db.wordWrap)
|
||||
panel.dataPanels[pointIndex].text:SetText(nil)
|
||||
panel.dataPanels[pointIndex].pointIndex = pointIndex
|
||||
|
||||
if showBGPanel then
|
||||
panel.dataPanels[pointIndex]:RegisterEvent("UPDATE_BATTLEFIELD_SCORE")
|
||||
panel.dataPanels[pointIndex]:SetScript("OnEvent", DT.UPDATE_BATTLEFIELD_SCORE)
|
||||
panel.dataPanels[pointIndex]:SetScript("OnEnter", DT.BattlegroundStats)
|
||||
panel.dataPanels[pointIndex]:SetScript("OnLeave", DT.Data_OnLeave)
|
||||
panel.dataPanels[pointIndex]:SetScript("OnClick", DT.HideBattlegroundTexts)
|
||||
DT.UPDATE_BATTLEFIELD_SCORE(panel.dataPanels[pointIndex])
|
||||
else
|
||||
--Register Panel to Datatext
|
||||
for name, data in pairs(DT.RegisteredDataTexts) do
|
||||
for option, value in pairs(self.db.panels) do
|
||||
if value and type(value) == "table" then
|
||||
if option == panelName and self.db.panels[option][pointIndex] and self.db.panels[option][pointIndex] == name then
|
||||
DT:AssignPanelToDataText(panel.dataPanels[pointIndex], data)
|
||||
end
|
||||
elseif value and type(value) == "string" and value == name then
|
||||
if self.db.panels[option] == name and option == panelName then
|
||||
DT:AssignPanelToDataText(panel.dataPanels[pointIndex], data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if DT.ForceHideBGStats then
|
||||
DT.ForceHideBGStats = nil
|
||||
end
|
||||
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
|
||||
]]
|
||||
function DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc, onLeaveFunc, localizedName)
|
||||
if name then
|
||||
DT.RegisteredDataTexts[name] = {}
|
||||
else
|
||||
error("Cannot register datatext no name was provided.")
|
||||
end
|
||||
|
||||
DT.RegisteredDataTexts[name].name = name
|
||||
|
||||
if type(events) ~= "table" and events ~= nil then
|
||||
error("Events must be registered as a table.")
|
||||
else
|
||||
DT.RegisteredDataTexts[name].events = events
|
||||
DT.RegisteredDataTexts[name].eventFunc = eventFunc
|
||||
end
|
||||
|
||||
if updateFunc and type(updateFunc) == "function" then
|
||||
DT.RegisteredDataTexts[name].onUpdate = updateFunc
|
||||
end
|
||||
|
||||
if clickFunc and type(clickFunc) == "function" then
|
||||
DT.RegisteredDataTexts[name].onClick = clickFunc
|
||||
end
|
||||
|
||||
if onEnterFunc and type(onEnterFunc) == "function" then
|
||||
DT.RegisteredDataTexts[name].onEnter = onEnterFunc
|
||||
end
|
||||
|
||||
if onLeaveFunc and type(onLeaveFunc) == "function" then
|
||||
DT.RegisteredDataTexts[name].onLeave = onLeaveFunc
|
||||
end
|
||||
|
||||
if localizedName and type(localizedName) == "string" then
|
||||
DT.RegisteredDataTexts[name].localizedName = localizedName
|
||||
end
|
||||
end
|
||||
|
||||
local function InitializeCallback()
|
||||
DT:Initialize()
|
||||
end
|
||||
|
||||
E:RegisterModule(DT:GetName(), InitializeCallback)
|
||||
@@ -0,0 +1,94 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local ipairs = ipairs
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local GetInventoryItemDurability = GetInventoryItemDurability
|
||||
local GetInventorySlotInfo = GetInventorySlotInfo
|
||||
local ToggleCharacter = ToggleCharacter
|
||||
local DURABILITY = DURABILITY
|
||||
|
||||
local displayString = ""
|
||||
local tooltipString = "%d%%"
|
||||
local lastPanel
|
||||
local totalDurability, current, maxDur
|
||||
local invDurability = {}
|
||||
|
||||
local slots = {
|
||||
"HeadSlot",
|
||||
"ShoulderSlot",
|
||||
"ChestSlot",
|
||||
"WristSlot",
|
||||
"HandsSlot",
|
||||
"WaistSlot",
|
||||
"LegsSlot",
|
||||
"FeetSlot",
|
||||
"MainHandSlot",
|
||||
"SecondaryHandSlot",
|
||||
"RangedSlot",
|
||||
}
|
||||
|
||||
local slotsLocales = {
|
||||
["HeadSlot"] = HEADSLOT,
|
||||
["ShoulderSlot"] = SHOULDERSLOT,
|
||||
["ChestSlot"] = CHESTSLOT,
|
||||
["WristSlot"] = WRISTSLOT,
|
||||
["HandsSlot"] = HANDSSLOT,
|
||||
["WaistSlot"] = WAISTSLOT,
|
||||
["LegsSlot"] = LEGSSLOT,
|
||||
["FeetSlot"] = FEETSLOT,
|
||||
["MainHandSlot"] = MAINHANDSLOT,
|
||||
["SecondaryHandSlot"] = SECONDARYHANDSLOT,
|
||||
["RangedSlot"] = RANGEDSLOT,
|
||||
}
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
totalDurability = 100
|
||||
|
||||
for _, sType in ipairs(slots) do
|
||||
local slot = GetInventorySlotInfo(sType)
|
||||
current, maxDur = GetInventoryItemDurability(slot)
|
||||
|
||||
if current then
|
||||
invDurability[sType] = (current / maxDur) * 100
|
||||
|
||||
if invDurability[sType] < totalDurability then
|
||||
totalDurability = invDurability[sType]
|
||||
end
|
||||
else
|
||||
invDurability[sType] = nil
|
||||
end
|
||||
end
|
||||
|
||||
self.text:SetFormattedText(displayString, totalDurability)
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
ToggleCharacter("PaperDollFrame")
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
for _, sType in ipairs(slots) do
|
||||
if invDurability[sType] then
|
||||
DT.tooltip:AddDoubleLine(slotsLocales[sType], format(tooltipString, invDurability[sType]), 1, 1, 1, E:ColorGradient(invDurability[sType] * 0.01, 1, 0, 0, 1, 1, 0, 0, 1, 0))
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", DURABILITY, ": ", hex, "%d%%|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel, "ELVUI_COLOR_UPDATE")
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Durability", {"PLAYER_ENTERING_WORLD", "UPDATE_INVENTORY_DURABILITY", "MERCHANT_SHOW"}, OnEvent, nil, OnClick, OnEnter, nil, DURABILITY)
|
||||
@@ -0,0 +1,292 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local next = next
|
||||
local find, format, join = string.find, string.format, string.join
|
||||
local sort, wipe = table.sort, table.wipe
|
||||
--WoW API / Variables
|
||||
local EasyMenu = EasyMenu
|
||||
local GetFriendInfo = GetFriendInfo
|
||||
local GetMouseFocus = GetMouseFocus
|
||||
local GetNumFriends = GetNumFriends
|
||||
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
||||
local GetRealZoneText = GetRealZoneText
|
||||
local InviteUnit = InviteUnit
|
||||
local SendChatMessage = SendChatMessage
|
||||
local SetItemRef = SetItemRef
|
||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local UnitIsAFK = UnitIsAFK
|
||||
local UnitIsDND = UnitIsDND
|
||||
local AFK = AFK
|
||||
local DND = DND
|
||||
local FRIENDS = FRIENDS
|
||||
|
||||
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 levelNameFormat = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
|
||||
local levelNameStatusFormat = "|cff%02x%02x%02x%d|r %s%s %s"
|
||||
local onlineInfoFormat = join("", FRIENDS_LIST_ONLINE, ": %s/%s")
|
||||
|
||||
local afkStatusString = format("<%s>", AFK)
|
||||
local dndStatusString = format("<%s>", DND)
|
||||
|
||||
local inGroupStamp = "|cffaaaaaa*|r"
|
||||
local friendOnlineString = string.gsub(ERR_FRIEND_ONLINE_SS, ".+|h", "")
|
||||
local friendOfflineString = string.gsub(ERR_FRIEND_OFFLINE_S, "%%s", "")
|
||||
|
||||
local onlineStatusString = "|cffFFFFFF[|r|cff%s%s|r|cffFFFFFF]|r"
|
||||
local onlineStatus = {
|
||||
[""] = "",
|
||||
[afkStatusString] = format(onlineStatusString, "FF9900", L["AFK"]),
|
||||
[dndStatusString] = format(onlineStatusString, "FF3333", L["DND"]),
|
||||
}
|
||||
|
||||
local displayString = ""
|
||||
local lastPanel
|
||||
|
||||
local dataTable = {}
|
||||
local dataUpdated
|
||||
|
||||
local menuFrame = CreateFrame("Frame", "FriendDatatextRightClickMenu", E.UIParent, "UIDropDownMenuTemplate")
|
||||
local menuList = {
|
||||
{text = OPTIONS_MENU, isTitle = true, notCheckable = true},
|
||||
{text = INVITE, hasArrow = true, notCheckable = true, keepShownOnClick = true, noClickSound = true, menuList = {}},
|
||||
{text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable = true, keepShownOnClick = true, noClickSound = true, menuList = {}},
|
||||
{text = PLAYER_STATUS, hasArrow = true, notCheckable = true, keepShownOnClick = true, noClickSound = true,
|
||||
menuList = {
|
||||
{
|
||||
text = format("|cff2BC226%s|r", AVAILABLE),
|
||||
notCheckable = true,
|
||||
func = function()
|
||||
if UnitIsAFK("player") then
|
||||
SendChatMessage("", "AFK")
|
||||
elseif UnitIsDND("player") then
|
||||
SendChatMessage("", "DND")
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
text = format("|cffE7E716%s|r", DND),
|
||||
notCheckable = true,
|
||||
func = function()
|
||||
if not UnitIsDND("player") then
|
||||
SendChatMessage("", "DND")
|
||||
end
|
||||
end
|
||||
},
|
||||
{
|
||||
text = format("|cffFF0000%s|r", AFK),
|
||||
notCheckable = true,
|
||||
func = function()
|
||||
if not UnitIsAFK("player") then
|
||||
SendChatMessage("", "AFK")
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local function inviteClick(_, playerName)
|
||||
menuFrame:Hide()
|
||||
InviteUnit(playerName)
|
||||
end
|
||||
|
||||
local function whisperClick(_, playerName)
|
||||
menuFrame:Hide()
|
||||
SetItemRef("player:"..playerName, format("|Hplayer:%1$s|h[%1$s]|h", playerName), "LeftButton")
|
||||
end
|
||||
|
||||
local function sortByName(a, b)
|
||||
if a[1] and b[1] then
|
||||
return a[1] < b[1]
|
||||
end
|
||||
end
|
||||
|
||||
local function BuildDataTable(total)
|
||||
wipe(dataTable)
|
||||
|
||||
if total == 0 then return end
|
||||
|
||||
local name, level, class, area, connected, status, note, className
|
||||
|
||||
for i = 1, total do
|
||||
name, level, class, area, connected, status, note = GetFriendInfo(i)
|
||||
|
||||
if connected then
|
||||
className = E:UnlocalizedClassName(class) or ""
|
||||
status = onlineStatus[status] or ""
|
||||
|
||||
dataTable[i] = {name, level, className, area, connected, status, note}
|
||||
end
|
||||
end
|
||||
|
||||
if next(dataTable) then
|
||||
sort(dataTable, sortByName)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
if btn == "RightButton" then
|
||||
DT.tooltip:Hide()
|
||||
|
||||
wipe(menuList[2].menuList)
|
||||
wipe(menuList[3].menuList)
|
||||
|
||||
local menuCountWhispers, menuCountInvites = 0, 0
|
||||
local classc, levelc, info, grouped, shouldSkip
|
||||
|
||||
local db = E.db.datatexts.friends
|
||||
|
||||
for i = 1, #dataTable do
|
||||
info = dataTable[i]
|
||||
|
||||
if info[5] then
|
||||
if (info[6] == onlineStatus[afkStatusString]) and db.hideAFK then
|
||||
shouldSkip = true
|
||||
elseif (info[6] == onlineStatus[dndStatusString]) and db.hideDND then
|
||||
shouldSkip = true
|
||||
else
|
||||
shouldSkip = nil
|
||||
end
|
||||
|
||||
if not shouldSkip then
|
||||
classc = E.media.herocolor
|
||||
classc = classc or GetQuestDifficultyColor(info[2])
|
||||
levelc = GetQuestDifficultyColor(info[2])
|
||||
|
||||
if UnitInParty(info[1]) or UnitInRaid(info[1]) then
|
||||
grouped = inGroupStamp
|
||||
else
|
||||
grouped = ""
|
||||
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
menuList[2].menuList[menuCountInvites] = {
|
||||
text = format(levelNameFormat, levelc.r*255, levelc.g*255, levelc.b*255, info[2], classc.r*255, classc.g*255, classc.b*255, info[1], grouped),
|
||||
arg1 = info[1],
|
||||
notCheckable = true,
|
||||
func = inviteClick
|
||||
}
|
||||
end
|
||||
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
menuList[3].menuList[menuCountWhispers] = {
|
||||
text = format(levelNameFormat, levelc.r*255, levelc.g*255, levelc.b*255, info[2], classc.r*255, classc.g*255, classc.b*255, info[1], grouped),
|
||||
arg1 = info[1],
|
||||
notCheckable = true,
|
||||
func = whisperClick
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
menuList[2].disabled = menuCountInvites == 0
|
||||
menuList[3].disabled = menuCountWhispers == 0
|
||||
|
||||
EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
|
||||
else
|
||||
ToggleFriendsFrame(1)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
local numberOfFriends, onlineFriends = GetNumFriends()
|
||||
if onlineFriends == 0 then return end
|
||||
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if not dataUpdated then
|
||||
if numberOfFriends > 0 then
|
||||
BuildDataTable(numberOfFriends)
|
||||
end
|
||||
|
||||
dataUpdated = true
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(
|
||||
L["Friends List"],
|
||||
format(onlineInfoFormat, onlineFriends, numberOfFriends),
|
||||
tthead.r, tthead.g, tthead.b,
|
||||
tthead.r, tthead.g, tthead.b
|
||||
)
|
||||
|
||||
local playerZone = GetRealZoneText()
|
||||
local db = E.db.datatexts.friends
|
||||
local zonec, classc, levelc, info, grouped, shouldSkip
|
||||
|
||||
for i = 1, #dataTable do
|
||||
info = dataTable[i]
|
||||
|
||||
if info[5] then
|
||||
if (info[6] == onlineStatus[afkStatusString]) and db.hideAFK then
|
||||
shouldSkip = true
|
||||
elseif (info[6] == onlineStatus[dndStatusString]) and db.hideDND then
|
||||
shouldSkip = true
|
||||
else
|
||||
shouldSkip = nil
|
||||
end
|
||||
|
||||
if not shouldSkip then
|
||||
if playerZone == info[4] then
|
||||
zonec = activezone
|
||||
else
|
||||
zonec = inactivezone
|
||||
end
|
||||
|
||||
classc = E.media.herocolor
|
||||
classc = classc or GetQuestDifficultyColor(info[2])
|
||||
levelc = GetQuestDifficultyColor(info[2])
|
||||
|
||||
if UnitInParty(info[1]) or UnitInRaid(info[1]) then
|
||||
grouped = inGroupStamp
|
||||
else
|
||||
grouped = ""
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(
|
||||
format(levelNameStatusFormat, levelc.r*255, levelc.g*255, levelc.b*255, info[2], info[1], grouped, info[6]),
|
||||
info[4],
|
||||
classc.r, classc.g, classc.b,
|
||||
zonec.r, zonec.g, zonec.b
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, message)
|
||||
lastPanel = self
|
||||
|
||||
-- special handler to detect friend coming online or going offline
|
||||
if event == "CHAT_MSG_SYSTEM" then
|
||||
if not (find(message, friendOnlineString) or find(message, friendOfflineString)) then return end
|
||||
end
|
||||
|
||||
local _, onlineFriends = GetNumFriends()
|
||||
|
||||
self.text:SetFormattedText(displayString, onlineFriends)
|
||||
|
||||
-- force update when showing tooltip
|
||||
dataUpdated = nil
|
||||
|
||||
if GetMouseFocus() == self then
|
||||
self:GetScript("OnEnter")(self)
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", FRIENDS, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel, "ELVUI_COLOR_UPDATE")
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Friends", {"PLAYER_ENTERING_WORLD", "CHAT_MSG_SYSTEM", "FRIENDLIST_UPDATE"}, OnEvent, nil, OnClick, OnEnter, nil, FRIENDS)
|
||||
@@ -0,0 +1,164 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local pairs = pairs
|
||||
local format = string.format
|
||||
local tinsert, wipe = tinsert, wipe
|
||||
--WoW API / Variables
|
||||
local GetBackpackCurrencyInfo = GetBackpackCurrencyInfo
|
||||
local GetMoney = GetMoney
|
||||
local IsLoggedIn = IsLoggedIn
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local CURRENCY = CURRENCY
|
||||
local MAX_WATCHED_TOKENS = MAX_WATCHED_TOKENS
|
||||
|
||||
local currencyString = "|T%s:14:14:0:0:64:64:4:60:4:60|t %s"
|
||||
local resetCountersFormatter = string.join("", "|cffaaaaaa", L["Reset Counters: Hold Shift + Left Click"], "|r")
|
||||
local resetDataFormatter = string.join("", "|cffaaaaaa", L["Reset Data: Hold Shift + Right Click"], "|r")
|
||||
|
||||
local dataTable = {}
|
||||
local dataUpdated
|
||||
local myDataID
|
||||
local totalGold = 0
|
||||
local altGold = 0
|
||||
local profit = 0
|
||||
local spent = 0
|
||||
|
||||
local function BuildDataTable()
|
||||
wipe(dataTable)
|
||||
|
||||
for charName in pairs(ElvDB.gold[E.myrealm]) do
|
||||
if ElvDB.gold[E.myrealm][charName] then
|
||||
local color = E.media.herocolor
|
||||
|
||||
tinsert(dataTable,
|
||||
{
|
||||
name = charName,
|
||||
amount = ElvDB.gold[E.myrealm][charName],
|
||||
amountText = E:FormatMoney(ElvDB.gold[E.myrealm][charName], E.db.datatexts.goldFormat or "BLIZZARD", not E.db.datatexts.goldCoins),
|
||||
r = color.r, g = color.g, b = color.b,
|
||||
}
|
||||
)
|
||||
|
||||
if charName == E.myname then
|
||||
myDataID = #dataTable
|
||||
else
|
||||
altGold = altGold + ElvDB.gold[E.myrealm][charName]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
if not IsLoggedIn() then return end
|
||||
|
||||
local curMoney = GetMoney()
|
||||
|
||||
if not dataUpdated and (event == "PLAYER_ENTERING_WORLD" or event == "ELVUI_FORCE_RUN") then
|
||||
ElvDB.gold = ElvDB.gold or {}
|
||||
ElvDB.gold[E.myrealm] = ElvDB.gold[E.myrealm] or {}
|
||||
ElvDB.gold[E.myrealm][E.myname] = ElvDB.gold[E.myrealm][E.myname] or curMoney
|
||||
|
||||
ElvDB.class = ElvDB.class or {}
|
||||
ElvDB.class[E.myrealm] = ElvDB.class[E.myrealm] or {}
|
||||
ElvDB.class[E.myrealm][E.myname] = E.myclass
|
||||
|
||||
BuildDataTable()
|
||||
dataUpdated = true
|
||||
|
||||
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
|
||||
end
|
||||
|
||||
local oldMoney = ElvDB.gold[E.myrealm][E.myname]
|
||||
|
||||
if oldMoney > curMoney then
|
||||
spent = spent - (curMoney - oldMoney)
|
||||
else
|
||||
profit = profit + (curMoney - oldMoney)
|
||||
end
|
||||
|
||||
ElvDB.gold[E.myrealm][E.myname] = curMoney
|
||||
totalGold = altGold + curMoney
|
||||
|
||||
local formattedMoney = E:FormatMoney(curMoney, E.db.datatexts.goldFormat or "BLIZZARD", not E.db.datatexts.goldCoins)
|
||||
|
||||
dataTable[myDataID].amount = curMoney
|
||||
dataTable[myDataID].amountText = formattedMoney
|
||||
|
||||
self.text:SetText(formattedMoney)
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local style = E.db.datatexts.goldFormat or "BLIZZARD"
|
||||
local textOnly = not E.db.datatexts.goldCoins
|
||||
|
||||
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(" ")
|
||||
DT.tooltip:AddLine(L["Character: "])
|
||||
|
||||
for _, g in ipairs(dataTable) do
|
||||
DT.tooltip:AddDoubleLine(g.name == E.myname and g.name.." |TInterface\\FriendsFrame\\StatusIcon-Online:14|t" or g.name, g.amountText, g.r, g.g, g.b, 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(L["Server: "])
|
||||
DT.tooltip:AddDoubleLine(L["Total: "], E:FormatMoney(totalGold, style, textOnly), 1, 1, 1, 1, 1, 1)
|
||||
|
||||
local name, count, currencyType, icon
|
||||
|
||||
for i = 1, MAX_WATCHED_TOKENS do
|
||||
name, count, currencyType, icon = GetBackpackCurrencyInfo(i)
|
||||
|
||||
if name and i == 1 then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(CURRENCY..":")
|
||||
end
|
||||
|
||||
if name and count then
|
||||
if currencyType == 1 then
|
||||
icon = "Interface\\PVPFrame\\PVP-ArenaPoints-Icon"
|
||||
elseif currencyType == 2 then
|
||||
icon = "Interface\\PVPFrame\\PVP-Currency-"..E.myfaction
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(format(currencyString, icon, name), count, 1, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(resetCountersFormatter)
|
||||
DT.tooltip:AddLine(resetDataFormatter)
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnClick(self, btn)
|
||||
if btn == "RightButton" and IsShiftKeyDown() then
|
||||
ElvDB.gold = nil
|
||||
dataUpdated = nil
|
||||
OnEvent(self, "PLAYER_ENTERING_WORLD")
|
||||
OnEnter(self)
|
||||
elseif btn == "LeftButton" then
|
||||
if IsShiftKeyDown() then
|
||||
profit = 0
|
||||
spent = 0
|
||||
OnEnter(self)
|
||||
else
|
||||
OpenAllBags()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT:RegisterDatatext("Gold", {"PLAYER_ENTERING_WORLD", "PLAYER_MONEY", "SEND_MAIL_MONEY_CHANGED", "SEND_MAIL_COD_CHANGED", "PLAYER_TRADE_MONEY", "TRADE_MONEY_CHANGED"}, OnEvent, nil, OnClick, OnEnter, nil, L["Gold"])
|
||||
@@ -0,0 +1,328 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local find, format, join = string.find, string.format, string.join
|
||||
local sort, wipe = table.sort, table.wipe
|
||||
--WoW API / Variables
|
||||
local EasyMenu = EasyMenu
|
||||
local GetGuildInfo = GetGuildInfo
|
||||
local GetGuildRosterInfo = GetGuildRosterInfo
|
||||
local GetGuildRosterMOTD = GetGuildRosterMOTD
|
||||
local GetMouseFocus = GetMouseFocus
|
||||
local GetNumGuildMembers = GetNumGuildMembers
|
||||
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
||||
local GetRealZoneText = GetRealZoneText
|
||||
local GuildRoster = GuildRoster
|
||||
local InviteUnit = InviteUnit
|
||||
local IsInGuild = IsInGuild
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local SetItemRef = SetItemRef
|
||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local GUILD = GUILD
|
||||
local GUILD_MOTD = GUILD_MOTD
|
||||
|
||||
local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=0.3,g=1,b=0.3}
|
||||
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
|
||||
|
||||
local levelNameFormat = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
|
||||
local levelNameStatusFormat = "|cff%02x%02x%02x%d|r %s%s"
|
||||
local onlineInfoFormat = join("", GUILD, ": %d/%d")
|
||||
|
||||
local guildMotDFormat = "%s |cffaaaaaa- |cffffffff%s"
|
||||
local moreMembersOnlineFormat = join("", "+ %d ", FRIENDS_LIST_ONLINE, "...")
|
||||
local nameRankFormat = "%s |cff999999-|cffffffff %s"
|
||||
local noteFormat = join("", "|cff999999 ", LABEL_NOTE, ":|r %s")
|
||||
local officerNoteFormat = join("", "|cff999999 ", GUILD_RANK1_DESC, ":|r %s")
|
||||
|
||||
local inGroupStamp = "|cffaaaaaa*|r"
|
||||
local friendOnlineString = select(2, string.split(" ", ERR_FRIEND_ONLINE_SS, 2))
|
||||
local friendOfflineString = select(2, string.split(" ", ERR_FRIEND_OFFLINE_S, 2))
|
||||
|
||||
local onlineStatusString = "|cffFFFFFF[|r|cffFF0000%s|r|cffFFFFFF]|r"
|
||||
local onlineStatus = {
|
||||
[0] = "",
|
||||
[1] = format(onlineStatusString, L["AFK"]),
|
||||
[2] = format(onlineStatusString, L["DND"]),
|
||||
}
|
||||
|
||||
local displayString = ""
|
||||
local noGuildString = ""
|
||||
local lastPanel
|
||||
|
||||
local dataTable = {}
|
||||
local guildMotD = ""
|
||||
local currentSortMode = false
|
||||
local dataUpdated
|
||||
local rosterDelay
|
||||
|
||||
local totalOnline = 0
|
||||
local totalMembers = 0
|
||||
|
||||
local menuFrame = CreateFrame("Frame", "GuildDatatTextRightClickMenu", E.UIParent, "UIDropDownMenuTemplate")
|
||||
local menuList = {
|
||||
{text = OPTIONS_MENU, isTitle = true, notCheckable = true},
|
||||
{text = INVITE, hasArrow = true, notCheckable = true, keepShownOnClick = true, noClickSound = true, menuList = {}},
|
||||
{text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable = true, keepShownOnClick = true, noClickSound = true, menuList = {}}
|
||||
}
|
||||
|
||||
local function inviteClick(_, playerName)
|
||||
menuFrame:Hide()
|
||||
InviteUnit(playerName)
|
||||
end
|
||||
|
||||
local function whisperClick(_, playerName)
|
||||
menuFrame:Hide()
|
||||
SetItemRef("player:"..playerName, format("|Hplayer:%1$s|h[%1$s]|h", playerName), "LeftButton")
|
||||
end
|
||||
|
||||
local function sortByRank(a, b)
|
||||
if a and b then
|
||||
return a[10] < b[10]
|
||||
end
|
||||
end
|
||||
|
||||
local function sortByName(a, b)
|
||||
if a and b then
|
||||
return a[1] < b[1]
|
||||
end
|
||||
end
|
||||
|
||||
local function SortDataTable(shiftKeyDown)
|
||||
if currentSortMode == shiftKeyDown and not dataUpdated then return end
|
||||
|
||||
if shiftKeyDown then
|
||||
sort(dataTable, sortByRank)
|
||||
else
|
||||
sort(dataTable, sortByName)
|
||||
end
|
||||
|
||||
currentSortMode = shiftKeyDown
|
||||
dataUpdated = nil
|
||||
end
|
||||
|
||||
local function BuildDataTable()
|
||||
wipe(dataTable)
|
||||
|
||||
totalMembers = GetNumGuildMembers()
|
||||
totalOnline = 0
|
||||
|
||||
local _, name, rank, rankIndex, level, zone, note, officernote, connected, status, englishClass
|
||||
|
||||
for i = 1, totalMembers do
|
||||
name, rank, rankIndex, level, _, zone, note, officernote, connected, status, englishClass = GetGuildRosterInfo(i)
|
||||
if not name then break end
|
||||
|
||||
if connected then
|
||||
totalOnline = totalOnline + 1
|
||||
dataTable[#dataTable + 1] = {name, rank, level, zone, note, officernote, connected, onlineStatus[status], englishClass, rankIndex}
|
||||
end
|
||||
end
|
||||
|
||||
dataUpdated = true
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
if btn == "RightButton" and IsInGuild() then
|
||||
if totalOnline <= 1 then return end
|
||||
|
||||
DT.tooltip:Hide()
|
||||
|
||||
wipe(menuList[2].menuList)
|
||||
wipe(menuList[3].menuList)
|
||||
|
||||
local menuCountWhispers, menuCountInvites = 0, 0
|
||||
local classc, levelc, info, grouped
|
||||
|
||||
for i = 1, #dataTable do
|
||||
info = dataTable[i]
|
||||
|
||||
if info[7] and info[1] ~= E.myname then
|
||||
classc = E.media.herocolor
|
||||
levelc = GetQuestDifficultyColor(info[3])
|
||||
|
||||
if UnitInParty(info[1]) or UnitInRaid(info[1]) then
|
||||
grouped = inGroupStamp
|
||||
else
|
||||
grouped = ""
|
||||
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
menuList[2].menuList[menuCountInvites] = {
|
||||
text = format(levelNameFormat, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], grouped),
|
||||
arg1 = info[1],
|
||||
notCheckable = true,
|
||||
func = inviteClick
|
||||
}
|
||||
end
|
||||
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
menuList[3].menuList[menuCountWhispers] = {
|
||||
text = format(levelNameFormat, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], grouped),
|
||||
arg1 = info[1],
|
||||
notCheckable = true,
|
||||
func = whisperClick
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
menuList[2].disabled = menuCountInvites == 0
|
||||
menuList[3].disabled = menuCountWhispers == 0
|
||||
|
||||
EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
|
||||
else
|
||||
ToggleFriendsFrame(3)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self, _, noUpdate)
|
||||
if not IsInGuild() then return end
|
||||
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if totalOnline == 0 then
|
||||
BuildDataTable()
|
||||
end
|
||||
|
||||
local guildName, guildRank = GetGuildInfo("player")
|
||||
|
||||
local playerZone = GetRealZoneText()
|
||||
local shiftKeyDown = IsShiftKeyDown()
|
||||
local zonec, classc, levelc, info, grouped
|
||||
local shown = 0
|
||||
|
||||
if totalOnline > 1 then
|
||||
SortDataTable(shiftKeyDown)
|
||||
end
|
||||
|
||||
if guildName and guildRank then
|
||||
DT.tooltip:AddDoubleLine(
|
||||
guildName,
|
||||
format(onlineInfoFormat, totalOnline, totalMembers),
|
||||
tthead.r, tthead.g, tthead.b,
|
||||
tthead.r, tthead.g, tthead.b
|
||||
)
|
||||
DT.tooltip:AddLine(guildRank, tthead.r,tthead.g,tthead.b)
|
||||
end
|
||||
|
||||
if guildMotD ~= "" then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(format(guildMotDFormat, GUILD_MOTD, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
for i = 1, #dataTable do
|
||||
info = dataTable[i]
|
||||
|
||||
if playerZone == info[4] then
|
||||
zonec = activezone
|
||||
else
|
||||
zonec = inactivezone
|
||||
end
|
||||
|
||||
classc = E.media.herocolor
|
||||
|
||||
if shiftKeyDown then
|
||||
DT.tooltip:AddDoubleLine(
|
||||
format(nameRankFormat, info[1], info[2]),
|
||||
info[4],
|
||||
classc.r, classc.g, classc.b,
|
||||
zonec.r, zonec.g, zonec.b
|
||||
)
|
||||
|
||||
if info[5] ~= "" then
|
||||
DT.tooltip:AddLine(format(noteFormat, info[5]), ttsubh.r, ttsubh.g, ttsubh.b, 1)
|
||||
end
|
||||
|
||||
if info[6] ~= "" then
|
||||
DT.tooltip:AddLine(format(officerNoteFormat, info[6]), ttoff.r, ttoff.g, ttoff.b, 1)
|
||||
end
|
||||
else
|
||||
levelc = GetQuestDifficultyColor(info[3])
|
||||
|
||||
if UnitInParty(info[1]) or UnitInRaid(info[1]) then
|
||||
grouped = inGroupStamp
|
||||
else
|
||||
grouped = ""
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(
|
||||
format(levelNameStatusFormat, levelc.r*255, levelc.g*255, levelc.b*255, info[3], info[1], grouped, info[8]),
|
||||
info[4],
|
||||
classc.r, classc.g, classc.b,
|
||||
zonec.r, zonec.g, zonec.b
|
||||
)
|
||||
end
|
||||
|
||||
shown = shown + 1
|
||||
|
||||
if shown == 30 then
|
||||
if totalOnline > 30 then
|
||||
DT.tooltip:AddLine(format(moreMembersOnlineFormat, totalOnline - 30), ttsubh.r, ttsubh.g, ttsubh.b)
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
|
||||
if not noUpdate then
|
||||
GuildRoster()
|
||||
end
|
||||
end
|
||||
|
||||
local eventHandlers = {
|
||||
["ELVUI_FORCE_RUN"] = function(self)
|
||||
guildMotD = GetGuildRosterMOTD()
|
||||
GuildRoster()
|
||||
end,
|
||||
["GUILD_MOTD"] = function(_, message)
|
||||
guildMotD = message
|
||||
end,
|
||||
["CHAT_MSG_SYSTEM"] = function(_, message)
|
||||
if rosterDelay then return end
|
||||
|
||||
if find(message, friendOnlineString) or find(message, friendOfflineString) then
|
||||
rosterDelay = E:Delay(10, function()
|
||||
GuildRoster()
|
||||
rosterDelay = nil
|
||||
end)
|
||||
end
|
||||
end,
|
||||
["GUILD_ROSTER_UPDATE"] = function(self)
|
||||
GuildRoster()
|
||||
BuildDataTable()
|
||||
|
||||
if GetMouseFocus() == self then
|
||||
self:GetScript("OnEnter")(self, nil, true)
|
||||
end
|
||||
end,
|
||||
["PLAYER_GUILD_UPDATE"] = GuildRoster,
|
||||
["ELVUI_COLOR_UPDATE"] = E.noop,
|
||||
}
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
lastPanel = self
|
||||
|
||||
if IsInGuild() then
|
||||
eventHandlers[event](self, ...)
|
||||
|
||||
self.text:SetFormattedText(displayString, totalOnline)
|
||||
else
|
||||
self.text:SetText(noGuildString)
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", GUILD, ": ", hex, "%d|r")
|
||||
noGuildString = join("", hex, L["No Guild"])
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel, "ELVUI_COLOR_UPDATE")
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Guild", {"CHAT_MSG_SYSTEM", "GUILD_ROSTER_UPDATE", "PLAYER_GUILD_UPDATE", "GUILD_MOTD"}, OnEvent, nil, OnClick, OnEnter, nil, GUILD)
|
||||
@@ -0,0 +1,87 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local select = select
|
||||
local time = time
|
||||
local max = math.max
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local UnitGUID = UnitGUID
|
||||
|
||||
local events = {SPELL_HEAL = true, SPELL_PERIODIC_HEAL = true}
|
||||
local playerID, petID
|
||||
local healTotal, lastHealAmount = 0, 0
|
||||
local combatTime = 0
|
||||
local timeStamp = 0
|
||||
local lastSegment = 0
|
||||
local lastPanel
|
||||
local displayString = ""
|
||||
|
||||
local function Reset()
|
||||
timeStamp = 0
|
||||
combatTime = 0
|
||||
healTotal = 0
|
||||
lastHealAmount = 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, E:ShortValue(hps))
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
lastPanel = self
|
||||
|
||||
if 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
|
||||
if not events[select(2, ...)] then return end
|
||||
|
||||
local id = select(3, ...)
|
||||
if id == playerID or id == petID then
|
||||
if timeStamp == 0 then
|
||||
timeStamp = ...
|
||||
end
|
||||
|
||||
lastSegment = timeStamp
|
||||
combatTime = (...) - timeStamp
|
||||
|
||||
local overHeal = select(13, ...)
|
||||
lastHealAmount = select(12, ...)
|
||||
healTotal = healTotal + max(0, lastHealAmount - overHeal)
|
||||
end
|
||||
elseif event == "UNIT_PET" then
|
||||
petID = UnitGUID("pet")
|
||||
elseif event == "PLAYER_ENTERING_WORLD" then
|
||||
playerID = E.myguid
|
||||
self:UnregisterEvent(event)
|
||||
end
|
||||
|
||||
GetHPS(self)
|
||||
end
|
||||
|
||||
local function OnClick(self)
|
||||
Reset()
|
||||
GetHPS(self)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", L["HPS"], ": ", hex, "%s")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("HPS", {"PLAYER_ENTERING_WORLD", "COMBAT_LOG_EVENT_UNFILTERED", "PLAYER_LEAVE_COMBAT", "PLAYER_REGEN_DISABLED", "UNIT_PET"}, OnEvent, nil, OnClick, nil, nil, L["HPS"])
|
||||
@@ -0,0 +1,76 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local GetCombatRating = GetCombatRating
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local UnitAttackSpeed = UnitAttackSpeed
|
||||
local UnitRangedDamage = UnitRangedDamage
|
||||
local ATTACK_SPEED = ATTACK_SPEED
|
||||
local CR_HASTE_MELEE = CR_HASTE_MELEE
|
||||
local CR_HASTE_RANGED = CR_HASTE_RANGED
|
||||
local CR_HASTE_RATING_TOOLTIP = CR_HASTE_RATING_TOOLTIP
|
||||
local CR_HASTE_SPELL = CR_HASTE_SPELL
|
||||
local PAPERDOLLFRAME_TOOLTIP_FORMAT = PAPERDOLLFRAME_TOOLTIP_FORMAT
|
||||
local SPELL_HASTE = SPELL_HASTE
|
||||
local SPELL_HASTE_ABBR = SPELL_HASTE_ABBR
|
||||
local SPELL_HASTE_TOOLTIP = SPELL_HASTE_TOOLTIP
|
||||
|
||||
local hasteRating
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
if E.Role == "Caster" then
|
||||
hasteRating = GetCombatRating(CR_HASTE_SPELL)
|
||||
elseif E.Role == "Ranged" then
|
||||
hasteRating = GetCombatRating(CR_HASTE_RANGED)
|
||||
else
|
||||
hasteRating = GetCombatRating(CR_HASTE_MELEE)
|
||||
end
|
||||
|
||||
self.text:SetFormattedText(displayNumberString, hasteRating)
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local text, tooltip
|
||||
if E.Role == "Caster" then
|
||||
text = format("%s %d", SPELL_HASTE, hasteRating)
|
||||
tooltip = format(SPELL_HASTE_TOOLTIP, GetCombatRatingBonus(CR_HASTE_SPELL))
|
||||
elseif E.Role == "Ranged" then
|
||||
text = format("%s %.2f", format(PAPERDOLLFRAME_TOOLTIP_FORMAT, ATTACK_SPEED), UnitRangedDamage("player"))
|
||||
tooltip = format(CR_HASTE_RATING_TOOLTIP, hasteRating, GetCombatRatingBonus(CR_HASTE_RANGED))
|
||||
else
|
||||
local speed, offhandSpeed = UnitAttackSpeed("player")
|
||||
|
||||
if offhandSpeed then
|
||||
text = format("%s %.2f / %.2f", format(PAPERDOLLFRAME_TOOLTIP_FORMAT, ATTACK_SPEED), speed, offhandSpeed)
|
||||
else
|
||||
text = format("%s %.2f", format(PAPERDOLLFRAME_TOOLTIP_FORMAT, ATTACK_SPEED), speed)
|
||||
end
|
||||
|
||||
tooltip = format(CR_HASTE_RATING_TOOLTIP, hasteRating, GetCombatRatingBonus(CR_HASTE_MELEE))
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(text, 1, 1, 1)
|
||||
DT.tooltip:AddLine(tooltip, nil, nil, nil, 1)
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", SPELL_HASTE_ABBR, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Haste", {"ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE", "UNIT_ATTACK_SPEED", "UNIT_SPELL_HASTE"}, OnEvent, nil, nil, OnEnter, nil, SPELL_HASTE)
|
||||
@@ -0,0 +1,40 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetCombatRatingBonus = GetCombatRatingBonus
|
||||
local CR_HIT_MELEE = CR_HIT_MELEE
|
||||
local CR_HIT_RANGED = CR_HIT_RANGED
|
||||
local CR_HIT_SPELL = CR_HIT_SPELL
|
||||
local STAT_HIT_CHANCE = STAT_HIT_CHANCE
|
||||
|
||||
local hitRatingBonus
|
||||
local displayString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
if E.Role == "Caster" then
|
||||
hitRatingBonus = GetCombatRatingBonus(CR_HIT_SPELL)
|
||||
elseif E.Role == "Ranged" then
|
||||
hitRatingBonus = GetCombatRatingBonus(CR_HIT_RANGED)
|
||||
else
|
||||
hitRatingBonus = GetCombatRatingBonus(CR_HIT_MELEE)
|
||||
end
|
||||
|
||||
self.text:SetFormattedText(displayString, hitRatingBonus)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", L["Hit"], ": ", hex, "%.2f%%|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Hit", {"ACTIVE_TALENT_GROUP_CHANGED", "PLAYER_TALENT_UPDATE", "COMBAT_RATING_UPDATE"}, OnEvent, nil, nil, nil, nil, STAT_HIT_CHANCE)
|
||||
@@ -0,0 +1,27 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetPVPLifetimeStats = GetPVPLifetimeStats
|
||||
local KILLS = KILLS
|
||||
|
||||
local lastPanel
|
||||
local displayNumberString = ""
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
self.text:SetFormattedText(displayNumberString, (GetPVPLifetimeStats()))
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", KILLS, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Honorable Kills", {"PLAYER_PVP_KILLS_CHANGED", "PLAYER_PVP_RANK_CHANGED"}, OnEvent, nil, nil, nil, nil, HONORABLE_KILLS)
|
||||
@@ -0,0 +1,27 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="DataTexts.lua"/>
|
||||
<Script file="System.lua"/>
|
||||
<Script file="Armor.lua"/>
|
||||
<Script file="Avoidance.lua"/>
|
||||
<Script file="Bags.lua"/>
|
||||
<Script file="CombatTime.lua"/>
|
||||
<Script file="Coordinates.lua"/>
|
||||
<Script file="Crit.lua"/>
|
||||
<Script file="DPS.lua"/>
|
||||
<Script file="Durability.lua"/>
|
||||
<Script file="Friends.lua"/>
|
||||
<Script file="Guild.lua"/>
|
||||
<Script file="Haste.lua"/>
|
||||
<Script file="Hit.lua"/>
|
||||
<Script file="HonorableKills.lua"/>
|
||||
<Script file="HPS.lua"/>
|
||||
<Script file="Regen.lua"/>
|
||||
<Script file="Time.lua"/>
|
||||
<Script file="Gold.lua"/>
|
||||
<Script file="AttackPower.lua"/>
|
||||
<Script file="SpellPower.lua"/>
|
||||
<Script file="Battleground.lua"/>
|
||||
<Script file="Resilience.lua"/>
|
||||
<Script file="Achievement.lua"/>
|
||||
<Script file="ConfigElvUI.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,35 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local GetManaRegen = GetManaRegen
|
||||
local MANA_REGEN = MANA_REGEN
|
||||
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
local baseMR, castingMR = GetManaRegen()
|
||||
|
||||
if InCombatLockdown() then
|
||||
self.text:SetFormattedText(displayNumberString, castingMR * 5)
|
||||
else
|
||||
self.text:SetFormattedText(displayNumberString, baseMR * 5)
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", MANA_REGEN, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Mana Regen", {"PLAYER_DAMAGE_DONE_MODS", "PLAYER_REGEN_DISABLED", "PLAYER_REGEN_ENABLED"}, OnEvent, nil, nil, nil, nil, MANA_REGEN)
|
||||
@@ -0,0 +1,39 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local min = math.min
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetCombatRating = GetCombatRating
|
||||
local CR_CRIT_TAKEN_MELEE = CR_CRIT_TAKEN_MELEE
|
||||
local CR_CRIT_TAKEN_RANGED = CR_CRIT_TAKEN_RANGED
|
||||
local CR_CRIT_TAKEN_SPELL = CR_CRIT_TAKEN_SPELL
|
||||
local STAT_RESILIENCE = STAT_RESILIENCE
|
||||
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
lastPanel = self
|
||||
|
||||
local melee = GetCombatRating(CR_CRIT_TAKEN_MELEE)
|
||||
local ranged = GetCombatRating(CR_CRIT_TAKEN_RANGED)
|
||||
local spell = GetCombatRating(CR_CRIT_TAKEN_SPELL)
|
||||
|
||||
local minResilience = min(melee, ranged)
|
||||
minResilience = min(minResilience, spell)
|
||||
|
||||
self.text:SetFormattedText(displayNumberString, minResilience)
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", STAT_RESILIENCE, ": ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Resilience", {"COMBAT_RATING_UPDATE"}, OnEvent, nil, nil, nil, nil, STAT_RESILIENCE)
|
||||
@@ -0,0 +1,34 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetSpellBonusDamage = GetSpellBonusDamage
|
||||
local GetSpellBonusHealing = GetSpellBonusHealing
|
||||
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
local spellDamage = GetSpellBonusDamage(7)
|
||||
local spellHealing = GetSpellBonusHealing()
|
||||
|
||||
if spellHealing > spellDamage then
|
||||
self.text:SetFormattedText(displayNumberString, L["HP"], spellHealing)
|
||||
else
|
||||
self.text:SetFormattedText(displayNumberString, L["SP"], spellDamage)
|
||||
end
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayNumberString = join("", "%s: ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Spell/Heal Power", {"PLAYER_DAMAGE_DONE_MODS"}, OnEvent, nil, nil, nil, nil, L["Spell/Heal Power"])
|
||||
@@ -0,0 +1,231 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local collectgarbage = collectgarbage
|
||||
local floor = math.floor
|
||||
local format = string.format
|
||||
local tinsert, sort = table.insert, table.sort
|
||||
--WoW API / Variables
|
||||
local CopyTable = CopyTable
|
||||
local GetAddOnCPUUsage = GetAddOnCPUUsage
|
||||
local GetAddOnInfo = GetAddOnInfo
|
||||
local GetAddOnMemoryUsage = GetAddOnMemoryUsage
|
||||
local GetFramerate = GetFramerate
|
||||
local GetNetStats = GetNetStats
|
||||
local GetNumAddOns = GetNumAddOns
|
||||
local HideUIPanel = HideUIPanel
|
||||
local IsAddOnLoaded = IsAddOnLoaded
|
||||
local IsModifierKeyDown = IsModifierKeyDown
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
local PlaySound = PlaySound
|
||||
local ResetCPUUsage = ResetCPUUsage
|
||||
local ShowUIPanel = ShowUIPanel
|
||||
local UpdateAddOnCPUUsage = UpdateAddOnCPUUsage
|
||||
local UpdateAddOnMemoryUsage = UpdateAddOnMemoryUsage
|
||||
|
||||
local cpuProfiling = GetCVar("scriptProfile") == "1"
|
||||
|
||||
local int = 5 -- initial delay
|
||||
local statusColors = {
|
||||
"|cff0CD809",
|
||||
"|cffE8DA0F",
|
||||
"|cffFF9000",
|
||||
"|cffD80909"
|
||||
}
|
||||
|
||||
local enteredFrame
|
||||
local homeLatencyString = "%d ms"
|
||||
local kiloByteString = "%d kb"
|
||||
local megaByteString = "%.2f mb"
|
||||
|
||||
local memoryTable = {}
|
||||
local cpuTable = {}
|
||||
local lodTable = {}
|
||||
local disabledTable = {}
|
||||
local initialized
|
||||
|
||||
local function OnEvent(self, event, addonName)
|
||||
if event == "ADDON_LOADED" then
|
||||
if lodTable[addonName] then
|
||||
tinsert(memoryTable, lodTable[addonName])
|
||||
|
||||
if cpuProfiling then
|
||||
tinsert(cpuTable, CopyTable(lodTable[addonName]))
|
||||
end
|
||||
|
||||
lodTable[addonName] = nil
|
||||
elseif disabledTable[addonName] then
|
||||
tinsert(memoryTable, disabledTable[addonName])
|
||||
|
||||
if cpuProfiling then
|
||||
tinsert(cpuTable, CopyTable(disabledTable[addonName]))
|
||||
end
|
||||
|
||||
disabledTable[addonName] = nil
|
||||
end
|
||||
elseif not initialized and (event == "PLAYER_ENTERING_WORLD" or event == "ELVUI_FORCE_RUN") then
|
||||
local _, name, title, enabled, loadable
|
||||
|
||||
for i = 1, GetNumAddOns() do
|
||||
name, title, _, enabled, loadable = GetAddOnInfo(i)
|
||||
|
||||
if IsAddOnLoaded(i) then
|
||||
tinsert(memoryTable, {i, title, 0})
|
||||
|
||||
if cpuProfiling then
|
||||
tinsert(cpuTable, {i, title, 0})
|
||||
end
|
||||
elseif loadable then
|
||||
lodTable[name] = {i, title, 0}
|
||||
elseif not enabled then
|
||||
disabledTable[name] = {i, title, 0}
|
||||
end
|
||||
end
|
||||
|
||||
initialized = true
|
||||
self:UnregisterEvent(event)
|
||||
elseif initialized and event == "ELVUI_FORCE_RUN" then
|
||||
local name
|
||||
|
||||
for i = 1, GetNumAddOns() do
|
||||
name = GetAddOnInfo(i)
|
||||
|
||||
if (lodTable[name] or disabledTable[name]) and IsAddOnLoaded(i) then
|
||||
OnEvent(self, "ADDON_LOADED", name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function formatMem(memory)
|
||||
if memory > 999 then
|
||||
return format(megaByteString, memory / 1024)
|
||||
else
|
||||
return format(kiloByteString, memory)
|
||||
end
|
||||
end
|
||||
|
||||
local function sortByMemoryOrCPU(a, b)
|
||||
if a and b then
|
||||
return (a[3] == b[3] and a[2] < b[2]) or a[3] > b[3]
|
||||
end
|
||||
end
|
||||
|
||||
local function UpdateMemory()
|
||||
UpdateAddOnMemoryUsage()
|
||||
|
||||
local totalMemory = 0
|
||||
for i = 1, #memoryTable do
|
||||
memoryTable[i][3] = GetAddOnMemoryUsage(memoryTable[i][1])
|
||||
totalMemory = totalMemory + memoryTable[i][3]
|
||||
end
|
||||
|
||||
sort(memoryTable, sortByMemoryOrCPU)
|
||||
|
||||
return totalMemory
|
||||
end
|
||||
|
||||
local function UpdateCPU()
|
||||
UpdateAddOnCPUUsage()
|
||||
|
||||
local totalCPU = 0
|
||||
for i = 1, #cpuTable do
|
||||
cpuTable[i][3] = GetAddOnCPUUsage(cpuTable[i][1])
|
||||
totalCPU = totalCPU + cpuTable[i][3]
|
||||
end
|
||||
|
||||
sort(cpuTable, sortByMemoryOrCPU)
|
||||
|
||||
return totalCPU
|
||||
end
|
||||
|
||||
local function ToggleGameMenuFrame()
|
||||
if GameMenuFrame:IsShown() then
|
||||
PlaySound("igMainMenuQuit")
|
||||
HideUIPanel(GameMenuFrame)
|
||||
else
|
||||
PlaySound("igMainMenuOpen")
|
||||
ShowUIPanel(GameMenuFrame)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
if IsModifierKeyDown() then
|
||||
collectgarbage("collect")
|
||||
ResetCPUUsage()
|
||||
elseif btn == "LeftButton" then
|
||||
ToggleGameMenuFrame()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local totalMemory = UpdateMemory()
|
||||
local _, _, homeLatency = GetNetStats()
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Home Latency:"], format(homeLatencyString, homeLatency), 0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
|
||||
DT.tooltip:AddDoubleLine(L["Total Memory:"], formatMem(totalMemory), 0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
|
||||
|
||||
local totalCPU
|
||||
if cpuProfiling then
|
||||
totalCPU = UpdateCPU()
|
||||
DT.tooltip:AddDoubleLine(L["Total CPU:"], format(homeLatencyString, totalCPU), 0.69, 0.31, 0.31, 0.84, 0.75, 0.65)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
local addon, red, green
|
||||
|
||||
if IsShiftKeyDown() or not cpuProfiling then
|
||||
for i = 1, #memoryTable do
|
||||
addon = memoryTable[i]
|
||||
red = addon[3] / totalMemory
|
||||
green = 1 - red
|
||||
DT.tooltip:AddDoubleLine(addon[2], formatMem(addon[3]), 1, 1, 1, red, green + .5, 0)
|
||||
end
|
||||
else
|
||||
for i = 1, #cpuTable do
|
||||
addon = cpuTable[i]
|
||||
red = addon[3] / totalCPU
|
||||
green = 1 - red
|
||||
DT.tooltip:AddDoubleLine(addon[2], format(homeLatencyString, addon[3]), 1, 1, 1, red, green + .5, 0)
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(L["(Hold Shift) Memory Usage"])
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(L["(Modifer Click) Collect Garbage"])
|
||||
DT.tooltip:Show()
|
||||
enteredFrame = true
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
enteredFrame = nil
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
local function OnUpdate(self, t)
|
||||
int = int - t
|
||||
|
||||
if int < 0 then
|
||||
local framerate = floor(GetFramerate() + 0.5)
|
||||
local _, _, homeLatency = GetNetStats()
|
||||
|
||||
self.text:SetFormattedText("FPS: %s%d|r MS: %s%d|r",
|
||||
statusColors[framerate >= 30 and 1 or (framerate >= 20 and framerate < 30) and 2 or (framerate >= 10 and framerate < 20) and 3 or 4],
|
||||
framerate,
|
||||
statusColors[homeLatency < 150 and 1 or (homeLatency >= 150 and homeLatency < 300) and 2 or (homeLatency >= 300 and homeLatency < 500) and 3 or 4],
|
||||
homeLatency)
|
||||
|
||||
int = 1
|
||||
|
||||
if enteredFrame then
|
||||
OnEnter(self)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT:RegisterDatatext("System", {"PLAYER_ENTERING_WORLD", "ADDON_LOADED"}, OnEvent, OnUpdate, OnClick, OnEnter, OnLeave, L["System"])
|
||||
@@ -0,0 +1,275 @@
|
||||
local E, L, V, P, G = unpack(select(2, ...)) --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts")
|
||||
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local date = date
|
||||
local next = next
|
||||
local select = select
|
||||
local time = time
|
||||
local tonumber = tonumber
|
||||
local find, format, gsub, join, utf8sub = string.find, string.format, string.gsub, string.join, string.utf8sub
|
||||
local tinsert, wipe = table.insert, table.wipe
|
||||
--WoW API / Variables
|
||||
local GetGameTime = GetGameTime
|
||||
local GetNumSavedInstances = GetNumSavedInstances
|
||||
local GetSavedInstanceInfo = GetSavedInstanceInfo
|
||||
local GetWintergraspWaitTime = GetWintergraspWaitTime
|
||||
local IsInInstance = IsInInstance
|
||||
local RequestRaidInfo = RequestRaidInfo
|
||||
local SecondsToTime = SecondsToTime
|
||||
|
||||
local QUEUE_TIME_UNAVAILABLE = QUEUE_TIME_UNAVAILABLE
|
||||
local TIMEMANAGER_AM = TIMEMANAGER_AM
|
||||
local TIMEMANAGER_PM = TIMEMANAGER_PM
|
||||
local TIMEMANAGER_TOOLTIP_LOCALTIME = TIMEMANAGER_TOOLTIP_LOCALTIME
|
||||
local TIMEMANAGER_TOOLTIP_REALMTIME = TIMEMANAGER_TOOLTIP_REALMTIME
|
||||
local WINTERGRASP_IN_PROGRESS = WINTERGRASP_IN_PROGRESS
|
||||
|
||||
local timeDisplayFormat = ""
|
||||
local dateDisplayFormat = ""
|
||||
local lockoutInfoFormat = "%s%s %s |cffaaaaaa(%s)"
|
||||
local lockoutColorExtended, lockoutColorNormal = {r = 0.3, g = 1, b = 0.3}, {r = .8, g = .8, b = .8}
|
||||
local lockedInstances = {raids = {}, dungeons = {}}
|
||||
local timeFormat, realmDiffSeconds, showAMPM, showSecs
|
||||
local enteredFrame, fullUpdate
|
||||
local instanceIconByName
|
||||
local numSavedInstances = 0
|
||||
|
||||
local locale = GetLocale()
|
||||
local krcntw = locale == "koKR" or locale == "zhCN" or locale == "zhTW"
|
||||
local difficultyTag = { -- Normal, Normal, Heroic, Heroic
|
||||
(krcntw and PLAYER_DIFFICULTY1) or utf8sub(PLAYER_DIFFICULTY1, 1, 1), -- N
|
||||
(krcntw and PLAYER_DIFFICULTY1) or utf8sub(PLAYER_DIFFICULTY1, 1, 1), -- N
|
||||
(krcntw and PLAYER_DIFFICULTY2) or utf8sub(PLAYER_DIFFICULTY2, 1, 1), -- H
|
||||
(krcntw and PLAYER_DIFFICULTY2) or utf8sub(PLAYER_DIFFICULTY2, 1, 1), -- H
|
||||
}
|
||||
|
||||
local function getRealmTimeDiff()
|
||||
local hours, minutes = GetGameTime()
|
||||
local localTime = date("*t")
|
||||
|
||||
local diffHours = localTime.hour - hours
|
||||
local diffMinutes = localTime.min - minutes
|
||||
|
||||
return (diffHours * 60 + diffMinutes) * 60
|
||||
end
|
||||
|
||||
local function GetCurrentDate(formatString, forceLocalTime, forceRealmTime)
|
||||
if timeFormat ~= E.db.datatexts.timeFormat then
|
||||
timeFormat = E.db.datatexts.timeFormat
|
||||
showAMPM = find(E.db.datatexts.timeFormat, "%%p") ~= nil
|
||||
showSecs = find(E.db.datatexts.timeFormat, "%%S") ~= nil
|
||||
end
|
||||
|
||||
if showAMPM then
|
||||
local localizedAMPM = tonumber(date("%H")) >= 12 and TIMEMANAGER_PM or TIMEMANAGER_AM
|
||||
|
||||
formatString = gsub(formatString, "^%%p", localizedAMPM)
|
||||
formatString = gsub(formatString, "([^%%])%%p", "%1"..localizedAMPM)
|
||||
end
|
||||
|
||||
if realmDiffSeconds ~= 0 and (E.db.datatexts.realmTime or forceRealmTime) and not forceLocalTime then
|
||||
return date(formatString, time() - realmDiffSeconds)
|
||||
else
|
||||
return date(formatString)
|
||||
end
|
||||
end
|
||||
|
||||
local function GetInstanceImages(...)
|
||||
local numTextures = select("#", ...) / 4
|
||||
|
||||
local argn, title, texture = 1
|
||||
for i = 1, numTextures do
|
||||
title, texture = select(argn, ...)
|
||||
if texture ~= "" then
|
||||
instanceIconByName[title] = texture
|
||||
end
|
||||
argn = argn + 4
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self, event)
|
||||
if event == "UPDATE_INSTANCE_INFO" then
|
||||
local num = GetNumSavedInstances()
|
||||
|
||||
if num ~= numSavedInstances then
|
||||
numSavedInstances = num or 0
|
||||
|
||||
if enteredFrame then
|
||||
fullUpdate = true
|
||||
end
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if not realmDiffSeconds then
|
||||
realmDiffSeconds = getRealmTimeDiff()
|
||||
|
||||
if realmDiffSeconds < 900 then
|
||||
realmDiffSeconds = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
if btn == "RightButton" then
|
||||
if not IsAddOnLoaded("Blizzard_TimeManager") then
|
||||
LoadAddOn("Blizzard_TimeManager")
|
||||
end
|
||||
TimeManagerClockButton_OnClick(TimeManagerClockButton)
|
||||
else
|
||||
GameTimeFrame:Click()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self, skipRequest)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if not skipRequest then
|
||||
RequestRaidInfo()
|
||||
end
|
||||
|
||||
if not instanceIconByName then
|
||||
instanceIconByName = {}
|
||||
GetInstanceImages(CalendarEventGetTextures(1))
|
||||
GetInstanceImages(CalendarEventGetTextures(2))
|
||||
end
|
||||
|
||||
local wgtime = GetWintergraspWaitTime()
|
||||
local _, instanceType = IsInInstance()
|
||||
if instanceType ~= "none" then
|
||||
wgtime = QUEUE_TIME_UNAVAILABLE
|
||||
elseif wgtime == nil then
|
||||
wgtime = WINTERGRASP_IN_PROGRESS
|
||||
else
|
||||
wgtime = SecondsToTime(wgtime, false, nil, 3)
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(L["Wintergrasp"], wgtime, 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
|
||||
if numSavedInstances > 0 then
|
||||
wipe(lockedInstances.raids)
|
||||
wipe(lockedInstances.dungeons)
|
||||
|
||||
local name, reset, difficulty, locked, extended, isRaid, maxPlayers, difficultyLetter, buttonImg
|
||||
|
||||
for i = 1, numSavedInstances do
|
||||
name, _, reset, difficulty, locked, extended, _, isRaid, maxPlayers = GetSavedInstanceInfo(i)
|
||||
|
||||
if name and (locked or extended) then
|
||||
difficultyLetter = difficultyTag[not isRaid and (difficulty == 2 and 3 or 1) or difficulty]
|
||||
buttonImg = format("|T%s%s:22:22:0:0:96:96:0:64:0:64|t ", "Interface\\LFGFrame\\LFGIcon-", instanceIconByName[name] or "Raid")
|
||||
|
||||
if isRaid then
|
||||
tinsert(lockedInstances.raids, {name, reset, extended, maxPlayers, difficultyLetter, buttonImg})
|
||||
elseif difficulty == 2 then
|
||||
tinsert(lockedInstances.dungeons, {name, reset, extended, maxPlayers, difficultyLetter, buttonImg})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local lockoutColor, info
|
||||
|
||||
if next(lockedInstances.raids) then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(L["Saved Raid(s)"])
|
||||
|
||||
for i = 1, #lockedInstances.raids do
|
||||
info = lockedInstances.raids[i]
|
||||
|
||||
lockoutColor = info[3] and lockoutColorExtended or lockoutColorNormal
|
||||
|
||||
DT.tooltip:AddDoubleLine(
|
||||
format(lockoutInfoFormat, info[6], info[4], info[5], info[1]),
|
||||
SecondsToTime(info[2], false, nil, 3),
|
||||
1, 1, 1,
|
||||
lockoutColor.r, lockoutColor.g, lockoutColor.b
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
if next(lockedInstances.dungeons) then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(L["Saved Dungeon(s)"])
|
||||
|
||||
for i = 1, #lockedInstances.dungeons do
|
||||
info = lockedInstances.dungeons[i]
|
||||
|
||||
lockoutColor = info[3] and lockoutColorExtended or lockoutColorNormal
|
||||
|
||||
DT.tooltip:AddDoubleLine(
|
||||
format(lockoutInfoFormat, info[6], info[4], info[5], info[1]),
|
||||
SecondsToTime(info[2], false, nil, 3),
|
||||
1, 1, 1,
|
||||
lockoutColor.r, lockoutColor.g, lockoutColor.b
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
if E.db.datatexts.realmTime then
|
||||
DT.tooltip:AddDoubleLine(TIMEMANAGER_TOOLTIP_LOCALTIME, GetCurrentDate(E.db.datatexts.timeFormat, true), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(TIMEMANAGER_TOOLTIP_REALMTIME, GetCurrentDate(E.db.datatexts.timeFormat, nil, true), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
enteredFrame = true
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
enteredFrame = nil
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
local function updateTooltipTime()
|
||||
if E.db.datatexts.realmTime then
|
||||
_G["DatatextTooltipTextRight" .. DT.tooltip:NumLines()]:SetText(GetCurrentDate(E.db.datatexts.timeFormat, true))
|
||||
else
|
||||
_G["DatatextTooltipTextRight" .. DT.tooltip:NumLines()]:SetText(GetCurrentDate(E.db.datatexts.timeFormat, nil, true))
|
||||
end
|
||||
end
|
||||
|
||||
local lastPanel
|
||||
local int = 5
|
||||
local function OnUpdate(self, elapsed)
|
||||
int = int - elapsed
|
||||
|
||||
if int > 0 then return end
|
||||
|
||||
int = 1
|
||||
lastPanel = self
|
||||
|
||||
if GameTimeFrame.flashInvite then
|
||||
E:Flash(self, 0.53)
|
||||
else
|
||||
E:StopFlash(self)
|
||||
end
|
||||
|
||||
self.text:SetText(gsub(gsub(GetCurrentDate(E.db.datatexts.timeFormat.." "..E.db.datatexts.dateFormat), ":", timeDisplayFormat), "%s", dateDisplayFormat))
|
||||
|
||||
if enteredFrame then
|
||||
if fullUpdate then
|
||||
fullUpdate = nil
|
||||
OnEnter(self, true)
|
||||
elseif showSecs then
|
||||
updateTooltipTime()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
timeDisplayFormat = join("", hex, ":|r")
|
||||
dateDisplayFormat = join("", hex, " ")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnUpdate(lastPanel, 20000)
|
||||
end
|
||||
end
|
||||
E.valueColorUpdateFuncs[ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Time", {"UPDATE_INSTANCE_INFO"}, OnEvent, OnUpdate, OnClick, OnEnter, OnLeave)
|
||||
Reference in New Issue
Block a user