Repository navigation
Expand file tree
/
Copy pathQuestDialogs.lua
More file actions
332 lines (324 loc) · 11.3 KB
/
Copy pathQuestDialogs.lua
File metadata and controls
332 lines (324 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
local QuestTogether = _G.QuestTogether
local L = QuestTogether.Translate
function QuestTogether:ShowDiscordLinkDialog(url)
if self:IsWorkBlocked("foreign_frame_mutation") then
return false
end
local frame = rawget(self, "discordLinkDialog")
if not frame then
frame = self:CreateScrollDialog(660, 280, L("QuestTogether Discord — Feedback & Support"))
if not frame then
return false
end
self.discordLinkDialog = frame
local hint = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
hint:SetPoint("TOPLEFT", frame.contentInset, -frame.contentTop)
hint:SetWidth(frame.contentWidth)
hint:SetText(L("Press Ctrl+C to copy this address, then open it in your browser."))
self:AddScrollDialogLabel(frame, hint)
frame.box = self:CreateOwnedWindowFrame("EditBox", nil, frame)
frame.box:SetPoint("TOPLEFT", hint, "BOTTOMLEFT", 0, -20)
frame.box:SetSize(frame.contentWidth, 32)
frame.LayoutManagedWindow = function()
frame:SetHeight(frame.contentTop + hint:GetStringHeight() + 20 + 32 + 24 + 24 + frame.contentBottom)
self:FitScrollDialog(frame)
end
frame:LayoutManagedWindow()
frame.box:SetAutoFocus(false)
frame.box:SetFontObject("ChatFontNormal")
frame.box:SetTextInsets(8, 8, 4, 4)
self:AddScrollDialogLabel(frame, frame.box)
local field = frame.box:CreateTexture(nil, "BACKGROUND")
field:SetAllPoints()
field:SetColorTexture(0.5, 0.5, 0.5, 0.18)
local function Close()
self:DismissManagedWindow(frame)
end
frame.box:SetScript("OnEscapePressed", Close)
frame.box:SetScript("OnEditFocusGained", function(box)
if not self:IsWorkBlocked("foreign_frame_mutation") and self.LibChev.CanMutateOwnedRegion(box) then
box:HighlightText()
end
end)
frame.box:SetScript("OnTextChanged", function(box, userInput)
if
self:CanAccessValue(userInput)
and userInput == true
and not self:IsWorkBlocked("foreign_frame_mutation")
and self.LibChev.CanMutateOwnedRegion(box)
then
box:SetText(frame.url)
box:HighlightText()
end
end)
self:ConfigureWindowController(frame, {
suspend = function()
if self.LibChev.CanMutateOwnedRegion(frame.box) then
frame.box:ClearFocus()
end
end,
})
frame.close = self:CreateOwnedWindowFrame("Button", nil, frame, "UIPanelButtonTemplate")
frame.close:SetPoint("BOTTOMRIGHT", -frame.contentInset, frame.contentBottom)
frame.close:SetSize(110, 24)
frame.close:SetText(L("Close"))
frame.close:SetScript("OnClick", Close)
end
if not self:ApplyScrollDialogTheme(frame) or not self.LibChev.CanMutateOwnedRegion(frame.box) then
return false
end
frame.url = url
frame.box:SetText(url)
frame:Show()
frame:Raise()
frame.box:SetFocus()
frame.box:HighlightText()
return true
end
function QuestTogether:ShowDialogPreview(kind)
if self:IsWorkBlocked("foreign_frame_mutation") then
self:Print(L("Dialog previews are unavailable while UI restrictions are active."))
return false
end
if kind == "unfollow" then
return self:ShowPartyFocusChangeDialog(L("Example Player"), function() end, true)
end
if kind == "focus" then
return self:ShowPartyFocusMissingDialog(
{ name = L("Example Player"), questID = 1, title = L("Example Quest") },
true
)
end
if kind == "partychat" then
return self:ShowPartyChatReminderPreview()
end
if kind == "discord" then
return self:OpenDiscordSupport()
end
if kind == "bubble" then
return self:ShowPersonalBubbleSettingsPreview()
end
local frame
if kind == "share" then
frame = self:CreatePartyQuestSharePrompt(true)
if not frame then
return false
end
frame.always:SetChecked(false)
frame.message:SetText(
string.format(
L("%s would like you to share\n[%s]\nwith the party."),
L("Example Player"),
L("Example Quest")
)
)
elseif kind == "join" then
frame = self:CreatePartyJoinPrompt(true)
if not frame then
return false
end
frame.friends:SetChecked(false)
frame.lfg:SetChecked(false)
frame.message:SetText(L("Example Player") .. L(" would like to join your party.\nSend an invitation?"))
else
self:PrintPreviewHelp()
return false
end
frame:LayoutRequest()
self:ApplyScrollDialogTheme(frame)
frame:Show()
return true
end
function QuestTogether:ClearPartyFocusMissingNotice()
self.partyFocusMissingNotice = nil
local frame = rawget(self, "partyFocusMissingDialog")
if frame and self.LibChev.CanMutateOwnedRegion(frame) then
frame:Hide()
end
end
function QuestTogether:QueuePartyFocusMissingNotice(name, questID, title)
local notice = { name = name, questID = questID, title = title }
self.partyFocusMissingNotice = notice
self:ScheduleDeferredWork("foreign_frame_mutation", "party_focus_missing", function()
if self.isEnabled and rawget(self, "partyFocusMissingNotice") == notice then
self:ShowPartyFocusMissingDialog(notice)
end
end, 0, "party focus missing quest")
end
local function RefreshPartyFocusMissingText(addon, frame, notice, preview)
local title = preview and notice.title
or addon:GetLocalizedQuestTitle(notice.questID)
or (notice.title and notice.title ~= "" and notice.title)
or addon:GetQuestTitle(notice.questID)
title = addon:NormalizeQuestDisplayTitleText(title)
if title == "" then title = L("Quest ") .. notice.questID end
frame.message:SetText(
string.format(
L(
"%s is tracking %s, which you don't have. Following has stopped. Your current navigation is unchanged.\n\nOpen Party Quest Log to request the quest, then follow this player again."
),
notice.name,
title
) .. (preview and ("\n\n" .. L("Preview - no settings will change.")) or "")
)
frame:LayoutManagedWindow()
end
function QuestTogether:OnPartyFocusTitleChanged(questID)
local notice, frame = rawget(self, "partyFocusMissingNotice"), rawget(self, "partyFocusMissingDialog")
if not self.isEnabled or self.isLoggingOut or not notice or notice.questID ~= questID or not frame then
return false
end
return self:ScheduleRuntimeWork("foreign_frame_mutation", "party_focus_title_changed", function()
if self.isEnabled and not self.isLoggingOut and rawget(self, "partyFocusMissingNotice") == notice
and rawget(self, "partyFocusMissingDialog") == frame and frame.notice == notice
and self:CanMutateOwnedUI(frame) and self:CanMutateOwnedUI(frame.message) and frame:IsShown() then
-- Update the current warning in place. A load completion is never a
-- request to show, raise, or recreate a dismissed or superseded dialog.
RefreshPartyFocusMissingText(self, frame, notice, false)
end
end, { mode = "nextFrame", reason = "party focus missing quest" })
end
function QuestTogether:ShowPartyFocusMissingDialog(notice, preview)
if self:IsWorkBlocked("foreign_frame_mutation") then
return false
end
local key = preview and "partyFocusMissingPreview" or "partyFocusMissingDialog"
local frame = rawget(self, key)
if not frame then
frame = self:CreateScrollDialog(650, 310, L("Quest following stopped"))
if not frame then
return false
end
self[key] = frame
frame.message = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
frame.message:SetPoint("TOPLEFT", frame.contentInset, -frame.contentTop)
frame.message:SetWidth(frame.contentWidth)
frame.message:SetJustifyH("LEFT")
frame.message:SetWordWrap(true)
self:AddScrollDialogLabel(frame, frame.message)
self:ConfigureWindowController(frame, {
dismiss = function()
if not preview then
self.partyFocusMissingNotice = nil
end
end,
})
local function Close()
self:DismissManagedWindow(frame)
end
frame.escapeAction = Close
frame.close = self:CreateOwnedWindowFrame("Button", nil, frame, "UIPanelCloseButton")
frame.close:SetPoint("TOPRIGHT", -12, -8)
frame.close:SetScript("OnClick", Close)
frame.open = self:CreateOwnedWindowFrame("Button", nil, frame, "UIPanelButtonTemplate")
frame.open:SetSize(240, 26)
frame.open:SetPoint("BOTTOMRIGHT", -frame.contentInset, frame.contentBottom)
frame.open:SetText(L("Open Party Quest Log"))
frame.open:SetScript("OnClick", function()
if self:IsWorkBlocked("foreign_frame_mutation") then
return
end
if preview then
self:OpenPartyQuestComparePreview()
else
self:OpenPartyQuestCompare()
end
Close()
end)
frame.LayoutManagedWindow = function()
frame.message:SetHeight(frame.message:GetStringHeight())
frame:SetHeight(
math.max(280, frame.contentTop + frame.message:GetStringHeight() + frame.contentBottom + 54)
)
self:FitScrollDialog(frame)
end
end
if not self.LibChev.CanMutateOwnedRegion(frame) or not self.LibChev.CanMutateOwnedRegion(frame.message) then
return false
end
frame.notice = notice
RefreshPartyFocusMissingText(self, frame, notice, preview)
self:ApplyScrollDialogTheme(frame)
frame:Show()
frame:Raise()
return true
end
-- The warning is also used by the isolated compare controller. Preview callbacks
-- can only change that controller, never the live party navigation model.
function QuestTogether:ShowPartyFocusChangeDialog(name, callback, preview, liveNavigation)
if self:IsWorkBlocked("foreign_frame_mutation") then
return false
end
local key = preview and "partyFocusChangePreview" or "partyFocusChangeDialog"
local frame = rawget(self, key)
if not frame then
frame = self:CreateScrollDialog(620, 300, L("Stop following quest focus?"))
if not frame then
return false
end
self[key] = frame
frame.message = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
frame.message:SetPoint("TOPLEFT", frame.contentInset, -frame.contentTop)
frame.message:SetWidth(frame.contentWidth)
frame.message:SetJustifyH("LEFT")
frame.message:SetWordWrap(true)
self:AddScrollDialogLabel(frame, frame.message)
self:ConfigureWindowController(frame, {
dismiss = function()
frame.confirmAction = nil
end,
})
local function Close()
self:DismissManagedWindow(frame)
end
frame.escapeAction = Close
frame.close = self:CreateOwnedWindowFrame("Button", nil, frame, "UIPanelCloseButton")
frame.close:SetPoint("TOPRIGHT", -12, -8)
frame.close:SetScript("OnClick", Close)
frame.cancel = self:CreateOwnedWindowFrame("Button", nil, frame, "UIPanelButtonTemplate")
frame.cancel:SetSize(160, 26)
frame.cancel:SetPoint("BOTTOMLEFT", frame.contentInset, frame.contentBottom)
frame.cancel:SetText(L("Cancel"))
frame.cancel:SetScript("OnClick", Close)
frame.confirm = self:CreateOwnedWindowFrame("Button", nil, frame, "UIPanelButtonTemplate")
frame.confirm:SetSize(220, 26)
frame.confirm:SetPoint("BOTTOMRIGHT", -frame.contentInset, frame.contentBottom)
frame.confirm:SetText(L("Change focus"))
frame.confirm:SetScript("OnClick", function()
if self:IsWorkBlocked("foreign_frame_mutation") then
return
end
local action = frame.confirmAction
Close()
if action then
action()
end
end)
frame.LayoutManagedWindow = function()
frame.message:SetHeight(frame.message:GetStringHeight())
frame:SetHeight(
math.max(260, frame.contentTop + frame.message:GetStringHeight() + frame.contentBottom + 54)
)
self:FitScrollDialog(frame)
end
end
if not self.LibChev.CanMutateOwnedRegion(frame) then
return false
end
frame.confirmAction = callback
frame.message:SetText(
string.format(L("Changing focus will stop following %s. Continue?"), name)
.. (
preview
and ("\n\n" .. (liveNavigation and L("Preview - quest focus changes affect your navigation.") or L(
"Preview - no settings will change."
)))
or ""
)
)
frame:LayoutManagedWindow()
self:ApplyScrollDialogTheme(frame)
frame:Show()
frame:Raise()
return true
end