Skip to content

Commit 5652ea8

Browse files
committed
Simplify cancelling travel form, since the wiki lied to me :)
1 parent 6128849 commit 5652ea8

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

TalentLoadoutBroker.lua

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ local TLB = ns.TLB;
66

77
local starterConfigID = Constants.TraitConsts.STARTER_BUILD_TRAIT_CONFIG_ID;
88
local isDruid = select(2, UnitClass('player')) == 'DRUID';
9-
local cancelFormButton = CreateFrame('Button', nil, UIParent, 'InsecureActionButtonTemplate');
109

1110
function TLB:Init()
1211
EventUtil.ContinueOnAddOnLoaded(addonName, function()
@@ -30,19 +29,6 @@ function TLB:Init()
3029
SlashCmdList['TALENT_LOADOUT_BROKER'] = function() ns.Config:OpenConfig(); end
3130
end);
3231

33-
cancelFormButton:SetAttribute('type', 'macro');
34-
cancelFormButton:SetAttribute('macrotext', '/cancelform [form:3]');
35-
cancelFormButton:SetAttribute('useOnKeyDown', true);
36-
cancelFormButton:RegisterForClicks('AnyDown')
37-
cancelFormButton:SetFrameStrata('FULLSCREEN_DIALOG');
38-
cancelFormButton:SetFrameLevel(9999);
39-
cancelFormButton:SetPropagateMouseMotion(true);
40-
cancelFormButton:HookScript('OnClick', function(self)
41-
self.elementDescription:Pick(MenuInputContext.MouseButton, 'LeftButton');
42-
self:ClearAllPoints();
43-
self:Hide();
44-
end);
45-
4632
self.configIDs, self.configIDToName, self.currentConfigID = nil, nil, nil;
4733
self.updatePending, self.pendingDisableStarterBuild, self.pendingConfigID = false, false, nil;
4834
self.currentConfigID = nil;
@@ -405,7 +391,12 @@ function TLB:GenerateSpecDropdown(rootDescription)
405391
do
406392
rootDescription:CreateTitle(SPECIALIZATION);
407393
local function isSelected(data) return activeSpecIndex == data; end
408-
local function selectSpec(data) self:SelectSpec(data); end
394+
local function selectSpec(data)
395+
if isDruid and GetShapeshiftForm() == 3 then
396+
CancelShapeshiftForm();
397+
end
398+
self:SelectSpec(data);
399+
end
409400

410401
for specIndex = 1, numSpecs do
411402
local _, name, _, icon = GetSpecializationInfoForClassID(PlayerUtil.GetClassID(), specIndex);
@@ -416,20 +407,14 @@ function TLB:GenerateSpecDropdown(rootDescription)
416407
specIndex
417408
);
418409
if isDruid then
419-
button:HookOnEnter(function(frame, elementDescription)
420-
cancelFormButton:ClearAllPoints();
421-
cancelFormButton:SetAllPoints(frame);
422-
cancelFormButton:Show();
423-
cancelFormButton.elementDescription = elementDescription;
410+
button:HookOnEnter(function(frame)
424411
if GetShapeshiftForm() == 3 then
425412
GameTooltip:SetOwner(frame, 'ANCHOR_TOP');
426413
GameTooltip:SetText('This will cancel your travel form!');
427414
GameTooltip:Show();
428415
end
429416
end);
430417
button:HookOnLeave(function()
431-
cancelFormButton:ClearAllPoints();
432-
cancelFormButton:Hide();
433418
GameTooltip:Hide();
434419
end);
435420
end

0 commit comments

Comments
 (0)