-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoopish_Main.lua
More file actions
59 lines (47 loc) · 1.43 KB
/
Copy pathLoopish_Main.lua
File metadata and controls
59 lines (47 loc) · 1.43 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
-- =========================================================
-- Loopish_Main.lua (ENTRY POINT)
-- =========================================================
local r = reaper
-- 1. SETUP PATHS
local info = debug.getinfo(1, 'S');
local script_path = info.source:match([[^@?(.*[\/])[^\/]-$]])
package.path = package.path .. ";" .. script_path .. "?.lua"
-- 2. DEV RELOAD (Optional: Remove in production)
-- Forces Lua to reload the modules every time you run the script action
package.loaded["Loopish_State"] = nil
package.loaded["Loopish_TrackManager"] = nil
package.loaded["Loopish_GUI"] = nil
-- 3. IMPORTS
local State = require("Loopish_State")
local TM = require("Loopish_TrackManager")
local GUI = require("Loopish_GUI")
-- 4. CONTEXT
local ctx = r.ImGui_CreateContext('Loopish')
-- 5. INITIALIZATION
local function OnInitialize()
if not r.APIExists('ImGui_GetVersion') then
r.ShowConsoleMsg("Error: ReaImGui extension not found.\n")
return false
end
-- Build state and sync hardware (Rec Arm)
TM.rebuild_state()
TM.force_sync_active_state()
return true
end
-- 6. LOOP
local function Main()
-- Run background logic
TM.on_defer_tick()
local visible, open = r.ImGui_Begin(ctx, 'Loopish', true)
if visible then
GUI.draw(ctx)
r.ImGui_End(ctx)
end
if open then
r.defer(Main)
end
end
-- 7. EXECUTE
if OnInitialize() then
r.defer(Main)
end