From 7c35564ee2e418bb4d60444454b25681c8b47631 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 25 Sep 2016 22:30:14 +0200 Subject: [PATCH] buffframes and weapon enchants --- modules/buff.lua | 122 +++++++++++++++++++++++++++++++++++++++++++++++ pfUI.toc | 1 + 2 files changed, 123 insertions(+) create mode 100644 modules/buff.lua diff --git a/modules/buff.lua b/modules/buff.lua new file mode 100644 index 00000000..537de3ed --- /dev/null +++ b/modules/buff.lua @@ -0,0 +1,122 @@ +pfUI:RegisterModule("buff", function () + pfUI.buff = CreateFrame("Frame") + + -- weapon enchant (main hand) + pfUI.buff.mainHand = CreateFrame("Frame", nil, UIParent) + pfUI.buff.mainHand.stacks = pfUI.buff.mainHand:CreateFontString(nil, "OVERLAY", "GameFontNormal") + pfUI.buff.mainHand.stacks:SetFont(STANDARD_TEXT_FONT, 14, "OUTLINE") + pfUI.buff.mainHand.stacks:SetTextColor(1,1,1,1) + pfUI.buff.mainHand.stacks:ClearAllPoints() + pfUI.buff.mainHand.stacks:SetPoint("TOPLEFT", pfUI.buff.mainHand ,"TOPLEFT", 2, -2) + pfUI.buff.mainHand.stacks:SetPoint("BOTTOMRIGHT", pfUI.buff.mainHand ,"BOTTOMRIGHT", -2, 2) + pfUI.buff.mainHand.stacks:SetJustifyH("RIGHT") + pfUI.buff.mainHand.stacks:SetJustifyV("BOTTOM") + + -- weapon enchant (off hand) + pfUI.buff.offHand = CreateFrame("Frame", nil, UIParent) + pfUI.buff.offHand.stacks = pfUI.buff.offHand:CreateFontString(nil, "OVERLAY", "GameFontNormal") + pfUI.buff.offHand.stacks:SetFont(STANDARD_TEXT_FONT, 14, "OUTLINE") + pfUI.buff.offHand.stacks:SetTextColor(1,1,1,1) + pfUI.buff.offHand.stacks:ClearAllPoints() + pfUI.buff.offHand.stacks:SetPoint("TOPLEFT", pfUI.buff.offHand ,"TOPLEFT", 2, -2) + pfUI.buff.offHand.stacks:SetPoint("BOTTOMRIGHT", pfUI.buff.offHand ,"BOTTOMRIGHT", -2, 2) + pfUI.buff.offHand.stacks:SetJustifyH("RIGHT") + pfUI.buff.offHand.stacks:SetJustifyV("BOTTOM") + + -- hook buff update + if not Hook_BuffButton_OnUpdate then + Hook_BuffButton_OnUpdate = BuffButton_OnUpdate + end + + function BuffButton_OnUpdate (arg1) + TemporaryEnchantFrame:ClearAllPoints() + TemporaryEnchantFrame:SetPoint("TOPRIGHT", pfUI.minimap, "TOPLEFT", -25,0) + + local buff = this + local icon = getglobal(buff:GetName().."Icon"); + local border = getglobal(buff:GetName().."Border") + + if border then + buff:SetBackdrop({ + bgFile = icon:GetTexture(), tile = false, tileSize = pfUI_config.unitframes.buff_size, + edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8, + insets = { left = 0, right = 0, top = 0, bottom = 0} + }) + buff:SetBackdropBorderColor(border:GetVertexColor()) + border:Hide() + else + buff:SetBackdrop({ + bgFile = icon:GetTexture(), tile = false, tileSize = pfUI_config.unitframes.buff_size, + edgeFile = "Interface\\AddOns\\pfUI\\img\\border", edgeSize = 8, + insets = { left = 0, right = 0, top = 0, bottom = 0} + }) + end + Hook_BuffButton_OnUpdate(arg1) + end + + -- hook weapon update + if not Hook_BuffFrame_Enchant_OnUpdate then + Hook_BuffFrame_Enchant_OnUpdate = BuffFrame_Enchant_OnUpdate + end + + function BuffFrame_Enchant_OnUpdate (arg1) + TemporaryEnchantFrame:ClearAllPoints() + TemporaryEnchantFrame:SetPoint("TOPRIGHT", pfUI.minimap, "TOPLEFT", -25,0) + + for _,frame in pairs ({TempEnchant1,TempEnchant2}) do + local buff = frame + local icon = getglobal(buff:GetName().."Icon"); + local border = getglobal(buff:GetName().."Border") + local _, _, mainhand, _, _, offhand = GetWeaponEnchantInfo() + + if buff then + buff:SetBackdrop({ + bgFile = icon:GetTexture(), tile = false, tileSize = pfUI_config.unitframes.buff_size, + edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8, + insets = { left = 0, right = 0, top = 0, bottom = 0} + }) + border:Hide() + end + + if mainhand then + if buff:GetID() == 16 then + local link = GetInventoryItemLink("player", 16) + local _, _, itemLink = string.find(link, "(item:%d+:%d+:%d+:%d+)"); + local _, _, itemRarity, itemLevel, _, _, _, itemEquipLoc, _ = GetItemInfo(itemLink) + + if itemRarity then + buff:SetBackdropBorderColor(GetItemQualityColor(itemRarity)) + end + + if mainhand > 0 then + pfUI.buff.mainHand.stacks:SetText(mainhand) + pfUI.buff.mainHand:SetAllPoints(buff) + pfUI.buff.mainHand:Show() + end + end + else + pfUI.buff.mainHand:Hide() + end + + if offhand then + if buff:GetID() == 17 then + local link = GetInventoryItemLink("player", 17) + local _, _, itemLink = string.find(link, "(item:%d+:%d+:%d+:%d+)"); + local _, _, itemRarity, itemLevel, _, _, _, itemEquipLoc, _ = GetItemInfo(itemLink) + + if itemRarity then + buff:SetBackdropBorderColor(GetItemQualityColor(itemRarity)) + end + if offhand > 0 then + pfUI.buff.offHand.stacks:SetText(offhand) + pfUI.buff.offHand:SetAllPoints(buff) + pfUI.buff.offHand:Show() + end + end + else + pfUI.buff.offHand:Hide() + end + end + Hook_BuffFrame_Enchant_OnUpdate(arg1) + end +end) diff --git a/pfUI.toc b/pfUI.toc index 2cad2cc7..a6989e0e 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -45,3 +45,4 @@ modules\cooldown.lua modules\tooltip.lua modules\uf_tukui.lua modules\thirdparty.lua +modules\buff.lua