--[[ Noindex: true ]] -- Script generated by Lokasenna's GUI Builder function Msg(param) reaper.ShowConsoleMsg(tostring(param) .. "\n") end -- OS INFO platform = reaper.GetOS() if platform == "OSX64" or platform == "OSX32" or platform == "OSX" or platform == "Other" or platform == "macOS-arm64" then separator = [[/]] else separator = [[\]] -- win end bin = "x64" if platform == "Win32" or platform == "OSX32" then bin = "x86" end reaper.Undo_BeginBlock() -- OS INFO platform = reaper.GetOS() if platform == "OSX64" or platform == "OSX32" or platform == "OSX" or platform == "Other" then separator = [[/]] else separator = [[\]] -- win end local info = debug.getinfo(1, 'S'); script_path = info.source:match [[^@?(.*[\/])[^\/]-$]] -- LOAD/SAVE SETTINGS MODULE loadfile(script_path .. [[Data]] .. separator .. bin .. separator .. "lkc_grimsync_shared_functions.dll")() -- LOAD LIBRARY FOR LOADING AND SAVING SETTINGS local CUR_SETTINGS, READ_FROM = WSHARED.GetAllSettings() ALLOWED_HIER_TYPES = { WorkUnit = true, ActorMixer = true, RandomSequenceContainer = true, SwitchContainer = true, BlendContainer = true, Folder = true, MusicSwitchContainer = true, MusicSegment = true, MusicPlaylistContainer = true } local AM_COLOR = reaper.ColorToNative(64, 181, 206) | 0x1000000 local IM_COLOR = reaper.ColorToNative(139, 45, 193) | 0x1000000 local EV_COLOR = reaper.ColorToNative(247, 150, 19) | 0x1000000 if reaper.HasExtState(WSHARED.INI_SECTION_NAME, "AM_COLOR") then AM_COLOR = tonumber(reaper.GetExtState(WSHARED.INI_SECTION_NAME, "AM_COLOR")) end if reaper.HasExtState(WSHARED.INI_SECTION_NAME, "IM_COLOR") then IM_COLOR = tonumber(reaper.GetExtState(WSHARED.INI_SECTION_NAME, "IM_COLOR")) end if reaper.HasExtState(WSHARED.INI_SECTION_NAME, "EV_COLOR") then EV_COLOR = tonumber(reaper.GetExtState(WSHARED.INI_SECTION_NAME, "EV_COLOR")) end -- AM_COLOR = reaper.ImGui_ColorConvertNative(AM_COLOR) -- IM_COLOR = reaper.ImGui_ColorConvertNative(IM_COLOR) -- EV_COLOR = reaper.ImGui_ColorConvertNative(EV_COLOR) -- RUN GrimSync GET command = "\"" .. script_path .. "bin\\GrimSync.exe\" --get " .. CUR_SETTINGS.waapi_connection_link os.execute(command) log = io.open(script_path .. "bin\\GrimSync.log", "r") output = log:read("*all") output = string.match(output, ">>>(.*)<<<") log:close() if output then -- Msg(output) name = string.match(output, "\"name\":\"(.-)\"") -- {"name":"pop"}, path = string.match(output, "\"path\":\"(.-)\"") -- {"path":"pop"}, guid = string.match(output, "\"guid\":\"(.-)\"") -- {"guid":"pop"}, ttype = string.match(output, "\"type\":\"(.-)\"") -- {"type":"pop"} originals = "" events_subpath = "" if CUR_SETTINGS.orig_path_type == 1 then originals = string.match(output, "\"originals\":\"(.-)\"") end if CUR_SETTINGS.event_path_type == 1 then events_subpath = string.match(output, "\"events_subpath\":\"(.-)\"") end -- Msg("NAME:"..name) -- Msg("GUID:"..guid) -- Msg("PATH:"..path) -- Msg("TYPE:"..ttype) SET = true if ALLOWED_HIER_TYPES[ttype] ~= true then reaper.ShowMessageBox("Invalid Wwise object type selected: " .. tostring(ttype) .. "\nPlease choose compatible container and try again.\nSelected: " .. path, "Error", 0) return end if string.match(path, "^\\Actor%-Mixer Hierarchy") ~= nil then -- Msg("CONTAINERS") color = AM_COLOR region_name = "{CONTAINERS=" .. name .. "}:" .. path .. "," .. guid .. "," .. "[ORIGINALS=" .. originals .. "]" .. "," .. "[EVENTS_SUBPATH=" .. events_subpath .. "],[TYPE=" .. ttype .. "]" container_name = name elseif string.match(path, "^\\Events") ~= nil then -- Msg("EVENTS") color = EV_COLOR region_name = "{EVENTS=" .. name .. "}:" .. path elseif string.match(path, "^\\Interactive Music Hierarchy") ~= nil then -- Msg("MUSIC") color = IM_COLOR region_name = "{CONTAINERS=" .. name .. "}:" .. path .. "," .. guid .. "," .. "[ORIGINALS=" .. originals .. "]" .. "," .. "[EVENTS_SUBPATH=" .. events_subpath .. "],[TYPE=" .. ttype .. "]" else SET = false reaper.ShowMessageBox( "Invalid Wwise object type selected!\nChoose either Actor-Mixer, Interactive Music or Events hierarchy!\nSelected: " .. path, "Error", 0) return end if SET then start_pos, end_pos = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false) if start_pos - end_pos ~= 0 then -- start_pos = start_pos -- end_pos = end_pos else start_pos = reaper.GetCursorPosition() end_pos = start_pos + 10 end reaper.AddProjectMarker2(0, true, start_pos, end_pos, region_name, 0, color) end else reaper.ShowMessageBox("Can't detect selected Wwise object!", "Error", 0) end reaper.Undo_EndBlock("LKC - Grim Sync - Create link region", -1) reaper.UpdateArrange() -- vraca output -- vidi se blank cmd