void FileDialog_export_textures(EditorState *state)
{
	std::string path = getSaveLoadDirectory(state->settings->get("save_directory"),
			state->isInstalled);

	const char *cdir = tinyfd_selectFolderDialog ("Select Folder", path.c_str());

	if (!cdir)
		return;

	std::string dir = trim(cdir);

	if (dir == "")
		return;

	dir = cleanDirectoryPath(dir);
	export_textures(dir, state);
}
void FileDialog_export_mod(EditorState *state)
{
	std::string path = getSaveLoadDirectory(state->settings->get("save_directory"),
			state->isInstalled);

	const char *cdir = tinyfd_selectFolderDialog ("Select Folder", path.c_str());

	if (!cdir)
		return;

	std::string dir = trim(cdir);

	if (dir == "")
		return;

	dir = cleanDirectoryPath(dir);
	export_textures(dir + "textures/", state);

	FileFormat *writer = getFromType(FILE_FORMAT_LUA, state);
	save_file(writer, state, dir + "init.lua");
}
Exemple #3
0
	std::wstring* FileDialog::OpenDirectory (std::wstring* title, std::wstring* filter, std::wstring* defaultPath) {

		// TODO: Filter?

		#ifdef HX_WINDOWS

		const wchar_t* path = tinyfd_selectFolderDialogW (title ? title->c_str () : 0, defaultPath ? defaultPath->c_str () : 0);

		if (path) {

			std::wstring* _path = new std::wstring (path);
			return _path;

		}

		#else

		std::string* _title = wstring_to_string (title);
		//std::string* _filter = wstring_to_string (filter);
		std::string* _defaultPath = wstring_to_string (defaultPath);

		const char* path = tinyfd_selectFolderDialog (_title ? _title->c_str () : NULL, _defaultPath ? _defaultPath->c_str () : NULL);

		if (_title) delete _title;
		//if (_filter) delete _filter;
		if (_defaultPath) delete _defaultPath;

		if (path) {

			std::string _path = std::string (path);
			std::wstring* __path = new std::wstring (_path.begin (), _path.end ());
			return __path;

		}

		#endif

		return 0;

	}
Exemple #4
0
  std::tuple<std::vector<std::string>, Window::DialogStatus, std::string> WindowManager::openDialogSync(
      Window::DialogMode mode,
      const std::string& title,
      const std::string& defaultFilePath,
      const std::vector<std::string> filters
  )
  {
    std::vector<std::string> paths;
    Window::DialogStatus status;
    const char* outPath = NULL;

    const char* f[256];
    for(int i = 0; i < filters.size(); i++) {
      f[i] = filters[i].c_str();
    }

    switch(mode) {
      case Window::DialogMode::FILE_DIALOG_OPEN_MULTIPLE:
      case Window::DialogMode::FILE_DIALOG_OPEN:
        outPath = tinyfd_openFileDialog(&title[0], &defaultFilePath[0], filters.size(), &f[0], NULL, mode == Window::DialogMode::FILE_DIALOG_OPEN_MULTIPLE);
        break;
      case Window::DialogMode::FILE_DIALOG_OPEN_FOLDER:
        outPath = tinyfd_selectFolderDialog(&title[0], &defaultFilePath[0]);
        break;
      case Window::DialogMode::FILE_DIALOG_SAVE:
        outPath = tinyfd_saveFileDialog(&title[0], &defaultFilePath[0], filters.size(), &f[0], NULL);
        break;
    }

    std::stringstream err;

    if(outPath == NULL) {
      return std::make_tuple(paths, Window::DialogStatus::CANCEL, "");
    }

    paths = split(std::string(outPath), '|');
    return std::make_tuple(paths, Window::DialogStatus::OKAY, "");
  }
Exemple #5
0
    /*
    std::string showOpenDialog(const std::string& caption, const FileTypes& extensions, const std::string& defaultFilename)
    {
        std::string pattern = "{";

        pattern += "}";
        auto pPath = tinyfd_openFileDialog(
            "Browse Game",
            defaultFilename.c_str(),
            (int)extensions.size(),
            NULL,
            NULL,
            0);
        if (!pPath) return "";
        return pPath;
    }

    std::string showSaveAsDialog(const std::string& caption, const FileTypes& extensions, const std::string& defaultFilename)
    {
        return "";
    }
    */
    std::string showOpenFolderDialog(const std::string& caption, const std::string& defaultPath)
    {
        auto pPath = tinyfd_selectFolderDialog(caption.c_str(), defaultPath.c_str());
        if (!pPath) return "";
        return pPath;
    }