forked from ReaTeam/ReaScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfillion_Show ReaPack about dialog for the focused JSFX.lua
69 lines (58 loc) · 1.84 KB
/
cfillion_Show ReaPack about dialog for the focused JSFX.lua
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
-- @description Show ReaPack about dialog for the focused JSFX
-- @author cfillion
-- @version 0.1
-- @link https://cfillion.ca
-- @donation https://www.paypal.me/cfillion
local script = ({reaper.get_action_context()})[2]:match('([^/\\_]+).lua$')
function ShowMsg(msg)
reaper.MB(msg, script, 0);
end
if not reaper.ReaPack_AboutInstalledPackage then
return ShowMsg('ReaPack v1.2+ is required to use this script.')
end
local fxtype, trackidx, itemidx, fxidx = reaper.GetFocusedFX()
local getchunk = ({
function()
local track
if trackidx == 0 then
track = reaper.GetMasterTrack(0)
else
track = reaper.GetTrack(0, trackidx - 1)
end
return reaper.GetTrackStateChunk(track, '')
end,
function()
local track = reaper.GetTrack(0, trackidx - 1)
local item = reaper.GetTrackMediaItem(track, itemidx)
return reaper.GetItemStateChunk(item, '', false)
end,
})[fxtype]
if not getchunk then return end
local ok, chunk = getchunk()
if not ok then return end
local name, type = ({function()
local index = 0
for type, file in chunk:gmatch("BYPASS %d+ %d+ %d+\n<([^%s]+) ([^\n]+)") do
if index == fxidx & 0xFFFF then
if type == 'JS' then
if file:sub(1, 1) == '"' then
return file:match('^"([^"]+)"'), type
else
return file:match('^[^%s]+'), type
end
else
return nil, type
end
end
index = index + 1
end
end})[1]()
if not name then
return ShowMsg(string.format('Documentation for %s plugins is not supported. Try again with a JSFX focused.', type))
end
local owner = reaper.ReaPack_GetOwner(string.format('Effects/%s', name))
if not owner then
return ShowMsg(string.format("Documentation cannot be found because ReaPack does not know about the JSFX at '%s'.", name))
end
reaper.ReaPack_AboutInstalledPackage(owner)
reaper.ReaPack_FreeEntry(owner)