Quantcast

fixed sorting

Steven Jackson [10-10-14 - 05:55]
fixed sorting
Filename
Interface/AddOns/SVUI/packages/bag/SVBag.lua
Interface/AddOns/SVUI/packages/bag/tools/sorting.lua
diff --git a/Interface/AddOns/SVUI/packages/bag/SVBag.lua b/Interface/AddOns/SVUI/packages/bag/SVBag.lua
index c553710..8a1e8cd 100644
--- a/Interface/AddOns/SVUI/packages/bag/SVBag.lua
+++ b/Interface/AddOns/SVUI/packages/bag/SVBag.lua
@@ -297,6 +297,15 @@ local BagMenu_OnLeave = function(self)
 	end
 end

+local BAG_FILTER_LABELS = _G.BAG_FILTER_LABELS;
+
+local BagMenu_OnClick = function(self)
+	if IsShiftKeyDown() then
+		print("Unavailable until WoD")
+		--SetBagSlotFlag(self.id, LE_BAG_FILTER_FLAG_EQUIPMENT, true)
+	end
+end
+
 local ContainerFrame_UpdateCooldowns = function(self)
 	for bagID, bag in ipairs(self.Bags) do
 		for slotID = 1, GetContainerNumSlots(bagID)do
@@ -395,12 +404,17 @@ local ContainerFrame_UpdateLayout = function(self)
 					bagSlot.iconTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9)

 					bagSlot:HookScript("OnEnter", BagMenu_OnEnter)
-					bagSlot:HookScript("OnLeave", BagMenu_OnLeave)
+					bagSlot:HookScript("OnLeave", BagMenu_OnLeave)
+
+					if(not bagSlot.tooltipText) then
+						bagSlot.tooltipText = ""
+					end

 					if(isBank) then
 						bagSlot:SetID(bagID)
 						bagSlot.id = bagID;
 					else
+						bagSlot:HookScript("OnClick", BagMenu_OnClick)
 						bagSlot.id = (bagID + 1);
 					end

@@ -532,6 +546,79 @@ local ContainerFrame_UpdateLayout = function(self)
 				end
 			end
 		end
+	else
+		local bag;
+		local bagName = ("%sBag%d"):format(containerName, 1)
+
+		if not self.Bags[1] then
+			bag = CreateFrame("Frame", bagName, self);
+			bag:SetID(1);
+			bag.numSlots = numSlots;
+			bag.SlotUpdate = SlotUpdate;
+			bag.RefreshSlots = RefreshSlots;
+			self.Bags[1] = bag
+		else
+			bag = self.Bags[1]
+		end
+
+		bag.bagFamily = false;
+
+		for slotID = 1, 98 do
+			local slot;
+			totalSlots = totalSlots + 1;
+
+			if not bag[slotID] then
+				local slotName = ("%sSlot%d"):format(bagName, slotID)
+				local newTexName = ("%sNewItemTexture"):format(slotName)
+				local iconName = ("%sIconTexture"):format(slotName)
+				local cdName = ("%sCooldown"):format(slotName)
+
+				slot = CreateFrame("CheckButton", slotName, bag, template);
+				slot:SetNormalTexture(nil);
+				slot:SetCheckedTexture(nil);
+				slot:SetSlotTemplate(true, 2, 0, 0, true);
+
+				if(_G[newTexName]) then
+					_G[newTexName]:Hide()
+				end
+
+				slot.iconTexture = _G[iconName];
+				slot.iconTexture:FillInner(slot);
+				slot.iconTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9);
+				slot.cooldown = _G[cdName];
+
+				SV.Timers:AddCooldown(slot.cooldown)
+
+				bag[slotID] = slot
+			else
+				slot = bag[slotID]
+			end
+
+			slot:SetID(slotID);
+			slot:Size(buttonSize);
+			bag:SlotUpdate(slotID);
+
+			if slot:GetPoint() then
+				slot:ClearAllPoints();
+			end
+
+			if lastButton then
+				if((totalSlots - 1) % numContainerColumns == 0) then
+					slot:Point("TOP", lastRowButton, "BOTTOM", 0, -buttonSpacing);
+					numContainerRows = numContainerRows + 1;
+					lastRowButton = slot;
+				else
+					slot:Point("LEFT", lastButton, "RIGHT", buttonSpacing, 0);
+				end
+			else
+				slot:Point("TOPLEFT", self.holderFrame, "TOPLEFT");
+				numContainerRows = numContainerRows + 1;
+				lastRowButton = slot;
+			end
+
+			lastButton = slot;
+		end
+
 	end

 	self:Size(containerWidth, (((buttonSize + buttonSpacing) * numContainerRows) - buttonSpacing) + self.topOffset + self.bottomOffset);
@@ -1224,7 +1311,7 @@ do
 		frame.sortButton.ttText = L["Sort Bags"]
 		frame.sortButton:SetScript("OnEnter", Tooltip_Show)
 		frame.sortButton:SetScript("OnLeave", Tooltip_Hide)
-		local Sort_OnClick = (SV.GameVersion >= 60000) and BankFrame_AutoSortButtonOnClick or MOD:RunSortingProcess(MOD.Sort, "bank")
+		local Sort_OnClick = (SV.GameVersion >= 60000) and SortBankBags or MOD:RunSortingProcess(MOD.Sort, "bank")
 		frame.sortButton:SetScript("OnClick", Sort_OnClick)

 		frame.stackButton = CreateFrame("Button", nil, frame)
diff --git a/Interface/AddOns/SVUI/packages/bag/tools/sorting.lua b/Interface/AddOns/SVUI/packages/bag/tools/sorting.lua
index be4c4d4..56c243f 100644
--- a/Interface/AddOns/SVUI/packages/bag/tools/sorting.lua
+++ b/Interface/AddOns/SVUI/packages/bag/tools/sorting.lua
@@ -588,7 +588,7 @@ do
 		for _, bag, slot in IterateBagsForSorting(bags, true, "withdraw") do
 			local sourceSlot = (bag*100) + slot
 			local itemID = sortingCache[2][sourceSlot]
-			if itemID and targetItems[itemID] and (canMove == true or canMove(itemID, bag, slot)) then
+			if itemID and targetItems[itemID] and (canMove == true or (type(canMove) == "function" and canMove(itemID, bag, slot))) then
 				for i = #targetSlots, 1, -1 do
 					local targetedSlot = targetSlots[i]
 					if sortingCache[2][sourceSlot] and sortingCache[2][targetedSlot] == itemID and targetedSlot ~= sourceSlot and not (sortingCache[4][targetedSlot] == sortingCache[5][targetedSlot]) and not sourceUsed[targetedSlot] then