mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
remove temp folder structure
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local format = string.format
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local UnitArmor = UnitArmor
|
||||
local UnitLevel = UnitLevel
|
||||
local ARMOR = ARMOR
|
||||
|
||||
local lastPanel
|
||||
local chanceString = "%.2f%%"
|
||||
local displayString = ""
|
||||
local _, effectiveArmor
|
||||
|
||||
local function GetArmorReduction(armor, attackerLevel)
|
||||
local levelModifier = attackerLevel
|
||||
if levelModifier > 59 then
|
||||
levelModifier = levelModifier + (4.5 * (levelModifier - 59))
|
||||
end
|
||||
local temp = 0.1 * armor/(8.5 * levelModifier + 40)
|
||||
temp = temp/(1 + temp)
|
||||
|
||||
if temp > 0.75 then return 75 end
|
||||
if temp < 0 then return 0 end
|
||||
|
||||
return temp*100
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
_, effectiveArmor = UnitArmor("player")
|
||||
|
||||
self.text:SetText(format(displayString, ARMOR, effectiveArmor))
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
DT.tooltip:AddLine(L["Mitigation By Level: "])
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
local playerLevel = UnitLevel("player") + 3
|
||||
for i = 1, 4 do
|
||||
local armorReduction = GetArmorReduction(effectiveArmor, playerLevel)
|
||||
DT.tooltip:AddDoubleLine(playerLevel, format(chanceString, armorReduction), 1, 1, 1)
|
||||
playerLevel = playerLevel - 1
|
||||
end
|
||||
|
||||
local targetLevel = UnitLevel("target")
|
||||
if targetLevel and targetLevel > 0 and (targetLevel > playerLevel + 3 or targetLevel < playerLevel) then
|
||||
local armorReduction = GetArmorReduction(effectiveArmor, targetLevel)
|
||||
DT.tooltip:AddDoubleLine(targetLevel, format(chanceString, armorReduction), 1, 1, 1)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(hex)
|
||||
displayString = join("", "%s: ", 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,66 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local max = math.max
|
||||
local format, join, sub = string.format, string.join, string.sub
|
||||
--WoW API / Variables
|
||||
local UnitAttackPower = UnitAttackPower
|
||||
local UnitRangedAttackPower = UnitRangedAttackPower
|
||||
local ATTACK_POWER_COLON = ATTACK_POWER_COLON
|
||||
local ATTACK_POWER_MAGIC_NUMBER = ATTACK_POWER_MAGIC_NUMBER
|
||||
local MELEE_ATTACK_POWER = MELEE_ATTACK_POWER
|
||||
local MELEE_ATTACK_POWER_TOOLTIP = MELEE_ATTACK_POWER_TOOLTIP
|
||||
local RANGED_ATTACK_POWER = RANGED_ATTACK_POWER
|
||||
local RANGED_ATTACK_POWER_TOOLTIP = RANGED_ATTACK_POWER_TOOLTIP
|
||||
local ATTACK_POWER_TOOLTIP = ATTACK_POWER_TOOLTIP
|
||||
|
||||
local ATTACK_POWER = sub(ATTACK_POWER_COLON, 1, -2)
|
||||
|
||||
local base, posBuff, negBuff, effective, Rbase, RposBuff, RnegBuff, Reffective, pwr
|
||||
local displayNumberString = ""
|
||||
local lastPanel
|
||||
|
||||
local function OnEvent(self)
|
||||
if(E.myclass == "HUNTER") then
|
||||
Rbase, RposBuff, RnegBuff = UnitRangedAttackPower("player")
|
||||
Reffective = Rbase + RposBuff + RnegBuff
|
||||
pwr = Reffective
|
||||
else
|
||||
base, posBuff, negBuff = UnitAttackPower("player")
|
||||
effective = base + posBuff + negBuff
|
||||
pwr = effective
|
||||
end
|
||||
|
||||
self.text:SetText(format(displayNumberString, ATTACK_POWER, pwr))
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if(E.myclass == "HUNTER") then
|
||||
DT.tooltip:AddDoubleLine(RANGED_ATTACK_POWER, pwr, 1, 1, 1)
|
||||
|
||||
local line = format(RANGED_ATTACK_POWER_TOOLTIP, max((pwr), 0) / ATTACK_POWER_MAGIC_NUMBER)
|
||||
|
||||
DT.tooltip:AddLine(line, nil, nil, nil, true)
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(MELEE_ATTACK_POWER, pwr, 1, 1, 1)
|
||||
DT.tooltip:AddLine(format(MELEE_ATTACK_POWER_TOOLTIP, max((base + posBuff + negBuff), 0) / ATTACK_POWER_MAGIC_NUMBER), nil, nil, nil, true)
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
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("Attack Power", {"UNIT_ATTACK_POWER", "UNIT_RANGED_ATTACK_POWER"}, OnEvent, nil, nil, OnEnter, nil, ATTACK_POWER_TOOLTIP)
|
||||
@@ -0,0 +1,124 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local format, join = string.format, string.join
|
||||
local abs = math.abs
|
||||
--WoW API / Variables
|
||||
local GetInventorySlotInfo = GetInventorySlotInfo
|
||||
local GetInventoryItemID = GetInventoryItemID
|
||||
local GetItemInfo = GetItemInfo
|
||||
local UnitLevel = UnitLevel
|
||||
local GetDodgeChance = GetDodgeChance
|
||||
local GetParryChance = GetParryChance
|
||||
local GetBlockChance = GetBlockChance
|
||||
local GetBonusBarOffset = GetBonusBarOffset
|
||||
local BOSS = BOSS
|
||||
local DODGE_CHANCE = DODGE_CHANCE
|
||||
local PARRY_CHANCE = PARRY_CHANCE
|
||||
local BLOCK_CHANCE = BLOCK_CHANCE
|
||||
|
||||
DEFENSE = "Defense";
|
||||
DODGE_CHANCE = "Dodge Chance";
|
||||
PARRY_CHANCE = "Parry Chance";
|
||||
BLOCK_CHANCE = "Block Chance";
|
||||
|
||||
local displayString, lastPanel
|
||||
local targetlv, playerlv
|
||||
local baseMissChance, levelDifference, dodge, parry, block, avoidance, unhittable
|
||||
local chanceString = "%.2f%%"
|
||||
local AVD_DECAY_RATE = 0.2
|
||||
|
||||
local function IsWearingShield()
|
||||
local slotID = GetInventorySlotInfo("SecondaryHandSlot")
|
||||
local itemID = nil
|
||||
|
||||
if itemID then
|
||||
return select(9, GetItemInfo(itemID))
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
targetlv, playerlv = UnitLevel("target"), UnitLevel("player")
|
||||
|
||||
baseMissChance = E.myrace == "NightElf" and 7 or 5
|
||||
if targetlv == -1 then
|
||||
levelDifference = 3
|
||||
elseif targetlv > playerlv then
|
||||
levelDifference = (targetlv - playerlv)
|
||||
elseif targetlv < playerlv and targetlv > 0 then
|
||||
levelDifference = (targetlv - playerlv)
|
||||
else
|
||||
levelDifference = 0
|
||||
end
|
||||
|
||||
if levelDifference >= 0 then
|
||||
dodge = (GetDodgeChance() - levelDifference * AVD_DECAY_RATE)
|
||||
parry = (GetParryChance() - levelDifference * AVD_DECAY_RATE)
|
||||
block = (GetBlockChance() - levelDifference * AVD_DECAY_RATE)
|
||||
baseMissChance = (baseMissChance - levelDifference * AVD_DECAY_RATE)
|
||||
else
|
||||
dodge = (GetDodgeChance() + abs(levelDifference * AVD_DECAY_RATE))
|
||||
parry = (GetParryChance() + abs(levelDifference * AVD_DECAY_RATE))
|
||||
block = (GetBlockChance() + abs(levelDifference * AVD_DECAY_RATE))
|
||||
baseMissChance = (baseMissChance+ abs(levelDifference * AVD_DECAY_RATE))
|
||||
end
|
||||
|
||||
if dodge <= 0 then dodge = 0 end
|
||||
if parry <= 0 then parry = 0 end
|
||||
if block <= 0 then block = 0 end
|
||||
|
||||
if E.myclass == "DRUID" and GetBonusBarOffset() == 3 then
|
||||
parry = 0
|
||||
end
|
||||
|
||||
if IsWearingShield() ~= "INVTYPE_SHIELD" then
|
||||
block = 0
|
||||
end
|
||||
|
||||
avoidance = (dodge + parry + block + baseMissChance)
|
||||
unhittable = avoidance - 102.4
|
||||
|
||||
self.text:SetText(format(displayString, DEFENSE, avoidance))
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
if targetlv > 1 then
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], join("", " (", L["lvl"], " ", targetlv, ")"))
|
||||
elseif targetlv == -1 then
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], join("", " (", BOSS, ")"))
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(L["Avoidance Breakdown"], join("", " (", L["lvl"], " ", playerlv, ")"))
|
||||
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(chanceString, 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("", "%s: ", 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,322 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:NewModule("DataTexts", "AceTimer-3.0", "AceHook-3.0", "AceEvent-3.0");
|
||||
local LDB = LibStub:GetLibrary("LibDataBroker-1.1");
|
||||
local LSM = LibStub("LibSharedMedia-3.0");
|
||||
local TT = E:GetModule("Tooltip");
|
||||
|
||||
local pairs, type, error = pairs, type, error
|
||||
local len = string.len
|
||||
|
||||
local CreateFrame = CreateFrame
|
||||
local InCombatLockdown = InCombatLockdown
|
||||
local IsInInstance = IsInInstance
|
||||
|
||||
function DT:Initialize()
|
||||
E.DataTexts = DT
|
||||
|
||||
self.tooltip = CreateFrame("GameTooltip", "DatatextTooltip", E.UIParent, "GameTooltipTemplate")
|
||||
DatatextTooltipTextLeft1:SetFontObject(GameTooltipText)
|
||||
DatatextTooltipTextRight1:SetFontObject(GameTooltipText)
|
||||
TT:HookScript(self.tooltip, "OnShow", "SetStyle")
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
local hasEnteredWorld = false
|
||||
function DT:PLAYER_ENTERING_WORLD()
|
||||
hasEnteredWorld = true
|
||||
self:LoadDataTexts()
|
||||
end
|
||||
|
||||
local function LoadDataTextsDelayed()
|
||||
E.Delay(0.5, function() DT:LoadDataTexts() end)
|
||||
end
|
||||
|
||||
local hex = "|cffFFFFFF"
|
||||
|
||||
function DT:SetupObjectLDB(name, obj)
|
||||
local curFrame = nil
|
||||
|
||||
local function OnEnter()
|
||||
DT:SetupTooltip(this)
|
||||
if obj.OnTooltipShow then
|
||||
obj.OnTooltipShow(DT.tooltip)
|
||||
end
|
||||
if obj.OnEnter then
|
||||
obj.OnEnter(this)
|
||||
end
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
if obj.OnLeave then
|
||||
obj.OnLeave(this)
|
||||
end
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
local function OnClick(self, button)
|
||||
if obj.OnClick then
|
||||
obj.OnClick(self, button)
|
||||
end
|
||||
end
|
||||
|
||||
local function textUpdate(_, name, _, value)
|
||||
if value == nil or (len(value) >= 3) or value == "n/a" or name == value then
|
||||
curFrame.text:SetText(value ~= "n/a" and value or name)
|
||||
else
|
||||
curFrame.text:SetText(format("%s: %s%s|r", name, hex, value))
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self)
|
||||
curFrame = self
|
||||
LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..name.."_text", textUpdate)
|
||||
LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..name.."_value", textUpdate)
|
||||
LDB.callbacks:Fire("LibDataBroker_AttributeChanged_"..name.."_text", name, nil, obj.text, obj)
|
||||
end
|
||||
|
||||
DT:RegisterDatatext(name, {"PLAYER_ENTER_WORLD"}, OnEvent, nil, OnClick, OnEnter, OnLeave)
|
||||
|
||||
if DT.PanelLayoutOptions then
|
||||
DT:PanelLayoutOptions()
|
||||
end
|
||||
|
||||
if hasEnteredWorld then
|
||||
LoadDataTextsDelayed()
|
||||
end
|
||||
end
|
||||
|
||||
function DT:RegisterLDB()
|
||||
for name, obj in LDB:DataObjectIterator() do
|
||||
self:SetupObjectLDB(name, obj)
|
||||
end
|
||||
end
|
||||
|
||||
local function ValueColorUpdate(newHex)
|
||||
hex = newHex
|
||||
end
|
||||
E["valueColorUpdateFuncs"][ValueColorUpdate] = true
|
||||
|
||||
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]:SetWidth(width)
|
||||
panel.dataPanels[pointIndex]:SetHeight(height)
|
||||
panel.dataPanels[pointIndex]:SetPoint(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", panel:GetName().."DataText"..i, panel)
|
||||
panel.dataPanels[pointIndex]:RegisterForClicks("LeftButtonUp", "RightButtonUp")
|
||||
panel.dataPanels[pointIndex].text = panel.dataPanels[pointIndex]:CreateFontString(nil, "OVERLAY")
|
||||
panel.dataPanels[pointIndex].text:SetAllPoints()
|
||||
E:FontTemplate(panel.dataPanels[pointIndex].text)
|
||||
panel.dataPanels[pointIndex].text:SetJustifyH("CENTER")
|
||||
panel.dataPanels[pointIndex].text:SetJustifyV("MIDDLE")
|
||||
end
|
||||
|
||||
panel.dataPanels[pointIndex]:SetPoint(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
|
||||
-- random error 132
|
||||
if event == "PLAYER_ENTERING_WORLD" then
|
||||
event = "PLAYER_LOGIN"
|
||||
end
|
||||
panel:RegisterEvent(event)
|
||||
end
|
||||
end
|
||||
|
||||
if data["eventFunc"] then
|
||||
panel:SetScript("OnEvent", function()
|
||||
data["eventFunc"](this, event)
|
||||
end)
|
||||
data["eventFunc"](panel, "ELVUI_FORCE_RUN")
|
||||
end
|
||||
|
||||
if data["onUpdate"] then
|
||||
panel:SetScript("OnUpdate", function()
|
||||
data["onUpdate"](this, arg1)
|
||||
end)
|
||||
data["onUpdate"](panel, 20000)
|
||||
end
|
||||
|
||||
if data["onClick"] then
|
||||
panel:SetScript("OnClick", function()
|
||||
data["onClick"](this, arg1)
|
||||
end)
|
||||
end
|
||||
|
||||
if data["onEnter"] then
|
||||
panel:SetScript("OnEnter", function()
|
||||
data["onEnter"](this)
|
||||
end)
|
||||
end
|
||||
|
||||
if data["onLeave"] then
|
||||
panel:SetScript("OnLeave", function()
|
||||
data["onLeave"](this)
|
||||
end)
|
||||
else
|
||||
panel:SetScript("OnLeave", DT.Data_OnLeave)
|
||||
end
|
||||
end
|
||||
|
||||
function DT:LoadDataTexts()
|
||||
self.db = E.db.datatexts
|
||||
LDB:UnregisterAllCallbacks(self)
|
||||
|
||||
local inInstance, instanceType = IsInInstance()
|
||||
local fontTemplate = LSM:Fetch("font", self.db.font)
|
||||
for panelName, panel in pairs(DT.RegisteredPanels) do
|
||||
for i = 1, panel.numPoints do
|
||||
local 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)
|
||||
E:FontTemplate(panel.dataPanels[pointIndex].text, fontTemplate, self.db.fontSize, self.db.fontOutline)
|
||||
panel.dataPanels[pointIndex].text:SetText(nil)
|
||||
panel.dataPanels[pointIndex].pointIndex = pointIndex
|
||||
|
||||
if (panelName == "LeftChatDataPanel" or panelName == "RightChatDataPanel") and (inInstance and (instanceType == "pvp")) and not DT.ForceHideBGStats and E.db.datatexts.battleground then
|
||||
panel.dataPanels[pointIndex]:RegisterEvent("UPDATE_BATTLEFIELD_SCORE")
|
||||
panel.dataPanels[pointIndex]:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
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
|
||||
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
|
||||
|
||||
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,102 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local _G = _G
|
||||
local pairs = pairs
|
||||
local format, join, upper = string.format, string.join, string.upper
|
||||
--WoW API / Variables
|
||||
local GetInventoryItemDurability = GetInventoryItemDurability
|
||||
local GetInventoryItemTexture = GetInventoryItemTexture
|
||||
local GetInventorySlotInfo = GetInventorySlotInfo
|
||||
local ToggleCharacter = ToggleCharacter
|
||||
local DURABILITY_TEMPLATE = string.gsub(DURABILITY_TEMPLATE, "%%d / %%d", "(%%d+) / (%%d+)")
|
||||
|
||||
local DURABILITY = "Durability" -- Neel ElvUI locale
|
||||
|
||||
local displayString = ""
|
||||
local tooltipString = "%d%%"
|
||||
local totalDurability = 0
|
||||
local current, max, lastPanel
|
||||
local invDurability = {}
|
||||
local slots = {
|
||||
"RangedSlot",
|
||||
"SecondaryHandSlot",
|
||||
"MainHandSlot",
|
||||
"FeetSlot",
|
||||
"LegsSlot",
|
||||
"HandsSlot",
|
||||
"WristSlot",
|
||||
"WaistSlot",
|
||||
"ChestSlot",
|
||||
"ShoulderSlot",
|
||||
"HeadSlot"
|
||||
}
|
||||
|
||||
local scan
|
||||
local function GetInventoryItemDurability(slot)
|
||||
if not GetInventoryItemTexture("player", slot) then return nil, nil end
|
||||
|
||||
if not scan then
|
||||
scan = CreateFrame("GameTooltip", "DurabilityScan", nil, "ShoppingTooltipTemplate")
|
||||
scan:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
end
|
||||
|
||||
scan:ClearLines()
|
||||
scan:SetInventoryItem("player", slot)
|
||||
|
||||
for i = 4, scan:NumLines() do
|
||||
local text = _G[scan:GetName().."TextLeft"..i]:GetText()
|
||||
for durability, max in string.gfind(text, DURABILITY_TEMPLATE) do
|
||||
return tonumber(durability), tonumber(max)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEvent(self, t)
|
||||
lastPanel = self
|
||||
totalDurability = 100
|
||||
|
||||
for _, value in pairs(slots) do
|
||||
local slot = GetInventorySlotInfo(value)
|
||||
current, max = GetInventoryItemDurability(slot)
|
||||
|
||||
if current then
|
||||
current, max = GetInventoryItemDurability(slot)
|
||||
|
||||
invDurability[value] = (current / max) * 100
|
||||
|
||||
if ((current / max) * 100) < totalDurability then
|
||||
totalDurability = (current / max) * 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.text:SetText(format(displayString, totalDurability))
|
||||
end
|
||||
|
||||
local function OnClick()
|
||||
ToggleCharacter("PaperDollFrame")
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
for slot, durability in pairs(invDurability) do
|
||||
DT.tooltip:AddDoubleLine(_G[upper(slot)], format(tooltipString, durability), 1, 1, 1, E:ColorGradient(durability * 0.01, 1, 0, 0, 1, 1, 0, 0, 1, 0))
|
||||
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_ALERTS", "MERCHANT_SHOW"}, OnEvent, nil, OnClick, OnEnter, nil, DURABILITY)
|
||||
@@ -0,0 +1,200 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local type, pairs = type, pairs
|
||||
local sort, wipe = table.sort, wipe
|
||||
local format, find, join, gsub = string.format, string.find, string.join, string.gsub
|
||||
--WoW API / Variables
|
||||
local UnitIsAFK = UnitIsAFK
|
||||
local UnitIsDND = UnitIsDND
|
||||
local SendChatMessage = SendChatMessage
|
||||
local InviteUnit = InviteUnit
|
||||
local SetItemRef = SetItemRef
|
||||
local GetFriendInfo = GetFriendInfo
|
||||
local GetNumFriends = GetNumFriends
|
||||
local GetQuestDifficultyColor = GetQuestDifficultyColor
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||
local L_EasyMenu = L_EasyMenu
|
||||
local AFK = AFK
|
||||
local DND = DND
|
||||
local LOCALIZED_CLASS_NAMES_MALE = LOCALIZED_CLASS_NAMES_MALE
|
||||
local LOCALIZED_CLASS_NAMES_FEMALE = LOCALIZED_CLASS_NAMES_FEMALE
|
||||
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
|
||||
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
||||
|
||||
local function GetNumberFriends()
|
||||
local numFriends = GetNumFriends()
|
||||
local onlineFriends = 0
|
||||
local _, online
|
||||
|
||||
for i = 1, numFriends do
|
||||
_, _, _, _, online = GetFriendInfo(i)
|
||||
|
||||
if online then
|
||||
onlineFriends = onlineFriends + 1
|
||||
end
|
||||
end
|
||||
|
||||
return numFriends, onlineFriends
|
||||
end
|
||||
|
||||
local menuFrame = CreateFrame("Frame", "FriendDatatextRightClickMenu", E.UIParent, "L_UIDropDownMenuTemplate")
|
||||
local menuList = {
|
||||
{text = OPTIONS_MENU, isTitle = true, notCheckable = true},
|
||||
{text = INVITE, hasArrow = true, notCheckable = true},
|
||||
{text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable = true},
|
||||
{text = PLAYER_STATUS, hasArrow = true, notCheckable = true,
|
||||
menuList = {
|
||||
{text = "|cff2BC226" .. AVAILABLE .. "|r", notCheckable = true, func = function() end},
|
||||
{text = "|cffE7E716" .. CHAT_MSG_AFK .. "|r", notCheckable = true, func = function() end},
|
||||
{text = "|cffFF0000" .. CHAT_MSG_DND .. "|r", notCheckable = true, func = function() end}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local function inviteClick(name)
|
||||
menuFrame:Hide()
|
||||
|
||||
if(type(name) ~= "number") then
|
||||
InviteUnit(name)
|
||||
end
|
||||
end
|
||||
|
||||
local function whisperClick(name)
|
||||
menuFrame:Hide()
|
||||
|
||||
SetItemRef("player:" .. name, format("|Hplayer:%1$s|h[%1$s]|h", name), "LeftButton")
|
||||
end
|
||||
|
||||
local lastPanel
|
||||
local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r"
|
||||
local levelNameClassString = "|cff%02x%02x%02x%d|r %s%s"
|
||||
local worldOfWarcraftString = WORLD_OF_WARCRAFT
|
||||
local totalOnlineString = join("", GUILD_ONLINE_LABEL, ": %s/%s")
|
||||
local tthead = {r = 0.4, g = 0.78, b = 1}
|
||||
local activezone, inactivezone = {r = 0.3, g = 1.0, b = 0.3}, {r = 0.65, g = 0.65, b = 0.65}
|
||||
local displayString = ""
|
||||
local groupedTable = {"|cffaaaaaa*|r", ""}
|
||||
local friendTable = {}
|
||||
local friendOnline, friendOffline = gsub(ERR_FRIEND_ONLINE_SS, "\124Hplayer:%%s\124h%[%%s%]\124h", ""), gsub(ERR_FRIEND_OFFLINE_S, "%%s", "")
|
||||
local dataValid = false
|
||||
|
||||
local function SortAlphabeticName(a, b)
|
||||
if(a[1] and b[1]) then
|
||||
return a[1] < b[1]
|
||||
end
|
||||
end
|
||||
|
||||
local function BuildFriendTable(total)
|
||||
wipe(friendTable)
|
||||
local name, level, class, area, connected, status, note
|
||||
for i = 1, total do
|
||||
name, level, class, area, connected, status, note = GetFriendInfo(i)
|
||||
|
||||
if status == CHAT_FLAG_AFK then
|
||||
status = "|cffFFFFFF[|r|cffFF0000" .. L["AFK"] .. "|r|cffFFFFFF]|r"
|
||||
elseif status == CHAT_FLAG_DND then
|
||||
status = "|cffFFFFFF[|r|cffFF0000" .. L["DND"] .. "|r|cffFFFFFF]|r"
|
||||
end
|
||||
|
||||
if(connected) then
|
||||
for k, v in pairs(LOCALIZED_CLASS_NAMES_MALE) do if(class == v) then class = k end end
|
||||
for k, v in pairs(LOCALIZED_CLASS_NAMES_FEMALE) do if(class == v) then class = k end end
|
||||
friendTable[i] = {name, level, class, area, connected, status, note}
|
||||
end
|
||||
end
|
||||
sort(friendTable, SortAlphabeticName)
|
||||
end
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
local _, onlineFriends = GetNumberFriends()
|
||||
|
||||
if event == "CHAT_MSG_SYSTEM" then
|
||||
local message = arg1
|
||||
if not (find(message, friendOnline) or find(message, friendOffline)) then return end
|
||||
end
|
||||
dataValid = false
|
||||
|
||||
self.text:SetText(format(displayString, L["Friends"], onlineFriends))
|
||||
|
||||
lastPanel = self
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
DT.tooltip:Hide()
|
||||
|
||||
if btn == "RightButton" then
|
||||
local menuCountWhispers = 0
|
||||
local menuCountInvites = 0
|
||||
local classc, levelc, info
|
||||
|
||||
menuList[2].menuList = {}
|
||||
menuList[3].menuList = {}
|
||||
|
||||
if getn(friendTable) > 0 then
|
||||
for i = 1, getn(friendTable) do
|
||||
info = friendTable[i]
|
||||
if (info[5]) then
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
|
||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[3]], GetQuestDifficultyColor(info[2])
|
||||
classc = classc or GetQuestDifficultyColor(info[2])
|
||||
|
||||
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[2],classc.r*255,classc.g*255,classc.b*255, info[1]), arg1 = info[1], notCheckable = true, func = inviteClick}
|
||||
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[2],classc.r*255,classc.g*255,classc.b*255, info[1]), arg1 = info[1], notCheckable = true, func = whisperClick}
|
||||
end
|
||||
end
|
||||
end
|
||||
L_EasyMenu(menuList, menuFrame, "cursor", 0, 0, "MENU", 2)
|
||||
else
|
||||
ToggleFriendsFrame(1)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local numberOfFriends, onlineFriends = GetNumberFriends()
|
||||
if onlineFriends == 0 then return end
|
||||
|
||||
if not dataValid then
|
||||
if numberOfFriends > 0 then BuildFriendTable(numberOfFriends) end
|
||||
dataValid = true
|
||||
end
|
||||
|
||||
local zonec, classc, levelc, info
|
||||
DT.tooltip:AddDoubleLine(L["Friends List"], format(totalOnlineString, onlineFriends, numberOfFriends), tthead.r, tthead.g, tthead.b, tthead.r, tthead.g, tthead.b)
|
||||
if onlineFriends > 0 then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(worldOfWarcraftString)
|
||||
for i = 1, getn(friendTable) do
|
||||
info = friendTable[i]
|
||||
if info[5] then
|
||||
if(GetRealZoneText() == info[4]) then zonec = activezone else zonec = inactivezone end
|
||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[3]], GetQuestDifficultyColor(info[2])
|
||||
|
||||
classc = classc or GetQuestDifficultyColor(info[2])
|
||||
|
||||
DT.tooltip:AddDoubleLine(format(levelNameClassString, levelc.r*255,levelc.g*255,levelc.b*255, info[2], info[1], " " .. 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 ValueColorUpdate(hex)
|
||||
displayString = join("", "%s: ", hex, "%d|r")
|
||||
|
||||
if lastPanel ~= nil then
|
||||
OnEvent(lastPanel, "ELVUI_COLOR_UPDATE")
|
||||
end
|
||||
end
|
||||
E["valueColorUpdateFuncs"][ValueColorUpdate] = true
|
||||
|
||||
DT:RegisterDatatext("Friends", {"PLAYER_LOGIN", "FRIENDLIST_UPDATE", "CHAT_MSG_SYSTEM"}, OnEvent, nil, OnClick, OnEnter, nil, L["Friends"])
|
||||
@@ -0,0 +1,81 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local pairs = pairs
|
||||
local join = string.join
|
||||
--WoW API / Variables
|
||||
local GetMoney = GetMoney
|
||||
local IsShiftKeyDown = IsShiftKeyDown
|
||||
|
||||
local Profit = 0
|
||||
local Spent = 0
|
||||
local resetInfoFormatter = join("", "|cffaaaaaa", L["Reset Data: Hold Shift + Right Click"], "|r")
|
||||
|
||||
local function OnEvent(self)
|
||||
local NewMoney = GetMoney()
|
||||
ElvDB = ElvDB or {}
|
||||
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 NewMoney
|
||||
|
||||
local OldMoney = ElvDB["gold"][E.myrealm][E.myname] or NewMoney
|
||||
|
||||
local Change = NewMoney - OldMoney
|
||||
if OldMoney > NewMoney then
|
||||
Spent = Spent - Change
|
||||
else
|
||||
Profit = Profit + Change
|
||||
end
|
||||
|
||||
self.text:SetText(E:FormatMoney(NewMoney, E.db.datatexts.goldFormat or "BLIZZARD"))
|
||||
|
||||
ElvDB["gold"][E.myrealm][E.myname] = NewMoney
|
||||
end
|
||||
|
||||
local function OnClick(self, btn)
|
||||
if btn == "RightButton" and IsShiftKeyDown() then
|
||||
ElvDB.gold = nil
|
||||
OnEvent(self)
|
||||
DT.tooltip:Hide()
|
||||
else
|
||||
OpenAllBags()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
local style = E.db.datatexts.goldFormat or "BLIZZARD"
|
||||
|
||||
DT.tooltip:AddLine(L["Session:"])
|
||||
DT.tooltip:AddDoubleLine(L["Earned:"], E:FormatMoney(Profit, style), 1, 1, 1, 1, 1, 1)
|
||||
DT.tooltip:AddDoubleLine(L["Spent:"], E:FormatMoney(Spent, style), 1, 1, 1, 1, 1, 1)
|
||||
if Profit < Spent then
|
||||
DT.tooltip:AddDoubleLine(L["Deficit:"], E:FormatMoney(Profit-Spent, style), 1, 0, 0, 1, 1, 1)
|
||||
elseif (Profit - Spent) > 0 then
|
||||
DT.tooltip:AddDoubleLine(L["Profit:"], E:FormatMoney(Profit-Spent, style), 0, 1, 0, 1, 1, 1)
|
||||
end
|
||||
DT.tooltip:AddLine(" ")
|
||||
|
||||
local totalGold = 0;
|
||||
DT.tooltip:AddLine(L["Character: "])
|
||||
|
||||
for k, _ in pairs(ElvDB["gold"][E.myrealm]) do
|
||||
if ElvDB["gold"][E.myrealm][k] then
|
||||
DT.tooltip:AddDoubleLine(k, E:FormatMoney(ElvDB["gold"][E.myrealm][k], style), 1, 1, 1, 1, 1, 1)
|
||||
totalGold = totalGold + ElvDB["gold"][E.myrealm][k]
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(L["Server: "])
|
||||
DT.tooltip:AddDoubleLine(L["Total: "], E:FormatMoney(totalGold, style), 1, 1, 1, 1, 1, 1)
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(resetInfoFormatter)
|
||||
|
||||
DT.tooltip:Show()
|
||||
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,243 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local unpack = unpack
|
||||
local format, join = string.format, string.join
|
||||
local sort, wipe = table.sort, 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 LoadAddOn = LoadAddOn
|
||||
local SetItemRef = SetItemRef
|
||||
local ToggleFriendsFrame = ToggleFriendsFrame
|
||||
local UnitInParty = UnitInParty
|
||||
local UnitInRaid = UnitInRaid
|
||||
local CUSTOM_CLASS_COLORS = CUSTOM_CLASS_COLORS
|
||||
local RAID_CLASS_COLORS = RAID_CLASS_COLORS
|
||||
local MOTD_COLON = MOTD_COLON
|
||||
|
||||
local FRIENDS_LIST_ONLINE = "FRIENDS_LIST_ONLINE"
|
||||
|
||||
local tthead, ttsubh, ttoff = {r=0.4, g=0.78, b=1}, {r=0.75, g=0.9, b=1}, {r=.3,g=1,b=.3}
|
||||
local activezone, inactivezone = {r=0.3, g=1.0, b=0.3}, {r=0.65, g=0.65, b=0.65}
|
||||
local displayString = ""
|
||||
local noGuildString = ""
|
||||
local guildInfoString = "%s"
|
||||
local guildInfoString2 = join("", GUILD, ": %d/%d")
|
||||
local guildMotDString = "%s |cffaaaaaa |cffffffff%s"
|
||||
local levelNameString = "|cff%02x%02x%02x%d|r |cff%02x%02x%02x%s|r %s"
|
||||
local levelNameStatusString = "|cff%02x%02x%02x%d|r %s "
|
||||
local nameRankString = "%s |cff999999-|cffffffff %s"
|
||||
local moreMembersOnlineString = join("", "+ %d ", FRIENDS_LIST_ONLINE, "...")
|
||||
local noteString = join("", "|cff999999 ", LABEL_NOTE, ":|r %s")
|
||||
local officerNoteString = join("", "|cff999999 ", GUILD_RANK1_DESC, ":|r %s")
|
||||
local guildTable, guildMotD = {}, ""
|
||||
local lastPanel
|
||||
|
||||
local function SortGuildTable(shift)
|
||||
sort(guildTable, function(a, b)
|
||||
if a and b then
|
||||
if shift then
|
||||
return a[9] < b[9]
|
||||
else
|
||||
return a[1] < b[1]
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function BuildGuildTable()
|
||||
wipe(guildTable)
|
||||
local _, name, rank, level, zone, note, officernote, connected, status, class
|
||||
|
||||
local totalMembers = GetNumGuildMembers()
|
||||
for i = 1, totalMembers do
|
||||
name, rank, _, level, class, zone, note, officernote, connected, status = GetGuildRosterInfo(i)
|
||||
|
||||
if connected then
|
||||
guildTable[getn(guildTable) + 1] = {name, rank, level, zone, note, officernote, connected, status, string.upper(class)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function UpdateGuildMessage()
|
||||
guildMotD = GetGuildRosterMOTD()
|
||||
end
|
||||
|
||||
local eventHandlers = {
|
||||
["CHAT_MSG_SYSTEM"] = function()
|
||||
GuildRoster()
|
||||
end,
|
||||
-- when we enter the world and guildframe is not available then
|
||||
-- load guild frame, update guild message and guild xp
|
||||
["PLAYER_ENTERING_WORLD"] = function()
|
||||
if IsInGuild() then
|
||||
GuildRoster()
|
||||
end
|
||||
end,
|
||||
-- Guild Roster updated, so rebuild the guild table
|
||||
["GUILD_ROSTER_UPDATE"] = function(self)
|
||||
GuildRoster()
|
||||
BuildGuildTable()
|
||||
UpdateGuildMessage()
|
||||
if GetMouseFocus() == self then
|
||||
self:GetScript("OnEnter")(self, nil, true)
|
||||
end
|
||||
end,
|
||||
["PLAYER_GUILD_UPDATE"] = function()
|
||||
GuildRoster()
|
||||
end,
|
||||
-- our guild message of the day changed
|
||||
["GUILD_MOTD"] = function(_, arg1)
|
||||
guildMotD = arg1
|
||||
end,
|
||||
["ELVUI_FORCE_RUN"] = E.noop,
|
||||
["ELVUI_COLOR_UPDATE"] = E.noop,
|
||||
}
|
||||
|
||||
local function OnEvent(self, event, ...)
|
||||
lastPanel = self
|
||||
|
||||
if IsInGuild() then
|
||||
eventHandlers[event](self, unpack(arg))
|
||||
self.text:SetText(format(displayString, getn(guildTable)))
|
||||
else
|
||||
self.text:SetText(noGuildString)
|
||||
end
|
||||
end
|
||||
|
||||
local menuFrame = CreateFrame("Frame", "GuildDatatTextRightClickMenu", E.UIParent, "L_UIDropDownMenuTemplate")
|
||||
local menuList = {
|
||||
{ text = OPTIONS_MENU, isTitle = true, notCheckable = true},
|
||||
{ text = INVITE, hasArrow = true, notCheckable = true,},
|
||||
{ text = CHAT_MSG_WHISPER_INFORM, hasArrow = true, notCheckable=true,}
|
||||
}
|
||||
|
||||
local function inviteClick(_, playerName)
|
||||
menuFrame:Hide()
|
||||
InviteUnit(playerName)
|
||||
end
|
||||
|
||||
local function whisperClick(_, playerName)
|
||||
menuFrame:Hide()
|
||||
SetItemRef("player:"..playerName, ("|Hplayer:%1$s|h[%1$s]|h"):format(playerName), "LeftButton")
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
if btn == "RightButton" and IsInGuild() then
|
||||
DT.tooltip:Hide()
|
||||
|
||||
local classc, levelc, grouped, info
|
||||
local menuCountWhispers = 0
|
||||
local menuCountInvites = 0
|
||||
|
||||
menuList[2].menuList = {}
|
||||
menuList[3].menuList = {}
|
||||
|
||||
for i = 1, getn(guildTable) do
|
||||
info = guildTable[i]
|
||||
if info[7] and info[1] ~= E.myname then
|
||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[9]], GetQuestDifficultyColor(info[3])
|
||||
--if UnitInParty(info[1]) or UnitInRaid(info[1]) then
|
||||
-- grouped = "|cffaaaaaa*|r"
|
||||
--elseif not info[11] then
|
||||
menuCountInvites = menuCountInvites + 1
|
||||
grouped = ""
|
||||
menuList[2].menuList[menuCountInvites] = {text = format(levelNameString, levelc.r*255,levelc.g*255,levelc.b*255, info[3], classc.r*255,classc.g*255,classc.b*255, info[1], ""), arg1 = info[1],notCheckable=true, func = inviteClick}
|
||||
--end
|
||||
menuCountWhispers = menuCountWhispers + 1
|
||||
if not grouped then grouped = "" end
|
||||
menuList[3].menuList[menuCountWhispers] = {text = format(levelNameString, 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
|
||||
|
||||
L_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)
|
||||
|
||||
local online, total = 0, GetNumGuildMembers(true)
|
||||
for i = 0, total do
|
||||
local _, _, _, _, _, _, _, _, _, status = GetGuildRosterInfo(i)
|
||||
if status then
|
||||
online = online + 1
|
||||
end
|
||||
end
|
||||
if getn(guildTable) == 0 then BuildGuildTable() end
|
||||
|
||||
SortGuildTable(IsShiftKeyDown())
|
||||
|
||||
local guildName, guildRank = GetGuildInfo("player")
|
||||
|
||||
if guildName and guildRank then
|
||||
DT.tooltip:AddDoubleLine(format(guildInfoString, guildName), format(guildInfoString2, online, total),tthead.r,tthead.g,tthead.b,tthead.r,tthead.g,tthead.b)
|
||||
DT.tooltip:AddLine(guildRank, unpack(tthead))
|
||||
end
|
||||
|
||||
if guildMotD ~= "" then
|
||||
DT.tooltip:AddLine(" ")
|
||||
DT.tooltip:AddLine(format(guildMotDString, GUILD_MOTD_LABEL, guildMotD), ttsubh.r, ttsubh.g, ttsubh.b, 1)
|
||||
end
|
||||
|
||||
local zonec, classc, levelc, info
|
||||
local shown = 0
|
||||
|
||||
DT.tooltip:AddLine(" ")
|
||||
for i = 1, getn(guildTable) do
|
||||
-- if more then 30 guild members are online, we don't Show any more, but inform user there are more
|
||||
if 30 - shown <= 1 then
|
||||
if online - 30 > 1 then DT.tooltip:AddLine(format(moreMembersOnlineString, online - 30), ttsubh.r, ttsubh.g, ttsubh.b) end
|
||||
break
|
||||
end
|
||||
|
||||
info = guildTable[i]
|
||||
if GetRealZoneText() == info[4] then zonec = activezone else zonec = inactivezone end
|
||||
|
||||
classc, levelc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[info[9]], GetQuestDifficultyColor(info[3])
|
||||
|
||||
if IsShiftKeyDown() then
|
||||
DT.tooltip:AddDoubleLine(format(nameRankString, 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(noteString, info[5]), ttsubh.r, ttsubh.g, ttsubh.b, 1) end
|
||||
if info[6] ~= "" then DT.tooltip:AddLine(format(officerNoteString, info[6]), ttoff.r, ttoff.g, ttoff.b, 1) end
|
||||
else
|
||||
DT.tooltip:AddDoubleLine(format(levelNameStatusString, levelc.r*255, levelc.g*255, levelc.b*255, info[3], info[1], info[4]), info[4], classc.r,classc.g,classc.b, zonec.r,zonec.g,zonec.b)
|
||||
end
|
||||
shown = shown + 1
|
||||
end
|
||||
|
||||
DT.tooltip:Show()
|
||||
|
||||
if not noUpdate then
|
||||
GuildRoster()
|
||||
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", {"PLAYER_ENTERING_WORLD", "CHAT_MSG_SYSTEM", "GUILD_ROSTER_UPDATE", "PLAYER_GUILD_UPDATE", "GUILD_MOTD"}, OnEvent, nil, OnClick, OnEnter, nil, GUILD)
|
||||
@@ -0,0 +1,12 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="DataTexts.lua"/>
|
||||
<Script file="Armor.lua"/>
|
||||
<Script file="AttackPower.lua"/>
|
||||
<Script file="Avoidance.lua"/>
|
||||
<Script file="Durability.lua"/>
|
||||
<Script file="Friends.lua"/>
|
||||
<Script file="Gold.lua"/>
|
||||
<Script file="Guild.lua"/>
|
||||
<Script file="System.lua"/>
|
||||
<Script file="Time.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,92 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local collectgarbage = collectgarbage
|
||||
local floor = math.floor
|
||||
local format = string.format
|
||||
local gcinfo = gcinfo
|
||||
--WoW API / Variables
|
||||
local GetNetStats = GetNetStats
|
||||
local GetFramerate = GetFramerate
|
||||
|
||||
local int = 6
|
||||
local statusColors = {
|
||||
"|cff0CD809",
|
||||
"|cffE8DA0F",
|
||||
"|cffFF9000",
|
||||
"|cffD80909"
|
||||
}
|
||||
|
||||
local enteredFrame = false
|
||||
local homeLatencyString = "%d ms"
|
||||
local kiloByteString = "%d kb"
|
||||
local megaByteString = "%.2f mb"
|
||||
|
||||
local function formatMem(memory)
|
||||
local mult = 10 ^ 1
|
||||
if(memory > 999) then
|
||||
local mem = ((memory / 1024) * mult) / mult
|
||||
return format(megaByteString, mem)
|
||||
else
|
||||
local mem = (memory * mult) / mult
|
||||
return format(kiloByteString, mem)
|
||||
end
|
||||
end
|
||||
|
||||
local function ToggleGameMenuFrame()
|
||||
if GameMenuFrame:IsShown() then
|
||||
PlaySound("igMainMenuQuit")
|
||||
HideUIPanel(GameMenuFrame)
|
||||
else
|
||||
PlaySound("igMainMenuOpen")
|
||||
ShowUIPanel(GameMenuFrame)
|
||||
end
|
||||
end
|
||||
|
||||
local function OnClick(_, btn)
|
||||
if btn == "RightButton" then
|
||||
collectgarbage()
|
||||
elseif btn == "LeftButton" then
|
||||
ToggleGameMenuFrame()
|
||||
end
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
enteredFrame = true
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local totalMemory = gcinfo()
|
||||
local _, _, latency = GetNetStats()
|
||||
DT.tooltip:AddDoubleLine(L["Home Latency:"], format(homeLatencyString, latency), 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)
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local function OnLeave()
|
||||
enteredFrame = false
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
local function OnUpdate(self, t)
|
||||
int = int - t
|
||||
|
||||
if int < 0 then
|
||||
local framerate = floor(GetFramerate())
|
||||
local _, _, latency = GetNetStats()
|
||||
|
||||
self.text:SetText(format("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[latency < 150 and 1 or (latency >= 150 and latency < 300) and 2 or (latency >= 300 and latency < 500) and 3 or 4],
|
||||
latency))
|
||||
int = 1
|
||||
if enteredFrame then
|
||||
OnEnter(this)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DT:RegisterDatatext("System", nil, nil, OnUpdate, OnClick, OnEnter, OnLeave, L["System"])
|
||||
@@ -0,0 +1,77 @@
|
||||
local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
|
||||
local DT = E:GetModule("DataTexts");
|
||||
|
||||
--Cache global variables
|
||||
--Lua functions
|
||||
local time = time
|
||||
local format, join = string.format, string.join
|
||||
--WoW API / Variables
|
||||
local GetGameTime = GetGameTime
|
||||
local GetNumSavedInstances = GetNumSavedInstances
|
||||
local GetSavedInstanceInfo = GetSavedInstanceInfo
|
||||
local SecondsToTime = SecondsToTime
|
||||
local TIMEMANAGER_TOOLTIP_REALMTIME = "Realm time:"
|
||||
|
||||
local timeDisplayFormat = ""
|
||||
local dateDisplayFormat = ""
|
||||
local europeDisplayFormat_nocolor = join("", "%02d", ":|r%02d")
|
||||
local lockoutInfoFormatNoEnc = "%s%s |cffaaaaaa(%s)"
|
||||
local difficultyInfo = {"N", "N", "H", "H"}
|
||||
local lockoutColorExtended, lockoutColorNormal = {r = 0.3, g = 1, b = 0.3}, {r = .8, g = .8, b = .8}
|
||||
|
||||
local function OnLeave()
|
||||
DT.tooltip:Hide()
|
||||
end
|
||||
|
||||
local function OnEnter(self)
|
||||
DT:SetupTooltip(self)
|
||||
|
||||
local name, _, reset, difficultyId, locked, extended, isRaid, maxPlayers
|
||||
local oneraid, lockoutColor
|
||||
for i = 1, GetNumSavedInstances() do
|
||||
name, _, reset, difficultyId, locked, extended, _, isRaid, maxPlayers = GetSavedInstanceInfo(i)
|
||||
if isRaid and (locked or extended) and name then
|
||||
if not oneraid then
|
||||
DT.tooltip:AddLine(L["Saved Raid(s)"])
|
||||
DT.tooltip:AddLine(" ")
|
||||
oneraid = true
|
||||
end
|
||||
if extended then
|
||||
lockoutColor = lockoutColorExtended
|
||||
else
|
||||
lockoutColor = lockoutColorNormal
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(format(lockoutInfoFormatNoEnc, maxPlayers, difficultyInfo[difficultyId], name), SecondsToTime(reset, false, nil, 3), 1, 1, 1, lockoutColor.r, lockoutColor.g, lockoutColor.b)
|
||||
end
|
||||
end
|
||||
|
||||
DT.tooltip:AddDoubleLine(TIMEMANAGER_TOOLTIP_REALMTIME, format(europeDisplayFormat_nocolor, GetGameTime()), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
|
||||
|
||||
DT.tooltip:Show()
|
||||
end
|
||||
|
||||
local lastPanel
|
||||
local int = 5
|
||||
local function OnUpdate(self, t)
|
||||
int = int - t
|
||||
|
||||
if int > 0 then return end
|
||||
|
||||
self.text:SetText(gsub(gsub(BetterDate(E.db.datatexts.timeFormat.." "..E.db.datatexts.dateFormat, time()), ":", timeDisplayFormat), "%s", dateDisplayFormat))
|
||||
|
||||
lastPanel = self
|
||||
int = 1
|
||||
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", nil, nil, OnUpdate, nil, OnEnter, OnLeave)
|
||||
Reference in New Issue
Block a user