comparison Comments.lua @ 267:f6f1d49b2a43

Added support for Achievement comments.
author James D. Callahan III <jcallahan@curse.com>
date Wed, 20 Mar 2013 12:26:12 -0500
parents d2f7737fd68b
children b6036060c096
comparison
equal deleted inserted replaced
266:d2f7737fd68b 267:f6f1d49b2a43
1 -- LUA API ------------------------------------------------------------ 1 -- LUA API ------------------------------------------------------------
2 2
3 local _G = getfenv(0) 3 local _G = getfenv(0)
4 4
5 local table = _G.table 5 local table = _G.table
6
7 local next = _G.next
6 8
7 -- ADDON NAMESPACE ---------------------------------------------------- 9 -- ADDON NAMESPACE ----------------------------------------------------
8 10
9 local ADDON_NAME, private = ... 11 local ADDON_NAME, private = ...
10 12
24 local LINK_EDITBOX_DESC_FORMAT = "Copy the highlighted text and paste it into your browser to visit the comments for |cffffd200%s|r." 26 local LINK_EDITBOX_DESC_FORMAT = "Copy the highlighted text and paste it into your browser to visit the comments for |cffffd200%s|r."
25 27
26 local URL_BASE = "http://www.wowdb.com/" 28 local URL_BASE = "http://www.wowdb.com/"
27 29
28 local URL_TYPE_MAP = { 30 local URL_TYPE_MAP = {
31 ACHIEVEMENT = "achievements",
29 ITEM = "items", 32 ITEM = "items",
30 OBJECT = "objects", 33 OBJECT = "objects",
31 NPC = "npcs", 34 NPC = "npcs",
32 QUEST = "quests", 35 QUEST = "quests",
33 SPELL = "spells", 36 SPELL = "spells",
381 comment_frame.subject_data:SetFormattedText("(%s #%d)", "QUEST", idnum) 384 comment_frame.subject_data:SetFormattedText("(%s #%d)", "QUEST", idnum)
382 comment_frame.scroll_frame.edit_box:SetText("") 385 comment_frame.scroll_frame.edit_box:SetText("")
383 _G.ShowUIPanel(comment_frame) 386 _G.ShowUIPanel(comment_frame)
384 end 387 end
385 388
389 local function CreateAchievementComment()
390 if not _G.AchievementFrame or not _G.AchievementFrameAchievements.selection then
391 WDP:Print("You must select an achievement from the Achievement frame.")
392 return
393 end
394
395 for _, button in next, _G.AchievementFrameAchievementsContainer.buttons do
396 if button.selected then
397 local title = button.label:GetText()
398
399 comment_subject.type_name = "ACHIEVEMENT"
400 comment_subject.id = button.id
401 comment_subject.label = title
402
403 comment_frame.subject_name:SetText(title)
404 comment_frame.subject_data:SetFormattedText("(%s #%d)", "ACHIEVEMENT", button.id)
405 comment_frame.scroll_frame.edit_box:SetText("")
406 _G.ShowUIPanel(comment_frame)
407 break
408 end
409 end
410 end
411
386 -- METHODS ------------------------------------------------------------ 412 -- METHODS ------------------------------------------------------------
387 413
388 function private.ProcessCommentCommand(arg) 414 function private.ProcessCommentCommand(arg)
389 if not arg or arg == "" then 415 if not arg or arg == "" then
390 WDP:Print("You must supply a valid comment type.") 416 WDP:Print("You must supply a valid comment type.")
391 return 417 return
392 end 418 end
393 419
394 if arg == "cursor" then 420 if arg == "achievement" then
421 CreateAchievementComment()
422 return
423 elseif arg == "cursor" then
395 CreateCursorComment() 424 CreateCursorComment()
396 return 425 return
397 elseif arg == "quest" then 426 elseif arg == "quest" then
398 CreateQuestComment() 427 CreateQuestComment()
399 return 428 return