-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for tabs added through SecureTabs-2.0, add support for Scrap
- Loading branch information
Showing
7 changed files
with
292 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
## X-WoWI-ID: 5217 | ||
## X-Wago-ID: kRNLnQKo | ||
|
||
libs/main.xml | ||
|
||
init.lua | ||
|
||
localisation/index.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- LibStub is a simple versioning stub meant for use in Libraries. http://www.wowace.com/wiki/LibStub for more info | ||
-- LibStub is hereby placed in the Public Domain Credits: Kaelten, Cladhaire, ckknight, Mikk, Ammo, Nevcairiel, joshborke | ||
local LIBSTUB_MAJOR, LIBSTUB_MINOR = "LibStub", 2 -- NEVER MAKE THIS AN SVN REVISION! IT NEEDS TO BE USABLE IN ALL REPOS! | ||
local LibStub = _G[LIBSTUB_MAJOR] | ||
|
||
if not LibStub or LibStub.minor < LIBSTUB_MINOR then | ||
LibStub = LibStub or {libs = {}, minors = {} } | ||
_G[LIBSTUB_MAJOR] = LibStub | ||
LibStub.minor = LIBSTUB_MINOR | ||
|
||
function LibStub:NewLibrary(major, minor) | ||
assert(type(major) == "string", "Bad argument #2 to `NewLibrary' (string expected)") | ||
minor = assert(tonumber(strmatch(minor, "%d+")), "Minor version must either be a number or contain a number.") | ||
|
||
local oldminor = self.minors[major] | ||
if oldminor and oldminor >= minor then return nil end | ||
self.minors[major], self.libs[major] = minor, self.libs[major] or {} | ||
return self.libs[major], oldminor | ||
end | ||
|
||
function LibStub:GetLibrary(major, silent) | ||
if not self.libs[major] and not silent then | ||
error(("Cannot find a library instance of %q."):format(tostring(major)), 2) | ||
end | ||
return self.libs[major], self.minors[major] | ||
end | ||
|
||
function LibStub:IterateLibraries() return pairs(self.libs) end | ||
setmetatable(LibStub, { __call = LibStub.GetLibrary }) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--[[ | ||
Copyright 2013-2024 João Cardoso | ||
SecureTabs is distributed under the terms of the GNU General Public License (or the Lesser GPL). | ||
This file is part of SecureTabs. | ||
SecureTabs is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
SecureTabs is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with SecureTabs. If not, see <http://www.gnu.org/licenses/>. | ||
--]] | ||
|
||
local Lib, old = LibStub:NewLibrary('SecureTabs-2.0', 10) | ||
if not Lib then | ||
return | ||
elseif not old then | ||
hooksecurefunc('PanelTemplates_SetTab', function(panel, id) | ||
Lib:Update(panel) | ||
end) | ||
end | ||
|
||
Lib.tabs = Lib.tabs or {} | ||
Lib.covers = Lib.covers or {} | ||
Lib.template = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE and 'PanelTabButtonTemplate' or 'CharacterFrameTabButtonTemplate' | ||
|
||
|
||
--[[ Main API ]]-- | ||
|
||
function Lib:Add(panel, frame, label) | ||
local secureTabs = self.tabs[panel] or {} | ||
local id = #secureTabs | ||
local anchor = id > 0 and 'SecureTab' .. (id-1) or 'Tab' .. panel.numTabs | ||
|
||
local tab = CreateFrame('Button', '$parentSecureTab' .. id, panel, self.template) | ||
tab:SetPoint('LEFT', panel:GetName() .. anchor, 'RIGHT', WOW_PROJECT_ID == WOW_PROJECT_MAINLINE and 3 or -16, 0) | ||
tab:SetScript('OnClick', function(tab) self:Select(tab) end) | ||
tab:SetText(label) | ||
tab.frame = frame | ||
tinsert(secureTabs, tab) | ||
PanelTemplates_DeselectTab(tab) | ||
|
||
local cover = self.covers[panel] or CreateFrame('Button', '$parentCoverTab', panel, self.template) | ||
cover:SetScript('OnClick', function(tab) self:Uncover(panel) end) | ||
PanelTemplates_DeselectTab(cover) | ||
|
||
self.tabs[panel] = secureTabs | ||
self.covers[panel] = cover | ||
|
||
return tab | ||
end | ||
|
||
function Lib:Select(tab) | ||
if tab.OnSelect then | ||
tab:OnSelect() | ||
end | ||
|
||
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB) | ||
self:Update(tab:GetParent(), tab) | ||
end | ||
|
||
|
||
--[[ Advanced Methods ]]-- | ||
|
||
function Lib:Uncover(panel) | ||
PlaySound(SOUNDKIT.IG_CHARACTER_INFO_TAB) | ||
self:Update(panel) | ||
end | ||
|
||
function Lib:Update(panel, selection) | ||
local secureTabs = self.tabs[panel] | ||
if not secureTabs then | ||
return | ||
end | ||
|
||
for i, tab in ipairs(secureTabs) do | ||
local selected = tab == selection | ||
if selected then | ||
PanelTemplates_SelectTab(tab) | ||
else | ||
PanelTemplates_DeselectTab(tab) | ||
end | ||
|
||
local frame = tab.frame | ||
if frame then | ||
frame:SetShown(selected) | ||
|
||
if selected then | ||
frame:SetParent(panel) | ||
frame:EnableMouse(true) | ||
frame:SetAllPoints(true) | ||
frame:SetFrameLevel(panel:GetFrameLevel() + 20) | ||
|
||
if frame.CloseButton then | ||
frame.CloseButton:SetScript('OnClick', function() | ||
local original = frame:GetParent() and frame:GetParent().CloseButton | ||
if original then | ||
ExecuteFrameScript(original, 'OnClick') -- make sure any additional behaviour is replicated | ||
end | ||
|
||
HideUIPanel(frame) -- safest hiding method | ||
end) | ||
end | ||
end | ||
end | ||
end | ||
|
||
if panel.selectedTab then | ||
local cover = self.covers[panel] | ||
local tab = _G[panel:GetName() .. 'Tab'.. panel.selectedTab] | ||
|
||
local name = tab:GetName() | ||
local left = tab.LeftActive or _G[name..'LeftDisabled'] | ||
local middle = tab.MiddleActive or _G[name..'MiddleDisabled'] | ||
local right = tab.RightActive or _G[name..'RightDisabled'] | ||
|
||
cover:SetShown(selection) | ||
left:SetShown(not selection) | ||
middle:SetShown(not selection) | ||
right:SetShown(not selection) | ||
|
||
if selection then | ||
cover:SetParent(tab) | ||
cover:SetAllPoints(tab) | ||
cover:SetText(tab:GetText()) | ||
PanelTemplates_TabResize(cover, 0, nil, 36, panel.maxTabWidth or 88) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<Ui><Script><![CDATA[--[[ | ||
TaintLess [24-07-27] | ||
https://www.townlong-yak.com/addons/taintless | ||
All rights reserved. | ||
Permission is hereby granted to distribute unmodified copies of this file. | ||
]] | ||
local purgeKey do | ||
local e = {} | ||
function purgeKey(t, k) | ||
e.textures, t[k] = t, 0 | ||
TextureLoadingGroupMixin.RemoveTexture(e, k) | ||
end | ||
end | ||
local patch, cbuild do | ||
local skips = securecall(function() | ||
local r, _, an = {moon="haunted"} | ||
cbuild, r.moon, _, an = select(4,GetBuildInfo()), nil, issecurevariable(r, "moon") | ||
for m, v, clo, chi in (C_AddOns.GetAddOnMetadata(an, "X-TaintLess-DisableMitigations") or ""):gmatch("([%a_]+)=(%d+):?(%d*):?(%d*)") do | ||
if (clo == "" or cbuild >= clo+0) and (chi == "" or chi+0 >= cbuild) then | ||
r[m] = v + 0 | ||
end | ||
end | ||
return r | ||
end) | ||
function patch(name, version, impl) | ||
if impl and not ((tonumber(_G[name]) or 0) >= version or skips and skips[name] == version) then | ||
_G[name] = version | ||
securecall(impl, version) | ||
end | ||
end | ||
end | ||
local CLASSIC = cbuild and cbuild < 11e4 | ||
-- https://www.townlong-yak.com/addons/taintless/fixes/RefreshOverread | ||
patch("UIDD_REFRESH_OVERREAD_PATCH_VERSION", 7, CLASSIC and function(V) | ||
hooksecurefunc("UIDropDownMenu_InitializeHelper", function() | ||
for i=1, UIDD_REFRESH_OVERREAD_PATCH_VERSION == V and UIDROPDOWNMENU_MAXLEVELS or 0 do | ||
for j=1+_G["DropDownList" .. i].numButtons, UIDROPDOWNMENU_MAXBUTTONS do | ||
local b, _ = _G["DropDownList" .. i .. "Button" .. j] | ||
_ = issecurevariable(b, "checked") or purgeKey(b, "checked") | ||
_ = issecurevariable(b, "notCheckable") or purgeKey(b, "notCheckable") | ||
end | ||
end | ||
end) | ||
end) | ||
-- https://www.townlong-yak.com/addons/taintless/fixes/DisplayModeTaint | ||
patch("UIDROPDOWNMENU_OPEN_PATCH_VERSION", 5, CLASSIC and function(V) | ||
hooksecurefunc("UIDropDownMenu_InitializeHelper", function(frame) | ||
if UIDROPDOWNMENU_OPEN_PATCH_VERSION == V | ||
and UIDROPDOWNMENU_OPEN_MENU and UIDROPDOWNMENU_OPEN_MENU ~= frame | ||
and not issecurevariable(UIDROPDOWNMENU_OPEN_MENU, "displayMode") then | ||
purgeKey(_G, "UIDROPDOWNMENU_OPEN_MENU") | ||
end | ||
end) | ||
end) | ||
-- https://www.townlong-yak.com/addons/taintless/fixes/CUFProfileActivation | ||
patch("CUF_PROFILE_ACTIVATE_PATCH_VERSION", 1, function(V) | ||
if not (type(SetActiveRaidProfile) == "function" and type(CompactUnitFrameProfiles) == "table" and | ||
type(ScriptErrorsFrameMixin) == "table" and type(ScriptErrorsFrameMixin.DisplayMessageInternal) == "function") then | ||
return | ||
end | ||
local o, dd = {}, CreateFrame("Frame") do | ||
local s, sk, sv = 1, {"seen", "order", "order", "count"}, {{}, {}, newproxy(true), _G} | ||
getmetatable(sv[3]).__len = function() | ||
return "UIDROPDOWNMENU_MENU_LEVEL" | ||
end | ||
setmetatable(o, {__index=function(_,k) | ||
s, sv[2][1] = k == sk[s] and s+1 or 1 | ||
return sv[s-1] | ||
end}) | ||
function dd.initialize() end | ||
dd:Hide() | ||
end | ||
hooksecurefunc("SetActiveRaidProfile", function() | ||
if CUF_PROFILE_ACTIVATE_PATCH_VERSION ~= V or | ||
(issecurevariable("UIDROPDOWNMENU_MENU_LEVEL") and issecurevariable(DropDownList1, "numButtons")) then | ||
return | ||
end | ||
pcall(UIDropDownMenu_InitializeHelper, dd) | ||
purgeKey(_G, "UIDROPDOWNMENU_OPEN_MENU") | ||
purgeKey(_G, "UIDROPDOWNMENU_INIT_MENU") | ||
pcall(ScriptErrorsFrameMixin.DisplayMessageInternal, o, "", 0, 0, 0, "") | ||
end) | ||
end) | ||
]]></Script></Ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Ui> | ||
<Include file="TaintLess\TaintLess.xml"/> | ||
<Script file="LibStub\LibStub.lua"/> | ||
<Script file="SecureTabs-2.0\SecureTabs-2.0.lua"/> | ||
</Ui> |