Mercurial > wow > bloodhound2
comparison Config.lua @ 0:ff01eb61abab
Initial beta version
Updated original addon herb and ore database
Fixed the configuration options (maybe - requires testing)
Added the 2 new zones in Pandaria (Isle of Giants and Isle of Thunder)
author | only1yzerman |
---|---|
date | Thu, 09 May 2013 18:53:18 -0400 |
parents | |
children | 75ca29b399e8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ff01eb61abab |
---|---|
1 -------- YOU'RE ON YOUR OWN HERE, THIS IS A FRIKKIN MESS - Osmium | |
2 -------- Challenge Accepted - Whyzerman | |
3 | |
4 local element; | |
5 local frame; | |
6 | |
7 Settings = {}; | |
8 Settings.MultiZoneMode = 0; | |
9 Settings.HerbFilter = {}; | |
10 Settings.OreFilter = {}; | |
11 Settings.ZoneFilter = {{}, {}, {}, {}, {}}; | |
12 Settings.InspectionRadius = 60; | |
13 local function Title(text) | |
14 local str = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge"); | |
15 str:SetPoint("TOPLEFT", element, "TOPLEFT", 16, -16); | |
16 str:SetJustifyH("LEFT"); | |
17 str:SetJustifyV("TOP"); | |
18 str:SetText(text); | |
19 element = str; | |
20 end | |
21 | |
22 local function Column2(offset) | |
23 local str = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge"); | |
24 str:SetPoint("TOPLEFT", element, "TOPRIGHT", -offset, -16); | |
25 str:SetText(" "); | |
26 element = str; | |
27 end | |
28 | |
29 local function Heading(text) | |
30 local str = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); | |
31 str:SetPoint("TOPLEFT", element, "BOTTOMLEFT", 0, -8); | |
32 str:SetText(text); | |
33 element = str; | |
34 end | |
35 | |
36 local ddCount = 0; | |
37 | |
38 local function DropDown(settings, key, width, init) | |
39 ddCount = ddCount + 1; | |
40 local dd = CreateFrame("Frame", "dropDown"..ddCount, frame, "UIDropDownMenuTemplate"); | |
41 dd:EnableMouse(true); | |
42 dd:SetPoint("TOPLEFT", element, "BOTTOMLEFT", 0, -8); | |
43 dd.State = {}; | |
44 UIDropDownMenu_Initialize(dd, init); | |
45 UIDropDownMenu_SetWidth(dd, width); | |
46 UIDropDownMenu_JustifyText(dd, "LEFT"); | |
47 UIDropDownMenu_SetSelectedValue(dd, settings[key]); | |
48 element = dd; | |
49 end | |
50 | |
51 function AddButton(settings, key, menu, label, value) | |
52 local info = UIDropDownMenu_CreateInfo(); | |
53 info.text = label; | |
54 info.value = value; | |
55 info.owner = menu; | |
56 info.func = function() | |
57 UIDropDownMenu_SetSelectedValue(menu, value); | |
58 settings[key] = value; | |
59 Bloodhound2.UpdateMinimap(); | |
60 end; | |
61 UIDropDownMenu_AddButton(info); | |
62 end | |
63 | |
64 local cbCount = 0; | |
65 | |
66 function CheckBox(label, value, relative, anchor, dx, dy, state) | |
67 cbCount = cbCount + 1; | |
68 local cb = CreateFrame("CheckButton", "checkBox"..cbCount, frame, "UICheckButtonTemplate"); | |
69 cb:SetWidth(16); | |
70 cb:SetHeight(16); | |
71 cb:SetPoint("TOPLEFT", relative, anchor, dx, dy); | |
72 local text = getglobal(cb:GetName() .. "Text"); | |
73 text:SetText(label); | |
74 cb:SetChecked(not state[value]); | |
75 cb:SetScript("OnClick", function(self) | |
76 if (self:GetChecked()) then | |
77 state[value] = nil; | |
78 else | |
79 state[value] = 1; | |
80 end | |
81 Bloodhound2.UpdateMinimap(); | |
82 end); | |
83 element = cb; | |
84 return text:GetWidth(); | |
85 end | |
86 | |
87 function ContinentName() | |
88 return select(GetCurrentMapContinent(), GetMapContinents()); | |
89 end | |
90 | |
91 function CheckBoxes(table, state) | |
92 local relative; | |
93 local bottom; | |
94 local height = 1; | |
95 local maxWidth = 0; | |
96 local i = 0; | |
97 local checkboxes = {}; | |
98 | |
99 for k, v in pairs(table) do | |
100 height = height + 1; | |
101 end | |
102 | |
103 height = floor(height / 2); | |
104 if height > 19 then height = 19; end; | |
105 | |
106 for k, v in pairs(table) do | |
107 i = i + 1; | |
108 if (i > 1) and (mod(i, height) == 1) then | |
109 width = CheckBox(v, k, relative, "TOPRIGHT", maxWidth + 6, 0, state); | |
110 relative = element; | |
111 maxWidth = width; | |
112 else | |
113 width = CheckBox(v, k, element, "BOTTOMLEFT", 0, 0, state); | |
114 if (i == 1) then relative = element; end; | |
115 maxWidth = max(width, maxWidth); | |
116 end | |
117 if (i == height) then bottom = element; end; | |
118 checkboxes[k] = element; | |
119 end | |
120 | |
121 local button = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate"); | |
122 button:SetText(L["All"]); | |
123 local allWidth = button:GetTextWidth() + 30; | |
124 button:SetWidth(allWidth); | |
125 button:SetHeight(22); | |
126 button:SetPoint("TOPLEFT", bottom, "TOPLEFT", 0, -20); | |
127 button:SetScript("OnClick", | |
128 function(self, button, down) | |
129 for k, v in pairs(table) do | |
130 checkboxes[k]:SetChecked(true); | |
131 state[k] = nil; | |
132 end | |
133 end | |
134 ); | |
135 | |
136 element = button; | |
137 | |
138 local button = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate"); | |
139 button:SetText(L["None"]); | |
140 button:SetWidth(button:GetTextWidth() + 30); | |
141 button:SetHeight(22); | |
142 button:SetPoint("TOPLEFT", bottom, "TOPLEFT", allWidth + 20, -20); | |
143 button:SetScript("OnClick", | |
144 function(self, button, down) | |
145 for k, v in pairs(table) do | |
146 checkboxes[k]:SetChecked(false); | |
147 state[k] = 1; | |
148 end | |
149 end | |
150 ); | |
151 end | |
152 | |
153 function AddZones(...) | |
154 local table = {}; | |
155 | |
156 for i=1,select("#", ...),1 do | |
157 table[i] = select(i, ...); | |
158 end | |
159 | |
160 if not Settings.ZoneFilter then | |
161 Settings.ZoneFilter = {{},{},{},{},{}}; | |
162 end | |
163 | |
164 local c = GetCurrentMapContinent() | |
165 | |
166 if not Settings.ZoneFilter[c] then | |
167 Settings.ZoneFilter[c] = {} | |
168 end | |
169 | |
170 CheckBoxes(table, Settings.ZoneFilter[c]); | |
171 end | |
172 | |
173 function AddHerbs() | |
174 local table = {}; | |
175 | |
176 for h, v in pairs(Bloodhound2.ContinentHerbs) do | |
177 local name = L[h]; | |
178 if not name then name="Herb "..h; end; | |
179 table[h] = name; | |
180 end | |
181 | |
182 if not Settings.HerbFilter then | |
183 Settings.HerbFilter = {}; | |
184 end | |
185 | |
186 CheckBoxes(table, Settings.HerbFilter); | |
187 end | |
188 | |
189 function AddOre() | |
190 local table = {}; | |
191 | |
192 for h, v in pairs(Bloodhound2.ContinentOre) do | |
193 local name = L[h]; | |
194 if not name then name="Ore "..h; end; | |
195 table[h] = name; | |
196 end | |
197 | |
198 if not Settings.OreFilter then | |
199 Settings.OreFilter = {}; | |
200 end | |
201 | |
202 CheckBoxes(table, Settings.OreFilter); | |
203 end | |
204 | |
205 local function CopyTable(table) | |
206 local copy = {}; | |
207 for k,v in pairs(table) do | |
208 if (type(v) == "table") then | |
209 copy[k] = CopyTable(v); | |
210 else | |
211 copy[k] = v; | |
212 end | |
213 end | |
214 return copy; | |
215 end | |
216 | |
217 local configFrame; | |
218 local BackupSettings; | |
219 | |
220 local function RefreshConfigFrame() | |
221 if (configFrame) then | |
222 configFrame:Hide(); | |
223 end | |
224 | |
225 BackupSettings = CopyTable(Settings); | |
226 | |
227 configFrame = CreateFrame("Frame", nil, Bloodhound2.panel); | |
228 configFrame:SetAllPoints(Bloodhound2.panel); | |
229 frame = configFrame; | |
230 element = frame; | |
231 Title(L["Bloodhound2 Options"]); | |
232 Heading(L["Multi-Zone"]); | |
233 DropDown(Settings, "MultiZoneMode", 120, function(menu) | |
234 AddButton(Settings, "MultiZoneMode", menu, L["While flying"], 0); | |
235 AddButton(Settings, "MultiZoneMode", menu, L["Always"], 1); | |
236 AddButton(Settings, "MultiZoneMode", menu, L["Never"], 2); | |
237 end); | |
238 Heading(L["Zones"].." ("..ContinentName()..")"); | |
239 AddZones(GetMapZones(GetCurrentMapContinent())); | |
240 element = frame; | |
241 Column2(150); | |
242 Heading(L["Inspection radius"]); | |
243 DropDown(Settings, "InspectionRadius", 70, function(menu) | |
244 AddButton(Settings, "InspectionRadius", menu, 30, 30); | |
245 AddButton(Settings, "InspectionRadius", menu, 35, 35); | |
246 AddButton(Settings, "InspectionRadius", menu, 40, 40); | |
247 AddButton(Settings, "InspectionRadius", menu, 45, 45); | |
248 AddButton(Settings, "InspectionRadius", menu, 50, 50); | |
249 AddButton(Settings, "InspectionRadius", menu, 60, 60); | |
250 AddButton(Settings, "InspectionRadius", menu, 70, 70); | |
251 AddButton(Settings, "InspectionRadius", menu, 80, 80); | |
252 AddButton(Settings, "InspectionRadius", menu, 90, 90); | |
253 AddButton(Settings, "InspectionRadius", menu, 100, 100); | |
254 AddButton(Settings, "InspectionRadius", menu, 120, 120); | |
255 end); | |
256 end | |
257 | |
258 local herbFrame; | |
259 | |
260 local function RefreshHerbs() | |
261 if (herbFrame) then herbFrame:Hide(); end; | |
262 herbFrame = CreateFrame("Frame", nil, Bloodhound2.herbPanel); | |
263 herbFrame:SetAllPoints(Bloodhound2.herbPanel); | |
264 frame = herbFrame; | |
265 element = frame; | |
266 Title(L["Bloodhound2 Options"]); | |
267 Heading(L["Herbs"].." ("..ContinentName()..")"); | |
268 AddHerbs(); | |
269 end | |
270 | |
271 local oreFrame; | |
272 | |
273 local function RefreshOre() | |
274 if (oreFrame) then oreFrame:Hide(); end; | |
275 oreFrame= CreateFrame("Frame", nil, Bloodhound2.orePanel); | |
276 oreFrame:SetAllPoints(Bloodhound2.orePanel); | |
277 frame = oreFrame; | |
278 element = frame; | |
279 Title(L["Bloodhound2 Options"]); | |
280 Heading(L["Minerals"].." ("..ContinentName()..")"); | |
281 AddOre(); | |
282 end | |
283 | |
284 local function RestoreHerbDefaults() | |
285 Settings.HerbFilter = {}; | |
286 end | |
287 | |
288 local function RestoreOreDefaults() | |
289 Settings.OreFilter = {}; | |
290 end | |
291 | |
292 local function RestoreZoneDefaults() | |
293 Settings.MultiZoneMode = 0; | |
294 Settings.InspectionRadius = 60; | |
295 Settings.ZoneFilter[GetCurrentMapContinent()] = {}; | |
296 end | |
297 | |
298 Bloodhound2.panel = CreateFrame("FRAME", "Bloodhound2", Bloodhound2.Frame); | |
299 Bloodhound2.panel.name = L["Bloodhound2"]; | |
300 Bloodhound2.panel.default = RestoreZoneDefaults; | |
301 Bloodhound2.panel.okay = function() end; | |
302 Bloodhound2.panel.cancel = function() Settings = BackupSettings; Bloodhound2.UpdateMinimap(); end; | |
303 Bloodhound2.panel.refresh = RefreshConfigFrame; | |
304 InterfaceOptions_AddCategory(Bloodhound2.panel); | |
305 | |
306 Bloodhound2.herbPanel = CreateFrame("FRAME", "Bloodhound2_Herbs", Bloodhound2.Frame); | |
307 Bloodhound2.herbPanel.name = L["Herbs"]; | |
308 Bloodhound2.herbPanel.parent = "Bloodhound2"; | |
309 Bloodhound2.herbPanel.default = RestoreHerbDefaults; | |
310 Bloodhound2.herbPanel.okay = function() end; | |
311 Bloodhound2.herbPanel.cancel = function() end; | |
312 Bloodhound2.herbPanel.refresh = RefreshHerbs; | |
313 InterfaceOptions_AddCategory(Bloodhound2.herbPanel); | |
314 | |
315 Bloodhound2.orePanel = CreateFrame("FRAME", "Bloodhound2_Ore", Bloodhound2.Frame); | |
316 Bloodhound2.orePanel.name = L["Minerals"]; | |
317 Bloodhound2.orePanel.parent = "Bloodhound2"; | |
318 Bloodhound2.orePanel.default = RestoreOreDefaults; | |
319 Bloodhound2.orePanel.okay = function() end; | |
320 Bloodhound2.orePanel.cancel = function() end; | |
321 Bloodhound2.orePanel.refresh = RefreshOre; | |
322 InterfaceOptions_AddCategory(Bloodhound2.orePanel); | |
323 |