Quantcast

Added sort menu.

Paul Schifferer [12-12-10 - 00:49]
Added sort menu.
Some tweaks to filter menu display.
Some tweaks to queue processing.
Filename
CauldronMain.lua
CauldronMain.xml
CauldronMainUI.lua
diff --git a/CauldronMain.lua b/CauldronMain.lua
index b99141b..3b95302 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -404,7 +404,9 @@ function Cauldron:OnTradeClose()
 end

 function Cauldron:OnTradeItemChanged()
-self:debug("trade item changed");
+	Cauldron:info("trade item changed");
+
+--	Cauldron:UpdateSkillList();
 end

 function Cauldron:OnSkillUpdate()
@@ -532,6 +534,9 @@ function Cauldron:OnBagUpdate(event, bagid)
 	-- update the bags
 	Cauldron:ScanBags();
 	--]==]
+
+	Cauldron:UpdateSkillList();
+
 end

 function Cauldron:OnCraftShow()
@@ -602,7 +607,7 @@ function Cauldron:OnAchievementEarned()

 	-- update the achievement skill map
 	Cauldron:CreateAchievementSkillMap();
--- TODO	Cauldron:UpdateSkillList();
+	Cauldron:UpdateSkillList();

 end

@@ -633,6 +638,17 @@ function Cauldron:OnSpellcastSucceed(event, unit, spell, rank)

 	local queue = self.db.realm.userdata[self.vars.playername].queue;

+	if Cauldron.makingItem then
+		CauldronQueue:AdjustItemCount(queue, self.makingItem, -1);
+
+		local count = Cauldron.makingItemCount - 1;
+		if count < 1 then
+			Cauldron.makingItem = nil;
+			Cauldron.makingItemCount = nil;
+		else
+			Cauldron.makingItemCount = count;
+		end
+	end
 --[[
 	-- adjust queue, but only if window is open
 	if CauldronFrame:IsShown() then
@@ -651,6 +667,9 @@ function Cauldron:OnSpellcastInterrupt(event, unit, spell, rank)

 -- self:info("spell interrupt - unit: "..tostring(unit).."; spell: "..tostring(spell).."; rank: "..tostring(rank));

+	Cauldron.makingItem = nil;
+	Cauldron.makingItemCount = nil;
+
 	self.processing = false;

 end
@@ -896,16 +915,9 @@ function Cauldron:ProcessItem(skillInfo, queueInfo, amount)

 	if ((not PartialPlayTime()) and (not NoPlayTime())) then
 		-- record the item we're making
-		self:debug("skillInfo.itemLink: "..tostring(skillInfo.itemLink));
 		self.makingItem = Cauldron:GetNameFromLink(queueInfo.link);
-		self:debug("makingItem: "..tostring(self.makingItem));
---		self.makingItemId = Cauldron:GetIdFromLink(skillInfo.itemLink);
---		self:debug("makingItemId: "..tostring(self.makingItemId));
 		self.itemCurrentCount = GetItemCount(skillInfo.itemLink);
-
-		self:debug("queueInfo.spell="..tostring(queueInfo.spell));
 		self.makingItemSpell = queueInfo.spell or Cauldron:GetNameFromLink(queueInfo.link);
-		self:debug("makingItemSpell: "..tostring(self.makingItemSpell));
 		self.makingItemCount = amount;
 		self.queueInfo = queueInfo;

diff --git a/CauldronMain.xml b/CauldronMain.xml
index f55da0f..93aea26 100755
--- a/CauldronMain.xml
+++ b/CauldronMain.xml
@@ -577,7 +577,7 @@

 			<!-- Status text -->
 			<Frame name="CauldronStatusFrame">
-				<Size x="535" y="20" />
+				<Size x="465" y="20" />
 				<Anchors>
 					<Anchor point="TOPLEFT">
 						<Offset x="7" y="-75" />
@@ -651,10 +651,11 @@
 				<Size x="1" y="1"/>
 				<Anchors>
 					<Anchor point="TOPRIGHT" relativeTo="CauldronFrame" relativePoint="TOPRIGHT">
-						<Offset x="-85" y="-62"/>
+						<Offset x="-80" y="-62"/>
 					</Anchor>
 				</Anchors>
 				<Frames>
+					<!-- filter -->
 					<Button name="CauldronFilterButton" inherits="UIMenuButtonStretchTemplate" text="FILTER">
 						<Size x="70" y="22"/>
 						<Anchors>
@@ -674,6 +675,29 @@
 							<OnLoad function="CauldronFilterDropDown_OnLoad"/>
 						</Scripts>
 					</Frame>
+
+					<!-- sort -->
+					<Button name="CauldronSortButton" inherits="UIMenuButtonStretchTemplate" text="SORT">
+						<Size x="70" y="22"/>
+						<Anchors>
+							<Anchor point="TOPLEFT" relativeTo="CauldronFilterButton" relativePoint="BOTTOMLEFT">
+								<Offset x="0" y="-1" />
+							</Anchor>
+						</Anchors>
+						<Scripts>
+							<OnClick>
+								ToggleDropDownMenu(1, nil, CauldronSortDropDown, "CauldronSortButton", 74, 15);
+							</OnClick>
+							<OnLoad>
+								CauldronSortButtonRightArrow:Show();
+							</OnLoad>
+						</Scripts>
+					</Button>
+					<Frame name="CauldronSortDropDown" inherits="UIDropDownMenuTemplate">
+						<Scripts>
+							<OnLoad function="CauldronSortDropDown_OnLoad"/>
+						</Scripts>
+					</Frame>
 				</Frames>
 			</Frame>

diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua
index d103610..564cde0 100644
--- a/CauldronMainUI.lua
+++ b/CauldronMainUI.lua
@@ -167,7 +167,7 @@ function CauldronFilterDropDown_Initialize(self, level)
 		difficultyOptimal.isNotRadio = true;
 		difficultyOptimal.notCheckable = false;
 		difficultyOptimal.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.optimal;
-		difficultyOptimal.keepShownOnClick = false;
+		difficultyOptimal.keepShownOnClick = true;
 		difficultyOptimal.tooltipTitle = L["Optimal"];
 		difficultyOptimal.tooltipText = L["Set whether items of this difficulty level should be shown"];
 		difficultyOptimal.func = function(arg1, arg2)
@@ -186,7 +186,7 @@ function CauldronFilterDropDown_Initialize(self, level)
 		difficultyMedium.isNotRadio = true;
 		difficultyMedium.notCheckable = false;
 		difficultyMedium.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.medium;
-		difficultyMedium.keepShownOnClick = false;
+		difficultyMedium.keepShownOnClick = true;
 		difficultyMedium.tooltipTitle = L["Medium"];
 		difficultyMedium.tooltipText = L["Set whether items of this difficulty level should be shown"];
 		difficultyMedium.func = function(arg1, arg2)
@@ -205,7 +205,7 @@ function CauldronFilterDropDown_Initialize(self, level)
 		difficultyEasy.isNotRadio = true;
 		difficultyEasy.notCheckable = false;
 		difficultyEasy.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.easy;
-		difficultyEasy.keepShownOnClick = false;
+		difficultyEasy.keepShownOnClick = true;
 		difficultyEasy.tooltipTitle = L["Easy"];
 		difficultyEasy.tooltipText = L["Set whether items of this difficulty level should be shown"];
 		difficultyEasy.func = function(arg1, arg2)
@@ -224,7 +224,7 @@ function CauldronFilterDropDown_Initialize(self, level)
 		difficultyTrivial.isNotRadio = true;
 		difficultyTrivial.notCheckable = false;
 		difficultyTrivial.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.trivial;
-		difficultyTrivial.keepShownOnClick = false;
+		difficultyTrivial.keepShownOnClick = true;
 		difficultyTrivial.tooltipTitle = L["Trivial"];
 		difficultyTrivial.tooltipText = L["Set whether items of this difficulty level should be shown"];
 		difficultyTrivial.func = function(arg1, arg2)
@@ -391,6 +391,161 @@ function CauldronFilterDropDown_Initialize(self, level)

 end

+function CauldronSortDropDown_OnLoad(self)
+	CauldronSortButton:SetText(L["Sort"]);
+	UIDropDownMenu_Initialize(self, CauldronSortDropDown_Initialize, "MENU");
+	CauldronSortDropDownText:SetJustifyH("CENTER");
+	CauldronSortDropDownButton:Show();
+end
+
+function CauldronSortDropDown_Initialize(self, level)
+
+	local skillName = CURRENT_TRADESKILL;
+	if IsTradeSkillLinked() then
+		skillName = "Linked-"..skillName;
+	end
+
+	local info = UIDropDownMenu_CreateInfo();
+
+	if level == 1 then
+
+		-- title
+		--[[
+		local sortTitle = UIDropDownMenu_CreateInfo();
+		sortTitle.text = L["Sort"];
+		sortTitle.isTitle = true;
+		sortTitle.isNotRadio = nil;
+		sortTitle.notCheckable = true;
+		sortTitle.tooltipTitle = "";
+		sortTitle.tooltipText = "";
+		UIDropDownMenu_AddButton(sortTitle, level);
+		--]]
+
+		-- default
+		local sortDefault = UIDropDownMenu_CreateInfo();
+		sortDefault.text = L["Default"];
+		sortDefault.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault;
+		sortDefault.isNotRadio = nil;
+		sortDefault.keepShownOnClick = false;
+		sortDefault.func = function()
+			Cauldron:FilterDropDown_SetSort("default");
+		end;
+		UIDropDownMenu_AddButton(sortDefault, level);
+
+	--[[
+	local sortDefault = {
+		text = L["Default"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault,
+		tooltipTitle = L["Default"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "default",
+		arg2 = "",
+	};
+	--]]
+
+		-- alpha
+		local sortAlpha = UIDropDownMenu_CreateInfo();
+		sortAlpha.text = L["Alphabetically"];
+		sortAlpha.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha;
+		sortAlpha.isNotRadio = nil;
+		sortAlpha.keepShownOnClick = false;
+		sortAlpha.func = function()
+			Cauldron:FilterDropDown_SetSort("alpha");
+		end;
+		UIDropDownMenu_AddButton(sortAlpha, level);
+
+	--[[
+	local sortAlpha = {
+		text = L["Alphabetically"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortAlpha,
+		tooltipTitle = L["Alphabetically"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "alpha",
+		arg2 = "",
+	};
+	--]]
+
+		-- difficulty
+		local sortDifficulty = UIDropDownMenu_CreateInfo();
+		sortDifficulty.text = L["By difficulty"];
+		sortDifficulty.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty;
+		sortDifficulty.isNotRadio = nil;
+		sortDifficulty.keepShownOnClick = false;
+		sortDifficulty.func = function()
+			Cauldron:FilterDropDown_SetSort("difficulty");
+		end;
+		UIDropDownMenu_AddButton(sortDifficulty, level);
+
+	--[[
+	local sortDifficulty = {
+		text = L["By difficulty"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDifficulty,
+		tooltipTitle = L["By difficulty"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "difficulty",
+		arg2 = "",
+	};
+	--]]
+
+		-- item level
+		local sortItemLevel = UIDropDownMenu_CreateInfo();
+		sortItemLevel.text = L["By item level"];
+		sortItemLevel.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel;
+		sortItemLevel.isNotRadio = nil;
+		sortItemLevel.keepShownOnClick = false;
+		sortItemLevel.func = function()
+			Cauldron:FilterDropDown_SetSort("itemlevel");
+		end;
+		UIDropDownMenu_AddButton(sortItemLevel, level);
+
+	--[[
+	local sortItemLevel = {
+		text = L["By item level"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortItemLevel,
+		tooltipTitle = L["By item level"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "itemlevel",
+		arg2 = "",
+	};
+	--]]
+
+		-- required level
+		local sortReqLevel = UIDropDownMenu_CreateInfo();
+		sortReqLevel.text = L["By required level"];
+		sortReqLevel.checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel;
+		sortReqLevel.isNotRadio = nil;
+		sortReqLevel.keepShownOnClick = false;
+		sortReqLevel.func = function()
+			Cauldron:FilterDropDown_SetSort("reqlevel");
+		end;
+		UIDropDownMenu_AddButton(sortReqLevel, level);
+
+	--[[
+	local sortReqLevel = {
+		text = L["By required level"],
+		checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortRequiredLevel,
+		tooltipTitle = L["By required level"],
+		tooltipText = L["Set the sorting method to use on the skills list"],
+		func = function(arg1, arg2) Cauldron:FilterDropDown_SetSort(arg1) end,
+		arg1 = "reqlevel",
+		arg2 = "",
+	};
+	--]]
+
+		-- favorites
+		-- TODO
+
+		-- benefit
+		-- TODO
+
+	end
+
+end
+
 --[==[
 function CauldronQueueWindowFrame_UpdateQueue()
 end
@@ -1562,14 +1717,16 @@ function Cauldron:FilterDropDown_Reset()

 end

-function Cauldron:FilterDropDown_SetSort(info)
+function Cauldron:FilterDropDown_SetSort(sort)
+
+	Cauldron:info("filter dropdown set sort: "..tostring(sort));

 	local skillName = CURRENT_TRADESKILL;
 	if IsTradeSkillLinked() then
 		skillName = "Linked-"..skillName;
 	end

-	local sort = info.arg1;
+--	local sort = info.arg1;

 	if sort == "default" then
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.sortDefault = true;
@@ -1632,6 +1789,7 @@ function Cauldron:FilterDropDown_SetSort(info)
 	-- update the UI
 						Cauldron:info("updating skill list from sort change");
 	Cauldron:UpdateSkillList();
+	Cauldron:UpdateStatus();

 end