06-16-16, 04:44 AM | #1 |
Help Clearing Text OnHide
I am having trouble figuring out how to clear or update text once it has been displayed. The below script creates the text onshow. The timer starts and if I have an empty item slot and equip it then it will update. However, should I remove the item the text remains. Swapping items creates new text but it is overlayed onto the old text.
Any help would be appreciated. Cheers! EDIT: This is for Legion/PTR. This also works (except for the above issues) on WoD live if you remove: PaperDollFrame_UpdateInventoryFixupComplete(self); PaperDollFrame_HideInventoryFixupComplete(self); Code:
-- --------------------------- -- -- DCS Durability Frames -- -- --------------------------- local DuraShowTimer local kids = { PaperDollItemsFrame:GetChildren() }; -- print(kids); local function duraOnShow() -- ------------------- -- - Item Durability - -- ------------------- print("tick") print("tock") for k, child in ipairs(kids) do child:GetName(); -- print(child); local duraFS = child:CreateFontString("FontString","OVERLAY","GameTooltipText") duraFS:SetPoint("BOTTOM",child,"BOTTOM",0,0); duraFS:SetFont("Fonts\\FRIZQT__.TTF", 14, "THINOUTLINE"); local slotId = child:GetID(); -- print(slotId); local durCur, durMax = GetInventoryItemDurability(slotId); if durCur == nil or durMax == nil then -- print(slotId); duraFS:Hide(); else -- print(slotId); local durItemFinite = durCur*(100/durMax); -- print(durItemFinite); duraFS:SetFormattedText("%.0f%%", durCur*(100/durMax)); if durItemFinite == 100 then duraFS:Hide(); elseif durItemFinite >= 75 then duraFS:SetTextColor(0.75, 0.75, 0.75); elseif durItemFinite >= 50 then duraFS:SetTextColor(0, 1, 0); elseif durItemFinite >= 25 then duraFS:SetTextColor(1, 1, 0); elseif durItemFinite >= 0 then duraFS:SetTextColor(1, 0, 0); end end end end local function duraOnHide() if DuraShowTimer then DuraShowTimer:Cancel() end end local function delayHideDura(self) DuraShowTimer = C_Timer.NewTicker(0.10, duraOnShow, nil) end -- -------------------- -- - Total Durability - -- -------------------- for slot, slotName in gmatch("1HEAD3SHOULDER5CHEST6WAIST7LEGS8FEET9WRIST10HANDS16MAINHAND17SECONDARYHAND18RANGED","(%d+)([^%d]+)") do local durCur, durMax = GetInventoryItemDurability(slot) -- print(durMax) -- print(slot) -- print(frameName) 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 -- ------------------------------------------------ -- -- 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) 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 delayHideDura() end) PaperDollFrame:SetScript("OnHide", function(self, event, arg1) CharacterStatsPane.initialOffsetY = 0; CharacterFrame_Collapse(); PaperDollSidebarTabs:Hide(); PaperDollFrame_HideInventoryFixupComplete(self); duraOnHide() end) Last edited by Dejablue : 06-16-16 at 04:50 AM. |
|
WoWInterface » Developer Discussions » General Authoring Discussion » Help Clearing Text OnHide |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|