Skip to content

Commit d634c62

Browse files
committed
Update for 11.2.0 popup dialog changes
1 parent cbe35ce commit d634c62

File tree

2 files changed

+58
-36
lines changed

2 files changed

+58
-36
lines changed

core/ReduceTaint.lua

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,24 @@ function Module:OnInitialize()
1919
StaticPopupDialogs[self.copyDialogName] = {
2020
text = 'CTRL-C to copy %s',
2121
button1 = CLOSE,
22+
--- @param dialog StaticPopupTemplate
23+
--- @param data string
2224
OnShow = function(dialog, data)
2325
local function HidePopup()
2426
dialog:Hide();
2527
end
26-
dialog.editBox:SetScript('OnEscapePressed', HidePopup);
27-
dialog.editBox:SetScript('OnEnterPressed', HidePopup);
28-
dialog.editBox:SetScript('OnKeyUp', function(_, key)
29-
if IsControlKeyDown() and key == 'C' then
28+
--- @type StaticPopupTemplate_EditBox
29+
local editBox = dialog.GetEditBox and dialog:GetEditBox() or dialog.editBox;
30+
editBox:SetScript('OnEscapePressed', HidePopup);
31+
editBox:SetScript('OnEnterPressed', HidePopup);
32+
editBox:SetScript('OnKeyUp', function(_, key)
33+
if IsControlKeyDown() and (key == 'C' or key == 'X') then
3034
HidePopup();
3135
end
3236
end);
33-
dialog.editBox:SetMaxLetters(0);
34-
dialog.editBox:SetText(data);
35-
dialog.editBox:HighlightText();
37+
editBox:SetMaxLetters(0);
38+
editBox:SetText(data);
39+
editBox:HighlightText();
3640
end,
3741
hasEditBox = true,
3842
editBoxWidth = 240,

modules/SideBarMixin.lua

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,35 @@ function SideBarMixin:OnInitialize()
3636
button1 = OKAY,
3737
button2 = CANCEL,
3838
hasEditBox = true,
39+
--- @param dialog StaticPopupTemplate
3940
--- @param data TLM_SideBarLoadoutInfo
40-
OnShow = function (dialog, data)
41-
dialog.editBox:SetText(data.name);
42-
dialog.editBox:HighlightText();
43-
dialog.editBox:SetScript("OnEscapePressed", function()
41+
OnShow = function(dialog, data)
42+
--- @type StaticPopupTemplate_EditBox
43+
local editBox = dialog:GetEditBox();
44+
editBox:SetText(data.name);
45+
editBox:HighlightText();
46+
editBox:SetScript("OnEscapePressed", function()
4447
dialog:Hide();
4548
end);
46-
dialog.editBox:SetScript("OnEnterPressed", function()
47-
dialog.button1:Click();
49+
editBox:SetScript("OnEnterPressed", function()
50+
dialog:GetButtons()[1]:Click();
4851
end);
4952
end,
53+
--- @param dialog StaticPopupTemplate
5054
--- @param data TLM_SideBarLoadoutInfo
5155
OnAccept = function(dialog, data)
52-
local newName = dialog.editBox:GetText();
56+
local newName = dialog:GetEditBox():GetText();
5357
GlobalAPI:RenameLoadout(data.id, newName);
5458
dialog:Hide();
5559
end,
56-
EditBoxOnTextChanged = function (self)
60+
--- @param self StaticPopupTemplate_EditBox
61+
EditBoxOnTextChanged = function(self)
62+
--- @type StaticPopupTemplate
63+
local dialog = self:GetParent();
5764
if self:GetText() == "" then
58-
self:GetParent().button1:Disable();
65+
dialog:GetButtons()[1]:Disable();
5966
else
60-
self:GetParent().button1:Enable();
67+
dialog:GetButtons()[1]:Enable();
6168
end
6269
end,
6370
timeout = 0,
@@ -72,24 +79,31 @@ function SideBarMixin:OnInitialize()
7279
button1 = OKAY,
7380
button2 = CANCEL,
7481
hasEditBox = true,
75-
OnShow = function (dialog)
76-
dialog.editBox:SetScript("OnEscapePressed", function()
82+
--- @param dialog StaticPopupTemplate
83+
OnShow = function(dialog)
84+
--- @type StaticPopupTemplate_EditBox
85+
local editBox = dialog:GetEditBox();
86+
editBox:SetScript("OnEscapePressed", function()
7787
dialog:Hide();
7888
end);
79-
dialog.editBox:SetScript("OnEnterPressed", function()
80-
dialog.button1:Click();
89+
editBox:SetScript("OnEnterPressed", function()
90+
dialog:GetButtons()[1]:Click();
8191
end);
8292
end,
93+
--- @param dialog StaticPopupTemplate
8394
OnAccept = function(dialog)
84-
local name = dialog.editBox:GetText();
95+
local name = dialog:GetEditBox():GetText();
8596
self:DoCreate(name)
8697
dialog:Hide();
8798
end,
88-
EditBoxOnTextChanged = function (self)
99+
--- @param self StaticPopupTemplate_EditBox
100+
EditBoxOnTextChanged = function(self)
101+
--- @type StaticPopupTemplate
102+
local dialog = self:GetParent();
89103
if self:GetText() == "" then
90-
self:GetParent().button1:Disable();
104+
dialog:GetButtons()[1]:Disable();
91105
else
92-
self:GetParent().button1:Enable();
106+
dialog:GetButtons()[1]:Enable();
93107
end
94108
end,
95109
timeout = 0,
@@ -103,6 +117,7 @@ function SideBarMixin:OnInitialize()
103117
text = "Delete loadout (%s)?",
104118
button1 = OKAY,
105119
button2 = CANCEL,
120+
--- @param dialog StaticPopupTemplate
106121
--- @param data TLM_SideBarLoadoutInfo
107122
OnAccept = function(dialog, data)
108123
GlobalAPI:DeleteLoadout(data.id);
@@ -119,6 +134,7 @@ function SideBarMixin:OnInitialize()
119134
text = "Remove loadout from list (%s)?",
120135
button1 = OKAY,
121136
button2 = CANCEL,
137+
--- @param dialog StaticPopupTemplate
122138
--- @param data TLM_SideBarLoadoutInfo
123139
OnAccept = function(dialog, data)
124140
GlobalAPI:RemoveLoadoutFromStorage(data.id);
@@ -135,6 +151,7 @@ function SideBarMixin:OnInitialize()
135151
text = "Remove all loadouts from %s from the list?",
136152
button1 = OKAY,
137153
button2 = CANCEL,
154+
--- @param dialog StaticPopupTemplate
138155
--- @param data TLM_SideBarLoadoutInfo
139156
OnAccept = function(dialog, data)
140157
self:RemoveAllLoadoutsByOwner(data.owner);
@@ -150,21 +167,24 @@ function SideBarMixin:OnInitialize()
150167
StaticPopupDialogs[self.copyDialogName] = {
151168
text = "CTRL-C to copy",
152169
button1 = CLOSE,
170+
--- @param dialog StaticPopupTemplate
153171
--- @param data string
154172
OnShow = function(dialog, data)
155173
local function HidePopup()
156174
dialog:Hide();
157175
end
158-
dialog.editBox:SetScript("OnEscapePressed", HidePopup);
159-
dialog.editBox:SetScript("OnEnterPressed", HidePopup);
160-
dialog.editBox:SetScript("OnKeyUp", function(_, key)
161-
if IsControlKeyDown() and key == "C" then
176+
--- @type StaticPopupTemplate_EditBox
177+
local editBox = dialog:GetEditBox();
178+
editBox:SetScript("OnEscapePressed", HidePopup);
179+
editBox:SetScript("OnEnterPressed", HidePopup);
180+
editBox:SetScript("OnKeyUp", function(_, key)
181+
if IsControlKeyDown() and (key == 'C' or key == 'X') then
162182
HidePopup();
163183
end
164184
end);
165-
dialog.editBox:SetMaxLetters(0);
166-
dialog.editBox:SetText(data);
167-
dialog.editBox:HighlightText();
185+
editBox:SetMaxLetters(0);
186+
editBox:SetText(data);
187+
editBox:HighlightText();
168188
end,
169189
hasEditBox = true,
170190
editBoxWidth = 240,
@@ -180,10 +200,8 @@ function SideBarMixin:OnInitialize()
180200
button1 = OKAY,
181201
button2 = nil,
182202
timeout = 0,
183-
OnAccept = function()
184-
end,
185-
OnCancel = function()
186-
end,
203+
OnAccept = function() end,
204+
OnCancel = function() end,
187205
whileDead = true,
188206
hideOnEscape = true,
189207
preferredIndex = 3,

0 commit comments

Comments
 (0)