Mercurial > wow > prospect-me
comparison ProspectMe_Config.lua @ 0:69b46322ff1b v1.2.1-Alpha
Updated Prospect me for initial client v6.0.3 support. Warning, there may be bugs!
| author | Vynn |
|---|---|
| date | Mon, 15 Dec 2014 22:51:49 -0500 |
| parents | |
| children | dabd5c6540ca |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:69b46322ff1b |
|---|---|
| 1 PM_Config = {} | |
| 2 | |
| 3 local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer) | |
| 4 local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge") | |
| 5 local ResultsToggle = CreateFrame( "CheckButton", "ProspectMeResultsToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 6 local EpicToggle = CreateFrame( "CheckButton", "ProspectMeEpicToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 7 local RareToggle = CreateFrame( "CheckButton", "ProspectMeRareToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 8 local UncommonToggle = CreateFrame( "CheckButton", "ProspectMeUncommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 9 local CommonToggle = CreateFrame( "CheckButton", "ProspectMeCommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 10 local PoorToggle = CreateFrame( "CheckButton", "ProspectMePoorToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 11 local SessionToggle = CreateFrame( "CheckButton", "ProspectMeSessionToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 12 local PercentToggle = CreateFrame( "CheckButton", "ProspectMePercentToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 13 local NumberToggle = CreateFrame( "CheckButton", "ProspectMeNumberToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
| 14 local ResetResults = CreateFrame( "Button", "ProspectMeResetButton", ProspectMeFrame, "UIPanelButtonTemplate" ) | |
| 15 local ResetText = PM_ConfigFrame:CreateFontString( "ProspectMeResetText", nil, "GameFontNormal" ) | |
| 16 | |
| 17 local function SetDefaults() | |
| 18 PM_Config.results = true | |
| 19 PM_Config.qualities ={[0] = false,[1] = true, [2] = true, [3] = true, [4] = true} | |
| 20 PM_Config.session = false | |
| 21 PM_Config.percent = true | |
| 22 PM_Config.number = true | |
| 23 PM_Config.savedVariables = true | |
| 24 end | |
| 25 | |
| 26 local function SpewMessage(handle, msg) | |
| 27 if handle == "loaded" then | |
| 28 print(PM_LOADMSG) | |
| 29 elseif handle == "help" then | |
| 30 print(PM_HELPMSG) | |
| 31 SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP) | |
| 32 SpewMessage(PM_RESULTS, PM_RESULTSTOOLTIP) | |
| 33 SpewMessage(PM_EPIC, PM_EPICTOOLTIP) | |
| 34 SpewMessage(PM_RARE, PM_RARETOOLTIP) | |
| 35 SpewMessage(PM_UNCOMMON, PM_UNCOMMONTOOLTIP) | |
| 36 SpewMessage(PM_COMMON, PM_COMMONTOOLTIP) | |
| 37 SpewMessage(PM_POOR, PM_POORTOOLTIP) | |
| 38 SpewMessage(PM_SESSION, PM_SESSIONTOOLTIP) | |
| 39 SpewMessage(PM_PERCENT, PM_PERCENTTOOLTIP) | |
| 40 SpewMessage(PM_NUMBER, PM_NUMBERTOOLTIP) | |
| 41 SpewMessage(PM_RESET, PM_RESETTOOLTIP) | |
| 42 else | |
| 43 print("|cFFFFCC00" .. handle .. "|r - " .. msg) | |
| 44 end | |
| 45 end | |
| 46 | |
| 47 local function ClearEntry(id) | |
| 48 if PM_ResultsTable[id] then | |
| 49 wipe(PM_ResultsTable[id]) | |
| 50 end | |
| 51 if PM_SessionTable[id] then | |
| 52 wipe(PM_SessionTable[id]) | |
| 53 end | |
| 54 end | |
| 55 | |
| 56 local function ResetDatabase() | |
| 57 for i, v in pairs(PM_ResultsTable) do | |
| 58 ClearEntry(i) | |
| 59 end | |
| 60 wipe(PM_ResultsTable) | |
| 61 wipe(PM_SessionTable) | |
| 62 end | |
| 63 | |
| 64 local function UpdateConfig() | |
| 65 | |
| 66 PM_Config.results = ProspectMeResultsToggle:GetChecked() | |
| 67 PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked() | |
| 68 PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked() | |
| 69 PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked() | |
| 70 PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked() | |
| 71 PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked() | |
| 72 PM_Config.session = ProspectMeSessionToggle:GetChecked() | |
| 73 PM_Config.percent = ProspectMePercentToggle:GetChecked() | |
| 74 PM_Config.number = ProspectMeNumberToggle:GetChecked() | |
| 75 | |
| 76 if (PM_Config.results) then | |
| 77 | |
| 78 ProspectMePoorToggle:Enable() | |
| 79 ProspectMeCommonToggle:Enable() | |
| 80 ProspectMeUncommonToggle:Enable() | |
| 81 ProspectMeRareToggle:Enable() | |
| 82 ProspectMeEpicToggle:Enable() | |
| 83 | |
| 84 PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked() | |
| 85 PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked() | |
| 86 PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked() | |
| 87 PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked() | |
| 88 PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked() | |
| 89 | |
| 90 else | |
| 91 | |
| 92 ProspectMePoorToggle:Disable() | |
| 93 ProspectMeCommonToggle:Disable() | |
| 94 ProspectMeUncommonToggle:Disable() | |
| 95 ProspectMeRareToggle:Disable() | |
| 96 ProspectMeEpicToggle:Disable() | |
| 97 | |
| 98 end | |
| 99 end | |
| 100 | |
| 101 local function PM_ConfigInit() | |
| 102 StaticPopupDialogs["PM_ConfirmReset"] = { | |
| 103 text = PM_RESETWARNING, | |
| 104 button1 = YES, | |
| 105 button2 = NO, | |
| 106 OnAccept = function() | |
| 107 ResetDatabase() | |
| 108 end, | |
| 109 timeout = 30, | |
| 110 whileDead = true, | |
| 111 hideOnEscape = true, | |
| 112 preferredIndex = 3, | |
| 113 } | |
| 114 | |
| 115 ProspectMeFrame.name = "Prospect Me" | |
| 116 | |
| 117 ProspectMeTitle:SetPoint("TOP", 0, -16) | |
| 118 ProspectMeTitle:SetText(GetAddOnMetadata("ProspectMe", "Title") .. " v" .. GetAddOnMetadata("ProspectMe", "Version")) | |
| 119 | |
| 120 ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 ) | |
| 121 ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) | |
| 122 ProspectMeSessionToggle:SetChecked(PM_Config.session) | |
| 123 ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) | |
| 124 ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP | |
| 125 | |
| 126 ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 ) | |
| 127 ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) | |
| 128 ProspectMePercentToggle:SetChecked(PM_Config.percent) | |
| 129 ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) | |
| 130 ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP | |
| 131 | |
| 132 ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 ) | |
| 133 ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) | |
| 134 ProspectMeNumberToggle:SetChecked(PM_Config.number) | |
| 135 ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE) | |
| 136 ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP | |
| 137 | |
| 138 ProspectMeResultsToggle:SetPoint( "TOPLEFT", 32, -118 ) | |
| 139 ProspectMeResultsToggle:SetScript("OnClick", UpdateConfig) | |
| 140 ProspectMeResultsToggle:SetChecked(PM_Config.results) | |
| 141 ProspectMeResultsToggleText:SetText(PM_RESULTSTOGGLE) | |
| 142 ProspectMeResultsToggle.tooltipText = PM_RESULTSTOOLTIP | |
| 143 | |
| 144 ProspectMeEpicToggle:SetPoint( "TOPLEFT", 60, -142 ) | |
| 145 ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) | |
| 146 ProspectMeEpicToggle:SetChecked(PM_Config.qualities[4]) | |
| 147 ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) | |
| 148 ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP | |
| 149 | |
| 150 ProspectMeRareToggle:SetPoint( "TOPLEFT", 60, -166 ) | |
| 151 ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) | |
| 152 ProspectMeRareToggle:SetChecked(PM_Config.qualities[3]) | |
| 153 ProspectMeRareToggleText:SetText(PM_RARETOGGLE) | |
| 154 ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP | |
| 155 | |
| 156 ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 60, -190 ) | |
| 157 ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) | |
| 158 ProspectMeUncommonToggle:SetChecked(PM_Config.qualities[2]) | |
| 159 ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) | |
| 160 ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP | |
| 161 | |
| 162 ProspectMeCommonToggle:SetPoint( "TOPLEFT", 60, -214 ) | |
| 163 ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) | |
| 164 ProspectMeCommonToggle:SetChecked(PM_Config.qualities[1]) | |
| 165 ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) | |
| 166 ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP | |
| 167 | |
| 168 ProspectMePoorToggle:SetPoint( "TOPLEFT", 60, -238 ) | |
| 169 ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) | |
| 170 ProspectMePoorToggle:SetChecked(PM_Config.qualities[0]) | |
| 171 ProspectMePoorToggleText:SetText(PM_POORTOGGLE) | |
| 172 ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP | |
| 173 | |
| 174 if (PM_Config.results == false) then | |
| 175 ProspectMePoorToggle:Disable() | |
| 176 ProspectMeCommonToggle:Disable() | |
| 177 ProspectMeUncommonToggle:Disable() | |
| 178 ProspectMeRareToggle:Disable() | |
| 179 ProspectMeEpicToggle:Disable() | |
| 180 end | |
| 181 | |
| 182 ProspectMeResetButton:SetPoint("TOP", 0, -310 ) | |
| 183 ProspectMeResetButton:SetScript("OnClick", function(self) StaticPopup_Show("PM_ConfirmReset") end) | |
| 184 ProspectMeResetButton:SetSize(250, 25) | |
| 185 ProspectMeResetButton:SetText(PM_RESETBUTTON) | |
| 186 | |
| 187 ProspectMeResetText:SetPoint("TOP", 0, -286) | |
| 188 ProspectMeResetText:SetText(PM_RESETTOOLTIP) | |
| 189 | |
| 190 InterfaceOptions_AddCategory(ProspectMeFrame) | |
| 191 | |
| 192 end | |
| 193 | |
| 194 function ProspectMeEventHandler(event, arg1) | |
| 195 if (PM_Config.savedVariables) then | |
| 196 PM_ConfigInit() | |
| 197 else | |
| 198 SetDefaults() | |
| 199 PM_ConfigInit() | |
| 200 end | |
| 201 SpewMessage("loaded") | |
| 202 end | |
| 203 | |
| 204 function SlashCmdList.PROSPECTME(msg, editbox) | |
| 205 if msg == PM_CONFIG then | |
| 206 InterfaceOptionsFrame_OpenToCategory(ProspectMeFrame) | |
| 207 elseif msg == PM_RESULTS then | |
| 208 ProspectMeResultsToggle:SetChecked(not ProspectMeResultsToggle:GetChecked()) | |
| 209 UpdateConfig() | |
| 210 elseif msg == PM_EPIC then | |
| 211 ProspectMeEpicToggle:SetChecked(not ProspectMeEpicToggle:GetChecked()) | |
| 212 UpdateConfig() | |
| 213 elseif msg == PM_RARE then | |
| 214 ProspectMeRareToggle:SetChecked(not ProspectMeRareToggle:GetChecked()) | |
| 215 UpdateConfig() | |
| 216 elseif msg == PM_UNCOMMON then | |
| 217 ProspectMeUncommonToggle:SetChecked(not ProspectMeUncommonToggle:GetChecked()) | |
| 218 UpdateConfig() | |
| 219 elseif msg == PM_COMMON then | |
| 220 ProspectMeCommonToggle:SetChecked(not ProspectMeCommonToggle:GetChecked()) | |
| 221 UpdateConfig() | |
| 222 elseif msg == PM_POOR then | |
| 223 ProspectMePoorToggle:SetChecked(not ProspectMePoorToggle:GetChecked()) | |
| 224 UpdateConfig() | |
| 225 elseif msg == PM_SESSION then | |
| 226 ProspectMeSessionToggle:SetChecked(not ProspectMeSessionToggle:GetChecked()) | |
| 227 UpdateConfig() | |
| 228 elseif msg == PM_PERCENT then | |
| 229 ProspectMePercentToggle:SetChecked(not ProspectMePercentToggle:GetChecked()) | |
| 230 UpdateConfig() | |
| 231 elseif msg == PM_NUMBER then | |
| 232 ProspectMeNumberToggle:SetChecked(not ProspectMeNumberToggle:GetChecked()) | |
| 233 UpdateConfig() | |
| 234 elseif msg == PM_RESET then | |
| 235 StaticPopup_Show("PM_ConfirmReset") | |
| 236 else | |
| 237 SpewMessage("help") | |
| 238 end | |
| 239 end | |
| 240 | |
| 241 ProspectMeFrame:RegisterEvent("VARIABLES_LOADED") | |
| 242 ProspectMeFrame:SetScript("OnEvent", ProspectMeEventHandler) |
