Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.78 KB | None | 0 0
  1. ------------------------------------------------------------------------------------------------------------------------
  2. -- Original Author Unknown - Updated by Xorcism & PFJ
  3. -- Last update: September 12, 2013 - 05:10:58 PM
  4.  
  5. -- Fixes the following frames to show the proper icon textures:
  6. -- Container, Bag Bar, Bank, Bag Portrait, Action Bar, Spellbook, and Trade.
  7.  
  8. -- Allows auto-equipping custom items from your bags by right-clicking them (from RemorseView). Tweaked to avoid
  9. -- throwing LUA errors when an empty slot is clicked.
  10.  
  11. -- 7.18.13 - Added a fix of the MerchantFrame that keeps it from resetting to page 1 when you buy an item. Updated this
  12. -- on 8.31.13 to rely on your target rather than a timer. This solves the issue of the page still resetting
  13. -- when you click (to buy) an item multiple times quickly or when buying multiple items via the BuyEmAll
  14. -- add-on.
  15.  
  16. -- 7.22.13 - Fixed the code from RemorseView so it only fires when the default right-click behavior is not enough.
  17. -- It was causing issues when trying to equip a non-custom item that was not already soulbound by right
  18. -- clicking from your bags.
  19.  
  20. -- Past Issues:
  21. -- "Interface action failed because of an addon" displays when you initially enter combat after logging in. At the
  22. -- present time this is unavoidable, but it's also harmless. FYI it's a result of the ActionBar fix.
  23.  
  24. -- Wasn't harmless with the default UI or action bar addons that funnel their button updates through the default
  25. -- function.
  26. ------------------------------------------------------------------------------------------------------------------------
  27. if(DEFAULT_CHAT_FRAME)then DEFAULT_CHAT_FRAME:AddMessage("|cff00ff00Custom Display Fix:|r started.");end
  28.  
  29. -- Container fix
  30. WOW_GetContainerItemInfo = GetContainerItemInfo;
  31. function GetContainerItemInfo(index, id)
  32. local texture, itemCount, locked, quality, readable;
  33. texture, itemCount, locked, quality, readable = WOW_GetContainerItemInfo(index, id);
  34. if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
  35. local itemlink = GetContainerItemLink(index, id);
  36. local itemid = 0;
  37. local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(itemlink)
  38. if(itemlink) then
  39. _, _, itemid = string.find(itemlink, "Hitem:(%d+):");
  40. texture = itemTexture;
  41. end
  42. end
  43.  
  44. return texture, itemCount, locked, quality, readable;
  45. end
  46.  
  47. -- Bag bar & and bank frame fix
  48. WOW_GetInventoryItemTexture = GetInventoryItemTexture;
  49. function GetInventoryItemTexture(unit, invSlot)
  50. local texture = WOW_GetInventoryItemTexture(unit, invSlot);
  51. if(not texture or (unit == "player" and invSlot > 19 and invSlot < 24)) then
  52. local itemLink = GetInventoryItemLink(unit, invSlot);
  53. if(itemLink) then
  54. _,_,_,_,_,_,_,_, _,texture = GetItemInfo(itemLink);
  55. end
  56. end
  57. return texture;
  58. end
  59.  
  60. -- Bag portrait fix
  61. WOW_ContainerFrame_GenerateFrame = ContainerFrame_GenerateFrame;
  62. function ContainerFrame_GenerateFrame(frame, size, id)
  63. WOW_ContainerFrame_GenerateFrame(frame, size, id);
  64. if(id > 0 and id < 5) then id = ((id + 20) -1);getglobal(frame:GetName().."Portrait"):SetTexture(GetInventoryItemTexture("player", id));end
  65. end
  66.  
  67. -- ArkInv uses GetItemIcon(name); - PallyFunJr
  68. WOW_GetItemIcon = GetItemIcon;
  69. function GetItemIcon(n)
  70. if n then
  71. if not WOW_GetItemIcon(n) then
  72. local itemName, itemLink, _, _, _, _, _, _, _, itemTexture = GetItemInfo(n)
  73. return itemTexture;
  74. else
  75. return WOW_GetItemIcon(n);
  76. end
  77. end
  78. end
  79.  
  80. -- Monkey see monkey do.
  81. local Bartender3 = Bartender3
  82. local Bartender4 = Bartender4
  83.  
  84. if(Bartender3 ~= nil) then
  85. function Bartender3.Class.Button.prototype:UpdateIcon()
  86. local frame = self.frame
  87. local texture = GetActionTexture(self.action)
  88. if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
  89. -- Anything with a question mark icon.
  90. if(self.action) then
  91. -- Has an action
  92. if(GetActionInfo(self.action)) then
  93. -- Has some info
  94. t,id,st = GetActionInfo(self.action);
  95. end
  96. end
  97.  
  98. if(t and string.find(t, "spell")) then
  99. spellName, spellRank = GetSpellName( id, BOOKTYPE_SPELL );
  100.  
  101. if(spellName == "Attack") then
  102. texture = GetInventoryItemTexture("player", 16);
  103. elseif(spellName == "Shoot" or spellName == "Auto Shot") then
  104. texture = GetInventoryItemTexture("player", 18);
  105. end
  106. elseif(t and string.find(t, "item")) then
  107. _,_,_,_,_,_,_,_,_,texture,_ = GetItemInfo(id);
  108. end
  109.  
  110. end
  111. if ( texture ) then
  112. self.rangeTimer = -1
  113. frame.icon:SetTexture(texture)
  114. frame.icon:Show()
  115. frame.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot2")
  116. frame.normalTexture:SetTexCoord(0,0,0,0)
  117. frame.tex = texture
  118. else
  119. self.rangeTimer = nil
  120. frame.icon:Hide()
  121. frame.cooldown:Hide()
  122. frame.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot")
  123. frame.hotkey:SetVertexColor(0.6, 0.6, 0.6)
  124. frame.normalTexture:SetTexCoord(-0.1,1.1,-0.1,1.12)
  125. frame.tex = nil
  126. end
  127. end
  128. elseif(Bartender4 ~= nil) then
  129. function Bartender4.Button.prototype:UpdateIcon()
  130. local texture = GetActionTexture(self.action)
  131. if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
  132. -- Anything with a question mark icon.
  133. if(self.action) then
  134. -- Has an action
  135. if(GetActionInfo(self.action)) then
  136. -- Has some info
  137. t,id,st = GetActionInfo(self.action);
  138. end
  139. end
  140.  
  141. if(t and string.find(t, "spell")) then
  142. spellName, spellRank = GetSpellName(id, BOOKTYPE_SPELL);
  143. if(spellName == "Attack") then
  144. texture = GetInventoryItemTexture("player", 16);
  145. elseif(spellName == "Shoot" or spellName == "Auto Shot") then
  146. texture = GetInventoryItemTexture("player", 18);
  147. end
  148. elseif(t and string.find(t, "item")) then
  149. _,_,_,_,_,_,_,_,_,texture,_ = GetItemInfo(id);
  150. end
  151. end
  152.  
  153. if(texture) then
  154. self.rangeTimer = -1
  155. self.icon:SetTexture(texture)
  156. self.icon:Show()
  157. self.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot2")
  158. self.normalTexture:SetTexCoord(0, 0, 0, 0)
  159. self.iconTex = texture
  160. else
  161. self.rangeTimer = nil
  162. self.icon:Hide()
  163. self.cooldown:Hide()
  164. self.normalTexture:SetTexture("Interface\\Buttons\\UI-Quickslot")
  165. self.normalTexture:SetTexCoord(-0.15, 1.15, -0.15, 1.17)
  166. self.hotkey:SetVertexColor(0.6, 0.6, 0.6)
  167. self.iconTex = nil
  168. end
  169. if self.parent.config.hidemacrotext then
  170. self.macroName:Hide()
  171. else
  172. self.macroName:Show()
  173. end
  174. end
  175. end
  176.  
  177.  
  178. -- Spellbook fix
  179. WOW_GetSpellTexture = GetSpellTexture;
  180. function GetSpellTexture(id, bookType)
  181. local texture = WOW_GetSpellTexture(id, bookType);
  182. local spellName, subSpellName = GetSpellName(id, bookType);
  183. if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
  184. if (spellName == "Attack") then
  185. texture = GetInventoryItemTexture("player",16);
  186. elseif (spellName == "Auto Shot" or spellName == "Shoot") then
  187. texture = GetInventoryItemTexture("player",18);
  188. end
  189. end
  190. return texture;
  191. end
  192.  
  193. -- Trade window fix
  194. WOW_GetTradePlayerItemInfo = GetTradePlayerItemInfo;
  195. function GetTradePlayerItemInfo(id)
  196. local name, texture, numItems, isUsable, enchantment = WOW_GetTradePlayerItemInfo(id);
  197. if(texture and string.find(texture, "INV_Misc_QuestionMark")) then
  198. local itemLink = GetTradePlayerItemLink(id);
  199. if(itemLink) then
  200. _,_,_,_,_,_,_,_,_, texture = GetItemInfo(itemLink);
  201. end
  202. end
  203. return name, texture, numItems, isUsable, enchantment;
  204. end
  205.  
  206. -- Merchant frame page fix
  207. local CDF_merchantFix = {targetName = nil,lastShown = nil,};
  208. MerchantFrame:RegisterEvent("PLAYER_TARGET_CHANGED");
  209. function MerchantFrame_OnEvent()
  210. if(event == "MERCHANT_UPDATE") then
  211. if(MerchantFrame:IsVisible()) then MerchantFrame_Update();end
  212. elseif(event == "MERCHANT_CLOSED") then
  213. HideUIPanel(this);
  214. elseif(event == "MERCHANT_SHOW") then
  215. ShowUIPanel(this);
  216. if(not this:IsShown())then CloseMerchant();return;end
  217. -- Only resetting when this fires and we've changed targets since then.
  218. if(CDF_merchantFix.targetName ~= CDF_merchantFix.lastShown) then this.page = 1;end
  219. CDF_merchantFix.lastShown = UnitName("target");
  220. MerchantFrame_Update();
  221. elseif(event == "PLAYER_TARGET_CHANGED") then
  222. CDF_merchantFix.targetName = UnitName("target");
  223. -- I believe this is only set when a vendor window is opened so changing targets may not necessarily
  224. -- change this unless the new target is a vendor and in range to open its merchant frame.
  225. end
  226. end
  227.  
  228. -- Taken from the RemorseView add-on (Thanks Morottal)
  229. -- Rather than adding to the default right-click behavior this should override it. Clicking a custom item currently with
  230. -- a use on it will use that item and then equip it... which is not really what we're after.
  231. local origItemLink;
  232. local function ContainerFrameItemButton_OnEnter_Hook(self)origItemLink=GetContainerItemLink(this:GetParent():GetID(),this:GetID());end
  233. local function ContainerFrameItemButton_OnClick_Hook(button)
  234. local bagID = this:GetParent():GetID();
  235. local slot = this:GetID();
  236. local t = WOW_GetContainerItemInfo(bagID, slot);
  237. if(t and string.find(t, "INV_Misc_QuestionMark")) then
  238. local link = GetContainerItemLink(bagID, slot);
  239. if(link and button == "RightButton" and link == origItemLink) then
  240. local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture = GetItemInfo(link);
  241. if(itemType == "Armor" or itemType == "Weapon") then
  242. PickupContainerItem(bagID, slot);
  243. AutoEquipCursorItem();
  244. end
  245. end
  246. origItemLink = link;
  247. end
  248. end
  249. hooksecurefunc("ContainerFrameItemButton_OnClick", ContainerFrameItemButton_OnClick_Hook);
  250. hooksecurefunc("ContainerFrameItemButton_OnEnter", ContainerFrameItemButton_OnEnter_Hook);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement