Update for async API breaking change, adding default filename

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-07-06 23:39:50 +01:00
parent 26785f2d75
commit 4c326f5f39
23 changed files with 96 additions and 34 deletions

View file

@ -147,8 +147,8 @@ void loadDialog()
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
DISTRHO_NAMESPACE::FileBrowserOptions opts;
opts.startDir = dir.c_str();
opts.saving = ui->saving = false;
opts.startDir = dir.c_str();
opts.title = "Open patch";
ui->openFileBrowser(opts);
});
@ -177,7 +177,7 @@ void loadSelectionDialog()
std::string selectionDir = asset::user("selections");
system::createDirectories(selectionDir);
async_dialog_filebrowser(false, selectionDir.c_str(), "Import selection", [w](char* pathC) {
async_dialog_filebrowser(false, nullptr, selectionDir.c_str(), "Import selection", [w](char* pathC) {
if (!pathC) {
// No path selected
return;
@ -250,8 +250,9 @@ static void saveAsDialog(const bool uncompressed)
DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
DISTRHO_NAMESPACE::FileBrowserOptions opts;
opts.startDir = dir.c_str();
opts.saving = ui->saving = true;
opts.defaultName = "patch.vcv";
opts.startDir = dir.c_str();
opts.title = "Save patch";
ui->savingUncompressed = uncompressed;
ui->openFileBrowser(opts);
@ -286,6 +287,7 @@ void openBrowser(const std::string& url)
}
void async_dialog_filebrowser(const bool saving,
const char* const defaultName,
const char* const startDir,
const char* const title,
const std::function<void(char* path)> action)
@ -302,6 +304,7 @@ void async_dialog_filebrowser(const bool saving,
DISTRHO_NAMESPACE::FileBrowserOptions opts;
opts.saving = saving;
opts.defaultName = defaultName;
opts.startDir = startDir;
opts.title = title;

View file

@ -65,7 +65,7 @@ static void CardinalModuleWidget__loadDialog(ModuleWidget* const w)
WeakPtr<ModuleWidget> weakThis = w;
async_dialog_filebrowser(false, presetDir.c_str(), "Load preset", [=](char* pathC) {
async_dialog_filebrowser(false, nullptr, presetDir.c_str(), "Load preset", [=](char* pathC) {
// Delete directories if empty
DEFER({
try {
@ -100,7 +100,7 @@ void CardinalModuleWidget__saveDialog(ModuleWidget* const w)
WeakPtr<ModuleWidget> weakThis = w;
async_dialog_filebrowser(true, presetDir.c_str(), "Save preset", [=](char* pathC) {
async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) {
// Delete directories if empty
DEFER({
try {
@ -281,7 +281,13 @@ static void CardinalModuleWidget__saveSelectionDialog(RackWidget* const w)
std::string selectionDir = asset::user("selections");
system::createDirectories(selectionDir);
async_dialog_filebrowser(true, selectionDir.c_str(), "Save selection as", [w](char* pathC) {
async_dialog_filebrowser(true, "selection.vcvs", selectionDir.c_str(),
#ifdef DISTRHO_OS_WASM
"Save selection",
#else
"Save selection as...",
#endif
[w](char* pathC) {
if (!pathC) {
// No path selected
return;

View file

@ -182,6 +182,17 @@ public:
}
}
#ifdef DISTRHO_OS_WASM
asyncDialog::create("Welcome!\n"
"This is a special web-assembly version of Cardinal, "
"allowing you to enjoy eurorack-style modules directly in your browser.\n"
"\n"
"This is still very much a work in progress, "
"minor issues and occasional crashes are expected.\n"
"\n"
"Proceed with caution and have fun!");
#endif
context->window->step();
rack::contextSet(nullptr);

View file

@ -208,9 +208,8 @@ ifeq ($(WASM),true)
LINK_FLAGS += --preload-file=./jsfx
LINK_FLAGS += --preload-file=./resources
LINK_FLAGS += -sALLOW_MEMORY_GROWTH
LINK_FLAGS += -sEXPORTED_RUNTIME_METHODS=FS,cwrap
LINK_FLAGS += -sINITIAL_MEMORY=64Mb
# LINK_FLAGS += -sLZ4=1
LINK_FLAGS += -sLZ4=1
LINK_FLAGS += --shell-file=../emscripten/shell.html
else ifeq ($(HAIKU),true)
LINK_FLAGS += -lpthread