93 lines
3.2 KiB
Lua
93 lines
3.2 KiB
Lua
local name, addon = ...
|
|
|
|
local function chatHoverIn(cf,link,text)
|
|
local typ = string.match(link, "^(.-):")
|
|
if(typ == "spell") then
|
|
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
|
|
GameTooltip:SetHyperlink(link)
|
|
ShowUIPanel(GameTooltip)
|
|
elseif(typ == "player") then
|
|
local typ, name = string.match(link, "^(.-):(.*).*")
|
|
if(name) then
|
|
GameTooltip:SetOwner(UIParent, "ANCHOR_CURSOR")
|
|
GameTooltip:SetUnit(name)
|
|
ShowUIPanel(GameTooltip)
|
|
-- GameTooltip:Hide()
|
|
end
|
|
end
|
|
end
|
|
|
|
local function chatHoverOut()
|
|
GameTooltip:Hide()
|
|
-- HideUIPanel(GameTooltip)
|
|
end
|
|
local frame = CreateFrame("Frame", name.."ScrollInfoBD", addon.davisframe, BackdropTemplateMixin and "BackdropTemplate" or nil)
|
|
frame.width = 350
|
|
frame.height = 140
|
|
frame:SetFrameStrata("BACKGROUND")
|
|
frame:SetAllPoints(addon.davisframe)
|
|
--frame:SetSize(frame.width, frame.height)
|
|
|
|
frame:SetBackdrop({
|
|
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
|
|
edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
|
|
tile = true,
|
|
tileSize = 32,
|
|
edgeSize = 32,
|
|
insets = { left = 8, right = 8, top = 8, bottom = 8 }
|
|
})
|
|
frame:SetBackdropColor(0, 0, 0, 1)
|
|
|
|
frame:SetScript("OnHide", function(self) if(not InCombatLockdown()) then self:GetParent():EnableMouse(false) end addon:UpdateInfoButtons() end)
|
|
frame:SetScript("OnShow", function(self) if(not InCombatLockdown()) then self:GetParent():EnableMouse(true) end addon:UpdateInfoButtons() end)
|
|
frame:Show()
|
|
local scroll = CreateFrame("ScrollingMessageFrame", name.."ScrollInfo", frame, BackdropTemplateMixin and "BackdropTemplate" or nil)
|
|
scroll:SetFontObject(GameFontNormal)
|
|
scroll:SetTextColor(1, 1, 1, 1)
|
|
scroll:SetHyperlinksEnabled(true)
|
|
scroll:SetSize(frame:GetWidth() - 60,frame:GetHeight() - 30)
|
|
scroll:SetPoint("TOPLEFT",frame,"TOPLEFT",10,-10)
|
|
|
|
scroll:SetJustifyH("LEFT")
|
|
scroll:SetFading(false)
|
|
scroll:SetMaxLines(300)
|
|
|
|
scroll:SetScript("OnHyperlinkEnter",chatHoverIn)
|
|
scroll:SetScript("OnHyperlinkLeave",chatHoverOut)
|
|
scroll:Clear()
|
|
scroll:Show()
|
|
frame.scroll = scroll
|
|
local closeButton = CreateFrame("Button",name.."CloseButton",frame,"UIPanelCloseButton")
|
|
closeButton:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -4, -4)
|
|
closeButton:SetFrameStrata("MEDIUM")
|
|
local scrollBar = CreateFrame("Slider", nil, frame, "UIPanelScrollBarTemplate")
|
|
scrollBar:SetPoint("TOPRIGHT", closeButton, "BOTTOMRIGHT", -1, -12)
|
|
scrollBar:SetSize(30, frame:GetHeight() - 76)
|
|
scrollBar:SetMinMaxValues(0, 99)
|
|
scrollBar:SetValueStep(1)
|
|
scrollBar.scrollStep = 1
|
|
frame.scrollBar = scrollBar
|
|
|
|
scrollBar:SetScript("OnValueChanged", function(self, value)
|
|
scroll:SetScrollOffset(select(2, scrollBar:GetMinMaxValues()) - value)
|
|
end)
|
|
|
|
scrollBar:SetValue(select(2, scrollBar:GetMinMaxValues()))
|
|
frame:SetScript("OnMouseWheel", function(self, delta)
|
|
local cur_val = scrollBar:GetValue()
|
|
local min_val, max_val = scrollBar:GetMinMaxValues()
|
|
if delta < 0 and cur_val < max_val then
|
|
cur_val = math.min(max_val, cur_val + 1)
|
|
scrollBar:SetValue(cur_val)
|
|
elseif delta > 0 and cur_val > min_val then
|
|
cur_val = math.max(min_val, cur_val - 1)
|
|
scrollBar:SetValue(cur_val)
|
|
end
|
|
end)
|
|
addon.scrollframe = frame
|
|
function addon:AddScrollMessage(msg)
|
|
if(not frame:IsVisible()) then
|
|
frame:Show()
|
|
end
|
|
scroll:AddMessage(date("[%H:%M]")..msg)
|
|
end |