diff --git a/Interface/AddOns/SVUI/packages/bag/SVBag.lua b/Interface/AddOns/SVUI/packages/bag/SVBag.lua index 618b218..659e0d0 100644 --- a/Interface/AddOns/SVUI/packages/bag/SVBag.lua +++ b/Interface/AddOns/SVUI/packages/bag/SVBag.lua @@ -33,7 +33,7 @@ local table = _G.table; local find, format, len = string.find, string.format, string.len; local sub, byte = string.sub, string.byte; --[[ MATH METHODS ]]-- -local floor = math.floor; +local floor, ceil = math.floor, math.ceil; local twipe = table.wipe; --[[ ########################################################## @@ -211,7 +211,8 @@ function MOD:INVENTORY_SEARCH_UPDATE() end local SlotUpdate = function(self, slotID) - if(not self[slotID]) then return end + if(not self[slotID]) then return end + local bag = self:GetID() local slot, _ = self[slotID], nil; local bagType = self.bagFamily; local texture, count, locked = GetContainerItemInfo(bag, slotID) @@ -324,10 +325,37 @@ local ContainerFrame_UpdateLayout = function(self) local isBank = self.isBank local isReagent = self.isReagent - local buttonSize = isBank and SV.db.SVBag.bankSize or SV.db.SVBag.bagSize; local buttonSpacing, numContainerRows = 8, 0; - local containerWidth = (SV.db.SVBag.alignToChat == true and (isBank and (SV.db.SVDock.dockLeftWidth - 14) or (SV.db.SVDock.dockRightWidth - 14))) or (isBank and SV.db.SVBag.bankWidth) or SV.db.SVBag.bagWidth - local numContainerColumns = floor(containerWidth / (buttonSize + buttonSpacing)); + local containerWidth, numContainerColumns, buttonSize + + if(SV.db.SVBag.alignToChat) then + containerWidth = (isBank and SV.db.SVDock.dockLeftWidth or SV.db.SVDock.dockRightWidth) + local precount, avg = 0, 0.08; + for i, bagID in ipairs(self.BagIDs) do + local numSlots = GetContainerNumSlots(bagID); + precount = precount + (numSlots or 0); + end + if(precount > 287) then + avg = 0.12 + elseif(precount > 167) then + avg = 0.11 + elseif(precount > 127) then + avg = 0.1 + elseif(precount > 97) then + avg = 0.09 + end + + --local rowCalc = ceil(precount * avg); + numContainerColumns = avg * 100; + + local unitSize = floor(containerWidth / numContainerColumns) + buttonSize = unitSize - buttonSpacing; + else + containerWidth = (isBank and SV.db.SVBag.bankWidth) or SV.db.SVBag.bagWidth + buttonSize = isBank and SV.db.SVBag.bankSize or SV.db.SVBag.bagSize; + numContainerColumns = floor(containerWidth / (buttonSize + buttonSpacing)); + end + local holderWidth = ((buttonSize + buttonSpacing) * numContainerColumns) - buttonSpacing; local bottomPadding = (containerWidth - holderWidth) * 0.5; local lastButton, lastRowButton, globalName; @@ -437,7 +465,7 @@ local ContainerFrame_UpdateLayout = function(self) bag[slotID]:SetID(slotID); bag[slotID]:Size(buttonSize); - self:SlotUpdate(bagID, slotID); + bag:SlotUpdate(slotID); if bag[slotID]:GetPoint() then bag[slotID]:ClearAllPoints(); @@ -477,15 +505,20 @@ local ContainerFrame_UpdateLayout = function(self) self:Size(containerWidth, (((buttonSize + buttonSpacing) * numContainerRows) - buttonSpacing) + self.topOffset + self.bottomOffset); end -function MOD:RefreshBagFrames() - if self.BagFrame then - self.BagFrame:UpdateLayout() - end - if self.BankFrame then - self.BankFrame:UpdateLayout() - end - if self.ReagentFrame then - self.ReagentFrame:UpdateLayout() +function MOD:RefreshBagFrames(frame) + if(frame and self[frame]) then + self[frame]:UpdateLayout() + return + else + if(self.BagFrame) then + self.BagFrame:UpdateLayout() + end + if self.BankFrame then + self.BankFrame:UpdateLayout() + end + if self.ReagentFrame then + self.ReagentFrame:UpdateLayout() + end end end @@ -546,17 +579,26 @@ end function MOD:ModifyBags() local docked = SV.db.SVBag.alignToChat local anchor, x, y - if self.BagFrame then - local parent = docked and RightSuperDock or SV.UIParent - local anchor, x, y = SV.db.SVBag.bags.point, SV.db.SVBag.bags.xOffset, SV.db.SVBag.bags.yOffset - self.BagFrame:ClearAllPoints() - self.BagFrame:Point(anchor, parent, anchor, x, y) - end - if self.BankFrame then - local parent = docked and LeftSuperDock or SV.UIParent - local anchor, x, y = SV.db.SVBag.bank.point, SV.db.SVBag.bank.xOffset, SV.db.SVBag.bank.yOffset - self.BankFrame:ClearAllPoints() - self.BankFrame:Point(anchor, parent, anchor, x, y) + if(docked) then + if self.BagFrame then + self.BagFrame:ClearAllPoints() + self.BagFrame:Point("BOTTOMRIGHT", RightSuperDock, "BOTTOMRIGHT", 0, 0) + end + if self.BankFrame then + self.BankFrame:ClearAllPoints() + self.BankFrame:Point("BOTTOMLEFT", LeftSuperDock, "BOTTOMLEFT", 0, 0) + end + else + if self.BagFrame then + local anchor, x, y = SV.db.SVBag.bags.point, SV.db.SVBag.bags.xOffset, SV.db.SVBag.bags.yOffset + self.BagFrame:ClearAllPoints() + self.BagFrame:Point(anchor, SV.UIParent, anchor, x, y) + end + if self.BankFrame then + local anchor, x, y = SV.db.SVBag.bank.point, SV.db.SVBag.bank.xOffset, SV.db.SVBag.bank.yOffset + self.BankFrame:ClearAllPoints() + self.BankFrame:Point(anchor, SV.UIParent, anchor, x, y) + end end end diff --git a/Interface/AddOns/SVUI/packages/unit/elements/tags.lua b/Interface/AddOns/SVUI/packages/unit/elements/tags.lua index 91fa938..f44def7 100644 --- a/Interface/AddOns/SVUI/packages/unit/elements/tags.lua +++ b/Interface/AddOns/SVUI/packages/unit/elements/tags.lua @@ -84,7 +84,7 @@ local function SetTagStyle(style, min, max) if result <= 0 then return "" else - return ("-%s")format(TruncateString(result)) + return ("-%s"):format(TruncateString(result)) end elseif style == "PERCENT" then local prct = min / max * 100 diff --git a/Interface/AddOns/SVUI_ConfigOMatic/components/bag.lua b/Interface/AddOns/SVUI_ConfigOMatic/components/bag.lua index 66c0b59..a82f95a 100644 --- a/Interface/AddOns/SVUI_ConfigOMatic/components/bag.lua +++ b/Interface/AddOns/SVUI_ConfigOMatic/components/bag.lua @@ -82,7 +82,7 @@ SV.Options.args.SVBag = { min = 15, max = 45, step = 1, - set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD.BagFrame:UpdateLayout() end + set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD:RefreshBagFrames("BagFrame") end }, bankSize = { order = 2, @@ -92,7 +92,7 @@ SV.Options.args.SVBag = { min = 15, max = 45, step = 1, - set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD.BankFrame:UpdateLayout() end + set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD:RefreshBagFrames("BankFrame") end }, sortInverted = { order = 3, @@ -108,7 +108,7 @@ SV.Options.args.SVBag = { min = 150, max = 700, step = 1, - set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD.BagFrame:UpdateLayout() end, + set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD:RefreshBagFrames("BagFrame") end, disabled = function()return SV.db.SVBag.alignToChat end }, bankWidth = { @@ -119,7 +119,7 @@ SV.Options.args.SVBag = { min = 150, max = 700, step = 1, - set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD.BankFrame:UpdateLayout() end, + set = function(a,b) MOD:ChangeDBVar(b,a[#a]) MOD:RefreshBagFrames("BankFrame") end, disabled = function() return SV.db.SVBag.alignToChat end }, currencyFormat = { @@ -163,7 +163,7 @@ SV.Options.args.SVBag = { type = "toggle", name = L["Align To Chat"], desc = L["Align the width of the bag frame to fit inside the chat box."], - set = function(a,b)MOD:ChangeDBVar(b,a[#a]) MOD:ModifyBags() end + set = function(a,b)MOD:ChangeDBVar(b,a[#a]) MOD:RefreshBagFrames() end }, bags = { order = 2, diff --git a/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua b/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua index 2dad6ed..a6fee08 100644 --- a/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua +++ b/Interface/AddOns/SVUI_LogOMatic/SVUI_LogOMatic.lua @@ -68,7 +68,8 @@ LOCAL FUNCTIONS ########################################################## ]]-- local RefreshLoggedSlot = function(self, slotID, save) - if(not self[slotID]) then return end + if(not self[slotID]) then return end + local bag = self:GetID() local slot, _ = self[slotID], nil; local bagType = self.bagFamily; local texture, count, locked = GetContainerItemInfo(bag, slotID)