Commit 1aefa0e9 authored by Merathilis's avatar Merathilis

Added own Durability DataText.. needs testing.

parent 935173a4
......@@ -2450,7 +2450,7 @@ function MER:SetupDts()
E.db["datatexts"]["minimapBottom"] = false
E.db["mui"]["datatexts"]["panels"]["ChatTab_Datatext_Panel"].left = "BfA Missions"
E.db["mui"]["datatexts"]["panels"]["ChatTab_Datatext_Panel"].middle = "Durability"
E.db["mui"]["datatexts"]["panels"]["ChatTab_Datatext_Panel"].middle = "MUI Durability"
E.db["mui"]["datatexts"]["panels"]["ChatTab_Datatext_Panel"].right = "Gold"
......
......@@ -194,6 +194,7 @@ L["Middle Datatext Panel"] = "Mittlere Infotextleiste"
L["Right Click"] = "Rechtsklick"
L["Toggle ActionBar"] = "Aktionsleisten ausblenden"
L["Toggle Middle DT"] = "Mittleren Infotext ausblenden"
L["Dura."] = "Haltb."
-- DataBars
L["DataBars"] = "Informationsleisten"
......
......@@ -197,6 +197,7 @@ L["Middle Datatext Panel"] = true
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = true
......
......@@ -196,6 +196,7 @@ L["Middle Datatext Panel"] = true
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = true
......
......@@ -196,6 +196,7 @@ L["Middle Datatext Panel"] = true
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = true
......
......@@ -192,6 +192,7 @@ L["Middle Datatext Panel"] = true
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = true
......
......@@ -194,6 +194,7 @@ L["Middle Datatext Panel"] = true
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = true
......
......@@ -194,6 +194,7 @@ L["Middle Datatext Panel"] = "中间的信息面板"
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = "数据条"
......
......@@ -194,6 +194,7 @@ L["Middle Datatext Panel"] = true
L["Right Click"] = true
L["Toggle ActionBar"] = true
L["Toggle Middle DT"] = true
L["Dura."] = true
-- DataBars
L["DataBars"] = true
......
local MER, E, L, V, P, G = unpack(select(2, ...))
local DT = E:GetModule('DataTexts')
--Lua functions
local _G = _G
local select = select
local format, gsub = string.format, string.gsub
local floor, modf = math.floor, math.modf
local tsort = table.sort
--WoW API / Variables
local CreateFrame = CreateFrame
local GetAverageItemLevel = GetAverageItemLevel
local GetInventoryItemTexture = GetInventoryItemTexture
local GetInventoryItemDurability = GetInventoryItemDurability
local GetInventoryItemLink = GetInventoryItemLink
local GetMoneyString = GetMoneyString
local InCombatLockdown = InCombatLockdown
local ToggleCharacter = ToggleCharacter
local UIParent = UIParent
local DURABILITY = DURABILITY
local NONE = NONE
local REPAIR_COST = REPAIR_COST
local HEADER_COLON = HEADER_COLON
local repairCostString = gsub(REPAIR_COST, HEADER_COLON, ":")
local localSlots = {
[1] = {1, INVTYPE_HEAD, 1000},
[2] = {3, INVTYPE_SHOULDER, 1000},
[3] = {5, INVTYPE_CHEST, 1000},
[4] = {6, INVTYPE_WAIST, 1000},
[5] = {9, INVTYPE_WRIST, 1000},
[6] = {10, INVTYPE_HAND, 1000},
[7] = {7, INVTYPE_LEGS, 1000},
[8] = {8, INVTYPE_FEET, 1000},
[9] = {16, INVTYPE_WEAPONMAINHAND, 1000},
[10] = {17, INVTYPE_WEAPONOFFHAND, 1000}
}
local function sortSlots(a, b)
if a and b then
return (a[3] == b[3] and a[1] < b[1]) or (a[3] < b[3])
end
end
local function getItemDurability()
local numSlots = 0
for i = 1, 10 do
localSlots[i][3] = 1000
local index = localSlots[i][1]
if GetInventoryItemLink("player", index) then
local current, max = GetInventoryItemDurability(index)
if current then
localSlots[i][3] = current/max
numSlots = numSlots + 1
end
end
end
tsort(localSlots, sortSlots)
return numSlots
end
local function gradientColor(perc)
perc = perc > 1 and 1 or perc < 0 and 0 or perc -- Stay between 0-1
local seg, relperc = modf(perc*2)
local r1, g1, b1, r2, g2, b2 = select(seg*3+1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0) -- R -> Y -> G
local r, g, b = r1+(r2-r1)*relperc, g1+(g2-g1)*relperc, b1+(b2-b1)*relperc
return format("|cff%02x%02x%02x", r*255, g*255, b*255), r, g, b
end
local tip = CreateFrame("GameTooltip", "muiDurabilityTooltip")
tip:SetOwner(UIParent, "ANCHOR_NONE")
local function OnEvent(self)
local numSlots = getItemDurability()
if numSlots > 0 then
self.text:SetText(format(gsub(L["Dura."]..": ".."[color]%d|r%%", "%[color%]", (gradientColor(floor(localSlots[1][3]*100)/100))), floor(localSlots[1][3]*100)))
else
self.text:SetText(L["Dura."]..": "..NONE)
end
end
local function Click()
if InCombatLockdown() then _G.UIErrorsFrame:AddMessage(E.InfoColor.._G.ERR_NOT_IN_COMBAT) return end
ToggleCharacter("PaperDollFrame")
end
local function OnEnter(self)
DT:SetupTooltip(self)
local total, equipped = GetAverageItemLevel()
DT.tooltip:ClearLines()
DT.tooltip:AddDoubleLine(DURABILITY, format("%s: %d/%d", _G.STAT_AVERAGE_ITEM_LEVEL, equipped, total), .6, .8, 1, 1, 1, 1)
DT.tooltip:AddLine(" ")
local totalCost = 0
for i = 1, 10 do
if localSlots[i][3] ~= 1000 then
local slot = localSlots[i][1]
local green = localSlots[i][3]*2
local red = 1 - green
local slotIcon = "|T"..GetInventoryItemTexture("player", slot)..":13:15:0:0:50:50:4:46:4:46|t " or ""
DT.tooltip:AddDoubleLine(slotIcon..localSlots[i][2], floor(localSlots[i][3]*100).."%", 1, 1, 1, red+1, green,0)
totalCost = totalCost + select(3, tip:SetInventoryItem("player", slot))
end
end
if totalCost > 0 then
DT.tooltip:AddLine(" ")
DT.tooltip:AddDoubleLine(repairCostString, GetMoneyString(totalCost), .6, .8, 1, 1, 1, 1)
end
DT.tooltip:Show()
end
DT:RegisterDatatext('MUI Durability', {'PLAYER_ENTERING_WORLD', "UPDATE_INVENTORY_DURABILITY", "MERCHANT_SHOW"}, OnEvent, nil, Click, OnEnter, nil, DURABILITY)
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="options.lua"/>
<Script file="durability.lua"/>
<Script file="time.lua"/>
</Ui>
local E, L, V, P, G, _ = unpack(ElvUI); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB, Localize Underscore
local MER, E, L, V, P, G = unpack(select(2, ...))
local DT = E:GetModule('DataTexts')
--All credits belongs to Merathilis for this Time datatext mod
......@@ -98,14 +98,14 @@ local function formatResetTime(sec)
return "N/A"
end
if d > 0 and lockoutFormatString[h>10 and 1 or 2] then
if d > 0 and lockoutFormatString[h>10 and 1 or 2] then
return format(lockoutFormatString[h>10 and 1 or 2], d, h, m)
end
if h > 0 and lockoutFormatString[h>10 and 3 or 4] then
return format(lockoutFormatString[h>10 and 3 or 4], h, m)
end
if m > 0 and lockoutFormatString[m>10 and 5 or 6] then
return format(lockoutFormatString[m>10 and 5 or 6], m)
if m > 0 and lockoutFormatString[m>10 and 5 or 6] then
return format(lockoutFormatString[m>10 and 5 or 6], m)
end
end
......@@ -120,7 +120,7 @@ local function OnEvent(self, event)
end
local function Click()
_G["GameTimeFrame"]:Click();
_G["GameTimeFrame"]:Click()
end
local function OnLeave(self)
......@@ -136,7 +136,7 @@ local function OnEnter(self)
RequestRaidInfo()
end
DT.tooltip:AddLine(VOICE_CHAT_BATTLEGROUND);
DT.tooltip:AddLine(VOICE_CHAT_BATTLEGROUND)
for i = 1, GetNumWorldPVPAreas() do
_, localizedName, isActive, canQueue, startTime, canEnter = GetWorldPVPAreaInfo(i)
if canEnter then
......@@ -160,10 +160,10 @@ local function OnEnter(self)
DT.tooltip:AddLine(L["Saved Raid(s)"])
oneraid = true
end
if extended then
lockoutColor = lockoutColorExtended
if extended then
lockoutColor = lockoutColorExtended
else
lockoutColor = lockoutColorNormal
lockoutColor = lockoutColorNormal
end
local _, _, isHeroic, _, displayHeroic, displayMythic = GetDifficultyInfo(difficultyId)
......@@ -193,7 +193,7 @@ local function OnEnter(self)
DT.tooltip:AddLine(" ")
if AmPm == -1 then
DT.tooltip:AddDoubleLine(E.db.datatexts.localtime and TIMEMANAGER_TOOLTIP_REALMTIME or TIMEMANAGER_TOOLTIP_LOCALTIME,
DT.tooltip:AddDoubleLine(E.db.datatexts.localtime and TIMEMANAGER_TOOLTIP_REALMTIME or TIMEMANAGER_TOOLTIP_LOCALTIME,
format(europeDisplayFormat_nocolor, Hr, Min), 1, 1, 1, lockoutColorNormal.r, lockoutColorNormal.g, lockoutColorNormal.b)
else
DT.tooltip:AddDoubleLine(E.db.datatexts.localtime and TIMEMANAGER_TOOLTIP_REALMTIME or TIMEMANAGER_TOOLTIP_LOCALTIME,
......@@ -226,11 +226,11 @@ local function OnEnter(self)
}
DT.tooltip:AddLine(" ")
local date = C_DateAndTime.GetCurrentCalendarTime();
local presentWeekday = date.weekday;
local presentMonth = date.month;
local presentDay = date.monthDay;
local presentYear = date.year;
local date = C_DateAndTime.GetCurrentCalendarTime()
local presentWeekday = date.weekday
local presentMonth = date.month
local presentDay = date.monthDay
local presentYear = date.year
DT.tooltip:AddLine(format("%s, %s %d, %d", daysAbr[presentWeekday], monthAbr[presentMonth], presentDay, presentYear))
DT.tooltip:Show()
......@@ -276,4 +276,4 @@ function Update(self, t)
int = 5
end
DT:RegisterDatatext("MUI Time", { "QUEST_COMPLETE", "QUEST_LOG_UPDATE" }, OnEvent, Update, Click, OnEnter, OnLeave)
\ No newline at end of file
DT:RegisterDatatext("MUI Time", { "QUEST_COMPLETE", "QUEST_LOG_UPDATE" }, OnEvent, Update, Click, OnEnter, OnLeave)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment