Commit 93a88b0c authored by Simpy's avatar Simpy 🐹
Browse files

Create an option to toggle tooltip skinning

1) create S.StatusBarColorGradient for use with our new status bar coloring in different skins
2) create tooltip skin file and move the tooltip skin hooks out of the main tooltip module
3) added an option to toggle off skinning tooltips (this also toggles off our coloring)

note: this option does not toggle skinning on the datatext tooltips
parent 63aad582
......@@ -58,6 +58,7 @@
<Script file='talent.lua'/>
<Script file='talkinghead.lua'/>
<Script file='taxi.lua'/>
<Script file='tooltip.lua'/>
<Script file='timemanager.lua'/>
<Script file='trade.lua'/>
<Script file='tradeskill.lua'/>
......
......@@ -41,13 +41,9 @@ local function LoadSkin()
end
end)
local function ColorProgressBars(self, percent)
if not (self.Bar and self.isSkinned and percent) then return end
local r, g, b = E:ColorGradient(percent/100, 0.8, 0, 0, 0.8, 0.8, 0, 0, 0.8, 0)
self.Bar:SetStatusBarColor(r, g, b)
if self.Bar.backdrop then
self.Bar.backdrop:SetBackdropColor(r*0.25, g*0.25, b*0.25)
end
local function ColorProgressBars(self, value)
if not (self.Bar and self.isSkinned and value) then return end
S:StatusBarColorGradient(self.Bar, value, 100)
end
local function SkinItemButton(self, block)
......
local E, L, V, P, G = unpack(select(2, ...)); --Inport: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
local S = E:GetModule('Skins')
local TT = E:GetModule('Tooltip')
--Cache global variables
--Lua functions
local _G = _G
local unpack = unpack
local pairs = pairs
--WoW API / Variables
local hooksecurefunc = hooksecurefunc
--Global variables that we don't cache, list them here for mikk's FindGlobals script
-- GLOBALS: ItemRefTooltip, FriendsTooltip, WorldMapTooltip
-- GLOBALS: WorldMapTaskTooltipStatusBar, ReputationParagonTooltipStatusBar
-- GLOBALS: ItemRefShoppingTooltip1, ItemRefShoppingTooltip2, ItemRefShoppingTooltip3
-- GLOBALS: WorldMapCompareTooltip1, WorldMapCompareTooltip2, WorldMapCompareTooltip3
-- GLOBALS: ShoppingTooltip1, ShoppingTooltip2, ShoppingTooltip3
-- GLOBALS: ItemRefCloseButton, AutoCompleteBox
local function LoadSkin()
if E.private.skins.blizzard.enable ~= true or E.private.skins.blizzard.tooltip ~= true then return end
local GameTooltip = _G['GameTooltip']
local GameTooltipStatusBar = _G['GameTooltipStatusBar']
GameTooltipStatusBar:SetStatusBarTexture(E['media'].normTex)
E:RegisterStatusBar(GameTooltipStatusBar)
GameTooltipStatusBar:CreateBackdrop('Transparent')
GameTooltipStatusBar:ClearAllPoints()
GameTooltipStatusBar:Point("TOPLEFT", GameTooltip, "BOTTOMLEFT", E.Border, -(E.Spacing * 3))
GameTooltipStatusBar:Point("TOPRIGHT", GameTooltip, "BOTTOMRIGHT", -E.Border, -(E.Spacing * 3))
S:HandleCloseButton(ItemRefCloseButton)
local tooltips = {
GameTooltip,
ItemRefTooltip,
ItemRefShoppingTooltip1,
ItemRefShoppingTooltip2,
ItemRefShoppingTooltip3,
AutoCompleteBox,
FriendsTooltip,
ShoppingTooltip1,
ShoppingTooltip2,
ShoppingTooltip3,
WorldMapTooltip,
WorldMapCompareTooltip1,
WorldMapCompareTooltip2,
WorldMapCompareTooltip3,
}
-- World Quest Reward Icon
WorldMapTooltip.ItemTooltip.Icon:SetTexCoord(unpack(E.TexCoords))
hooksecurefunc(WorldMapTooltip.ItemTooltip.IconBorder, 'SetVertexColor', function(self, r, g, b)
self:GetParent().backdrop:SetBackdropBorderColor(r, g, b)
self:SetTexture('')
end)
hooksecurefunc(WorldMapTooltip.ItemTooltip.IconBorder, 'Hide', function(self)
self:GetParent().backdrop:SetBackdropBorderColor(unpack(E.media.bordercolor))
end)
WorldMapTooltip.ItemTooltip:CreateBackdrop()
WorldMapTooltip.ItemTooltip.backdrop:SetOutside(WorldMapTooltip.ItemTooltip.Icon)
WorldMapTooltip.ItemTooltip.Count:ClearAllPoints()
WorldMapTooltip.ItemTooltip.Count:SetPoint('BOTTOMRIGHT', WorldMapTooltip.ItemTooltip.Icon, 'BOTTOMRIGHT', 1, 0)
-- Tooltip Statusbars
local function SkinTooltipProgressBar(frame)
if not (frame and frame.Bar) then return end
frame.Bar:StripTextures()
frame.Bar:CreateBackdrop('Transparent')
frame.Bar:SetStatusBarTexture(E['media'].normTex)
E:RegisterStatusBar(frame.Bar)
frame.isSkinned = true
end
SkinTooltipProgressBar(ReputationParagonTooltipStatusBar)
SkinTooltipProgressBar(WorldMapTaskTooltipStatusBar)
-- Color Tooltip Statusbars
local function ColorTooltipProgressBar(self, value)
local frame, tooltip, amount, max, r, g, b, _
if self.worldQuest and self.questID then
frame = _G['WorldMapTaskTooltipStatusBar']
if not (frame and frame.Bar and frame.isSkinned) then return end
elseif value then
tooltip = _G['ReputationParagonTooltip']
frame = _G['ReputationParagonTooltipStatusBar']
if not (frame and frame.Bar and frame.isSkinned and tooltip and tooltip.factionID == value) then return end
end
amount = frame and frame.Bar and frame.Bar.GetValue and frame.Bar:GetValue()
if not amount then return end
_, max = frame.Bar.GetMinMaxValues and frame.Bar:GetMinMaxValues()
S:StatusBarColorGradient(frame.Bar, amount, max)
end
hooksecurefunc('TaskPOI_OnEnter', ColorTooltipProgressBar)
hooksecurefunc('ReputationParagonFrame_SetupParagonTooltip', ColorTooltipProgressBar)
for _, tt in pairs(tooltips) do
TT:SecureHookScript(tt, 'OnShow', 'SetStyle')
end
TT:SecureHook('GameTooltip_ShowStatusBar', 'GameTooltip_ShowStatusBar')
TT:SecureHookScript(GameTooltip, 'OnSizeChanged', 'CheckBackdropColor')
TT:SecureHookScript(GameTooltip, 'OnUpdate', 'CheckBackdropColor') --There has to be a more elegant way of doing this.
TT:RegisterEvent('CURSOR_UPDATE', 'CheckBackdropColor')
end
S:AddCallback('SkinTooltip', LoadSkin)
\ No newline at end of file
......@@ -36,6 +36,15 @@ function S:SetOriginalBackdrop()
self:SetBackdropBorderColor(unpack(E["media"].bordercolor))
end
function S:StatusBarColorGradient(bar, value, max, backdrop)
local current = (not max and value) or (value and max and max ~= 0 and value/max)
if not (bar and current) then return end
local r, g, b = E:ColorGradient(current, 0.8,0,0, 0.8,0.8,0, 0,0.8,0)
local bg = backdrop or bar.backdrop
if bg then bg:SetBackdropColor(r*0.25, g*0.25, b*0.25) end
bar:SetStatusBarColor(r, g, b)
end
function S:HandleButton(f, strip)
assert(f, "doesn't exist!")
if f.Left then f.Left:SetAlpha(0) end
......
......@@ -83,7 +83,7 @@ local hooksecurefunc = hooksecurefunc
--Global variables that we don't cache, list them here for mikk's FindGlobals script
-- GLOBALS: ElvUI_ContainerFrame, RightChatPanel, TooltipMover, UIParent, ElvUI_KeyBinder
-- GLOBALS: ItemRefCloseButton, RightChatToggleButton, BNToastFrame, MMHolder, GameTooltipText
-- GLOBALS: RightChatToggleButton, BNToastFrame, MMHolder, GameTooltipText
-- GLOBALS: BNETMover, ItemRefTooltip, InspectFrame, GameTooltipHeaderText, GameTooltipTextSmall
-- GLOBALS: ShoppingTooltip1TextLeft1, ShoppingTooltip1TextLeft2, ShoppingTooltip1TextLeft3
-- GLOBALS: ShoppingTooltip1TextLeft4, ShoppingTooltip1TextRight1, ShoppingTooltip1TextRight2
......@@ -91,7 +91,6 @@ local hooksecurefunc = hooksecurefunc
-- GLOBALS: ShoppingTooltip2TextLeft2, ShoppingTooltip2TextLeft3, ShoppingTooltip2TextLeft4
-- GLOBALS: ShoppingTooltip2TextRight1, ShoppingTooltip2TextRight2, ShoppingTooltip2TextRight3
-- GLOBALS: ShoppingTooltip2TextRight4, GameTooltipTextLeft1, GameTooltipTextLeft2, WorldMapTooltip
-- GLOBALS: WorldMapTaskTooltipStatusBar, ReputationParagonTooltipStatusBar
local GameTooltip, GameTooltipStatusBar = _G["GameTooltip"], _G["GameTooltipStatusBar"]
local S_ITEM_LEVEL = ITEM_LEVEL:gsub( "%%d", "(%%d+)" )
......@@ -102,23 +101,6 @@ local AFK_LABEL = " |cffFFFFFF[|r|cffFF0000"..L["AFK"].."|r|cffFFFFFF]|r"
local DND_LABEL = " |cffFFFFFF[|r|cffFFFF00"..L["DND"].."|r|cffFFFFFF]|r"
local keybindFrame
local tooltips = {
GameTooltip,
ItemRefTooltip,
ItemRefShoppingTooltip1,
ItemRefShoppingTooltip2,
ItemRefShoppingTooltip3,
AutoCompleteBox,
FriendsTooltip,
ShoppingTooltip1,
ShoppingTooltip2,
ShoppingTooltip3,
WorldMapTooltip,
WorldMapCompareTooltip1,
WorldMapCompareTooltip2,
WorldMapCompareTooltip3,
}
local classification = {
worldboss = format("|cffAF5050 %s|r", BOSS),
rareelite = format("|cffAF5050+ %s|r", ITEM_QUALITY3_DESC),
......@@ -745,13 +727,7 @@ function TT:Initialize()
E.Tooltip = TT
GameTooltipStatusBar:Height(self.db.healthBar.height)
GameTooltipStatusBar:SetStatusBarTexture(E["media"].normTex)
E:RegisterStatusBar(GameTooltipStatusBar)
GameTooltipStatusBar:CreateBackdrop('Transparent')
GameTooltipStatusBar:SetScript("OnValueChanged", self.OnValueChanged)
GameTooltipStatusBar:ClearAllPoints()
GameTooltipStatusBar:Point("TOPLEFT", GameTooltip, "BOTTOMLEFT", E.Border, -(E.Spacing * 3))
GameTooltipStatusBar:Point("TOPRIGHT", GameTooltip, "BOTTOMRIGHT", -E.Border, -(E.Spacing * 3))
GameTooltipStatusBar:SetScript("OnValueChanged", nil) -- Do we need to unset this?
GameTooltipStatusBar.text = GameTooltipStatusBar:CreateFontString(nil, "OVERLAY")
GameTooltipStatusBar.text:Point("CENTER", GameTooltipStatusBar, 0, -3)
GameTooltipStatusBar.text:FontTemplate(E.LSM:Fetch("font", self.db.healthBar.font), self.db.healthBar.fontSize, self.db.healthBar.fontOutline)
......@@ -772,7 +748,6 @@ function TT:Initialize()
E:CreateMover(GameTooltipAnchor, 'TooltipMover', L["Tooltip"])
self:SecureHook('GameTooltip_SetDefaultAnchor')
self:SecureHook('GameTooltip_ShowStatusBar')
self:SecureHook("SetItemRef")
self:SecureHook(GameTooltip, "SetUnitAura")
self:SecureHook(GameTooltip, "SetUnitBuff", "SetUnitAura")
......@@ -781,31 +756,8 @@ function TT:Initialize()
self:SecureHookScript(GameTooltip, 'OnTooltipCleared', 'GameTooltip_OnTooltipCleared')
self:SecureHookScript(GameTooltip, 'OnTooltipSetItem', 'GameTooltip_OnTooltipSetItem')
self:SecureHookScript(GameTooltip, 'OnTooltipSetUnit', 'GameTooltip_OnTooltipSetUnit')
self:SecureHookScript(GameTooltip, "OnSizeChanged", "CheckBackdropColor")
self:SecureHookScript(GameTooltip, "OnUpdate", "CheckBackdropColor") --There has to be a more elegant way of doing this.
self:SecureHookScript(GameTooltipStatusBar, 'OnValueChanged', 'GameTooltipStatusBar_OnValueChanged')
self:RegisterEvent("MODIFIER_STATE_CHANGED")
self:RegisterEvent("CURSOR_UPDATE", "CheckBackdropColor")
E.Skins:HandleCloseButton(ItemRefCloseButton)
for _, tt in pairs(tooltips) do
self:SecureHookScript(tt, 'OnShow', 'SetStyle')
end
--World Quest Reward Icon
WorldMapTooltip.ItemTooltip.Icon:SetTexCoord(unpack(E.TexCoords))
hooksecurefunc(WorldMapTooltip.ItemTooltip.IconBorder, "SetVertexColor", function(self, r, g, b)
self:GetParent().backdrop:SetBackdropBorderColor(r, g, b)
self:SetTexture("")
end)
hooksecurefunc(WorldMapTooltip.ItemTooltip.IconBorder, "Hide", function(self)
self:GetParent().backdrop:SetBackdropBorderColor(unpack(E.media.bordercolor))
end)
WorldMapTooltip.ItemTooltip:CreateBackdrop()
WorldMapTooltip.ItemTooltip.backdrop:SetOutside(WorldMapTooltip.ItemTooltip.Icon)
WorldMapTooltip.ItemTooltip.Count:ClearAllPoints()
WorldMapTooltip.ItemTooltip.Count:SetPoint("BOTTOMRIGHT", WorldMapTooltip.ItemTooltip.Icon, "BOTTOMRIGHT", 1, 0)
--Variable is localized at top of file, then set here when we're sure the frame has been created
--Used to check if keybinding is active, if so then don't hide tooltips on actionbars
......@@ -813,43 +765,6 @@ function TT:Initialize()
--Variable is localized at top of file, but setting it right away doesn't work on first session after opening up WoW
playerGUID = UnitGUID("player")
-- Tooltip Statusbars
local function SkinTooltipProgressBar(frame)
if not (frame and frame.Bar) then return end
frame.Bar:StripTextures()
frame.Bar:CreateBackdrop("Transparent")
frame.Bar:SetStatusBarTexture(E["media"].normTex)
E:RegisterStatusBar(frame.Bar)
frame.isSkinned = true
end
SkinTooltipProgressBar(ReputationParagonTooltipStatusBar)
SkinTooltipProgressBar(WorldMapTaskTooltipStatusBar)
-- Color Tooltip Statusbars
local function ColorTooltipProgressBar(self, value)
local frame, tooltip, amount, max, r, g, b, _
if self.worldQuest and self.questID then
frame = _G["WorldMapTaskTooltipStatusBar"]
if not (frame and frame.Bar and frame.isSkinned) then return end
elseif value then
tooltip = _G["ReputationParagonTooltip"]
frame = _G["ReputationParagonTooltipStatusBar"]
if not (frame and frame.Bar and frame.isSkinned and tooltip and tooltip.factionID == value) then return end
end
amount = frame and frame.Bar and frame.Bar.GetValue and frame.Bar:GetValue()
if not amount then return end
_, max = frame.Bar:GetMinMaxValues()
if max and max > 0 then
r, g, b = E:ColorGradient(amount/max, 0.8, 0, 0, 0.8, 0.8, 0, 0, 0.8, 0)
frame.Bar:SetStatusBarColor(r, g, b)
if frame.Bar.backdrop then
frame.Bar.backdrop:SetBackdropColor(r*0.25, g*0.25, b*0.25)
end
end
end
hooksecurefunc("TaskPOI_OnEnter", ColorTooltipProgressBar)
hooksecurefunc("ReputationParagonFrame_SetupParagonTooltip", ColorTooltipProgressBar)
end
local function InitializeCallback()
......
......@@ -87,6 +87,7 @@ V['skins'] = {
["greeting"] = true,
["worldmap"] = true,
["taxi"] = true,
["tooltip"] = true,
["quest"] = true,
["questChoice"] = false,
["petition"] = true,
......
......@@ -706,6 +706,7 @@ L["Tabard Frame"] = "战袍"
L["Talent Frame"] = "天赋"
L["TalkingHead"] = "剧情对话框"
L["Taxi Frame"] = "载具"
L["Tooltip"] = true
L["Time Manager"] = "时间管理"
L["Trade Frame"] = "交易"
L["TradeSkill Frame"] = "专业技能"
......
......@@ -695,6 +695,7 @@ L["Tabard Frame"] = true;
L["Talent Frame"] = true;
L["TalkingHead"] = true;
L["Taxi Frame"] = true;
L["Tooltip"] = true;
L["Time Manager"] = true;
L["Trade Frame"] = true;
L["TradeSkill Frame"] = true;
......
......@@ -706,6 +706,7 @@ L["Tabard Frame"] = "Tabard"
L["Talent Frame"] = "Fenêtre des talents"
L["TalkingHead"] = true;
L["Taxi Frame"] = "Trajets aériens"
L["Tooltip"] = true
L["Time Manager"] = "Chronomètre"
L["Trade Frame"] = "Fenêtre d'échange"
L["TradeSkill Frame"] = "Métiers"
......
......@@ -707,6 +707,7 @@ L["Tabard Frame"] = "Wappenrockfenster"
L["Talent Frame"] = "Talentfenster"
L["TalkingHead"] = "Sprechender Kopf"
L["Taxi Frame"] = "Flugroutenfenster"
L["Tooltip"] = true
L["Time Manager"] = "Zeitmanager"
L["Trade Frame"] = "Handelsfenster"
L["TradeSkill Frame"] = "Berufsfenster"
......
......@@ -754,6 +754,7 @@ L["Tabard Frame"] = "휘장 프레임"
L["Talent Frame"] = "특성 창"
L["TalkingHead"] = true;
L["Taxi Frame"] = "그리폰/와이번 창"
L["Tooltip"] = true
L["Time Manager"] = "시계 창"
L["Trade Frame"] = "거래창"
L["TradeSkill Frame"] = "전문기술 창"
......
......@@ -706,6 +706,7 @@ L["Tabard Frame"] = "Tabardo"
L["Talent Frame"] = "Talentos"
L["TalkingHead"] = true;
L["Taxi Frame"] = "Taxi"
L["Tooltip"] = true
L["Time Manager"] = "Relógio"
L["Trade Frame"] = "Negociar"
L["TradeSkill Frame"] = "Profissões"
......
......@@ -705,6 +705,7 @@ L["Tabard Frame"] = "Создание накидки"
L["Talent Frame"] = "Таланты"
L["TalkingHead"] = "Говорящая голова"
L["Taxi Frame"] = "Такси"
L["Tooltip"] = true
L["Time Manager"] = "Секундомер"
L["Trade Frame"] = "Обмен"
L["TradeSkill Frame"] = "Профессия"
......
......@@ -705,6 +705,7 @@ L["Tabard Frame"] = "Tabardos"
L["Talent Frame"] = "Talentos"
L["TalkingHead"] = true;
L["Taxi Frame"] = "Viaje"
L["Tooltip"] = true
L["Time Manager"] = "Administrador de Tiempo"
L["Trade Frame"] = "Comercio"
L["TradeSkill Frame"] = "Comercio de Habilidades"
......
......@@ -706,6 +706,7 @@ L["Tabard Frame"] = "外袍"
L["Talent Frame"] = "天賦"
L["TalkingHead"] = "特寫框體"
L["Taxi Frame"] = "載具"
L["Tooltip"] = true
L["Time Manager"] = "時間管理"
L["Trade Frame"] = "交易"
L["TradeSkill Frame"] = "專業技能"
......
......@@ -204,6 +204,11 @@ E.Options.args.skins = {
name = L["Taxi Frame"],
desc = L["TOGGLESKIN_DESC"],
},
tooltip = {
type = "toggle",
name = L["Tooltip"],
desc = L["TOGGLESKIN_DESC"],
},
lfg = {
type = "toggle",
name = L["LFG Frame"],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment