vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 -- Name: TinyTip
3 -- Author: Thrae of Maelstrom (aka "Matthew Carras")
4 -- Release Date: 6-25-06
5 --
6 -- These functions allow you to change options via a
7 -- Dewdrop GUI. Loaded on demand by TinyTip.
8 --
9 -- This part does NOT need to be localized, look in
10 -- TinyTipChatLocale_xxXX.lua.
11 --]]
12  
13 local _G = getfenv(0)
14 local dewdrop = _G.AceLibrary:GetInstance("Dewdrop-2.0")
15 local ddframe
16 local db
17  
18 local function ToggleDB(k)
19 db[k] = not db[k]
20 end
21  
22 local function SetDB(k,v)
23 db[k] = v
24 end
25  
26 local function SetDBNum(k,v)
27 db[k] = tonumber(v)
28 end
29  
30 local function SetAnchor(k,v)
31 db[k] = v
32 if db[k] then
33 _G.TinyTipAnchor_Hook()
34 end
35 end
36  
37 local function ToggleExtras(k)
38 db[k] = not db[k]
39 _G.TinyTip_LoDRun("TinyTipExtras","TinyTipExtras_Init", db, _G.TinyTipEventFrame)
40 end
41  
42 local function SetExtras(k,v)
43 db[k] = v
44 _G.TinyTip_LoDRun("TinyTipExtras","TinyTipExtras_Init", db, _G.TinyTipEventFrame)
45 end
46  
47 local function SetExtrasNum(k,v)
48 db[k] = tonumber(v)
49 _G.TinyTip_LoDRun("TinyTipExtras","TinyTipExtras_Init", db, _G.TinyTipEventFrame)
50 end
51  
52  
53 local function SetTargets(k,v,v2)
54 if v and v2 then
55 v = tonumber(v2)
56 end
57 db[k] = v
58 if db[k] then
59 _G.TinyTip_LoDRun("TinyTipExtras","TinyTipTargetsExists")
60 end
61 end
62  
63 local function DDAddArrow(opt)
64 dewdrop:AddLine( 'text', _G["TinyTipChatLocale_Opt_" .. opt],
65 'hasArrow', true,
66 'value', opt,
67 'tooltipTitle', "TinyTip",
68 'tooltipText', _G["TinyTipChatLocale_Desc_" .. opt]
69 )
70 end
71  
72 local function DDAddChecked(opt, func)
73 dewdrop:AddLine( 'text', _G["TinyTipChatLocale_Opt_" .. opt],
74 'checked', db[opt],
75 'func', func or ToggleDB,
76 'arg1', opt,
77 'tooltipTitle', "TinyTip",
78 'tooltipText', _G["TinyTipChatLocale_Desc_" .. opt]
79 )
80 end
81  
82 local function DDAddEditBoxNum(opt, func, arg2)
83 dewdrop:AddLine( 'text', _G["TinyTipChatLocale_Opt_" .. opt],
84 'hasArrow', true,
85 'hasEditBox', true,
86 'editBoxText', db[ opt ],
87 'editBoxFunc', func or SetDBNum,
88 'editBoxArg1', opt,
89 'editBoxArg2', arg2,
90 'tooltipTitle', "TinyTip",
91 'tooltipText', _G["TinyTipChatLocale_Desc_" .. opt]
92 )
93 end
94  
95 local function DDAddRadioBoxes(opt, map, func, default)
96 local k,v
97 dewdrop:AddLine('text', default or _G.TinyTipChatLocale_GameDefault,
98 'isRadio', true,
99 'checked', not db[opt],
100 'func', func or SetDB,
101 'arg1', opt )
102 for k,v in map do
103 dewdrop:AddLine('text', v,
104 'isRadio', true,
105 'checked', db[opt] == k,
106 'func', func or SetDB,
107 'arg1', opt,
108 'arg2', k )
109 end
110 end
111  
112 local function DDAddScale(opt, func, default)
113 dewdrop:AddLine( 'text', _G["TinyTipChatLocale_Opt_" .. opt],
114 'hasArrow', true,
115 'hasSlider', true,
116 'sliderMin', 0.01,
117 'sliderMax', 2.0,
118 'sliderIsPercent', true,
119 'sliderValue', db[opt] or default or 1.0,
120 'sliderFunc', func or _G.TinyTip_SetScale,
121 'sliderArg1', opt,
122 'tooltipTitle', "TinyTip",
123 'tooltipText', _G["TinyTipChatLocale_Desc_" .. opt] )
124 end
125  
126 function TinyTipOptions_CreateDDMenu(level,value)
127 if not db then return end
128 if level == 1 then
129 dewdrop:AddLine( 'text', _G.TinyTipChatLocale_MenuTitle,
130 'isTitle', true
131 )
132 if _G.TinyTipAnchorExists then
133 DDAddArrow("Main_Anchor")
134 end
135 DDAddArrow("Main_Text")
136 DDAddArrow("Main_Appearance")
137 if _G.GetAddOnMetadata("TinyTipExtras", "Title") then
138 DDAddArrow("Main_Targets")
139 DDAddArrow("Main_Extras")
140 end
141  
142 dewdrop:AddLine()
143 if _G.TinyTipDB then
144 dewdrop:AddLine('text', _G.TinyTipChatLocale_Opt_Profiles,
145 'checked', _G.TinyTipDB["_profile"],
146 'func', function()
147 _G.TinyTipDB["_profile"] = not _G.TinyTipDB["_profile"]
148 _G.TinyTip_UpdateProfiles()
149 end,
150 'tooltipTitle', "TinyTip",
151 'tooltipText', _G.TinyTipChatLocale_Desc_Profiles
152 )
153 end
154 dewdrop:AddLine()
155  
156 dewdrop:AddLine('text', _G.TinyTipChatLocale_Opt_Main_Default,
157 'textR', 1, 'textG', 0.4, 'textB', 0.4,
158 'func', _G.TinyTip_DefaultDB,
159 'tooltipTitle', "TinyTip",
160 'tooltipText', _G.TinyTipChatLocale_Desc_Main_Default)
161  
162 elseif level == 2 then
163 if value == "Main_Anchor" then
164 DDAddArrow("MAnchor")
165 DDAddEditBoxNum("MOffX")
166 DDAddEditBoxNum("MOffY")
167  
168 dewdrop:AddLine()
169  
170 DDAddArrow("FAnchor")
171 DDAddEditBoxNum("FOffX")
172 DDAddEditBoxNum("FOffY")
173  
174 dewdrop:AddLine()
175 DDAddChecked("AnchorAll")
176 DDAddChecked("AlwaysAnchor")
177 if db["ExtraTooltip"] then
178 dewdrop:AddLine()
179  
180 DDAddArrow("ETAnchor")
181 DDAddEditBoxNum("ETOffX")
182 DDAddEditBoxNum("ETOffY")
183 end
184 if db["PvPIcon"] then
185 dewdrop:AddLine()
186  
187 DDAddArrow("PvPIconAnchor1")
188 DDAddArrow("PvPIconAnchor2")
189 DDAddEditBoxNum("PvPIconOffX")
190 DDAddEditBoxNum("PvPIconOffY")
191 end
192 if db["RTIcon"] then
193 dewdrop:AddLine()
194  
195 DDAddArrow("RTIconAnchor1")
196 DDAddArrow("RTIconAnchor2")
197 DDAddEditBoxNum("RTIconOffX")
198 DDAddEditBoxNum("RTIconOffY")
199 end
200 if db["Buffs"] then
201 dewdrop:AddLine()
202  
203 DDAddArrow("BuffAnchor1")
204 DDAddArrow("BuffAnchor2")
205 DDAddEditBoxNum("BuffOffX")
206 DDAddEditBoxNum("BuffOffY")
207 end
208 if db["Debuffs"] then
209 dewdrop:AddLine()
210  
211 DDAddArrow("DebuffAnchor1")
212 DDAddArrow("DebuffAnchor2")
213 DDAddEditBoxNum("DebuffOffX")
214 DDAddEditBoxNum("DebuffOffY")
215 end
216  
217 elseif value == "Main_Text" then
218 DDAddArrow("PvPRank")
219  
220 dewdrop:AddLine()
221  
222 DDAddChecked("HideLevelText")
223 DDAddChecked("HideRace")
224 DDAddChecked("KeyElite")
225 DDAddChecked("HideGuild")
226 DDAddChecked("ReactionText")
227 DDAddChecked("LevelGuess")
228 elseif value == "Main_Appearance" then
229 DDAddScale("Scale")
230 DDAddArrow("BGColor")
231 DDAddArrow("Border")
232 DDAddArrow("Fade")
233 DDAddArrow("Friends")
234  
235 dewdrop:AddLine()
236  
237 DDAddChecked("SmoothBorder", TinyTip_SmoothBorder)
238 DDAddChecked("Compact")
239 DDAddChecked("HideInFrames")
240 DDAddChecked("FormatDisabled")
241  
242 if db["PvPIcon"] or db["RTIcon"] or db["Buffs"] or db["Debuffs"] then
243 dewdrop:AddLine()
244 end
245 if db["PvPIcon"] then
246 DDAddScale("PvPIconScale", SetExtrasNum, 0.7)
247 end
248 if db["RTIcon"] then
249 DDAddScale("RTIconScale", SetExtrasNum, 0.1)
250 end
251 if db["Buffs"] or db["Debuffs"] then
252 DDAddScale("BuffScale", SetExtrasNum, 0.2)
253 end
254 elseif value == "Main_Targets" then
255 DDAddArrow("ToT")
256 DDAddArrow("ToP")
257 DDAddArrow("ToR")
258 elseif value == "Main_Extras" then
259 DDAddArrow("ExtraTooltip")
260 DDAddArrow("Buffs")
261 DDAddArrow("Debuffs")
262  
263 dewdrop:AddLine()
264  
265 DDAddChecked("PvPIcon", ToggleExtras)
266 DDAddChecked("RTIcon", ToggleExtras)
267 DDAddChecked("ManaBar", ToggleExtras)
268 end
269 elseif level == 3 then
270 local k,v
271 if value == "MAnchor" then
272 dewdrop:AddLine('text', _G.TinyTipChatLocale_GameDefault,
273 'isRadio', true,
274 'checked', db["MAnchor"] == "GAMEDEFAULT",
275 'func', SetDB,
276 'arg1', "MAnchor",
277 'arg2', "GAMEDEFAULT")
278  
279 dewdrop:AddLine('text', _G.TinyTipChatLocale_Anchor_Cursor,
280 'isRadio', true,
281 'checked', not db["MAnchor"],
282 'func', SetAnchor,
283 'arg1', "MAnchor")
284  
285 for k,v in _G.TinyTipChatLocale_ChatMap_Anchor do
286 dewdrop:AddLine('text', v,
287 'isRadio', true,
288 'checked', db["MAnchor"] == k,
289 'func', SetAnchor,
290 'arg1', "MAnchor",
291 'arg2', k )
292 end
293 elseif value == "FAnchor" then
294 dewdrop:AddLine('text', _G.TinyTipChatLocale_GameDefault,
295 'isRadio', true,
296 'checked', not db["FAnchor"],
297 'func', SetDB,
298 'arg1', "FAnchor" )
299  
300 dewdrop:AddLine('text', _G.TinyTipChatLocale_Anchor_Sticky,
301 'isRadio', true,
302 'checked', db["FAnchor"] == "STICKY",
303 'func', SetAnchor,
304 'arg1', "FAnchor",
305 'arg2', "STICKY" )
306  
307 dewdrop:AddLine('text', _G.TinyTipChatLocale_Anchor_Cursor,
308 'isRadio', true,
309 'checked', db["FAnchor"] == "CURSOR",
310 'func', SetAnchor,
311 'arg1', "FAnchor",
312 'arg2', "CURSOR" )
313  
314 for k,v in _G.TinyTipChatLocale_ChatMap_Anchor do
315 dewdrop:AddLine('text', v,
316 'isRadio', true,
317 'checked', db["FAnchor"] == k,
318 'func', SetAnchor,
319 'arg1', "FAnchor",
320 'arg2', k )
321 end
322 elseif value == "PvPIconAnchor1" then
323 DDAddRadioBoxes(value,
324 _G.TinyTipChatLocale_ChatMap_Anchor,
325 SetExtras,
326 _G.TinyTipChatLocale_TinyTipDefault)
327 elseif value == "PvPIconAnchor2" then
328 DDAddRadioBoxes(value,
329 _G.TinyTipChatLocale_ChatMap_Anchor,
330 SetExtras,
331 _G.TinyTipChatLocale_TinyTipDefault)
332 elseif value == "RTIconAnchor1" then
333 DDAddRadioBoxes(value,
334 _G.TinyTipChatLocale_ChatMap_Anchor,
335 SetExtras,
336 _G.TinyTipChatLocale_TinyTipDefault)
337 elseif value == "RTIconAnchor2" then
338 DDAddRadioBoxes(value,
339 _G.TinyTipChatLocale_ChatMap_Anchor,
340 SetExtras,
341 _G.TinyTipChatLocale_TinyTipDefault)
342 elseif value == "BuffAnchor1" then
343 DDAddRadioBoxes(value,
344 _G.TinyTipChatLocale_ChatMap_Anchor,
345 SetExtras,
346 _G.TinyTipChatLocale_TinyTipDefault)
347 elseif value == "BuffAnchor2" then
348 DDAddRadioBoxes(value,
349 _G.TinyTipChatLocale_ChatMap_Anchor,
350 SetExtras,
351 _G.TinyTipChatLocale_TinyTipDefault)
352 elseif value == "DebuffAnchor1" then
353 DDAddRadioBoxes(value,
354 _G.TinyTipChatLocale_ChatMap_Anchor,
355 SetExtras,
356 _G.TinyTipChatLocale_TinyTipDefault)
357 elseif value == "DebuffAnchor2" then
358 DDAddRadioBoxes(value,
359 _G.TinyTipChatLocale_ChatMap_Anchor,
360 SetExtras,
361 _G.TinyTipChatLocale_TinyTipDefault)
362 elseif value == "PvPRank" then
363 DDAddRadioBoxes(value,
364 _G.TinyTipChatLocale_ChatIndex_PvPRank,
365 nil,
366 _G.TinyTipChatLocale_TinyTipDefault)
367 elseif value == "BGColor" then
368 DDAddRadioBoxes(value,
369 _G.TinyTipChatLocale_ChatIndex_BGColor,
370 nil,
371 _G.TinyTipChatLocale_TinyTipDefault)
372 elseif value == "Border" then
373 DDAddRadioBoxes(value,
374 _G.TinyTipChatLocale_ChatIndex_Border,
375 nil,
376 _G.TinyTipChatLocale_TinyTipDefault)
377 elseif value == "Fade" then
378 DDAddRadioBoxes(value,
379 _G.TinyTipChatLocale_ChatIndex_Fade )
380 elseif value == "Friends" then
381 DDAddRadioBoxes(value,
382 _G.TinyTipChatLocale_ChatIndex_Friends,
383 nil,
384 _G.TinyTipChatLocale_TinyTipDefault)
385 elseif value == "ToT" then
386 DDAddRadioBoxes(value,
387 _G.TinyTipChatLocale_ChatIndex_ToT,
388 SetTargets,
389 _G.TinyTipChatLocale_Off)
390 elseif value == "ToP" then
391 DDAddRadioBoxes(value,
392 _G.TinyTipChatLocale_ChatIndex_ToP,
393 SetTargets,
394 _G.TinyTipChatLocale_Off)
395 elseif value == "ToR" then
396 DDAddRadioBoxes(value,
397 _G.TinyTipChatLocale_ChatIndex_ToR,
398 SetTargets,
399 _G.TinyTipChatLocale_Off)
400 elseif value == "ExtraTooltip" then
401 DDAddRadioBoxes(value,
402 _G.TinyTipChatLocale_ChatIndex_ExtraTooltip,
403 SetExtras,
404 _G.TinyTipChatLocale_Off)
405 elseif value == "ETAnchor" then
406 dewdrop:AddLine('text', _G.TinyTipChatLocale_GameDefault,
407 'isRadio', true,
408 'checked', not db["ETAnchor"],
409 'func', SetDB,
410 'arg1', "ETAnchor" )
411  
412 for k,v in _G.TinyTipChatLocale_ChatMap_Anchor do
413 dewdrop:AddLine('text', v,
414 'isRadio', true,
415 'checked', db["ETAnchor"] == k,
416 'func', SetAnchor,
417 'arg1', "ETAnchor",
418 'arg2', k )
419 end
420 elseif value == "Buffs" then
421 DDAddRadioBoxes(value,
422 _G.TinyTipChatLocale_ChatIndex_Buffs,
423 SetExtras,
424 _G.TinyTipChatLocale_Off)
425 elseif value == "Debuffs" then
426 DDAddRadioBoxes(value,
427 _G.TinyTipChatLocale_ChatIndex_Debuffs,
428 SetExtras,
429 _G.TinyTipChatLocale_Off)
430 end
431 end
432 end
433  
434 function TinyTipOptions_SetLocals(_db)
435 if _db then db = _db end
436 end
437  
438 function TinyTipChat_SlashHandler(msg, _db)
439 if _db then db = _db
440 elseif not db then return end
441  
442 msg = string.lower(msg)
443 -- non saved variable options
444 if msg == _G.TinyTipChatLocale_Opt_Slash_Default then
445 _G.TinyTip_Msg( string.format("%s %s %s.", _G.TinyTipChatLocale_DefaultWarning,
446 _G.SLASH_TINYTIP2,
447 _G.TinyTipChatLocale_Confirm ) )
448 elseif msg == _G.TinyTipChatLocale_Confirm then -- "hidden option"
449 _G.TinyTip_DefaultDB()
450 elseif msg == _G.TinyTipChatLocale_Opt_Slash_Report then
451 local reportmap = _G.TinyTip_GetAllOptions()
452 local k,v
453 for _,v in reportmap do
454 _G.TinyTip_Msg( string.format("%s %s [|cFFFFCC00%s|r]", v,
455 _G.TinyTipChatLocale_IsSetTo,
456 ( db[v] and type(db[v]) == "boolean"
457 and _G.TinyTipChatLocale_On ) or
458 (db[v] and type(db[v]) == "string" and
459 string.format('"%s"', db[v])) or
460 (type(db[v]) == "number" and db[v]) or
461 _G.TinyTipChatLocale_Off ) )
462 end
463 elseif msg and string.len(msg) > 0 then
464 _G.TinyTip_Msg( string.format('"|cFFFF2222%s|r" %s', msg, _G.TinyTipChatLocale_NotValidCommand) )
465 else -- open up options window
466  
467 if not ddframe then
468 ddframe = _G.CreateFrame("Frame", nil, _G.UIParent)
469 ddframe:SetWidth(2)
470 ddframe:SetHeight(2)
471 ddframe:SetPoint("BOTTOMLEFT", _G.GetCursorPosition())
472 ddframe:SetClampedToScreen(true)
473 dewdrop:Register(ddframe, 'dontHook', true, 'children', _G.TinyTipOptions_CreateDDMenu )
474 end
475 local x,y = _G.GetCursorPosition()
476 ddframe:SetPoint("BOTTOMLEFT", x / UIParent:GetScale(), y / UIParent:GetScale())
477 dewdrop:Open(ddframe)
478  
479 end
480  
481 end
482