Mercurial > wow > wowdb-profiler
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 260:3558ba83eacd | 261:2f493bc054e5 |
|---|---|
| 18 -- CONSTANTS ---------------------------------------------------------- | 18 -- CONSTANTS ---------------------------------------------------------- |
| 19 | 19 |
| 20 local EDIT_MAXCHARS = 3000 | 20 local EDIT_MAXCHARS = 3000 |
| 21 local EDIT_DESCRIPTION_FORMAT = "Enter your comment below, being as descriptive as possible. Comments are limited to %s characters, including newlines and spaces." | 21 local EDIT_DESCRIPTION_FORMAT = "Enter your comment below, being as descriptive as possible. Comments are limited to %s characters, including newlines and spaces." |
| 22 local LINK_COMMENT_TOOLTIP = "Click here to create a link to the comment page on WoWDB." | 22 local LINK_COMMENT_TOOLTIP = "Click here to create a link to the comment page on WoWDB." |
| 23 local LINK_EDITBOX_DESC_FORMAT = "Copy the highlighted text and paste it into your browser to visit the comments for %s." | 23 local LINK_EDITBOX_DESC_FORMAT = "Copy the highlighted text and paste it into your browser to visit the comments for |cffffd200%s|r." |
| 24 | 24 |
| 25 local URL_BASE = "http://www.wowdb.com/" | 25 local URL_BASE = "http://www.wowdb.com/" |
| 26 | 26 |
| 27 local URL_TYPE_MAP = { | 27 local URL_TYPE_MAP = { |
| 28 ITEM = "items", | 28 ITEM = "items", |
| 29 OBJECT = "objects", | 29 OBJECT = "objects", |
| 30 NPC = "npcs", | 30 NPC = "npcs", |
| 31 QUEST = "quests", | |
| 31 SPELL = "spells", | 32 SPELL = "spells", |
| 32 VEHICLE = "npcs", | 33 VEHICLE = "npcs", |
| 33 } | 34 } |
| 34 | 35 |
| 35 Dialog:Register("WDP_CommentLink", { | 36 Dialog:Register("WDP_CommentLink", { |
| 55 editbox:SetWidth(self:GetWidth() - 20) | 56 editbox:SetWidth(self:GetWidth() - 20) |
| 56 editbox:SetText(("%s%s/%d#related:comments"):format(URL_BASE, URL_TYPE_MAP[data.type_name], data.id)) | 57 editbox:SetText(("%s%s/%d#related:comments"):format(URL_BASE, URL_TYPE_MAP[data.type_name], data.id)) |
| 57 editbox:HighlightText() | 58 editbox:HighlightText() |
| 58 editbox:SetFocus() | 59 editbox:SetFocus() |
| 59 | 60 |
| 61 self.text:SetJustifyH("LEFT") | |
| 60 self.text:SetFormattedText(LINK_EDITBOX_DESC_FORMAT:format(data.label)) | 62 self.text:SetFormattedText(LINK_EDITBOX_DESC_FORMAT:format(data.label)) |
| 61 end, | 63 end, |
| 62 }) | 64 }) |
| 63 | 65 |
| 64 local comment_subject = {} | 66 local comment_subject = {} |
| 331 CURSOR_DATA_FUNCS[data_type](DATA_TYPE_MAPPING[data_type] or data_type:upper(), data, data_subtype, subdata) | 333 CURSOR_DATA_FUNCS[data_type](DATA_TYPE_MAPPING[data_type] or data_type:upper(), data, data_subtype, subdata) |
| 332 comment_frame.scroll_frame.edit_box:SetText("") | 334 comment_frame.scroll_frame.edit_box:SetText("") |
| 333 comment_frame:Show() | 335 comment_frame:Show() |
| 334 end | 336 end |
| 335 | 337 |
| 338 local function CreateQuestComment() | |
| 339 local index = _G.GetQuestLogSelection() | |
| 340 | |
| 341 if not index or not _G.QuestLogFrame:IsShown() then | |
| 342 WDP:Print("You must select a quest from the Quest frame.") | |
| 343 return | |
| 344 end | |
| 345 local title, _, tag, _, is_header, _, _, _, idnum = _G.GetQuestLogTitle(index) | |
| 346 | |
| 347 if is_header then | |
| 348 WDP:Print("You must select a quest from the Quest frame.") | |
| 349 return | |
| 350 end | |
| 351 comment_subject.type_name = "QUEST" | |
| 352 comment_subject.id = idnum | |
| 353 comment_subject.label = title | |
| 354 | |
| 355 comment_frame.subject_name:SetText(title) | |
| 356 comment_frame.subject_data:SetFormattedText("(%s #%d)", "QUEST", idnum) | |
| 357 comment_frame.scroll_frame.edit_box:SetText("") | |
| 358 comment_frame:Show() | |
| 359 end | |
| 360 | |
| 336 -- METHODS ------------------------------------------------------------ | 361 -- METHODS ------------------------------------------------------------ |
| 337 | 362 |
| 338 function private.ProcessCommentCommand(arg) | 363 function private.ProcessCommentCommand(arg) |
| 339 if not arg or arg == "" then | 364 if not arg or arg == "" then |
| 340 WDP:Print("You must supply a valid comment type.") | 365 WDP:Print("You must supply a valid comment type.") |
| 342 end | 367 end |
| 343 | 368 |
| 344 if arg == "cursor" then | 369 if arg == "cursor" then |
| 345 CreateCursorComment() | 370 CreateCursorComment() |
| 346 return | 371 return |
| 372 elseif arg == "quest" then | |
| 373 CreateQuestComment() | |
| 374 return | |
| 347 end | 375 end |
| 348 CreateUnitComment(arg) | 376 CreateUnitComment(arg) |
| 349 end | 377 end |
