Quantcast

Add 'about' options panel in AddonCore

James Whitehead II [11-13-10 - 12:27]
Add 'about' options panel in AddonCore
Filename
AddonCore.lua
TomTomLite.lua
diff --git a/AddonCore.lua b/AddonCore.lua
index ebf98d8..2367ce7 100644
--- a/AddonCore.lua
+++ b/AddonCore.lua
@@ -155,3 +155,59 @@ function addon:RegisterLocale(locale, tbl)
         end
     end
 end
+
+--[[-------------------------------------------------------------------------
+--  Addon 'About' Dialog for Interface Options
+--
+--  Some of this code was taken from/inspired by tekKonfigAboutPanel
+-------------------------------------------------------------------------]]--
+
+local about = CreateFrame("Frame", addonName .. "AboutPanel", InterfaceOptionsFramePanelContainer)
+about.name = addonName
+about:Hide()
+
+function about.OnShow(frame)
+    local fields = {"Version", "Author", "X-Category", "X-License", "X-Email", "X-Website", "X-Credits"}
+	local notes = GetAddOnMetadata(addonName, "Notes")
+
+    local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
+
+	title:SetPoint("TOPLEFT", 16, -16)
+	title:SetText(addonName)
+
+	local subtitle = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+	subtitle:SetHeight(32)
+	subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
+	subtitle:SetPoint("RIGHT", about, -32, 0)
+	subtitle:SetNonSpaceWrap(true)
+	subtitle:SetJustifyH("LEFT")
+	subtitle:SetJustifyV("TOP")
+	subtitle:SetText(notes)
+
+	local anchor
+	for _,field in pairs(fields) do
+		local val = GetAddOnMetadata(addonName, field)
+		if val then
+			local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
+			title:SetWidth(75)
+			if not anchor then title:SetPoint("TOPLEFT", subtitle, "BOTTOMLEFT", -2, -8)
+			else title:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, -6) end
+			title:SetJustifyH("RIGHT")
+			title:SetText(field:gsub("X%-", ""))
+
+			local detail = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+			detail:SetPoint("LEFT", title, "RIGHT", 4, 0)
+			detail:SetPoint("RIGHT", -16, 0)
+			detail:SetJustifyH("LEFT")
+			detail:SetText(val)
+
+			anchor = title
+		end
+	end
+
+    -- Clear the OnShow so it only happens once
+	frame:SetScript("OnShow", nil)
+end
+
+about:SetScript("OnShow", about.OnShow)
+InterfaceOptions_AddCategory(about)
diff --git a/TomTomLite.lua b/TomTomLite.lua
new file mode 100644
index 0000000..f8d1b49
--- /dev/null
+++ b/TomTomLite.lua
@@ -0,0 +1,12 @@
+--[[-------------------------------------------------------------------
+--  TomTomLite - Copyright 2010 - James N. Whitehead II
+-------------------------------------------------------------------]]--
+
+local addonName, addon = ...
+local L = addon.L
+
+addon.callbacks = LibStub("CallbackHandler-1.0"):New(addon)
+addon.mapdata = LibStub("LibMapData-1.0")
+
+function addon:Initialize()
+end