Quantcast

Fix a bug in the blacklist editor due to prior change

James Whitehead II [10-29-10 - 08:19]
Fix a bug in the blacklist editor due to prior change
Filename
Clique.toc
FrameOptionsPanel.lua
OptionsPanel.lua
libs/tekKonfigAboutPanel.lua
diff --git a/Clique.toc b/Clique.toc
index b2dd045..0b9ce16 100755
--- a/Clique.toc
+++ b/Clique.toc
@@ -16,6 +16,7 @@ Localization.zhTW.lua
 libs\LibStub\LibStub.lua
 libs\CallbackHandler-1.0\CallbackHandler-1.0.xml
 libs\AceDB-3.0\AceDB-3.0.xml
+libs\tekKonfigAboutPanel.lua

 DatabaseDefaults.lua

diff --git a/FrameOptionsPanel.lua b/FrameOptionsPanel.lua
index 52b3bec..cf761ee 100644
--- a/FrameOptionsPanel.lua
+++ b/FrameOptionsPanel.lua
@@ -102,16 +102,13 @@ function panel:CreateOptions()
             end
         end

-        for frame in pairs(addon.hccframes) do
-            local name = frame:GetName()
-            if name then
-                state[name] = true
-            end
+        for name, frame in pairs(addon.hccframes) do
+            state[name] = true
         end

         self:UpdateScrollFrame()
     end)
-
+
     self.selectnone = CreateFrame("Button", "CliqueOptionsBlacklistSelectNone", self, "UIPanelButtonTemplate2")
     self.selectnone:SetText(L["Select None"])
     self.selectnone:SetPoint("BOTTOMLEFT", self.selectall, "BOTTOMRIGHT", 5, 0)
@@ -124,11 +121,8 @@ function panel:CreateOptions()
             end
         end

-        for frame in pairs(addon.hccframes) do
-            local name = frame:GetName()
-            if name then
-                state[name] = false
-            end
+        for name, frame in pairs(addon.hccframes) do
+            state[name] = false
         end

         self:UpdateScrollFrame()
@@ -144,13 +138,10 @@ function panel:UpdateScrollFrame()
         end
     end

-    for frame in pairs(addon.hccframes) do
-        local name = frame:GetName()
-        if name then
-            table.insert(sort, name)
-        end
+    for name, frame in pairs(addon.hccframes) do
+        table.insert(sort, name)
     end
-
+
     table.sort(sort)

     local offset = FauxScrollFrame_GetOffset(self.scrollframe)
@@ -193,11 +184,8 @@ function panel.refresh()
         end
     end

-    for frame in pairs(addon.hccframes) do
-        local name = frame:GetName()
-        if name then
-            state[name] = false
-        end
+    for name, frame in pairs(addon.hccframes) do
+        state[name] = false
     end

     for frame, value in pairs(addon.settings.blacklist) do
diff --git a/OptionsPanel.lua b/OptionsPanel.lua
index fc0e78e..523d607 100644
--- a/OptionsPanel.lua
+++ b/OptionsPanel.lua
@@ -9,7 +9,7 @@
 -------------------------------------------------------------------------]]--

 local addonName, addon = ...
-local L = addon.L
+local L = addon.L

 local panel = CreateFrame("Frame")
 panel.name = addonName
@@ -35,7 +35,7 @@ local function make_dropdown(name, parent)
     local frame = CreateFrame("Frame", name, parent, "UIDropDownMenuTemplate")
     frame:SetClampedToScreen(true)
     frame.type = "dropdown"
-    return frame
+    return frame
 end

 local function make_label(name, parent, template)
@@ -52,7 +52,7 @@ function panel:CreateOptions()

     -- Create the general options panel here:
     local bits = {}
-
+
     self.updown = make_checkbox("CliqueOptionsUpDownClick", self)
     self.updown.text:SetText(L["Trigger bindings on the 'down' portion of the click (experimental)"])

@@ -68,7 +68,7 @@ function panel:CreateOptions()
         else
             UIDropDownMenu_DisableDropDown(panel.prispec)
             UIDropDownMenu_DisableDropDown(panel.secspec)
-        end
+        end
     end
     self.specswap:SetScript("PostClick", self.specswap.EnableDisable)

@@ -191,7 +191,7 @@ local function spec_initialize(dropdown, level)

     if not level or level == 1 then
         if not paged then
-            -- Display the profiles un-paged
+            -- Display the profiles un-paged
             for idx, entry in ipairs(sort) do
                 local info = UIDropDownMenu_CreateInfo()
                 info.text = entry
@@ -204,7 +204,7 @@ local function spec_initialize(dropdown, level)
         else
             -- Page the results into sub-menus
             for idx = 1, #sort, 10 do
-                -- Make the submenus for each group
+                -- Make the submenus for each group
                 local lastidx = (idx + 9 > #sort) and #sort or (idx + 9)
                 local info = UIDropDownMenu_CreateInfo()
                 local first = sort[idx]
@@ -242,7 +242,7 @@ local function mgmt_initialize(dropdown, level)

     if not level or level == 1 then
         if not paged then
-            -- Display the profiles un-paged
+            -- Display the profiles un-paged
             for idx, entry in ipairs(sort) do
                 local info = UIDropDownMenu_CreateInfo()
                 info.text = entry
@@ -254,7 +254,7 @@ local function mgmt_initialize(dropdown, level)
         else
             -- Page the results into sub-menus
             for idx = 1, #sort, 10 do
-                -- Make the submenus for each group
+                -- Make the submenus for each group
                 local lastidx = (idx + 9 > #sort) and #sort or (idx + 9)
                 local info = UIDropDownMenu_CreateInfo()
                 local first = sort[idx]
@@ -300,7 +300,7 @@ local function mgmt_initialize(dropdown, level)
             --info.disabled = addon.settings.specswap
             info.func = function(frame)
                 UIDropDownMenu_SetSelectedValue(dropdown, UIDROPDOWNMENU_MENU_VALUE)
-                UIDropDownMenu_SetText(dropdown, UIDROPDOWNMENU_MENU_VALUE)
+                UIDropDownMenu_SetText(dropdown, UIDROPDOWNMENU_MENU_VALUE)
                 addon.db:SetProfile(UIDROPDOWNMENU_MENU_VALUE)
             end
             UIDropDownMenu_AddButton(info, level)
@@ -328,14 +328,14 @@ local function mgmt_initialize(dropdown, level)
         info.disabled = addon.settings.specswap
         info.func = function(frame)
             UIDropDownMenu_SetSelectedValue(dropdown, UIDROPDOWNMENU_MENU_VALUE)
-            UIDropDownMenu_SetText(dropdown, UIDROPDOWNMENU_MENU_VALUE)
+            UIDropDownMenu_SetText(dropdown, UIDROPDOWNMENU_MENU_VALUE)
             addon.db:SetProfile(UIDROPDOWNMENU_MENU_VALUE)
         end
         UIDropDownMenu_AddButton(info, level)

         info = UIDropDownMenu_CreateInfo()
         info.text = L["Delete profile: %s"]:format(UIDROPDOWNMENU_MENU_VALUE)
-        info.disabled = UIDROPDOWNMENU_MENU_VALUE == currentProfile
+        info.disabled = UIDROPDOWNMENU_MENU_VALUE == currentProfile
         info.value = sort[UIDROPDOWNMENU_MENU_VALUE]
         info.func = function(frame)
             local dialog = StaticPopupDialogs["CLIQUE_CONFIRM_PROFILE_DELETE"]
@@ -359,15 +359,15 @@ function panel.refresh()
     UIDropDownMenu_Initialize(panel.prispec, spec_initialize)
     UIDropDownMenu_SetSelectedValue(panel.prispec, settings.pri_profileKey or currentProfile)
     UIDropDownMenu_SetText(panel.prispec, settings.pri_profileKey or currentProfile)
-
-    UIDropDownMenu_Initialize(panel.secspec, spec_initialize)
+
+    UIDropDownMenu_Initialize(panel.secspec, spec_initialize)
     UIDropDownMenu_SetSelectedValue(panel.secspec, settings.sec_profileKey or currentProfile)
     UIDropDownMenu_SetText(panel.secspec, settings.sec_profileKey or currentProfile)
-
+
     UIDropDownMenu_Initialize(panel.profiledd, mgmt_initialize)
     UIDropDownMenu_SetSelectedValue(panel.profiledd, currentProfile)
     UIDropDownMenu_SetText(panel.profiledd, L["Current: "] .. currentProfile)
-
+
     panel.updown:SetChecked(settings.downclick)
     panel.fastooc:SetChecked(settings.fastooc)
     panel.specswap:SetChecked(settings.specswap)
@@ -400,3 +400,5 @@ function addon:UpdateOptionsPanel()
 end

 InterfaceOptions_AddCategory(panel)
+
+LibStub("tekKonfig-AboutPanel").new(addonName, addonName)
diff --git a/libs/tekKonfigAboutPanel.lua b/libs/tekKonfigAboutPanel.lua
new file mode 100644
index 0000000..f7ea166
--- /dev/null
+++ b/libs/tekKonfigAboutPanel.lua
@@ -0,0 +1,115 @@
+
+local lib, oldminor = LibStub:NewLibrary("tekKonfig-AboutPanel", 5)
+if not lib then return end
+
+
+function lib.new(parent, addonname)
+	local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
+	frame.name, frame.parent, frame.addonname = parent and "About" or addonname, parent, addonname
+	frame:Hide()
+	frame:SetScript("OnShow", lib.OnShow)
+	InterfaceOptions_AddCategory(frame)
+	return frame
+end
+
+
+local editbox = CreateFrame('EditBox', nil, UIParent)
+editbox:Hide()
+editbox:SetAutoFocus(true)
+editbox:SetHeight(32)
+editbox:SetFontObject('GameFontHighlightSmall')
+lib.editbox = editbox
+
+local left = editbox:CreateTexture(nil, "BACKGROUND")
+left:SetWidth(8) left:SetHeight(20)
+left:SetPoint("LEFT", -5, 0)
+left:SetTexture("Interface\\Common\\Common-Input-Border")
+left:SetTexCoord(0, 0.0625, 0, 0.625)
+
+local right = editbox:CreateTexture(nil, "BACKGROUND")
+right:SetWidth(8) right:SetHeight(20)
+right:SetPoint("RIGHT", 0, 0)
+right:SetTexture("Interface\\Common\\Common-Input-Border")
+right:SetTexCoord(0.9375, 1, 0, 0.625)
+
+local center = editbox:CreateTexture(nil, "BACKGROUND")
+center:SetHeight(20)
+center:SetPoint("RIGHT", right, "LEFT", 0, 0)
+center:SetPoint("LEFT", left, "RIGHT", 0, 0)
+center:SetTexture("Interface\\Common\\Common-Input-Border")
+center:SetTexCoord(0.0625, 0.9375, 0, 0.625)
+
+editbox:SetScript("OnEscapePressed", editbox.ClearFocus)
+editbox:SetScript("OnEnterPressed", editbox.ClearFocus)
+editbox:SetScript("OnEditFocusLost", editbox.Hide)
+editbox:SetScript("OnEditFocusGained", editbox.HighlightText)
+editbox:SetScript("OnTextChanged", function(self)
+	self:SetText(self:GetParent().val)
+	self:HighlightText()
+end)
+
+
+function lib.OpenEditbox(self)
+	editbox:SetText(self.val)
+	editbox:SetParent(self)
+	editbox:SetPoint("LEFT", self)
+	editbox:SetPoint("RIGHT", self)
+	editbox:Show()
+end
+
+
+local fields = {"Version", "Author", "X-Category", "X-License", "X-Email", "X-Website", "X-Credits"}
+local haseditbox = {["Version"] = true, ["X-Website"] = true, ["X-Email"] = true}
+local function HideTooltip() GameTooltip:Hide() end
+local function ShowTooltip(self)
+	GameTooltip:SetOwner(self, "ANCHOR_TOPRIGHT")
+	GameTooltip:SetText("Click and press Ctrl-C to copy")
+end
+function lib.OnShow(frame)
+	local notes = GetAddOnMetadata(frame.addonname, "Notes")
+
+	local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
+	title:SetPoint("TOPLEFT", 16, -16)
+	title:SetText((frame.parent or frame.addonname).." - About")
+
+	local subtitle = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
+	subtitle:SetHeight(32)
+	subtitle:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
+	subtitle:SetPoint("RIGHT", parent, -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(frame.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((haseditbox[field] and "|cff9999ff" or "").. val)
+
+			if haseditbox[field] then
+				local button = CreateFrame("Button", nil, frame)
+				button:SetAllPoints(detail)
+				button.val = val
+				button:SetScript("OnClick", lib.OpenEditbox)
+				button:SetScript("OnEnter", ShowTooltip)
+				button:SetScript("OnLeave", HideTooltip)
+			end
+
+			anchor = title
+		end
+	end
+
+	frame:SetScript("OnShow", nil)
+end