Quantcast

ToC Bump.

Daniel Yates [04-27-11 - 13:25]
ToC Bump.
Removed all legacy/useless code.
Fixed LSM bugs.
Fixed nil error.
Filename
Core.lua
Modules/Auras.lua
Modules/Border.lua
Modules/Buttons.lua
Modules/TimerStacksConfig.lua
PowerAurasButtons.toc
diff --git a/Core.lua b/Core.lua
index af3453c..bf8cb9c 100644
--- a/Core.lua
+++ b/Core.lua
@@ -342,45 +342,6 @@ function CoreFrame:FixSettings()
 			end
 		end
 	end
-	-- Merge old config too.
-	if(PowerAurasButtonsDB) then
-		-- Old global config.
-		for auraID, actions in pairs(PowerAurasButtonsDB) do
-			PowerAurasButtons_AurasDB[auraID-120] = {};
-			for actionID, actionData in pairs(actions) do
-				PowerAurasButtons_AurasDB[auraID-120][actionID] = {};
-				PowerAurasButtons_AurasDB[auraID-120][actionID]["type"] = actionData[1];
-				PowerAurasButtons_AurasDB[auraID-120][actionID]["id"] = actionData[2];
-				PowerAurasButtons_AurasDB[auraID-120][actionID]["glow"] = actionData[3];
-				PowerAurasButtons_AurasDB[auraID-120][actionID]["timer"] = actionData[4];
-				PowerAurasButtons_AurasDB[auraID-120][actionID]["stacks"] = actionData[5];
-			end
-		end
-		-- Wipe old settings.
-		PowerAurasButtonsDB = nil;
-	end
-	if(PowerAurasButtonsCharDB) then
-		-- Old per-char config.
-		for auraID, actions in pairs(PowerAurasButtonsCharDB) do
-			PowerAurasButtons_CharacterAurasDB[auraID] = {};
-			for actionID, actionData in pairs(actions) do
-				PowerAurasButtons_CharacterAurasDB[auraID][actionID] = {};
-				PowerAurasButtons_CharacterAurasDB[auraID][actionID]["type"] = actionData[1];
-				PowerAurasButtons_CharacterAurasDB[auraID][actionID]["id"] = actionData[2];
-				PowerAurasButtons_CharacterAurasDB[auraID][actionID]["glow"] = actionData[3];
-				PowerAurasButtons_CharacterAurasDB[auraID][actionID]["timer"] = actionData[4];
-				PowerAurasButtons_CharacterAurasDB[auraID][actionID]["stacks"] = actionData[5];
-			end
-		end
-		-- Wipe old settings.
-		PowerAurasButtonsCharDB = nil;
-	end
-	if(PowerAurasButtonsSettingsDB) then
-		-- Old settings config.
-		PowerAurasButtons_SettingsDB = PowerAurasButtonsSettingsDB;
-		-- Wipe old settings.
-		PowerAurasButtonsSettingsDB = nil;
-	end
 end
 --[[
 ----------------------------------------------------------------------------------------------------
diff --git a/Modules/Auras.lua b/Modules/Auras.lua
index f66286b..1d064b6 100644
--- a/Modules/Auras.lua
+++ b/Modules/Auras.lua
@@ -10,13 +10,10 @@ local Modules          = CoreFrame.Modules;
 --[[
 ----------------------------------------------------------------------------------------------------
 Variables
-	ActionTable        Stores a precalculated complicated list of all created actions and the
-	                   auras that share those actions in common. This is a BIG table.
 	ActiveAuras        Stores a list of auras alongside their associated action data tables.
 	BlizzAuras         Stores a list of active spell overlays fired by Blizzard's spell events.
 ----------------------------------------------------------------------------------------------------
 --]]
-local ActionTable      = {};
 local ActiveAuras      = {};
 local BlizzAuras       = {};
 --[[
@@ -91,41 +88,6 @@ function ModuleFrame:SPELL_ACTIVATION_OVERLAY_GLOW_HIDE(auraID)
 end
 --[[
 ----------------------------------------------------------------------------------------------------
-CalculateActionTable
-
-Calculates a table of actions (uniquely seperated by a key composed of action type and ID) which
-contains a list of auras which could modify the display of buttons which match the actions.
-----------------------------------------------------------------------------------------------------
---]]
-function ModuleFrame:CalculateActionTable()
-	-- Wipe the existing table.
-	wipe(ActionTable);
-	-- Go over every single possible aura we have.
-	local actions, key;
-	for auraID=1,360 do
-		-- Reset vars.
-		actions, key = ModuleFrame:GetAuraActions(auraID), nil;
-		if(actions and #(actions) > 0) then
-			-- Go over them.
-			for actionID, actionData in pairs(actions) do
-				-- Calculate a key from the data.
-				if(actionData and actionData["id"] and actionData["id"] > 0) then
-					key = strupper(strsub(actionData["type"], 0, 1)) .. actionData["id"];
-					-- Does a table for auras with this key already exist?
-					if(not ActionTable[key]) then
-						ActionTable[key] = {};
-					end
-					-- Add the aura.
-					tinsert(ActionTable[key], format("%03d", auraID) .. actionID);
-				end
-			end
-		end
-	end
-	-- Perform GC.
-	collectgarbage("collect");
-end
---[[
-----------------------------------------------------------------------------------------------------
 GetActionTable

 Returns the listing from the ActionTable table which has the given key, or nil.
@@ -160,8 +122,6 @@ function ModuleFrame:ResetAuras()
 			 ModuleFrame:OnAuraShow(i);
 		end
 	end
-	-- On a reset, recalculate the table too.
-	ModuleFrame:CalculateActionTable();
 end
 --[[
 ----------------------------------------------------------------------------------------------------
@@ -324,8 +284,6 @@ function ModuleFrame:OnInitialize()
 	CoreFrame:RegisterModuleEvent("OnActionCreate");
 	CoreFrame:RegisterModuleEvent("OnAuraShow");
 	CoreFrame:RegisterModuleEvent("OnAuraHide");
-	-- Calculate some actions baby.
-	ModuleFrame:CalculateActionTable();
 	-- Done.
 	return true;
 end
\ No newline at end of file
diff --git a/Modules/Border.lua b/Modules/Border.lua
index 83b5b99..982a227 100644
--- a/Modules/Border.lua
+++ b/Modules/Border.lua
@@ -68,7 +68,7 @@ function ModuleFrame:OnButtonDisplayAura(buttonID, auraID, actionData)
 	if(not ButtonBorders[buttonID]) then ButtonBorders[buttonID] = {}; end
 	-- Calculate.
 	if(not ButtonBorders[buttonID][1] or
-	actionData["border_priority"] > (ButtonBorders[buttonID][1] or 25)) then
+	(actionData["border_priority"] or 25) > (ButtonBorders[buttonID][1] or 25)) then
 		-- Make sure it's enabled.
 		EnabledButtons[buttonID] = true;
 		-- It's a higher priority than the currently recorded one.
diff --git a/Modules/Buttons.lua b/Modules/Buttons.lua
index d56be0a..aa480e3 100644
--- a/Modules/Buttons.lua
+++ b/Modules/Buttons.lua
@@ -65,104 +65,87 @@ be glowing, showing displays, etc.
 ----------------------------------------------------------------------------------------------------
 --]]
 function ModuleFrame:ProcessButtonActions(button)
-	-- Few button data related locals.
+	-- Few locals.
 	local buttonID = button:GetName();
-	if(not ButtonData[buttonID]) then ButtonData[buttonID] = {}; end
-	wipe(ButtonData[buttonID]);
+	-- Get the button data table if it exists. Otherwise, make a new one. We recycle the old one
+	-- so the memory size won't fluctuate.
+	local buttonData = ButtonData[buttonID] or {};
+	-- Wipe the data.
+	wipe(buttonData);
 	-- Fire button processing event.
 	CoreFrame:FireModuleEvent("OnButtonProcess", buttonID);
-	-- Determine the action key from the button.
-	local buttonAction = button._state_action or button.action;
-	-- Action must be a number.
-	if(not buttonAction or type(buttonAction) ~= "number") then return; end
-	local buttonActionType, buttonActionID = GetActionInfo(buttonAction);
-	-- Make sure we got the stuff.
-	if(not buttonActionType or not buttonActionID) then return; end
-	-- Key it.
-	local key = strupper(strsub(buttonActionType, 0, 1)) .. buttonActionID;
-	-- Blizzard auras need checking first off, but only if enabled.
+	-- Get the non blizzard auras.
+	local CustomAuras, BlizzAuras = Modules.Auras:GetAuras();
+	-- More locals.
+	local buttonAction, buttonActionType, buttonActionID, buttonMacro, displayCount;
+	-- Get the button action ID.
+	buttonAction = button._state_action or button.action;
+	-- Action needs to be integer.
+	if(not buttonAction or type(buttonAction) ~= "number") then
+		-- Action isn't valid.
+		ButtonData[buttonID] = buttonData;
+		return;
+	end
+	-- Get the button action data.
+	buttonActionType, buttonActionID = GetActionInfo(buttonAction);
+	-- Get macro names if needed.
+	if(buttonActionType == "macro") then
+		buttonMacro = GetMacroSpell(buttonActionID) or GetMacroItem(buttonActionID);
+	end
+	-- Right, first off we need to go over all the auras see if they're linked to this one.
+	for auraID, _ in pairs(CustomAuras) do
+		-- Aura needs to be active.
+		if(Modules.Auras:IsAuraShown(auraID)) then
+			-- And go over the actions.
+			for auraActionID, auraActionData in pairs(Modules.Auras:GetAuraActions(auraID)) do
+				-- Action needs to be a valid ID (> 0)
+				if(auraActionData["id"] and auraActionData["id"] > 0) then
+					-- If the type/data keys match, or this is a macro/spell combo then continue.
+					if(buttonActionType == auraActionData["type"]
+					or (buttonActionType == "macro" and auraActionData["type"] == "spell")
+					or (buttonActionType == "macro" and auraActionData["type"] == "item")) then
+						-- Compare ID's. If they match, we're golden. If they don't, do macro
+						-- comparisons.
+						if((buttonActionID == auraActionData["id"]
+						and buttonActionType == auraActionData["type"])
+						or buttonMacro and (auraActionData["type"] == "spell"
+						and GetSpellInfo(auraActionData["id"]) == buttonMacro
+						or auraActionData["type"] == "item"
+						and GetItemInfo(auraActionData["id"]) == buttonMacro)) then
+							-- Enable glows if the action says so.
+							Modules.Auras:MergeAuraAction(buttonData, auraActionData);
+							-- Fire the OnAuraDisplay event.
+							CoreFrame:FireModuleEvent("OnButtonDisplayAura", buttonID, auraID,
+								auraActionData, auraActionID);
+						end
+					end
+				end
+			end
+		end
+	end
+	-- Blizzard auras need checking if glow isn't on, and if enabled.
 	if(CoreFrame:GetModuleSetting("Buttons", "ShowBlizzardGlows")) then
-		if(buttonActionType == "spell" and IsSpellOverlayed(buttonActionID)) then
+		if(not buttonData["glow"] and buttonActionType == "spell"
+		and IsSpellOverlayed(buttonActionID)) then
 			-- It needs to glow.
-			ButtonData[buttonID]["glow"] = true;
-		elseif(buttonActionType == "macro") then
+			buttonData["glow"] = true;
+		elseif(not buttonData["glow"] and buttonActionType == "macro") then
 			-- Macros should glow too.
-			local buttonMacro = GetMacroSpell(buttonActionID);
+			buttonMacro = GetMacroSpell(buttonActionID) or GetMacroItem(buttonActionID);
 			-- Loop over active Blizzard auras.
-			local _, BlizzAuras = Modules.Auras:GetAuras();
 			for blizzAuraID, _ in pairs(BlizzAuras) do
 				-- Check ID.
-				if(not ButtonData[buttonID]["glow"] and buttonMacro
-				and buttonMacro == GetSpellInfo(blizzAuraID)) then
+				if(not buttonData["glow"] and buttonMacro
+				and (buttonMacro == GetSpellInfo(blizzAuraID)
+				or GetItemInfo(blizzAuraID) == buttonMacro)) then
 					-- Yeah, it's a match. Timers/Stacks aren't on for blizz ones.
-					ButtonData[buttonID]["glow"] = true;
+					buttonData["glow"] = true;
 				end
 			end
 		end
 	end
-	-- Does this key exist anywhere?
-	local auras = Modules.Auras:GetActionTable(key);
-	if(not auras) then
-		-- It's not necessarily the end, is this a macro?
-		if(buttonActionType == "macro") then
-			-- In that case, get the spell or item name the button represents.
-			local buttonMacro = GetMacroSpell(buttonActionID) or GetMacroItem(buttonActionID);
-			local actionData;
-			-- Go over all of the actions. Slow, I know, but decent enough for now...
-			for actionKey, auras in pairs(Modules.Auras:GetActionTable()) do
-				-- And for this one, figure out what the hell spell or item name it represents.
-				local actionType = strsub(actionKey, 0, 1);
-				actionData = (actionType == "S"
-					and GetSpellInfo(tonumber(strsub(actionKey, 2))))
-					or (actionType == "I"
-					and GetSpellInfo(tonumber(strsub(actionKey, 2))))
-					or nil;
-				if(actionData and actionData == buttonMacro) then
-					-- Right, it's a match. A complicated match. Go over the auras.
-					for _, auraID in pairs(auras) do
-						-- I hate duplicating code but I don't want to create tables.
-						local auraActionID = tonumber(strsub(auraID, 4, 5));
-						auraID = tonumber(strsub(auraID, 0, 3));
-						-- Is the aura active?
-						if(Modules.Auras:IsAuraShown(auraID)) then
-							-- Get the action data.
-							local actionData = Modules.Auras:GetAuraAction(auraID, auraActionID);
-							-- One difference for macros is we check the type.
-							if(actionType == strupper(strsub(actionData["type"], 0, 1))) then
-								-- Enable displays for this aura.
-								Modules.Auras:MergeAuraAction(ButtonData[buttonID], actionData);
-								-- Fire aura display event.
-								CoreFrame:FireModuleEvent("OnButtonDisplayAura", buttonID, auraID,
-									actionData, auraActionID);
-							end
-						end
-					end
-				end
-			end
-			-- Done.
-			return;
-		else
-			-- Not a macro, end it.
-			return;
-		end
-	end
-	-- Go over the auras this key has.
-	for _, auraID in pairs(auras) do
-		-- The action ID is actually the auraID padded to 3 digits + the action ID appended.
-		-- So split it up.
-		local auraActionID = tonumber(strsub(auraID, 4, 5));
-		auraID = tonumber(strsub(auraID, 0, 3));
-		-- Is the aura active?
-		if(Modules.Auras:IsAuraShown(auraID)) then
-			-- Get the action data.
-			local actions = Modules.Auras:GetAuraAction(auraID, auraActionID);
-			-- Enable displays for this aura.
-			Modules.Auras:MergeAuraAction(ButtonData[buttonID], actions);
-			-- Fire aura display event.
-			CoreFrame:FireModuleEvent("OnButtonDisplayAura", buttonID, auraID, actions,
-				auraActionID);
-		end
-	end
+	-- Update.
+	ButtonData[buttonID] = buttonData;
 end
 --[[
 ----------------------------------------------------------------------------------------------------
diff --git a/Modules/TimerStacksConfig.lua b/Modules/TimerStacksConfig.lua
index 4fe762d..90e073e 100644
--- a/Modules/TimerStacksConfig.lua
+++ b/Modules/TimerStacksConfig.lua
@@ -217,7 +217,7 @@ function ModuleFrame:CreateInterfaceOptionsTimerFrame()
 	local LSMFonts;
 	if(LibStub) then
 		-- Try LSM.
-		local LSM = LibStub("LibSharedMedia-3.0");
+		local LSM = LibStub("LibSharedMedia-3.0", true);
 		if(LSM) then
 			-- Get all fonts.
 			LSMFonts = LSM:HashTable(LSM.MediaType.FONT);
@@ -511,7 +511,7 @@ function ModuleFrame:CreateInterfaceOptionsStacksFrame()
 	local LSMFonts;
 	if(LibStub) then
 		-- Try LSM.
-		local LSM = LibStub("LibSharedMedia-3.0");
+		local LSM = LibStub("LibSharedMedia-3.0", true);
 		if(LSM) then
 			-- Get all fonts.
 			LSMFonts = LSM:HashTable(LSM.MediaType.FONT);
diff --git a/PowerAurasButtons.toc b/PowerAurasButtons.toc
index 47af704..d6af278 100644
--- a/PowerAurasButtons.toc
+++ b/PowerAurasButtons.toc
@@ -1,12 +1,12 @@
-## Interface: 40000
+## Interface: 40100
 ## Author: Daniel Yates
 ## Version: @project-version@
 ## Title: Power Auras Classic: Buttons
 ## Notes: Allows you to use various displays on action buttons when a Power Auras aura is activated.
 ## Dependencies: PowerAuras
 ## OptionalDeps: LibActionButton-1.0, LibSharedMedia-3.0, SharedMedia, LibStub, Bartender4, Dominos
-## SavedVariables: PowerAurasButtons_AurasDB, PowerAurasButtons_SettingsDB, PowerAurasButtonsDB, PowerAurasButtonsSettingsDB
-## SavedVariablesPerCharacter: PowerAurasButtons_CharacterAurasDB, PowerAurasButtonsCharDB
+## SavedVariables: PowerAurasButtons_AurasDB, PowerAurasButtons_SettingsDB
+## SavedVariablesPerCharacter: PowerAurasButtons_CharacterAurasDB

 # NOTE: Old SV's will be gone in 4.1.0.