Mercurial > wow > wowdb-profiler
comparison Comments.lua @ 277:7e8e2297614a
Added support for commenting on spells when the mouse is hovering over them.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Wed, 27 Mar 2013 00:08:01 -0500 |
parents | a43a9444659e |
children | 84817627cb22 |
comparison
equal
deleted
inserted
replaced
276:a43a9444659e | 277:7e8e2297614a |
---|---|
144 end | 144 end |
145 table.wipe(comment_units) | 145 table.wipe(comment_units) |
146 NewComment("ITEM", item_name, item_id) | 146 NewComment("ITEM", item_name, item_id) |
147 end | 147 end |
148 | 148 |
149 local function CreateSpellComment(is_command) | |
150 local spell_name, spell_rank, spell_id | |
151 | |
152 if is_command then | |
153 spell_name, spell_rank, spell_id = _G.GameTooltip:GetSpell() | |
154 | |
155 if not spell_name and not spell_id then | |
156 WDP:Print("Your mouse is not over a spell.") | |
157 return | |
158 end | |
159 else | |
160 local spell_rank = comment_units.spell.rank | |
161 spell_id = comment_units.spell.id | |
162 spell_name = ("%s%s"):format(comment_units.spell.name, (spell_rank ~= "") and (" (%s)"):format(spell_rank) or "") | |
163 end | |
164 table.wipe(comment_units) | |
165 NewComment("SPELL", spell_name, spell_id) | |
166 end | |
167 | |
149 local CreateCursorComment | 168 local CreateCursorComment |
150 do | 169 do |
151 local CURSOR_DATA_FUNCS = { | 170 local CURSOR_DATA_FUNCS = { |
152 item = function(type_name, id_num, data_subtype) | 171 item = function(type_name, id_num, data_subtype) |
153 local item_name = _G.GetItemInfo(id_num) | 172 local item_name = _G.GetItemInfo(id_num) |
314 | 333 |
315 if name_func then | 334 if name_func then |
316 line = display:AddLine(("Cursor: %s"):format(name_func(data, data_subtype, subdata))) | 335 line = display:AddLine(("Cursor: %s"):format(name_func(data, data_subtype, subdata))) |
317 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateCursorComment) | 336 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateCursorComment) |
318 end | 337 end |
338 local spell_name, spell_rank, spell_id = _G.GameTooltip:GetSpell() | |
339 | |
340 if spell_name and spell_rank and spell_id then | |
341 comment_units.spell = { | |
342 id = spell_id, | |
343 name = spell_name, | |
344 rank = spell_rank, | |
345 } | |
346 | |
347 line = display:AddLine(("Spell: %s%s"):format(spell_name, (spell_rank ~= "") and (" (%s)"):format(spell_rank) or "")) | |
348 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateSpellComment) | |
349 end | |
350 | |
319 local item_name, item_link = _G.GameTooltip:GetItem() | 351 local item_name, item_link = _G.GameTooltip:GetItem() |
320 | 352 |
321 if item_name and item_link then | 353 if item_name and item_link then |
322 comment_units.item = { | 354 comment_units.item = { |
323 link = item_link, | 355 link = item_link, |
324 name = item_name, | 356 name = item_name, |
325 } | 357 } |
358 | |
326 line = display:AddLine(("Item: %s"):format(item_name)) | 359 line = display:AddLine(("Item: %s"):format(item_name)) |
327 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateItemComment) | 360 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateItemComment) |
328 end | 361 end |
329 | 362 |
330 local quest_index = _G.GetQuestLogSelection() | 363 local quest_index = _G.GetQuestLogSelection() |
366 elseif arg == "item" then | 399 elseif arg == "item" then |
367 CreateItemComment(true) | 400 CreateItemComment(true) |
368 return | 401 return |
369 elseif arg == "quest" then | 402 elseif arg == "quest" then |
370 CreateQuestComment() | 403 CreateQuestComment() |
404 return | |
405 elseif arg == "spell" then | |
406 CreateSpellComent(true) | |
371 return | 407 return |
372 end | 408 end |
373 CreateUnitComment(arg, true) | 409 CreateUnitComment(arg, true) |
374 end | 410 end |
375 | 411 |