add javascript binding and file picker for web

This commit is contained in:
2019-10-08 23:16:04 +02:00
parent f2a73a905d
commit a669d1313b
7 changed files with 228 additions and 135 deletions

View File

@@ -26,6 +26,8 @@ void destroy_window();
#elif __LINUX__
std::string linux_home_path();
int mkpath(const std::string& dir, mode_t mode = DEFFILEMODE);
#elif __WEB__
#include <unistd.h>
#endif
App* App::I = nullptr; // singleton
@@ -52,7 +54,7 @@ void App::create()
void App::open_document(std::string path)
{
std::regex r(R"((.*)[\\/]([^\\/]+)\.(\w+)$)");
std::regex r(R"((.*)[\\/]?([^\\/]+)\.(\w+)$)");
std::smatch m;
if (!std::regex_search(path, m, r))
return;
@@ -236,6 +238,14 @@ void App::initLog()
mkpath(data_path + "/patterns/thumbs");
mkpath(data_path + "/settings");
mkpath(data_path + "/frames");
#elif __WEB__
data_path = "/";
mkdir("/brushes", 0777);
mkdir("/brushes/thumbs", 0777);
mkdir("/patterns", 0777);
mkdir("/patterns/thumbs", 0777);
mkdir("/settings", 0777);
mkdir("/frames", 0777);
#endif
// TODO: save this path somewhere in the settings, don't overwrite every start