annotate config.lua @ 13:bb0c8ce689d1 v1.2.15.0

fixed minor bug on startup with new settings
author yellowfive
date Thu, 10 Jul 2014 15:25:18 -0700
parents ece9167c0d1c
children e77e01abce98
rev   line source
adam@0 1 local addonName, AskMrRobot = ...
adam@0 2
adam@0 3 --if not addon.healthCheck then return end
adam@0 4 local L = AskMrRobot.L
adam@0 5
adam@0 6 local wow_ver = select(4, GetBuildInfo())
adam@0 7 local wow_500 = wow_ver >= 50000
adam@0 8 local UIPanelButtonTemplate = wow_500 and "UIPanelButtonTemplate" or "UIPanelButtonTemplate2"
adam@0 9
adam@0 10 local frame = CreateFrame("Frame", nil, InterfaceOptionsFramePanelContainer)
adam@0 11 frame.name = addonName
adam@0 12 frame:Hide()
adam@0 13
adam@0 14 -- Credits to Ace3, Tekkub, cladhaire and Tuller for some of the widget stuff.
adam@0 15
adam@0 16 local function newCheckbox(label, tooltipTitle, description, onClick)
adam@0 17 local check = CreateFrame("CheckButton", "AmrCheck" .. label, frame, "InterfaceOptionsCheckButtonTemplate")
adam@0 18 check:SetScript("OnClick", function(self)
adam@0 19 PlaySound(self:GetChecked() and "igMainMenuOptionCheckBoxOn" or "igMainMenuOptionCheckBoxOff")
adam@0 20 onClick(self, self:GetChecked() and true or false)
adam@0 21 end)
adam@0 22 check.label = _G[check:GetName() .. "Text"]
adam@0 23 check.label:SetText(label)
adam@0 24 check.tooltipText = tooltipTitle
adam@0 25 check.tooltipRequirement = description
adam@0 26 return check
adam@0 27 end
adam@0 28
adam@0 29 frame:SetScript("OnShow", function(frame)
adam@0 30 local title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
adam@0 31 title:SetPoint("TOPLEFT", 16, -16)
adam@0 32 title:SetText(addonName)
adam@0 33
adam@0 34 local subTitleWrapper = CreateFrame("Frame", nil, frame)
adam@0 35 subTitleWrapper:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
adam@0 36 subTitleWrapper:SetPoint("RIGHT", -16, 0)
adam@0 37 local subtitle = subTitleWrapper:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
adam@0 38 subtitle:SetPoint("TOPLEFT", subTitleWrapper)
adam@0 39 subtitle:SetWidth(subTitleWrapper:GetRight() - subTitleWrapper:GetLeft())
adam@0 40 subtitle:SetJustifyH("LEFT")
adam@0 41 subtitle:SetNonSpaceWrap(false)
adam@0 42 subtitle:SetJustifyV("TOP")
yellowfive@11 43 subtitle:SetText(L.AMR_CONFIG_EXIMPORT)
adam@0 44 subTitleWrapper:SetHeight(subtitle:GetHeight())
adam@0 45
adam@0 46 local autoPopup = newCheckbox(
yellowfive@11 47 L.AMR_CONFIG_CHECKBOX_MINIMAP_LABEL,
yellowfive@11 48 L.AMR_CONFIG_CHECKBOX_MINIMAP_TOOLTIP_TITLE,
yellowfive@11 49 L.AMR_CONFIG_CHECKBOX_MINIMAP_DESCRIPTION,
adam@0 50 function(self, value)
adam@0 51 if AmrOptions.hideMapIcon then
adam@0 52 AmrOptions.hideMapIcon = false
adam@0 53 else
adam@0 54 AmrOptions.hideMapIcon = true
adam@0 55 end
adam@0 56 AskMrRobot.AmrUpdateMinimap();
adam@0 57 end
adam@0 58 )
adam@0 59 autoPopup:SetChecked(not AmrOptions.hideMapIcon)
adam@0 60 autoPopup:SetPoint("TOPLEFT", subTitleWrapper, "BOTTOMLEFT", -2, -16)
adam@0 61
adam@0 62 local autoReforge = newCheckbox(
yellowfive@11 63 L.AMR_CONFIG_CHECKBOX_AUTOREFORGE_LABEL,
yellowfive@11 64 L.AMR_CONFIG_CHECKBOX_AUTOREFORGE_TOOLTIP_TITLE,
yellowfive@11 65 L.AMR_CONFIG_CHECKBOX_AUTOREFORGE_DESCRIPTION,
adam@0 66 function(self, value)
adam@0 67 if AmrOptions.manualShowReforge then
adam@0 68 AmrOptions.manualShowReforge = false
adam@0 69 else
adam@0 70 AmrOptions.manualShowReforge = true
adam@0 71 end
adam@0 72 end
adam@0 73 )
adam@0 74 autoReforge:SetChecked(not AmrOptions.manualShowReforge)
adam@0 75 autoReforge:SetPoint("TOPLEFT", subTitleWrapper, "BOTTOMLEFT", -2, -52)
adam@0 76
adam@0 77 local autoAh = newCheckbox(
yellowfive@11 78 L.AMR_CONFIG_CHECKBOX_AUTOAH_LABEL,
yellowfive@11 79 L.AMR_CONFIG_CHECKBOX_AUTOAH_TOOLTIP_TITLE,
yellowfive@11 80 L.AMR_CONFIG_CHECKBOX_AUTOAH_DESCRIPTION,
adam@0 81 function(self, value)
adam@0 82 if AmrOptions.manualShowShop then
adam@0 83 AmrOptions.manualShowShop = false
adam@0 84 else
adam@0 85 AmrOptions.manualShowShop = true
adam@0 86 end
adam@0 87 end
adam@0 88 )
adam@0 89 autoAh:SetChecked(not AmrOptions.manualShowShop)
adam@0 90 autoAh:SetPoint("TOPLEFT", subTitleWrapper, "BOTTOMLEFT", -2, -88)
adam@0 91
adam@0 92 --[[
adam@0 93 AmrOptions.autoLog = AmrOptions.autoLog or {}
adam@0 94
adam@0 95 local autoCombatLog = newCheckbox(
yellowfive@11 96 L.AMR_CONFIG_CHECKBOX_AUTOLOG_LABEL,
yellowfive@11 97 L.AMR_CONFIG_CHECKBOX_AUTOLOG_TOOLTIP_TITLE,
yellowfive@11 98 L.AMR_CONFIG_CHECKBOX_AUTOLOG_DESCRIPTION,
adam@0 99 function(self, value)
adam@0 100 if AmrOptions.autoLog[1136] then
adam@0 101 AmrOptions.autoLog[1136] = false
adam@0 102 else
adam@0 103 AmrOptions.autoLog[1136] = true
adam@0 104 end
adam@0 105 end
adam@0 106 )
adam@0 107 autoCombatLog:SetChecked(AmrOptions.autoLog[1136])
adam@0 108 autoCombatLog:SetPoint("TOPLEFT", subTitleWrapper, "BOTTOMLEFT", -2, -124)
adam@0 109 ]]
adam@0 110
adam@0 111 frame:SetScript("OnShow", nil)
adam@0 112 end)
adam@0 113 InterfaceOptions_AddCategory(frame)
adam@0 114