Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------------------------------------------------------------------------------------------------------------
- -- Original Author Unknown - Updated by Xorcism & PFJ
- -- Last update: September 12, 2013 - 05:10:58 PM
- -- Fixes the following frames to show the proper icon textures:
- -- Container, Bag Bar, Bank, Bag Portrait, Action Bar, Spellbook, and Trade.
- -- Allows auto-equipping custom items from your bags by right-clicking them (from RemorseView). Tweaked to avoid
- -- throwing LUA errors when an empty slot is clicked.
- -- 7.18.13 - Added a fix of the MerchantFrame that keeps it from resetting to page 1 when you buy an item. Updated this
- -- on 8.31.13 to rely on your target rather than a timer. This solves the issue of the page still resetting
- -- when you click (to buy) an item multiple times quickly or when buying multiple items via the BuyEmAll
- -- add-on.
- -- 7.22.13 - Fixed the code from RemorseView so it only fires when the default right-click behavior is not enough.
- -- It was causing issues when trying to equip a non-custom item that was not already soulbound by right
- -- clicking from your bags.
- -- Past Issues:
- -- "Interface action failed because of an addon" displays when you initially enter combat after logging in. At the
- -- present time this is unavoidable, but it's also harmless. FYI it's a result of the ActionBar fix.
- -- Wasn't harmless with the default UI or action bar addons that funnel their button updates through the default
- -- function.
- ------------------------------------------------------------------------------------------------------------------------
- if(DEFAULT_CHAT_FRAME)then DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00Custom Display Fix:|r started.");end
- -- Container fix
- WOW_GetContainerItemInfo = GetContainerItemInfo;
- function GetContainerItemInfo(index, id)
- local texture, itemCount, locked, quality, readable;
- texture, itemCount, locked, quality, readable = WOW_GetContainerItemInfo(index, id);
- if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
- local itemlink = GetContainerItemLink(index, id);
- local itemid = 0;
- local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemlink)
- if(itemlink) then
- _, _, itemid = string.find(itemlink, "Hitem:(%d+):");
- texture = itemTexture;
- end
- end
- return texture, itemCount, locked, quality, readable;
- end
- -- Bag bar & and bank frame fix
- WOW_GetInventoryItemTexture = GetInventoryItemTexture;
- function GetInventoryItemTexture(unit, invSlot)
- local texture = WOW_GetInventoryItemTexture(unit, invSlot);
- if(not texture or (unit == "player" and invSlot > 19 and invSlot < 24)) then
- local itemLink = GetInventoryItemLink(unit, invSlot);
- if(itemLink) then
- _,_,_,_,_,_,_,_, _,texture = GetItemInfo(itemLink);
- end
- end
- return texture;
- end
- -- Bag portrait fix
- WOW_ContainerFrame_GenerateFrame = ContainerFrame_GenerateFrame;
- function ContainerFrame_GenerateFrame(frame, size, id)
- WOW_ContainerFrame_GenerateFrame(frame, size, id);
- if(id > 0 and id < 5) then id = ((id + 20) -1);getglobal(frame:GetName().."Portrait"):SetTexture(GetInventoryItemTexture("player", id));end
- end
- -- ArkInv uses GetItemIcon(name); - PallyFunJr
- WOW_GetItemIcon = GetItemIcon;
- function GetItemIcon(n)
- if n then
- if not WOW_GetItemIcon(n) then
- local itemName, itemLink, _, _, _, _, _, _, _, itemTexture = GetItemInfo(n)
- return itemTexture;
- else
- return WOW_GetItemIcon(n);
- end
- end
- end
- -- Monkey see monkey do.
- local Bartender3 = Bartender3
- local Bartender4 = Bartender4
- if(Bartender3 ~= nil) then
- function Bartender3.Class.Button.prototype:UpdateIcon()
- local frame = self.frame
- local texture = GetActionTexture(self.action)
- if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
- -- Anything with a question mark icon.
- if(self.action) then
- -- Has an action
- if(GetActionInfo(self.action)) then
- -- Has some info
- t,id,st = GetActionInfo(self.action);
- end
- end
- if(t and string.find(t, "spell")) then
- spellName, spellRank = GetSpellName( id, BOOKTYPE_SPELL );
- if(spellName == "Attack") then
- texture = GetInventoryItemTexture("player", 16);
- elseif(spellName == "Shoot" or spellName == "Auto Shot") then
- texture = GetInventoryItemTexture("player", 18);
- end
- elseif(t and string.find(t, "item")) then
- _,_,_,_,_,_,_,_,_,texture,_ = GetItemInfo(id);
- end
- end
- if ( texture ) then
- self.rangeTimer = -1
- frame.icon:SetTexture(texture)
- frame.icon:Show()
- frame.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot2")
- frame.normalTexture:SetTexCoord(0,0,0,0)
- frame.tex = texture
- else
- self.rangeTimer = nil
- frame.icon:Hide()
- frame.cooldown:Hide()
- frame.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot")
- frame.hotkey:SetVertexColor(0.6, 0.6, 0.6)
- frame.normalTexture:SetTexCoord(-0.1,1.1,-0.1,1.12)
- frame.tex = nil
- end
- end
- elseif(Bartender4 ~= nil) then
- function Bartender4.Button.prototype:UpdateIcon()
- local texture = GetActionTexture(self.action)
- if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
- -- Anything with a question mark icon.
- if(self.action) then
- -- Has an action
- if(GetActionInfo(self.action)) then
- -- Has some info
- t,id,st = GetActionInfo(self.action);
- end
- end
- if(t and string.find(t, "spell")) then
- spellName, spellRank = GetSpellName(id, BOOKTYPE_SPELL);
- if(spellName == "Attack") then
- texture = GetInventoryItemTexture("player", 16);
- elseif(spellName == "Shoot" or spellName == "Auto Shot") then
- texture = GetInventoryItemTexture("player", 18);
- end
- elseif(t and string.find(t, "item")) then
- _,_,_,_,_,_,_,_,_,texture,_ = GetItemInfo(id);
- end
- end
- if(texture) then
- self.rangeTimer = -1
- self.icon:SetTexture(texture)
- self.icon:Show()
- self.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot2")
- self.normalTexture:SetTexCoord(0, 0, 0, 0)
- self.iconTex = texture
- else
- self.rangeTimer = nil
- self.icon:Hide()
- self.cooldown:Hide()
- self.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot")
- self.normalTexture:SetTexCoord(-0.15, 1.15, -0.15, 1.17)
- self.hotkey:SetVertexColor(0.6, 0.6, 0.6)
- self.iconTex = nil
- end
- if self.parent.config.hidemacrotext then
- self.macroName:Hide()
- else
- self.macroName:Show()
- end
- end
- end
- -- Spellbook fix
- WOW_GetSpellTexture = GetSpellTexture;
- function GetSpellTexture(id, bookType)
- local texture = WOW_GetSpellTexture(id, bookType);
- local spellName, subSpellName = GetSpellName(id, bookType);
- if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
- if (spellName == "Attack") then
- texture = GetInventoryItemTexture("player",16);
- elseif (spellName == "Auto Shot" or spellName == "Shoot") then
- texture = GetInventoryItemTexture("player",18);
- end
- end
- return texture;
- end
- -- Trade window fix
- WOW_GetTradePlayerItemInfo = GetTradePlayerItemInfo;
- function GetTradePlayerItemInfo(id)
- local name, texture, numItems, isUsable, enchantment = WOW_GetTradePlayerItemInfo(id);
- if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
- local itemLink = GetTradePlayerItemLink(id);
- if(itemLink) then
- _,_,_,_,_,_,_,_,_, texture = GetItemInfo(itemLink);
- end
- end
- return name, texture, numItems, isUsable, enchantment;
- end
- -- Merchant frame page fix
- local CDF_merchantFix = {targetName = nil,lastShown = nil,};
- MerchantFrame:RegisterEvent("PLAYER_TARGET_CHANGED");
- function MerchantFrame_OnEvent()
- if(event == "MERCHANT_UPDATE") then
- if(MerchantFrame:IsVisible()) then MerchantFrame_Update();end
- elseif(event == "MERCHANT_CLOSED") then
- HideUIPanel(this);
- elseif(event == "MERCHANT_SHOW") then
- ShowUIPanel(this);
- if(not this:IsShown())then CloseMerchant();return;end
- -- Only resetting when this fires and we've changed targets since then.
- if(CDF_merchantFix.targetName ~= CDF_merchantFix.lastShown) then this.page = 1;end
- CDF_merchantFix.lastShown = UnitName("target");
- MerchantFrame_Update();
- elseif(event == "PLAYER_TARGET_CHANGED") then
- CDF_merchantFix.targetName = UnitName("target");
- -- I believe this is only set when a vendor window is opened so changing targets may not necessarily
- -- change this unless the new target is a vendor and in range to open its merchant frame.
- end
- end
- -- Taken from the RemorseView add-on (Thanks Morottal)
- -- Rather than adding to the default right-click behavior this should override it. Clicking a custom item currently with
- -- a use on it will use that item and then equip it... which is not really what we're after.
- local origItemLink;
- local function ContainerFrameItemButton_OnEnter_Hook(self)origItemLink=GetContainerItemLink(this:GetParent():GetID(),this:GetID());end
- local function ContainerFrameItemButton_OnClick_Hook(button)
- local bagID = this:GetParent():GetID();
- local slot = this:GetID();
- local t = WOW_GetContainerItemInfo(bagID, slot);
- if(t and string.find(t, "INV_Misc_QuestionMark")) then
- local link = GetContainerItemLink(bagID, slot);
- if(link and button == "RightButton" and link == origItemLink) then
- local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(link);
- if(itemType == "Armor" or itemType == "Weapon") then
- PickupContainerItem(bagID, slot);
- AutoEquipCursorItem();
- end
- end
- origItemLink = link;
- end
- end
- hooksecurefunc("ContainerFrameItemButton_OnClick", ContainerFrameItemButton_OnClick_Hook);
- hooksecurefunc("ContainerFrameItemButton_OnEnter", ContainerFrameItemButton_OnEnter_Hook);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement