Skip to content

Commit

Permalink
- added first bunch of necessary changes for latest expansion TWW
Browse files Browse the repository at this point in the history
  • Loading branch information
frozn committed Jul 25, 2024
1 parent 716a341 commit 8b31bef
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 49 deletions.
100 changes: 100 additions & 0 deletions TipTac/libs/LibFroznFunctions-1.0/LibFroznFunctions-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,106 @@ function LibFroznFunctions:IsMountCollected(mountID)
end
end

-- get mouse focus
--
-- @return frame that currently has mouse focus
function LibFroznFunctions:GetMouseFocus()
-- since tww 11.0.0
if (GetMouseFoci) then
local frames = GetMouseFoci();

return frames and frames[1];
end

-- before tww 11.0.0
return GetMouseFocus();
end

-- get spell info
--
-- @param spell spell id or name
-- @return name, rank, icon, castTime, minRange, maxRange, spellID, originalIcon
function LibFroznFunctions:GetSpellInfo(spell)
-- since tww 11.0.0
if (C_Spell) and (C_Spell.GetSpellInfo) then
if (not spell) then
return nil;
end

local spellInfo = C_Spell.GetSpellInfo(spell);

if (not spellInfo) then
return nil;
end

return spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID, spellInfo.originalIconID;
end

-- before tww 11.0.0
return GetSpellInfo(spell);
end

-- get spell subtext
--
-- @param spell spell id or name
-- @return name, rank, icon, castTime, minRange, maxRange, spellID, originalIcon
function LibFroznFunctions:GetSpellSubtext(spell)
-- since tww 11.0.0
if (C_Spell) and (C_Spell.GetSpellSubtext) then
if (not spell) then
return nil;
end

return C_Spell.GetSpellSubtext(spell);
end

-- before tww 11.0.0
return GetSpellSubtext(spell);
end

-- get spell link
--
-- @param spell spell id or name
-- @param glyphID optional. glyph id.
-- @return spellLink
function LibFroznFunctions:GetSpellLink(spell, glyphID)
-- since tww 11.0.0
if (C_Spell) and (C_Spell.GetSpellLink) then
if (not spell) then
return nil;
end

return C_Spell.GetSpellLink(spell, glyphID);
end

-- before tww 11.0.0
if (not LibFroznFunctions.hasWoWFlavor.realGetSpellLinkAvailable) then
local name, _, icon, castTime, minRange, maxRange, _spellID = self:GetSpellInfo(spell);

return format("|c%s|Hspell:%d:0|h[%s]|h|r", "FF71D5FF", spellID, name);
end

return GetSpellLink(spell);
end

-- get spell book item name
--
-- @param index spellbook slot index, ranging from 1 through the total number of spells across all tabs and pages.
-- @param bookType BOOKTYPE_SPELL or BOOKTYPE_PET depending on if you wish to query the player or pet spellbook.
-- @return spellName, spellSubName, spellID
function LibFroznFunctions:GetSpellBookItemName(index, bookType)
-- since tww 11.0.0
if (C_SpellBook) and (C_SpellBook.GetSpellBookItemName) then
local BOOKTYPE_SPELL = "spell";
local spellBank = (bookType == BOOKTYPE_SPELL) and Enum.SpellBookSpellBank.Player or Enum.SpellBookSpellBank.Pet;

return C_SpellBook.GetSpellBookItemName(index, spellBank);
end

-- before tww 11.0.0
return GetSpellBookItemName(index, bookType);
end

----------------------------------------------------------------------------------------------------
-- Helper Functions --
----------------------------------------------------------------------------------------------------
Expand Down
5 changes: 1 addition & 4 deletions TipTac/modules/ttAuras.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ function ttAuras:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig)
aura:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);
end

for _, aura in self.aurasPool:EnumerateInactive() do
aura:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);
end

-- setup active unit tip's auras
local tipsProcessed = {};

Expand Down Expand Up @@ -180,6 +176,7 @@ function ttAuras:DisplayUnitTipsAuras(tip, currentDisplayParams, auraType, start
local aura = self.aurasPool:Acquire();

aura:SetParent(tip);
aura:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

-- anchor aura frame
aura:ClearAllPoints();
Expand Down
7 changes: 1 addition & 6 deletions TipTac/modules/ttBars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ function ttBars:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig)
end
end

for _, barsPool in pairs(self.barPools) do
for _, bar in barsPool:EnumerateInactive() do
bar:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);
end
end

-- setup active tip's bars
local tipsProcessed = {};

Expand Down Expand Up @@ -227,6 +221,7 @@ function ttBars:DisplayUnitTipsBar(barsPool, frameParams, tip, unitRecord, offse
local bar = barsPool:Acquire();

bar:SetParent(tip);
bar:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

local newOffsetY = offsetY;

Expand Down
9 changes: 5 additions & 4 deletions TipTac/modules/ttIcons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ function ttIcons:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig)
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);
end

for _, icon in self.iconPool:EnumerateInactive() do
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);
end

-- setup active tip's icons
local tipsProcessed = {};

Expand Down Expand Up @@ -149,6 +145,7 @@ function ttIcons:DisplayTipsIcon(tip, currentDisplayParams, iconType, startingIc
icon = self.iconPool:Acquire();

icon:SetParent(tip);
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

-- set icon
icon.icon:SetTexture("Interface\\TargetingFrame\\UI-RaidTargetingIcons");
Expand All @@ -164,6 +161,7 @@ function ttIcons:DisplayTipsIcon(tip, currentDisplayParams, iconType, startingIc
icon = self.iconPool:Acquire();

icon:SetParent(tip);
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

-- set icon
icon.icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA");
Expand All @@ -188,6 +186,7 @@ function ttIcons:DisplayTipsIcon(tip, currentDisplayParams, iconType, startingIc
icon = self.iconPool:Acquire();

icon:SetParent(tip);
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

-- set icon
icon.icon:SetTexture("Interface\\TargetingFrame\\UI-PVP-" .. englishFaction);
Expand All @@ -204,6 +203,7 @@ function ttIcons:DisplayTipsIcon(tip, currentDisplayParams, iconType, startingIc
icon = self.iconPool:Acquire();

icon:SetParent(tip);
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

-- set icon
icon.icon:SetTexture("Interface\\CharacterFrame\\UI-StateIcon");
Expand All @@ -219,6 +219,7 @@ function ttIcons:DisplayTipsIcon(tip, currentDisplayParams, iconType, startingIc
icon = self.iconPool:Acquire();

icon:SetParent(tip);
icon:OnApplyConfig(TT_CacheForFrames, cfg, TT_ExtendedConfig);

-- set icon
local texCoord = CLASS_ICON_TCOORDS[unitRecord.classFile];
Expand Down
4 changes: 2 additions & 2 deletions TipTac/ttCore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2957,7 +2957,7 @@ function tt:GetAnchorPosition(tip)
end
end

local mouseFocus = GetMouseFocus();
local mouseFocus = LibFroznFunctions:GetMouseFocus();

if (isUnit == nil) then
isUnit = (UnitExists("mouseover")) and (not UnitIsUnit("mouseover", "player")) or (mouseFocus and mouseFocus.GetAttribute and mouseFocus:GetAttribute("unit")); -- GetAttribute("unit") here is bad, as that will find things like buff frames too.
Expand Down Expand Up @@ -3209,7 +3209,7 @@ function tt:SetUnitRecordFromTip(tip)
-- and it will return as "mouseover", but the "mouseover" unit id is still invalid at this point for those unitframes!
-- to overcome this problem, we look if the mouse is over a unitframe, and if that unitframe has a unit attribute set?
if (not unitID) then
local mouseFocus = GetMouseFocus();
local mouseFocus = LibFroznFunctions:GetMouseFocus();

unitID = mouseFocus and mouseFocus.GetAttribute and mouseFocus:GetAttribute("unit");
end
Expand Down
100 changes: 100 additions & 0 deletions TipTacItemRef/libs/LibFroznFunctions-1.0/LibFroznFunctions-1.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,106 @@ function LibFroznFunctions:IsMountCollected(mountID)
end
end

-- get mouse focus
--
-- @return frame that currently has mouse focus
function LibFroznFunctions:GetMouseFocus()
-- since tww 11.0.0
if (GetMouseFoci) then
local frames = GetMouseFoci();

return frames and frames[1];
end

-- before tww 11.0.0
return GetMouseFocus();
end

-- get spell info
--
-- @param spell spell id or name
-- @return name, rank, icon, castTime, minRange, maxRange, spellID, originalIcon
function LibFroznFunctions:GetSpellInfo(spell)
-- since tww 11.0.0
if (C_Spell) and (C_Spell.GetSpellInfo) then
if (not spell) then
return nil;
end

local spellInfo = C_Spell.GetSpellInfo(spell);

if (not spellInfo) then
return nil;
end

return spellInfo.name, nil, spellInfo.iconID, spellInfo.castTime, spellInfo.minRange, spellInfo.maxRange, spellInfo.spellID, spellInfo.originalIconID;
end

-- before tww 11.0.0
return GetSpellInfo(spell);
end

-- get spell subtext
--
-- @param spell spell id or name
-- @return name, rank, icon, castTime, minRange, maxRange, spellID, originalIcon
function LibFroznFunctions:GetSpellSubtext(spell)
-- since tww 11.0.0
if (C_Spell) and (C_Spell.GetSpellSubtext) then
if (not spell) then
return nil;
end

return C_Spell.GetSpellSubtext(spell);
end

-- before tww 11.0.0
return GetSpellSubtext(spell);
end

-- get spell link
--
-- @param spell spell id or name
-- @param glyphID optional. glyph id.
-- @return spellLink
function LibFroznFunctions:GetSpellLink(spell, glyphID)
-- since tww 11.0.0
if (C_Spell) and (C_Spell.GetSpellLink) then
if (not spell) then
return nil;
end

return C_Spell.GetSpellLink(spell, glyphID);
end

-- before tww 11.0.0
if (not LibFroznFunctions.hasWoWFlavor.realGetSpellLinkAvailable) then
local name, _, icon, castTime, minRange, maxRange, _spellID = self:GetSpellInfo(spell);

return format("|c%s|Hspell:%d:0|h[%s]|h|r", "FF71D5FF", spellID, name);
end

return GetSpellLink(spell);
end

-- get spell book item name
--
-- @param index spellbook slot index, ranging from 1 through the total number of spells across all tabs and pages.
-- @param bookType BOOKTYPE_SPELL or BOOKTYPE_PET depending on if you wish to query the player or pet spellbook.
-- @return spellName, spellSubName, spellID
function LibFroznFunctions:GetSpellBookItemName(index, bookType)
-- since tww 11.0.0
if (C_SpellBook) and (C_SpellBook.GetSpellBookItemName) then
local BOOKTYPE_SPELL = "spell";
local spellBank = (bookType == BOOKTYPE_SPELL) and Enum.SpellBookSpellBank.Player or Enum.SpellBookSpellBank.Pet;

return C_SpellBook.GetSpellBookItemName(index, spellBank);
end

-- before tww 11.0.0
return GetSpellBookItemName(index, bookType);
end

----------------------------------------------------------------------------------------------------
-- Helper Functions --
----------------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 8b31bef

Please sign in to comment.