Works perfect. Thanks again everyone. Here is the tentative script:
Code:
-- ---------------------------
-- -- DCS Durability Frames --
-- ---------------------------
local DuraShowTimer
local DCSITEM_SLOT_FRAMES = {CharacterHeadSlot,CharacterNeckSlot,CharacterShoulderSlot,
CharacterBackSlot,CharacterChestSlot,CharacterWristSlot,CharacterHandsSlot,
CharacterWaistSlot,CharacterLegsSlot,CharacterFeetSlot,CharacterFinger0Slot,
CharacterFinger1Slot,CharacterTrinket0Slot,CharacterTrinket1Slot,
CharacterMainHandSlot,CharacterSecondaryHandSlot,
};
-- -------------------
-- - Item Durability -
-- -------------------
for k, v in ipairs(DCSITEM_SLOT_FRAMES) do
-- print(v)
v.durability = duraFS
v.durability = v:CreateFontString("FontString","OVERLAY","GameTooltipText")
v.durability:SetPoint("BOTTOM",v,"BOTTOM",0,0);
v.durability:SetFont("Fonts\\FRIZQT__.TTF", 14, "THINOUTLINE");
v.durability:SetFormattedText("");
end
local function duraOnShow()
for k, v in ipairs(DCSITEM_SLOT_FRAMES) do
local slotId = v:GetID();
-- print(slotId)
local durCur, durMax = GetInventoryItemDurability(slotId)
if durCur == nil or durMax == nil then
v.durability:SetFormattedText("");
elseif ( durCur ~= durMax ) then
local durFinite = durCur*(100/durMax)
-- print(durFinite)
v.durability:SetFormattedText("%.0f%%", durCur*(100/durMax));
if durFinite >= 75 then
v.durability:SetTextColor(0.75, 0.75, 0.75);
elseif durFinite >= 50 then
v.durability:SetTextColor(0, 1, 0);
elseif durFinite >= 25 then
v.durability:SetTextColor(1, 1, 0);
elseif durFinite >= 0 then
v.durability:SetTextColor(1, 0, 0);
end
end
end
-- --------------------
-- - Total Durability -
-- --------------------
for slot, slotName in gmatch("1HEAD3SHOULDER5CHEST6WAIST7LEGS8FEET9WRIST10HANDS16MAINHAND17SECONDARYHAND18RANGED","([%d-]+)") do
-- print(slot)
local durCur, durMax = GetInventoryItemDurability(slot)
-- print(durCur, durMax)
-- print(durMax)
-- print(slot)
if ( durCur ~= durMax ) then
local duraFS = CharacterShirtSlot:CreateFontString("FontString","OVERLAY","GameTooltipText")
duraFS:ClearAllPoints()
duraFS:SetPoint("CENTER",CharacterShirtSlot,"CENTER",0,0)
duraFS:SetFont("Fonts\\FRIZQT__.TTF", 16, "THINOUTLINE")
local durFinite = durCur*(100/durMax)
-- print(durFinite)
duraFS:SetFormattedText("%.0f%%", durCur*(100/durMax))
if durFinite == 100 then
duraFS:Hide();
elseif durFinite >= 75 then
duraFS:SetTextColor(0.75, 0.75, 0.75);
elseif durFinite >= 50 then
duraFS:SetTextColor(0, 1, 0);
elseif durFinite >= 25 then
duraFS:SetTextColor(1, 1, 0);
elseif durFinite >= 0 then
duraFS:SetTextColor(1, 0, 0);
end
end
end
end
-- ---------------------
-- -- Timers OnUpdate --
-- ---------------------
local function duraOnHide()
if DuraShowTimer then DuraShowTimer:Cancel() end
end
local function delayShowDura(self)
DuraShowTimer = C_Timer.NewTicker(0.10, duraOnShow, nil)
end
-- ------------------------------------------------
-- -- DCS Character Frame Expand/Collapse Button --
-- ------------------------------------------------
local _, private = ...
private.defaults.dejacharacterstatsExpandChecked = {
ExpandSetChecked = true,
}
local DCS_ExpandCheck = CreateFrame("Button", "DCS_ExpandCheck", CharacterFrameInset, "InterfaceOptionsCheckButtonTemplate")
DCS_ExpandCheck:RegisterEvent("PLAYER_LOGIN")
DCS_ExpandCheck:ClearAllPoints()
DCS_ExpandCheck:SetPoint("BOTTOMRIGHT", 0, 0)
DCS_ExpandCheck:SetScale(1.25)
DCS_ExpandCheck.tooltipText = 'Show Character Stats.' --Creates a tooltip on mouseover.
local DCS_ExpandButtontexture = DCS_ExpandCheck:CreateTexture()
DCS_ExpandButtontexture:SetAllPoints(DCS_ExpandCheck)
DCS_ExpandCheck:SetScript("OnEvent", function(self, event, arg1)
if event == "PLAYER_LOGIN" then
checked = private.db.dejacharacterstatsExpandChecked.ExpandSetChecked
-- print(checked)
end
end)
DCS_ExpandCheck:SetScript("OnClick", function(self,event,arg1)
checked = private.db.dejacharacterstatsExpandChecked.ExpandSetChecked
if checked == true then
-- print(checked)
CharacterFrame_Collapse();
DCS_ExpandButtontexture:SetTexture("Interface\\GLUES\\COMMON\\Glue-RightArrow-Button-Up")
private.db.dejacharacterstatsExpandChecked.ExpandSetChecked = false
else
-- print(checked)
CharacterFrame_Expand();
DCS_ExpandButtontexture:SetTexture("Interface\\GLUES\\COMMON\\Glue-RightArrow-Button-Down")
private.db.dejacharacterstatsExpandChecked.ExpandSetChecked = true
end
end)
-- ------------------------------
-- -- PaperDoll OnShow/OnHide --
-- ------------------------------
PaperDollFrame:SetScript("OnShow", function(self, event, arg1)
CharacterStatsPane.initialOffsetY = 0;
CharacterFrameTitleText:SetText(UnitPVPName("player"));
PaperDollFrame_SetLevel();
PaperDollFrame_UpdateStats();
SetPaperDollBackground(CharacterModelFrame, "player");
PaperDollBgDesaturate(true);
PaperDollSidebarTabs:Show();
PaperDollFrame_UpdateInventoryFixupComplete(self);
checked = private.db.dejacharacterstatsExpandChecked.ExpandSetChecked
if checked == true then
-- print(checked)
CharacterFrame_Expand();
DCS_ExpandButtontexture:SetTexture("Interface\\GLUES\\COMMON\\Glue-RightArrow-Button-Down")
else
-- print(checked)
CharacterFrame_Collapse();
DCS_ExpandButtontexture:SetTexture("Interface\\GLUES\\COMMON\\Glue-RightArrow-Button-Up")
end
delayShowDura()
end)
PaperDollFrame:SetScript("OnHide", function(self, event, arg1)
CharacterStatsPane.initialOffsetY = 0;
CharacterFrame_Collapse();
PaperDollSidebarTabs:Hide();
PaperDollFrame_HideInventoryFixupComplete(self);
duraOnHide()
end)