Skip to content

Commit

Permalink
V1.4.x (#54)
Browse files Browse the repository at this point in the history
* Closes #14: Support Mouseover (#47)

* Closes #40: Configure Loot Feed Strata (#52)

* Closes #12: Item Loot Filters (#49)
  • Loading branch information
Mctalian authored Aug 23, 2024
1 parent d2a3083 commit 0d72fb0
Show file tree
Hide file tree
Showing 10 changed files with 345 additions and 94 deletions.
44 changes: 44 additions & 0 deletions BlizzOverrides/BossBanner.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local RLF = G_RLF.RLF

local bossBannerAttempts = 0

function RLF:BossBannerHook()
if self:IsHooked(BossBanner, "OnEvent") then
return
end
if BossBanner then
self:RawHookScript(BossBanner, "OnEvent", "InterceptBossBannerAlert", true)
else
if bossBannerAttempts <= 30 then
bossBannerAttempts = bossBannerAttempts + 1
-- Keep checking until it's available
self:ScheduleTimer("BossBannerHook", 1)
else
self:Print(G_RLF.L["BossBannerAlertUnavailable"])
self:Print(G_RLF.L["Issues"])
end
end
end

function RLF:InterceptBossBannerAlert(s, event, ...)
if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.FULLY_DISABLE then
return
end

if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.DISABLE_LOOT and event == "ENCOUNTER_LOOT_RECEIVED" then
return
end

local _, _, _, _, playerName, _ = ...;
local myGuid = GetPlayerGuid()
local myName, _ = GetNameAndServerNameFromGUID(myGuid)
if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.DISABLE_MY_LOOT and event == "ENCOUNTER_LOOT_RECEIVED" and playerName == myName then
return
end

if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.DISABLE_GROUP_LOOT and event == "ENCOUNTER_LOOT_RECEIVED" and playerName ~= myName then
return
end
-- Call the original AddAlert function if not blocked
self.hooks[BossBanner].OnEvent(s, event, ...)
end
28 changes: 28 additions & 0 deletions BlizzOverrides/LootToasts.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local RLF = G_RLF.RLF

local lootAlertAttempts = 0
function RLF:LootToastHook()
if RLF:IsHooked(LootAlertSystem, "AddAlert") then
return
end
if LootAlertSystem and LootAlertSystem.AddAlert then
RLF:RawHook(LootAlertSystem, "AddAlert", "InterceptAddAlert", true)
else
if lootAlertAttempts <= 30 then
lootAlertAttempts = lootAlertAttempts + 1
-- Keep checking until it's available
RLF:ScheduleTimer("LootToastHook", 1)
else
RLF:Print(G_RLF.L["AddLootAlertUnavailable"])
RLF:Print(G_RLF.L["Issues"])
end
end
end

function RLF:InterceptAddAlert(frame, ...)
if G_RLF.db.global.disableBlizzLootToasts then
return
end
-- Call the original AddAlert function if not blocked
RLF.hooks[LootAlertSystem].AddAlert(frame, ...)
end
7 changes: 7 additions & 0 deletions BlizzOverrides/overrides.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
<Script file="LootToasts.lua"/>
<Script file="BossBanner.lua"/>
</Ui>
46 changes: 42 additions & 4 deletions Features/ItemLoot.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
local ItemLoot = {}

-- local equipLocToSlotID = {
-- ["INVTYPE_HEAD"] = INVSLOT_HEAD,
-- ["INVTYPE_NECK"] = INVSLOT_NECK,
-- ["INVTYPE_SHOULDER"] = INVSLOT_SHOULDER,
-- ["INVTYPE_CHEST"] = INVSLOT_CHEST,
-- ["INVTYPE_WAIST"] = INVSLOT_WAIST,
-- ["INVTYPE_LEGS"] = INVSLOT_LEGS,
-- ["INVTYPE_FEET"] = INVSLOT_FEET,
-- ["INVTYPE_WRIST"] = INVSLOT_WRIST,
-- ["INVTYPE_HAND"] = INVSLOT_HAND,
-- ["INVSLOT_FINGER1"] = INVSLOT_FINGER1,
-- ["INVSLOT_FINGER2"] = INVSLOT_FINGER2,
-- ["INVSLOT_TRINKET1"] = INVSLOT_TRINKET1,
-- ["INVSLOT_TRINKET2"] = INVSLOT_TRINKET2,
-- ["INVTYPE_BACK"] = INVSLOT_BACK,
-- ["INVTYPE_MAINHAND"] = INVSLOT_MAINHAND,
-- ["INVTYPE_OFFHAND"] = INVSLOT_OFFHAND,
-- ["INVTYPE_RANGED"] = INVSLOT_RANGED,
-- ["INVTYPE_WEAPON"] = INVSLOT_MAINHAND, -- Generally used for one-handed weapons
-- ["INVTYPE_2HWEAPON"] = INVSLOT_MAINHAND, -- Two-handed weapons
-- ["INVTYPE_RANGEDRIGHT"] = INVSLOT_RANGED, -- Ranged weapons
-- }

function ItemLoot:OnItemLooted(...)
if not G_RLF.db.global.itemLootFeed then
return
Expand All @@ -16,11 +39,26 @@ function ItemLoot:OnItemLooted(...)
if not me then
return
end
local itemID = msg:match("Hitem:(%d+)")
if itemID ~= nil then
local itemLink = msg:match("|c%x+|Hitem:.-|h%[.-%]|h|r")
if itemLink then
local amount = msg:match("r ?x(%d+)") or 1
local _, itemLink, _, _, _, _, _, _, _, itemTexture = C_Item.GetItemInfo(itemID)
G_RLF.LootDisplay:ShowLoot(itemID, itemLink, itemTexture, amount)
local _, _, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expansionID, setID, isCraftingReagent = C_Item.GetItemInfo(itemLink)
if not G_RLF.db.global.itemQualityFilter[itemQuality] then
return
end
-- if G_RLF.db.global.onlyBetterThanEquipped and itemEquipLoc then
-- local equippedLink = GetInventoryItemLink("player", equipLocToSlotID[itemEquipLoc])
-- if equippedLink then
-- local _, _, _, equippediLvl, _, _, equippedSubType = C_Item.GetItemInfo(equippedLink)
-- if equippediLvl > itemLevel then
-- return
-- elseif equippedSubType ~= itemSubType then
-- return
-- end
-- end

-- end
G_RLF.LootDisplay:ShowLoot(itemLink, itemLink, itemTexture, amount)
end
end

Expand Down
58 changes: 54 additions & 4 deletions LootDisplay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local updateRowPositions
local defaults = {
anchorPoint = "BOTTOMLEFT",
relativePoint = UIParent,
frameStrata = "MEDIUM",
xOffset = 720,
yOffset = 375,
feedWidth = 330,
Expand Down Expand Up @@ -52,6 +53,8 @@ function LootDisplay:Initialize()
frame:SetSize(config.feedWidth, getFrameHeight())
frame:SetPoint(config.anchorPoint, _G[config.relativePoint], config.xOffset, config.yOffset)

frame:SetFrameStrata(config.frameStrata) -- Set the frame strata here

frame:SetClipsChildren(true) -- Enable clipping of child elements

boundingBox = frame:CreateTexture(nil, "BACKGROUND")
Expand All @@ -76,6 +79,12 @@ function LootDisplay:UpdatePosition()
frame:SetPoint(config.anchorPoint, _G[config.relativePoint], config.xOffset, config.yOffset)
end

function LootDisplay:UpdateStrata()
if frame then
frame:SetFrameStrata(config.frameStrata)
end
end

function LootDisplay:UpdateRowStyles()
frame:SetSize(config.feedWidth, getFrameHeight())

Expand All @@ -100,6 +109,10 @@ function LootDisplay:ShowLoot(id, link, icon, amountLooted)
row.amount = row.amount + amountLooted
row.highlightAnimation:Stop()
row.highlightAnimation:Play()
if row.fadeOutAnimation:IsPlaying() then
row.fadeOutAnimation:Stop()
row.fadeOutAnimation:Play()
end
else
row = leaseRow(key)
if (row == nil) then
Expand All @@ -112,10 +125,34 @@ function LootDisplay:ShowLoot(id, link, icon, amountLooted)
row.amount = amountLooted
local extraWidth = getTextWidth(" x" .. row.amount)
row.link = truncateItemLink(link, extraWidth)
row.fadeOutAnimation:Stop()
row.fadeOutAnimation:Play()
end
row.amountText:SetText(row.link .. " x" .. row.amount)
row.fadeOutAnimation:Stop()
row.fadeOutAnimation:Play()
-- Add Tooltip
row.amountText:SetScript("OnEnter", function()
row.fadeOutAnimation:Stop()
row.highlightAnimation:Stop()
row.highlightBorder:SetAlpha(0)
if not G_RLF.db.global.tooltip then
return
end
if G_RLF.db.global.tooltipOnShift and not IsShiftKeyDown() then
return
end
local inCombat = UnitAffectingCombat("player")
if inCombat then
GameTooltip:Hide()
return
end
GameTooltip:SetOwner(row.amountText, "ANCHOR_RIGHT")
GameTooltip:SetHyperlink(row.link) -- Use the item's link to show the tooltip
GameTooltip:Show()
end)
row.amountText:SetScript("OnLeave", function()
row.fadeOutAnimation:Play()
GameTooltip:Hide()
end)
end

function LootDisplay:ShowMoney(copper)
Expand Down Expand Up @@ -494,8 +531,21 @@ leaseRow = function(key)
row.link = nil
row.experience = nil
row.rep = nil
if row.amountText and defaultColor then
row.amountText:SetTextColor(unpack(defaultColor))
if row.highlightBorder then
row.highlightBorder:SetAlpha(0)
end
if row.fadeOutAnimation then
row.fadeOutAnimation:Stop()
end
if row.highlightAnimation then
row.highlightAnimation:Stop()
end
if row.amountText then
row.amountText:SetScript("OnEnter", nil)
row.amountText:SetScript("OnLeave", nil)
if defaultColor then
row.amountText:SetTextColor(unpack(defaultColor))
end
end
end

Expand Down
91 changes: 12 additions & 79 deletions RPGLootFeed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ function RLF:OnInitialize()
end

function RLF:SlashCommand(msg, editBox)
LibStub("AceConfigDialog-3.0"):Open(addonName)
if msg == "test" then
G_RLF.TestMode:ToggleTestMode()
elseif msg == "clear" then
G_RLF.LootDisplay:HideLoot()
else
LibStub("AceConfigDialog-3.0"):Open(addonName)
end
end

function RLF:PLAYER_ENTERING_WORLD(event, isLogin, isReload)
self:InitializeOptions()
self:CheckForLootAlertSystem()
self:CheckForBossBanner()
if self.optionsFrame == nil then
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addonName, addonName)
end
self:LootToastHook()
self:BossBannerHook()
G_RLF.Rep:RefreshRepData()
G_RLF.Xp:Snapshot()
if isLogin and isReload == false then
Expand Down Expand Up @@ -60,78 +68,3 @@ end
function RLF:PLAYER_XP_UPDATE(eventName, unitTarget)
G_RLF.Xp:OnXpChange(unitTarget)
end

function RLF:InitializeOptions()
if self.optionsFrame == nil then
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(addonName, addonName)
end
end

local lootAlertAttempts = 0
function RLF:CheckForLootAlertSystem()
if self:IsHooked(LootAlertSystem, "AddAlert") then
return
end
if LootAlertSystem and LootAlertSystem.AddAlert then
self:RawHook(LootAlertSystem, "AddAlert", "InterceptAddAlert", true)
else
if lootAlertAttempts <= 30 then
lootAlertAttempts = lootAlertAttempts + 1
-- Keep checking until it's available
self:ScheduleTimer("CheckForLootAlertSystem", 1)
else
self:Print(G_RLF.L["AddLootAlertUnavailable"])
self:Print(G_RLF.L["Issues"])
end
end
end

local bossBannerAttempts = 0
function RLF:CheckForBossBanner()
if self:IsHooked(BossBanner, "OnEvent") then
return
end
if BossBanner then
self:RawHookScript(BossBanner, "OnEvent", "InterceptBossBannerAlert", true)
else
if bossBannerAttempts <= 30 then
bossBannerAttempts = bossBannerAttempts + 1
-- Keep checking until it's available
self:ScheduleTimer("CheckForBossBanner", 1)
else
self:Print(G_RLF.L["BossBannerAlertUnavailable"])
self:Print(G_RLF.L["Issues"])
end
end
end

function RLF:InterceptBossBannerAlert(s, event, ...)
if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.FULLY_DISABLE then
return
end

if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.DISABLE_LOOT and event == "ENCOUNTER_LOOT_RECEIVED" then
return
end

local _, _, _, _, playerName, _ = ...;
local myGuid = GetPlayerGuid()
local myName, _ = GetNameAndServerNameFromGUID(myGuid)
if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.DISABLE_MY_LOOT and event == "ENCOUNTER_LOOT_RECEIVED" and playerName == myName then
return
end

if G_RLF.db.global.bossBannerConfig == G_RLF.DisableBossBanner.DISABLE_GROUP_LOOT and event == "ENCOUNTER_LOOT_RECEIVED" and playerName ~= myName then
return
end
-- Call the original AddAlert function if not blocked
self.hooks[BossBanner].OnEvent(s, event, ...)
end

function RLF:InterceptAddAlert(frame, ...)
if G_RLF.db.global.disableBlizzLootToasts then
return
end
-- Call the original AddAlert function if not blocked
self.hooks[LootAlertSystem].AddAlert(frame, ...)
end
2 changes: 2 additions & 0 deletions RPGLootFeed.toc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ locale/locales.xml

Features/features.xml

BlizzOverrides/overrides.xml

RPGLootFeed.lua

config/config.xml
Expand Down
Loading

0 comments on commit 0d72fb0

Please sign in to comment.