@@ -1 +1 @@ | |||||
Subproject commit eca8056dc29865bbcbcab0dc6494b20dd459c7ad | |||||
Subproject commit 1af66e49db01b5e2a5f90e85fe748c162bb83a48 |
@@ -31,6 +31,11 @@ | |||||
#include <osdialog.h> | #include <osdialog.h> | ||||
#ifdef NDEBUG | |||||
# undef DEBUG | |||||
#endif | |||||
#include "DistrhoPluginUtils.hpp" | |||||
#include "PluginContext.hpp" | #include "PluginContext.hpp" | ||||
#include "WindowParameters.hpp" | #include "WindowParameters.hpp" | ||||
#include "extra/Base64.hpp" | #include "extra/Base64.hpp" | ||||
@@ -63,26 +68,41 @@ struct Initializer { | |||||
settings::threadCount = 1; | settings::threadCount = 1; | ||||
system::init(); | system::init(); | ||||
asset::init(); | |||||
logger::init(); | logger::init(); | ||||
random::init(); | random::init(); | ||||
ui::init(); | ui::init(); | ||||
// Make system dir point to source code location. It is good enough for now | |||||
asset::systemDir = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "Rack"; | |||||
std::string resDir; | |||||
if (const char* const bundlePath = plugin->getBundlePath()) | |||||
{ | |||||
asset::systemDir = bundlePath; | |||||
#ifdef DISTRHO_OS_MAC | |||||
asset::systemDir += "/Contents/Resources"; | |||||
#endif | |||||
} | |||||
else | |||||
{ | |||||
// Make system dir point to source code location as fallback | |||||
// TODO use /usr/share if on linux? if we count on it being installed.. | |||||
asset::systemDir = CARDINAL_PLUGIN_SOURCE_DIR DISTRHO_OS_SEP_STR "Rack" DISTRHO_OS_SEP_STR "res"; | |||||
} | |||||
asset::userDir = asset::systemDir; | |||||
// Log environment | // Log environment | ||||
INFO("%s %s v%s", APP_NAME.c_str(), APP_EDITION.c_str(), APP_VERSION.c_str()); | INFO("%s %s v%s", APP_NAME.c_str(), APP_EDITION.c_str(), APP_VERSION.c_str()); | ||||
INFO("%s", system::getOperatingSystemInfo().c_str()); | INFO("%s", system::getOperatingSystemInfo().c_str()); | ||||
INFO("Binary filename: %s", getBinaryFilename()); | |||||
INFO("Bundle path: %s", plugin->getBundlePath()); | |||||
INFO("System directory: %s", asset::systemDir.c_str()); | INFO("System directory: %s", asset::systemDir.c_str()); | ||||
INFO("User directory: %s", asset::userDir.c_str()); | INFO("User directory: %s", asset::userDir.c_str()); | ||||
// Check existence of the system res/ directory | // Check existence of the system res/ directory | ||||
const std::string resDir = asset::system("res"); | |||||
if (! system::isDirectory(resDir)) | |||||
if (! system::isDirectory(asset::systemDir)) | |||||
{ | { | ||||
d_stderr2("Resource directory \"%s\" does not exist.\n" | |||||
"Make sure Cardinal was downloaded and installed correctly.", resDir.c_str()); | |||||
d_stderr2("System directory \"%s\" does not exist.\n" | |||||
"Make sure Cardinal was downloaded and installed correctly.", asset::systemDir.c_str()); | |||||
} | } | ||||
INFO("Initializing audio driver"); | INFO("Initializing audio driver"); | ||||
@@ -88,13 +88,18 @@ class CardinalUI : public UI, | |||||
public: | public: | ||||
CardinalUI() | CardinalUI() | ||||
: UI(1280, 720), | |||||
: UI(1228, 666), | |||||
fContext(getRackContextFromPlugin(getPluginInstancePointer())), | fContext(getRackContextFromPlugin(getPluginInstancePointer())), | ||||
fResizeHandle(this) | fResizeHandle(this) | ||||
{ | { | ||||
if (isResizable()) | if (isResizable()) | ||||
fResizeHandle.hide(); | fResizeHandle.hide(); | ||||
const double scaleFactor = getScaleFactor(); | |||||
if (scaleFactor != 1) | |||||
setSize(1228 * scaleFactor, 666 * scaleFactor); | |||||
fContext->window = new rack::window::Window; | fContext->window = new rack::window::Window; | ||||
{ | { | ||||
@@ -47,7 +47,7 @@ endif | |||||
FILES_DSP += $(wildcard Rack/src/*.c) | FILES_DSP += $(wildcard Rack/src/*.c) | ||||
FILES_DSP += $(wildcard Rack/src/*/*.c) | FILES_DSP += $(wildcard Rack/src/*/*.c) | ||||
FILES_DSP += $(filter-out Rack/src/common.cpp Rack/src/dep.cpp Rack/src/discord.cpp Rack/src/gamepad.cpp Rack/src/keyboard.cpp Rack/src/library.cpp Rack/src/network.cpp Rack/src/rtaudio.cpp Rack/src/rtmidi.cpp, $(wildcard Rack/src/*.cpp)) | |||||
FILES_DSP += $(filter-out Rack/src/asset.cpp Rack/src/common.cpp Rack/src/dep.cpp Rack/src/discord.cpp Rack/src/gamepad.cpp Rack/src/keyboard.cpp Rack/src/library.cpp Rack/src/network.cpp Rack/src/rtaudio.cpp Rack/src/rtmidi.cpp, $(wildcard Rack/src/*.cpp)) | |||||
FILES_DSP += $(filter-out Rack/src/window/Window.cpp, $(wildcard Rack/src/*/*.cpp)) | FILES_DSP += $(filter-out Rack/src/window/Window.cpp, $(wildcard Rack/src/*/*.cpp)) | ||||
# -------------------------------------------------------------- | # -------------------------------------------------------------- | ||||
@@ -71,6 +71,34 @@ Exception::Exception(const char* format, ...) | |||||
} | } | ||||
} | } | ||||
// Custom assets location | |||||
#include <algorithm> | |||||
#include <asset.hpp> | |||||
#include <system.hpp> | |||||
#include <plugin/Plugin.hpp> | |||||
namespace rack { | |||||
namespace asset { | |||||
std::string systemDir; | |||||
std::string userDir; | |||||
std::string bundlePath; | |||||
static inline std::string& trim(std::string& s) { | |||||
if (std::strncmp(s.c_str(), "res" DISTRHO_OS_SEP_STR, 4) == 0) | |||||
s = s.substr(4, s.size()-4); | |||||
return s; | |||||
} | |||||
std::string system(std::string filename) { | |||||
return system::join(systemDir, trim(filename)); | |||||
} | |||||
std::string user(std::string filename) { | |||||
return system::join(userDir, trim(filename)); | |||||
} | |||||
std::string plugin(plugin::Plugin* plugin, std::string filename) { | |||||
DISTRHO_SAFE_ASSERT_RETURN(plugin != nullptr, {}); | |||||
return system::join(systemDir, plugin->path, trim(filename)); | |||||
} | |||||
} | |||||
} | |||||
// Define the stuff needed for VCVRack but unused for Cardinal | // Define the stuff needed for VCVRack but unused for Cardinal | ||||
#include <library.hpp> | #include <library.hpp> | ||||
#include <network.hpp> | #include <network.hpp> | ||||