Quantcast

Avoid hard-coding "Ovale" name string to promote reusability.

Johnny C. Lam [04-06-14 - 18:46]
Avoid hard-coding "Ovale" name string to promote reusability.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1268 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
Ovale.lua
OvaleEquipement.lua
OvaleFrame.lua
OvaleRecount.lua
OvaleScore.lua
OvaleSkada.lua
diff --git a/Ovale.lua b/Ovale.lua
index 20147f3..7bd1cb1 100644
--- a/Ovale.lua
+++ b/Ovale.lua
@@ -8,11 +8,11 @@
     file accompanying this program.
 --]]----------------------------------------------------------------------

-local _, addonNamespace = ...
-Ovale = LibStub("AceAddon-3.0"):NewAddon(addonNamespace, "Ovale", "AceConsole-3.0", "AceEvent-3.0")
+local addonName, addonTable = ...
+Ovale = LibStub("AceAddon-3.0"):NewAddon(addonTable, addonName, "AceConsole-3.0", "AceEvent-3.0")

 --<private-static-properties>
-local L = LibStub("AceLocale-3.0"):GetLocale("Ovale")
+local L = LibStub("AceLocale-3.0"):GetLocale(addonName)
 local OvaleOptions = nil

 local format = string.format
@@ -54,7 +54,7 @@ Ovale.listes = {}
 --</public-static-properties>

 --Key bindings
-BINDING_HEADER_OVALE = "Ovale"
+BINDING_HEADER_OVALE = addonName
 BINDING_NAME_OVALE_CHECKBOX0 = L["Inverser la boîte à cocher "].."(1)"
 BINDING_NAME_OVALE_CHECKBOX1 = L["Inverser la boîte à cocher "].."(2)"
 BINDING_NAME_OVALE_CHECKBOX2 = L["Inverser la boîte à cocher "].."(3)"
@@ -86,7 +86,7 @@ function Ovale:OnEnable()
 	self:RegisterEvent("PLAYER_REGEN_DISABLED")
 	self:RegisterEvent("PLAYER_TARGET_CHANGED")

-	self.frame = LibStub("AceGUI-3.0"):Create("OvaleFrame")
+	self.frame = LibStub("AceGUI-3.0"):Create(addonName .. "Frame")
 	self:UpdateFrame()
 end

diff --git a/OvaleEquipement.lua b/OvaleEquipement.lua
index 1f790a4..1f6d540 100644
--- a/OvaleEquipement.lua
+++ b/OvaleEquipement.lua
@@ -8,7 +8,7 @@
     file accompanying this program.
 --]]--------------------------------------------------------------------

-local _, Ovale = ...
+local addonName, Ovale = ...
 local OvaleEquipement = Ovale:NewModule("OvaleEquipement", "AceEvent-3.0")
 Ovale.OvaleEquipement = OvaleEquipement

@@ -49,7 +49,7 @@ local INVSLOT_WAIST = INVSLOT_WAIST
 local INVSLOT_WRIST = INVSLOT_WRIST

 -- frame for tooltip-scanning
-local self_tooltip = API_CreateFrame("GameTooltip", "OvaleScanningTooltip", nil, "GameTooltipTemplate")
+local self_tooltip = API_CreateFrame("GameTooltip", addonName .. "ScanningTooltip", nil, "GameTooltipTemplate")
 do
 	self_tooltip:SetOwner(UIParent, "ANCHOR_NONE")
 end
@@ -1303,7 +1303,7 @@ function GetItemLevel(slotId)
 	self_tooltip:SetInventoryItem("player", slotId)
 	local itemLevel
 	for i = 2, self_tooltip:NumLines() do
-		local text = _G["OvaleScanningTooltipTextLeft" .. i]:GetText()
+		local text = _G[addonName .. "ScanningTooltipTextLeft" .. i]:GetText()
 		if text then
 			itemLevel = strmatch(text, OVALE_ITEM_LEVEL_PATTERN)
 			if itemLevel then
diff --git a/OvaleFrame.lua b/OvaleFrame.lua
index 32dcbce..b0366f4 100644
--- a/OvaleFrame.lua
+++ b/OvaleFrame.lua
@@ -8,7 +8,7 @@
     file accompanying this program.
 --]]--------------------------------------------------------------------

-local _, Ovale = ...
+local addonName, Ovale = ...

 --<class name="OvaleFrame" inherits="Frame" />
 do
@@ -24,7 +24,7 @@ do
 	local OvaleState = Ovale.OvaleState
 	local OvaleTimeSpan = Ovale.OvaleTimeSpan

-	local Type = "OvaleFrame"
+	local Type = addonName .. "Frame"
 	local Version = 7

 	local pairs = pairs
@@ -364,12 +364,12 @@ do
 				local icon
 				if not node.secure then
 					if not action.icons[l] then
-						action.icons[l] = API_CreateFrame("CheckButton", "Icon"..k.."n"..l,self.frame,"OvaleIconTemplate");
+						action.icons[l] = API_CreateFrame("CheckButton", "Icon"..k.."n"..l, self.frame, addonName .. "IconTemplate");
 					end
 					icon = action.icons[l]
 				else
 					if not action.secureIcons[l] then
-						action.secureIcons[l] = API_CreateFrame("CheckButton", "SecureIcon"..k.."n"..l,self.frame,"SecureOvaleIconTemplate");
+						action.secureIcons[l] = API_CreateFrame("CheckButton", "SecureIcon"..k.."n"..l, self.frame, "Secure" .. addonName .. "IconTemplate");
 					end
 					icon = action.secureIcons[l]
 				end
@@ -419,7 +419,7 @@ do

 	local function Constructor()
 		-- Create parent frame for Ovale that auto-hides/shows based on whether the Pet Battle UI is active.
-		local hider = API_CreateFrame("Frame", "OvalePetBattleFrameHider", UIParent, "SecureHandlerStateTemplate")
+		local hider = API_CreateFrame("Frame", addonName .. "PetBattleFrameHider", UIParent, "SecureHandlerStateTemplate")
 		hider:SetAllPoints(true)
 		API_RegisterStateDriver(hider, "visibility", "[petbattle] hide; show")

@@ -449,7 +449,7 @@ do
 		self.barre = self.frame:CreateTexture();
 		self.content = API_CreateFrame("Frame",nil,frame)
 		if Masque then
-			self.skinGroup = Masque:Group("Ovale")
+			self.skinGroup = Masque:Group(addonName)
 		end
 		self.lastUpdate = nil
 		--Cheating with frame object which has an obj property
diff --git a/OvaleRecount.lua b/OvaleRecount.lua
index 01e2c20..e7068c0 100644
--- a/OvaleRecount.lua
+++ b/OvaleRecount.lua
@@ -8,7 +8,7 @@
     file accompanying this program.
 --]]--------------------------------------------------------------------

-local _, Ovale = ...
+local addonName, Ovale = ...
 local OvaleRecount = Ovale:NewModule("OvaleRecount")
 Ovale.OvaleRecount = OvaleRecount

@@ -52,7 +52,7 @@ function OvaleRecount:OnInitialize()
 		if not L then
 			L = setmetatable({}, { __index = function(t, k) t[k] = k; return k; end })
 		end
-		Recount:AddModeTooltip("Ovale", DataModes, TooltipFuncs, nil, nil, nil, nil)
+		Recount:AddModeTooltip(addonName, DataModes, TooltipFuncs, nil, nil, nil, nil)
 	end
 end

@@ -70,8 +70,8 @@ function OvaleRecount:ReceiveScore(name, guid, scored, scoreMax)
 	if Recount then
 		local source = Recount.db2.combatants[name]
 		if source then
-			Recount:AddAmount(source, "Ovale", scored)
-			Recount:AddAmount(source, "OvaleMax", scoreMax)
+			Recount:AddAmount(source, addonName, scored)
+			Recount:AddAmount(source, addonName .. "Max", scoreMax)
 		end
 	end
 end
diff --git a/OvaleScore.lua b/OvaleScore.lua
index 7980e5a..5d9924e 100644
--- a/OvaleScore.lua
+++ b/OvaleScore.lua
@@ -28,7 +28,7 @@
 	or a method name for the module with the given name.
 ]]--

-local _, Ovale = ...
+local addonName, Ovale = ...
 local OvaleScore = Ovale:NewModule("OvaleScore", "AceEvent-3.0")
 Ovale.OvaleScore = OvaleScore

@@ -44,6 +44,9 @@ local API_UnitName = UnitName
 local self_guid = nil
 -- Player's name.
 local self_name = nil
+
+-- Message prefix.
+local MSG_PREFIX = addonName
 --</private-static-properties>

 --<public-static-properties>
@@ -63,7 +66,7 @@ OvaleScore.scoredSpell = {}
 function OvaleScore:OnEnable()
 	self_guid = API_UnitGUID("player")
 	self_name = API_UnitName("player")
-	API_RegisterAddonMessagePrefix("Ovale")
+	API_RegisterAddonMessagePrefix(MSG_PREFIX)
 	self:RegisterEvent("CHAT_MSG_ADDON")
 	self:RegisterEvent("PLAYER_REGEN_ENABLED")
 	self:RegisterEvent("PLAYER_REGEN_DISABLED")
@@ -78,7 +81,7 @@ end
 -- Receive scores for damage meters from other Ovale addons in the raid.
 function OvaleScore:CHAT_MSG_ADDON(event, ...)
 	local prefix, message, channel, sender = ...
-	if prefix ~= "Ovale" then return end
+	if prefix ~= MSG_PREFIX then return end
 	if channel ~= "RAID" and channel ~= "PARTY" then return end

 	local scored, scoreMax, guid = strsplit(";", message)
@@ -90,7 +93,7 @@ function OvaleScore:PLAYER_REGEN_ENABLED()
 	-- Broadcast message is "score;maxScore;playerGUID"
 	if self.maxScore > 0 then
 		local message = self.score .. ";" .. self.maxScore .. ";" .. self_guid
-		API_SendAddonMessage("Ovale", message, "RAID")
+		API_SendAddonMessage(MSG_PREFIX, message, "RAID")
 	end
 end

diff --git a/OvaleSkada.lua b/OvaleSkada.lua
index 2f3edd8..227ad3f 100644
--- a/OvaleSkada.lua
+++ b/OvaleSkada.lua
@@ -8,9 +8,9 @@
     file accompanying this program.
 --]]--------------------------------------------------------------------

-local _, Ovale = ...
+local addonName, Ovale = ...
 local Skada = LibStub("AceAddon-3.0"):GetAddon("Skada", true)
-local OvaleSkada = Skada and Skada:NewModule("Ovale Spell Priority") or Ovale:NewModule("OvaleSkada")
+local OvaleSkada = Skada and Skada:NewModule(addonName) or Ovale:NewModule("OvaleSkada")
 Ovale.OvaleSkada = OvaleSkada

 --<private-static-properties>