mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-06 21:50:00 +00:00
add tooltips
This commit is contained in:
+37
-1
@@ -21,7 +21,7 @@ pfUI:RegisterModule("gui", function ()
|
||||
end)
|
||||
|
||||
function pfUI.gui.SwitchTab(frame)
|
||||
local elements = { pfUI.gui.global, pfUI.gui.uf , pfUI.gui.bar, pfUI.gui.panel }
|
||||
local elements = { pfUI.gui.global, pfUI.gui.uf , pfUI.gui.bar, pfUI.gui.panel, pfUI.gui.tooltip }
|
||||
for _, hide in pairs(elements) do
|
||||
hide:Hide()
|
||||
end
|
||||
@@ -289,6 +289,42 @@ pfUI:RegisterModule("gui", function ()
|
||||
|
||||
pfUI.gui.CreateConfig(pfUI.gui.panel, "Other Panel: Minimap", pfUI_config.panel.other, "minimap")
|
||||
|
||||
|
||||
-- Tooltip settings
|
||||
pfUI.gui.tooltip = CreateFrame("Frame", nil, pfUI.gui)
|
||||
pfUI.gui.tooltip:SetWidth(400)
|
||||
pfUI.gui.tooltip:SetHeight(320)
|
||||
|
||||
pfUI.gui.tooltip:SetBackdrop(pfUI.backdrop)
|
||||
pfUI.gui.tooltip:SetBackdropColor(0,0,0,.50);
|
||||
pfUI.gui.tooltip:SetPoint("RIGHT",0,0)
|
||||
|
||||
pfUI.gui.tooltip.switch = CreateFrame("Button", nil, pfUI.gui)
|
||||
pfUI.gui.tooltip.switch:ClearAllPoints()
|
||||
pfUI.gui.tooltip.switch:SetWidth(80)
|
||||
pfUI.gui.tooltip.switch:SetHeight(20)
|
||||
pfUI.gui.tooltip.switch:SetPoint("TOPLEFT", 0, -80)
|
||||
pfUI.gui.tooltip.switch:SetBackdrop(pfUI.backdrop)
|
||||
pfUI.gui.tooltip.switch.text = pfUI.gui.tooltip.switch:CreateFontString("Status", "LOW", "GameFontNormal")
|
||||
pfUI.gui.tooltip.switch.text:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", 9, "OUTLINE")
|
||||
pfUI.gui.tooltip.switch.text:ClearAllPoints()
|
||||
pfUI.gui.tooltip.switch.text:SetAllPoints(pfUI.gui.tooltip.switch)
|
||||
pfUI.gui.tooltip.switch.text:SetPoint("CENTER", 0, 0)
|
||||
pfUI.gui.tooltip.switch.text:SetFontObject(GameFontWhite)
|
||||
pfUI.gui.tooltip.switch.text:SetText("Tooltips")
|
||||
pfUI.gui.tooltip.switch:SetScript("OnClick", function()
|
||||
pfUI.gui.SwitchTab(pfUI.gui.tooltip)
|
||||
end)
|
||||
|
||||
pfUI.gui.tooltip.title = pfUI.gui.tooltip:CreateFontString("Status", "LOW", "GameFontNormal")
|
||||
pfUI.gui.tooltip.title:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", 12, "OUTLINE")
|
||||
pfUI.gui.tooltip.title:SetPoint("TOP", 0, -10)
|
||||
pfUI.gui.tooltip.title:SetFontObject(GameFontWhite)
|
||||
pfUI.gui.tooltip.title:SetText("Tooltip Settings")
|
||||
|
||||
pfUI.gui.CreateConfig(pfUI.gui.tooltip, "Tooltip Position:", pfUI_config.tooltip, "position")
|
||||
|
||||
|
||||
-- Unlock Frames
|
||||
pfUI.gui.unlockFrames = CreateFrame("Button", nil, pfUI.gui)
|
||||
pfUI.gui.unlockFrames:ClearAllPoints()
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
pfUI:RegisterModule("tooltip", function ()
|
||||
GameTooltip:SetBackdrop(pfUI.backdrop)
|
||||
|
||||
if pfUI_config.tooltip.position == "cursor" then
|
||||
function GameTooltip_SetDefaultAnchor(tooltip, parent)
|
||||
tooltip:SetOwner(parent, "ANCHOR_CURSOR");
|
||||
end
|
||||
end
|
||||
|
||||
pfUI.tooltip = CreateFrame('Frame', nil, GameTooltip)
|
||||
pfUI.tooltip:SetAllPoints()
|
||||
pfUI.tooltip:SetScript("OnShow", function()
|
||||
if GameTooltip:GetAnchorType() == "ANCHOR_NONE" then
|
||||
GameTooltip:ClearAllPoints();
|
||||
if pfUI_config.tooltip.position == "bottom" then
|
||||
GameTooltip:SetPoint("BOTTOMRIGHT",pfUI.panel.right,"TOPRIGHT",0,0)
|
||||
elseif pfUI_config.tooltip.position == "chat" then
|
||||
GameTooltip:SetPoint("BOTTOMRIGHT",pfUI.chat.right,"TOPRIGHT",0,0)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
pfUI.tooltipStatusBar = CreateFrame('Frame', nil, GameTooltipStatusBar)
|
||||
pfUI.tooltipStatusBar:SetScript("OnUpdate", function()
|
||||
if(not UnitExists('mouseover')) then
|
||||
|
||||
return
|
||||
end
|
||||
local _, class = UnitClass("mouseover")
|
||||
local reaction = UnitReaction("mouseover", "player")
|
||||
|
||||
local hp = UnitHealth("mouseover")
|
||||
local hpm = UnitHealthMax("mouseover")
|
||||
|
||||
if pfUI.tooltipStatusBar.HP == nil then
|
||||
pfUI.tooltipStatusBar.HP = GameTooltipStatusBar:CreateFontString("Status", "DIALOG", "GameFontNormal")
|
||||
pfUI.tooltipStatusBar.HP:SetPoint("TOP", 0,8)
|
||||
pfUI.tooltipStatusBar.HP:SetNonSpaceWrap(false)
|
||||
pfUI.tooltipStatusBar.HP:SetFontObject(GameFontWhite)
|
||||
pfUI.tooltipStatusBar.HP:SetFont("Interface\\AddOns\\pfUI\\fonts\\arial.ttf", 12, "OUTLINE")
|
||||
end
|
||||
|
||||
if hp and hpm then
|
||||
if hp >= 1000 then hp = round(hp / 1000, 1) .. "k" end
|
||||
if hpm >= 1000 then hpm = round(hpm / 1000, 1) .. "k" end
|
||||
pfUI.tooltipStatusBar.HP:SetText(hp .. " / " .. hpm)
|
||||
end
|
||||
|
||||
if class and reaction then
|
||||
if UnitIsPlayer("mouseover") then
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
GameTooltipStatusBar:SetStatusBarColor(color.r, color.g, color.b)
|
||||
else
|
||||
local color = UnitReactionColor[reaction]
|
||||
GameTooltipStatusBar:SetStatusBarColor(color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
pfUI.tooltipEvent = CreateFrame("Frame")
|
||||
pfUI.tooltipEvent:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
|
||||
pfUI.tooltipEvent:SetScript("OnEvent", function()
|
||||
local pvpname = UnitPVPName("mouseover")
|
||||
local name = UnitName("mouseover")
|
||||
local target = UnitName("mouseovertarget")
|
||||
local _, targetClass = UnitClass("mouseovertarget")
|
||||
local targetReaction = UnitReaction("player","mouseovertarget")
|
||||
local _, class = UnitClass("mouseover")
|
||||
local guild = GetGuildInfo("mouseover")
|
||||
local reaction = UnitReaction("player", "mouseover")
|
||||
local pvptitle = gsub(pvpname," "..name, "", 1)
|
||||
|
||||
if name and reaction then
|
||||
if UnitIsPlayer("mouseover") and class then
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
GameTooltipStatusBar:SetStatusBarColor(color.r, color.g, color.b)
|
||||
GameTooltip:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
GameTooltipTextLeft1:SetText("|c" .. color.colorStr .. name)
|
||||
else
|
||||
local color = UnitReactionColor[reaction]
|
||||
GameTooltipStatusBar:SetStatusBarColor(color.r, color.g, color.b)
|
||||
GameTooltip:SetBackdropBorderColor(color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
if pvptitle ~= name then
|
||||
GameTooltip:AppendText(" |cff666666["..pvptitle.."]|r")
|
||||
end
|
||||
end
|
||||
|
||||
if guild then
|
||||
GameTooltip:AddLine("<" .. guild .. ">", 0.3, 1, 0.5)
|
||||
end
|
||||
|
||||
if target and ( targetClass or targetReaction ) then
|
||||
if UnitIsPlayer("mouseovertarget") then
|
||||
local color = RAID_CLASS_COLORS[targetClass]
|
||||
GameTooltip:AddLine(target, color.r, color.g, color.b)
|
||||
elseif targetReaction ~= nil then
|
||||
local color = UnitReactionColor[targetReaction]
|
||||
GameTooltip:AddLine(target, color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
GameTooltip:Show()
|
||||
end)
|
||||
|
||||
GameTooltipStatusBar:SetHeight(6)
|
||||
GameTooltipStatusBar:ClearAllPoints()
|
||||
GameTooltipStatusBar:SetPoint("BOTTOMLEFT", GameTooltip, "TOPLEFT", 1, 2)
|
||||
GameTooltipStatusBar:SetPoint("BOTTOMRIGHT", GameTooltip, "TOPRIGHT", -1, 2)
|
||||
GameTooltipStatusBar:SetStatusBarTexture("Interface\\AddOns\\pfUI\\img\\bar")
|
||||
GameTooltipStatusBar:SetBackdrop( { bgFile = [[Interface\Tooltips\UI-Tooltip-Background]],
|
||||
insets = {left = -1, right = -1, top = -1, bottom = -1} })
|
||||
GameTooltipStatusBar:SetBackdropColor(0, 0, 0, 1)
|
||||
|
||||
end)
|
||||
@@ -99,7 +99,10 @@ pfUI_config = {
|
||||
["other"] = {
|
||||
minimap = "zone",
|
||||
},
|
||||
}
|
||||
},
|
||||
["tooltip"] = {
|
||||
position = "bottom"
|
||||
},
|
||||
}
|
||||
|
||||
pfUI.cache = CreateFrame("Frame",nil,UIParent)
|
||||
@@ -108,7 +111,6 @@ pfUI.cache:SetScript("OnEvent", function()
|
||||
_, class = UnitClass("player")
|
||||
local color = RAID_CLASS_COLORS[class]
|
||||
pfUI.cache.class_r, pfUI.cache.class_g, pfUI.cache.class_b = (color.r + .5) * .5, (color.g + .5) * .5, (color.b + .5) * .5
|
||||
|
||||
end)
|
||||
|
||||
message = function (msg)
|
||||
|
||||
Reference in New Issue
Block a user