-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompat.lua
More file actions
64 lines (54 loc) · 2.24 KB
/
Copy pathCompat.lua
File metadata and controls
64 lines (54 loc) · 2.24 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
local addonName, NS = ...
local Compat = {}
local function Detect(env)
env = env or _G
local projectID = env.WOW_PROJECT_ID
local isRetail = projectID ~= nil and projectID == env.WOW_PROJECT_MAINLINE
local isClassicEra = projectID ~= nil and projectID == env.WOW_PROJECT_CLASSIC
local isTBCAnniversary = projectID ~= nil and projectID == env.WOW_PROJECT_BURNING_CRUSADE_CLASSIC
-- Mists of Pandaria Classic (5.5.x) runs on the modern engine: it ships the
-- ScrollBox suite, PortraitFrameTemplate, and the modern Settings API, so it
-- takes the modern UI path and is deliberately NOT folded into isClassicFamily
-- (which selects the reduced FauxScroll / plain-chrome / color-glyph
-- fallbacks). Verified in-game on 5.5.x — the modern History panel renders
-- correctly. (BSP-065)
local isMistsClassic = projectID ~= nil and projectID == env.WOW_PROJECT_MISTS_CLASSIC
local isClassicFamily = isClassicEra or isTBCAnniversary
local hasModernHistoryList =
type(env.CreateScrollBoxListLinearView) == "function"
and type(env.CreateDataProvider) == "function"
and type(env.ScrollUtil) == "table"
and type(env.ScrollUtil.InitScrollBoxListWithScrollBar) == "function"
local hasClassicHistoryList =
type(env.FauxScrollFrame_Update) == "function"
and type(env.FauxScrollFrame_OnVerticalScroll) == "function"
and type(env.FauxScrollFrame_GetOffset) == "function"
local hasChatReportDialog =
type(env.PlayerLocation) == "table"
and type(env.PlayerLocation.CreateFromChatLineID) == "function"
and type(env.C_ReportSystem) == "table"
and type(env.C_ReportSystem.OpenReportPlayerDialog) == "function"
and env.PLAYER_REPORT_TYPE_SPAM ~= nil
return {
addonName = addonName,
isRetail = isRetail,
isClassicEra = isClassicEra,
isTBCAnniversary = isTBCAnniversary,
isMistsClassic = isMistsClassic,
isClassicFamily = isClassicFamily,
hasModernHistoryList = hasModernHistoryList,
hasClassicHistoryList = hasClassicHistoryList,
hasChatReportDialog = hasChatReportDialog,
}
end
function Compat.Detect(env)
return Detect(env)
end
local runtime = Detect(_G)
for key, value in pairs(runtime) do
Compat[key] = value
end
if type(NS) == "table" then
NS.Compat = Compat
end
return Compat