Skip to content

Commit

Permalink
Cleanup: Deleted code that was left for DF compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Numynum committed Aug 21, 2024
1 parent d6d9df4 commit 6054977
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 249 deletions.
14 changes: 9 additions & 5 deletions SharedUtil.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ local _, TTT = ...
local Util = {};
TTT.Util = Util;
local L = TTT.L;
--- @type TalentTreeTweaks_ImportExportUtilV1|TalentTreeTweaks_ImportExportUtilV2
--- @type TalentTreeTweaks_ImportExportUtilV2
local ImportExportUtil = TTT.ImportExportUtil;

local isDF = select(4, GetBuildInfo()) < 110000;
Util.isDF = isDF;
local talentAddonName = isDF and 'Blizzard_ClassTalentUI' or 'Blizzard_PlayerSpells';
local talentAddonName = 'Blizzard_PlayerSpells';

local LTT = LibStub('LibTalentTree-1.0');
Util.LibTalentTree = LTT;
Expand Down Expand Up @@ -86,13 +84,19 @@ function Util:OnInitialize()
self:RefreshConfigIDLookup();
end

--- @generic T: table
--- @param db table
--- @param defaults T
--- @return T
function Util:PrepareModuleDb(module, db, defaults)
module.db = db;
for k, v in pairs(defaults) do
if db[k] == nil then
db[k] = v;
end
end

return db;
end

function Util:GetterSetterIncrementFactory(db, postSetCallback)
Expand Down Expand Up @@ -144,7 +148,7 @@ function Util:CopyText(text, optionalTitleSuffix)
end

function Util:GetTalentContainerFrame(noAutoload)
local frameName = isDF and 'ClassTalentFrame' or 'PlayerSpellsFrame';
local frameName = 'PlayerSpellsFrame';
if not _G[frameName] and not noAutoload then
C_AddOns.LoadAddOn(talentAddonName);
end
Expand Down
38 changes: 32 additions & 6 deletions modules/alwaysShowGates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function Module:OnDisable()
if talentFrame then
self.gatePool:ReleaseAll();
talentFrame:RefreshGates();
if not Util.isDF and talentFrame.HeroTalentsContainer then
talentFrame.HeroTalentsContainer:SetPoint("TOP", talentFrame.ButtonsParent, 'TOP', -15, 0)
if talentFrame.HeroTalentsContainer then
talentFrame:UpdateSpecBackground();
end
end
end
Expand All @@ -41,6 +41,24 @@ function Module:GetName()
return L['Always Show Gates'];
end

function Module:GetOptions(defaultOptionsTable, db)
self.db = Util:PrepareModuleDb(self, db, {
shiftHeroTrees = false,
});
local getter, setter, increment = Util:GetterSetterIncrementFactory(db, function() self:UpdateHeroContainerPosition(); end);

defaultOptionsTable.args.shiftHeroTrees = {
order = increment(),
type = "toggle",
name = L["Shift Hero Talent Trees"],
desc = L["Shifts the Hero Talent Trees to the left to avoid overlapping with the gate text."],
get = getter,
set = setter,
}

return defaultOptionsTable;
end

function Module:SetupHook()
local talentTab = Util:GetTalentFrame();
-- We have to create our own gatePool, because otherwise we will cause massive taint issues
Expand All @@ -66,7 +84,7 @@ function Module:RefreshGates()
return;
end

for i, gateInfo in ipairs(talentFrame.talentTreeInfo.gates) do
for _, gateInfo in pairs(talentFrame.talentTreeInfo.gates) do
local firstButton = talentFrame:GetTalentButtonByNodeID(gateInfo.topLeftNodeID);
local condInfo = talentFrame:GetAndCacheCondInfo(gateInfo.conditionID);
if firstButton and firstButton:IsVisible() and condInfo.isMet then
Expand All @@ -83,9 +101,17 @@ function Module:RefreshGates()
end
end

if not Util.isDF and talentFrame.HeroTalentsContainer then
-- shift the hero talents container to the left to make room for the longer gate text
talentFrame.HeroTalentsContainer:SetPoint("TOP", talentFrame.ButtonsParent, 'TOP', -80, 0)
self:UpdateHeroContainerPosition();
end

function Module:UpdateHeroContainerPosition()
local talentFrame = Util:GetTalentFrame();
if talentFrame.HeroTalentsContainer then
if self.db.shiftHeroTrees then
talentFrame.HeroTalentsContainer:SetPoint("TOP", talentFrame.ButtonsParent, 'TOP', -80, 0);
else
talentFrame:UpdateSpecBackground();
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion modules/exportInspectedBuild.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local Main = TTT.Main;
local Util = TTT.Util;
local L = TTT.L;

local LEVEL_CAP = Util.isDF and 70 or 80;
local LEVEL_CAP = 80;

--- @class TalentTreeTweaks_ExportInspectedBuild: AceModule, AceHook-3.0
local Module = Main:NewModule('ExportInspectedBuild', 'AceHook-3.0');
Expand Down Expand Up @@ -143,6 +143,7 @@ end

function Module:MakeLinkButton(talentsTab)
local button = CreateFrame('Button', nil, talentsTab, 'UIPanelButtonNoTooltipTemplate, UIButtonTemplate');
talentsTab.TalentTreeTweaks_LinkToChatButton = button;
button:SetText(TALENT_FRAME_DROP_DOWN_EXPORT_CHAT_LINK or L['Post in Chat']);
button:SetSize(100, 22);
button:SetPoint('BOTTOMLEFT', 47, 5);
Expand Down
3 changes: 0 additions & 3 deletions modules/heroTalents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ local Main = TTT.Main;
local Util = TTT.Util;
local L = TTT.L;

-- TWW+ only
if Util.isDF then return; end

--- @class TalentTreeTweaks_HeroTalents: AceModule, AceHook-3.0
local Module = Main:NewModule('HeroTalents', 'AceHook-3.0');

Expand Down
4 changes: 3 additions & 1 deletion modules/importIntoCurrentLoadout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function Module:SetupHook()
end

function Module:OnUnlockImportButtonValueChanged()
if not Util.isDF then return; end -- todo: TWW compatibility
if true then return; end -- todo: TWW compatibility
local dropdown = Util:GetTalentFrame().LoadoutDropDown;
for _, sentinelInfo in pairs(dropdown.sentinelKeyToInfo) do
if sentinelInfo.text == TALENT_FRAME_DROP_DOWN_IMPORT then
Expand Down Expand Up @@ -139,6 +139,7 @@ function Module:CreateCheckbox(dialog)

local text = string.format(L['Import into current loadout (click "%s" afterwards)'], TALENT_FRAME_APPLY_BUTTON_TEXT);
local checkbox = CreateFrame('CheckButton', nil, dialog, 'UICheckButtonTemplate');
dialog.TalentTreeTweaks_ImportIntoCurrentCheckbox = checkbox;
checkbox:SetPoint('TOPLEFT', dialog.NameControl, 'BOTTOMLEFT', 0, 5);
checkbox:SetSize(24, 24);
checkbox:SetScript('OnClick', function(cb) self:OnCheckboxClick(cb); end);
Expand Down Expand Up @@ -167,6 +168,7 @@ function Module:CreateAcceptButton(dialog)
end

local acceptButton = CreateFrame('Button', nil, dialog, 'ClassTalentLoadoutDialogButtonTemplate');
dialog.TalentTreeTweaks_AcceptButton = acceptButton;
acceptButton:SetPoint('BOTTOMRIGHT', dialog.ContentArea, 'BOTTOM', -5, 0);
acceptButton:SetText(HUD_CLASS_TALENTS_IMPORT_LOADOUT_ACCEPT_BUTTON);
acceptButton.disabledTooltip = HUD_CLASS_TALENTS_IMPORT_ERROR_IMPORT_STRING_AND_NAME;
Expand Down
1 change: 1 addition & 0 deletions modules/inspectDiff.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function Module:InitCheckbox(talentViewerFrame)
end

local checkbox = CreateFrame('CheckButton', nil, talentViewerFrame, 'UICheckButtonTemplate');
talentViewerFrame.TalentTreeTweaks_ShowDiffCheckbox = checkbox;
checkbox:SetPoint('TOPLEFT', talentViewerFrame.IgnoreRestrictions, 'BOTTOMLEFT');
checkbox:SetSize(25, 25);
checkbox:SetScript('OnClick', function()
Expand Down
51 changes: 19 additions & 32 deletions modules/miniTreeInTooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ end
function Module:OnInitialize()
self.debug = false;
self.containers = {};
if not Util.isDF then
Menu.ModifyMenu('MENU_CLASS_TALENT_PROFILE', function(dropdown, rootDescription, contextData)
if not self:IsEnabled() then return; end
self:OnLoadoutMenuOpen(dropdown, rootDescription);
end);
end
Menu.ModifyMenu('MENU_CLASS_TALENT_PROFILE', function(dropdown, rootDescription, contextData)
if not self:IsEnabled() then return; end
self:OnLoadoutMenuOpen(dropdown, rootDescription);
end);
end

function Module:OnEnable()
Expand All @@ -80,16 +78,7 @@ function Module:OnEnable()
self:SecureHookScript(frame, "OnHyperlinkEnter");
self:SecureHookScript(frame, "OnHyperlinkLeave");
end)
self:SecureHook(GameTooltip, "Show", "OnTooltipShow")

Util:OnTalentUILoad(function()
local talentsTab = Util:GetTalentFrame();
if Util.isDF then -- todo: remove after 11.0 release
local dropdown = talentsTab.LoadoutDropDown;
self:SecureHook(dropdown.DropDownControl, 'SetCustomSetup', 'HookCustomSetupCallback');
self:HookCustomSetupCallback(dropdown.DropDownControl);
end
end)
self:SecureHook(GameTooltip, "Show", "OnTooltipShow");

EventUtil.ContinueOnAddOnLoaded("Blizzard_InspectUI", function()
self:HookInspectTalentsButton();
Expand Down Expand Up @@ -249,20 +238,18 @@ function Module:GetOptions(defaultOptionsTable, db)
step = 0.1,
get = getter,
set = setter,
}
if not Util.isDF then
defaultOptionsTable.args.inactiveSubTreeAlpha = {
order = increment(),
type = "range",
name = L["Fade Inactive Hero Trees"],
desc = L["Fade Inactive Hero Trees, to more easily see which one is active."],
min = 0,
max = 1,
step = 0.1,
get = getter,
set = setter,
};
end
};
defaultOptionsTable.args.inactiveSubTreeAlpha = {
order = increment(),
type = "range",
name = L["Fade Inactive Hero Trees"],
desc = L["Fade Inactive Hero Trees, to more easily see which one is active."],
min = 0,
max = 1,
step = 0.1,
get = getter,
set = setter,
};
defaultOptionsTable.args.example = {
order = increment(),
type = "execute",
Expand All @@ -280,7 +267,7 @@ function Module:GetOptions(defaultOptionsTable, db)
TalentTreeTweaks_EmbedMiniTreeIntoTooltip(ItemRefTooltip, nil, configID)
end,
disabled = function() return not C_ClassTalents.GetActiveConfigID(); end,
}
};

return defaultOptionsTable;
end
Expand Down Expand Up @@ -552,7 +539,7 @@ function containerMixin:Init()
self.spacing = 20;
self.dotSize = 12;
self.expectedMaxRows = 10;
self.expectedMaxCols = Util.isDF and 20 or 23;
self.expectedMaxCols = 23;

self:SetSize(self.expectedMaxCols * self.spacing, self.expectedMaxRows * self.spacing);
self:Hide();
Expand Down
Loading

0 comments on commit 6054977

Please sign in to comment.