forked from EllesmereGaming/EllesmereUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEllesmereUI_PatchNotesPopup.lua
More file actions
334 lines (308 loc) · 14.4 KB
/
Copy pathEllesmereUI_PatchNotesPopup.lua
File metadata and controls
334 lines (308 loc) · 14.4 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
333
334
-------------------------------------------------------------------------------
-- EllesmereUI_PatchNotesPopup.lua
--
-- One-time login popup that announces the new Patch Notes section to EXISTING
-- users (people who already had EllesmereUI installed before this version) so
-- they know to check it after updating. Offers a "View Patch Notes" button that
-- opens the options panel straight to the Patch Notes page.
--
-- NEW users never see it. The new-vs-existing guarantee mirrors
-- EllesmereUI_RaidFramesPopup.lua: at the parent ADDON_LOADED, EllesmereUIDB
-- still reflects ONLY the previous session's data, because child addons have
-- not initialized their per-profile DBs yet this session. So a profile that
-- already carries `addons` data can only have come from a prior version =
-- an existing/upgrade user. A nil DB, or a DB with no prior addon data, is a
-- fresh install: we stamp it at login so it never fires later either.
--
-- Fires once, at PLAYER_LOGIN. Guarded by EllesmereUIDB.patchNotesIntroShown.
-- Defers behind the Raid Frames intro popup if that one is also pending (rare:
-- a user upgrading from pre-Raid-Frames straight to this build), so the two
-- never stack.
-------------------------------------------------------------------------------
local EllesmereUI = _G.EllesmereUI
if not EllesmereUI then return end
-- Suite-only: the Patch Notes page is never registered in single-module
-- standalone builds, so the announcement is meaningless there. Deriving this
-- from the host addon name (the `...` vararg = real folder name) is
-- rename-immune.
local EUI_HOST_ADDON = ...
local IS_STANDALONE = type(EUI_HOST_ADDON) == "string" and EUI_HOST_ADDON:find("Standalone") ~= nil
if IS_STANDALONE then return end
local PAGE_PATCHNOTES = "Patch Notes"
local PP = EllesmereUI.PanelPP
local MakeBorder = EllesmereUI.MakeBorder
local ELLESMERE_GREEN = EllesmereUI.ELLESMERE_GREEN
-------------------------------------------------------------------------------
-- Conflict-check handoff
-- For existing users the addon-conflict check auto-runs ~2s after load (gated
-- in EllesmereUI.lua on EllesmereUIDB.firstInstallPopupShown). We raise a
-- pending flag so that check defers while our popup is open, then trigger it
-- here on dismiss -- so the two popups never stack.
-------------------------------------------------------------------------------
local function ReleaseConflictCheck()
EllesmereUI._patchNotesIntroPending = nil
if EllesmereUIDB and EllesmereUIDB.firstInstallPopupShown and EllesmereUI._RunConflictCheck then
C_Timer.After(0.3, EllesmereUI._RunConflictCheck)
end
end
-------------------------------------------------------------------------------
-- The popup
-------------------------------------------------------------------------------
local function ShowPatchNotesPopup()
local FONT = EllesmereUI._font or ("Interface\\AddOns\\EllesmereUI\\media\\fonts\\Expressway.ttf")
local EG = ELLESMERE_GREEN
local POPUP_W, POPUP_H = 470, 372
local ppScale = (EllesmereUI.GetPopupScale and EllesmereUI.GetPopupScale()) or 1
-- Dimmer (eats clicks; no close on outside click)
local dimmer = CreateFrame("Frame", "EUIPatchNotesIntroDimmer", UIParent)
dimmer:SetFrameStrata("FULLSCREEN_DIALOG")
dimmer:SetAllPoints(UIParent)
dimmer:EnableMouse(true)
dimmer:EnableMouseWheel(true)
dimmer:SetScript("OnMouseWheel", function() end)
dimmer:SetScale(ppScale)
local dimTex = dimmer:CreateTexture(nil, "BACKGROUND")
dimTex:SetAllPoints()
dimTex:SetColorTexture(0, 0, 0, 0.35)
-- Panel
local popup = CreateFrame("Frame", "EUIPatchNotesIntroPopup", dimmer)
popup:SetScale(ppScale * 1.15)
popup:SetFrameStrata("FULLSCREEN_DIALOG")
popup:SetFrameLevel(dimmer:GetFrameLevel() + 10)
PP.Size(popup, POPUP_W, POPUP_H)
popup:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
popup:EnableMouse(true)
local bg = popup:CreateTexture(nil, "BACKGROUND")
bg:SetAllPoints()
bg:SetColorTexture(0.06, 0.08, 0.10, 1)
-- 1 physical-pixel white border (alpha 0.15). Thickness is derived from the
-- popup's effective scale (after the 1.15x SetScale above) so each edge stays
-- exactly one physical pixel on screen. Four edge textures, snap disabled.
local onePhys = 1 / (popup:GetEffectiveScale() or 1)
local BRD_A = 0.15
local function MakeEdge()
local t = popup:CreateTexture(nil, "BORDER")
t:SetColorTexture(1, 1, 1, BRD_A)
if t.SetSnapToPixelGrid then t:SetSnapToPixelGrid(false); t:SetTexelSnappingBias(0) end
return t
end
local spT = MakeEdge(); spT:SetPoint("TOPLEFT", 0, 0); spT:SetPoint("TOPRIGHT", 0, 0); spT:SetHeight(onePhys)
local spB = MakeEdge(); spB:SetPoint("BOTTOMLEFT", 0, 0); spB:SetPoint("BOTTOMRIGHT", 0, 0); spB:SetHeight(onePhys)
local spL = MakeEdge(); spL:SetPoint("TOPLEFT", spT, "BOTTOMLEFT"); spL:SetPoint("BOTTOMLEFT", spB, "TOPLEFT"); spL:SetWidth(onePhys)
local spR = MakeEdge(); spR:SetPoint("TOPRIGHT", spT, "BOTTOMRIGHT"); spR:SetPoint("BOTTOMRIGHT", spB, "TOPRIGHT"); spR:SetWidth(onePhys)
-- Decorative mini patch-note cards (header visual) -- two little hero cards
-- with a green top accent and stand-in text lines, previewing the real page.
local CARD_W, CARD_H, CARD_GAP = 168, 52, 16
local cardsW = 2 * CARD_W + CARD_GAP
local cardsLeft = (POPUP_W - cardsW) / 2
for i = 1, 2 do
local card = CreateFrame("Frame", nil, popup)
card:SetFrameLevel(popup:GetFrameLevel() + 1)
PP.Size(card, CARD_W, CARD_H)
PP.Point(card, "TOPLEFT", popup, "TOPLEFT", cardsLeft + (i - 1) * (CARD_W + CARD_GAP), -26)
local cbg = card:CreateTexture(nil, "BACKGROUND")
cbg:SetAllPoints()
cbg:SetColorTexture(0.12, 0.13, 0.15, 1)
-- 2px green top accent, matching the real hero cards
local accent = card:CreateTexture(nil, "ARTWORK")
accent:SetColorTexture(EG.r, EG.g, EG.b, 0.9)
accent:SetPoint("TOPLEFT", card, "TOPLEFT", 0, 0)
accent:SetPoint("TOPRIGHT", card, "TOPRIGHT", 0, 0)
accent:SetHeight(2)
-- Title line (wider, brighter) then two dimmer body lines.
local t1 = card:CreateTexture(nil, "ARTWORK")
t1:SetColorTexture(1, 1, 1, 0.55)
PP.Size(t1, CARD_W - 28, 6)
PP.Point(t1, "TOPLEFT", card, "TOPLEFT", 14, -16)
local t2 = card:CreateTexture(nil, "ARTWORK")
t2:SetColorTexture(1, 1, 1, 0.22)
PP.Size(t2, CARD_W - 56, 5)
PP.Point(t2, "TOPLEFT", t1, "BOTTOMLEFT", 0, -9)
local t3 = card:CreateTexture(nil, "ARTWORK")
t3:SetColorTexture(1, 1, 1, 0.16)
PP.Size(t3, CARD_W - 82, 5)
PP.Point(t3, "TOPLEFT", t2, "BOTTOMLEFT", 0, -6)
MakeBorder(card, 1, 1, 1, 0.10, PP)
end
-- Eyebrow
local eyebrow = popup:CreateFontString(nil, "OVERLAY")
eyebrow:SetFont(FONT, 13, "")
eyebrow:SetTextColor(EG.r, EG.g, EG.b, 0.9)
PP.Point(eyebrow, "TOP", popup, "TOP", 0, -98)
eyebrow:SetText("NEW")
-- Title
local title = popup:CreateFontString(nil, "OVERLAY")
title:SetFont(FONT, 26, "")
title:SetTextColor(1, 1, 1, 1)
PP.Point(title, "TOP", eyebrow, "BOTTOM", 0, -6)
title:SetText("Patch Notes")
-- Description
local desc = popup:CreateFontString(nil, "OVERLAY")
desc:SetFont(FONT, 15, "")
desc:SetTextColor(1, 1, 1, 0.5)
desc:SetWidth(POPUP_W - 80)
desc:SetJustifyH("CENTER")
desc:SetWordWrap(true)
PP.Point(desc, "TOP", title, "BOTTOM", 0, -12)
desc:SetText("Never miss an update again. The new Patch Notes section breaks down what's new each release, with quick links straight to every new setting.")
-- Feature bullets
local BULLETS = {
"See the highlights from every new update",
"Jump straight to any new setting in one click",
"Catch up on anything you may have missed",
}
local prev
for i, text in ipairs(BULLETS) do
local bl = popup:CreateFontString(nil, "OVERLAY")
bl:SetFont(FONT, 14, "")
bl:SetTextColor(1, 1, 1, 0.72)
bl:SetJustifyH("LEFT")
if i == 1 then
PP.Point(bl, "TOPLEFT", popup, "TOPLEFT", 92, -210)
else
PP.Point(bl, "TOPLEFT", prev, "BOTTOMLEFT", 0, -10)
end
bl:SetText(text)
local dot = popup:CreateTexture(nil, "OVERLAY")
dot:SetColorTexture(EG.r, EG.g, EG.b, 1)
PP.Size(dot, 5, 5)
PP.Point(dot, "RIGHT", bl, "LEFT", -10, 0)
prev = bl
end
-- Stamp + close. view=true opens the options panel to the Patch Notes page.
local function Finish(view)
if not EllesmereUIDB then EllesmereUIDB = {} end
EllesmereUIDB.patchNotesIntroShown = true
dimmer:Hide()
ReleaseConflictCheck()
if view then
if InCombatLockdown() then
EllesmereUI.Print("|cffff6060[EllesmereUI]|r Cannot open options during combat. Use /eui to view Patch Notes.")
return
end
if EllesmereUI.NavigateToElementSettings then
EllesmereUI:NavigateToElementSettings(EllesmereUI.GLOBAL_KEY or "_EUIGlobal", PAGE_PATCHNOTES, nil, nil, nil)
end
end
end
-- Bordered button matching the EUI style (primary = green, secondary = dim
-- white that brightens on hover).
local BTN_W, BTN_H, BTN_GAP = 184, 38, 14
local function MakeActionButton(text, r, g, b, secondary)
local btn = CreateFrame("Button", nil, popup)
btn:SetFrameLevel(popup:GetFrameLevel() + 2)
PP.Size(btn, BTN_W, BTN_H)
local bbg = btn:CreateTexture(nil, "BACKGROUND")
bbg:SetAllPoints()
bbg:SetColorTexture(0.06, 0.08, 0.10, 0.92)
local brd = MakeBorder(btn, r, g, b, secondary and 0.35 or 0.9, PP)
local lbl = btn:CreateFontString(nil, "OVERLAY")
lbl:SetFont(FONT, 15, "")
PP.Point(lbl, "CENTER", btn, "CENTER", 0, 0)
lbl:SetTextColor(r, g, b, secondary and 0.55 or 0.9)
lbl:SetText(text)
btn:SetScript("OnEnter", function()
lbl:SetTextColor(r, g, b, 1)
brd:SetColor(r, g, b, secondary and 0.6 or 1)
end)
btn:SetScript("OnLeave", function()
lbl:SetTextColor(r, g, b, secondary and 0.55 or 0.9)
brd:SetColor(r, g, b, secondary and 0.35 or 0.9)
end)
return btn
end
-- Primary "View Patch Notes" on the left, secondary "Maybe Later" on the
-- right, centered as a pair around the popup's bottom center.
local viewBtn = MakeActionButton("View Patch Notes", EG.r, EG.g, EG.b, false)
PP.Point(viewBtn, "BOTTOMRIGHT", popup, "BOTTOM", -BTN_GAP / 2, 40)
viewBtn:SetScript("OnClick", function() Finish(true) end)
local laterBtn = MakeActionButton("Maybe Later", 1, 1, 1, true)
PP.Point(laterBtn, "BOTTOMLEFT", popup, "BOTTOM", BTN_GAP / 2, 40)
laterBtn:SetScript("OnClick", function() Finish(false) end)
-- Footnote
local footnote = popup:CreateFontString(nil, "OVERLAY")
footnote:SetFont(FONT, 12, "")
footnote:SetTextColor(1, 1, 1, 0.35)
footnote:SetWidth(POPUP_W - 80)
footnote:SetJustifyH("CENTER")
PP.Point(footnote, "BOTTOM", popup, "BOTTOM", 0, 16)
footnote:SetText("Open it anytime from Global Settings > Patch Notes.")
-- Escape = Maybe Later (the non-committal default). Consume Escape, propagate
-- other keys so chat/UI shortcuts still work behind the dimmer.
popup:EnableKeyboard(true)
popup:SetScript("OnKeyDown", function(self, key)
self:SetPropagateKeyboardInput(key ~= "ESCAPE")
if key == "ESCAPE" then Finish(false) end
end)
dimmer:Show()
end
EllesmereUI.ShowPatchNotesIntroPopup = ShowPatchNotesPopup
-------------------------------------------------------------------------------
-- Trigger: existing users only, once, at login
--
-- Decision is captured at the parent ADDON_LOADED, while EllesmereUIDB still
-- holds only the previous session's data:
-- "show" -> existing/upgrade user (a profile already carries addon data)
-- "new" -> fresh install (nil DB, or DB with no prior addon data); stamp
-- at login so it never fires later
-- "done" -> already shown before
-------------------------------------------------------------------------------
local _decision
local function ComputeDecision()
if not EllesmereUIDB then
-- No SavedVariables at all -> brand-new first session.
return "new"
end
if EllesmereUIDB.patchNotesIntroShown then
return "done"
end
local profiles = EllesmereUIDB.profiles
if type(profiles) == "table" then
for _, prof in pairs(profiles) do
if type(prof) == "table" and type(prof.addons) == "table" and next(prof.addons) then
-- Data from a previous session = existing/upgrade user.
return "show"
end
end
end
-- DB exists but carries no prior addon data -> treat as fresh, stamp now.
EllesmereUIDB.patchNotesIntroShown = true
return "new"
end
local loader = CreateFrame("Frame")
loader:RegisterEvent("ADDON_LOADED")
loader:RegisterEvent("PLAYER_LOGIN")
loader:SetScript("OnEvent", function(self, event, addonName)
if event == "ADDON_LOADED" then
if addonName ~= "EllesmereUI" then return end
self:UnregisterEvent("ADDON_LOADED")
_decision = ComputeDecision()
if _decision == "show" then
-- Hold the auto conflict check until our popup is dismissed.
EllesmereUI._patchNotesIntroPending = true
end
elseif event == "PLAYER_LOGIN" then
self:UnregisterEvent("PLAYER_LOGIN")
if _decision == "new" then
-- Stamp brand-new users so the popup never fires in a later session.
if not EllesmereUIDB then EllesmereUIDB = {} end
EllesmereUIDB.patchNotesIntroShown = true
return
end
if _decision ~= "show" then return end
local function TryShow()
if EllesmereUIDB and EllesmereUIDB.patchNotesIntroShown then
ReleaseConflictCheck()
return
end
-- Defer behind the Raid Frames intro popup if it is still pending or
-- open, so the two announcements never stack on a single login.
if EllesmereUI._raidFramesIntroPending then
C_Timer.After(0.4, TryShow)
return
end
ShowPatchNotesPopup()
end
C_Timer.After(0.5, TryShow)
end
end)