Mercurial > wow > wowdb-profiler
comparison Comments.lua @ 276:a43a9444659e
Added support for commenting on items when the mouse is hovering over them.
| author | James D. Callahan III <jcallahan@curse.com> |
|---|---|
| date | Tue, 26 Mar 2013 23:38:29 -0500 |
| parents | ac6163ed8330 |
| children | 7e8e2297614a |
comparison
equal
deleted
inserted
replaced
| 275:ac6163ed8330 | 276:a43a9444659e |
|---|---|
| 124 | 124 |
| 125 local DATA_TYPE_MAPPING = { | 125 local DATA_TYPE_MAPPING = { |
| 126 merchant = "ITEM", | 126 merchant = "ITEM", |
| 127 } | 127 } |
| 128 | 128 |
| 129 local function CreateItemComment(is_command) | |
| 130 local item_name, item_id | |
| 131 | |
| 132 if is_command then | |
| 133 local item_link | |
| 134 item_name, item_link = _G.GameTooltip:GetItem() | |
| 135 | |
| 136 if not item_name and not item_link then | |
| 137 WDP:Print("Your mouse is not over an item.") | |
| 138 return | |
| 139 end | |
| 140 item_id = ItemLinkToID(item_link) | |
| 141 else | |
| 142 item_id = ItemLinkToID(comment_units.item.link) | |
| 143 item_name = comment_units.item.name | |
| 144 end | |
| 145 table.wipe(comment_units) | |
| 146 NewComment("ITEM", item_name, item_id) | |
| 147 end | |
| 148 | |
| 129 local CreateCursorComment | 149 local CreateCursorComment |
| 130 do | 150 do |
| 131 local CURSOR_DATA_FUNCS = { | 151 local CURSOR_DATA_FUNCS = { |
| 132 item = function(type_name, id_num, data_subtype) | 152 item = function(type_name, id_num, data_subtype) |
| 133 local item_name = _G.GetItemInfo(id_num) | 153 local item_name = _G.GetItemInfo(id_num) |
| 294 | 314 |
| 295 if name_func then | 315 if name_func then |
| 296 line = display:AddLine(("Cursor: %s"):format(name_func(data, data_subtype, subdata))) | 316 line = display:AddLine(("Cursor: %s"):format(name_func(data, data_subtype, subdata))) |
| 297 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateCursorComment) | 317 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateCursorComment) |
| 298 end | 318 end |
| 319 local item_name, item_link = _G.GameTooltip:GetItem() | |
| 320 | |
| 321 if item_name and item_link then | |
| 322 comment_units.item = { | |
| 323 link = item_link, | |
| 324 name = item_name, | |
| 325 } | |
| 326 line = display:AddLine(("Item: %s"):format(item_name)) | |
| 327 display:SetLineScript(line, "OnMouseUp", CreateComment, CreateItemComment) | |
| 328 end | |
| 299 | 329 |
| 300 local quest_index = _G.GetQuestLogSelection() | 330 local quest_index = _G.GetQuestLogSelection() |
| 301 | 331 |
| 302 if quest_index and _G.QuestLogFrame:IsShown() then | 332 if quest_index and _G.QuestLogFrame:IsShown() then |
| 303 local title, _, tag, _, is_header, _, _, _, idnum = _G.GetQuestLogTitle(quest_index) | 333 local title, _, tag, _, is_header, _, _, _, idnum = _G.GetQuestLogTitle(quest_index) |
| 330 if arg == "achievement" then | 360 if arg == "achievement" then |
| 331 CreateAchievementComment() | 361 CreateAchievementComment() |
| 332 return | 362 return |
| 333 elseif arg == "cursor" then | 363 elseif arg == "cursor" then |
| 334 CreateCursorComment() | 364 CreateCursorComment() |
| 365 return | |
| 366 elseif arg == "item" then | |
| 367 CreateItemComment(true) | |
| 335 return | 368 return |
| 336 elseif arg == "quest" then | 369 elseif arg == "quest" then |
| 337 CreateQuestComment() | 370 CreateQuestComment() |
| 338 return | 371 return |
| 339 end | 372 end |
| 570 -- }) | 603 -- }) |
| 571 -- | 604 -- |
| 572 -- private.data_obj = data_obj | 605 -- private.data_obj = data_obj |
| 573 -- LibStub("LibDBIcon-1.0"):Register(ADDON_NAME, data_obj, private.db.global.config.minimap_icon) | 606 -- LibStub("LibDBIcon-1.0"):Register(ADDON_NAME, data_obj, private.db.global.config.minimap_icon) |
| 574 | 607 |
| 608 _G.GameTooltip:HookScript("OnTooltipSetItem", function(self) | |
| 609 end) | |
| 610 | |
| 575 _G["BINDING_HEADER_WOWDB_PROFILER"] = "WoWDB Profiler" | 611 _G["BINDING_HEADER_WOWDB_PROFILER"] = "WoWDB Profiler" |
| 576 end | 612 end |
