distribution/packages/emulators/standalone/vita3k-sa/patches/003-drop-xdg-desktop-portals.patch
2023-10-25 15:17:00 +00:00

596 lines
27 KiB
Diff

diff --git a/.gitmodules b/.gitmodules
index e57fd159..bb5ed956 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -90,9 +90,9 @@
[submodule "external/tracy"]
path = external/tracy
url = https://github.com/wolfpld/tracy.git
-[submodule "external/nativefiledialog-extended"]
- path = external/nativefiledialog-extended
- url = https://github.com/btzy/nativefiledialog-extended.git
+[submodule "external/nativefiledialog-cmake"]
+ path = external/nativefiledialog-cmake
+ url = https://github.com/Vita3K/nativefiledialog-cmake
[submodule "external/cubeb"]
path = external/cubeb
url = https://github.com/mozilla/cubeb.git
diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index d4dcfc94..4cb3e1ee 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -344,11 +344,20 @@ target_compile_definitions(tracy PUBLIC $<$<CONFIG:Debug,RelWithDebInfo>:TRACY_E
#
# target_compile_definitions(tracy PUBLIC TRACY_ENABLE)
-# Use XDG desktop portals on Linux
-set(NFD_PORTAL ON)
+# Create alias to prevent the need of multiple changes in case the target name changes
+# Batocera - bring back nativefiledialog
+if(UNIX)
+ find_package(PkgConfig REQUIRED)
+ pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
-# nativefiledialog-extended
-add_subdirectory(nativefiledialog-extended)
+ include_directories(${GTK3_INCLUDE_DIRS})
+ link_directories(${GTK3_LIBRARY_DIRS})
+
+ add_definitions(${GTK3_CFLAGS_OTHER})
+
+ add_library(nativefiledialog STATIC nativefiledialog-cmake/src/nfd_gtk.c nativefiledialog-cmake/src/nfd_common.c)
+ target_include_directories(nativefiledialog PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/nativefiledialog-cmake/src/include")
+ target_link_libraries(nativefiledialog ${GTK3_LIBRARIES})
+endif()
+set_property(TARGET nativefiledialog PROPERTY FOLDER externals)
-# Create alias to prevent the need of multiple changes in case the target name changes
-add_library(NFDe::NFDe ALIAS nfd)
diff --git a/vita3k/CMakeLists.txt b/vita3k/CMakeLists.txt
index e1b27dfd..25d8f88b 100644
--- a/vita3k/CMakeLists.txt
+++ b/vita3k/CMakeLists.txt
@@ -105,7 +105,6 @@ add_subdirectory(features)
add_subdirectory(glutil)
add_subdirectory(gui)
add_subdirectory(gxm)
-add_subdirectory(host)
add_subdirectory(ime)
add_subdirectory(lang)
add_subdirectory(net)
diff --git a/vita3k/dir_doc.cpp b/vita3k/dir_doc.cpp
index b66bbd98..28d5a6f4 100644
--- a/vita3k/dir_doc.cpp
+++ b/vita3k/dir_doc.cpp
@@ -115,12 +115,6 @@
* @brief Vita's GXM low-level graphics API translation layer
*/
-/**
- * @dir vita3k/host
- *
- * @brief Host operating system abstraction layer
- */
-
/**
* @dir vita3k/io
*
diff --git a/vita3k/gui/CMakeLists.txt b/vita3k/gui/CMakeLists.txt
index ef7de553..811ee661 100644
--- a/vita3k/gui/CMakeLists.txt
+++ b/vita3k/gui/CMakeLists.txt
@@ -51,5 +51,5 @@ add_library(
target_include_directories(gui PUBLIC include ${CMAKE_SOURCE_DIR}/vita3k)
target_link_libraries(gui PUBLIC app compat config dialog emuenv https ime imgui glutil lang regmgr np)
-target_link_libraries(gui PRIVATE audio ctrl kernel miniz psvpfsparser pugixml::pugixml stb renderer packages sdl2 touch vkutil host::dialog)
+target_link_libraries(gui PRIVATE audio ctrl kernel miniz psvpfsparser pugixml::pugixml stb renderer packages sdl2 touch vkutil nativefiledialog)
target_link_libraries(gui PUBLIC tracy)
diff --git a/vita3k/gui/src/archive_install_dialog.cpp b/vita3k/gui/src/archive_install_dialog.cpp
index 67832991..5d724637 100644
--- a/vita3k/gui/src/archive_install_dialog.cpp
+++ b/vita3k/gui/src/archive_install_dialog.cpp
@@ -19,7 +19,7 @@
#include "private.h"
#include <gui/functions.h>
-#include <host/dialog/filesystem.hpp>
+#include <nfd.h>
#include <packages/sfo.h>
#include <util/string_utils.h>
@@ -32,7 +33,7 @@ static bool delete_archive_file;
static std::string state, type, title;
static std::map<fs::path, std::vector<ContentInfo>> contents_archives;
static std::vector<fs::path> invalid_archives;
-static std::filesystem::path archive_path = "";
+static nfdchar_t *archive_path;
static float global_progress = 0.f;
static float archives_count = 0.f;
@@ -104,20 +104,12 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
gui.file_menu.archive_install_dialog = false;
} else {
if (state.empty()) {
- host::dialog::filesystem::Result result = host::dialog::filesystem::Result::CANCEL;
- if (type == "file") {
- // Set file filters for the file picking dialog
- std::vector<host::dialog::filesystem::FileFilter> file_filters = {
- { "PlayStation Vita commercial software package (NoNpDrm/FAGDec) / PlayStation Vita homebrew software package", { "zip", "vpk" } },
- { "PlayStation Vita commercial software package (NoNpDrm/FAGDec)", { "zip" } },
- { "PlayStation Vita homebrew software package", { "vpk" } },
- };
- // Call file picking dialog from the native file browser
- result = host::dialog::filesystem::open_file(archive_path, file_filters);
- } else {
- result = host::dialog::filesystem::pick_folder(archive_path);
- }
- if (result == host::dialog::filesystem::Result::SUCCESS) {
+ nfdresult_t result = NFD_CANCEL;
+ if (type == "file")
+ result = NFD_OpenDialog("zip,vpk", nullptr, &archive_path);
+ else
+ result = NFD_PickFolder(nullptr, &archive_path);
+ if (result == NFD_OKAY) {
state = "install";
} else
type.clear();
@@ -133,7 +127,7 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
} else
invalid_archives.push_back(archive_path);
};
- const auto contents_path = fs::path(archive_path.wstring());
+ const auto contents_path = fs::path(string_utils::utf_to_wide(archive_path));
if (type == "directory") {
const auto archives_path = get_path_of_archives(contents_path);
archives_count = float(archives_path.size());
@@ -264,7 +258,7 @@ void draw_archive_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
for (const auto archive : invalid_archives)
fs::remove(archive);
}
- archive_path = "";
+ archive_path = nullptr;
gui.file_menu.archive_install_dialog = false;
delete_archive_file = false;
contents_archives.clear();
diff --git a/vita3k/gui/src/firmware_install_dialog.cpp b/vita3k/gui/src/firmware_install_dialog.cpp
index 1b7208e6..f29150f7 100644
--- a/vita3k/gui/src/firmware_install_dialog.cpp
+++ b/vita3k/gui/src/firmware_install_dialog.cpp
@@ -19,18 +19,19 @@
#include <config/state.h>
#include <gui/functions.h>
-#include <host/dialog/filesystem.hpp>
#include <packages/functions.h>
#include <util/log.h>
#include <util/string_utils.h>
+#include <nfd.h>
+
#include <thread>
namespace gui {
std::string fw_version;
bool delete_pup_file;
-std::filesystem::path pup_path = "";
+nfdchar_t *pup_path;
static void get_firmware_version(EmuEnvState &emuenv) {
fs::ifstream versionFile(emuenv.pref_path + L"/PUP_DEC/PUP/version.txt");
@@ -46,7 +46,7 @@ static void get_firmware_version(EmuEnvState &emuenv) {
}
void draw_firmware_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
- host::dialog::filesystem::Result result = host::dialog::filesystem::Result::CANCEL;
+ nfdresult_t result = NFD_CANCEL;
static std::mutex install_mutex;
static bool draw_file_dialog = true;
@@ -62,23 +62,23 @@ void draw_firmware_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
std::lock_guard<std::mutex> lock(install_mutex);
if (draw_file_dialog) {
- result = host::dialog::filesystem::open_file(pup_path, { { "PlayStation Vita Firmware Package", { "PUP" } } });
+ result = NFD_OpenDialog("PUP", nullptr, &pup_path);
draw_file_dialog = false;
finished_installing = false;
- if (result == host::dialog::filesystem::Result::SUCCESS) {
+ if (result == NFD_OKAY) {
std::thread installation([&emuenv]() {
- install_pup(emuenv.pref_path, pup_path.string(), progress_callback);
+ install_pup(emuenv.pref_path, pup_path, progress_callback);
std::lock_guard<std::mutex> lock(install_mutex);
finished_installing = true;
get_firmware_version(emuenv);
});
installation.detach();
- } else if (result == host::dialog::filesystem::Result::CANCEL) {
+ } else if (result == NFD_CANCEL) {
gui.file_menu.firmware_install_dialog = false;
draw_file_dialog = true;
} else {
- LOG_ERROR("Error initializing file dialog: {}", host::dialog::filesystem::get_error());
+ LOG_ERROR("Error initializing file dialog: {}", NFD_GetError());
gui.file_menu.firmware_install_dialog = false;
draw_file_dialog = true;
}
@@ -117,7 +118,7 @@ void draw_firmware_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
ImGui::SetCursorPosX(ImGui::GetWindowWidth() / 2 - 30);
if (ImGui::Button("OK", BUTTON_SIZE)) {
if (delete_pup_file) {
- fs::remove(fs::path(pup_path.wstring()));
+ fs::remove(fs::path(string_utils::utf_to_wide(pup_path)));
delete_pup_file = false;
}
if (emuenv.cfg.initial_setup)
diff --git a/vita3k/gui/src/initial_setup.cpp b/vita3k/gui/src/initial_setup.cpp
index 0bbe3548..e327c6cb 100644
--- a/vita3k/gui/src/initial_setup.cpp
+++ b/vita3k/gui/src/initial_setup.cpp
@@ -19,11 +19,12 @@
#include <config/state.h>
#include <gui/functions.h>
-#include <host/dialog/filesystem.hpp>
#include <lang/functions.h>
#include <util/string_utils.h>
+#include <nfd.h>
+
namespace gui {
enum InitialSetup {
@@ -121,12 +122,12 @@ void draw_initial_setup(GuiState &gui, EmuEnvState &emuenv) {
ImGui::TextWrapped("%s", emuenv.cfg.pref_path.c_str());
ImGui::SetCursorPos(!is_default_path ? ImVec2((WINDOW_SIZE.x / 2.f) - BIG_BUTTON_SIZE.x - (20.f * SCALE.x), BIG_BUTTON_POS.y) : BIG_BUTTON_POS);
if (ImGui::Button("Change Emulator Path", BIG_BUTTON_SIZE)) {
- std::filesystem::path emulator_path = "";
- host::dialog::filesystem::Result result = host::dialog::filesystem::pick_folder(emulator_path);
+ nfdchar_t *emulator_path = nullptr;
+ nfdresult_t result = NFD_PickFolder(nullptr, &emulator_path);
- if ((result == host::dialog::filesystem::Result::SUCCESS) && (emulator_path.wstring() != emuenv.pref_path)) {
- emuenv.pref_path = emulator_path.wstring() + L'/';
- emuenv.cfg.pref_path = emulator_path.string();
+ if ((result == NFD_OKAY) && (string_utils::utf_to_wide(emulator_path) != emuenv.pref_path)) {
+ emuenv.pref_path = string_utils::utf_to_wide(emulator_path) + L'/';
+ emuenv.cfg.pref_path = emulator_path;
}
}
if (!is_default_path) {
diff --git a/vita3k/gui/src/license_install_dialog.cpp b/vita3k/gui/src/license_install_dialog.cpp
index beabedb8..7eb910a5 100644
--- a/vita3k/gui/src/license_install_dialog.cpp
+++ b/vita3k/gui/src/license_install_dialog.cpp
@@ -17,15 +17,15 @@
#include "private.h"
-#include <host/dialog/filesystem.hpp>
#include <misc/cpp/imgui_stdlib.h>
#include <packages/functions.h>
#include <util/string_utils.h>
+#include <nfd.h>
namespace gui {
static std::string state, title, zRIF;
-std::filesystem::path license_path = "";
+nfdchar_t *license_path;
static bool delete_license_file;
void draw_license_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
@@ -67,10 +67,10 @@ void draw_license_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
if (ImGui::Button(common["cancel"].c_str(), BUTTON_SIZE))
gui.file_menu.license_install_dialog = false;
} else if (state == "license") {
- host::dialog::filesystem::Result result = host::dialog::filesystem::Result::CANCEL;
- result = host::dialog::filesystem::open_file(license_path, { { "PlayStation Vita software license file", { "bin", "rif" } } });
- if (result == host::dialog::filesystem::Result::SUCCESS) {
- if (copy_license(emuenv, fs::path(license_path.wstring())))
+ nfdresult_t result = NFD_CANCEL;
+ result = NFD_OpenDialog("bin,rif", nullptr, &license_path);
+ if (result == NFD_OKAY) {
+ if (copy_license(emuenv, license_path))
state = "success";
else
state = "fail";
@@ -105,12 +105,12 @@ void draw_license_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
- if (license_path != "")
+ if (license_path)
ImGui::Checkbox(license["delete_bin_rif"].c_str(), &delete_license_file);
ImGui::SetCursorPos(ImVec2(POS_BUTTON, ImGui::GetWindowSize().y - BUTTON_SIZE.y - (20.f * SCALE.y)));
if (ImGui::Button(common["ok"].c_str(), BUTTON_SIZE)) {
if (delete_license_file) {
- fs::remove(fs::path(license_path.wstring()));
+ fs::remove(fs::path(string_utils::utf_to_wide(std::string(license_path))));
delete_license_file = false;
}
license_path = nullptr;
diff --git a/vita3k/gui/src/pkg_install_dialog.cpp b/vita3k/gui/src/pkg_install_dialog.cpp
index 75c11214..46fcf6f8 100644
--- a/vita3k/gui/src/pkg_install_dialog.cpp
+++ b/vita3k/gui/src/pkg_install_dialog.cpp
@@ -18,7 +18,6 @@
#include "private.h"
#include <gui/functions.h>
-#include <host/dialog/filesystem.hpp>
#include <misc/cpp/imgui_stdlib.h>
#include <packages/functions.h>
#include <packages/pkg.h>
@@ -25,19 +25,18 @@
#include <rif2zrif.h>
#include <util/log.h>
#include <util/string_utils.h>
-
+#include <nfd.h>
#include <thread>
namespace gui {
-static std::filesystem::path pkg_path = "";
-static std::filesystem::path license_path = "";
+static nfdchar_t *pkg_path, *license_path;
static std::string state, title, zRIF;
static bool draw_file_dialog = true;
static bool delete_pkg_file, delete_license_file;
void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
- host::dialog::filesystem::Result result = host::dialog::filesystem::Result::CANCEL;
+ nfdresult_t result = NFD_CANCEL;
static std::atomic<float> progress(0);
static std::mutex install_mutex;
static const auto progress_callback = [&](float updated_progress) {
@@ -53,15 +53,15 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
const auto BUTTON_SIZE = ImVec2(160.f * SCALE.x, 45.f * SCALE.y);
if (draw_file_dialog) {
- result = host::dialog::filesystem::open_file(pkg_path, { { "PlayStation Store Downloaded Package", { "pkg" } } });
+ result = NFD_OpenDialog("pkg", nullptr, &pkg_path);
draw_file_dialog = false;
- if (result == host::dialog::filesystem::Result::SUCCESS)
+ if (result == NFD_OKAY)
ImGui::OpenPopup("install");
- else if (result == host::dialog::filesystem::Result::CANCEL) {
+ else if (result == NFD_CANCEL) {
gui.file_menu.pkg_install_dialog = false;
draw_file_dialog = true;
} else {
- LOG_ERROR("Error initializing file dialog: {}", host::dialog::filesystem::get_error());
+ LOG_ERROR("Error initializing file dialog: {}", NFD_GetError());
gui.file_menu.pkg_install_dialog = false;
draw_file_dialog = true;
}
@@ -97,9 +96,9 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
draw_file_dialog = true;
}
} else if (state == "license") {
- result = host::dialog::filesystem::open_file(license_path, { { "PlayStation Vita software license file", { "bin", "rif" } } });
- if (result == host::dialog::filesystem::Result::SUCCESS) {
- fs::ifstream binfile(license_path.wstring(), std::ios::in | std::ios::binary | std::ios::ate);
+ result = NFD_OpenDialog("bin,rif", nullptr, &license_path);
+ if (result == NFD_OKAY) {
+ fs::ifstream binfile(string_utils::utf_to_wide(std::string(license_path)), std::ios::in | std::ios::binary | std::ios::ate);
zRIF = rif2zrif(binfile);
state = "install";
} else
@@ -125,7 +125,7 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
state = "install";
} else if (state == "install") {
std::thread installation([&emuenv]() {
- if (install_pkg(pkg_path.string(), emuenv, zRIF, progress_callback)) {
+ if (install_pkg(std::string(pkg_path), emuenv, zRIF, progress_callback)) {
std::lock_guard<std::mutex> lock(install_mutex);
state = "success";
} else {
@@ -143,17 +142,17 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
ImGui::Separator();
ImGui::Spacing();
ImGui::Checkbox(lang["delete_pkg"].c_str(), &delete_pkg_file);
- if (license_path != "")
+ if (license_path)
ImGui::Checkbox(lang["delete_bin_rif"].c_str(), &delete_license_file);
ImGui::Spacing();
ImGui::SetCursorPos(ImVec2(POS_BUTTON, ImGui::GetWindowSize().y - BUTTON_SIZE.y - (20.f * SCALE.y)));
if (ImGui::Button(common["ok"].c_str(), BUTTON_SIZE)) {
if (delete_pkg_file) {
- fs::remove(fs::path(pkg_path.wstring()));
+ fs::remove(fs::path(string_utils::utf_to_wide(std::string(pkg_path))));
delete_pkg_file = false;
}
if (delete_license_file) {
- fs::remove(fs::path(license_path.wstring()));
+ fs::remove(fs::path(string_utils::utf_to_wide(std::string(pkg_path))));
delete_license_file = false;
}
if ((emuenv.app_info.app_category.find("gd") != std::string::npos) || (emuenv.app_info.app_category.find("gp") != std::string::npos)) {
@@ -160,8 +160,8 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
save_apps_cache(gui, emuenv);
}
update_notice_info(gui, emuenv, "content");
- pkg_path = "";
- license_path = "";
+ pkg_path = nullptr;
+ license_path = nullptr;
gui.file_menu.pkg_install_dialog = false;
draw_file_dialog = true;
state.clear();
@@ -175,7 +175,7 @@ void draw_pkg_install_dialog(GuiState &gui, EmuEnvState &emuenv) {
ImGui::SetCursorPos(ImVec2(POS_BUTTON, ImGui::GetWindowSize().y - BUTTON_SIZE.y - (20.f * SCALE.y)));
if (ImGui::Button("OK", BUTTON_SIZE)) {
gui.file_menu.pkg_install_dialog = false;
- pkg_path = "";
+ pkg_path = nullptr;
draw_file_dialog = true;
work_path = "";
state.clear();
diff --git a/vita3k/gui/src/settings.cpp b/vita3k/gui/src/settings.cpp
index 72ffabdb..7a6f4265 100644
--- a/vita3k/gui/src/settings.cpp
+++ b/vita3k/gui/src/settings.cpp
@@ -20,7 +20,6 @@
#include <config/functions.h>
#include <config/state.h>
#include <gui/functions.h>
-#include <host/dialog/filesystem.hpp>
#include <ime/functions.h>
#include <io/device.h>
#include <io/state.h>
@@ -29,6 +28,7 @@
#include <util/safe_time.h>
#include <util/string_utils.h>
+#include <nfd.h>
#include <pugixml.hpp>
#include <stb_image.h>
@@ -581,11 +581,11 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
sub_menu.clear();
}
} else if (sub_menu == "image") {
- std::filesystem::path image_path = "";
- host::dialog::filesystem::Result result = host::dialog::filesystem::open_file(image_path, { { "Image file", { "bmp", "gif", "jpg", "png", "tif" } } });
+ nfdchar_t *image_path;
+ nfdresult_t result = NFD_OpenDialog("bmp,gif,jpg,png,tif", nullptr, &image_path);
- if ((result == host::dialog::filesystem::Result::SUCCESS) && init_user_start_background(gui, image_path.string())) {
- gui.users[emuenv.io.user_id].start_path = image_path.string();
+ if ((result == NFD_OKAY) && init_user_start_background(gui, image_path)) {
+ gui.users[emuenv.io.user_id].start_path = image_path;
gui.users[emuenv.io.user_id].start_type = "image";
save_user(gui, emuenv, emuenv.io.user_id);
}
@@ -641,12 +641,12 @@ void draw_settings(GuiState &gui, EmuEnvState &emuenv) {
ImGui::NextColumn();
}
if (ImGui::Selectable(theme_background.home_screen_backgrounds["add_background"].c_str(), false, ImGuiSelectableFlags_None, SIZE_PACKAGE)) {
- std::filesystem::path background_path = "";
- host::dialog::filesystem::Result result = host::dialog::filesystem::open_file(background_path, { { "Image file", { "bmp", "gif", "jpg", "png", "tif" } } });
+ nfdchar_t *background_path;
+ nfdresult_t result = NFD_OpenDialog("bmp,gif,jpg,png,tif", nullptr, &background_path);
- if ((result == host::dialog::filesystem::Result::SUCCESS) && (!gui.user_backgrounds.contains(background_path.string()))) {
- if (init_user_background(gui, emuenv, background_path.string())) {
- gui.users[emuenv.io.user_id].backgrounds.push_back(background_path.string());
+ if ((result == NFD_OKAY) && (gui.user_backgrounds.find(background_path) == gui.user_backgrounds.end())) {
+ if (init_user_background(gui, emuenv, background_path)) {
+ gui.users[emuenv.io.user_id].backgrounds.push_back(background_path);
gui.users[emuenv.io.user_id].use_theme_bg = false;
save_user(gui, emuenv, emuenv.io.user_id);
}
diff --git a/vita3k/gui/src/settings_dialog.cpp b/vita3k/gui/src/settings_dialog.cpp
index 37c05f1c..73dc08c3 100644
--- a/vita3k/gui/src/settings_dialog.cpp
+++ b/vita3k/gui/src/settings_dialog.cpp
@@ -21,7 +21,6 @@
#include <config/functions.h>
#include <config/state.h>
#include <display/state.h>
-#include <host/dialog/filesystem.hpp>
#include <io/state.h>
#include <kernel/state.h>
#include <renderer/state.h>
@@ -43,6 +42,7 @@
#include <SDL.h>
#include <algorithm>
+#include <nfd.h>
#include <pugixml.hpp>
#include <sstream>
@@ -105,12 +105,12 @@ static void reset_emulator(GuiState &gui, EmuEnvState &emuenv) {
}
static void change_emulator_path(GuiState &gui, EmuEnvState &emuenv) {
- std::filesystem::path emulator_path = "";
- host::dialog::filesystem::Result result = host::dialog::filesystem::pick_folder(emulator_path);
+ nfdchar_t *emulator_path = nullptr;
+ nfdresult_t result = NFD_PickFolder(nullptr, &emulator_path);
- if (result == host::dialog::filesystem::Result::SUCCESS && emulator_path.wstring() != emuenv.pref_path) {
+ if (result == NFD_OKAY && string_utils::utf_to_wide(emulator_path) != emuenv.pref_path) {
// Refresh the working paths
- emuenv.pref_path = emulator_path.wstring() + L'/';
+ emuenv.pref_path = string_utils::utf_to_wide(emulator_path) + L'/';
// TODO: Move app old to new path
reset_emulator(gui, emuenv);
diff --git a/vita3k/gui/src/trophy_collection.cpp b/vita3k/gui/src/trophy_collection.cpp
index 85854dc3..97193c7d 100644
--- a/vita3k/gui/src/trophy_collection.cpp
+++ b/vita3k/gui/src/trophy_collection.cpp
@@ -26,6 +26,7 @@
#include <io/device.h>
#include <io/functions.h>
+#include <nfd.h>
#include <pugixml.hpp>
#include <stb_image.h>
diff --git a/vita3k/gui/src/user_management.cpp b/vita3k/gui/src/user_management.cpp
index e1d23bfb..f0b8a935 100644
--- a/vita3k/gui/src/user_management.cpp
+++ b/vita3k/gui/src/user_management.cpp
@@ -24,13 +24,13 @@
#include <display/state.h>
#include <gui/functions.h>
-#include <host/dialog/filesystem.hpp>
#include <io/state.h>
#include <np/common.h>
#include <util/log.h>
#include <util/string_utils.h>
+#include <nfd.h>
#include <pugixml.hpp>
#include <stb_image.h>
@@ -373,11 +373,11 @@ void draw_user_management(GuiState &gui, EmuEnvState &emuenv) {
const auto CHANGE_AVATAR_BTN_SIZE = ImGui::CalcTextSize(lang["change_avatar"].c_str()).x + (ImGui::GetStyle().FramePadding.x * 2.f);
ImGui::SetCursorPos(ImVec2(AVATAR_POS.x + (AVATAR_SIZE.x / 2.f) - (CHANGE_AVATAR_BTN_SIZE / 2.f), AVATAR_POS.y + AVATAR_SIZE.y));
if (ImGui::Button(lang["choose_avatar"].c_str(), CHANGE_AVATAR_BTN_SIZE)) {
- std::filesystem::path avatar_path = "";
- host::dialog::filesystem::Result result = host::dialog::filesystem::open_file(avatar_path, { { "Image file", { "bmp", "gif", "jpg", "png", "tif" } } });
+ nfdchar_t *avatar_path;
+ nfdresult_t result = NFD_OpenDialog("bmp,gif,jpg,png,tif", nullptr, &avatar_path);
- if ((result == host::dialog::filesystem::Result::SUCCESS) && init_avatar(gui, emuenv, "temp", avatar_path.string()))
- temp.avatar = avatar_path.string();
+ if ((result == NFD_OKAY) && init_avatar(gui, emuenv, "temp", avatar_path))
+ temp.avatar = avatar_path;
}
ImGui::SetWindowFontScale(0.8f);
const auto INPUT_NAME_SIZE = 330.f * SCALE.x;
diff --git a/vita3k/host/CMakeLists.txt b/vita3k/host/CMakeLists.txt
deleted file mode 100644
index f9d89128..00000000
--- a/vita3k/host/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-add_subdirectory(dialog)
diff --git a/vita3k/host/dialog/CMakeLists.txt b/vita3k/host/dialog/CMakeLists.txt
deleted file mode 100644
index d577a152..00000000
--- a/vita3k/host/dialog/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-add_library(host_dialog STATIC
- src/filesystem.cpp
-)
-
-# Create alias for more friendly naming and avoid conflicts
-# in global CMake scope
-add_library(host::dialog ALIAS host_dialog)
-
-target_include_directories(host_dialog PUBLIC include)
-
-target_link_libraries(host_dialog PRIVATE NFDe::NFDe)