Quantcast

rep bar and event changes

Steven Jackson [03-25-15 - 02:21]
rep bar and event changes
Filename
SVUI_!Core/system/_reports/reputation.lua
SVUI_!Core/system/core.lua
SVUI_!Core/system/errors.lua
SVUI_!Core/system/gear.lua
diff --git a/SVUI_!Core/system/_reports/reputation.lua b/SVUI_!Core/system/_reports/reputation.lua
index 89884a7..8a726a8 100644
--- a/SVUI_!Core/system/_reports/reputation.lua
+++ b/SVUI_!Core/system/_reports/reputation.lua
@@ -194,7 +194,7 @@ ReportBar.OnEvent = function(self, event, ...)
 	end
 end

-Report.OnClick = function(self, button)
+ReportBar.OnClick = function(self, button)
 	CacheRepData(self.InnerData)
 	SV.Dropdown:Open(self, self.InnerData, "Select Faction")
 end
@@ -216,7 +216,7 @@ ReportBar.OnEnter = function(self)
 	Reports:ShowDataTip(true)
 end

-Report.OnInit = function(self)
+ReportBar.OnInit = function(self)
 	if(not self.InnerData) then
 		self.InnerData = {}
 	end
diff --git a/SVUI_!Core/system/core.lua b/SVUI_!Core/system/core.lua
index 2ceb7ff..2f0acd2 100644
--- a/SVUI_!Core/system/core.lua
+++ b/SVUI_!Core/system/core.lua
@@ -612,6 +612,7 @@ function SV:ToggleConfig()
         self:RegisterEvent('PLAYER_REGEN_ENABLED')
         return
     end
+    self.OptionsStandby = nil
     if not IsAddOnLoaded(self.ConfigID) then
         local _,_,_,_,_,state = GetAddOnInfo(self.ConfigID)
         if state ~= "MISSING" and state ~= "DISABLED" then
@@ -789,6 +790,7 @@ function SV:PLAYER_REGEN_DISABLED()
         if aceConfig.OpenFrames[self.NameID] then
             self:RegisterEvent("PLAYER_REGEN_ENABLED")
             aceConfig:Close(self.NameID)
+            self.OptionsStandby = true
             forceClosed = true
         end
     end
@@ -804,7 +806,9 @@ end

 function SV:PLAYER_REGEN_ENABLED()
     self:UnregisterEvent("PLAYER_REGEN_ENABLED")
-    self:ToggleConfig()
+    if(self.OptionsStandby) then
+        self:ToggleConfig()
+    end
 end

 function SV:TaintHandler(event, taint, sourceName, sourceFunc)
diff --git a/SVUI_!Core/system/errors.lua b/SVUI_!Core/system/errors.lua
index 0c1cf82..7171191 100644
--- a/SVUI_!Core/system/errors.lua
+++ b/SVUI_!Core/system/errors.lua
@@ -24,26 +24,24 @@ LOCAL VARS
 ##########################################################
 ]]--
 local UIErrorsFrame = _G.UIErrorsFrame;
+local SVUI_ErrorsFrame = CreateFrame("Frame", nil);
 local ERR_FILTERS = {};
 --[[
 ##########################################################
 EVENTS
 ##########################################################
 ]]--
-function SV:UI_ERROR_MESSAGE(event, msg)
-	if((not msg) or ERR_FILTERS[msg]) then return end
-	UIErrorsFrame:AddMessage(msg, 1.0, 0.1, 0.1, 1.0);
-end
-
-local ErrorFrameHandler = function(self, event)
+local ErrorFrameHandler = function(self, event, msg)
 	if(event == 'PLAYER_REGEN_DISABLED') then
-		SV:UnregisterEvent('UI_ERROR_MESSAGE')
-	else
-		SV:RegisterEvent('UI_ERROR_MESSAGE')
+		self:UnregisterEvent('UI_ERROR_MESSAGE')
+	elseif(event == 'PLAYER_REGEN_ENABLED') then
+		self:RegisterEvent('UI_ERROR_MESSAGE')
+	elseif(msg and (not ERR_FILTERS[msg])) then
+		UIErrorsFrame:AddMessage(msg, 1.0, 0.1, 0.1, 1.0);
 	end
 end

-function SV:CacheFilters()
+local function CacheFilters()
 	for k, v in pairs(SV.db.general.errorFilters) do
 		ERR_FILTERS[k] = v
 	end
@@ -55,18 +53,18 @@ end

 function SV:UpdateErrorFilters()
 	if(SV.db.general.filterErrors) then
-		self:CacheFilters()
+		CacheFilters()
 		UIErrorsFrame:UnregisterEvent('UI_ERROR_MESSAGE')
-		self:RegisterEvent('UI_ERROR_MESSAGE')
+		SVUI_ErrorsFrame:RegisterEvent('UI_ERROR_MESSAGE')
 		if(SV.db.general.hideErrorFrame) then
-			self:RegisterEvent('PLAYER_REGEN_DISABLED', ErrorFrameHandler)
-			self:RegisterEvent('PLAYER_REGEN_ENABLED', ErrorFrameHandler)
+			SVUI_ErrorsFrame:RegisterEvent('PLAYER_REGEN_DISABLED')
+			SVUI_ErrorsFrame:RegisterEvent('PLAYER_REGEN_ENABLED')
 		end
 	else
 		UIErrorsFrame:RegisterEvent('UI_ERROR_MESSAGE')
-		self:UnregisterEvent('UI_ERROR_MESSAGE')
-		self:UnregisterEvent('PLAYER_REGEN_DISABLED')
-		self:UnregisterEvent('PLAYER_REGEN_ENABLED')
+		SVUI_ErrorsFrame:UnregisterEvent('UI_ERROR_MESSAGE')
+		SVUI_ErrorsFrame:UnregisterEvent('PLAYER_REGEN_DISABLED')
+		SVUI_ErrorsFrame:UnregisterEvent('PLAYER_REGEN_ENABLED')
 	end
 end
 --[[
@@ -76,13 +74,14 @@ LOAD
 ]]--
 local function SetErrorFilters()
 	if(SV.db.general.filterErrors) then
-		SV:CacheFilters()
+		CacheFilters()
 		UIErrorsFrame:UnregisterEvent('UI_ERROR_MESSAGE')
-		SV:RegisterEvent('UI_ERROR_MESSAGE')
+		SVUI_ErrorsFrame:RegisterEvent('UI_ERROR_MESSAGE')
 		if(SV.db.general.hideErrorFrame) then
-			SV:RegisterEvent('PLAYER_REGEN_DISABLED', ErrorFrameHandler)
-			SV:RegisterEvent('PLAYER_REGEN_ENABLED', ErrorFrameHandler)
+			SVUI_ErrorsFrame:RegisterEvent('PLAYER_REGEN_DISABLED')
+			SVUI_ErrorsFrame:RegisterEvent('PLAYER_REGEN_ENABLED')
 		end
+		SVUI_ErrorsFrame:SetScript("OnEvent", ErrorFrameHandler)
 	end
 end

diff --git a/SVUI_!Core/system/gear.lua b/SVUI_!Core/system/gear.lua
index ead6a87..04c7d83 100644
--- a/SVUI_!Core/system/gear.lua
+++ b/SVUI_!Core/system/gear.lua
@@ -63,6 +63,8 @@ local EquipmentSlots = {
 LOCAL FUNCTIONS
 ##########################################################
 ]]--
+local GearHandler = CreateFrame("Frame", nil);
+
 local function SetItemLevelDisplay(globalName, iLevel)
 	local frame = _G[globalName]
 	if(not frame) then return; end
@@ -172,10 +174,10 @@ CORE FUNCTIONS
 local function RefreshInspectedGear()
 	if(not SV.GearBuildComplete) then return end
 	if(InCombatLockdown()) then
-		SV:RegisterEvent("PLAYER_REGEN_ENABLED", RefreshInspectedGear)
+		GearHandler:RegisterEvent("PLAYER_REGEN_ENABLED", RefreshInspectedGear)
 		return
 	else
-		SV:UnregisterEvent("PLAYER_REGEN_ENABLED")
+		GearHandler.WaitingOnInspect = nil
 	end

 	local unit = InspectFrame and InspectFrame.unit or "player";
@@ -188,15 +190,20 @@ local function RefreshInspectedGear()
 	end
 end

+local function UpdateLocals()
+	SHOW_LEVEL = SV.db.Gear.itemlevel.enable
+	SHOW_DURABILITY = SV.db.Gear.durability.enable
+	ONLY_DAMAGED = SV.db.Gear.durability.onlydamaged
+	MAX_LEVEL, AVG_LEVEL = GetAverageItemLevel()
+end
+
 function SV:UpdateGearInfo()
 	if(not SV.GearBuildComplete) then return end
 	if(InCombatLockdown()) then
-		SV:RegisterEvent("PLAYER_REGEN_ENABLED", RefreshGear)
+		GearHandler:RegisterEvent("PLAYER_REGEN_ENABLED")
 		return
-	else
-		SV:UnregisterEvent("PLAYER_REGEN_ENABLED")
 	end
-	SV:UpdateLocals()
+	UpdateLocals()
 	if(SHOW_LEVEL) then
 		SV:ParseGearSlots("player", false, SetItemLevelDisplay, SetItemDurabilityDisplay)
 	else
@@ -204,7 +211,8 @@ function SV:UpdateGearInfo()
 	end
 end

-local Gear_UpdateTabs = function()
+local Gear_UpdateTabs = function()
+	GearHandler.WaitingOnInspect = true
 	SV.Timers:ExecuteTimer(RefreshInspectedGear, 0.2)
 end

@@ -229,9 +237,16 @@ function SV:GearSwap()
 end

 local MSG_PREFIX = "You have equipped equipment set: "
-local GearHandler = CreateFrame("Frame", nil);
+
 local GearHandler_OnEvent = function(self, event, ...)
-	if(event == "EQUIPMENT_SWAP_FINISHED") then
+	if(event == "PLAYER_REGEN_ENABLED") then
+		self:UnregisterEvent("PLAYER_REGEN_ENABLED")
+		if(self.WaitingOnInspect) then
+			SV.Timers:ExecuteTimer(RefreshInspectedGear, 0.2)
+		else
+			SV:UpdateGearInfo()
+		end
+	elseif(event == "EQUIPMENT_SWAP_FINISHED") then
 		if LIVESET then
 			local strMsg = ("%s%s"):format(MSG_PREFIX, LIVESET)
 			SV:AddonMessage(strMsg)
@@ -242,13 +257,6 @@ local GearHandler_OnEvent = function(self, event, ...)
 	end
 end

-function SV:UpdateLocals()
-	SHOW_LEVEL = SV.db.Gear.itemlevel.enable
-	SHOW_DURABILITY = SV.db.Gear.durability.enable
-	ONLY_DAMAGED = SV.db.Gear.durability.onlydamaged
-	MAX_LEVEL, AVG_LEVEL = GetAverageItemLevel()
-end
-
 local function InitializeGearInfo()
 	MSG_PREFIX = L["You have equipped equipment set: "]
 	SHOW_LEVEL = SV.db.Gear.itemlevel.enable