Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.42 KB | None | 0 0
  1. function Module:SetUpQuestDetailLinks()
  2.     -- Create editbox
  3.     local qDL = CreateFrame("EditBox", nil, QuestLogPopupDetailFrame)
  4.     qDL:ClearAllPoints()
  5.     qDL:SetPoint("TOPLEFT", 65, -3)
  6.     qDL:SetHeight(16)
  7.     qDL:SetFontObject("GameFontNormal")
  8.     qDL:SetBlinkSpeed(0)
  9.     qDL:SetAutoFocus(false)
  10.     qDL:EnableKeyboard(false)
  11.     qDL:SetHitRectInsets(0, 90, 0, 0)
  12.     qDL:SetScript("OnKeyDown", function() end)
  13.     qDL:SetScript("OnMouseUp", function()
  14.         if qDL:IsMouseOver() then
  15.             qDL:HighlightText()
  16.         else
  17.             qDL:HighlightText(0, 0)
  18.         end
  19.     end)
  20.  
  21.     -- Create hidden font string (used for setting width of editbox)
  22.     qDL.z = qDL:CreateFontString(nil, "ARTWORK", "GameFontNormal")
  23.     qDL.z:Hide()
  24.  
  25.     -- Function to set editbox value
  26.     local function SetQuestInBox()
  27.         local questID
  28.         if QuestLogPopupDetailFrame:IsShown() and QuestLogPopupDetailFrame.questID then
  29.             -- Get quest ID from currently showing quest in details panel
  30.             questID = QuestLogPopupDetailFrame.questID
  31.         end
  32.         if questID then
  33.             -- Hide editbox if quest ID is invalid
  34.             if questID == 0 then qDL:Hide() else qDL:Show() end
  35.             -- Set editbox text
  36.             qDL:SetText("https://" .. wowheadLoc .. "/quest=" .. questID)
  37.             -- Set hidden fontstring then resize editbox to match
  38.             qDL.z:SetText(qDL:GetText())
  39.             qDL:SetWidth(qDL.z:GetStringWidth() + 90)
  40.             -- Get quest title for tooltip
  41.             local questLink = GetQuestLink(questID) or nil
  42.             if questLink then
  43.                 local title = QuestInfoTitleHeader:GetText() or string_match(questLink, "%[(.-)%]")
  44.                 qDL.tiptext = title
  45.             else
  46.                 qDL.tiptext = ""
  47.             end
  48.         end
  49.     end
  50.  
  51.     -- Set URL when super tracked quest changes and on startup
  52.     qDL:RegisterEvent("SUPER_TRACKED_QUEST_CHANGED")
  53.     qDL:SetScript("OnEvent", SetQuestInBox)
  54.     SetQuestInBox()
  55.  
  56.     -- Set URL when quest details frame is shown or hidden
  57.     hooksecurefunc("QuestLogPopupDetailFrame_Show", SetQuestInBox)
  58.     hooksecurefunc("QuestLogPopupDetailFrame_Update", SetQuestInBox)
  59.  
  60.     local r, g, b = 0.2, 1.0, 0.2
  61.  
  62.     -- Create tooltip
  63.     qDL:HookScript("OnEnter", function()
  64.         qDL:HighlightText()
  65.         qDL:SetFocus()
  66.         GameTooltip:SetOwner(qDL, "ANCHOR_BOTTOM", 0, -10)
  67.         GameTooltip:AddLine(qDL.tiptext)
  68.         GameTooltip:AddLine(L["Maps"].PressToCopy, r, g, b)
  69.         GameTooltip:Show()
  70.     end)
  71.  
  72.     qDL:HookScript("OnLeave", function()
  73.         qDL:HighlightText(0, 0)
  74.         qDL:ClearFocus()
  75.         SetQuestInBox()
  76.         if (GameTooltip:IsForbidden()) then
  77.             return
  78.         end
  79.         GameTooltip:Hide()
  80.     end)
  81. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement