add mounted load condition, add more wow api for load and organize it better

This commit is contained in:
NoM0Re
2025-03-03 13:55:49 +01:00
parent 049dae9b04
commit 57b67eca07
3 changed files with 52 additions and 32 deletions
+17 -13
View File
@@ -1184,6 +1184,7 @@ function HandleEvent(frame, event, arg1, arg2, ...)
if (event == "PLAYER_ENTERING_WORLD") then if (event == "PLAYER_ENTERING_WORLD") then
timer:ScheduleTimer(function() timer:ScheduleTimer(function()
Private.CreateTalentCache() Private.CreateTalentCache()
WeakAuras.WatchForMounts()
HandleEvent(frame, "WA_DELAYED_PLAYER_ENTERING_WORLD"); HandleEvent(frame, "WA_DELAYED_PLAYER_ENTERING_WORLD");
Private.ScanForLoads(nil, "WA_DELAYED_PLAYER_ENTERING_WORLD") Private.ScanForLoads(nil, "WA_DELAYED_PLAYER_ENTERING_WORLD")
Private.StartProfileSystem("generictrigger WA_DELAYED_PLAYER_ENTERING_WORLD"); Private.StartProfileSystem("generictrigger WA_DELAYED_PLAYER_ENTERING_WORLD");
@@ -3542,27 +3543,30 @@ do
local isMounted = IsMounted(); local isMounted = IsMounted();
local function checkForMounted(self, elaps) local function checkForMounted(self, elaps)
Private.StartProfileSystem("generictrigger mounted"); Private.StartProfileSystem("generictrigger mounted")
elapsed = elapsed + elaps elapsed = elapsed + elaps
if(isMounted ~= IsMounted()) then if(isMounted ~= IsMounted()) then
isMounted = IsMounted(); isMounted = IsMounted()
Private.ScanEvents("MOUNTED_UPDATE"); Private.ScanForLoads(nil, "MOUNTED_UPDATE")
mountedFrame:SetScript("OnUpdate", nil); Private.ScanEvents("MOUNTED_UPDATE")
mountedFrame:SetScript("OnUpdate", nil)
end end
if(elapsed > delay) then if(elapsed > delay) then
mountedFrame:SetScript("OnUpdate", nil); mountedFrame:SetScript("OnUpdate", nil)
end end
Private.StopProfileSystem("generictrigger mounted"); Private.StopProfileSystem("generictrigger mounted")
end end
function WeakAuras.WatchForMounts() function WeakAuras.WatchForMounts()
if not(mountedFrame) then if not (mountedFrame) then
mountedFrame = CreateFrame("Frame"); mountedFrame = CreateFrame("Frame")
Private.frames["Mount Use Handler"] = mountedFrame; Private.frames["Mount Use Handler"] = mountedFrame
mountedFrame:RegisterEvent("COMPANION_UPDATE"); mountedFrame:RegisterEvent("COMPANION_UPDATE")
mountedFrame:SetScript("OnEvent", function() mountedFrame:SetScript("OnEvent", function(_, _, arg)
elapsed = 0; if arg == "MOUNT" then
mountedFrame:SetScript("OnUpdate", checkForMounted); elapsed = 0
mountedFrame:SetScript("OnUpdate", checkForMounted)
end
end) end)
end end
end end
+9 -3
View File
@@ -972,6 +972,15 @@ Private.load_prototype = {
optional = true, optional = true,
events = {"VEHICLE_UPDATE", "UNIT_ENTERED_VEHICLE", "UNIT_EXITED_VEHICLE"} events = {"VEHICLE_UPDATE", "UNIT_ENTERED_VEHICLE", "UNIT_EXITED_VEHICLE"}
}, },
{
name = "mounted",
display = L["Mounted"],
type = "tristate",
init = "arg",
width = WeakAuras.normalWidth,
optional = true,
events = {"MOUNTED_UPDATE"}
},
{ {
name ="playerTitle", name ="playerTitle",
display = L["Player"], display = L["Player"],
@@ -7429,9 +7438,6 @@ Private.event_prototypes = {
if (trigger.use_ismoving ~= nil) then if (trigger.use_ismoving ~= nil) then
WeakAuras.WatchPlayerMoveSpeed(); WeakAuras.WatchPlayerMoveSpeed();
end end
if (trigger.use_mounted ~= nil) then
WeakAuras.WatchForMounts();
end
if (trigger.use_HasPet ~= nil) then if (trigger.use_HasPet ~= nil) then
AddWatchedUnits("pet") AddWatchedUnits("pet")
end end
+26 -16
View File
@@ -6,20 +6,29 @@ local internalVersion = 83
local insert = table.insert local insert = table.insert
-- WoW APIs -- WoW APIs
local IsAddOnLoaded, InCombatLockdown = IsAddOnLoaded, InCombatLockdown local IsAddOnLoaded, LoadAddOn
local LoadAddOn, UnitName, GetRealmName, UnitFactionGroup, IsInRaid = IsAddOnLoaded, LoadAddOn
= LoadAddOn, UnitName, GetRealmName, UnitFactionGroup, IsInRaid local UnitName, GetRealmName, UnitRace, UnitFactionGroup, UnitClass
local UnitClass, UnitExists, UnitGUID, UnitAffectingCombat, GetInstanceInfo, IsInInstance = UnitName, GetRealmName, UnitRace, UnitFactionGroup, UnitClass
= UnitClass, UnitExists, UnitGUID, UnitAffectingCombat, GetInstanceInfo, IsInInstance local IsInRaid, UnitIsPartyLeader, UnitIsRaidOfficer, GetRaidRosterInfo, UnitInRaid, UnitInParty
local UnitIsUnit, GetRaidRosterInfo, UnitInVehicle, UnitHasVehicleUI, GetSpellInfo = IsInRaid, UnitIsPartyLeader, UnitIsRaidOfficer, GetRaidRosterInfo, UnitInRaid, UnitInParty
= UnitIsUnit, GetRaidRosterInfo, UnitInVehicle, UnitHasVehicleUI, GetSpellInfo local InCombatLockdown, UnitAffectingCombat, GetInstanceInfo, IsInInstance
local SendChatMessage, UnitInBattleground, UnitInRaid, UnitInParty, GetTime = InCombatLockdown, UnitAffectingCombat, GetInstanceInfo, IsInInstance
= SendChatMessage, UnitInBattleground, UnitInRaid, UnitInParty, GetTime local GetCurrentMapAreaID, GetRealZoneText, GetSubZoneText
local CreateFrame, IsShiftKeyDown, GetScreenWidth, GetScreenHeight, GetCursorPosition, UpdateAddOnCPUUsage, GetFrameCPUUsage, debugprofilestop = GetCurrentMapAreaID, GetRealZoneText, GetSubZoneText
= CreateFrame, IsShiftKeyDown, GetScreenWidth, GetScreenHeight, GetCursorPosition, UpdateAddOnCPUUsage, GetFrameCPUUsage, debugprofilestop local UnitIsPVPFreeForAll, UnitIsPVP, UnitOnTaxi, IsMounted
local debugstack = debugstack = UnitIsPVPFreeForAll, UnitIsPVP, UnitOnTaxi, IsMounted
local GetNumTalentTabs, GetNumTalents = GetNumTalentTabs, GetNumTalents local UnitInVehicle, UnitHasVehicleUI, UnitIsUnit, UnitIsDeadOrGhost
local MAX_NUM_TALENTS = MAX_NUM_TALENTS or 40 = UnitInVehicle, UnitHasVehicleUI, UnitIsUnit, UnitIsDeadOrGhost
local SendChatMessage, UnitInBattleground
= SendChatMessage, UnitInBattleground
local GetTime, UpdateAddOnCPUUsage, GetFrameCPUUsage, debugprofilestop
= GetTime, UpdateAddOnCPUUsage, GetFrameCPUUsage, debugprofilestop
local GetNumTalentTabs, GetNumTalents, MAX_NUM_TALENTS
= GetNumTalentTabs, GetNumTalents, MAX_NUM_TALENTS or 40
local CreateFrame, IsShiftKeyDown, GetScreenWidth, GetScreenHeight, GetCursorPosition
= CreateFrame, IsShiftKeyDown, GetScreenWidth, GetScreenHeight, GetCursorPosition
local debugstack, GetSpellInfo = debugstack, GetSpellInfo
local ADDON_NAME = "WeakAuras" local ADDON_NAME = "WeakAuras"
local WeakAuras = WeakAuras local WeakAuras = WeakAuras
@@ -1422,6 +1431,7 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
local pvp = UnitIsPVPFreeForAll("player") or UnitIsPVP("player") local pvp = UnitIsPVPFreeForAll("player") or UnitIsPVP("player")
local vehicle = UnitInVehicle("player") or UnitOnTaxi("player") or false local vehicle = UnitInVehicle("player") or UnitOnTaxi("player") or false
local vehicleUi = UnitHasVehicleUI("player") or false local vehicleUi = UnitHasVehicleUI("player") or false
local mounted = IsMounted() or false
local raidMemberType = 0 local raidMemberType = 0
@@ -1447,8 +1457,8 @@ local function scanForLoadsImpl(toCheck, event, arg1, ...)
if (data and not data.controlledChildren) then if (data and not data.controlledChildren) then
local loadFunc = loadFuncs[id]; local loadFunc = loadFuncs[id];
local loadOpt = loadFuncsForOptions[id]; local loadOpt = loadFuncsForOptions[id];
shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, player, realm, class, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty); shouldBeLoaded = loadFunc and loadFunc("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, mounted, player, realm, class, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty);
couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, player, realm, class, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty); couldBeLoaded = loadOpt and loadOpt("ScanForLoads_Auras", inCombat, alive, pvp, vehicle, vehicleUi, mounted, player, realm, class, race, faction, playerLevel, role, role, raidRole, group, groupSize, raidMemberType, zone, zoneId, subzone, size, difficulty);
if(shouldBeLoaded and not loaded[id]) then if(shouldBeLoaded and not loaded[id]) then
changed = changed + 1; changed = changed + 1;