From 9329bbe6ba7b1880ea598f24f685ad49bb8a3447 Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 16 Jun 2018 19:38:10 +0200 Subject: [PATCH] unusable: remove broken module This module was not ready to be pulled into master. Sorry for the inconveniences. After the initial fixes I made, there are still some points open: * dead code for merchant window (no difference to stock ui) * dead code for mail window (no difference to stock ui) * bugs out when receiving mails (quickfix broke recipes) --- modules/bags.lua | 7 -- modules/unusable.lua | 192 ------------------------------------------- pfUI.toc | 1 - 3 files changed, 200 deletions(-) delete mode 100644 modules/unusable.lua diff --git a/modules/bags.lua b/modules/bags.lua index 9e24250f..9d7c9692 100644 --- a/modules/bags.lua +++ b/modules/bags.lua @@ -136,9 +136,6 @@ pfUI:RegisterModule("bags", function () if pfUI.bags[bag].slots[slot].frame:IsShown() then local _, _, locked, _ = GetContainerItemInfo(bag, slot) SetItemButtonDesaturated(pfUI.bags[bag].slots[slot].frame, locked, 0.5, 0.5, 0.5) - if pfUI.unusable then - pfUI.unusable:UpdateSlot(pfUI.bags[bag].slots[slot], bag, slot) - end end end end @@ -425,10 +422,6 @@ pfUI:RegisterModule("bags", function () end pfUI.bags[bag].slots[slot].frame:Show() - - if pfUI.unusable then - pfUI.unusable:UpdateSlot(pfUI.bags[bag].slots[slot], bag, slot) - end end function pfUI.bag:CreateBagSlots(frame) diff --git a/modules/unusable.lua b/modules/unusable.lua deleted file mode 100644 index 388c080d..00000000 --- a/modules/unusable.lua +++ /dev/null @@ -1,192 +0,0 @@ -pfUI:RegisterModule("unusable", function () - pfUI.unusable = CreateFrame("Frame", "pfUnusable", UIParent) - pfUI.unusable.tooltip = CreateFrame("GameTooltip", "pfUnusableTooltip", UIParent, "GameTooltipTemplate") - pfUI.unusable.tooltip:SetOwner(UIParent, "ANCHOR_NONE") - - pfUI.unusable:RegisterEvent("MAIL_INBOX_UPDATE") - pfUI.unusable:RegisterEvent("PLAYER_LEVEL_UP") - pfUI.unusable:RegisterEvent("SKILL_LINES_CHANGED") - - pfUI.unusable.unusables = {} - - pfUI.unusable:SetScript("OnEvent", function() - if event == "MAIL_INBOX_UPDATE" and MailFrame:IsVisible() then - local total = GetInboxNumItems() - for i = 1, INBOXITEMS_TO_DISPLAY do - local index = (((InboxFrame.pageNum - 1) * INBOXITEMS_TO_DISPLAY) + i) - local name, _, _, _, canUse = GetInboxItem(index) - local _, _, _, _, _, _, _, hasItem = GetInboxHeaderInfo(index) - - if hasItem and hasItem > 0 and name then - if not canUse or not pfUI.unusable:IsItemUsable(name, "MailBox", i) then - pfUI.unusable:MakeUnusable(_G["MailItem" .. i .. "ButtonIcon"]) - end - else - pfUI.unusable:MakeUsable(_G["MailItem" .. i .. "ButtonIcon"]) - end - end - elseif event == "PLAYER_LEVEL_UP" or event == "SKILL_LINES_CHANGED" then - for _, slot in pairs(pfUI.unusable.unusables) do - if slot and not pfUI.unusable:IsSlotItemUsable(slot) then - pfUI.unusable:MakeUnusable(slot) - end - end - end - end) - - function pfUI.unusable:UpdateSlot(frame, bag, slot) - if not pfUI.unusable:IsSlotItemUsable(frame, bag, slot) then - pfUI.unusable:MakeUnusable(frame) - else - pfUI.unusable:MakeUsable(frame) - end - end - - function pfUI.unusable:IsSlotItemUsable(slot, bag, index) - if not bag then bag = slot.bag end - if not index then index = slot.slot end - - local itemId, name = self:GetItemInfoFromLink(GetContainerItemLink(bag, index)) - return self:IsItemUsable(itemId, bag, index) - end - - function pfUI.unusable:IsItemUsable(item, bag, slot) - if item and (type(item) == "number" and item < 0) or item == "Unknown" then - return true - else - local name, itemLink, _, minLevel = GetItemInfo(item) - - if minLevel and minLevel > UnitLevel("player") then - return false - end - end - - for id = 0, 8 do - for _, v in pairs({"TextRight", "TextLeft"}) do - local widget = _G["pfUnusableTooltip"..v..id] - if widget then widget:SetTextColor(1,1,1,1) end - end - end - - if bag == -1 then - self.tooltip:SetInventoryItem("player", slot + 39) - elseif bag == "MailBox" then - self.tooltip:SetInboxItem(slot) - elseif bag == "Merchant" then - self.tooltip:SetMerchantItem(slot) - else - self.tooltip:SetBagItem(bag, slot) - end - - local result = true - for id = 0, 8 do - for _, v in pairs({"TextRight", "TextLeft"}) do - local widget = _G["pfUnusableTooltip"..v..id] - if widget and widget:GetText() then - local r, g, b = widget:GetTextColor() - if r > .9 and g < .2 and b < .2 then - -- item contains red text - result = false - break - end - end - if not result then break end - end - end - - self.tooltip:Hide() - return result - end - - function pfUI.unusable:MakeUnusable(slot) - if not slot then return end - local frame = slot.frame - - if type(frame) == "number" then - if MerchantFrame:IsVisible() then - local itemButton = _G["MerchantItem" .. frame .. "ItemButton"] - if itemButton then - SetItemButtonTextureVertexColor(itemButton, 0, 1, 0) - SetItemButtonNormalTextureVertexColor(itemButton, 0, 1, 0) - end - local merchantButton = _G["MerchantItem" .. frame] - if merchantButton then - SetItemButtonNameFrameVertexColor(merchantButton, 0, 1, 0) - SetItemButtonSlotVertexColor(merchantButton, 0, 1, 0) - end - end - elseif type(frame) == "table" or type(frame) == "userdata" then - if frame:IsObjectType("Texture") then - SetDesaturation(frame, nil) - frame:SetVertexColor(1, 0, 0) - SetDesaturation(frame, nil) - else - SetItemButtonTextureVertexColor(frame, 1, 0, 0) - - -- Hack: there is an issue with the bank frame overriding the VertexColor, - -- since we have no idea where this is happening, we will store the - -- original SetVertexColor function and override it, it will be restored - -- when we call MakeUsable(). - if not slot.oldVertexFunc and slot.bag and slot.bag < 0 then - slot.oldVertexFunc = _G[frame:GetName().."IconTexture"].SetVertexColor - _G[frame:GetName().."IconTexture"].SetVertexColor = function(this, r, g, b, a) - return slot.oldVertexFunc(this, 1, 0, 0) - end - end - end - else - return false - end - - self.unusables[slot] = slot - return true - end - - function pfUI.unusable:MakeUsable(slot) - if not slot then return end - local frame = slot.frame - - if type(frame) == "number" and MerchantFrame:IsVisible() then - local itemButton = _G["MerchantItem" .. frame .. "ItemButton"] - if itemButton then - SetItemButtonTextureVertexColor(itemButton, 1, 1, 1) - SetItemButtonNormalTextureVertexColor(itemButton, 1, 1, 1) - end - local merchantButton = _G["MerchantItem" .. frame] - if merchantButton then - SetItemButtonNameFrameVertexColor(merchantButton, 1, 1, 1) - SetItemButtonSlotVertexColor(merchantButton, 1, 1, 1) - end - elseif type(frame) == "table" or type(frame) == "userdata" then - if frame:IsObjectType("Texture") then - SetDesaturation(frame, nil) - frame:SetVertexColor(1, 1, 1) - SetDesaturation(frame, nil) - else - if slot.oldVertexFunc then - _G[frame:GetName().."IconTexture"].SetVertexColor = slot.oldVertexFunc - slot.oldVertexFunc = nil - end - - SetItemButtonTextureVertexColor(frame, 1, 1, 1) - end - else - return false - end - - self.unusables[slot] = nil - return true - end - - function pfUI.unusable:GetItemInfoFromLink(link) - local id = -1 - local name = "Unknown" - if link ~= nil then - for i, n in string.gfind(link, "|c%x+|Hitem:(%d+):%d+:%d+:%d+|h%[(.-)%]|h|r") do - if i ~= nil then id = i end - if n ~= nil then name = n end - end - end - return id, name - end -end) diff --git a/pfUI.toc b/pfUI.toc index 1c5cd776..4b0a0b4b 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -96,4 +96,3 @@ modules\tracking.lua modules\easteregg.lua modules\farmmode.lua modules\pettarget.lua -modules\unusable.lua