From 38db472d393aaffa2328c1da52dae0ef4ac5f7ad Mon Sep 17 00:00:00 2001 From: Ou Junhui Date: Mon, 5 Jul 2021 23:53:36 +0800 Subject: [PATCH] optimize a bit --- rBag/core.lua | 50 ++++++++++++++++++++++++++------------------------ rBag/init.lua | 2 +- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/rBag/core.lua b/rBag/core.lua index e5e3f12..2ff6a74 100644 --- a/rBag/core.lua +++ b/rBag/core.lua @@ -1,3 +1,5 @@ +-- copy from inventory module of tukui +-- all credit goes to tukz local A, L = ... local Noop = function() end @@ -46,7 +48,7 @@ local BagSize = {} function Bags:SetTokensPosition() local Money = ContainerFrame1MoneyFrame - + MAX_WATCHED_TOKENS = 2 -- Set Position @@ -55,7 +57,7 @@ function Bags:SetTokensPosition() Token2:ClearAllPoints() Token2:SetPoint("LEFT", Token1, "RIGHT", 0, 0) Token3:SetParent(L.Hider) - + -- Skin Icons Token1.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) Token2.icon:SetTexCoord(0.1, 0.9, 0.1, 0.9) @@ -130,7 +132,7 @@ function Bags:CreateContainer(storagetype, ...) if (storagetype == "Bag") then local Sort = CreateFrame("Button", nil, Container) local Keys = CreateFrame("Button", nil, Container) - + Sort:SetSize(16, 16) Sort:SetPoint("TOPRIGHT", Container, "TOPRIGHT", -8, -8) Sort.Text = Sort:CreateFontString(nil, "OVERLAY") @@ -146,7 +148,7 @@ function Bags:CreateContainer(storagetype, ...) end SortBags() end) - + Keys:SetSize(16, 16) Keys:SetPoint("RIGHT", Sort, "LEFT", -5, 0) Keys.Text = Keys:CreateFontString(nil, "OVERLAY") @@ -163,7 +165,7 @@ function Bags:CreateContainer(storagetype, ...) ToggleAllBags() end end) - + Container.SortButton = Sort Container.Keys = Keys else @@ -181,7 +183,7 @@ function Bags:CreateContainer(storagetype, ...) TotalCost:SetPoint("LEFT", CostText, "RIGHT", 0, 0) PurchaseButton:ClearAllPoints() PurchaseButton:SetPoint("BOTTOMRIGHT", -10, 10) - + local SortButton = CreateFrame("Button", nil, Container) SortButton:SetSize(16, 16) SortButton:SetPoint("TOPRIGHT", Container, "TOPRIGHT", -8, -8) @@ -231,7 +233,7 @@ function Bags:CreateContainer(storagetype, ...) Bag:SetWidth(ButtonSize) Bag:SetHeight(ButtonSize) Bag:ClearAllPoints() - + if i == 1 then Bag:SetPoint("TOPLEFT", BankBagsContainer, "TOPLEFT", ButtonSpacing, -ButtonSpacing) else @@ -306,7 +308,7 @@ function Bags:SlotUpdate(id, button) button:HookScript("OnEnter", function(self) local ItemID = self.ItemID local BagID = self:GetID() - + if ItemID and BagID then local IsNewItem = C_NewItems.IsNewItem(self.ItemID, self:GetID()) @@ -316,12 +318,12 @@ function Bags:SlotUpdate(id, button) end end) end - + if not button.Animation:IsPlaying() then button.Animation:Play() end end - + if L.C.showItemLevel then if ItemLink then local Level = GetDetailedItemLevelInfo(ItemLink) @@ -336,7 +338,7 @@ function Bags:SlotUpdate(id, button) end button.ItemLevel:SetText(Level) - + if Rarity then button.ItemLevel:SetTextColor(GetItemQualityColor(Rarity)) else @@ -410,7 +412,7 @@ function Bags:BagUpdate(id) local color = RAID_CLASS_COLORS["HUNTER"] Button.TypeStatus:SetStatusBarColor(color.r, color.g, color.b) end - + self:SlotUpdate(id, Button) end end @@ -428,7 +430,7 @@ function Bags:UpdateAllBags() BagSize[i] = ContainerSize end end - + if (not NeedBagRefresh) then return end @@ -440,11 +442,11 @@ function Bags:UpdateAllBags() for Bag = 1, 5 do local ID = Bag - 1 - + if IsBagOpen(KEYRING_CONTAINER) then ID = -2 end - + local Slots = GetContainerNumSlots(ID) for Item = Slots, 1, -1 do @@ -459,7 +461,7 @@ function Bags:UpdateAllBags() Button:SetWidth(ButtonSize) Button:SetHeight(ButtonSize) Button:SetScale(1) - + Button.newitemglowAnim:Stop() Button.newitemglowAnim.Play = Noop @@ -498,7 +500,7 @@ function Bags:UpdateAllBags() end Bags:BagUpdate(ID) - + if IsBagOpen(KEYRING_CONTAINER) then break end @@ -617,7 +619,7 @@ function Bags:OpenBag(id) for i = 1, 40 do local Index = Size - i + 1 local Button = _G[OpenFrame:GetName().."Item"..i] - + if Button then if (i > Size) then Button:Hide() @@ -661,7 +663,7 @@ end function Bags:OpenAllBankBags() local Bank = BankFrame - + if Bank:IsShown() then self.Bank:Show() @@ -685,7 +687,7 @@ function Bags:CloseAllBags() end CloseAllBags() - + if IsBagOpen(KEYRING_CONTAINER) then CloseBag(KEYRING_CONTAINER) end @@ -708,12 +710,12 @@ function Bags:ToggleBags(id, openonly) CloseAllBags() CloseBankBagFrames() CloseBankFrame() - + NeedBagRefresh = true - + Bags:OpenBag(id) Bags:UpdateAllBags() - + NeedBagRefresh = true else CloseBag(id) @@ -860,7 +862,7 @@ function Bags:Enable() HelpBox:SetParent(L.Hider) end end - + OpenAllBagsMatchingContext = function() return 4 end -- Register Events for Updates diff --git a/rBag/init.lua b/rBag/init.lua index ea944c4..70d4631 100644 --- a/rBag/init.lua +++ b/rBag/init.lua @@ -24,7 +24,7 @@ local cfg = {} cfg.icon = { size = 32, spacing = 4, - columns = 12, + columns = 8, } cfg.sort = { -- 1.7.9.5