# HG changeset patch # User James D. Callahan III # Date 1364360881 18000 # Node ID 7e8e2297614aab8e6f00d1186cc39ed0743107bf # Parent a43a9444659e9a99892c2c4035ca437ab78402e8 Added support for commenting on spells when the mouse is hovering over them. diff -r a43a9444659e -r 7e8e2297614a Comments.lua --- a/Comments.lua Tue Mar 26 23:38:29 2013 -0500 +++ b/Comments.lua Wed Mar 27 00:08:01 2013 -0500 @@ -146,6 +146,25 @@ NewComment("ITEM", item_name, item_id) end +local function CreateSpellComment(is_command) + local spell_name, spell_rank, spell_id + + if is_command then + spell_name, spell_rank, spell_id = _G.GameTooltip:GetSpell() + + if not spell_name and not spell_id then + WDP:Print("Your mouse is not over a spell.") + return + end + else + local spell_rank = comment_units.spell.rank + spell_id = comment_units.spell.id + spell_name = ("%s%s"):format(comment_units.spell.name, (spell_rank ~= "") and (" (%s)"):format(spell_rank) or "") + end + table.wipe(comment_units) + NewComment("SPELL", spell_name, spell_id) +end + local CreateCursorComment do local CURSOR_DATA_FUNCS = { @@ -316,6 +335,19 @@ line = display:AddLine(("Cursor: %s"):format(name_func(data, data_subtype, subdata))) display:SetLineScript(line, "OnMouseUp", CreateComment, CreateCursorComment) end + local spell_name, spell_rank, spell_id = _G.GameTooltip:GetSpell() + + if spell_name and spell_rank and spell_id then + comment_units.spell = { + id = spell_id, + name = spell_name, + rank = spell_rank, + } + + line = display:AddLine(("Spell: %s%s"):format(spell_name, (spell_rank ~= "") and (" (%s)"):format(spell_rank) or "")) + display:SetLineScript(line, "OnMouseUp", CreateComment, CreateSpellComment) + end + local item_name, item_link = _G.GameTooltip:GetItem() if item_name and item_link then @@ -323,6 +355,7 @@ link = item_link, name = item_name, } + line = display:AddLine(("Item: %s"):format(item_name)) display:SetLineScript(line, "OnMouseUp", CreateComment, CreateItemComment) end @@ -369,6 +402,9 @@ elseif arg == "quest" then CreateQuestComment() return + elseif arg == "spell" then + CreateSpellComent(true) + return end CreateUnitComment(arg, true) end