commit 1dc7e66f86e8d745f8b72a4d1d78fc92a4cdd7c1 parent 707ea8faeba92fadcf7f6c9a05af55247039641b Author: Andrew Costa <acosta@audiokinetic.com> Date: Fri, 7 Jul 2023 15:06:44 -0400 SP-3040: Various fixes for OpenAssociatedStrataProject script Change-Id: I21adc04ba0cf8c1cc5712331d316af7df5477cd9 Diffstat:
3 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/OpenAssociatedReaperProject/OpenAssociatedReaperProject_Install Wwise Command.lua b/OpenAssociatedReaperProject/OpenAssociatedReaperProject_Install Wwise Command.lua @@ -99,7 +99,7 @@ if utils.WindowsOS() then openInReaperPath = openInReaperPath:gsub("/", "\\") end -os.execute("mkdir "..openInReaperPath) +reaper.RecursiveCreateDirectory(openInReaperPath) openInReaperPath = openInReaperPath.."OpenAssociatedReaperProject.json" file, err = io.open(openInReaperPath, "w") diff --git a/OpenAssociatedReaperProject/OpenAssociatedReaperProject_Script.lua b/OpenAssociatedReaperProject/OpenAssociatedReaperProject_Script.lua @@ -26,15 +26,20 @@ local utils = dofile(scriptPath.."Utilities.lua") local tempProject, _ = reaper.EnumProjects( -1, "" ) local firstTrack = reaper.GetTrack(utils.CURRENT_PROJECT, 0) + +if not firstTrack then + reaper.ShowMessageBox("No audio file sent to REAPER!", "Open Associated REAPER Project: Failed", utils.OK_MESSAGE_BOX) + return +end + local mediaItemCount = reaper.CountTrackMediaItems(firstTrack) local mediaItem = reaper.GetTrackMediaItem(firstTrack, 0) local mediaItemTake = reaper.GetActiveTake(mediaItem) local pcmSource = reaper.GetMediaItemTake_Source(mediaItemTake) local filePath = reaper.GetMediaSourceFileName(pcmSource) - if not reaper.file_exists(filePath) then - reaper.ShowMessageBox("Unable to locate file `" .. filePath .. "`", "Open Associated REAPER Project: Failed", OK_MESSAGE_BOX) + reaper.ShowMessageBox("Unable to locate file `" .. filePath .. "`", "Open Associated REAPER Project: Failed", utils.OK_MESSAGE_BOX) return end diff --git a/OpenAssociatedReaperProject/Utilities.lua b/OpenAssociatedReaperProject/Utilities.lua @@ -84,15 +84,15 @@ end -- JS dependency check -- function Utilities.JSDependencyCheck() if not reaper.JS_Window_FindChildByID or not reaper.JS_Window_Find or not reaper.JS_Window_SetScrollPos or not reaper.JS_Dialog_BrowseForFolder then - local selectedOption = reaper.ShowMessageBox("The script requires the latest version of js_ReaScriptAPI be installed.\n\nView in ReaPack?", "Open Associated REAPER Project: Failed", OK_CANCEL_MESSAGE_BOX) + local selectedOption = reaper.ShowMessageBox("The script requires the latest version of js_ReaScriptAPI be installed.\n\nView in ReaPack?", "Open Associated REAPER Project: Failed", Utilities.OK_CANCEL_MESSAGE_BOX) - if selectedOption == OK_RESULT then + if selectedOption == Utilities.OK_RESULT then if reaper.ReaPack_BrowsePackages then reaper.ReaPack_BrowsePackages("js_ReaScriptAPI") else - selectedOption = reaper.ShowMessageBox("Unable to locate ReaPack. You can download ReaPack by going to https://reapack.com.\n\nGo there now?", "Open Associated REAPER Project: Failed", OK_CANCEL_MESSAGE_BOX) + selectedOption = reaper.ShowMessageBox("Unable to locate ReaPack. You can download ReaPack by going to https://reapack.com.\n\nGo there now?", "Open Associated REAPER Project: Failed", Utilities.OK_CANCEL_MESSAGE_BOX) - if selectedOption == OK_RESULT then + if selectedOption == Utilities.OK_RESULT then openUrl("https://reapack.com") end end