Skip to content

Commit d68b996

Browse files
authored
Open files on everything except macOS standalone (#297)
1 parent cbb69c3 commit d68b996

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

NeuralAmpModeler/NeuralAmpModeler.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,19 @@ NeuralAmpModeler::NeuralAmpModeler(const InstanceInfo& info)
223223
}
224224
};
225225

226-
pGraphics->AttachControl(new NAMFileBrowserControl(modelArea, kMsgTagClearModel, "Select model directory...", "nam",
227-
loadModelCompletionHandler, style, fileSVG, closeButtonSVG,
228-
leftArrowSVG, rightArrowSVG),
226+
#ifdef NAM_PICK_DIRECTORY
227+
const std::string defaultNamFileString = "Select model directory...";
228+
const std::string defaultIRString = "Select IR directory...";
229+
#else
230+
const std::string defaultNamFileString = "Select model...";
231+
const std::string defaultIRString = "Select IR...";
232+
#endif
233+
pGraphics->AttachControl(new NAMFileBrowserControl(modelArea, kMsgTagClearModel, defaultNamFileString.c_str(),
234+
"nam", loadModelCompletionHandler, style, fileSVG,
235+
closeButtonSVG, leftArrowSVG, rightArrowSVG),
229236
kCtrlTagModelFileBrowser);
230237
pGraphics->AttachControl(
231-
new NAMFileBrowserControl(irArea, kMsgTagClearIR, "Select IR directory...", "wav", loadIRCompletionHandler, style,
238+
new NAMFileBrowserControl(irArea, kMsgTagClearIR, defaultIRString.c_str(), "wav", loadIRCompletionHandler, style,
232239
fileSVG, closeButtonSVG, leftArrowSVG, rightArrowSVG),
233240
kCtrlTagIRFileBrowser);
234241

NeuralAmpModeler/NeuralAmpModelerControls.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
202202
WDL_String fileName;
203203
WDL_String path;
204204
GetSelectedFileDirectory(path);
205+
#ifdef NAM_PICK_DIRECTORY
205206
pCaller->GetUI()->PromptForDirectory(path, [&](const WDL_String& fileName, const WDL_String& path) {
206207
if (path.GetLength())
207208
{
@@ -212,6 +213,19 @@ class NAMFileBrowserControl : public IDirBrowseControlBase
212213
LoadFileAtCurrentIndex();
213214
}
214215
});
216+
#else
217+
pCaller->GetUI()->PromptForFile(
218+
fileName, path, EFileAction::Open, mExtension.Get(), [&](const WDL_String& fileName, const WDL_String& path) {
219+
if (fileName.GetLength())
220+
{
221+
ClearPathList();
222+
AddPath(path.Get(), "");
223+
SetupMenu();
224+
SetSelectedFile(fileName.Get());
225+
LoadFileAtCurrentIndex();
226+
}
227+
});
228+
#endif
215229
};
216230

217231
auto clearFileFunc = [&](IControl* pCaller) {

NeuralAmpModeler/config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@
7373
#define TOGGLEIR2X_FN "[email protected]"
7474
#define TOGGLE_HANDLE_FN "SkinEHeritage_ToggleHandle.png"
7575
#define TOGGLE_HANDLE2X_FN "[email protected]"
76+
77+
// Issue 291
78+
// On the macOS standalone, we might not have permissions to traverse the file directory, so we have the app ask the
79+
// user to pick a directory instead of the file in the directory.
80+
// Everyone else is fine though.
81+
#if defined(APP_API) && defined(__APPLE__)
82+
#define NAM_PICK_DIRECTORY
83+
#endif

0 commit comments

Comments
 (0)