From 73561eda4a8004e68a7d1282caeda2929cc12489 Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 30 Jul 2025 20:18:52 +0200 Subject: [PATCH] compat: make hooksecurefunc append by default --- compat/vanilla.lua | 10 +++++----- libs/libcast.lua | 8 ++++---- libs/libdebuff.lua | 6 +++--- libs/libpredict.lua | 6 +++--- libs/libtotem.lua | 6 +++--- modules/loot.lua | 2 +- modules/minimap.lua | 2 +- modules/socialmod.lua | 6 +++--- modules/thirdparty-vanilla.lua | 4 ++-- modules/turtle-wow.lua | 2 +- skins/blizzard/auction.lua | 10 +++++----- skins/blizzard/battlefield_minimap.lua | 2 +- skins/blizzard/character.lua | 2 +- skins/blizzard/inspect.lua | 2 +- skins/blizzard/mail.lua | 2 +- skins/blizzard/merchant.lua | 2 +- skins/blizzard/professions.lua | 2 +- skins/blizzard/questlog.lua | 4 ++-- skins/blizzard/readycheck.lua | 6 +++--- skins/blizzard/survey.lua | 2 +- skins/blizzard/trade.lua | 2 +- skins/blizzard/trainer.lua | 2 +- 22 files changed, 45 insertions(+), 45 deletions(-) diff --git a/compat/vanilla.lua b/compat/vanilla.lua index 2dad05aa..0ad1e2d2 100644 --- a/compat/vanilla.lua +++ b/compat/vanilla.lua @@ -34,9 +34,9 @@ ACTIONBAR_SECURE_TEMPLATE_BUTTON = nil UNITFRAME_SECURE_TEMPLATE = nil --[[ Vanilla API Extensions ]]-- -function hooksecurefunc(tbl, name, func, append) +function hooksecurefunc(tbl, name, func, prepend) if type(tbl) == "string" then - append, func, name, tbl = func, name, tbl, _G + prepend, func, name, tbl = func, name, tbl, _G end if not tbl or not tbl[name] then return end @@ -45,15 +45,15 @@ function hooksecurefunc(tbl, name, func, append) pfUI.hooks[tostring(func)]["old"] = tbl[name] pfUI.hooks[tostring(func)]["new"] = func - if append then + if prepend then pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) - pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) + pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) end else pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) - pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) + pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) end end diff --git a/libs/libcast.lua b/libs/libcast.lua index b6a0fe41..11cada49 100644 --- a/libs/libcast.lua +++ b/libs/libcast.lua @@ -395,17 +395,17 @@ hooksecurefunc("CastSpell", function(id, bookType) local cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime, _, _, cachedSpellId, cachedBookType = libspell.GetSpellInfo(id, bookType) CastCustom(cachedSpellId, cachedBookType, cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime) -end, true) +end) hooksecurefunc("CastSpellByName", function(spellCasted, target) local cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime, _, _, cachedSpellId, cachedBookType = libspell.GetSpellInfo(spellCasted) CastCustom(cachedSpellId, cachedBookType, cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime) -end, true) +end) hooksecurefunc("UseAction", function(slot, target, button) if GetActionText(slot) or not IsCurrentAction(slot) then return end - + scanner:SetAction(slot) local rawSpellName, rank = scanner:Line(1) if not rawSpellName then return end -- ignore if the spell is not found @@ -413,7 +413,7 @@ hooksecurefunc("UseAction", function(slot, target, button) local cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime, _, _, cachedSpellId, cachedBookType = libspell.GetSpellInfo(rawSpellName .. (rank and ("(" .. rank .. ")") or "")) CastCustom(cachedSpellId, cachedBookType, cachedRawSpellName, cachedRank, cachedTexture, cachedCastingTime) -end, true) +end) -- add libcast to pfUI API pfUI.api.libcast = libcast diff --git a/libs/libdebuff.lua b/libs/libdebuff.lua index 545b9fb7..27924622 100644 --- a/libs/libdebuff.lua +++ b/libs/libdebuff.lua @@ -236,13 +236,13 @@ hooksecurefunc("CastSpell", function(id, bookType) local rawEffect, rank = libspell.GetSpellInfo(id, bookType) local duration = libdebuff:GetDuration(rawEffect, rank) libdebuff:AddPending(UnitName("target"), UnitLevel("target"), rawEffect, duration, "player") -end, true) +end) hooksecurefunc("CastSpellByName", function(effect, target) local rawEffect, rank = libspell.GetSpellInfo(effect) local duration = libdebuff:GetDuration(rawEffect, rank) libdebuff:AddPending(UnitName("target"), UnitLevel("target"), rawEffect, duration, "player") -end, true) +end) hooksecurefunc("UseAction", function(slot, target, button) if GetActionText(slot) or not IsCurrentAction(slot) then return end @@ -250,7 +250,7 @@ hooksecurefunc("UseAction", function(slot, target, button) local rawEffect, rank = scanner:Line(1) local duration = libdebuff:GetDuration(rawEffect, rank) libdebuff:AddPending(UnitName("target"), UnitLevel("target"), rawEffect, duration, "player") -end, true) +end) function libdebuff:UnitDebuff(unit, id) local unitname = UnitName(unit) diff --git a/libs/libpredict.lua b/libs/libpredict.lua index 36332fd9..e98412cd 100644 --- a/libs/libpredict.lua +++ b/libs/libpredict.lua @@ -397,7 +397,7 @@ hooksecurefunc("CastSpell", function(id, bookType) spell_queue[1] = effect spell_queue[2] = effect.. ( rank or "" ) spell_queue[3] = UnitName("target") and UnitCanAssist("player", "target") and UnitName("target") or UnitName("player") -end, true) +end) hooksecurefunc("CastSpellByName", function(effect, target) if not libpredict.sender.enabled then return end @@ -414,7 +414,7 @@ hooksecurefunc("CastSpellByName", function(effect, target) spell_queue[1] = effect spell_queue[2] = effect.. ( rank or "" ) spell_queue[3] = target or mouseover or default -end, true) +end) local scanner = libtipscan:GetScanner("prediction") hooksecurefunc("UseAction", function(slot, target, selfcast) @@ -426,7 +426,7 @@ hooksecurefunc("UseAction", function(slot, target, selfcast) spell_queue[1] = effect spell_queue[2] = effect.. ( rank or "" ) spell_queue[3] = selfcast and UnitName("player") or UnitName("target") and UnitCanAssist("player", "target") and UnitName("target") or UnitName("player") -end, true) +end) libpredict.sender = CreateFrame("Frame", "pfPredictionSender", UIParent) libpredict.sender.enabled = true diff --git a/libs/libtotem.lua b/libs/libtotem.lua index 339c9932..4f0eb6e8 100644 --- a/libs/libtotem.lua +++ b/libs/libtotem.lua @@ -158,13 +158,13 @@ hooksecurefunc("CastSpell", function(id, bookType) local name, rank, icon = libspell.GetSpellInfo(id, bookType) if not name then return end if libtotem:CheckAddQueue(name, rank, icon) then return end -end, true) +end) hooksecurefunc("CastSpellByName", function(effect, target) local name, rank, icon = libspell.GetSpellInfo(effect) if not name then return end if libtotem:CheckAddQueue(name, rank, icon) then return end -end, true) +end) local scanner = libtipscan:GetScanner("prediction") hooksecurefunc("UseAction", function(slot, target, selfcast) @@ -174,4 +174,4 @@ hooksecurefunc("UseAction", function(slot, target, selfcast) local icon = GetActionTexture(slot) if not name then return end if libtotem:CheckAddQueue(name, rank, icon) then return end -end, true) +end) diff --git a/modules/loot.lua b/modules/loot.lua index ccc6e08b..a2284398 100644 --- a/modules/loot.lua +++ b/modules/loot.lua @@ -426,7 +426,7 @@ pfUI:RegisterModule("loot", "vanilla:tbc", function () end end end - end,true) + end) else pfUI.loot:RemoveMasterlootMenus() UIDropDownMenu_Initialize(GroupLootDropDown, GroupLootDropDown_Initialize, "MENU") diff --git a/modules/minimap.lua b/modules/minimap.lua index 9084d541..53bc3374 100644 --- a/modules/minimap.lua +++ b/modules/minimap.lua @@ -72,7 +72,7 @@ pfUI:RegisterModule("minimap", "vanilla:tbc", function () pfUI.minimap:SetAlpha(0) Minimap:Hide() end - end, true) + end) -- battleground icon MiniMapBattlefieldFrame:ClearAllPoints() diff --git a/modules/socialmod.lua b/modules/socialmod.lua index 31e64cc9..e18fea58 100644 --- a/modules/socialmod.lua +++ b/modules/socialmod.lua @@ -66,7 +66,7 @@ pfUI:RegisterModule("socialmod", "vanilla:tbc", function () end end end - end, true) + end) end do -- add colors to friend list @@ -119,7 +119,7 @@ pfUI:RegisterModule("socialmod", "vanilla:tbc", function () friendInfo:SetVertexColor(1,1,1,.4) end end - end, true) + end) end do -- add colors to who list @@ -193,6 +193,6 @@ pfUI:RegisterModule("socialmod", "vanilla:tbc", function () local color = GetDifficultyColor(level) _G["WhoFrameButton"..i.."Level"]:SetTextColor(color.r, color.g, color.b) end - end, true) + end) end end) diff --git a/modules/thirdparty-vanilla.lua b/modules/thirdparty-vanilla.lua index 8789fed5..482f3e60 100644 --- a/modules/thirdparty-vanilla.lua +++ b/modules/thirdparty-vanilla.lua @@ -536,7 +536,7 @@ pfUI:RegisterModule("thirdparty-vanilla", "vanilla", function() local colorstr = rgbhex(RAID_CLASS_COLORS[class].r, RAID_CLASS_COLORS[class].g, RAID_CLASS_COLORS[class].b, RAID_CLASS_COLORS[class].a) _G.WIM_ClassColors[wimclass] = gsub(colorstr, "^|cff", "") end - end, true) + end) -- convo menu CreateBackdrop(WIM_Icon_ToolTip, 0, nil, tonumber(C.tooltip.alpha)) @@ -560,7 +560,7 @@ pfUI:RegisterModule("thirdparty-vanilla", "vanilla", function() btn:SetText(btn_txt) end end - end, true) + end) if WIM_HistoryFrame then -- history frame CreateBackdrop(WIM_HistoryFrame, nil, nil, .8) diff --git a/modules/turtle-wow.lua b/modules/turtle-wow.lua index fdd46171..3d403cd4 100644 --- a/modules/turtle-wow.lua +++ b/modules/turtle-wow.lua @@ -304,7 +304,7 @@ pfUI:RegisterModule("turtle-wow", "vanilla", function () -- only run once initialized = true - end, true) + end) end) end diff --git a/skins/blizzard/auction.lua b/skins/blizzard/auction.lua index c392e6f2..0cd64855 100644 --- a/skins/blizzard/auction.lua +++ b/skins/blizzard/auction.lua @@ -15,7 +15,7 @@ pfUI:RegisterSkin("Auctionhouse", "vanilla:tbc", function () hooksecurefunc("AuctionFrame_OnShow", function() AuctionFrame:ClearAllPoints() AuctionFrame:SetPoint("TOPLEFT", 10, -104) - end, 1) + end) StripTextures(AuctionFrame, true) CreateBackdrop(AuctionFrame, nil, nil, .75) @@ -80,7 +80,7 @@ pfUI:RegisterSkin("Auctionhouse", "vanilla:tbc", function () for i = 1, NUM_BROWSE_TO_DISPLAY do HandleIcon(_G["BrowseButton"..i.."Item"], _G["BrowseButton"..i.."ItemIconTexture"]) end - end, 1) + end) SkinArrowButton(BrowsePrevPageButton, "left", 18) SkinArrowButton(BrowseNextPageButton, "right", 18) @@ -149,7 +149,7 @@ pfUI:RegisterSkin("Auctionhouse", "vanilla:tbc", function () for i = 1, NUM_BIDS_TO_DISPLAY do HandleIcon(_G["BidButton"..i.."Item"], _G["BidButton"..i.."ItemIconTexture"]) end - end, 1) + end) SkinMoneyInputFrame(BidBidPrice) BidBidPrice:ClearAllPoints() @@ -195,13 +195,13 @@ pfUI:RegisterSkin("Auctionhouse", "vanilla:tbc", function () for i = 1, NUM_AUCTIONS_TO_DISPLAY do HandleIcon(_G["AuctionsButton"..i.."Item"], _G["AuctionsButton"..i.."ItemIconTexture"]) end - end, 1) + end) SkinButton(AuctionsItemButton) hooksecurefunc("AuctionSellItemButton_OnEvent", function() if event ~= "NEW_AUCTION_UPDATE" then return end HandleIcon(AuctionsItemButton, AuctionsItemButton:GetNormalTexture()) - end, 1) + end) SkinMoneyInputFrame(StartPrice) SkinMoneyInputFrame(BuyoutPrice) diff --git a/skins/blizzard/battlefield_minimap.lua b/skins/blizzard/battlefield_minimap.lua index 44967b5a..e0a21d5e 100644 --- a/skins/blizzard/battlefield_minimap.lua +++ b/skins/blizzard/battlefield_minimap.lua @@ -22,6 +22,6 @@ pfUI:RegisterSkin("Battlefield Minimap", "vanilla:tbc", function () hooksecurefunc("BattlefieldMinimap_ShowOpacity", function() OpacityFrame:ClearAllPoints() OpacityFrame:SetPoint("TOPRIGHT", "BattlefieldMinimap", "TOPLEFT", -2*border, 0) - end, 1) + end) end) end) diff --git a/skins/blizzard/character.lua b/skins/blizzard/character.lua index 649df2b3..88d4775f 100644 --- a/skins/blizzard/character.lua +++ b/skins/blizzard/character.lua @@ -142,7 +142,7 @@ pfUI:RegisterSkin("Character", "vanilla:tbc", function () RefreshCharacterSlot(this) end end) - hooksecurefunc("PetTab_Update", RefreshPetPosition, 1) + hooksecurefunc("PetTab_Update", RefreshPetPosition) this.hooked = true end end) diff --git a/skins/blizzard/inspect.lua b/skins/blizzard/inspect.lua index 06c326c6..b81609c3 100644 --- a/skins/blizzard/inspect.lua +++ b/skins/blizzard/inspect.lua @@ -264,7 +264,7 @@ pfUI:RegisterSkin("Inspect", "vanilla", function () UpdateSlots() QueueFunction(UpdateSlots) - end, 1) + end) end do -- Honor Tab diff --git a/skins/blizzard/mail.lua b/skins/blizzard/mail.lua index ece67137..861c7d1f 100644 --- a/skins/blizzard/mail.lua +++ b/skins/blizzard/mail.lua @@ -67,7 +67,7 @@ pfUI:RegisterSkin("Mailbox", "vanilla:tbc", function () else SendMailPackageButton:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color)) end - end, 1) + end) end end) skin:RegisterEvent("MAIL_SHOW") diff --git a/skins/blizzard/merchant.lua b/skins/blizzard/merchant.lua index 167874c8..ccceba7e 100644 --- a/skins/blizzard/merchant.lua +++ b/skins/blizzard/merchant.lua @@ -63,7 +63,7 @@ pfUI:RegisterSkin("Merchant", "vanilla:tbc", function () _G["MerchantItem"..i]:SetPoint("TOPLEFT", _G["MerchantItem"..i-2], "BOTTOMLEFT", 0, -15) end end - end, 1) + end) StripTextures(MerchantPrevPageButton) SkinArrowButton(MerchantPrevPageButton, "left", 18) diff --git a/skins/blizzard/professions.lua b/skins/blizzard/professions.lua index d7b0df0b..eab6d31e 100644 --- a/skins/blizzard/professions.lua +++ b/skins/blizzard/professions.lua @@ -216,7 +216,7 @@ pfUI:RegisterSkin("Profession", "vanilla:tbc", function () end end end - end, true) + end) end -- Compatibility diff --git a/skins/blizzard/questlog.lua b/skins/blizzard/questlog.lua index 8ecea6a3..23b4d0e8 100644 --- a/skins/blizzard/questlog.lua +++ b/skins/blizzard/questlog.lua @@ -27,7 +27,7 @@ pfUI:RegisterSkin("Quest Log", "vanilla:tbc", function () hooksecurefunc("QuestLog_OnShow", function() QuestLogFrame:ClearAllPoints() QuestLogFrame:SetPoint("TOPLEFT", 10, -104) - end, 1) + end) QuestLogFrame:SetWidth(676) QuestLogFrame:SetHeight(440) @@ -191,7 +191,7 @@ pfUI:RegisterSkin("Quest Log", "vanilla:tbc", function () end end end - end, 1) + end) end do -- right pane diff --git a/skins/blizzard/readycheck.lua b/skins/blizzard/readycheck.lua index 26abd097..51ec176b 100644 --- a/skins/blizzard/readycheck.lua +++ b/skins/blizzard/readycheck.lua @@ -7,7 +7,7 @@ pfUI:RegisterSkin("Readycheck", "vanilla:tbc", function () else -- vanilla update_func = "ReadyCheck_OnUpdate" end - + StripTextures(ReadyCheckFrame, true) CreateBackdrop(ReadyCheckFrame, nil, nil, .75) CreateBackdropShadow(ReadyCheckFrame) @@ -41,7 +41,7 @@ pfUI:RegisterSkin("Readycheck", "vanilla:tbc", function () hooksecurefunc("ShowReadyCheck", function() max = ReadyCheckFrame.timer frame.bar:SetMinMaxValues(0, max) - end, 1) + end) hooksecurefunc(update_func, function() if not ReadyCheckFrame.timer then return end @@ -50,6 +50,6 @@ pfUI:RegisterSkin("Readycheck", "vanilla:tbc", function () frame.bar:SetStatusBarColor(GetColorGradient(perc)) frame.bar:SetValue(ReadyCheckFrame.timer) frame.bar.text:SetText(round(ReadyCheckFrame.timer, 2)) - end, 1) + end) end) end) diff --git a/skins/blizzard/survey.lua b/skins/blizzard/survey.lua index d4ba653b..4ea12fec 100644 --- a/skins/blizzard/survey.lua +++ b/skins/blizzard/survey.lua @@ -34,6 +34,6 @@ pfUI:RegisterSkin("GM Survey", "vanilla", function () GMSurveyFrameComment:SetMaxLetters(2000) hooksecurefunc("GMSurveyFrame_Update", function() GMSurveyFrameComment:SetWidth(505) - end, 1) + end) end) end) diff --git a/skins/blizzard/trade.lua b/skins/blizzard/trade.lua index a71d57bd..fd6237d6 100644 --- a/skins/blizzard/trade.lua +++ b/skins/blizzard/trade.lua @@ -43,7 +43,7 @@ pfUI:RegisterSkin("Trade", "vanilla:tbc", function () hooksecurefunc("TradeFrame_UpdateTargetItem", function(id) HandleIcon(_G["TradeRecipientItem"..id.."ItemButton"], _G["TradeRecipientItem"..id..'IconTexture']) - end, 1) + end) SkinMoneyInputFrame(TradePlayerInputMoneyFrame) diff --git a/skins/blizzard/trainer.lua b/skins/blizzard/trainer.lua index 8b208fca..62df6005 100644 --- a/skins/blizzard/trainer.lua +++ b/skins/blizzard/trainer.lua @@ -38,7 +38,7 @@ pfUI:RegisterSkin("Trainer", "vanilla:tbc", function () SkinButton(ClassTrainerSkillIcon, nil, nil, nil, nil, true) hooksecurefunc("ClassTrainer_SetSelection", function() HandleIcon(ClassTrainerSkillIcon, ClassTrainerSkillIcon:GetNormalTexture()) - end, 1) + end) StripTextures(ClassTrainerExpandButtonFrame) StripTextures(ClassTrainerCollapseAllButton)