Mercurial > wow > prospect-me
comparison ProspectMe_Config.lua @ 49:9dae86337a41
Merge Prospect Me v2 Branch to default
author | Vynn <mischivin@gmail.com> |
---|---|
date | Thu, 17 Nov 2016 16:24:48 -0500 |
parents | 78a07841e004 |
children | ef591210a1e4 |
comparison
equal
deleted
inserted
replaced
28:dc1504b4c03c | 49:9dae86337a41 |
---|---|
1 if not PM_Config then | |
2 PM_Config = {} | |
3 end | |
4 | |
5 local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer) | 1 local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer) |
6 local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge") | 2 local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge") |
7 local ResultsToggle = CreateFrame( "CheckButton", "ProspectMeResultsToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
8 local EpicToggle = CreateFrame( "CheckButton", "ProspectMeEpicToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 3 local EpicToggle = CreateFrame( "CheckButton", "ProspectMeEpicToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
9 local RareToggle = CreateFrame( "CheckButton", "ProspectMeRareToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 4 local RareToggle = CreateFrame( "CheckButton", "ProspectMeRareToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
10 local UncommonToggle = CreateFrame( "CheckButton", "ProspectMeUncommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 5 local UncommonToggle = CreateFrame( "CheckButton", "ProspectMeUncommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
11 local CommonToggle = CreateFrame( "CheckButton", "ProspectMeCommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 6 local CommonToggle = CreateFrame( "CheckButton", "ProspectMeCommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
12 local PoorToggle = CreateFrame( "CheckButton", "ProspectMePoorToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 7 local PoorToggle = CreateFrame( "CheckButton", "ProspectMePoorToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
14 local PercentToggle = CreateFrame( "CheckButton", "ProspectMePercentToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 9 local PercentToggle = CreateFrame( "CheckButton", "ProspectMePercentToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
15 local NumberToggle = CreateFrame( "CheckButton", "ProspectMeNumberToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | 10 local NumberToggle = CreateFrame( "CheckButton", "ProspectMeNumberToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) |
16 local ResetResults = CreateFrame( "Button", "ProspectMeResetButton", ProspectMeFrame, "UIPanelButtonTemplate" ) | 11 local ResetResults = CreateFrame( "Button", "ProspectMeResetButton", ProspectMeFrame, "UIPanelButtonTemplate" ) |
17 local ResetText = PM_ConfigFrame:CreateFontString( "ProspectMeResetText", nil, "GameFontNormal" ) | 12 local ResetText = PM_ConfigFrame:CreateFontString( "ProspectMeResetText", nil, "GameFontNormal" ) |
18 | 13 |
19 local function SetDefaults() | |
20 PM_Config.results = true | |
21 PM_Config.qualities ={[0] = false,[1] = true, [2] = true, [3] = true, [4] = true} | |
22 PM_Config.session = false | |
23 PM_Config.percent = true | |
24 PM_Config.number = true | |
25 PM_Config.savedVariables = true | |
26 end | |
27 | |
28 local function SpewMessage(handle, msg) | 14 local function SpewMessage(handle, msg) |
29 if handle == "loaded" then | 15 if handle == "loaded" then |
30 print(PM_LOADMSG) | 16 print(PM_LOADMSG) |
31 elseif handle == "help" then | 17 elseif handle == "help" then |
32 print(PM_HELPMSG) | 18 print(PM_HELPMSG) |
33 SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP) | 19 SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP) |
34 SpewMessage(PM_RESULTS, PM_RESULTSTOOLTIP) | |
35 SpewMessage(PM_EPIC, PM_EPICTOOLTIP) | 20 SpewMessage(PM_EPIC, PM_EPICTOOLTIP) |
36 SpewMessage(PM_RARE, PM_RARETOOLTIP) | 21 SpewMessage(PM_RARE, PM_RARETOOLTIP) |
37 SpewMessage(PM_UNCOMMON, PM_UNCOMMONTOOLTIP) | 22 SpewMessage(PM_UNCOMMON, PM_UNCOMMONTOOLTIP) |
38 SpewMessage(PM_COMMON, PM_COMMONTOOLTIP) | 23 SpewMessage(PM_COMMON, PM_COMMONTOOLTIP) |
39 SpewMessage(PM_POOR, PM_POORTOOLTIP) | 24 SpewMessage(PM_POOR, PM_POORTOOLTIP) |
44 else | 29 else |
45 print("|cFFFFCC00" .. handle .. "|r - " .. msg) | 30 print("|cFFFFCC00" .. handle .. "|r - " .. msg) |
46 end | 31 end |
47 end | 32 end |
48 | 33 |
49 local function ClearEntry(id) | |
50 if PM_ResultsTable[id] then | |
51 wipe(PM_ResultsTable[id]) | |
52 end | |
53 if PM_SessionTable[id] then | |
54 wipe(PM_SessionTable[id]) | |
55 end | |
56 end | |
57 | |
58 local function ResetDatabase() | 34 local function ResetDatabase() |
59 if PM_ResultsTable then | 35 if ProspectMe.Results then |
60 for i, v in pairs(PM_ResultsTable) do | 36 ProspectMe.Results = {} |
61 ClearEntry(i) | |
62 end | |
63 wipe(PM_ResultsTable) | |
64 end | |
65 if PM_SessionTable then | |
66 wipe(PM_SessionTable) | |
67 end | 37 end |
68 end | 38 end |
69 | 39 |
70 local function UpdateConfig() | 40 local function UpdateConfig() |
71 | 41 ProspectMe.Config.ShowQualities.Junk = ProspectMePoorToggle:GetChecked() |
72 PM_Config.results = ProspectMeResultsToggle:GetChecked() | 42 ProspectMe.Config.ShowQualities.Common = ProspectMeCommonToggle:GetChecked() |
73 PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked() | 43 ProspectMe.Config.ShowQualities.Uncommon = ProspectMeUncommonToggle:GetChecked() |
74 PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked() | 44 ProspectMe.Config.ShowQualities.Rare = ProspectMeRareToggle:GetChecked() |
75 PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked() | 45 ProspectMe.Config.ShowQualities.Epic = ProspectMeEpicToggle:GetChecked() |
76 PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked() | 46 ProspectMe.Config.PerSession = ProspectMeSessionToggle:GetChecked() |
77 PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked() | 47 ProspectMe.Config.ShowPercent = ProspectMePercentToggle:GetChecked() |
78 PM_Config.session = ProspectMeSessionToggle:GetChecked() | 48 ProspectMe.Config.ShowNumber = ProspectMeNumberToggle:GetChecked() |
79 PM_Config.percent = ProspectMePercentToggle:GetChecked() | |
80 PM_Config.number = ProspectMeNumberToggle:GetChecked() | |
81 | |
82 if (PM_Config.results) then | |
83 | |
84 ProspectMePoorToggle:Enable() | |
85 ProspectMeCommonToggle:Enable() | |
86 ProspectMeUncommonToggle:Enable() | |
87 ProspectMeRareToggle:Enable() | |
88 ProspectMeEpicToggle:Enable() | |
89 | |
90 PM_Config.qualities[0] = ProspectMePoorToggle:GetChecked() | |
91 PM_Config.qualities[1] = ProspectMeCommonToggle:GetChecked() | |
92 PM_Config.qualities[2] = ProspectMeUncommonToggle:GetChecked() | |
93 PM_Config.qualities[3] = ProspectMeRareToggle:GetChecked() | |
94 PM_Config.qualities[4] = ProspectMeEpicToggle:GetChecked() | |
95 | |
96 else | |
97 | |
98 ProspectMePoorToggle:Disable() | |
99 ProspectMeCommonToggle:Disable() | |
100 ProspectMeUncommonToggle:Disable() | |
101 ProspectMeRareToggle:Disable() | |
102 ProspectMeEpicToggle:Disable() | |
103 | |
104 end | |
105 end | 49 end |
106 | 50 |
107 local function PM_ConfigInit() | 51 local function PM_ConfigInit() |
108 StaticPopupDialogs["PM_ConfirmReset"] = { | 52 StaticPopupDialogs["PM_ConfirmReset"] = { |
109 text = PM_RESETWARNING, | 53 text = PM_RESETWARNING, |
123 ProspectMeTitle:SetPoint("TOP", 0, -16) | 67 ProspectMeTitle:SetPoint("TOP", 0, -16) |
124 ProspectMeTitle:SetText(GetAddOnMetadata("ProspectMe", "Title") .. " v" .. GetAddOnMetadata("ProspectMe", "Version")) | 68 ProspectMeTitle:SetText(GetAddOnMetadata("ProspectMe", "Title") .. " v" .. GetAddOnMetadata("ProspectMe", "Version")) |
125 | 69 |
126 ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 ) | 70 ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 ) |
127 ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) | 71 ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) |
128 ProspectMeSessionToggle:SetChecked(PM_Config.session) | 72 ProspectMeSessionToggle:SetChecked(ProspectMe.Config.PerSession) |
129 ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) | 73 ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) |
130 ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP | 74 ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP |
131 | 75 |
132 ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 ) | 76 ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 ) |
133 ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) | 77 ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) |
134 ProspectMePercentToggle:SetChecked(PM_Config.percent) | 78 ProspectMePercentToggle:SetChecked(ProspectMe.Config.ShowPercent) |
135 ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) | 79 ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) |
136 ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP | 80 ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP |
137 | 81 |
138 ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 ) | 82 ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 ) |
139 ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) | 83 ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) |
140 ProspectMeNumberToggle:SetChecked(PM_Config.number) | 84 ProspectMeNumberToggle:SetChecked(ProspectMe.Config.ShowNumber) |
141 ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE) | 85 ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE) |
142 ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP | 86 ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP |
143 | |
144 ProspectMeResultsToggle:SetPoint( "TOPLEFT", 32, -118 ) | |
145 ProspectMeResultsToggle:SetScript("OnClick", UpdateConfig) | |
146 ProspectMeResultsToggle:SetChecked(PM_Config.results) | |
147 ProspectMeResultsToggleText:SetText(PM_RESULTSTOGGLE) | |
148 ProspectMeResultsToggle.tooltipText = PM_RESULTSTOOLTIP | |
149 | 87 |
150 ProspectMeEpicToggle:SetPoint( "TOPLEFT", 60, -142 ) | 88 ProspectMeEpicToggle:SetPoint( "TOPLEFT", 32, -118 ) |
151 ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) | 89 ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) |
152 ProspectMeEpicToggle:SetChecked(PM_Config.qualities[4]) | 90 ProspectMeEpicToggle:SetChecked(ProspectMe.Config.ShowQualities.Epic) |
153 ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) | 91 ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) |
154 ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP | 92 ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP |
155 | 93 |
156 ProspectMeRareToggle:SetPoint( "TOPLEFT", 60, -166 ) | 94 ProspectMeRareToggle:SetPoint( "TOPLEFT", 32, -142 ) |
157 ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) | 95 ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) |
158 ProspectMeRareToggle:SetChecked(PM_Config.qualities[3]) | 96 ProspectMeRareToggle:SetChecked(ProspectMe.Config.ShowQualities.Rare) |
159 ProspectMeRareToggleText:SetText(PM_RARETOGGLE) | 97 ProspectMeRareToggleText:SetText(PM_RARETOGGLE) |
160 ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP | 98 ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP |
161 | 99 |
162 ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 60, -190 ) | 100 ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 32, -166 ) |
163 ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) | 101 ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) |
164 ProspectMeUncommonToggle:SetChecked(PM_Config.qualities[2]) | 102 ProspectMeUncommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Uncommon) |
165 ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) | 103 ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) |
166 ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP | 104 ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP |
167 | 105 |
168 ProspectMeCommonToggle:SetPoint( "TOPLEFT", 60, -214 ) | 106 ProspectMeCommonToggle:SetPoint( "TOPLEFT", 32, -190 ) |
169 ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) | 107 ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) |
170 ProspectMeCommonToggle:SetChecked(PM_Config.qualities[1]) | 108 ProspectMeCommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Common) |
171 ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) | 109 ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) |
172 ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP | 110 ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP |
173 | 111 |
174 ProspectMePoorToggle:SetPoint( "TOPLEFT", 60, -238 ) | 112 ProspectMePoorToggle:SetPoint( "TOPLEFT", 32, -214 ) |
175 ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) | 113 ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) |
176 ProspectMePoorToggle:SetChecked(PM_Config.qualities[0]) | 114 ProspectMePoorToggle:SetChecked(ProspectMe.Config.ShowQualities.Poor) |
177 ProspectMePoorToggleText:SetText(PM_POORTOGGLE) | 115 ProspectMePoorToggleText:SetText(PM_POORTOGGLE) |
178 ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP | 116 ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP |
179 | |
180 if (PM_Config.results == false) then | |
181 ProspectMePoorToggle:Disable() | |
182 ProspectMeCommonToggle:Disable() | |
183 ProspectMeUncommonToggle:Disable() | |
184 ProspectMeRareToggle:Disable() | |
185 ProspectMeEpicToggle:Disable() | |
186 end | |
187 | 117 |
188 ProspectMeResetButton:SetPoint("TOP", 0, -310 ) | 118 ProspectMeResetButton:SetPoint("TOP", 0, -310 ) |
189 ProspectMeResetButton:SetScript("OnClick", function(self) StaticPopup_Show("PM_ConfirmReset") end) | 119 ProspectMeResetButton:SetScript("OnClick", function(self) StaticPopup_Show("PM_ConfirmReset") end) |
190 ProspectMeResetButton:SetSize(250, 25) | 120 ProspectMeResetButton:SetSize(250, 25) |
191 ProspectMeResetButton:SetText(PM_RESETBUTTON) | 121 ProspectMeResetButton:SetText(PM_RESETBUTTON) |
195 | 125 |
196 InterfaceOptions_AddCategory(ProspectMeFrame) | 126 InterfaceOptions_AddCategory(ProspectMeFrame) |
197 | 127 |
198 end | 128 end |
199 | 129 |
200 function ProspectMeEventHandler(event, arg1) | 130 local function EventHandler(event, arg1) |
201 if (PM_Config.savedVariables) then | 131 if (ProspectMe.Config) then |
202 PM_ConfigInit() | |
203 else | |
204 SetDefaults() | |
205 PM_ConfigInit() | 132 PM_ConfigInit() |
206 end | 133 end |
207 SpewMessage("loaded") | 134 SpewMessage("loaded") |
208 end | 135 end |
209 | 136 |
243 SpewMessage("help") | 170 SpewMessage("help") |
244 end | 171 end |
245 end | 172 end |
246 | 173 |
247 ProspectMeFrame:RegisterEvent("VARIABLES_LOADED") | 174 ProspectMeFrame:RegisterEvent("VARIABLES_LOADED") |
248 ProspectMeFrame:SetScript("OnEvent", ProspectMeEventHandler) | 175 ProspectMeFrame:SetScript("OnEvent", EventHandler) |