聊天重做前缓存
This commit is contained in:
@@ -78,6 +78,43 @@ local DEBUFF_TYPE_COLORS = {
|
||||
local DEBUFF_DEFAULT_COLOR = { r = 0.80, g = 0.00, b = 0.00 }
|
||||
local WEAPON_ENCHANT_COLOR = { r = 0.58, g = 0.22, b = 0.82 }
|
||||
|
||||
local function IsTooltipOwnedBy(frame)
|
||||
if not frame or not GameTooltip or not GameTooltip:IsVisible() then
|
||||
return false
|
||||
end
|
||||
if GameTooltip.IsOwned then
|
||||
return GameTooltip:IsOwned(frame)
|
||||
end
|
||||
if GameTooltip.GetOwner then
|
||||
return GameTooltip:GetOwner() == frame
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function HideOwnedTooltip(frame)
|
||||
if IsTooltipOwnedBy(frame) then
|
||||
GameTooltip:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
local function SetSlotTooltipKey(btn, key)
|
||||
if btn._sfTooltipKey ~= key then
|
||||
HideOwnedTooltip(btn)
|
||||
btn._sfTooltipKey = key
|
||||
end
|
||||
end
|
||||
|
||||
local function ClearSlotState(btn)
|
||||
HideOwnedTooltip(btn)
|
||||
btn.buffIndex = -1
|
||||
btn._sfSimulated = false
|
||||
btn._sfSimLabel = nil
|
||||
btn._sfSimDesc = nil
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
btn._sfTooltipKey = nil
|
||||
end
|
||||
|
||||
local function HideBlizzardBuffs()
|
||||
for i = 0, 23 do
|
||||
local btn = _G["BuffButton" .. i]
|
||||
@@ -170,18 +207,19 @@ local function CreateSlot(parent, namePrefix, index, isBuff)
|
||||
btn:SetScript("OnLeave", function()
|
||||
GameTooltip:Hide()
|
||||
end)
|
||||
btn:SetScript("OnHide", function()
|
||||
HideOwnedTooltip(this)
|
||||
end)
|
||||
btn:SetScript("OnClick", function()
|
||||
if this._sfSimulated then return end
|
||||
if this._isWeaponEnchant then return end
|
||||
if this.isBuff and this.buffIndex and this.buffIndex >= 0 then
|
||||
HideOwnedTooltip(this)
|
||||
CancelPlayerBuff(this.buffIndex)
|
||||
end
|
||||
end)
|
||||
|
||||
btn.buffIndex = -1
|
||||
btn._sfSimulated = false
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
ClearSlotState(btn)
|
||||
btn:Hide()
|
||||
return btn
|
||||
end
|
||||
@@ -339,9 +377,12 @@ function MB:UpdateBuffs()
|
||||
local btn = self.buffSlots[slotIdx]
|
||||
local texture = GetPlayerBuffTexture(buffIndex)
|
||||
if texture then
|
||||
SetSlotTooltipKey(btn, "buff:" .. tostring(buffIndex))
|
||||
btn.icon:SetTexture(texture)
|
||||
btn.buffIndex = buffIndex
|
||||
btn._sfSimulated = false
|
||||
btn._sfSimLabel = nil
|
||||
btn._sfSimDesc = nil
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
|
||||
@@ -360,10 +401,8 @@ function MB:UpdateBuffs()
|
||||
btn:SetBackdropBorderColor(0.25, 0.25, 0.30, 1)
|
||||
btn:Show()
|
||||
else
|
||||
ClearSlotState(btn)
|
||||
btn:Hide()
|
||||
btn.buffIndex = -1
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -378,9 +417,12 @@ function MB:UpdateBuffs()
|
||||
local btn = self.buffSlots[slotIdx]
|
||||
local texture = GetInventoryItemTexture("player", 16)
|
||||
if texture then
|
||||
SetSlotTooltipKey(btn, "weapon:16")
|
||||
btn.icon:SetTexture(texture)
|
||||
btn.buffIndex = -1
|
||||
btn._sfSimulated = false
|
||||
btn._sfSimLabel = nil
|
||||
btn._sfSimDesc = nil
|
||||
btn._isWeaponEnchant = true
|
||||
btn._weaponSlotID = 16
|
||||
|
||||
@@ -407,9 +449,12 @@ function MB:UpdateBuffs()
|
||||
local btn = self.buffSlots[slotIdx]
|
||||
local texture = GetInventoryItemTexture("player", 17)
|
||||
if texture then
|
||||
SetSlotTooltipKey(btn, "weapon:17")
|
||||
btn.icon:SetTexture(texture)
|
||||
btn.buffIndex = -1
|
||||
btn._sfSimulated = false
|
||||
btn._sfSimLabel = nil
|
||||
btn._sfSimDesc = nil
|
||||
btn._isWeaponEnchant = true
|
||||
btn._weaponSlotID = 17
|
||||
|
||||
@@ -432,10 +477,8 @@ function MB:UpdateBuffs()
|
||||
|
||||
for j = slotIdx + 1, MAX_BUFFS do
|
||||
local btn = self.buffSlots[j]
|
||||
ClearSlotState(btn)
|
||||
btn:Hide()
|
||||
btn.buffIndex = -1
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
end
|
||||
|
||||
self:UpdateDebuffs()
|
||||
@@ -450,6 +493,7 @@ function MB:UpdateDebuffs()
|
||||
|
||||
if db.showDebuffs == false then
|
||||
for i = 1, MAX_DEBUFFS do
|
||||
ClearSlotState(self.debuffSlots[i])
|
||||
self.debuffSlots[i]:Hide()
|
||||
end
|
||||
if self.debuffContainer then self.debuffContainer:Hide() end
|
||||
@@ -467,9 +511,14 @@ function MB:UpdateDebuffs()
|
||||
local btn = self.debuffSlots[slotIdx]
|
||||
local texture = GetPlayerBuffTexture(buffIndex)
|
||||
if texture then
|
||||
SetSlotTooltipKey(btn, "debuff:" .. tostring(buffIndex))
|
||||
btn.icon:SetTexture(texture)
|
||||
btn.buffIndex = buffIndex
|
||||
btn._sfSimulated = false
|
||||
btn._sfSimLabel = nil
|
||||
btn._sfSimDesc = nil
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
|
||||
local apps = GetPlayerBuffApplications(buffIndex)
|
||||
if apps and apps > 1 then
|
||||
@@ -495,15 +544,15 @@ function MB:UpdateDebuffs()
|
||||
|
||||
btn:Show()
|
||||
else
|
||||
ClearSlotState(btn)
|
||||
btn:Hide()
|
||||
btn.buffIndex = -1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for j = slotIdx + 1, MAX_DEBUFFS do
|
||||
ClearSlotState(self.debuffSlots[j])
|
||||
self.debuffSlots[j]:Hide()
|
||||
self.debuffSlots[j].buffIndex = -1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -556,6 +605,7 @@ function MB:SimulateBuffs()
|
||||
local btn = self.buffSlots[i]
|
||||
local sim = SIM_BUFFS[i]
|
||||
if sim then
|
||||
SetSlotTooltipKey(btn, "sim-buff:" .. tostring(i))
|
||||
btn.icon:SetTexture(sim.tex)
|
||||
btn.buffIndex = -1
|
||||
btn._sfSimulated = true
|
||||
@@ -578,6 +628,7 @@ function MB:SimulateBuffs()
|
||||
btn:SetBackdropBorderColor(0.25, 0.25, 0.30, 1)
|
||||
btn:Show()
|
||||
else
|
||||
ClearSlotState(btn)
|
||||
btn:Hide()
|
||||
end
|
||||
end
|
||||
@@ -586,11 +637,14 @@ function MB:SimulateBuffs()
|
||||
local btn = self.debuffSlots[i]
|
||||
local sim = SIM_DEBUFFS[i]
|
||||
if sim then
|
||||
SetSlotTooltipKey(btn, "sim-debuff:" .. tostring(i))
|
||||
btn.icon:SetTexture(sim.tex)
|
||||
btn.buffIndex = -1
|
||||
btn._sfSimulated = true
|
||||
btn._sfSimLabel = sim.label
|
||||
btn._sfSimDesc = sim.desc
|
||||
btn._isWeaponEnchant = false
|
||||
btn._weaponSlotID = nil
|
||||
|
||||
btn.timer:SetText(sim.time)
|
||||
ApplyTimerColor(btn, sim.time)
|
||||
@@ -601,6 +655,7 @@ function MB:SimulateBuffs()
|
||||
btn:SetBackdropBorderColor(c.r, c.g, c.b, 1)
|
||||
btn:Show()
|
||||
else
|
||||
ClearSlotState(btn)
|
||||
btn:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user