Quantcast

Reverted frame creation for queue display.

pschifferer [02-24-09 - 05:42]
Reverted frame creation for queue display.
Made string values in queue item template blank by default.
Filename
CauldronMain.xml
CauldronMainUI.lua
diff --git a/CauldronMain.xml b/CauldronMain.xml
index 7aec0a2..3cdf6b8 100644
--- a/CauldronMain.xml
+++ b/CauldronMain.xml
@@ -286,7 +286,7 @@
 			<Layer level="OVERLAY">
 	    		<!-- item name -->
 				<FontString name="$parentItemName" inherits="GameFontNormal"
-							text="(name)" justifyH="LEFT" justifyV="CENTER">
+							text="" justifyH="LEFT" justifyV="CENTER">
 					<Size x="250" y="12"/>
 					<Anchors>
 						<Anchor point="TOPLEFT">
@@ -297,7 +297,7 @@
 				</FontString>
 				<!-- quantity info -->
 				<FontString name="$parentInfo" inherits="GameFontNormal"
-							text="(info)" justifyH="LEFT" justifyV="CENTER">
+							text="" justifyH="LEFT" justifyV="CENTER">
 					<Size x="250" y="12"/>
 					<Anchors>
 						<Anchor point="TOPLEFT">
diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua
index a43dada..b5bbf1d 100644
--- a/CauldronMainUI.lua
+++ b/CauldronMainUI.lua
@@ -586,10 +586,9 @@ function Cauldron:UpdateQueue()

 	local height = 0;

-	local f = 0;
-
 	CauldronQueueFrameScrollFrameQueueSectionsMainItemsHeaderText:SetText(L["In order to make:"]);
 	-- adjust the scroll child size
+	self:debug("set main section height for "..#itemQueue.." items: "..(#itemQueue * itemFrameHeight));
 	CauldronQueueFrameScrollFrameQueueSectionsMainItems:SetHeight(#itemQueue * itemFrameHeight);

 	for i, queueInfo in ipairs(itemQueue) do
@@ -597,19 +596,21 @@ function Cauldron:UpdateQueue()
 		self:debug("queueInfo: name="..queueInfo.name);
 --@end-alpha@

-		f = f + 1;
-
-		local queueItemFrame = _G["CauldronQueueItem"..f];
+		local queueItemFrame = _G["CauldronQueueItem"..i];
+		self:debug("queueItemFrame: "..tostring(queueItemFrame));

 		-- check if we have a frame for this position
 		if not queueItemFrame then
-			-- create a new frame for the skill information
+			-- create a new frame for the queue information
+			self:debug("create a new frame for item "..i..": "..queueInfo.name);
 			queueItemFrame = CreateFrame("Button",
-									 	 "CauldronQueueItem"..f,
+									 	 "CauldronQueueItem"..i,
 									 	 CauldronQueueFrameScrollFrameQueueSectionsMainItems,
 									 	 "CauldronQueueItemFrameTemplate");
 	    else
-	    	-- set the frame's parent
+	    	self:debug("use existing frame for item "..i..": "..queueInfo.name);
+
+	    	-- set the frame's parent
 	    	queueItemFrame:SetParent(CauldronQueueFrameScrollFrameQueueSectionsMainItems);
 		end

@@ -624,12 +625,12 @@ function Cauldron:UpdateQueue()
 		queueItemFrame.shoppable = false;
 		queueItemFrame.inHoverButtons = false;

-		_G["CauldronQueueItem"..f.."RemoveItem"]:Hide();
-		_G["CauldronQueueItem"..f.."RemoveItem"]:SetScale(0.75);
-		_G["CauldronQueueItem"..f.."IncreasePriority"]:Hide();
-		_G["CauldronQueueItem"..f.."DecreasePriority"]:Hide();
-		_G["CauldronQueueItem"..f.."DecrementCount"]:Hide();
-		_G["CauldronQueueItem"..f.."AddToShoppingList"]:Hide();
+		_G["CauldronQueueItem"..i.."RemoveItem"]:Hide();
+		_G["CauldronQueueItem"..i.."RemoveItem"]:SetScale(0.75);
+		_G["CauldronQueueItem"..i.."IncreasePriority"]:Hide();
+		_G["CauldronQueueItem"..i.."DecreasePriority"]:Hide();
+		_G["CauldronQueueItem"..i.."DecrementCount"]:Hide();
+		_G["CauldronQueueItem"..i.."AddToShoppingList"]:Hide();

 		local skillInfo = Cauldron:GetSkillInfo(queueInfo.tradeskill, queueInfo.name);
 		if not skillInfo then
@@ -641,7 +642,7 @@ function Cauldron:UpdateQueue()
 		local frame = nil;

 		-- set name and difficulty color
-		frame = _G["CauldronQueueItem"..f.."ItemName"];
+		frame = _G["CauldronQueueItem"..i.."ItemName"];
 		frame:SetText(queueInfo.name);
 		if skillInfo then
 			local color = TradeSkillTypeColor[skillInfo.difficulty];
@@ -658,7 +659,7 @@ function Cauldron:UpdateQueue()
 		end

 		-- set quantity info
-		frame = _G["CauldronQueueItem"..f.."Info"];
+		frame = _G["CauldronQueueItem"..i.."Info"];
 		local infoText = queueInfo.tradeskill;
 		-- TODO: alts/bank/etc.
 		frame:SetText(infoText);
@@ -666,21 +667,21 @@ function Cauldron:UpdateQueue()
 --		frame:SetShadowOffset(0, 0);

 		-- set the icon
-		frame = _G["CauldronQueueItem"..f.."Icon"];
+		frame = _G["CauldronQueueItem"..i.."Icon"];
 		frame:SetNormalTexture(queueInfo.icon);
 		frame.link = queueInfo.link;

 		-- set the amount
-		frame = _G["CauldronQueueItem"..f.."IconCount"];
+		frame = _G["CauldronQueueItem"..i.."IconCount"];
 		frame:SetText(queueInfo.amount);

 		-- place the frame in the scroll view
-		if f > 1 then
+		if i > 1 then
 			-- anchor to the frame above
 --@alpha@
 			self:debug("UpdateQueue: anchor frame to top left of frame above");
 --@end-alpha@
-			queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueItem"..tostring(f-1)], "BOTTOMLEFT", 0, 0);
+			queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueItem"..(i-1)], "BOTTOMLEFT", 0, 0);
 		else
 			-- anchor to the parent
 --@alpha@
@@ -700,7 +701,7 @@ function Cauldron:UpdateQueue()
 	end

 	-- hide any remaining frames
-	local j = f + 1;
+	local j = #itemQueue + 1;
 	while true do
 		local frame = _G["CauldronQueueItem"..j];
 		if not frame then
@@ -746,33 +747,31 @@ function Cauldron:UpdateQueue()
 --@alpha@
 			self:debug("intQueue: name="..queueInfo.name);
 --@end-alpha@
-
-			f = f + 1;

-			local queueItemFrame = _G["CauldronQueueItem"..f];
+			local queueItemFrame = _G["CauldronQueueIntItem"..i];

 			-- check if we have a frame for this position
 			if not queueItemFrame then
 				-- create a new frame for the skill information
 				queueItemFrame = CreateFrame("Button",
-											 "CauldronQueueItem"..f,
+											 "CauldronQueueIntItem"..i,
 											 CauldronQueueFrameScrollFrameQueueSectionsSecondaryItems,
 											 "CauldronQueueItemFrameTemplate");
 			end

-			queueItemFrame:SetID(f);
+			queueItemFrame:SetID(i);
 			queueItemFrame.itemName = queueInfo.name;
 			queueItemFrame.removeable = false;
 			queueItemFrame.shoppable = false;
 			queueItemFrame.inHoverButtons = false;

 			-- don't show the remove button
-			_G["CauldronQueueItem"..f.."RemoveItem"]:Hide();
-			_G["CauldronQueueItem"..f.."RemoveItem"]:SetScale(0.75);
-			_G["CauldronQueueItem"..f.."IncreasePriority"]:Hide();
-			_G["CauldronQueueItem"..f.."DecreasePriority"]:Hide();
-			_G["CauldronQueueItem"..f.."DecrementCount"]:Hide();
-			_G["CauldronQueueItem"..f.."AddToShoppingList"]:Hide();
+			_G["CauldronQueueIntItem"..i.."RemoveItem"]:Hide();
+			_G["CauldronQueueIntItem"..i.."RemoveItem"]:SetScale(0.75);
+			_G["CauldronQueueIntItem"..i.."IncreasePriority"]:Hide();
+			_G["CauldronQueueIntItem"..i.."DecreasePriority"]:Hide();
+			_G["CauldronQueueIntItem"..i.."DecrementCount"]:Hide();
+			_G["CauldronQueueIntItem"..i.."AddToShoppingList"]:Hide();

 			local skillInfo = Cauldron:GetSkillInfo(queueInfo.tradeskill, queueInfo.name);
 			if not skillInfo then
@@ -787,7 +786,7 @@ function Cauldron:UpdateQueue()
 			local frame = nil;

 			-- set name and difficulty color
-			frame = _G["CauldronQueueItem"..f.."ItemName"];
+			frame = _G["CauldronQueueIntItem"..i.."ItemName"];
 			frame:SetText(queueInfo.name);
 			if skillInfo then
 				local color = TradeSkillTypeColor[skillInfo.difficulty];
@@ -807,7 +806,7 @@ function Cauldron:UpdateQueue()
 			end

 			-- set quantity info
-			frame = _G["CauldronQueueItem"..f.."Info"];
+			frame = _G["CauldronQueueIntItem"..i.."Info"];
 			local countInfo = Cauldron:ReagentCount(queueInfo.name);
 			local infoText = string.format(queueInfo.tradeskill.."; "..L["Have %d"], countInfo.has);
 			if countInfo.bank > 0 then
@@ -823,21 +822,21 @@ function Cauldron:UpdateQueue()
 			frame:SetShadowOffset(0, 0);

 			-- set the icon
-			frame = _G["CauldronQueueItem"..f.."Icon"];
+			frame = _G["CauldronQueueIntItem"..i.."Icon"];
 			frame:SetNormalTexture(queueInfo.icon);
 			frame.link = queueInfo.link;

 			-- set the amount
-			frame = _G["CauldronQueueItem"..f.."IconCount"];
+			frame = _G["CauldronQueueIntItem"..i.."IconCount"];
 			frame:SetText(queueInfo.amount);

 			-- place the frame in the scroll view
-			if f > 1 then
+			if i > 1 then
 				-- anchor to the frame above
 --@alpha@
 				self:debug("UpdateQueue: anchor frame to top left of frame above");
 --@end-alpha@
-				queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueItem"..tostring(f-1)], "BOTTOMLEFT", 0, 0);
+				queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueIntItem"..(i-1)], "BOTTOMLEFT", 0, 0);
 			else
 				-- anchor to the parent
 --@alpha@
@@ -860,14 +859,14 @@ function Cauldron:UpdateQueue()
 	end

 	-- hide any remaining frames
-	j = f + 1;
+	j = #intQueue + 1;
 	while true do
-		local frame = _G["CauldronQueueItem"..j];
+		local frame = _G["CauldronQueueIntItem"..j];
 		if not frame then
 			break;
 		end

-		_G["CauldronQueueItem"..j] = nil;
+		_G["CauldronQueueIntItem"..j] = nil;

 		frame:Hide();
 		frame:SetHeight(0);
@@ -888,16 +887,14 @@ function Cauldron:UpdateQueue()
 --@alpha@
 		self:debug("reagentList: "..queueInfo.name);
 --@end-alpha@
-
-		f = f + 1;

-		local queueItemFrame = _G["CauldronQueueItem"..f];
+		local queueItemFrame = _G["CauldronQueueReagentItem"..i];

 		-- check if we have a frame for this position
 		if not queueItemFrame then
 			-- create a new frame for the skill information
 			queueItemFrame = CreateFrame("Button",
-										 "CauldronQueueItem"..f,
+										 "CauldronQueueReagentItem"..i,
 										 CauldronQueueFrameScrollFrameQueueSectionsReagents,
 										 "CauldronQueueItemFrameTemplate");
 		end
@@ -905,7 +902,7 @@ function Cauldron:UpdateQueue()
 		local countInfo = Cauldron:ReagentCount(queueInfo.name);
 		local need = math.max(0, queueInfo.amount - countInfo.has);

-		queueItemFrame:SetID(f);
+		queueItemFrame:SetID(i);
 		queueItemFrame.skillIndex = queueInfo.skillIndex;
 		queueItemFrame.index = queueInfo.index;
 		queueItemFrame.itemName = queueInfo.name;
@@ -915,13 +912,13 @@ function Cauldron:UpdateQueue()
 		queueItemFrame.needAmount = need;

 		-- don't show the remove button
-		_G["CauldronQueueItem"..f.."RemoveItem"]:Hide();
-		_G["CauldronQueueItem"..f.."RemoveItem"]:SetScale(0.75);
-		_G["CauldronQueueItem"..f.."IncreasePriority"]:Hide();
-		_G["CauldronQueueItem"..f.."DecreasePriority"]:Hide();
-		_G["CauldronQueueItem"..f.."DecrementCount"]:Hide();
-		_G["CauldronQueueItem"..f.."AddToShoppingList"]:Hide();
-		_G["CauldronQueueItem"..f.."AddToShoppingList"]:SetScale(0.5);
+		_G["CauldronQueueReagentItem"..i.."RemoveItem"]:Hide();
+		_G["CauldronQueueReagentItem"..i.."RemoveItem"]:SetScale(0.75);
+		_G["CauldronQueueReagentItem"..i.."IncreasePriority"]:Hide();
+		_G["CauldronQueueReagentItem"..i.."DecreasePriority"]:Hide();
+		_G["CauldronQueueReagentItem"..i.."DecrementCount"]:Hide();
+		_G["CauldronQueueReagentItem"..i.."AddToShoppingList"]:Hide();
+		_G["CauldronQueueReagentItem"..i.."AddToShoppingList"]:SetScale(0.5);

 		local skillInfo = Cauldron:GetSkillInfo(queueInfo.tradeskill, queueInfo.name);
 		if not skillInfo then
@@ -932,7 +929,7 @@ function Cauldron:UpdateQueue()
 		local frame = nil;

 		-- set name and difficulty color
-		frame = _G["CauldronQueueItem"..f.."ItemName"];
+		frame = _G["CauldronQueueReagentItem"..i.."ItemName"];
 		frame:SetText(queueInfo.name);
 		frame:SetShadowOffset(0, 0);
 		frame:SetFont("GameFontNormal", 12);
@@ -942,7 +939,7 @@ function Cauldron:UpdateQueue()
 		frame.b = 1.0;

 		-- set quantity info
-		frame = _G["CauldronQueueItem"..f.."Info"];
+		frame = _G["CauldronQueueReagentItem"..i.."Info"];
 		local countInfo = Cauldron:ReagentCount(queueInfo.name);
 		local qtyText = string.format(L["Have %d"], countInfo.has);
 		if countInfo.bank > 0 then
@@ -957,7 +954,7 @@ function Cauldron:UpdateQueue()
 		frame:SetShadowOffset(0, 0);

 		-- set the icon
-		frame = _G["CauldronQueueItem"..f.."Icon"];
+		frame = _G["CauldronQueueReagentItem"..i.."Icon"];
 		frame:SetNormalTexture(queueInfo.icon);
 		frame.link = queueInfo.link;
 --		local playerReagentCount = 0; -- TODO
@@ -970,16 +967,16 @@ function Cauldron:UpdateQueue()
 --		end

 		-- set the amount
-		frame = _G["CauldronQueueItem"..f.."IconCount"];
+		frame = _G["CauldronQueueReagentItem"..i.."IconCount"];
 		frame:SetText(queueInfo.amount);

 		-- place the frame in the scroll view
-		if f > 1 then
+		if i > 1 then
 			-- anchor to the frame above
 --@alpha@
 			self:debug("UpdateQueue: anchor frame to top left of frame above");
 --@end-alpha@
-			queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueItem"..tostring(f-1)], "BOTTOMLEFT", 0, 0);
+			queueItemFrame:SetPoint("TOPLEFT", _G["CauldronQueueReagentItem"..(i-1)], "BOTTOMLEFT", 0, 0);
 		else
 			-- anchor to the parent
 --@alpha@
@@ -1001,14 +998,14 @@ function Cauldron:UpdateQueue()
 	end

 	-- hide any remaining frames
-	j = f + 1;
+	j = #reagentList + 1;
 	while true do
-		local frame = _G["CauldronQueueItem"..j];
+		local frame = _G["CauldronQueueReagentItem"..j];
 		if not frame then
 			break;
 		end

-		_G["CauldronQueueItem"..j] = nil;
+		_G["CauldronQueueReagentItem"..j] = nil;

 		frame:Hide();
 		frame:SetHeight(0);