Guest User

Untitled

a guest
Nov 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.69 KB | None | 0 0
  1. local F, C = unpack(Aurora)
  2.  
  3. --[[ Get the number of bag and bank container slots used ]]
  4.  
  5. local function CheckSlots()
  6.     for i = 4, 1, -1 do
  7.         if GetContainerNumSlots(i) ~= 0 then
  8.             return i + 1
  9.         end
  10.     end
  11.     return 1
  12. end
  13.  
  14. -- [[ Local stuff ]]
  15.  
  16. local Spacing = 1
  17. local _G = _G
  18. local bu, con, bag, col, row
  19. local buttons, bankbuttons = {}, {}
  20. local firstbankopened = 1
  21.  
  22. --[[ Function to move buttons ]]
  23.  
  24. local MoveButtons = function(table, frame, columns)
  25.     col, row = 0, 0
  26.     for i = 1, #table do
  27.         bu = table[i]
  28.         bu:ClearAllPoints()
  29.         bu:SetPoint("TOPLEFT", frame, "TOPLEFT", col * (37 + Spacing) + 3, -1 * row * (37 + Spacing) - 3)
  30.         if(col > (columns - 2)) then
  31.             col = 0
  32.             row = row + 1
  33.         else
  34.             col = col + 1
  35.         end
  36.     end
  37.  
  38.     frame:SetHeight((row + (col==0 and 0 or 1)) * (37 + Spacing) + 19)
  39.     frame:SetWidth(columns * 37 + Spacing * (columns - 1) + 6)
  40.     col, row = 0, 0
  41. end
  42.  
  43. --[[ Bags ]]
  44.  
  45. local holder = CreateFrame("Button", "BagsHolder", UIParent)
  46. holder:SetPoint("BOTTOMRIGHT", UIParent, "RIGHT", -100, -180)
  47. holder:SetFrameStrata("HIGH")
  48. holder:Hide()
  49. F.CreateBD(holder, .6)
  50.  
  51. local ReanchorButtons = function()
  52.     table.wipe(buttons)
  53.     for f = 1, CheckSlots() do
  54.         con = "ContainerFrame"..f
  55.         bag = _G[con]
  56.         if not bag.reskinned then
  57.             bag:EnableMouse(false)
  58.             _G[con.."CloseButton"]:Hide()
  59.             _G[con.."PortraitButton"]:EnableMouse(false)
  60.  
  61.             for i = 1, 7 do
  62.                 select(i, bag:GetRegions()):SetAlpha(0)
  63.             end
  64.  
  65.             bag.reskinned = true
  66.         end
  67.  
  68.         for i = GetContainerNumSlots(f-1), 1, -1  do
  69.             bu = _G[con.."Item"..i]
  70.             if not bu.reskinned then
  71.                 bu:SetNormalTexture("")
  72.                 bu:SetPushedTexture("")
  73.                 bu:SetFrameStrata("HIGH")
  74.                 _G[con.."Item"..i.."Count"]:SetFont("Interface\\AddOns\\SharedMedia\\Fonts\\Pixel.ttf", 8, "OUTLINEMONOCHROME")
  75.                 _G[con.."Item"..i.."Count"]:ClearAllPoints()
  76.                 _G[con.."Item"..i.."Count"]:SetPoint("BOTTOMRIGHT", bu, 0, 1)
  77.                 _G[con.."Item"..i.."IconTexture"]:SetTexCoord(.08, .92, .08, .92)
  78.                 _G[con.."Item"..i.."IconQuestTexture"]:SetAlpha(0)
  79.                 bu.reskinned = true
  80.             end
  81.             tinsert(buttons, bu)
  82.         end
  83.     end
  84.     MoveButtons(buttons, holder, CheckSlots() + 4)
  85.     holder:Show()
  86. end
  87.  
  88. local money = _G["ContainerFrame1MoneyFrame"]
  89. money:SetFrameStrata("DIALOG")
  90. money:SetParent(holder)
  91. money:ClearAllPoints()
  92. money:SetPoint("BOTTOMRIGHT", holder, "BOTTOMRIGHT", 12, 2)
  93.  
  94. --[[ Bank ]]
  95.  
  96. local bankholder = CreateFrame("Button", "BagsBankHolder", UIParent)
  97. bankholder:SetFrameStrata("HIGH")
  98. bankholder:Hide()
  99. F.CreateBD(bankholder, .6)
  100.  
  101. local ReanchorBankButtons = function()
  102.     table.wipe(bankbuttons)
  103.     for i = 1, 28 do
  104.         bu = _G["BankFrameItem"..i]
  105.         if not bu.reskinned then
  106.             bu:SetNormalTexture("")
  107.             bu:SetPushedTexture("")
  108.             bu:SetFrameStrata("HIGH")
  109.             _G["BankFrameItem"..i.."IconTexture"]:SetTexCoord(.08, .92, .08, .92)
  110.             _G["BankFrameItem"..i.."Count"]:SetFont("Interface\\AddOns\\SharedMedia\\Fonts\\Pixel.ttf", 8, "OUTLINEMONOCHROME")
  111.             _G["BankFrameItem"..i.."Count"]:ClearAllPoints()
  112.             _G["BankFrameItem"..i.."Count"]:SetPoint("BOTTOMRIGHT", bu, 0, 2)
  113.             _G["BankFrameItem"..i.."IconQuestTexture"]:SetAlpha(0)
  114.             bu.reskinned = true
  115.         end
  116.         tinsert(bankbuttons, bu)
  117.     end
  118.  
  119.     if(firstbankopened==1) then
  120.         _G["BankFrame"]:EnableMouse(false)
  121.         _G["BankCloseButton"]:Hide()
  122.  
  123.         for f = 1, 5 do
  124.             select(f, _G["BankFrame"]:GetRegions()):SetAlpha(0)
  125.         end
  126.         bankholder:SetPoint("BOTTOMRIGHT", "BagsHolder", "BOTTOMLEFT", -10 , 0)
  127.         firstbankopened = 0
  128.     end
  129.  
  130.     for f = CheckSlots() + 1, CheckSlots() + GetNumBankSlots() + 1, 1 do
  131.         con = "ContainerFrame"..f
  132.         bag = _G[con]
  133.         if not bag.reskinned then
  134.             bag:EnableMouse(false)
  135.             bag:SetScale(1)
  136.             bag.SetScale = F.dummy
  137.             _G[con.."CloseButton"]:Hide()
  138.             _G[con.."PortraitButton"]:EnableMouse(false)
  139.  
  140.             for i = 1, 7 do
  141.                 select(i, bag:GetRegions()):SetAlpha(0)
  142.             end
  143.             bag.reskinned = true
  144.         end
  145.  
  146.         for i = GetContainerNumSlots(f-1), 1, -1  do
  147.             bu = _G[con.."Item"..i]
  148.             if not bu.reskinned then
  149.                 bu:SetNormalTexture("")
  150.                 bu:SetPushedTexture("")
  151.                 bu:SetFrameStrata("HIGH")
  152.                 _G[con.."Item"..i.."Count"]:SetFont("Interface\\AddOns\\SharedMedia\\Fonts\\Pixel.ttf", 8, "OUTLINEMONOCHROME")
  153.                 _G[con.."Item"..i.."Count"]:ClearAllPoints()
  154.                 _G[con.."Item"..i.."Count"]:SetPoint("TOP", bu, 1, -2)
  155.                 _G[con.."Item"..i.."IconTexture"]:SetTexCoord(.08, .92, .08, .92)
  156.                 _G[con.."Item"..i.."IconQuestTexture"]:SetAlpha(0)
  157.                 bu.reskinned = true
  158.             end
  159.             tinsert(bankbuttons, bu)
  160.         end
  161.     end
  162.     local _, full = GetNumBankSlots()
  163.     if full then purchase:Hide() end
  164.     MoveButtons(bankbuttons, bankholder, CheckSlots() + 8)
  165.     bankholder:Show()
  166. end
  167.  
  168. local money = _G["BankFrameMoneyFrame"]
  169. money:SetFrameStrata("DIALOG")
  170. money:ClearAllPoints()
  171. money:SetPoint("BOTTOMRIGHT", bankholder, "BOTTOMRIGHT", 12, 2)
  172.  
  173. --[[ Misc. frames ]]
  174.  
  175. _G["BankFramePurchaseInfo"]:Hide()
  176. _G["BankFramePurchaseInfo"].Show = F.dummy
  177.  
  178. local BankBagButtons = {
  179.     BankFrameBag1,
  180.     BankFrameBag2,
  181.     BankFrameBag3,
  182.     BankFrameBag4,
  183.     BankFrameBag5,
  184.     BankFrameBag6,
  185.     BankFrameBag7,
  186. }
  187.  
  188. local BagButtons = {
  189.     CharacterBag0Slot,
  190.     CharacterBag1Slot,
  191.     CharacterBag2Slot,
  192.     CharacterBag3Slot,
  193. }
  194.  
  195. local bankbagholder = CreateFrame("Frame", nil, BankFrame)
  196. bankbagholder:SetSize(289, 43)
  197. bankbagholder:SetPoint("BOTTOM", bankholder, "TOP", 0, -1)
  198. F.CreateBD(bankbagholder, .6)
  199. bankbagholder:SetAlpha(0)
  200.  
  201. bankbagholder:SetScript("OnEnter", function(self)
  202.     self:SetAlpha(1)
  203.     for _, g in pairs(BankBagButtons) do
  204.         g:SetAlpha(1)
  205.     end
  206. end)
  207. bankbagholder:SetScript("OnLeave", function(self)
  208.     self:SetAlpha(0)
  209.     for _, g in pairs(BankBagButtons) do
  210.         g:SetAlpha(0)
  211.     end
  212. end)
  213.  
  214. local bagholder = CreateFrame("Frame", nil, ContainerFrame1)
  215. bagholder:SetSize(130, 35)
  216. bagholder:SetPoint("BOTTOM", holder, "TOP", 0, -1)
  217.  
  218. bagholder:SetScript("OnEnter", function(self)
  219.     for _, g in pairs(BagButtons) do
  220.         g:SetAlpha(1)
  221.     end
  222. end)
  223. bagholder:SetScript("OnLeave", function(self)
  224.     for _, g in pairs(BagButtons) do
  225.         g:SetAlpha(0)
  226.     end
  227. end)
  228.  
  229. for i = 1, 7 do
  230.     local bag = _G["BankFrameBag"..i]
  231.     local ic = _G["BankFrameBag"..i.."IconTexture"]
  232.     _G["BankFrameBag"..i.."HighlightFrame"]:Hide()
  233.  
  234.     bag:SetParent(bankholder)
  235.     bag:ClearAllPoints()
  236.  
  237.     if i == 1 then
  238.         bag:SetPoint("BOTTOM", bankholder, "TOP", -123, 2)
  239.     else
  240.         bag:SetPoint("LEFT", _G["BankFrameBag"..i-1], "RIGHT", 4, 0)
  241.     end
  242.  
  243.     bag:SetNormalTexture("")
  244.     bag:SetPushedTexture("")
  245.  
  246.     ic:SetTexCoord(.08, .92, .08, .92)
  247.    
  248.     bag:SetAlpha(0)
  249.     bag:HookScript("OnEnter", function(self)
  250.         bankbagholder:SetAlpha(1)
  251.         for _, g in pairs(BankBagButtons) do
  252.             g:SetAlpha(1)
  253.         end
  254.     end)
  255.     bag:HookScript("OnLeave", function(self)
  256.         bankbagholder:SetAlpha(0)
  257.         for _, g in pairs(BankBagButtons) do
  258.             g:SetAlpha(0)
  259.         end
  260.     end)
  261. end
  262.  
  263. for i = 0, 3 do
  264.     local bag = _G["CharacterBag"..i.."Slot"]
  265.     local ic = _G["CharacterBag"..i.."SlotIconTexture"]
  266.  
  267.     bag:SetParent(holder)
  268.     bag:ClearAllPoints()
  269.  
  270.     if i == 0 then
  271.         bag:SetPoint("BOTTOM", holder, "TOP", -46, 1)
  272.     else
  273.         bag:SetPoint("LEFT", _G["CharacterBag"..(i-1).."Slot"], "RIGHT", 1, 0)
  274.     end
  275.  
  276.     bag:SetNormalTexture("")
  277.     bag:SetCheckedTexture("")
  278.     bag:SetPushedTexture("")
  279.  
  280.     ic:SetTexCoord(.08, .92, .08, .92)
  281.     ic:SetPoint("TOPLEFT", 1, -1)
  282.     ic:SetPoint("BOTTOMRIGHT", -1, 1)
  283.     F.CreateBD(bag)
  284.  
  285.     bag:SetAlpha(0)
  286.     bag:HookScript("OnEnter", function(self)
  287.         for _, g in pairs(BagButtons) do
  288.             g:SetAlpha(1)
  289.         end
  290.      end)
  291.     bag:HookScript("OnLeave", function(self)
  292.         for _, g in pairs(BagButtons) do
  293.             g:SetAlpha(0)
  294.         end
  295.     end)
  296. end
  297.  
  298. local moneytext = {"ContainerFrame1MoneyFrameGoldButtonText", "ContainerFrame1MoneyFrameSilverButtonText", "ContainerFrame1MoneyFrameCopperButtonText",
  299.  
  300. "BankFrameMoneyFrameGoldButtonText", "BankFrameMoneyFrameSilverButtonText", "BankFrameMoneyFrameCopperButtonText", "BackpackTokenFrameToken1Count", "BackpackTokenFrameToken2Count",
  301.  
  302. "BackpackTokenFrameToken3Count"}
  303.  
  304. for i = 1, 9 do
  305.     _G[moneytext[i]]:SetFont("Interface\\AddOns\\SharedMedia\\Fonts\\Pixel.ttf", 8, "OUTLINEMONOCHROME")
  306. end
  307.  
  308. --[[ Show & Hide functions etc ]]
  309.  
  310. tinsert(UISpecialFrames, bankholder)
  311. tinsert(UISpecialFrames, holder)
  312.  
  313. local CloseBags = function()
  314.     bankholder:Hide()
  315.     holder:Hide()
  316.     for i = 0, 11 do
  317.         CloseBag(i)
  318.     end
  319. end
  320.  
  321. local CloseBags2 = function()
  322.     bankholder:Hide()
  323.     holder:Hide()
  324.     CloseBankFrame()
  325. end
  326.  
  327. local OpenBags = function()
  328.     for i = 0, 11 do
  329.         OpenBag(i)
  330.     end
  331. end
  332.  
  333. local ToggleBags = function()
  334.     if(IsBagOpen(0)) then
  335.         CloseBankFrame()
  336.         CloseBags()
  337.     else
  338.         OpenBags()
  339.     end
  340. end
  341.  
  342. for i = 1, 5 do
  343.     local bag = _G["ContainerFrame"..i]
  344.     hooksecurefunc(bag, "Show", ReanchorButtons)
  345.     hooksecurefunc(bag, "Hide", CloseBags2)
  346.     bag.SetScale = F.dummy
  347. end
  348. hooksecurefunc(BankFrame, "Show", function()
  349.     OpenBags()
  350.     ReanchorBankButtons()
  351. end)
  352. hooksecurefunc(BankFrame, "Hide", CloseBags)
  353.  
  354. ToggleBackpack = ToggleBags
  355. OpenAllBags = OpenBags
  356. OpenBackpack = OpenBags
  357. CloseAllBags = CloseBags
  358.  
  359. -- [[ Currency ]]
  360.  
  361. BackpackTokenFrame:GetRegions():Hide()
  362. BackpackTokenFrameToken1:ClearAllPoints()
  363. BackpackTokenFrameToken1:SetPoint("BOTTOMLEFT", holder, "BOTTOMLEFT", 0, 2)
  364. for i = 1, 3 do
  365.     local bu = _G["BackpackTokenFrameToken"..i]
  366.     local ic = _G["BackpackTokenFrameToken"..i.."Icon"]
  367.     _G["BackpackTokenFrameToken"..i.."Count"]:SetShadowOffset(0, 0)
  368.  
  369.     bu:SetFrameStrata("DIALOG")
  370.     ic:SetDrawLayer("OVERLAY")
  371.     ic:SetTexCoord(.08, .92, .08, .92)
  372.  
  373.     F.CreateBG(ic)
  374. end
  375.  
  376. -- [[ Search ]]
  377.  
  378. editbox = CreateFrame("EditBox", nil, holder)
  379. editbox:SetHeight(13)
  380. editbox:SetPoint("TOPLEFT", holder, "BOTTOMLEFT", 0, 1)
  381. editbox:SetPoint("TOPRIGHT", holder, "BOTTOMRIGHT", 0, 1)
  382. editbox:SetAutoFocus(false)
  383. editbox:SetFont("Interface\\AddOns\\SharedMedia\\Fonts\\Pixel.ttf", 8, "OUTLINEMONOCHROME")
  384. editbox:SetText("Click to search...")
  385. editbox:SetJustifyH("CENTER")
  386. F.CreateBD(editbox, .6)
  387. editbox:SetAlpha(0)
  388.  
  389. local SearchUpdate = function(str, table)
  390.     str = string.lower(str)
  391.  
  392.     for _, b in ipairs(table) do
  393.         if b:GetParent() == BankFrame then
  394.             b.id = GetContainerItemID(-1, b:GetID())
  395.         else
  396.             b.id = GetContainerItemID(b:GetParent():GetID(), b:GetID())
  397.         end
  398.         if b.id then
  399.              b.name, _, _, _, _, _, _, _, b.slot = GetItemInfo(b.id)
  400.             if b.slot then b.slot = _G[b.slot] end
  401.         end
  402.         if not b.name then
  403.             b:SetAlpha(.2)
  404.             b.glow:SetAlpha(0)
  405.         elseif not string.find(string.lower(b.name), str, 1, true) and not (b.slot and string.find(string.lower(b.slot), str)) then
  406.             SetItemButtonDesaturated(b, 1, 1, 1, 1)
  407.             b:SetAlpha(.2)
  408.             b.glow:SetAlpha(0)
  409.         else
  410.             SetItemButtonDesaturated(b, 0, 1, 1, 1)
  411.             b:SetAlpha(1)
  412.             b.glow:SetAlpha(1)
  413.         end
  414.     end
  415. end
  416.  
  417. local HideSearch = function()
  418.     editbox:SetAlpha(0)
  419. end
  420.  
  421. local Reset = function(self)
  422.     self:ClearFocus()
  423.     for _, b in ipairs(buttons) do
  424.         b:SetAlpha(1)
  425.         b.glow:SetAlpha(1)
  426.         SetItemButtonDesaturated(b, 0, 1, 1, 1)
  427.     end
  428.     for _, b in ipairs(bankbuttons) do
  429.         b:SetAlpha(1)
  430.         b.glow:SetAlpha(1)
  431.         SetItemButtonDesaturated(b, 0, 1, 1, 1)
  432.     end
  433.     self:SetAlpha(0)
  434.     self:SetScript("OnLeave", HideSearch)
  435.     self:SetText("Click to search...")
  436. end
  437.  
  438. local text
  439.  
  440. local UpdateSearch = function(self, t)
  441.     if t == true then
  442.         text = self:GetText()
  443.         SearchUpdate(text, buttons)
  444.         if BankFrame:IsShown() then SearchUpdate(text, bankbuttons) end
  445.     end
  446. end
  447.  
  448. editbox:SetScript("OnEscapePressed", Reset)
  449. editbox:SetScript("OnEnterPressed", Reset)
  450. editbox:SetScript("OnTextChanged", UpdateSearch)
  451. editbox:SetScript("OnEditFocusGained", function(self)
  452.     self:HighlightText()
  453.     self:SetScript("OnLeave", nil)
  454. end)
  455.  
  456. editbox:SetScript("OnEnter", function(self)
  457.     self:SetAlpha(1)
  458. end)
  459. editbox:SetScript("OnLeave", HideSearch)
  460.  
  461. -- [[ Money ]]
  462.  
  463. local r, g, b = unpack(C.classcolours)
  464.  
  465. local function FormatTooltipMoney(money)
  466.     local gold = abs(money / 10000)
  467.     local cash = ""
  468.     cash = format("%.2d\124TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0\124t", gold)    
  469.     return cash
  470. end
  471.  
  472. local name = UnitName("player")
  473. local realm = GetRealmName()
  474.  
  475. local f = CreateFrame("Frame")
  476. f:RegisterEvent("PLAYER_MONEY")
  477. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  478. f:SetScript("OnEvent", function(self, event)
  479. end)
  480.  
  481. local function ShowMoney()
  482.     GameTooltip:SetOwner(ContainerFrame1MoneyFrameGoldButton, "ANCHOR_NONE")
  483.     GameTooltip:SetPoint("BOTTOMRIGHT", BagsHolder, "BOTTOMLEFT", -1, 0)
  484.     GameTooltip:Show()
  485. end
  486.  
  487. ContainerFrame1MoneyFrameGoldButton:HookScript("OnEnter", ShowMoney)
  488. ContainerFrame1MoneyFrameSilverButton:HookScript("OnEnter", ShowMoney)
  489. ContainerFrame1MoneyFrameCopperButton:HookScript("OnEnter", ShowMoney)
  490. ContainerFrame1MoneyFrameGoldButton:HookScript("OnLeave", GameTooltip_Hide)
  491. ContainerFrame1MoneyFrameSilverButton:HookScript("OnLeave", GameTooltip_Hide)
  492. ContainerFrame1MoneyFrameCopperButton:HookScript("OnLeave", GameTooltip_Hide)
Add Comment
Please, Sign In to add comment