Commit 7efba15b authored by Caedis's avatar Caedis

Cleaning up

parent d835a566
local E, L, V, P, G, _ = unpack(ElvUI);
local DT = E:GetModule('DataTexts')
--Cache global variables
--Lua functions
local floor = floor
local format = string.format
--WoW API / Variables
local C_AzeriteItem_FindActiveAzeriteItem = C_AzeriteItem.FindActiveAzeriteItem
local C_AzeriteItem_GetAzeriteItemXPInfo = C_AzeriteItem.GetAzeriteItemXPInfo
local C_AzeriteItem_GetPowerLevel = C_AzeriteItem.GetPowerLevel
local C_AzeriteEmpoweredItem_IsAzeriteEmpoweredItem = C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItem
local C_Item_DoesItemExist = C_Item.DoesItemExist
local InCombatLockdown = InCombatLockdown
local GetInventorySlotInfo = GetInventorySlotInfo
local GetInventoryItemID = GetInventoryItemID
local GetItemInfo = GetItemInfo
local GetItemIcon = GetItemIcon
local Item = Item
local ARTIFACT_POWER = ARTIFACT_POWER
local AZERITE_POWER_TOOLTIP_BODY = AZERITE_POWER_TOOLTIP_BODY
local AZERITE_POWER_TOOLTIP_TITLE = AZERITE_POWER_TOOLTIP_TITLE
local menuFrame = CreateFrame("Frame", "AzeriteItemsDatatextClickMenu", E.UIParent, "UIDropDownMenuTemplate")
azeriteItemsList = {
{ text = 'Select Azerite Item', isTitle = true, notCheckable = true },
{ slot = 'HeadSlot', textTemplate = 'Helm: %s', notCheckable = true },
{ slot = 'ShoulderSlot', textTemplate = 'Shoulders: %s', notCheckable = true },
{ slot = 'ChestSlot', textTemplate = 'Chest: %s', notCheckable = true }
}
--for equipSlotIndex, itemLocation in AzeriteUtil.EnumerateEquipedAzeriteEmpoweredItems() do
-- OpenAzeriteEmpoweredItemUIFromItemLocation(itemLocation)
--end
local shortNum = function(v)
if v <= 999 then
return format("%d", v)
elseif v >= 1000000000 then
return format("%.1fb", v/1000000000)
elseif v >= 1000000 then
return format("%.1fm", v/1000000)
elseif v >= 1000 then
return format("%.1fk", v/1000)
end
end
local function OnEnter(self)
E:UIFrameFadeIn(self, 0.4, self:GetAlpha(), 1)
DT:SetupTooltip(self)
DT.tooltip:ClearLines()
--DT.tooltip:SetOwner(self, 'ANCHOR_CURSOR', 0, -4)
local azeriteItemLocation = C_AzeriteItem_FindActiveAzeriteItem();
if not azeriteItemLocation then
return
end
local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
local xp, totalLevelXP = C_AzeriteItem_GetAzeriteItemXPInfo(azeriteItemLocation)
local currentLevel = C_AzeriteItem_GetPowerLevel(azeriteItemLocation)
local xpToNextLevel = totalLevelXP - xp
local azeriteItemName = azeriteItem:GetItemName()
--[[ From Blizz Code
GameTooltip:SetText(AZERITE_POWER_TOOLTIP_TITLE:format(currentLevel, xpToNextLevel), HIGHLIGHT_FONT_COLOR:GetRGB());
GameTooltip:AddLine(AZERITE_POWER_TOOLTIP_BODY:format(azeriteItemName));
]]
DT.tooltip:AddDoubleLine(ARTIFACT_POWER, azeriteItemName.." ("..currentLevel..")", nil, nil, nil, 0.90, 0.80, 0.50) -- Temp Locale
DT.tooltip:AddLine(' ')
DT.tooltip:AddDoubleLine(L["AP:"], format(' %d / %d (%d%%)', xp, totalLevelXP, xp / totalLevelXP * 100), 1, 1, 1)
DT.tooltip:AddDoubleLine(L["Remaining:"], format(' %d (%d%% - %d '..L["Bars"]..')', xpToNextLevel, xpToNextLevel / totalLevelXP * 100, 10 * xpToNextLevel / totalLevelXP), 1, 1, 1)
DT.tooltip:AddLine(' ')
DT.tooltip:AddLine("|cffFFFFFFLeft Click:|r Show Azerite UI")
--DT.tooltip:AddLine("|cffFFFFFFRight Click:|r Change Azerite Item") --todo
DT.tooltip:Show()
end
--azeriteItemsList
function OnClick(self, button)
if button == "LeftButton" then
DT.tooltip:Hide()
local i = 2;
for index = 1, 3 do
local item = azeriteItemsList[index + 1]
local itemLocation = ItemLocation:CreateFromEquipmentSlot(GetInventorySlotInfo(item.slot));
item.notCheckable = true;
if C_Item_DoesItemExist(itemLocation) and C_AzeriteEmpoweredItem_IsAzeriteEmpoweredItem(itemLocation) then
local itemID = GetInventoryItemID("PLAYER", GetInventorySlotInfo(item.slot))
local itemName = GetItemInfo(itemID)
local itemIcon = GetItemIcon(itemID)
item.text = format(item.textTemplate, itemName)
item.icon = itemIcon
item.func = function() OpenAzeriteEmpoweredItemUIFromItemLocation(itemLocation) end
item.disabled = false
else
item.text = format(item.textTemplate, 'None Equipped')
item.icon = nil
item.func = nil
item.disabled = true
end
end
EasyMenu(azeriteItemsList, menuFrame, "cursor", -15, -7, "MENU", 2);
end
end
local function OnEvent(self, event, unit)
local azeriteItemLocation = C_AzeriteItem_FindActiveAzeriteItem();
if (not azeriteItemLocation) then
self.text:SetText('Azerite Item Not Found')
return;
end
local azeriteItem = Item:CreateFromItemLocation(azeriteItemLocation);
local xp, totalXP = C_AzeriteItem_GetAzeriteItemXPInfo(azeriteItemLocation);
local currentLevel = C_AzeriteItem_GetPowerLevel(azeriteItemLocation);
self.text:SetText(format('|cffe6cc80AP|r: %s/%s (%.0f%%)', shortNum(xp), shortNum(totalXP), xp/totalXP * 100))
lastPanel = self
end
local events = {
"PLAYER_ENTERING_WORLD",
"AZERITE_ITEM_EXPERIENCE_CHANGED"
}
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc)
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
]]
DT:RegisterDatatext('Azerite', events, OnEvent, nil, OnClick, OnEnter)
local E, L, V, P, G, _ = unpack(ElvUI)
local DT = E:GetModule("DataTexts")
--Cache global variables
--Lua functions
local floor = floor
local format = string.format
--WoW API / Variables
local C_PvP_IsWarModeActive = C_PvP.IsWarModeActive
local C_PvP_IsWarModeDesired = C_PvP.IsWarModeDesired
local C_PvP_IsWarModeFeatureEnabled = C_PvP.IsWarModeFeatureEnabled
local C_PvP_ToggleWarMode = C_PvP.ToggleWarMode
local C_PvP_CanToggleWarMode = C_PvP.CanToggleWarMode
local InCombatLockdown = InCombatLockdown
local function OnEnter(self)
E:UIFrameFadeIn(self, 0.4, self:GetAlpha(), 1)
DT:SetupTooltip(self)
DT.tooltip:ClearLines()
DT.tooltip:AddLine("|cffFFFFFFLeft Click:|r Toggle War Mode")
DT.tooltip:Show()
end
--azeriteItemsList
function OnClick(self, button)
if button == "LeftButton" then
DT.tooltip:Hide()
if C_PvP_CanToggleWarMode() then
C_PvP_ToggleWarMode()
end
end
end
local function OnEvent(self, event, unit)
local color
local icon
if C_PvP_IsWarModeDesired() then
color = "ff0000"
icon = " |TInterface\\Icons\\ui_warmode:16|t "
else
color = "00ff00"
icon = ""
end
self.text:SetText(format("%s|cff%sWar Mode%s", icon, color, icon))
end
local events = {
"PLAYER_ENTERING_WORLD",
"WAR_MODE_STATUS_UPDATE",
"PLAYER_FLAGS_CHANGED"
}
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc)
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
]]
DT:RegisterDatatext("War Mode", events, OnEvent, nil, OnClick, OnEnter)
local E, L, V, P, G, _ = unpack(ElvUI);
local DT = E:GetModule('DataTexts')
local lastPanel
local displayString = "---"
local _hex
local function OnEvent(self, event, ...)
lastPanel = self
local _text = "---"
if not _hex then return end
for i = 1, MAX_WATCHED_TOKENS do
if i == 1 then
displayString = ''
end
local name, count, extraCurrencyType, icon, itemid = GetBackpackCurrencyInfo(i)
if name and count then
if(i ~= 1) then _text = " " else _text = "" end
words = { strsplit(" ", name) }
for _, word in ipairs(words) do
if (name == "Honor Points" and i == 1) then
_text = "Honor"
else
_text = _text .. string.sub(word,1,1)
end
end
local str = tostring(_text..": ".._hex..count.."|r")
displayString = displayString..str
elseif i == 1 and not name and not count then
displayString = tostring(_hex.."---")
end
end
if self then
self.text:SetFormattedText(displayString)
end
displayString = "---"
end
local function OnEnter(self)
DT:SetupTooltip(self)
if lastPanel ~= nil then
OnEvent(lastPanel)
end
GameTooltip:Show()
end
local function OnClick(self)
GetBackpackCurrencyInfo(i)
end
local function ValueColorUpdate(hex, r, g, b)
_hex = hex
if lastPanel ~= nil then
OnEvent(lastPanel)
end
end
E['valueColorUpdateFuncs'][ValueColorUpdate] = true
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc)
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
]]
DT:RegisterDatatext('Currency', {"PLAYER_LOGIN"}, OnEvent, nil, nil, OnEnter)
hooksecurefunc("BackpackTokenFrame_Update", function(...) OnEvent(lastPanel) end )
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file='Volume.lua'/>
<Script file='RaidGroup.lua'/>
<Script file='currency.lua'/>
<Script file='avoidance.lua'/>
<Script file='mail.lua'/>
<Script file='ExpRep.lua'/>
<Script file='rdps.lua'/>
<Script file='rdtps.lua'/>
<Script file='rhps.lua'/>
<Script file='played.lua'/>
<Script file='NodeCount.lua'/>
<Script file='Avoidance.lua'/>
<Script file='CombatIndicator.lua'/>
<Script file='iLvl.lua'/>
<!-- <Script file='Artifact.lua'/> -->
<Script file='ExpRep.lua'/>
<Script file='HeartOfAzeroth.lua'/>
<Script file='ILvl.lua'/>
<Script file='Mail.lua'/>
<Script file='NodeCount.lua'/>
<Script file='Played.lua'/>
<Script file='RaidGroup.lua'/>
<Script file='Volume.lua'/>
<Script file='Warmode.lua'/>
</Ui>
\ No newline at end of file
local E, L, V, P, G, _ = unpack(ElvUI);
local DT = E:GetModule('DataTexts')
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 max_single_dps = 0
local max_rdps = 0
local max_who = ' '
local _hex
local function Reset()
timeStamp = 0
combatTime = 0
DMGTotal = 0
lastDMGAmount = 0
max_single_dps = 0
max_rdps = 0
max_who = ' '
end
-- add comma to separate thousands
--
function comma_value(amount)
local formatted = string.format("%.1f",amount)
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local function GetDPS(self)
local DPS
if DMGTotal == 0 or combatTime == 0 then
DPS = 0.0
else
DPS = (DMGTotal) / (combatTime)
end
if DPS > max_rdps then
max_rdps = DPS
end
self.text:SetFormattedText(displayString, 'RDPS: ', comma_value(DPS))
end
local function OnEvent(self, event, ...)
lastPanel = self
local dmg_type
if not _hex then return end
if not event then return end
if event == "PLAYER_ENTERING_WORLD" then
playerID = UnitGUID('player')
self.text:SetFormattedText('No Instance')
elseif event == 'PLAYER_REGEN_DISABLED' or event == "PLAYER_LEAVE_COMBAT" then
local now = time()
if now - lastSegment > 60 then --time since the last segment
-- Reset()
end
lastSegment = now
elseif event:match("^ZONE_.*") then
local inInstance, instanceType = IsInInstance()
if not inInstance and (instanceType == 'none' or instanceType == 'pvp' or instanceType == 'arena') then
self.text:SetFormattedText('No Instance')
else
GetDPS(self)
end
elseif event == 'COMBAT_LOG_EVENT_UNFILTERED' then
if not events[select(2, ...)] then return end
-- only use events from the party
local id = select(4, ...)
local name = select(5, ...)
local target = select(9, ...)
local inInstance, instanceType = IsInInstance()
if instanceType == 'party' or instanceType == 'raid' or target:match(".*Training Dummy") then
if UnitInParty(name) or UnitInRaid(name) and inInstance then
if timeStamp == 0 then timeStamp = select(1, ...) end
lastSegment = timeStamp
combatTime = select(1, ...) - timeStamp
if select(2, ...) == "SWING_DAMAGE" then
lastDMGAmount = select(12, ...)
dmg_type = ' |rSpell/Ability: '.._hex..' Melee'
else
lastDMGAmount = select(15, ...)
dmg_type = ' |rSpell/Ability: '.._hex..select(13, ...)
end
if lastDMGAmount > max_single_dps then
max_single_dps = lastDMGAmount
max_who = ' |rName: '.._hex..name..dmg_type..' |rTarget: '.._hex..target
end
DMGTotal = DMGTotal + lastDMGAmount
GetDPS(self)
end
end
elseif event == UNIT_PET then
petID = UnitGUID("pet")
end
end
local function OnClick(self)
Reset()
local inInstance, instanceType = IsInInstance()
if not inInstance and (instanceType == 'none' or instanceType == 'pvp' or instanceType == 'arena') then
self.text:SetFormattedText('No Instance')
else
GetDPS(self)
end
end
local function OnEnter(self)
DT:SetupTooltip(self)
GameTooltip:AddDoubleLine('"Raid Damage Done:')
GameTooltip:AddDoubleLine(' ')
GameTooltip:AddDoubleLine('|rMax Raid DPS: '.._hex..comma_value(max_rdps) )
GameTooltip:AddDoubleLine(tostring("Max Single: ".._hex..comma_value(max_single_dps)..max_who.."|r"))
GameTooltip:Show()
end
local function ValueColorUpdate(hex, r, g, b)
_hex = hex
displayString = string.join("", "%s", hex, "%s|r", hex)
if lastPanel ~= nil then
OnEvent(lastPanel)
end
end
E['valueColorUpdateFuncs'][ValueColorUpdate] = true;
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc)
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
]]
DT:RegisterDatatext('Raid-DPS', {'PLAYER_ENTERING_WORLD', 'COMBAT_LOG_EVENT_UNFILTERED', "PLAYER_LEAVE_COMBAT", 'PLAYER_REGEN_DISABLED', 'UNIT_PET', "ZONE_CHANGED", 'ZONE_CHANGED_NEW_AREA', "ZONE_CHANGED_INDOORS"}, OnEvent, nil, OnClick, OnEnter)
local E, L, V, P, G, _ = unpack(ElvUI);
local DT = E:GetModule('DataTexts')
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 max_single_dmg = 0
local max_rdtps = 0
local max_who = ' '
local _hex
local function Reset()
timeStamp = 0
combatTime = 0
DMGTotal = 0
lastDMGAmount = 0
max_single_dmg = 0
max_rdtps = 0
max_who = ' '
end
-- add comma to separate thousands
--
function comma_value(amount)
local formatted = string.format("%.1f",amount)
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
local function GetDTPS(self)
local DTPS
if DMGTotal == 0 or combatTime == 0 then
DTPS = 0.0
else
DTPS = (DMGTotal) / (combatTime)
end
if DTPS > max_rdtps then
max_rdtps = DTPS
end
self.text:SetFormattedText(displayString, 'RDTPS: ', comma_value(DTPS))
end
local function OnEvent(self, event, ...)
lastPanel = self
local dmg_type
if not _hex then return end
if not event then return end
if event == "PLAYER_ENTERING_WORLD" then
playerID = UnitGUID('player')
self.text:SetFormattedText('No Instance')
elseif event == 'PLAYER_REGEN_DISABLED' or event == "PLAYER_LEAVE_COMBAT" then
local now = time()
if now - lastSegment > 60 then --time since the last segment
Reset()
end
lastSegment = now
elseif event:match("^ZONE_.*") then
local inInstance, instanceType = IsInInstance()
if not inInstance and (instanceType == 'none' or instanceType == 'pvp' or instanceType == 'arena') then
self.text:SetFormattedText('No Instance')
else
GetDTPS(self)
end
elseif event == 'COMBAT_LOG_EVENT_UNFILTERED' then
if not events[select(2, ...)] then return end
-- only use events from the party
local id = select(4, ...)
local name = select(5, ...)
local inInstance, instanceType = IsInInstance()
if UnitInParty(name) and inInstance and not(instanceType == 'none' or instanceType == 'pvp' or instanceType == 'arena') then
-- if UnitInParty(name) or id == petID then
if timeStamp == 0 then timeStamp = select(1, ...) end
lastSegment = timeStamp
combatTime = select(1, ...) - timeStamp
if select(2, ...) == "SWING_DAMAGE" then
lastDMGAmount = select(12, ...)
dmg_type = ' |rSpell/Ability: '.._hex..' Melee'
else
lastDMGAmount = select(15, ...)
dmg_type = ' |rSpell/Ability: '.._hex..select(13, ...)
end
if lastDMGAmount > max_single_dmg then
max_single_dmg = lastDMGAmount
max_who = ' |rName: '.._hex..name..dmg_type
end
DMGTotal = DMGTotal + lastDMGAmount
GetDTPS(self)
else
self.text:SetFormattedText('No Instance')
end
elseif event == UNIT_PET then
petID = UnitGUID("pet")
end
end
local function OnClick(self)
Reset()
local inInstance, instanceType = IsInInstance()
if not inInstance and (instanceType == 'none' or instanceType == 'pvp' or instanceType == 'arena') then
self.text:SetFormattedText('No Instance')
else
GetDTPS(self)
end
end
local function OnEnter(self)
DT:SetupTooltip(self)
GameTooltip:AddDoubleLine('"Raid Damage Taken:')
GameTooltip:AddDoubleLine(' ')
GameTooltip:AddDoubleLine(tostring("Max Single: ".._hex..comma_value(max_single_dmg)..max_who.."|r"))
GameTooltip:AddDoubleLine('|rMax Raid DTPS: '.._hex..comma_value(max_rdtps) )
GameTooltip:Show()
end
local function ValueColorUpdate(hex, r, g, b)
_hex = hex
displayString = string.join("", "%s", hex, "%s|r", hex)
if lastPanel ~= nil then
OnEvent(lastPanel)
end
end
E['valueColorUpdateFuncs'][ValueColorUpdate] = true;
--[[
DT:RegisterDatatext(name, events, eventFunc, updateFunc, clickFunc, onEnterFunc)
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
]]