Quantcast

5.4.19

Steven Jackson [01-18-15 - 07:58]
5.4.19
Filename
Interface/AddOns/SVUI/packages/quest/components/quests.lua
Interface/AddOns/SVUI_StyleOMatic/Loader.lua
diff --git a/Interface/AddOns/SVUI/packages/quest/components/quests.lua b/Interface/AddOns/SVUI/packages/quest/components/quests.lua
index 25e94dd..79e5360 100644
--- a/Interface/AddOns/SVUI/packages/quest/components/quests.lua
+++ b/Interface/AddOns/SVUI/packages/quest/components/quests.lua
@@ -74,7 +74,7 @@ local CACHED_QUESTS = {};
 local QUESTS_BY_LOCATION = {};
 local QUEST_HEADER_MAP = {};
 local USED_QUESTIDS = {};
-local TICKERS, ACTIVE_ITEMS = {}, {};
+local TICKERS, ACTIVE_ITEMS, SWAP_ITEMS = {}, {}, {};
 local CURRENT_MAP_ID = 0;
 local WORLDMAP_UPDATE = false;

@@ -156,21 +156,21 @@ do
     end

     local Button_SetItem = function(self, itemLink, texture, completed)
+    	if(completed) then
+    		self:ClearUsage()
+    		return
+    	end
         if(itemLink) then
-        	if(completed and (itemLink == self.itemLink)) then
-        		self:ClearUsage()
-        		return
-        	end
-            if(ACTIVE_ITEMS[itemLink] or (itemLink == self.itemLink and self:IsShown())) then
-                return false
+            if(ACTIVE_ITEMS[itemLink] or ((itemLink == self.itemLink) and self:IsShown())) then
+                return
             end
-            ACTIVE_ITEMS[itemLink] = true;
+            ACTIVE_ITEMS[itemLink] = self:GetID();
             self.Icon:SetTexture(texture)
             self.itemID, self.itemName = string.match(itemLink, '|Hitem:(.-):.-|h%[(.+)%]|h')
             self.itemLink = itemLink

             if(ItemBlacklist[self.itemID]) then
-                return false
+                return
             end
             self:FadeIn()
         end
@@ -187,7 +187,7 @@ do
     end

     local Button_ClearItem = function(self)
-        self:FadeOut()
+        --self:FadeOut()
         if(InCombatLockdown()) then
             self.attribute = nil;
             self:RegisterEvent('PLAYER_REGEN_ENABLED');
@@ -300,6 +300,12 @@ do

     function ItemBar:SetQuestItem(itemLink, texture, completed)
     	if(not itemLink) then return end
+    	local savedIndex = ACTIVE_ITEMS[itemLink]
+    	if(savedIndex and self.Buttons[savedIndex]) then
+    		self.Buttons[savedIndex]:SetUsage(itemLink, texture, completed)
+    		return
+    	end
+
 		local maxIndex = #self.Buttons;
 		for i = 1, maxIndex do
 			if(not self.Buttons[i]:GetAttribute('item')) then
@@ -316,7 +322,6 @@ end

 function ItemBar:Reset()
 	local maxIndex = #self.Buttons;
-	wipe(ACTIVE_ITEMS)
 	for i = 1, maxIndex do
 		local button = self.Buttons[i];
 		button:ClearUsage();
@@ -329,17 +334,23 @@ function ItemBar:Update()
 		self.needsUpdate = true
 		return
 	end
+	wipe(SWAP_ITEMS);
 	local maxIndex = #self.Buttons;
-
 	local firstButton = self.Buttons[1];
+	local itemLink = firstButton.itemLink;
 	firstButton:ClearAllPoints();
 	firstButton:SetPoint("TOP", self, "TOP", 0, -2);

-	local lastButton = firstButton;
-	local totalShown = 1;
+	if(itemLink and ACTIVE_ITEMS[itemLink]) then
+		SWAP_ITEMS[itemLink] = 1
+	end
+
+	local lastButton, totalShown, button = firstButton, 1;

 	for i = 2, maxIndex do
-		local button = self.Buttons[i];
+		button = self.Buttons[i];
+		itemLink = button.itemLink;
+
 		button:ClearAllPoints();
 		if(button:IsShown()) then
 			totalShown = totalShown + 1;
@@ -357,8 +368,22 @@ function ItemBar:Update()
 				button:FadeIn();
 			end
 			lastButton = button
+
+			if(itemLink) then
+				if(ACTIVE_ITEMS[itemLink]) then
+					SWAP_ITEMS[itemLink] = i
+				end
+			else
+				button:ClearUsage()
+			end
 		end
 	end
+
+	wipe(ACTIVE_ITEMS);
+	for k,v in pairs(SWAP_ITEMS) do
+		ACTIVE_ITEMS[k] = v
+	end
+
 	self.needsUpdate = nil
 end
 --[[
@@ -853,8 +878,6 @@ local SetQuestRow = function(self, index, watchIndex, title, level, icon, questI
 		objective_block:FadeIn();
 	end

-	--if(iscomplete) then MOD.QuestItem:ClearUsage(questLogIndex) end
-
 	fill_height = fill_height + (QUEST_ROW_HEIGHT + 6);

 	return index, fill_height;
@@ -898,7 +921,7 @@ local RefreshQuests = function(self, event, ...)
 					rows, zone = self:SetZone(rows, zoneName);
 					fill_height = fill_height + QUEST_ROW_HEIGHT;
 				end
-				rows, add_height = self:Set(rows, quest[1], quest[2], quest[3], quest[4], quest[5], quest[6], quest[7], quest[8], quest[9], quest[10])
+				rows, add_height = self:Set(rows, unpack(quest))
 				fill_height = fill_height + add_height;
 				if(quest[12]) then
 					ItemBar:SetQuestItem(quest[12], quest[4], quest[10])
@@ -923,14 +946,19 @@ local AddOneQuest = function(self, questID)
 	if(questID) then
 		local fill_height = self:GetHeight();
 		local quest = CACHED_QUESTS[questID];
-		if(quest[1] and quest[1] ~= '') then
+		if(quest[2] and quest[2] ~= '') then
 			local add_height = 0;
 			rows, add_height = self:Set(rows, unpack(quest))
 			fill_height = fill_height + add_height;
+			if(quest[12]) then
+				ItemBar:SetQuestItem(quest[12], quest[4], quest[10])
+			end
 		end

 		self:SetHeightToScale(fill_height + 2);
 	end
+
+	ItemBar:Update()
 end

 local ResetQuestBlock = function(self)
@@ -951,7 +979,6 @@ local ResetQuestBlock = function(self)
 			row.Objectives:Reset();
 		end
 	end
-	ItemBar:Reset();
 	UpdateCachedQuests();
 end

@@ -1037,6 +1064,7 @@ function MOD:UpdateObjectives(event, ...)
 			if(CACHED_QUESTS[questID]) then
 				CACHED_QUESTS[questID] = nil;
 				self:CheckActiveQuest(questID);
+				ItemBar:Reset();
 				self.Headers["Quests"]:Reset();
 				self.Headers["Quests"]:Refresh(event, ...);
 				self:UpdateDimensions();
@@ -1119,6 +1147,7 @@ function MOD:InitializeQuests()
 	self:RegisterEvent("ZONE_CHANGED_NEW_AREA", self.UpdateObjectives);
 	self:RegisterEvent("ZONE_CHANGED", self.UpdateObjectives);

+	ItemBar:Reset();
 	CacheQuestHeaders()
 	self.Headers["Quests"]:Reset()
 	self.Headers["Quests"]:Refresh()
diff --git a/Interface/AddOns/SVUI_StyleOMatic/Loader.lua b/Interface/AddOns/SVUI_StyleOMatic/Loader.lua
index 96cf35d..e79d0e0 100644
--- a/Interface/AddOns/SVUI_StyleOMatic/Loader.lua
+++ b/Interface/AddOns/SVUI_StyleOMatic/Loader.lua
@@ -137,23 +137,6 @@ SV.Options.args.plugins.args.pluginOptions.args[Schema].args["blizzardEnable"] =
     get = function(key) return PLUGIN.db.blizzard.enable end,
     set = function(key,value) PLUGIN.db.blizzard.enable = value; SV:StaticPopup_Show("RL_CLIENT") end
 }
-SV.Options.args.plugins.args.pluginOptions.args[Schema].args["addonEnable"] = {
-    order = 3,
-	name = "Addon Styling",
-    type = "toggle",
-    get = function(key) return PLUGIN.db.addons.enable end,
-    set = function(key,value) PLUGIN.db.addons.enable = value; SV:StaticPopup_Show("RL_CLIENT") end
-}
-SV.Options.args.plugins.args.pluginOptions.args[Schema].args["addons"] = {
-	order = 4,
-	type = "group",
-	name = "Addon Styling",
-	get = function(key) return PLUGIN.db.addons[key[#key]] end,
-	set = function(key,value) PLUGIN.db.addons[key[#key]] = value; SV:StaticPopup_Show("RL_CLIENT")end,
-	disabled = function() return not PLUGIN.db.addons.enable end,
-	guiInline = true,
-	args = {}
-}
 SV.Options.args.plugins.args.pluginOptions.args[Schema].args["blizzard"] = {
 	order = 300,
 	type = "group",
@@ -439,4 +422,38 @@ SV.Options.args.plugins.args.pluginOptions.args[Schema].args["blizzard"] = {
 			desc = L["TOGGLEART_DESC"]
 		}
 	}
+}
+
+
+local function AddonConfigOptions()
+	local t = {};
+	for addonName,_ in pairs(AddonObject.defaults.addons) do
+		t[addonName] = {
+			type = "toggle",
+			name = addonName,
+			desc = L["Addon Styling"],
+			get = function(key) return PLUGIN:IsAddonReady(key[#key]) end,
+			set = function(key,value) PLUGIN:ChangeDBVar(value, key[#key], "addons"); SV:StaticPopup_Show("RL_CLIENT") end,
+		}
+	end
+	return t;
+end
+
+SV.Options.args.plugins.args.pluginOptions.args[Schema].args["addonEnable"] = {
+    order = 3,
+	name = "Addon Styling",
+    type = "toggle",
+    get = function(key) return PLUGIN.db.addons.enable end,
+    set = function(key,value) PLUGIN.db.addons.enable = value; SV:StaticPopup_Show("RL_CLIENT") end
+}
+
+SV.Options.args.plugins.args.pluginOptions.args[Schema].args["addons"] = {
+	order = 4,
+	type = "group",
+	name = "Addon Styling",
+	get = function(key) return PLUGIN.db.addons[key[#key]] end,
+	set = function(key,value) PLUGIN.db.addons[key[#key]] = value; SV:StaticPopup_Show("RL_CLIENT")end,
+	disabled = function() return not PLUGIN.db.addons.enable end,
+	guiInline = true,
+	args = AddonConfigOptions()
 }
\ No newline at end of file