Quantcast

Load config options at OpenConfig instead of in OnInitialize to save on memory.

Scott Sibley [09-22-10 - 03:45]
Load config options at OpenConfig instead of in OnInitialize to save on memory.
Filename
StarTip.lua
modules.xml
diff --git a/StarTip.lua b/StarTip.lua
index 1000be3..05c331f 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -447,15 +447,28 @@ end

 checkTooltipAlphaFrame = CreateFrame("Frame")

+local menuoptions = {
+	name = "StarTip",
+	type = "group",
+	args = {
+		open = {
+			name = "Open Configuration",
+			type = "execute",
+			func = function() StarTip:OpenConfig() end
+		}
+	}
+}
 function StarTip:OnInitialize()
 	self.db = LibStub("AceDB-3.0"):New("StarTipDB", defaults, "Default")
 	self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
 	self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
 	self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")

-	LibStub("AceConfig-3.0"):RegisterOptionsTable("StarTip", options)
+	LibStub("AceConfig-3.0"):RegisterOptionsTable("StarTip-Addon", options)
+	LibStub("AceConfig-3.0"):RegisterOptionsTable("StarTip", menuoptions)
+	AceConfigDialog:SetDefaultSize("StarTip-Addon", 800, 450)
 	self:RegisterChatCommand("startip", "OpenConfig")
-	AceConfigDialog:AddToBlizOptions("StarTip")
+	AceConfigDialog:AddToBlizOptions("StarTip-Addons-Menu")
 	LibDBIcon:Register("StarTipLDB", LDB, self.db.profile.minimap)

 	if not options.args.Profiles then
@@ -507,9 +520,10 @@ function StarTip:OnEnable()
 		end
 	end

-	self:RestartTimers()

-	self:RebuildOpts()
+	self:RestartTimers()
+
+	--self:RebuildOpts()

 	self:RegisterEvent("MODIFIER_STATE_CHANGED")

@@ -608,8 +622,8 @@ function StarTip:RebuildOpts()
 end

 function StarTip:OpenConfig()
-	AceConfigDialog:SetDefaultSize("StarTip", 800, 450)
-	AceConfigDialog:Open("StarTip")
+	self:RebuildOpts()
+	AceConfigDialog:Open("StarTip-Addon")
 end

 function StarTip.GameTooltipAddLine(...)
diff --git a/modules.xml b/modules.xml
index 1244b92..dd0ccb0 100644
--- a/modules.xml
+++ b/modules.xml
@@ -13,7 +13,8 @@
 <Script file = "Modules\Histograms.lua"/>
 <Script file = "Modules\UnitTooltip.lua"/>

-<!--<Script file = "Modules\Debug.lua"/>
+<!--
+<Script file = "Modules\Debug.lua"/>
 -->

 </Ui>