Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mods for dungeon affixes #1240

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
2c211b3
enable zones for instanceId tables
ntowle Apr 14, 2022
e809c91
support string zoneIds
ntowle Apr 14, 2022
2cd81ec
don't need hardcoded check
ntowle Apr 14, 2022
cdbb749
Merge branch 'BigWigsMods:master' into affixes
ntowle Apr 26, 2022
1f23154
Merge branch 'BigWigsMods:master' into affixes
ntowle May 2, 2022
288fe44
Merge branch 'master' into affixes2
ntowle Jun 1, 2022
eb67214
provide NewAffix function
ntowle Jul 10, 2022
0c1f2ff
split NewAffix into NewDungeonAffix and NewModifiedInstance
ntowle Jul 17, 2022
95b1f39
localization support
ntowle Jul 17, 2022
7d4e152
Merge branch 'BigWigsMods:master' into affixes2
ntowle Jul 17, 2022
9518f21
enable mod on affix detected
ntowle Jul 18, 2022
6d90381
refactoring
ntowle Jul 18, 2022
636254c
localization
ntowle Jul 18, 2022
0128978
globals
ntowle Jul 18, 2022
a32420b
localization
ntowle Jul 18, 2022
3d05f3d
refactor
ntowle Jul 18, 2022
d9155f8
expose new globals for core
ntowle Jul 18, 2022
252a98e
support NewAffix and NewModifiedInstance in gen_option_values
ntowle Jul 18, 2022
e2761c8
add stub for Fated
ntowle Jul 18, 2022
73d8aa8
modified instance detection
ntowle Jul 18, 2022
fca6d32
remove unneeded function
ntowle Jul 18, 2022
9057b66
globals
ntowle Jul 18, 2022
0ed652a
formatting, naming
ntowle Jul 18, 2022
7eab8a7
temporarily disable fated module
ntowle Jul 18, 2022
79a358d
extraMenu for raid affixes
ntowle Jul 18, 2022
fe2829b
luacheck
ntowle Jul 18, 2022
88652ef
fallback for non-localized menu names
ntowle Jul 19, 2022
066156b
split LittleWigs_Affixes to be its own addon
ntowle Jul 30, 2022
34bb0ef
Merge branch 'master' into affixes2
ntowle Aug 3, 2022
ccffb12
remove modified affix handling + fated module
ntowle Aug 3, 2022
3235c1c
Merge branch 'BigWigsMods:master' into affixes2
ntowle Aug 5, 2022
94115c0
trim string extra menus
ntowle Sep 11, 2022
ccfe381
Merge remote-tracking branch 'upstream/master' into affixes2
ntowle Sep 19, 2022
a5cfb5d
Merge remote-tracking branch 'upstream/master' into affixes2
ntowle Sep 19, 2022
33f6274
fix littlewigs enable checks
ntowle Sep 19, 2022
8410d59
Merge remote-tracking branch 'upstream/master' into affixes2
ntowle Oct 12, 2022
0b6a0ef
Merge branch 'master' into affixes2
ntowle Oct 25, 2022
860745a
Merge branch 'master' into affixes2
ntowle Oct 26, 2022
4975020
Merge remote-tracking branch 'upstream/master' into affixes2
ntowle Nov 5, 2022
4edd48f
Merge remote-tracking branch 'upstream/master' into affixes2
ntowle Nov 5, 2022
663e1b8
Merge remote-tracking branch 'upstream/master' into affixes2
ntowle Nov 14, 2022
6c8eefd
Merge branch 'master' into affixes2
ntowle Nov 15, 2022
609d018
Merge branch 'master' into affixes2
ntowle Nov 28, 2022
6f0a601
Merge branch 'master' into affixes2
ntowle Dec 4, 2022
090bfe0
Merge branch 'master' into affixes2
ntowle Dec 5, 2022
b145fe7
Merge branch 'master' into affixes2
ntowle Dec 12, 2022
bba9fdd
Merge branch 'master' into affixes2
ntowle Dec 14, 2022
3558e7e
Merge branch 'master' into affixes2
ntowle Dec 15, 2022
8f87db5
Merge branch 'master' into affixes2
ntowle Dec 17, 2022
a41f097
Merge branch 'master' into affixes2
ntowle Dec 17, 2022
69500b5
Merge branch 'master' into affixes2
ntowle Dec 17, 2022
3c8ea24
Merge branch 'master' into affixes2
ntowle Dec 19, 2022
02328c2
Merge branch 'master' into affixes2
ntowle Dec 29, 2022
003ade6
Merge branch 'master' into affixes2
ntowle Jan 3, 2023
304d96d
Merge branch 'master' into affixes2
ntowle Jan 3, 2023
ebb64a4
Merge branch 'master' into affixes2
ntowle Aug 18, 2024
d764fe0
cleanup
ntowle Aug 18, 2024
4ca2eb9
Cleanups
ntowle Aug 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ globals = {
"BigWigsOptions",
"BigWigsStatsDB",
"BigWigsKrosusFirstBeamWasLeft", -- Legion/Nighthold/Krosus.lua
"C_ChallengeMode",
"C_EncounterJournal",
"C_GossipInfo",
"C_Minimap", -- Legion/TombOfSargeras/Kiljaeden.lua
Expand Down
136 changes: 101 additions & 35 deletions Core/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ local coreEnabled = false
local GetBestMapForUnit = loader.GetBestMapForUnit
local SendAddonMessage = loader.SendAddonMessage
local GetInstanceInfo = loader.GetInstanceInfo
local GetAffixInfo = loader.GetAffixInfo
local IsChallengeModeActive = loader.IsChallengeModeActive
local GetActiveKeystoneInfo = loader.GetActiveKeystoneInfo
local UnitName = loader.UnitName
local UnitGUID = loader.UnitGUID
local UnitIsDeadOrGhost = loader.UnitIsDeadOrGhost
Expand Down Expand Up @@ -121,7 +124,7 @@ else
end

-------------------------------------------------------------------------------
-- Target monitoring
-- Module Enablement
--

local enablezones, enablemobs = {}, {}
Expand All @@ -134,25 +137,67 @@ local function enableBossModule(module, sync)
end
end

local function shouldReallyEnable(unit, moduleName, mobId, sync)
local function shouldReallyEnable(unit, moduleName, seenId, sync)
local module = bosses[moduleName]
if not module or module:IsEnabled() then return end
if (not module.VerifyEnable or module:VerifyEnable(unit, mobId, GetBestMapForUnit("player"))) then
if (not module.VerifyEnable or module:VerifyEnable(unit, seenId, GetBestMapForUnit("player"))) then
enableBossModule(module, sync)
end
end

local function targetSeen(unit, targetModule, mobId, sync)
local function targetSeen(unit, targetModule, seenId, sync)
if type(targetModule) == "string" then
shouldReallyEnable(unit, targetModule, mobId, sync)
shouldReallyEnable(unit, targetModule, seenId, sync)
else
for i = 1, #targetModule do
local module = targetModule[i]
shouldReallyEnable(unit, module, mobId, sync)
shouldReallyEnable(unit, module, seenId, sync)
end
end
end

-------------------------------------------------------------------------------
-- Dungeon affix detection
--

local enableAffixes = {}
local function affixCheck(sync)
local affixes = IsChallengeModeActive() and select(2, GetActiveKeystoneInfo())
if affixes then
for i = 1, #affixes do
local affixId = affixes[i]
if affixId and enableAffixes[affixId] then
targetSeen(nil, enableAffixes[affixId], affixId, sync)
end
end
end
end

function core:RegisterEnableAffix(module, ...)
for i = 1, select("#", ...) do
local affixId = select(i, ...)
if type(affixId) ~= "number" or affixId < 1 then
core:Error(("Module %q tried to register the affixId %q, but it wasn't a valid number."):format(module.moduleName, tostring(affixId)))
else
local entryType = type(enableAffixes[affixId])
if entryType == "nil" then
enableAffixes[affixId] = module.moduleName
elseif entryType == "table" then
enableAffixes[affixId][#enableAffixes[affixId] + 1] = module.moduleName
elseif entryType == "string" then -- Converting from 1 module registered to this affixId, to multiple modules
local previousModuleEntry = enableAffixes[affixId]
enableAffixes[affixId] = { previousModuleEntry, module.moduleName }
else
core:Error(("Unknown type in a enable trigger table at index %d for %q."):format(i, module.moduleName))
end
end
end
end

-------------------------------------------------------------------------------
-- Target monitoring
--

local function targetCheck(unit, sync)
local name = UnitName(unit)
if not name or UnitIsCorpse(unit) or UnitIsDead(unit) or UnitPlayerControlled(unit) then return end
Expand All @@ -168,8 +213,12 @@ local function targetCheck(unit, sync)
end
end

local function updateMouseover() targetCheck("mouseover", true) end
local function unitTargetChanged(_, target)
local function updateMouseover()
targetCheck("mouseover", true)
affixCheck(true)
end

local function unitTargetChanged(event, target)
targetCheck(target .. "target")
end

Expand Down Expand Up @@ -393,6 +442,24 @@ end
do
local errorAlreadyRegistered = "%q already exists as a module in BigWigs, but something is trying to register it again."
local errorJournalIdInvalid = "%q is using the invalid journal id of %q."

local function createModule(name, moduleName, metatable)
return setmetatable({
name = name,
moduleName = moduleName,
enableMobs = {},

-- Embed callback handler
RegisterMessage = loader.RegisterMessage,
UnregisterMessage = loader.UnregisterMessage,
SendMessage = loader.SendMessage,

-- Embed event handler
RegisterEvent = core.RegisterEvent,
UnregisterEvent = core.UnregisterEvent,
}, metatable)
end

local bossMeta = { __index = bossPrototype, __metatable = false }
local EJ_GetEncounterInfo = loader.isCata and function(key)
return EJ_GetEncounterInfo(key) or BigWigsAPI:GetLocale("BigWigs: Encounters")[key]
Expand All @@ -403,20 +470,7 @@ do
if bosses[moduleName] then
core:Print(errorAlreadyRegistered:format(moduleName))
else
local m = setmetatable({
name = "BigWigs_Bosses_"..moduleName, -- XXX AceAddon/AceDB backwards compat
moduleName = moduleName,
enableMobs = {},

-- Embed callback handler
RegisterMessage = loader.RegisterMessage,
UnregisterMessage = loader.UnregisterMessage,
SendMessage = loader.SendMessage,

-- Embed event handler
RegisterEvent = core.RegisterEvent,
UnregisterEvent = core.UnregisterEvent,
}, bossMeta)
local m = createModule("BigWigs_Bosses_"..moduleName, moduleName, bossMeta) -- XXX AceAddon/AceDB backwards compat
bosses[moduleName] = m
initModules[#initModules+1] = m

Expand All @@ -442,24 +496,36 @@ do
end
end

function core:NewDungeonAffix(moduleName, affixId, zoneIds)
if bosses[moduleName] then
core:Print(errorAlreadyRegistered:format(moduleName))
else
local m = createModule("BigWigs_Bosses_"..moduleName, moduleName, bossMeta) -- XXX AceAddon/AceDB backwards compat
bosses[moduleName] = m
initModules[#initModules+1] = m
if affixId then
m.displayName = select(1, GetAffixInfo(affixId))
m.affixId = affixId
core:RegisterEnableAffix(m, affixId)
else
m.displayName = moduleName
end
m.otherMenu = "dungeonAffixes"

if type(zoneIds) == 'table' or zoneIds > 0 then
m.instanceId = zoneIds
end

return m, CL
end
end

local pluginMeta = { __index = pluginPrototype, __metatable = false }
function core:NewPlugin(moduleName)
if plugins[moduleName] then
core:Print(errorAlreadyRegistered:format(moduleName))
else
local m = setmetatable({
name = "BigWigs_Plugins_"..moduleName, -- XXX AceAddon/AceDB backwards compat
moduleName = moduleName,

-- Embed callback handler
RegisterMessage = loader.RegisterMessage,
UnregisterMessage = loader.UnregisterMessage,
SendMessage = loader.SendMessage,

-- Embed event handler
RegisterEvent = core.RegisterEvent,
UnregisterEvent = core.UnregisterEvent,
}, pluginMeta)
local m = createModule("BigWigs_Plugins_"..moduleName, moduleName, pluginMeta) -- XXX AceAddon/AceDB backwards compat
plugins[moduleName] = m
initModules[#initModules+1] = m

Expand Down
16 changes: 14 additions & 2 deletions Loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ local tooltipFunctions = {}
local next, tonumber, type, strsplit, strsub = next, tonumber, type, strsplit, string.sub
local SendAddonMessage, RegisterAddonMessagePrefix, CTimerAfter, CTimerNewTicker = C_ChatInfo.SendAddonMessage, C_ChatInfo.RegisterAddonMessagePrefix, C_Timer.After, C_Timer.NewTicker
local GetInstanceInfo, GetBestMapForUnit, GetMapInfo = GetInstanceInfo, C_Map.GetBestMapForUnit, C_Map.GetMapInfo
local GetAffixInfo, IsChallengeModeActive, GetActiveKeystoneInfo = C_ChallengeMode.GetAffixInfo, C_ChallengeMode.IsChallengeModeActive, C_ChallengeMode.GetActiveKeystoneInfo
local Ambiguate, UnitName, UnitGUID = Ambiguate, UnitName, UnitGUID
local debugstack, print = debugstack, print
local myLocale = GetLocale()
Expand All @@ -105,6 +106,9 @@ public.DoCountdown = C_PartyInfo.DoCountdown
public.GetBestMapForUnit = GetBestMapForUnit
public.GetInstanceInfo = GetInstanceInfo
public.GetMapInfo = GetMapInfo
public.GetAffixInfo = GetAffixInfo
public.IsChallengeModeActive = IsChallengeModeActive
public.GetActiveKeystoneInfo = GetActiveKeystoneInfo
public.GetPlayerAuraBySpellID = C_UnitAuras and C_UnitAuras.GetPlayerAuraBySpellID
public.GetSpellCooldown = C_Spell and C_Spell.GetSpellCooldown or GetSpellCooldown
public.GetSpellDescription = C_Spell and C_Spell.GetSpellDescription or GetSpellDescription
Expand Down Expand Up @@ -186,6 +190,7 @@ do
local lw_tww = "LittleWigs_TheWarWithin"
local lw_delves = "LittleWigs_Delves"
local lw_cs = "LittleWigs_CurrentSeason"
local lw_affixes = "LittleWigs_Affixes"
local cap = "Capping"

if public.isVanilla then
Expand Down Expand Up @@ -505,6 +510,8 @@ do
[2688] = lw_delves, -- The Spiral Weave
[2689] = lw_delves, -- Tak-Rethan Abyss
[2690] = lw_delves, -- The Underkeep
--[[ LittleWigs: Affixes ]]--
["dungeonAffixes"] = lw_affixes, -- Dungeon Affixes

--[[ Capping ]]--
[30] = cap, -- Alterac Valley
Expand Down Expand Up @@ -899,8 +906,8 @@ do

local function addExtraMenus(addon, ...)
for i = 1, select("#", ...) do
local rawMenu = select(i, ...)
local id = tonumber(rawMenu:trim())
local rawMenu = select(i, ...):trim()
local id = tonumber(rawMenu)
if id then
local name
if id < 0 then
Expand All @@ -919,6 +926,11 @@ do

if not menus[id] then menus[id] = true end
end
elseif type(rawMenu) == "string" then
if not loadOnZone[rawMenu] then loadOnZone[rawMenu] = {} end
loadOnZone[rawMenu][#loadOnZone[rawMenu] + 1] = addon

if not menus[rawMenu] then menus[rawMenu] = true end
else
local name = GetAddOnInfo(addon)
sysprint(("The extra menu ID %q from the addon %q was not parsable."):format(tostring(rawMenu), name))
Expand Down
3 changes: 3 additions & 0 deletions Locales/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.N10 = "Normal 10"
L.N25 = "Normal 25"
L.H10 = "Heroisch 10"
L.H25 = "Heroisch 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,6 @@ L.N10 = "Normal 10"
L.N25 = "Normal 25"
L.H10 = "Heroic 10"
L.H25 = "Heroic 25"

-- Non-instance specific modules
L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.mythic = "Mítico"
--L.N25 = "Normal 25"
--L.H10 = "Heroic 10"
--L.H25 = "Heroic 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/esMX.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.mythic = "Mítico"
--L.N25 = "Normal 25"
--L.H10 = "Heroic 10"
--L.H25 = "Heroic 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/frFR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.N10 = "10 joueurs"
L.N25 = "25 joueurs"
L.H10 = "Héroïque 10"
L.H25 = "Héroïque 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/itIT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.mythic = "Mitica"
--L.N25 = "Normal 25"
--L.H10 = "Heroic 10"
--L.H25 = "Heroic 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/koKR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.N10 = "일반 10"
L.N25 = "일반 25"
L.H10 = "영웅 10"
L.H25 = "영웅 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/ptBR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.mythic = "Mítico"
--L.N25 = "Normal 25"
--L.H10 = "Heroic 10"
--L.H25 = "Heroic 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/ruRU.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.N10 = "Нормал 10"
L.N25 = "Нормал 25"
L.H10 = "Героик 10"
L.H25 = "Героик 25"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.N10 = "10人普通"
L.N25 = "25人普通"
L.H10 = "10人英雄"
L.H25 = "25人英雄"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
3 changes: 3 additions & 0 deletions Locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ L.N10 = "10人普通"
L.N25 = "25人普通"
L.H10 = "10人英雄"
L.H25 = "25人英雄"

-- Non-instance specific modules
--L.dungeonAffixes = "Dungeon Affixes"
5 changes: 4 additions & 1 deletion Options/Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,10 @@ do
local zoneToId, alphabeticalZoneList = {}, {}
for k in next, loader:GetZoneMenus() do
local zoneName
if k < 0 then
if type(k) == "string" then
-- check if the zone is a localized string key
zoneName = L[k] or k
elseif k < 0 then
local tbl = GetMapInfo(-k)
if tbl then
zoneName = tbl.name
Expand Down
2 changes: 1 addition & 1 deletion gen_option_values.lua
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ local function parseLua(file)
f:close()

-- First, check to make sure this is actually a boss module file.
local module_name, module_args = data:match("\nlocal mod.*= BigWigs:NewBoss%(\"(.-)\",?%s*([^)]*)")
local module_name, module_args = data:match("\nlocal mod.*= BigWigs:New[A-Za-z]+%(\"(.-)\",?%s*([^)]*)")
if not module_name then
return
end
Expand Down