Skip to content

Commit

Permalink
Add the talent build's level to the clickable link text
Browse files Browse the repository at this point in the history
Attempt to reduce the impact of various taint issues
  • Loading branch information
Numynum committed Dec 7, 2022
1 parent 9ca015f commit 71ca9cd
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 107 deletions.
60 changes: 60 additions & 0 deletions SharedUtil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
local _, TTT = ...
--- @class TalentTreeTweaks_Util
local Util = {};
TTT.Util = Util;

--- @type LibTalentTree
local LTT = LibStub('LibTalentTree-1.0');
Util.LibTalentTree = LTT;

function Util:OnInitialize()
self.dialogName = 'TalentTreeTweaksCopyTextDialog';
StaticPopupDialogs['TalentTreeTweaksCopyTextDialog'] = {
text = 'CTRL-C to copy',
button1 = CLOSE,
OnShow = function(dialog, data)
local function HidePopup()
dialog:Hide();
end
dialog.editBox:SetScript('OnEscapePressed', HidePopup);
dialog.editBox:SetScript('OnEnterPressed', HidePopup);
dialog.editBox:SetScript('OnKeyUp', function(_, key)
if IsControlKeyDown() and key == 'C' then
HidePopup();
end
end);
dialog.editBox:SetMaxLetters(0);
dialog.editBox:SetText(data);
dialog.editBox:HighlightText();
end,
hasEditBox = true,
editBoxWidth = 240,
timeout = 0,
whileDead = true,
hideOnEscape = true,
preferredIndex = 3,
};
end

function Util:CopyText(text)
StaticPopup_Show(self.dialogName, nil, nil, text);
end

local LOADOUT_SERIALIZATION_VERSION = 1;
function Util:GetLoadoutExportString(talentsTab)
local exportStream = ExportUtil.MakeExportDataStream();
local configID = talentsTab:GetConfigID();
local currentSpecID = talentsTab:GetSpecID();
local treeID = LTT:GetClassTreeId(talentsTab:GetClassID())

-- write header
exportStream:AddValue(talentsTab.bitWidthHeaderVersion, LOADOUT_SERIALIZATION_VERSION);
exportStream:AddValue(talentsTab.bitWidthSpecID, currentSpecID);
-- treeHash is a 128bit hash, passed as an array of 16, 8-bit values
-- empty tree hash will disable validation on import
exportStream:AddValue(8 * 16, 0);

talentsTab:WriteLoadoutContent(exportStream, configID, treeID);

return exportStream:GetExportString();
end
130 changes: 130 additions & 0 deletions TaintLess.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<Ui><Script><![CDATA[--[[
TaintLess [22-11-27]
https://www.townlong-yak.com/addons/taintless
All rights reserved.
Permission is hereby granted to distribute unmodified copies of this file.
]]
local function purgeKey(t, k)
local logLevel, c = GetCVar("taintLog"), -42
if (tonumber(logLevel) or 0) > 1 then
if CVarCallbackRegistry then
CVarCallbackRegistry:UnregisterEvent("CVAR_UPDATE")
end
SetCVar("taintLog", "1")
else
logLevel = nil
end
t[k] = nil
repeat
if t[c] == nil then
t[c] = nil
end
c = c - 1
until issecurevariable(t, k)
if logLevel then
SetCVar("taintLog", logLevel)
if CVarCallbackRegistry then
CVarCallbackRegistry:RegisterEvent("CVAR_UPDATE")
end
end
end
-- https://www.townlong-yak.com/addons/taintless/fixes/RefreshOverread
if (tonumber(UIDD_REFRESH_OVERREAD_PATCH_VERSION) or 0) < 3 then
UIDD_REFRESH_OVERREAD_PATCH_VERSION = 3
hooksecurefunc("UIDropDownMenu_InitializeHelper", function()
for i=1, UIDD_REFRESH_OVERREAD_PATCH_VERSION == 3 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
if (tonumber(UIDROPDOWNMENU_OPEN_PATCH_VERSION) or 0) < 1 then
UIDROPDOWNMENU_OPEN_PATCH_VERSION = 1
hooksecurefunc("UIDropDownMenu_InitializeHelper", function(frame)
if UIDROPDOWNMENU_OPEN_PATCH_VERSION == 1
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/IOFrameSelection
if (tonumber(IOFRAME_SELECTION_PATCH_VERSION) or 0) < 3 then
IOFRAME_SELECTION_PATCH_VERSION = 3
if InterfaceOptionsFrame then
InterfaceOptionsFrame:HookScript("OnHide", function()
if IOFRAME_SELECTION_PATCH_VERSION == 3 then
InterfaceOptionsFrameCategories.selection = nil
end
end)
end
end
-- https://www.townlong-yak.com/addons/taintless/fixes/EditModeOpenDrop
if EditModeManagerFrame and FriendsFrameStatusDropDown and (tonumber(EDITMAN_OPENDROP_PATCH_VERSION) or 0) < 1 then
EDITMAN_OPENDROP_PATCH_VERSION = 1
hooksecurefunc(EditModeManagerFrame, "GetAttribute", function(_, attr)
if attr ~= "UIPanelLayout-checkFit" or EDITMAN_OPENDROP_PATCH_VERSION ~= 1
or (issecurevariable(DropDownList1, "maxWidth") and issecurevariable("UIDROPDOWNMENU_MENU_LEVEL")) then
elseif InCombatLockdown() and FriendsFrameStatusDropDown:IsProtected() then
elseif FriendsFrameStatusDropDown:IsVisible() then
FriendsFrameStatusDropDown:Hide()
FriendsFrameStatusDropDown:Show()
else
local op = FriendsFrameStatusDropDown:GetParent()
FriendsFrameStatusDropDown:SetParent(nil)
if not FriendsFrameStatusDropDown:IsShown() then
FriendsFrameStatusDropDown:Show()
FriendsFrameStatusDropDown:Hide()
end
FriendsFrameStatusDropDown:SetParent(op)
end
end)
end
-- https://www.townlong-yak.com/addons/taintless/fixes/ObjectiveTrackerUpdate
if ObjectiveTrackerFrame and (tonumber(OBJTRACK_DELAYUPDATE_PATCH_VERSION) or 0) < 1 then
OBJTRACK_DELAYUPDATE_PATCH_VERSION = 1
local counter, didDelayUpdate, delayFrameCount = (CreateFrame("Frame", nil, ObjectiveTrackerFrame))
counter:Hide()
counter:SetScript("OnUpdate", function()
if OBJTRACK_DELAYUPDATE_PATCH_VERSION == 1 then
delayFrameCount = delayFrameCount + 1
else
counter:Hide()
end
end)
hooksecurefunc("ObjectiveTracker_Update", function()
if OBJTRACK_DELAYUPDATE_PATCH_VERSION == 1 and didDelayUpdate then
didDelayUpdate = nil
purgeKey(ObjectiveTrackerFrame, "isUpdating")
end
end)
hooksecurefunc(ObjectiveTrackerFrame.HeaderMenu.Title, "ClearAllPoints", function()
if OBJTRACK_DELAYUPDATE_PATCH_VERSION == 1 and not ObjectiveTrackerFrame.isUpdating then
if issecurevariable(ObjectiveTrackerFrame, "isOnLeftSideOfScreen") then
if delayFrameCount then
delayFrameCount = nil
counter:Hide()
end
elseif (delayFrameCount or 0) < 4 then
ObjectiveTrackerFrame.isUpdating, didDelayUpdate, delayFrameCount = 86, 1, delayFrameCount or 0
counter:Show()
else
counter:Hide()
end
end
end)
end
]]></Script></Ui>
3 changes: 3 additions & 0 deletions TalentTreeTweaks.toc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
## X-Curse-Project-ID: 678792
## SavedVariables: TalentTreeTweaksDB

TaintLess.xml
libs\embeds.xml

core.lua
SharedUtil.lua

modules\tooltipIds.lua
modules\exportInspectedBuild.lua
modules\debugNodeInfo.lua
Expand Down
1 change: 1 addition & 0 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function Main:OnInitialize()
self.db = TalentTreeTweaksDB;
self.version = GetAddOnMetadata(name, "Version") or "";
self:InitDefaults();
TTT.Util:OnInitialize();
for moduleName, module in self:IterateModules() do
--- @type TalentTreeTweaks_Module
local module = module;
Expand Down
Loading

0 comments on commit 71ca9cd

Please sign in to comment.