diff Comments.lua @ 261:2f493bc054e5

Added support for quest comments. Left-justified the text of the link dialog box as well as highlighting the name of the comment subject.
author James D. Callahan III <jcallahan@curse.com>
date Tue, 19 Mar 2013 12:29:24 -0500
parents 3558ba83eacd
children 7f5982e01953
line wrap: on
line diff
--- a/Comments.lua	Mon Mar 18 17:58:08 2013 -0500
+++ b/Comments.lua	Tue Mar 19 12:29:24 2013 -0500
@@ -20,7 +20,7 @@
 local EDIT_MAXCHARS = 3000
 local EDIT_DESCRIPTION_FORMAT = "Enter your comment below, being as descriptive as possible. Comments are limited to %s characters, including newlines and spaces."
 local LINK_COMMENT_TOOLTIP = "Click here to create a link to the comment page on WoWDB."
-local LINK_EDITBOX_DESC_FORMAT = "Copy the highlighted text and paste it into your browser to visit the comments for %s."
+local LINK_EDITBOX_DESC_FORMAT = "Copy the highlighted text and paste it into your browser to visit the comments for |cffffd200%s|r."
 
 local URL_BASE = "http://www.wowdb.com/"
 
@@ -28,6 +28,7 @@
     ITEM = "items",
     OBJECT = "objects",
     NPC = "npcs",
+    QUEST = "quests",
     SPELL = "spells",
     VEHICLE = "npcs",
 }
@@ -57,6 +58,7 @@
         editbox:HighlightText()
         editbox:SetFocus()
 
+        self.text:SetJustifyH("LEFT")
         self.text:SetFormattedText(LINK_EDITBOX_DESC_FORMAT:format(data.label))
     end,
 })
@@ -333,6 +335,29 @@
     comment_frame:Show()
 end
 
+local function CreateQuestComment()
+    local index = _G.GetQuestLogSelection()
+
+    if not index or not _G.QuestLogFrame:IsShown() then
+        WDP:Print("You must select a quest from the Quest frame.")
+        return
+    end
+    local title, _, tag, _, is_header, _, _, _, idnum = _G.GetQuestLogTitle(index)
+
+    if is_header then
+        WDP:Print("You must select a quest from the Quest frame.")
+        return
+    end
+    comment_subject.type_name = "QUEST"
+    comment_subject.id = idnum
+    comment_subject.label = title
+
+    comment_frame.subject_name:SetText(title)
+    comment_frame.subject_data:SetFormattedText("(%s #%d)", "QUEST", idnum)
+    comment_frame.scroll_frame.edit_box:SetText("")
+    comment_frame:Show()
+end
+
 -- METHODS ------------------------------------------------------------
 
 function private.ProcessCommentCommand(arg)
@@ -344,6 +369,9 @@
     if arg == "cursor" then
         CreateCursorComment()
         return
+    elseif arg == "quest" then
+        CreateQuestComment()
+        return
     end
     CreateUnitComment(arg)
 end