From 423d60469c51d098e1dfa6008dae5e2479746047 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Sat, 13 Nov 2010 12:27:25 +0000 Subject: [PATCH] Add 'about' options panel in AddonCore --- AddonCore.lua | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ TomTomLite.lua | 12 ++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 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 -- 1.7.9.5