Quantcast

Add additional event handlers so information is accurate on initial login.

Johnny C. Lam [03-17-13 - 10:58]
Add additional event handlers so information is accurate on initial login.

PLAYER_ALIVE is triggered when the player's talent & glyph information is
first available and happens after PLAYER_ENTERING_WORLD.

PLAYER_ENTERING_WORLD triggers every time there is a loading screen, so
the information gathered during PLAYER_ALIVE is available at this time
after the first login.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@792 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleData.lua
OvaleEquipement.lua
diff --git a/OvaleData.lua b/OvaleData.lua
index 108e75b..33352e6 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -305,7 +305,8 @@ function OvaleData:OnEnable()
 	self:RegisterEvent("GLYPH_ENABLED", "UpdateGlyphs")
 	self:RegisterEvent("GLYPH_REMOVED", "UpdateGlyphs")
 	self:RegisterEvent("GLYPH_UPDATED", "UpdateGlyphs")
-	self:RegisterEvent("PLAYER_ALIVE")
+	self:RegisterEvent("PLAYER_ALIVE", "Update")
+	self:RegisterEvent("PLAYER_ENTERING_WORLD", "Update")
 	self:RegisterEvent("PLAYER_TALENT_UPDATE", "RemplirListeTalents")
 	self:RegisterEvent("SPELLS_CHANGED", "FillSpellList")
 	self:RegisterEvent("UNIT_PET", "FillPetSpellList")
@@ -319,13 +320,13 @@ function OvaleData:OnDisable()
 	self:UnregisterEvent("GLYPH_REMOVED")
 	self:UnregisterEvent("GLYPH_UPDATED")
 	self:UnregisterEvent("PLAYER_ALIVE")
+	self:UnregisterEvent("PLAYER_ENTERING_WORLD")
 	self:UnregisterEvent("PLAYER_TALENT_UPDATE")
 	self:UnregisterEvent("SPELLS_CHANGED")
 	self:UnregisterEvent("UNIT_PET")
 end

--- Talent information is available to the UI when PLAYER_ALIVE fires.
-function OvaleData:PLAYER_ALIVE(event)
+function OvaleData:Update()
 	self:RemplirListeTalents()
 	self:UpdateGlyphs()
 	self:FillSpellList()
diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua
index 20e2300..ddcd514 100644
--- a/OvaleEquipement.lua
+++ b/OvaleEquipement.lua
@@ -953,12 +953,14 @@ end

 --<public-static-methods>
 function OvaleEquipement:OnEnable()
-	self:RegisterEvent("PLAYER_ENTERING_WORLD")
+	self:RegisterEvent("PLAYER_ENTERING_WORLD", "UpdateEquippedItems")
+	self:RegisterEvent("PLAYER_ALIVE", "UpdateEquippedItems")
 	self:RegisterEvent("PLAYER_EQUIPMENT_CHANGED")
 end

 function OvaleEquipement:OnDisable()
 	self:UnregisterEvent("PLAYER_ENTERING_WORLD")
+	self:UnregisterEvent("PLAYER_ALIVE")
 	self:UnregisterEvent("PLAYER_EQUIPMENT_CHANGED")
 end

@@ -983,12 +985,6 @@ function OvaleEquipement:PLAYER_EQUIPMENT_CHANGED(event, slotId, hasItem)
 	self:SendMessage("Ovale_EquipmentChanged")
 end

-function OvaleEquipement:PLAYER_ENTERING_WORLD(event)
-	self:UpdateEquippedItems()
-	self:UpdateArmorSetCount()
-	self:SendMessage("Ovale_EquipmentChanged")
-end
-
 function OvaleEquipement:GetArmorSetCount(name)
 	if not armorSetCount[name] then
 		return 0
@@ -1048,11 +1044,22 @@ function OvaleEquipement:UpdateArmorSetCount()
 end

 function OvaleEquipement:UpdateEquippedItems()
+	local changed = false
+	local item
 	for slotId = INVSLOT_FIRST_EQUIPPED, INVSLOT_LAST_EQUIPPED do
-		equippedItems[slotId] = GetInventoryItemID("player", slotId)
+		item = GetInventoryItemID("player", slotId)
+		if item ~= equippedItems[slotId] then
+			equippedItems[slotId] = GetInventoryItemID("player", slotId)
+			changed = true
+		end
 	end
 	mainHandItemType = GetEquippedItemType(INVSLOT_MAINHAND)
 	offHandItemType = GetEquippedItemType(INVSLOT_OFFHAND)
+
+	if changed then
+		self:UpdateArmorSetCount()
+		self:SendMessage("Ovale_EquipmentChanged")
+	end
 end

 function OvaleEquipement:Debug()