Mercurial > wow > prospect-me
comparison Modules/ProspectMe_Config.lua @ 60:155fa49865f2 v2.7.1.2-Alpha
Changed directory structure around to clean it up a bit.
author | Vynn <mischivin@gmail.com> |
---|---|
date | Mon, 28 Nov 2016 12:28:35 -0500 |
parents | ProspectMe_Config.lua@ef591210a1e4 |
children | 33d421188c8f |
comparison
equal
deleted
inserted
replaced
59:ef591210a1e4 | 60:155fa49865f2 |
---|---|
1 local ProspectMeFrame = CreateFrame( "Frame", "PM_ConfigFrame", InterfaceOptionsFramePanelContainer) | |
2 local Title = PM_ConfigFrame:CreateFontString( "ProspectMeTitle", nil, "GameFontNormalLarge") | |
3 local EpicToggle = CreateFrame( "CheckButton", "ProspectMeEpicToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
4 local RareToggle = CreateFrame( "CheckButton", "ProspectMeRareToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
5 local UncommonToggle = CreateFrame( "CheckButton", "ProspectMeUncommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
6 local CommonToggle = CreateFrame( "CheckButton", "ProspectMeCommonToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
7 local PoorToggle = CreateFrame( "CheckButton", "ProspectMePoorToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
8 local EconToggle = CreateFrame( "CheckButton", "ProspectMeEconToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
9 local SessionToggle = CreateFrame( "CheckButton", "ProspectMeSessionToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
10 local PercentToggle = CreateFrame( "CheckButton", "ProspectMePercentToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
11 local NumberToggle = CreateFrame( "CheckButton", "ProspectMeNumberToggle", ProspectMeFrame, "InterfaceOptionsCheckButtonTemplate" ) | |
12 local ResetResults = CreateFrame( "Button", "ProspectMeResetButton", ProspectMeFrame, "UIPanelButtonTemplate" ) | |
13 local ResetText = PM_ConfigFrame:CreateFontString( "ProspectMeResetText", nil, "GameFontNormal" ) | |
14 | |
15 local function SpewMessage(handle, msg) | |
16 if handle == "loaded" then | |
17 print(PM_LOADMSG) | |
18 elseif handle == "help" then | |
19 print(PM_HELPMSG) | |
20 SpewMessage(PM_CONFIG, PM_CONFIGTOOLTIP) | |
21 SpewMessage(PM_EPIC, PM_EPICTOOLTIP) | |
22 SpewMessage(PM_RARE, PM_RARETOOLTIP) | |
23 SpewMessage(PM_UNCOMMON, PM_UNCOMMONTOOLTIP) | |
24 SpewMessage(PM_COMMON, PM_COMMONTOOLTIP) | |
25 SpewMessage(PM_POOR, PM_POORTOOLTIP) | |
26 SpewMEssage(PM_ECON, PM_ECONTOOLTIP) | |
27 SpewMessage(PM_SESSION, PM_SESSIONTOOLTIP) | |
28 SpewMessage(PM_PERCENT, PM_PERCENTTOOLTIP) | |
29 SpewMessage(PM_NUMBER, PM_NUMBERTOOLTIP) | |
30 SpewMessage(PM_RESET, PM_RESETTOOLTIP) | |
31 else | |
32 print("|cFFFFCC00" .. handle .. "|r - " .. msg) | |
33 end | |
34 end | |
35 | |
36 local function ResetDatabase() | |
37 if ProspectMe.Results then | |
38 ProspectMe.Results = {} | |
39 end | |
40 end | |
41 | |
42 local function UpdateConfig() | |
43 ProspectMe.Config.ShowQualities.Junk = ProspectMePoorToggle:GetChecked() | |
44 ProspectMe.Config.ShowQualities.Common = ProspectMeCommonToggle:GetChecked() | |
45 ProspectMe.Config.ShowQualities.Uncommon = ProspectMeUncommonToggle:GetChecked() | |
46 ProspectMe.Config.ShowQualities.Rare = ProspectMeRareToggle:GetChecked() | |
47 ProspectMe.Config.ShowQualities.Epic = ProspectMeEpicToggle:GetChecked() | |
48 ProspectMe.Config.ShowEconomics = ProspectMeEconToggle:GetChecked() | |
49 ProspectMe.Config.PerSession = ProspectMeSessionToggle:GetChecked() | |
50 ProspectMe.Config.ShowPercent = ProspectMePercentToggle:GetChecked() | |
51 ProspectMe.Config.ShowNumber = ProspectMeNumberToggle:GetChecked() | |
52 end | |
53 | |
54 local function PM_ConfigInit() | |
55 StaticPopupDialogs["PM_ConfirmReset"] = { | |
56 text = PM_RESETWARNING, | |
57 button1 = YES, | |
58 button2 = NO, | |
59 OnAccept = function() | |
60 ResetDatabase() | |
61 end, | |
62 timeout = 30, | |
63 whileDead = true, | |
64 hideOnEscape = true, | |
65 preferredIndex = 3, | |
66 } | |
67 | |
68 ProspectMeFrame.name = "Prospect Me" | |
69 | |
70 ProspectMeTitle:SetPoint("TOP", 0, -16) | |
71 ProspectMeTitle:SetText(GetAddOnMetadata("ProspectMe", "Title") .. " v" .. GetAddOnMetadata("ProspectMe", "Version")) | |
72 | |
73 ProspectMeEconToggle:SetPoint( "TOPLEFT", 16, -46 ) | |
74 ProspectMeEconToggle:SetScript("OnClick", UpdateConfig) | |
75 ProspectMeEconToggle:SetChecked(ProspectMe.Config.ShowEconomics) | |
76 ProspectMeEconToggleText:SetText(PM_ECONTOGGLE) | |
77 ProspectMeEconToggle.tooltipText = PM_ECONTOOLTIP | |
78 | |
79 ProspectMeSessionToggle:SetPoint( "TOPLEFT", 32, -46 ) | |
80 ProspectMeSessionToggle:SetScript("OnClick", UpdateConfig) | |
81 ProspectMeSessionToggle:SetChecked(ProspectMe.Config.PerSession) | |
82 ProspectMeSessionToggleText:SetText(PM_SESSIONTOGGLE) | |
83 ProspectMeSessionToggle.tooltipText = PM_SESSIONTOOLTIP | |
84 | |
85 ProspectMePercentToggle:SetPoint( "TOPLEFT", 32, -70 ) | |
86 ProspectMePercentToggle:SetScript("OnClick", UpdateConfig) | |
87 ProspectMePercentToggle:SetChecked(ProspectMe.Config.ShowPercent) | |
88 ProspectMePercentToggleText:SetText(PM_PERCENTTOGGLE) | |
89 ProspectMePercentToggle.tooltipText = PM_PERCENTTOOLTIP | |
90 | |
91 ProspectMeNumberToggle:SetPoint( "TOPLEFT", 32, -94 ) | |
92 ProspectMeNumberToggle:SetScript("OnClick", UpdateConfig) | |
93 ProspectMeNumberToggle:SetChecked(ProspectMe.Config.ShowNumber) | |
94 ProspectMeNumberToggleText:SetText(PM_NUMBERTOGGLE) | |
95 ProspectMeNumberToggle.tooltipText = PM_NUMBERTOOLTIP | |
96 | |
97 ProspectMeEpicToggle:SetPoint( "TOPLEFT", 32, -118 ) | |
98 ProspectMeEpicToggle:SetScript("OnClick", UpdateConfig) | |
99 ProspectMeEpicToggle:SetChecked(ProspectMe.Config.ShowQualities.Epic) | |
100 ProspectMeEpicToggleText:SetText(PM_EPICTOGGLE) | |
101 ProspectMeEpicToggle.tooltipText = PM_EPICTOOLTIP | |
102 | |
103 ProspectMeRareToggle:SetPoint( "TOPLEFT", 32, -142 ) | |
104 ProspectMeRareToggle:SetScript("OnClick", UpdateConfig) | |
105 ProspectMeRareToggle:SetChecked(ProspectMe.Config.ShowQualities.Rare) | |
106 ProspectMeRareToggleText:SetText(PM_RARETOGGLE) | |
107 ProspectMeRareToggle.tooltipText = PM_RARETOOLTIP | |
108 | |
109 ProspectMeUncommonToggle:SetPoint( "TOPLEFT", 32, -166 ) | |
110 ProspectMeUncommonToggle:SetScript("OnClick", UpdateConfig) | |
111 ProspectMeUncommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Uncommon) | |
112 ProspectMeUncommonToggleText:SetText(PM_UNCOMMONTOGGLE) | |
113 ProspectMeUncommonToggle.tooltipText = PM_UNCOMMONTOOLTIP | |
114 | |
115 ProspectMeCommonToggle:SetPoint( "TOPLEFT", 32, -190 ) | |
116 ProspectMeCommonToggle:SetScript("OnClick", UpdateConfig) | |
117 ProspectMeCommonToggle:SetChecked(ProspectMe.Config.ShowQualities.Common) | |
118 ProspectMeCommonToggleText:SetText(PM_COMMONTOGGLE) | |
119 ProspectMeCommonToggle.tooltipText = PM_COMMONTOOLTIP | |
120 | |
121 ProspectMePoorToggle:SetPoint( "TOPLEFT", 32, -214 ) | |
122 ProspectMePoorToggle:SetScript("OnClick", UpdateConfig) | |
123 ProspectMePoorToggle:SetChecked(ProspectMe.Config.ShowQualities.Poor) | |
124 ProspectMePoorToggleText:SetText(PM_POORTOGGLE) | |
125 ProspectMePoorToggle.tooltipText = PM_POORTOOLTIP | |
126 | |
127 ProspectMeResetButton:SetPoint("TOP", 0, -310 ) | |
128 ProspectMeResetButton:SetScript("OnClick", function(self) StaticPopup_Show("PM_ConfirmReset") end) | |
129 ProspectMeResetButton:SetSize(250, 25) | |
130 ProspectMeResetButton:SetText(PM_RESETBUTTON) | |
131 | |
132 ProspectMeResetText:SetPoint("TOP", 0, -286) | |
133 ProspectMeResetText:SetText(PM_RESETTOOLTIP) | |
134 | |
135 InterfaceOptions_AddCategory(ProspectMeFrame) | |
136 | |
137 end | |
138 | |
139 local function EventHandler(event, arg1) | |
140 if (ProspectMe.Config) then | |
141 PM_ConfigInit() | |
142 end | |
143 SpewMessage("loaded") | |
144 end | |
145 | |
146 function SlashCmdList.PROSPECTME(msg, editbox) | |
147 if msg == PM_CONFIG then | |
148 InterfaceOptionsFrame_OpenToCategory(ProspectMeFrame) | |
149 elseif msg == PM_ECON then | |
150 ProspectMeEconToggle:SetChecked(not ProspectMeEconToggle:GetChecked()) | |
151 UpdateConfig() | |
152 elseif msg == PM_EPIC then | |
153 ProspectMeEpicToggle:SetChecked(not ProspectMeEpicToggle:GetChecked()) | |
154 UpdateConfig() | |
155 elseif msg == PM_RARE then | |
156 ProspectMeRareToggle:SetChecked(not ProspectMeRareToggle:GetChecked()) | |
157 UpdateConfig() | |
158 elseif msg == PM_UNCOMMON then | |
159 ProspectMeUncommonToggle:SetChecked(not ProspectMeUncommonToggle:GetChecked()) | |
160 UpdateConfig() | |
161 elseif msg == PM_COMMON then | |
162 ProspectMeCommonToggle:SetChecked(not ProspectMeCommonToggle:GetChecked()) | |
163 UpdateConfig() | |
164 elseif msg == PM_POOR then | |
165 ProspectMePoorToggle:SetChecked(not ProspectMePoorToggle:GetChecked()) | |
166 UpdateConfig() | |
167 elseif msg == PM_SESSION then | |
168 ProspectMeSessionToggle:SetChecked(not ProspectMeSessionToggle:GetChecked()) | |
169 UpdateConfig() | |
170 elseif msg == PM_PERCENT then | |
171 ProspectMePercentToggle:SetChecked(not ProspectMePercentToggle:GetChecked()) | |
172 UpdateConfig() | |
173 elseif msg == PM_NUMBER then | |
174 ProspectMeNumberToggle:SetChecked(not ProspectMeNumberToggle:GetChecked()) | |
175 UpdateConfig() | |
176 elseif msg == PM_RESET then | |
177 StaticPopup_Show("PM_ConfirmReset") | |
178 else | |
179 SpewMessage("help") | |
180 end | |
181 end | |
182 | |
183 ProspectMeFrame:RegisterEvent("VARIABLES_LOADED") | |
184 ProspectMeFrame:SetScript("OnEvent", EventHandler) |