Quantcast

Started adding "favorite" capability.

pschifferer [01-22-09 - 17:27]
Started adding "favorite" capability.
Filename
Cauldron/CauldronMain.lua
Cauldron/CauldronMain.xml
Cauldron/CauldronMainUI.lua
Cauldron/CauldronQueue.lua
Cauldron/CauldronTradeskill.lua
diff --git a/Cauldron/CauldronMain.lua b/Cauldron/CauldronMain.lua
index e44255e..62965cb 100644
--- a/Cauldron/CauldronMain.lua
+++ b/Cauldron/CauldronMain.lua
@@ -4,7 +4,7 @@
 Cauldron = LibStub("AceAddon-3.0"):NewAddon("Cauldron", "AceEvent-3.0", "AceTimer-3.0", "AceConsole-3.0", "AceHook-3.0", "LibLogger-1.0")
 local L = LibStub("AceLocale-3.0"):GetLocale("Cauldron")

-Cauldron.version = "0.9.5." .. string.sub("$Revision$", 12, -3);
+Cauldron.version = "0.9.6." .. string.sub("$Revision$", 12, -3);
 Cauldron.date = string.sub("$Date$", 8, 17);

 -- key binding names
@@ -202,6 +202,9 @@ function Cauldron:OnSkillUpdate()
 		end

 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.selected = 0;
+
+		Cauldron:UpdateSkills();
+		CauldronQueue:CalculateAllRequiredItems();
 	end

 	self:Frame_Update();
@@ -610,10 +613,12 @@ end
 							["medium"] = true, -- should medium skills be shown?
 							["easy"] = true, -- should easy skills be shown?
 							["trivial"] = false, -- should trivial skills be shown?
+							["favorites"] = false, -- should only favorite skills be shown?
 						},
 						["skills"] = {
 							["<skill>"] = {
 								["expanded"] = false, -- should the skill's reagents be displayed?
+								["favorite"] = false, -- is the skill a favorite?
 							},
 							...
 						},
diff --git a/Cauldron/CauldronMain.xml b/Cauldron/CauldronMain.xml
index 6f1e874..81c8447 100644
--- a/Cauldron/CauldronMain.xml
+++ b/Cauldron/CauldronMain.xml
@@ -149,6 +149,23 @@
 					</OnClick>
 				</Scripts>
 			</Button>
+			<CheckButton name="$parentFavoriteButton" hidden="false" inherits="UICheckButtonTemplate">
+				<Size x="20" y="22"/>
+				<Anchors>
+					<Anchor point="TOPRIGHT">
+						<Offset x="0" y="0"/>
+					</Anchor>
+				</Anchors>
+				<Scripts>
+					<OnLoad>
+						self:SetScale(0.5);
+						getglobal(self:GetName()):SetText("");
+					</OnLoad>
+					<OnClick>
+						Cauldron:FavoriteItemButton_OnClick(self);
+					</OnClick>
+				</Scripts>
+			</Button>
     		<Frame name="$parentReagents">
     			<Size x="40" y="100" />
 				<Anchors>
diff --git a/Cauldron/CauldronMainUI.lua b/Cauldron/CauldronMainUI.lua
index c979542..6b672bc 100644
--- a/Cauldron/CauldronMainUI.lua
+++ b/Cauldron/CauldronMainUI.lua
@@ -223,6 +223,10 @@ function Cauldron:UpdateSkillList()
 		frame.g = TradeSkillTypeColor.header.g;
 		frame.b = TradeSkillTypeColor.header.b;

+		-- set favorite check button
+		frame = _G["CauldronSkillItem"..i.."FavoriteButton"];
+		frame:SetChecked(self.db.realm.userdata[self.vars.playername].skills[skillName].window.skills[skillInfo.name].favorite);
+
 		-- set cooldown
 		frame = _G["CauldronSkillItem"..i.."SkillCooldown"];
 		local cooldown = GetTradeSkillCooldown(skillInfo.index);
@@ -1054,6 +1058,26 @@ function Cauldron:FilterDropDown_Initialize(level)
 		text = "",
 		notClickable = true,
 	});
+
+	if not IsTradeSkillLinked() then
+		-- favorites
+		local faves = {
+			text = L["Favorites"],
+			checked = Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.favorites,
+			tooltipTitle = L["Favorites"],
+			tooltipText = L["Display only favorite skills"],
+			func = function(arg1, arg2) Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.favorites = not Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.filter.favorites end,
+			arg1 = "favorite",
+			arg2 = "",
+		};
+		UIDropDownMenu_AddButton(faves);
+
+		-- spacer
+		UIDropDownMenu_AddButton({
+			text = "",
+			notClickable = true,
+		});
+	end

 	-- reagents availability

@@ -1564,3 +1588,18 @@ function Cauldron:AmountIncrement_OnClick()

 	self:debug("AmountIncrement_OnClick exit");
 end
+
+function Cauldron:FavoriteItemButton_OnClick(button)
+	self:debug("FavoriteItemButton_OnClick enter");
+
+	local skillName = CURRENT_TRADESKILL;
+	if IsTradeSkillLinked() then
+		skillName = "Linked-"..skillName;
+	end
+
+	local skillInfo = button.skillInfo;
+
+	Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[skillName].window.skills[skillInfo.name].favorite = button:GetChecked();
+
+	self:debug("FavoriteItemButton_OnClick exit");
+end
diff --git a/Cauldron/CauldronQueue.lua b/Cauldron/CauldronQueue.lua
index e2337f8..ec01e06 100644
--- a/Cauldron/CauldronQueue.lua
+++ b/Cauldron/CauldronQueue.lua
@@ -75,13 +75,9 @@ function CauldronQueue:GetItems(queue)
 	local items = {};

 	for _, item in pairs(queue.main) do
---		if tradeskill then
---			if tradeskill == item.tradeskill then
---				table.insert(items, item);
---			end
---		else
+		if item.amount > 0 then
 			table.insert(items, item);
---		end
+		end
 	end

 	-- sort the list
diff --git a/Cauldron/CauldronTradeskill.lua b/Cauldron/CauldronTradeskill.lua
index 6b99393..34a96f0 100644
--- a/Cauldron/CauldronTradeskill.lua
+++ b/Cauldron/CauldronTradeskill.lua
@@ -297,6 +297,14 @@ function Cauldron:GetSkillList(playername, skillName)
 			end
 		end

+		-- check favorites filter
+		if self.db.realm.userdata[playername].skills[skillName].window.filter.favorites then
+			if not self.db.realm.userdata[playername].skills[skillName].window.skills[recipe.name].favorite then
+				self:debug("skipping recipe: "..name.." (favorite: "..tostring(self.db.realm.userdata[playername].skills[skillName].window.skills[recipe.name].favorite)..")");
+				add = false;
+			end
+		end
+
 		-- we got here, add the recipe to the list
 		if add then
 			table.insert(skills, recipe);