Update
This commit is contained in:
@@ -1,72 +1,72 @@
|
||||
local baseUrl = "https://www.wowhead.com/"
|
||||
local keybind = "CTRL-C"
|
||||
local popupText = "Wowhead %s Link\n" .. keybind .. " to copy"
|
||||
|
||||
local typeAttributeMap = {
|
||||
quest = {"id", "questId", "questID"},
|
||||
item = {info = {"id"}}
|
||||
}
|
||||
|
||||
|
||||
local function ShowUrlPopup(id, type)
|
||||
if not (id or type) then return end
|
||||
local url = baseUrl .. type .. "=" .. id
|
||||
StaticPopup_Show("WowheadQuestLinkUrl", type:sub(1, 1):upper() .. type:sub(2), _, url)
|
||||
end
|
||||
|
||||
|
||||
local function getIdAndType(focus)
|
||||
local function loop(focus, keys)
|
||||
if not focus then return end
|
||||
for key, value in pairs(keys) do
|
||||
if type(value) == "table" then
|
||||
return loop(focus[key], value)
|
||||
end
|
||||
local id = focus[value]
|
||||
if id then
|
||||
return id
|
||||
end
|
||||
end
|
||||
end
|
||||
if not focus then return end
|
||||
for type, keys in pairs(typeAttributeMap) do
|
||||
local id = loop(focus, keys)
|
||||
if id then
|
||||
return id, type
|
||||
end
|
||||
end
|
||||
return getIdAndType(focus:GetParent())
|
||||
end
|
||||
|
||||
|
||||
local function run()
|
||||
local focus = GetMouseFocus()
|
||||
local id, type = getIdAndType(focus)
|
||||
ShowUrlPopup(id, type)
|
||||
end
|
||||
|
||||
|
||||
StaticPopupDialogs["WowheadQuestLinkUrl"] = {
|
||||
text = popupText,
|
||||
button1 = "Close",
|
||||
OnShow = function(self, data)
|
||||
local function HidePopup(self) self:GetParent():Hide() end
|
||||
self.editBox:SetScript("OnEscapePressed", HidePopup)
|
||||
self.editBox:SetScript("OnEnterPressed", HidePopup)
|
||||
self.editBox:SetMaxLetters(0)
|
||||
self.editBox:SetText(data)
|
||||
self.editBox:HighlightText(0, self.editBox:GetNumLetters())
|
||||
end,
|
||||
hasEditBox = true,
|
||||
editBoxWidth = 233,
|
||||
timeout = 0,
|
||||
whileDead = true,
|
||||
hideOnEscape = true,
|
||||
preferredIndex = 3,
|
||||
}
|
||||
|
||||
|
||||
local btn = CreateFrame("BUTTON", "KeybindBtn")
|
||||
SetBindingClick(keybind, btn:GetName())
|
||||
btn:SetScript("OnClick", run)
|
||||
|
||||
local baseUrl = "https://www.wowhead.com/"
|
||||
local keybind = "CTRL-C"
|
||||
local popupText = "Wowhead %s Link\n" .. keybind .. " to copy"
|
||||
|
||||
local typeAttributeMap = {
|
||||
quest = {"id", "questId", "questID"},
|
||||
item = {info = {"id"}}
|
||||
}
|
||||
|
||||
|
||||
local function ShowUrlPopup(id, type)
|
||||
if not (id or type) then return end
|
||||
local url = baseUrl .. type .. "=" .. id
|
||||
StaticPopup_Show("WowheadQuestLinkUrl", type:sub(1, 1):upper() .. type:sub(2), _, url)
|
||||
end
|
||||
|
||||
|
||||
local function getIdAndType(focus)
|
||||
local function loop(focus, keys)
|
||||
if not focus then return end
|
||||
for key, value in pairs(keys) do
|
||||
if type(value) == "table" then
|
||||
return loop(focus[key], value)
|
||||
end
|
||||
local id = focus[value]
|
||||
if id then
|
||||
return id
|
||||
end
|
||||
end
|
||||
end
|
||||
if not focus then return end
|
||||
for type, keys in pairs(typeAttributeMap) do
|
||||
local id = loop(focus, keys)
|
||||
if id then
|
||||
return id, type
|
||||
end
|
||||
end
|
||||
return getIdAndType(focus:GetParent())
|
||||
end
|
||||
|
||||
|
||||
local function run()
|
||||
local focus = GetMouseFocus()
|
||||
local id, type = getIdAndType(focus)
|
||||
ShowUrlPopup(id, type)
|
||||
end
|
||||
|
||||
|
||||
StaticPopupDialogs["WowheadQuestLinkUrl"] = {
|
||||
text = popupText,
|
||||
button1 = "Close",
|
||||
OnShow = function(self, data)
|
||||
local function HidePopup(self) self:GetParent():Hide() end
|
||||
self.editBox:SetScript("OnEscapePressed", HidePopup)
|
||||
self.editBox:SetScript("OnEnterPressed", HidePopup)
|
||||
self.editBox:SetMaxLetters(0)
|
||||
self.editBox:SetText(data)
|
||||
self.editBox:HighlightText(0, self.editBox:GetNumLetters())
|
||||
end,
|
||||
hasEditBox = true,
|
||||
editBoxWidth = 233,
|
||||
timeout = 0,
|
||||
whileDead = true,
|
||||
hideOnEscape = true,
|
||||
preferredIndex = 3,
|
||||
}
|
||||
|
||||
|
||||
local btn = CreateFrame("BUTTON", "KeybindBtn")
|
||||
SetBindingClick(keybind, btn:GetName())
|
||||
btn:SetScript("OnClick", run)
|
||||
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
function(event,addonName)
|
||||
if event == "ADDON_LOADED" and addonName == "Blizzard_Communities" then
|
||||
--create overlay
|
||||
local f = CreateFrame("Button",nil,UIParent)
|
||||
f:SetFrameStrata("HIGH")
|
||||
f.tex = f:CreateTexture(nil, "BACKGROUND")
|
||||
f.tex:SetAllPoints()
|
||||
f.tex:SetColorTexture(0.1,0.1,0.1,1)
|
||||
f.text = f:CreateFontString()
|
||||
f.text:SetFontObject("GameFontNormalMed3")
|
||||
f.text:SetText("Chat Hidden. Click to show")
|
||||
f.text:SetTextColor(1, 1, 1, 1)
|
||||
f.text:SetJustifyH("CENTER")
|
||||
f.text:SetJustifyV("CENTER")
|
||||
f.text:SetHeight(20)
|
||||
f.text:SetPoint("CENTER",f,"CENTER",0,0)
|
||||
f:EnableMouse(true)
|
||||
f:RegisterForClicks("AnyUp")
|
||||
f:SetScript("OnClick",function(...)
|
||||
f:Hide()
|
||||
end)
|
||||
--toggle
|
||||
local function toggleOverlay()
|
||||
if CommunitiesFrame:GetDisplayMode() == COMMUNITIES_FRAME_DISPLAY_MODES.CHAT then
|
||||
f:SetAllPoints(CommunitiesFrame.Chat.InsetFrame)
|
||||
f:Show()
|
||||
elseif CommunitiesFrame:GetDisplayMode() == COMMUNITIES_FRAME_DISPLAY_MODES.MINIMIZED then
|
||||
f:SetAllPoints(CommunitiesFrameInset)
|
||||
f:Show()
|
||||
else
|
||||
f:Hide()
|
||||
end
|
||||
end
|
||||
local function hideOverlay()
|
||||
f:Hide()
|
||||
end
|
||||
toggleOverlay() --run once
|
||||
|
||||
--hook
|
||||
hooksecurefunc(CommunitiesFrame,"SetDisplayMode", toggleOverlay)
|
||||
hooksecurefunc(CommunitiesFrame,"Show",toggleOverlay)
|
||||
hooksecurefunc(CommunitiesFrame,"Hide",hideOverlay)
|
||||
hooksecurefunc(CommunitiesFrame,"OnClubSelected", toggleOverlay)
|
||||
end
|
||||
function(event,addonName)
|
||||
if event == "ADDON_LOADED" and addonName == "Blizzard_Communities" then
|
||||
--create overlay
|
||||
local f = CreateFrame("Button",nil,UIParent)
|
||||
f:SetFrameStrata("HIGH")
|
||||
f.tex = f:CreateTexture(nil, "BACKGROUND")
|
||||
f.tex:SetAllPoints()
|
||||
f.tex:SetColorTexture(0.1,0.1,0.1,1)
|
||||
f.text = f:CreateFontString()
|
||||
f.text:SetFontObject("GameFontNormalMed3")
|
||||
f.text:SetText("Chat Hidden. Click to show")
|
||||
f.text:SetTextColor(1, 1, 1, 1)
|
||||
f.text:SetJustifyH("CENTER")
|
||||
f.text:SetJustifyV("CENTER")
|
||||
f.text:SetHeight(20)
|
||||
f.text:SetPoint("CENTER",f,"CENTER",0,0)
|
||||
f:EnableMouse(true)
|
||||
f:RegisterForClicks("AnyUp")
|
||||
f:SetScript("OnClick",function(...)
|
||||
f:Hide()
|
||||
end)
|
||||
--toggle
|
||||
local function toggleOverlay()
|
||||
if CommunitiesFrame:GetDisplayMode() == COMMUNITIES_FRAME_DISPLAY_MODES.CHAT then
|
||||
f:SetAllPoints(CommunitiesFrame.Chat.InsetFrame)
|
||||
f:Show()
|
||||
elseif CommunitiesFrame:GetDisplayMode() == COMMUNITIES_FRAME_DISPLAY_MODES.MINIMIZED then
|
||||
f:SetAllPoints(CommunitiesFrameInset)
|
||||
f:Show()
|
||||
else
|
||||
f:Hide()
|
||||
end
|
||||
end
|
||||
local function hideOverlay()
|
||||
f:Hide()
|
||||
end
|
||||
toggleOverlay() --run once
|
||||
|
||||
--hook
|
||||
hooksecurefunc(CommunitiesFrame,"SetDisplayMode", toggleOverlay)
|
||||
hooksecurefunc(CommunitiesFrame,"Show",toggleOverlay)
|
||||
hooksecurefunc(CommunitiesFrame,"Hide",hideOverlay)
|
||||
hooksecurefunc(CommunitiesFrame,"OnClubSelected", toggleOverlay)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user