Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 31.03 KB | None | 0 0
  1. --[[
  2.     A featureless, 'pure' version of Stuffing.
  3.     This version should work on absolutely everything,
  4.     but I've removed pretty much all of the options.
  5.    
  6.     All credits of this bags script is by Stuffing and his author Hungtar.
  7.     Special Thank's to Hungtar to allow me to use his bag mod for Tukui.
  8. --]]
  9.  
  10. if not TukuiCF["bags"].enable == true then return end
  11.  
  12. local bags_BACKPACK = {0, 1, 2, 3, 4}
  13. local bags_BANK = {-1, 5, 6, 7, 8, 9, 10, 11}
  14. local BAGSFONT = TukuiCF["media"].font
  15. local ST_NORMAL = 1
  16. local ST_SPECIAL = 3
  17. local bag_bars = 0
  18.  
  19. -- hide bags options in default interface
  20. InterfaceOptionsDisplayPanelShowFreeBagSpace:Hide()
  21.  
  22. Stuffing = CreateFrame ("Frame", nil, UIParent)
  23. Stuffing:RegisterEvent("ADDON_LOADED")
  24. Stuffing:RegisterEvent("PLAYER_ENTERING_WORLD")
  25. Stuffing:SetScript("OnEvent", function(this, event, ...)
  26.     Stuffing[event](this, ...)
  27. end)
  28.  
  29. -- stub for localization.
  30. local L = setmetatable({}, {
  31.     __index = function (t, v)
  32.         t[v] = v
  33.         return v
  34.     end
  35. })
  36.  
  37.  
  38. local function Print (x)
  39.     DEFAULT_CHAT_FRAME:AddMessage("|cffC495DDTukui:|r " .. x)
  40. end
  41.  
  42. local function Stuffing_Sort(args)
  43.     if not args then
  44.         args = ""
  45.     end
  46.  
  47.     Stuffing.itmax = 0
  48.     Stuffing:SetBagsForSorting(args)
  49.     Stuffing:SortBags()
  50. end
  51.  
  52.  
  53. local function Stuffing_OnShow()
  54.     Stuffing:PLAYERBANKSLOTS_CHANGED(29)    -- XXX: hack to force bag frame update
  55.  
  56.     Stuffing:Layout()
  57.     Stuffing:SearchReset()
  58. end
  59.  
  60.  
  61. local function StuffingBank_OnHide()
  62.     CloseBankFrame()
  63.     if Stuffing.frame:IsShown() then
  64.         Stuffing.frame:Hide()
  65.     end
  66. end
  67.  
  68.  
  69. local function Stuffing_OnHide()
  70.     if Stuffing.bankFrame and Stuffing.bankFrame:IsShown() then
  71.         Stuffing.bankFrame:Hide()
  72.     end
  73. end
  74.  
  75.  
  76. local function Stuffing_Open()
  77.     Stuffing.frame:Show()
  78. end
  79.  
  80.  
  81. local function Stuffing_Close()
  82.     Stuffing.frame:Hide()
  83. end
  84.  
  85.  
  86. local function Stuffing_Toggle()
  87.     if Stuffing.frame:IsShown() then
  88.         Stuffing.frame:Hide()
  89.     else
  90.         Stuffing.frame:Show()
  91.     end
  92. end
  93.  
  94.  
  95. local function Stuffing_ToggleBag(id)
  96.     if id == -2 then
  97.         ToggleKeyRing()
  98.         return
  99.     end
  100.     Stuffing_Toggle()
  101. end
  102.  
  103.  
  104. --
  105. -- bag slot stuff
  106. --
  107. local trashParent = CreateFrame("Frame", nil, UIParent)
  108. local trashButton = {}
  109. local trashBag = {}
  110.  
  111. -- for the tooltip frame used to scan item tooltips
  112. local StuffingTT = nil
  113.  
  114. -- mostly from carg.bags_Aurora
  115. local QUEST_ITEM_STRING = nil
  116.  
  117. function Stuffing:SlotUpdate(b)
  118.     if not StuffingFrameBags:IsShown() then return end -- don't do any slot update if bags are not show
  119.     local texture, count, locked = GetContainerItemInfo (b.bag, b.slot)
  120.     local clink = GetContainerItemLink(b.bag, b.slot)
  121.    
  122.     -- set all slot color to default tukui on update
  123.     if not b.frame.lock then
  124.         b.frame:SetBackdropBorderColor(0, 0, 0)
  125.     end
  126.    
  127.     if b.Cooldown then
  128.         local cd_start, cd_finish, cd_enable = GetContainerItemCooldown(b.bag, b.slot)
  129.         CooldownFrame_SetTimer(b.Cooldown, cd_start, cd_finish, cd_enable)
  130.     end
  131.  
  132.     if(clink) then
  133.         local iType
  134.         b.name, _, b.rarity, _, _, iType = GetItemInfo(clink)
  135.        
  136.         -- color slot according to item quality
  137.         if not b.frame.lock and b.rarity and b.rarity > 1 then
  138.             b.frame:SetBackdropBorderColor(GetItemQualityColor(b.rarity))
  139.         end
  140.  
  141.             if not StuffingTT then
  142.                 StuffingTT = CreateFrame("GameTooltip", "StuffingTT", nil, "GameTooltipTemplate")
  143.                 StuffingTT:Hide()
  144.             end
  145.  
  146.             if QUEST_ITEM_STRING == nil then
  147.                 -- GetItemInfo returns a localized item type.
  148.                 -- this is to figure out what that string is.
  149.                 local t = {GetAuctionItemClasses()}
  150.                 QUEST_ITEM_STRING = t[#t]   -- #t == 12
  151.             end
  152.  
  153.             -- load tooltip, check if ITEM_BIND_QUEST ("Quest Item") is in it.
  154.             -- If the tooltip says its a quest item, we assume it is a quest item
  155.             -- and ignore the item type from GetItemInfo.
  156.             StuffingTT:SetOwner(WorldFrame, "ANCHOR_NONE")
  157.             StuffingTT:ClearLines()
  158.             StuffingTT:SetBagItem(b.bag, b.slot)
  159.             for i = 1, StuffingTT:NumLines() do
  160.                 local txt = getglobal("StuffingTTTextLeft" .. i)
  161.                 if txt then
  162.                     local text = txt:GetText()
  163.                     if string.find (txt:GetText(), ITEM_BIND_QUEST) then
  164.                         iType = QUEST_ITEM_STRING
  165.                     end
  166.                 end
  167.             end
  168.  
  169.             if iType and iType == QUEST_ITEM_STRING then
  170.                 b.qitem = true
  171.                 -- color quest item red
  172.                 if not b.frame.lock then b.frame:SetBackdropBorderColor(1.0, 0.3, 0.3) end
  173.             else
  174.                 b.qitem = nil
  175.             end
  176.     else
  177.         b.name, b.rarity, b.qitem = nil, nil, nil
  178.     end
  179.    
  180.     SetItemButtonTexture(b.frame, texture)
  181.     SetItemButtonCount(b.frame, count)
  182.     SetItemButtonDesaturated(b.frame, locked, 0.5, 0.5, 0.5)
  183.        
  184.     b.frame:Show()
  185. end
  186.  
  187.  
  188. function Stuffing:BagSlotUpdate(bag)
  189.     if not self.buttons then
  190.         return
  191.     end
  192.  
  193.     for _, v in ipairs (self.buttons) do
  194.         if v.bag == bag then
  195.             self:SlotUpdate(v)
  196.         end
  197.     end
  198. end
  199.  
  200.  
  201. function Stuffing:BagFrameSlotNew (slot, p)
  202.     for _, v in ipairs(self.bagframe_buttons) do
  203.         if v.slot == slot then
  204.             --print ("found " .. slot)
  205.             return v, false
  206.         end
  207.     end
  208.  
  209.     --print ("new " .. slot)
  210.     local ret = {}
  211.     local tpl
  212.  
  213.     if slot > 3 then
  214.         ret.slot = slot
  215.         slot = slot - 4
  216.         tpl = "BankItemButtonBagTemplate"
  217.         ret.frame = CreateFrame("CheckButton", "StuffingBBag" .. slot, p, tpl)
  218.         ret.frame:SetID(slot + 4)
  219.         table.insert(self.bagframe_buttons, ret)
  220.  
  221.         BankFrameItemButton_Update(ret.frame)
  222.         BankFrameItemButton_UpdateLocked(ret.frame)
  223.  
  224.         if not ret.frame.tooltipText then
  225.             ret.frame.tooltipText = ""
  226.         end
  227.     else
  228.         tpl = "BagSlotButtonTemplate"
  229.         ret.frame = CreateFrame("CheckButton", "StuffingFBag" .. slot .. "Slot", p, tpl)
  230.         ret.slot = slot
  231.         table.insert(self.bagframe_buttons, ret)
  232.     end
  233.  
  234.     return ret
  235. end
  236.  
  237.  
  238. function Stuffing:SlotNew (bag, slot)
  239.     for _, v in ipairs(self.buttons) do
  240.         if v.bag == bag and v.slot == slot then
  241.             return v, false
  242.         end
  243.     end
  244.  
  245.     local tpl = "ContainerFrameItemButtonTemplate"
  246.  
  247.     if bag == -1 then
  248.         tpl = "BankItemButtonGenericTemplate"
  249.     end
  250.  
  251.     local ret = {}
  252.  
  253.     if #trashButton > 0 then
  254.         local f = -1
  255.         for i, v in ipairs(trashButton) do
  256.             local b, s = v:GetName():match("(%d+)_(%d+)")
  257.  
  258.             b = tonumber(b)
  259.             s = tonumber(s)
  260.  
  261.             --print (b .. " " .. s)
  262.             if b == bag and s == slot then
  263.                 f = i
  264.                 break
  265.             end
  266.         end
  267.  
  268.         if f ~= -1 then
  269.             --print("found it")
  270.             ret.frame = trashButton[f]
  271.             table.remove(trashButton, f)
  272.         end
  273.     end
  274.  
  275.     if not ret.frame then
  276.         ret.frame = CreateFrame("Button", "StuffingBag" .. bag .. "_" .. slot, self.bags[bag], tpl)
  277.     end
  278.  
  279.     ret.bag = bag
  280.     ret.slot = slot
  281.     ret.frame:SetID(slot)
  282.  
  283.     ret.Cooldown = _G[ret.frame:GetName() .. "Cooldown"]
  284.     ret.Cooldown:Show()
  285.  
  286.     self:SlotUpdate (ret)
  287.  
  288.     return ret, true
  289. end
  290.  
  291.  
  292. -- from OneBag
  293.  
  294. local BAGTYPE_PROFESSION = 0x0008 + 0x0010 + 0x0020 + 0x0040 + 0x0080 + 0x0200 + 0x0400
  295.  
  296. function Stuffing:BagType(bag)
  297.     local bagType = select(2, GetContainerNumFreeSlots(bag))
  298.  
  299.     if bit.band(bagType, BAGTYPE_PROFESSION) > 0 then
  300.         return ST_SPECIAL
  301.     end
  302.  
  303.     return ST_NORMAL
  304. end
  305.  
  306.  
  307. function Stuffing:BagNew (bag, f)
  308.     for i, v in pairs(self.bags) do
  309.         if v:GetID() == bag then
  310.             v.bagType = self:BagType(bag)
  311.             return v
  312.         end
  313.     end
  314.  
  315.     local ret
  316.  
  317.     if #trashBag > 0 then
  318.         local f = -1
  319.         for i, v in pairs(trashBag) do
  320.             if v:GetID() == bag then
  321.                 f = i
  322.                 break
  323.             end
  324.         end
  325.  
  326.         if f ~= -1 then
  327.             --print("found bag " .. bag)
  328.             ret = trashBag[f]
  329.             table.remove(trashBag, f)
  330.             ret:Show()
  331.             ret.bagType = self:BagType(bag)
  332.             return ret
  333.         end
  334.     end
  335.  
  336.     --print("new bag " .. bag)
  337.     ret = CreateFrame("Frame", "StuffingBag" .. bag, f)
  338.     ret.bagType = self:BagType(bag)
  339.  
  340.     ret:SetID(bag)
  341.     return ret
  342. end
  343.  
  344.  
  345. function Stuffing:SearchUpdate(str)
  346.     str = string.lower(str)
  347.  
  348.     for _, b in ipairs(self.buttons) do
  349.         if b.frame and not b.name then
  350.             b.frame:SetAlpha(.2)
  351.         end
  352.         if b.name then
  353.             if not string.find (string.lower(b.name), str) then
  354.                 SetItemButtonDesaturated(b.frame, 1, 1, 1, 1)
  355.                 b.frame:SetAlpha(.2)
  356.             else
  357.                 SetItemButtonDesaturated(b.frame, 0, 1, 1, 1)
  358.                 b.frame:SetAlpha(1)
  359.             end
  360.         end
  361.     end
  362. end
  363.  
  364.  
  365. function Stuffing:SearchReset()
  366.     for _, b in ipairs(self.buttons) do
  367.         b.frame:SetAlpha(1)
  368.         SetItemButtonDesaturated(b.frame, 0, 1, 1, 1)
  369.     end
  370. end
  371.  
  372. -- drop down menu stuff from Postal
  373. local Stuffing_DDMenu = CreateFrame("Frame", "Stuffing_DropDownMenu")
  374. Stuffing_DDMenu.displayMode = "MENU"
  375. Stuffing_DDMenu.info = {}
  376. Stuffing_DDMenu.HideMenu = function()
  377.     if UIDROPDOWNMENU_OPEN_MENU == Stuffing_DDMenu then
  378.         CloseDropDownMenus()
  379.     end
  380. end
  381.  
  382. function Stuffing:CreateBagFrame(w)
  383.     local n = "StuffingFrame"  .. w
  384.     local f = CreateFrame ("Frame", n, UIParent)
  385.     f:EnableMouse(1)
  386.     f:SetMovable(1)
  387.     f:SetToplevel(1)
  388.     f:SetFrameStrata("HIGH")
  389.     f:SetFrameLevel(20)
  390.     if w == "Bank" then
  391.         f:SetPoint("BOTTOMLEFT", ChatPanel, "TOPLEFT", 0, TukuiDB.Scale(5))
  392.     else
  393.         if TukuiInfoRight:IsShown() or oUF_Tukz_focus:IsShown() then
  394.             f:SetPoint("BOTTOMRIGHT", TukuiInfoRight, "TOPRIGHT", 0, TukuiDB.Scale(5))
  395.         else
  396.             f:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", TukuiDB.Scale(-11), TukuiDB.Scale(7))
  397.         end
  398.     end
  399.    
  400.     -- close button  (Credits to Eclípsé / Smelly for this code)
  401.     f.b_close = CreateFrame("Button", "Stuffing_CloseButton" .. w, f)
  402.     f.b_close:SetWidth(TukuiDB.Scale(15))
  403.     f.b_close:SetHeight(TukuiDB.Scale(15))
  404.     TukuiDB.SetThinTemplate(f.b_close)
  405.     f.b_close:SetPoint("TOPRIGHT", TukuiDB.Scale(-12), TukuiDB.Scale(-8))
  406.     f.b_close:SetScript("OnClick", function(self, btn)
  407.         if self:GetParent():GetName() == "StuffingFrameBags" and btn == "RightButton" then
  408.             if Stuffing_DDMenu.initialize ~= Stuffing.Menu then
  409.                 CloseDropDownMenus()
  410.                 Stuffing_DDMenu.initialize = Stuffing.Menu
  411.             end
  412.             ToggleDropDownMenu(1, nil, Stuffing_DDMenu, self:GetName(), 0, 0)
  413.             return
  414.         end
  415.         self:GetParent():Hide()
  416.     end)
  417.     f.b_close:RegisterForClicks("AnyUp")
  418.    
  419.     f.b_text = f.b_close:CreateFontString(nil, "OVERLAY")
  420.     f.b_text:SetFont(TukuiCF["media"].pixelfont, TukuiCF["media"].pixelfontsize, TukuiCF["media"].fonttags)
  421.     f.b_text:SetPoint("CENTER", f.b_close, "CENTER", 1, 0)
  422.     f.b_text:SetText("X")
  423.    
  424.     f.b_close:SetScript("OnEnter", function()
  425.         local color = RAID_CLASS_COLORS[TukuiDB.myclass]
  426.         f.b_close:SetBackdropBorderColor(color.r, color.g, color.b)
  427.     end)
  428.     f.b_close:SetScript("OnLeave", function()
  429.         f.b_close:SetBackdropBorderColor(0, 0, 0)
  430.     end)
  431.  
  432.     -- create the bags frame
  433.     local fb = CreateFrame ("Frame", n .. "BagsFrame", f)
  434.     fb:SetPoint("BOTTOMLEFT", f, "TOPLEFT", 0, TukuiDB.Scale(2))
  435.     fb:SetFrameStrata("HIGH")
  436.     f.bags_frame = fb
  437.  
  438.     return f
  439. end
  440.  
  441.  
  442. function Stuffing:InitBank()
  443.     if self.bankFrame then
  444.         return
  445.     end
  446.  
  447.     local f = self:CreateBagFrame("Bank")
  448.     f:SetScript("OnHide", StuffingBank_OnHide)
  449.     self.bankFrame = f
  450. end
  451.  
  452.  
  453. local parent_startmoving = function(self)
  454.     StartMoving(self:GetParent())
  455. end
  456.  
  457.  
  458. local parent_stopmovingorsizing = function (self)
  459.     StopMoving(self:GetParent())
  460. end
  461.  
  462.  
  463. function Stuffing:InitBags()
  464.     if self.frame then
  465.         return
  466.     end
  467.  
  468.     self.buttons = {}
  469.     self.bags = {}
  470.     self.bagframe_buttons = {}
  471.  
  472.     local f = self:CreateBagFrame("Bags")
  473.     f:SetScript("OnShow", Stuffing_OnShow)
  474.     f:SetScript("OnHide", Stuffing_OnHide)
  475.  
  476.     -- search editbox (tekKonfigAboutPanel.lua)
  477.     local editbox = CreateFrame("EditBox", nil, f)
  478.     editbox:Hide()
  479.     editbox:SetAutoFocus(true)
  480.     editbox:SetHeight(TukuiDB.Scale(32))
  481.     TukuiDB.SetThinTemplate(editbox)
  482.  
  483.     local resetAndClear = function (self)
  484.         self:GetParent().detail:Show()
  485.         self:GetParent().gold:Show()
  486.         self:ClearFocus()
  487.         Stuffing:SearchReset()
  488.     end
  489.  
  490.     local updateSearch = function(self, t)
  491.         if t == true then
  492.             Stuffing:SearchUpdate(self:GetText())
  493.         end
  494.     end
  495.  
  496.     editbox:SetScript("OnEscapePressed", resetAndClear)
  497.     editbox:SetScript("OnEnterPressed", resetAndClear)
  498.     editbox:SetScript("OnEditFocusLost", editbox.Hide)
  499.     editbox:SetScript("OnEditFocusGained", editbox.HighlightText)
  500.     editbox:SetScript("OnTextChanged", updateSearch)
  501.     editbox:SetText(tukuilocal.bags_search)
  502.  
  503.  
  504.     local detail = f:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge")
  505.     detail:SetPoint("TOPLEFT", f, TukuiDB.Scale(12), TukuiDB.Scale(-10))
  506.     detail:SetPoint("RIGHT", TukuiDB.Scale(-(16 + 24)), 0)
  507.     detail:SetJustifyH("LEFT")
  508.     detail:SetText("|cff9999ff" .. "Search")
  509.     editbox:SetAllPoints(detail)
  510.  
  511.     local gold = f:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge")
  512.     gold:SetJustifyH("RIGHT")
  513.     gold:SetPoint("RIGHT", f.b_close, "LEFT", TukuiDB.Scale(-5), 0)
  514.  
  515.     f:SetScript("OnEvent", function (self, e)
  516.         self.gold:SetText(GetMoneyString(GetMoney(), 12))
  517.     end)
  518.  
  519.     f:RegisterEvent("PLAYER_MONEY")
  520.     f:RegisterEvent("PLAYER_LOGIN")
  521.     f:RegisterEvent("PLAYER_TRADE_MONEY")
  522.     f:RegisterEvent("TRADE_MONEY_CHANGED")
  523.  
  524.     local OpenEditbox = function(self)
  525.         self:GetParent().detail:Hide()
  526.         self:GetParent().gold:Hide()
  527.         self:GetParent().editbox:Show()
  528.         self:GetParent().editbox:HighlightText()
  529.     end
  530.  
  531.     local button = CreateFrame("Button", nil, f)
  532.     button:EnableMouse(1)
  533.     button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
  534.     button:SetAllPoints(detail)
  535.     button:SetScript("OnClick", function(self, btn)
  536.         if btn == "RightButton" then
  537.             OpenEditbox(self)
  538.         else
  539.             if self:GetParent().editbox:IsShown() then
  540.                 self:GetParent().editbox:Hide()
  541.                 self:GetParent().editbox:ClearFocus()
  542.                 self:GetParent().detail:Show()
  543.                 self:GetParent().gold:Show()
  544.                 Stuffing:SearchReset()
  545.             end
  546.         end
  547.     end)
  548.  
  549.     local tooltip_hide = function()
  550.         GameTooltip:Hide()
  551.     end
  552.  
  553.     local tooltip_show = function (self)
  554.         GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  555.         GameTooltip:ClearLines()
  556.         GameTooltip:SetText(tukuilocal.bags_rightclick_search)
  557.     end
  558.  
  559.     button:SetScript("OnEnter", tooltip_show)
  560.     button:SetScript("OnLeave", tooltip_hide)
  561.  
  562.     f.editbox = editbox
  563.     f.detail = detail
  564.     f.button = button
  565.     f.gold = gold
  566.     self.frame = f
  567.     f:Hide()
  568. end
  569.  
  570.  
  571. function Stuffing:Layout(lb)
  572.     local slots = 0
  573.     local rows = 0
  574.     local off = 26
  575.     local cols
  576.     local f
  577.     local bs
  578.  
  579.     if lb then
  580.         bs = bags_BANK
  581.         if TukuiCF["panels"].tinfowidth >= 405 then
  582.             cols = 11
  583.         elseif TukuiCF["panels"].tinfowidth >= 370 and TukuiCF["panels"].tinfowidth < 405 then
  584.             cols = 10
  585.         elseif TukuiCF["panels"].tinfowidth >= 335 and TukuiCF["panels"].tinfowidth < 370 then
  586.             cols = 9
  587.         else
  588.             cols = 8
  589.         end
  590.         f = self.bankFrame
  591.     else
  592.         bs = bags_BACKPACK
  593.         if TukuiCF["panels"].tinfowidth >= 405 then
  594.             cols = 11
  595.         elseif TukuiCF["panels"].tinfowidth >= 370 and TukuiCF["panels"].tinfowidth < 405 then
  596.             cols = 10
  597.         elseif TukuiCF["panels"].tinfowidth >= 335 and TukuiCF["panels"].tinfowidth < 370 then
  598.             cols = 9
  599.         else
  600.             cols = 8
  601.         end
  602.         f = self.frame
  603.  
  604.         f.gold:SetText(GetMoneyString(GetMoney(), 12))
  605.         f.editbox:SetFont(BAGSFONT, 12)
  606.         f.detail:SetFont(BAGSFONT, 12)
  607.         f.gold:SetFont(BAGSFONT, 12)
  608.  
  609.         f.detail:ClearAllPoints()
  610.         f.detail:SetPoint("TOPLEFT", f, TukuiDB.Scale(12), TukuiDB.Scale(-10))
  611.         f.detail:SetPoint("RIGHT", TukuiDB.Scale(-(16 + 24)), 0)
  612.     end
  613.  
  614.     f:SetClampedToScreen(1)
  615.     TukuiDB.SetThinTemplate(f)
  616.  
  617.  
  618.     -- bag frame stuff
  619.     local fb = f.bags_frame
  620.     if bag_bars == 1 then
  621.         fb:SetClampedToScreen(1)       
  622.         TukuiDB.SetThinTemplate(fb)
  623.  
  624.         local bsize = 30
  625.         if lb then bsize = 37 end
  626.  
  627.         local w = 2 * 12
  628.         w = w + ((#bs - 1) * bsize)
  629.         w = w + (12 * (#bs - 2))
  630.  
  631.         fb:SetHeight(TukuiDB.Scale(2 * 12 + bsize))
  632.         fb:SetWidth(TukuiDB.Scale(w))
  633.         fb:Show()
  634.     else
  635.         fb:Hide()
  636.     end
  637.  
  638.  
  639.  
  640.     local idx = 0
  641.     for _, v in ipairs(bs) do
  642.         if (not lb and v <= 3 ) or (lb and v ~= -1) then
  643.             local bsize = 30
  644.             if lb then bsize = 37 end
  645.  
  646.             local b = self:BagFrameSlotNew(v, fb)
  647.  
  648.             local xoff = 12
  649.  
  650.             xoff = xoff + (idx * bsize) -- 31)
  651.             xoff = xoff + (idx * 4)
  652.  
  653.             b.frame:ClearAllPoints()
  654.             b.frame:SetPoint("LEFT", fb, "LEFT", TukuiDB.Scale(xoff), 0)
  655.             b.frame:Show()
  656.  
  657.  
  658.             idx = idx + 1
  659.         end
  660.     end
  661.  
  662.  
  663.     for _, i in ipairs(bs) do
  664.         local x = GetContainerNumSlots(i)
  665.         if x > 0 then
  666.             if not self.bags[i] then
  667.                 self.bags[i] = self:BagNew(i, f)
  668.             end
  669.  
  670.             slots = slots + GetContainerNumSlots(i)
  671.         end
  672.     end
  673.  
  674.  
  675.     rows = floor (slots / cols)
  676.     if (slots % cols) ~= 0 then
  677.         rows = rows + 1
  678.     end
  679.  
  680.     f:SetWidth(TukuiDB.Scale(TukuiInfoRight:GetWidth()))
  681.     f:SetHeight(TukuiDB.Scale(rows * 31 + (rows - 1) * 4 + off + 12 * 2))
  682.  
  683.  
  684.     local idx = 0
  685.     for _, i in ipairs(bs) do
  686.         local bag_cnt = GetContainerNumSlots(i)
  687.  
  688.         if bag_cnt > 0 then
  689.             self.bags[i] = self:BagNew(i, f)
  690.             local bagType = self.bags[i].bagType
  691.  
  692.             self.bags[i]:Show()
  693.             for j = 1, bag_cnt do
  694.                 local b, isnew = self:SlotNew (i, j)
  695.                 local xoff
  696.                 local yoff
  697.                 local x = (idx % cols)
  698.                 local y = floor(idx / cols)
  699.  
  700.                 if isnew then
  701.                     table.insert(self.buttons, idx + 1, b)
  702.                 end
  703.  
  704.                 xoff = 12 + (x * 31)
  705.                         + (x * 4)
  706.  
  707.                 yoff = off + 12 + (y * 31)
  708.                         + ((y - 1) * 4)
  709.                 yoff = yoff * -1
  710.  
  711.                 b.frame:ClearAllPoints()
  712.                 b.frame:SetPoint("TOPLEFT", f, "TOPLEFT", TukuiDB.Scale(xoff), TukuiDB.Scale(yoff))
  713.                 b.frame:SetHeight(TukuiDB.Scale(31))
  714.                 b.frame:SetWidth(TukuiDB.Scale(31))
  715.                 b.frame:SetPushedTexture("")
  716.                 b.frame:SetNormalTexture("")
  717.                 b.frame:Show()
  718.                 TukuiDB.SetThinTemplate(b.frame)
  719.                 b.frame:SetBackdropColor(0, 0, 0, 0) -- we just need border with SetTemplate, not the backdrop. Hopefully this will fix invisible item that some users have.
  720.                 TukuiDB.StyleButton(b.frame, false)
  721.                
  722.                  -- color profession bag slot border ~yellow
  723.                  if bagType == ST_SPECIAL then b.frame:SetBackdropBorderColor(255/255, 243/255,  82/255) b.frame.lock = true end
  724.                  
  725.                 self:SlotUpdate(b)
  726.                
  727.                 local iconTex = _G[b.frame:GetName() .. "IconTexture"]
  728.                 iconTex:SetTexCoord(.08, .92, .08, .92)
  729.                 iconTex:SetPoint("TOPLEFT", b.frame, TukuiDB.Scale(1), TukuiDB.Scale(-1))
  730.                 iconTex:SetPoint("BOTTOMRIGHT", b.frame, TukuiDB.Scale(-1), TukuiDB.Scale(1))
  731.  
  732.                 iconTex:Show()
  733.                 b.iconTex = iconTex
  734.                
  735.                 idx = idx + 1
  736.             end
  737.         end
  738.     end
  739. end
  740.  
  741.  
  742. function Stuffing:SetBagsForSorting(c)
  743.     Stuffing_Open()
  744.  
  745.     self.sortBags = {}
  746.  
  747.     local cmd = ((c == nil or c == "") and {"d"} or {strsplit("/", c)})
  748.  
  749.     for _, s in ipairs(cmd) do
  750.         if s == "c" then
  751.             self.sortBags = {}
  752.         elseif s == "d" then
  753.             if not self.bankFrame or not self.bankFrame:IsShown() then
  754.                 for _, i in ipairs(bags_BACKPACK) do
  755.                     if self.bags[i] and self.bags[i].bagType == ST_NORMAL then
  756.                         table.insert(self.sortBags, i)
  757.                     end
  758.                 end
  759.             else
  760.                 for _, i in ipairs(bags_BANK) do
  761.                     if self.bags[i] and self.bags[i].bagType == ST_NORMAL then
  762.                         table.insert(self.sortBags, i)
  763.                     end
  764.                 end
  765.             end
  766.         elseif s == "p" then
  767.             if not self.bankFrame or not self.bankFrame:IsShown() then
  768.                 for _, i in ipairs(bags_BACKPACK) do
  769.                     if self.bags[i] and self.bags[i].bagType == ST_SPECIAL then
  770.                         table.insert(self.sortBags, i)
  771.                     end
  772.                 end
  773.             else
  774.                 for _, i in ipairs(bags_BANK) do
  775.                     if self.bags[i] and self.bags[i].bagType == ST_SPECIAL then
  776.                         table.insert(self.sortBags, i)
  777.                     end
  778.                 end
  779.             end
  780.         else
  781.             if tonumber(s) == nil then
  782.                 Print(string.format(L["Error: don't know what \"%s\" means."], s))
  783.             end
  784.  
  785.             table.insert(self.sortBags, tonumber(s))
  786.         end
  787.     end
  788.  
  789.     local bids = tukuilocal.bags_bids
  790.     for _, i in ipairs(self.sortBags) do
  791.         bids = bids .. i .. " "
  792.     end
  793.  
  794.     Print(bids)
  795. end
  796.  
  797.  
  798. -- slash command handler
  799. local function StuffingSlashCmd(Cmd)
  800.     local cmd, args = strsplit(" ", Cmd:lower(), 2)
  801.  
  802.     if cmd == "config" then
  803.         Stuffing_OpenConfig()
  804.     elseif cmd == "sort" then
  805.         Stuffing_Sort(args)
  806.     elseif cmd == "psort" then
  807.         Stuffing_Sort("c/p")
  808.     elseif cmd == "stack" then
  809.         Stuffing:SetBagsForSorting(args)
  810.         Stuffing:Restack()
  811.     elseif cmd == "test" then
  812.         Stuffing:SetBagsForSorting(args)
  813.     elseif cmd == "purchase" then
  814.         -- XXX
  815.         if Stuffing.bankFrame and Stuffing.bankFrame:IsShown() then
  816.             local cnt, full = GetNumBankSlots()
  817.             if full then
  818.                 Print(tukuilocal.bags_noslots)
  819.                 return
  820.             end
  821.  
  822.             if args == "yes" then
  823.                 PurchaseSlot()
  824.                 return
  825.             end
  826.  
  827.             Print(string.format(tukuilocal.bags_costs, GetBankSlotCost() / 10000))
  828.             Print(tukuilocal.bags_buyslots)
  829.         else
  830.             Print(tukuilocal.bags_openbank)
  831.         end
  832.     else
  833.         Print("sort - " .. tukuilocal.bags_sort)
  834.         Print("stack - " .. tukuilocal.bags_stack)
  835.         Print("purchase - " .. tukuilocal.bags_buybankslot)
  836.     end
  837. end
  838.  
  839.  
  840. function Stuffing:ADDON_LOADED(addon)
  841.     if addon ~= "Tukui" then
  842.         return nil
  843.     end
  844.  
  845.     self:RegisterEvent("BAG_UPDATE")
  846.     self:RegisterEvent("ITEM_LOCK_CHANGED")
  847.  
  848.     self:RegisterEvent("BANKFRAME_OPENED")
  849.     self:RegisterEvent("BANKFRAME_CLOSED")
  850.     self:RegisterEvent("PLAYERBANKSLOTS_CHANGED")
  851.  
  852.     self:RegisterEvent("BAG_CLOSED")
  853.  
  854.     SlashCmdList["STUFFING"] = StuffingSlashCmd
  855.     SLASH_STUFFING1 = "/bags"
  856.  
  857.     self:InitBags()
  858.    
  859.     tinsert(UISpecialFrames,"StuffingFrameBags")
  860.  
  861.     ToggleBackpack = Stuffing_Toggle
  862.     ToggleBag = Stuffing_ToggleBag
  863.     OpenAllBags = Stuffing_Toggle
  864.     OpenBackpack = Stuffing_Open
  865.     CloseAllBags = Stuffing_Close
  866.     CloseBackpack = Stuffing_Close
  867.  
  868.     BankFrame:UnregisterAllEvents()
  869. end
  870.  
  871. function Stuffing:PLAYER_ENTERING_WORLD()
  872.     -- please don't do anything after 1 player_entering_world event.
  873.     Stuffing:UnregisterEvent("PLAYER_ENTERING_WORLD")
  874.    
  875.     -- hooking and setting key ring bag
  876.     -- this is just a reskin of Blizzard key bag to fit Tukui
  877.     -- hooking OnShow because sometime key max slot changes.
  878.     ContainerFrame1:HookScript("OnShow", function(self)
  879.         local keybackdrop = CreateFrame("Frame", nil, self)
  880.         keybackdrop:SetPoint("TOPLEFT", TukuiDB.Scale(9), TukuiDB.Scale(-40))
  881.         keybackdrop:SetPoint("BOTTOMLEFT", 0, 0)
  882.         keybackdrop:SetSize(TukuiDB.Scale(179),TukuiDB.Scale(215))
  883.         TukuiDB.SetThinTemplate(keybackdrop)
  884.         ContainerFrame1CloseButton:Hide()
  885.         ContainerFrame1Portrait:Hide()
  886.         ContainerFrame1Name:Hide()
  887.         ContainerFrame1BackgroundTop:SetAlpha(0)
  888.         ContainerFrame1BackgroundMiddle1:SetAlpha(0)
  889.         ContainerFrame1BackgroundMiddle2:SetAlpha(0)
  890.         ContainerFrame1BackgroundBottom:SetAlpha(0)
  891.         for i=1, GetKeyRingSize() do
  892.             local slot = _G["ContainerFrame1Item"..i]
  893.             local t = _G["ContainerFrame1Item"..i.."IconTexture"]
  894.             slot:SetPushedTexture("")
  895.             slot:SetNormalTexture("")
  896.             t:SetTexCoord(.08, .92, .08, .92)
  897.             t:SetPoint("TOPLEFT", slot, TukuiDB.Scale(1), TukuiDB.Scale(-1))
  898.             t:SetPoint("BOTTOMRIGHT", slot, TukuiDB.Scale(-1), TukuiDB.Scale(1))
  899.             TukuiDB.SetThinTemplate(slot)
  900.             TukuiDB.StyleButton(slot, false)
  901.         end
  902.         self:ClearAllPoints()
  903.         if TukuiInfoRight:IsShown() or oUF_Tukz_focus:IsShown() then
  904.             self:SetPoint("BOTTOMRIGHT", TukuiInfoRight, "TOPRIGHT", TukuiDB.Scale(4), TukuiDB.Scale(5))
  905.         else
  906.             self:SetPoint("BOTTOMRIGHT", UIParent, "BOTTOMRIGHT", TukuiDB.Scale(-7), TukuiDB.Scale(7))
  907.         end
  908.     end)
  909. end
  910.  
  911. function Stuffing:PLAYERBANKSLOTS_CHANGED(id)
  912.     if id > 28 then
  913.         for _, v in ipairs(self.bagframe_buttons) do
  914.             if v.frame and v.frame.GetInventorySlot then
  915.  
  916.                 BankFrameItemButton_Update(v.frame)
  917.                 BankFrameItemButton_UpdateLocked(v.frame)
  918.  
  919.                 if not v.frame.tooltipText then
  920.                     v.frame.tooltipText = ""
  921.                 end
  922.             end
  923.         end
  924.     end
  925.  
  926.     if self.bankFrame and self.bankFrame:IsShown() then
  927.         self:BagSlotUpdate(-1)
  928.     end
  929. end
  930.  
  931.  
  932. function Stuffing:BAG_UPDATE(id)
  933.     self:BagSlotUpdate(id)
  934. end
  935.  
  936.  
  937. function Stuffing:ITEM_LOCK_CHANGED(bag, slot)
  938.     if slot == nil then
  939.         return
  940.     end
  941.  
  942.     for _, v in ipairs(self.buttons) do
  943.         if v.bag == bag and v.slot == slot then
  944.             self:SlotUpdate(v)
  945.             break
  946.         end
  947.     end
  948. end
  949.  
  950.  
  951. function Stuffing:BANKFRAME_OPENED()
  952.     Stuffing_Open()
  953.     if not self.bankFrame then
  954.         self:InitBank()
  955.     end
  956.  
  957.     self:Layout(true)
  958.     for _, x in ipairs(bags_BANK) do
  959.         self:BagSlotUpdate(x)
  960.     end
  961.     self.bankFrame:Show()
  962. end
  963.  
  964.  
  965. function Stuffing:BANKFRAME_CLOSED()
  966.     if not self.bankFrame then
  967.         return
  968.     end
  969.  
  970.     self.bankFrame:Hide()
  971. end
  972.  
  973.  
  974. function Stuffing:BAG_CLOSED(id)
  975.     local b = self.bags[id]
  976.     if b then
  977.         table.remove(self.bags, id)
  978.         b:Hide()
  979.         table.insert (trashBag, #trashBag + 1, b)
  980.     end
  981.  
  982.     while true do
  983.         local changed = false
  984.  
  985.         for i, v in ipairs(self.buttons) do
  986.             if v.bag == id then
  987.                 v.frame:Hide()
  988.                 v.iconTex:Hide()
  989.  
  990.                 table.insert (trashButton, #trashButton + 1, v.frame)
  991.                 table.remove(self.buttons, i)
  992.  
  993.                 v = nil
  994.                 changed = true
  995.             end
  996.         end
  997.  
  998.         if not changed then
  999.             break
  1000.         end
  1001.     end
  1002. end
  1003.  
  1004.  
  1005. function Stuffing:SortOnUpdate(e)
  1006.     if not self.elapsed then
  1007.         self.elapsed = 0
  1008.     end
  1009.  
  1010.     if not self.itmax then
  1011.         self.itmax = 0
  1012.     end
  1013.  
  1014.     self.elapsed = self.elapsed + e
  1015.  
  1016.     if self.elapsed < 0.1 then
  1017.         return
  1018.     end
  1019.  
  1020.     self.elapsed = 0
  1021.     self.itmax = self.itmax + 1
  1022.  
  1023.     local changed, blocked  = false, false
  1024.  
  1025.     if self.sortList == nil or next(self.sortList, nil) == nil then
  1026.         -- wait for all item locks to be released.
  1027.         local locks = false
  1028.  
  1029.         for i, v in pairs(self.buttons) do
  1030.             local _, _, l = GetContainerItemInfo(v.bag, v.slot)
  1031.             if l then
  1032.                 locks = true
  1033.             else
  1034.                 v.block = false
  1035.             end
  1036.         end
  1037.  
  1038.         if locks then
  1039.             -- something still locked. wait some more.
  1040.             return
  1041.         else
  1042.             -- all unlocked. get a new table.
  1043.             self:SetScript("OnUpdate", nil)
  1044.             self:SortBags()
  1045.  
  1046.             if self.sortList == nil then
  1047.                 return
  1048.             end
  1049.         end
  1050.     end
  1051.  
  1052.     -- go through the list and move stuff if we can.
  1053.     for i, v in ipairs (self.sortList) do
  1054.         repeat
  1055.             if v.ignore then
  1056.                 blocked = true
  1057.                 break
  1058.             end
  1059.  
  1060.             if v.srcSlot.block then
  1061.                 changed = true
  1062.                 break
  1063.             end
  1064.  
  1065.             if v.dstSlot.block then
  1066.                 changed = true
  1067.                 break
  1068.             end
  1069.  
  1070.             local _, _, l1 = GetContainerItemInfo(v.dstSlot.bag, v.dstSlot.slot)
  1071.             local _, _, l2 = GetContainerItemInfo(v.srcSlot.bag, v.srcSlot.slot)
  1072.  
  1073.             if l1 then
  1074.                 v.dstSlot.block = true
  1075.             end
  1076.  
  1077.             if l2 then
  1078.                 v.srcSlot.block = true
  1079.             end
  1080.  
  1081.             if l1 or l2 then
  1082.                 break
  1083.             end
  1084.  
  1085.             if v.sbag ~= v.dbag or v.sslot ~= v.dslot then
  1086.                 if v.srcSlot.name ~= v.dstSlot.name then
  1087.                     v.srcSlot.block = true
  1088.                     v.dstSlot.block = true
  1089.                     PickupContainerItem (v.sbag, v.sslot)
  1090.                     PickupContainerItem (v.dbag, v.dslot)
  1091.                     changed = true
  1092.                     break
  1093.                 end
  1094.             end
  1095.         until true
  1096.     end
  1097.  
  1098.     self.sortList = nil
  1099.  
  1100.     if (not changed and not blocked) or self.itmax > 250 then
  1101.         self:SetScript("OnUpdate", nil)
  1102.         self.sortList = nil
  1103.         Print (tukuilocal.bags_sortingbags)
  1104.     end
  1105. end
  1106.  
  1107.  
  1108. local function InBags(x)
  1109.     if not Stuffing.bags[x] then
  1110.         return false
  1111.     end
  1112.  
  1113.     for _, v in ipairs(Stuffing.sortBags) do
  1114.         if x == v then
  1115.             return true
  1116.         end
  1117.     end
  1118.     return false
  1119. end
  1120.  
  1121.  
  1122. function Stuffing:SortBags()
  1123.     local bs = self.sortBags
  1124.     if #bs < 1 then
  1125.         Print (tukuilocal.bags_nothingsort)
  1126.         return
  1127.     end
  1128.  
  1129.     local st = {}
  1130.     local bank = false
  1131.  
  1132.     Stuffing_Open()
  1133.  
  1134.     for i, v in pairs(self.buttons) do
  1135.         if InBags(v.bag) then
  1136.             self:SlotUpdate(v)
  1137.  
  1138.             if v.name then
  1139.                 local tex, cnt, _, _, _, _, clink = GetContainerItemInfo(v.bag, v.slot)
  1140.                 local n, _, q, iL, rL, c1, c2, _, Sl = GetItemInfo(clink)
  1141.                 table.insert(st, {
  1142.                     srcSlot = v,
  1143.                     sslot = v.slot,
  1144.                     sbag = v.bag,
  1145.                     --sort = q .. iL .. c1 .. c2 .. rL .. Sl .. n .. i,
  1146.                     --sort = q .. iL .. c1 .. c2 .. rL .. Sl .. n .. (#self.buttons - i),
  1147.                     sort = q .. c1 .. c2 .. rL .. n .. iL .. Sl .. (#self.buttons - i),
  1148.                     --sort = q .. (#self.buttons - i) .. n,
  1149.                 })
  1150.             end
  1151.         end
  1152.     end
  1153.  
  1154.     -- sort them
  1155.     table.sort (st, function(a, b)
  1156.         return a.sort > b.sort
  1157.     end)
  1158.  
  1159.     -- for each button we want to sort, get a destination button
  1160.     local st_idx = #bs
  1161.     local dbag = bs[st_idx]
  1162.     local dslot = GetContainerNumSlots(dbag)
  1163.  
  1164.     for i, v in ipairs (st) do
  1165.         v.dbag = dbag
  1166.         v.dslot = dslot
  1167.         v.dstSlot = self:SlotNew(dbag, dslot)
  1168.  
  1169.         dslot = dslot - 1
  1170.  
  1171.         if dslot == 0 then
  1172.             while true do
  1173.                 st_idx = st_idx - 1
  1174.  
  1175.                 if st_idx < 0 then
  1176.                     break
  1177.                 end
  1178.  
  1179.                 dbag = bs[st_idx]
  1180.  
  1181.                 if Stuffing:BagType(dbag) == ST_NORMAL or dbag < 1 then
  1182.                     break
  1183.                 end
  1184.             end
  1185.  
  1186.             dslot = GetContainerNumSlots(dbag)
  1187.         end
  1188.     end
  1189.  
  1190.     -- throw various stuff out of the search list
  1191.     local changed = true
  1192.     while changed do
  1193.         changed = false
  1194.         -- XXX why doesn't this remove all x->x moves in one pass?
  1195.  
  1196.         for i, v in ipairs (st) do
  1197.  
  1198.             -- source is same as destination
  1199.             if (v.sslot == v.dslot) and (v.sbag == v.dbag) then
  1200.                 table.remove (st, i)
  1201.                 changed = true
  1202.             end
  1203.         end
  1204.     end
  1205.  
  1206.     -- kick off moving of stuff, if needed.
  1207.     if st == nil or next(st, nil) == nil then
  1208.         Print(tukuilocal.bags_sortingbags)
  1209.         self:SetScript("OnUpdate", nil)
  1210.     else
  1211.         self.sortList = st
  1212.         self:SetScript("OnUpdate", Stuffing.SortOnUpdate)
  1213.     end
  1214. end
  1215.  
  1216.  
  1217. function Stuffing:RestackOnUpdate(e)
  1218.     if not self.elapsed then
  1219.         self.elapsed = 0
  1220.     end
  1221.  
  1222.     self.elapsed = self.elapsed + e
  1223.  
  1224.     if self.elapsed < 0.1 then
  1225.         return
  1226.     end
  1227.  
  1228.     self.elapsed = 0
  1229.     self:Restack()
  1230. end
  1231.  
  1232.  
  1233. function Stuffing:Restack()
  1234.     local st = {}
  1235.  
  1236.     Stuffing_Open()
  1237.  
  1238.     for i, v in pairs(self.buttons) do
  1239.         if InBags(v.bag) then
  1240.             local tex, cnt, _, _, _, _, clink = GetContainerItemInfo(v.bag, v.slot)
  1241.             if clink then
  1242.                 local n, _, _, _, _, _, _, s = GetItemInfo(clink)
  1243.  
  1244.                 if cnt ~= s then
  1245.                     if not st[n] then
  1246.                         st[n] = {{
  1247.                             item = v,
  1248.                             size = cnt,
  1249.                             max = s
  1250.                         }}
  1251.                     else
  1252.                         table.insert(st[n], {
  1253.                             item = v,
  1254.                             size = cnt,
  1255.                             max = s
  1256.                         })
  1257.                     end
  1258.                 end
  1259.             end
  1260.         end
  1261.     end
  1262.  
  1263.     local did_restack = false
  1264.  
  1265.     for i, v in pairs(st) do
  1266.         if #v > 1 then
  1267.             for j = 2, #v, 2 do
  1268.                 local a, b = v[j - 1], v[j]
  1269.                 local _, _, l1 = GetContainerItemInfo(a.item.bag, a.item.slot)
  1270.                 local _, _, l2 = GetContainerItemInfo(b.item.bag, b.item.slot)
  1271.  
  1272.                 if l1 or l2 then
  1273.                     did_restack = true
  1274.                 else
  1275.                     PickupContainerItem (a.item.bag, a.item.slot)
  1276.                     PickupContainerItem (b.item.bag, b.item.slot)
  1277.                     did_restack = true
  1278.                 end
  1279.             end
  1280.         end
  1281.     end
  1282.  
  1283.     if did_restack then
  1284.         self:SetScript("OnUpdate", Stuffing.RestackOnUpdate)
  1285.     else
  1286.         self:SetScript("OnUpdate", nil)
  1287.         Print (tukuilocal.bags_stackend)
  1288.     end
  1289. end
  1290.  
  1291. function Stuffing.Menu(self, level)
  1292.     if not level then
  1293.         return
  1294.     end
  1295.  
  1296.     local info = self.info
  1297.  
  1298.     wipe(info)
  1299.  
  1300.     if level ~= 1 then
  1301.         return
  1302.     end
  1303.  
  1304.     wipe(info)
  1305.     info.text = tukuilocal.bags_sortmenu
  1306.     info.notCheckable = 1
  1307.     info.func = function()
  1308.         Stuffing_Sort("d")
  1309.     end
  1310.     UIDropDownMenu_AddButton(info, level)
  1311.    
  1312.     wipe(info)
  1313.     info.text = tukuilocal.bags_sortspecial
  1314.     info.notCheckable = 1
  1315.     info.func = function()
  1316.         Stuffing_Sort("c/p")
  1317.     end
  1318.     UIDropDownMenu_AddButton(info, level)
  1319.  
  1320.     wipe(info)
  1321.     info.text = tukuilocal.bags_stackmenu
  1322.     info.notCheckable = 1
  1323.     info.func = function()
  1324.         Stuffing:SetBagsForSorting("d")
  1325.         Stuffing:Restack()
  1326.     end
  1327.     UIDropDownMenu_AddButton(info, level)
  1328.    
  1329.     wipe(info)
  1330.     info.text = tukuilocal.bags_stackspecial
  1331.     info.notCheckable = 1
  1332.     info.func = function()
  1333.         Stuffing:SetBagsForSorting("c/p")
  1334.         Stuffing:Restack()
  1335.     end
  1336.     UIDropDownMenu_AddButton(info, level)
  1337.  
  1338.     wipe(info)
  1339.     info.text = tukuilocal.bags_showbags
  1340.     info.checked = function()
  1341.         return bag_bars == 1
  1342.     end
  1343.  
  1344.     info.func = function()
  1345.         if bag_bars == 1 then
  1346.             bag_bars = 0
  1347.         else
  1348.             bag_bars = 1
  1349.         end
  1350.         Stuffing:Layout()
  1351.         if Stuffing.bankFrame and Stuffing.bankFrame:IsShown() then
  1352.             Stuffing:Layout(true)
  1353.         end
  1354.  
  1355.     end
  1356.     UIDropDownMenu_AddButton(info, level)
  1357.  
  1358.     wipe(info)
  1359.     info.disabled = nil
  1360.     info.notCheckable = 1
  1361.     info.text = CLOSE
  1362.     info.func = self.HideMenu
  1363.     info.tooltipTitle = CLOSE
  1364.     UIDropDownMenu_AddButton(info, level)
  1365. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement