Show warning to user in GUI if resources are not found

This commit is contained in:
falkTX 2022-01-01 18:16:25 +00:00
parent d5d2d5befc
commit 72274a3663
2 changed files with 28 additions and 3 deletions

View file

@ -120,9 +120,10 @@ struct Initializer
{
templatePath = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "template.vcv";
}
else
// If source code dir does not exist use install target prefix as system dir
else
#endif
if (system::exists(CARDINAL_PLUGIN_PREFIX "/share/Cardinal"))
{
asset::bundlePath = CARDINAL_PLUGIN_PREFIX "/share/Cardinal/PluginManifests";
asset::systemDir = CARDINAL_PLUGIN_PREFIX "/share/Cardinal";
@ -142,8 +143,13 @@ struct Initializer
INFO("User directory: %s", asset::userDir.c_str());
INFO("Template patch: %s", templatePath.c_str());
// Check existence of the system res/ directory
if (! system::exists(asset::systemDir))
// Report to user if something is wrong with the installation
if (asset::systemDir.empty())
{
d_stderr2("Failed to locate Cardinal plugin bundle.\n"
"Install Cardinal with its bundle folder intact and try again.");
}
else if (! system::exists(asset::systemDir))
{
d_stderr2("System directory \"%s\" does not exist.\n"
"Make sure Cardinal was downloaded and installed correctly.", asset::systemDir.c_str());

View file

@ -16,6 +16,7 @@
*/
#include <app/Scene.hpp>
#include <asset.hpp>
#include <context.hpp>
#include <helpers.hpp>
#include <patch.hpp>
@ -298,6 +299,24 @@ public:
rack::widget::Widget* const libraryButton = headerLayout->children.back();
libraryButton->hide();
// Report to user if something is wrong with the installation
std::string errorMessage;
if (rack::asset::systemDir.empty())
{
errorMessage = "Failed to locate Cardinal plugin bundle.\n"
"Install Cardinal with its plugin bundle folder intact and try again.";
}
else if (! rack::system::exists(rack::asset::systemDir))
{
errorMessage = rack::string::f("System directory \"%s\" does not exist. "
"Make sure Cardinal was downloaded and installed correctly.",
rack::asset::systemDir.c_str());
}
if (! errorMessage.empty())
asyncDialog::create(errorMessage.c_str());
context->window->step();
rack::contextSet(nullptr);