diff --git a/.gitmodules b/.gitmodules index 42a3671bf..05d781d50 100644 --- a/.gitmodules +++ b/.gitmodules @@ -42,9 +42,9 @@ path = extern/zeus url = ../zeus.git branch = master -[submodule "extern/nativefiledialog"] - path = extern/nativefiledialog - url = https://github.com/mlabbe/nativefiledialog.git +[submodule "extern/nativefiledialog-extended"] + path = extern/nativefiledialog-extended + url = https://github.com/btzy/nativefiledialog-extended.git [submodule "extern/optick"] path = extern/optick url = https://github.com/AxioDL/optick.git diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index 4fc5171b6..3f68eae06 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -242,6 +242,7 @@ public: #endif if (!m_projectInitialized && !m_deferredProject.empty()) { + Log.report(logvisor::Info, FMT_STRING("Loading game from '{}'"), m_deferredProject); if (CDvdFile::Initialize(m_deferredProject)) { m_projectInitialized = true; m_cvarCommons.m_lastDiscPath->fromLiteral(m_deferredProject); diff --git a/Runtime/CMakeLists.txt b/Runtime/CMakeLists.txt index dc941081d..120d2f545 100644 --- a/Runtime/CMakeLists.txt +++ b/Runtime/CMakeLists.txt @@ -230,8 +230,8 @@ add_executable(metaforce CMain.cpp ${PLAT_SRCS} ImGuiEntitySupport.hpp ImGuiEntitySupport.cpp) # RUNTIME_LIBRARIES repeated here for link ordering target_link_libraries(metaforce PUBLIC RuntimeCommon RuntimeCommonB ${RUNTIME_LIBRARIES} ${PLAT_LIBS} aurora::main) -if (TARGET nativefiledialog) - target_link_libraries(metaforce PRIVATE nativefiledialog) +if (TARGET nfd) + target_link_libraries(metaforce PRIVATE nfd) endif() target_compile_definitions(metaforce PUBLIC "-DMETAFORCE_TARGET_BYTE_ORDER=__BYTE_ORDER__") diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index d560ef622..22f961bb9 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -17,7 +17,7 @@ #include "ImGuiEngine.hpp" #include "magic_enum.hpp" #ifdef NATIVEFILEDIALOG_SUPPORTED -#include "nfd.h" +#include #endif #include @@ -51,7 +51,9 @@ std::set ImGuiConsole::inspectingEntities; ImGuiPlayerLoadouts ImGuiConsole::loadouts; ImGuiConsole::ImGuiConsole(CVarManager& cvarMgr, CVarCommons& cvarCommons) -: m_cvarMgr(cvarMgr), m_cvarCommons(cvarCommons) {} +: m_cvarMgr(cvarMgr), m_cvarCommons(cvarCommons) { + NFD::Init(); +} void ImGuiStringViewText(std::string_view text) { // begin()/end() do not work on MSVC @@ -690,13 +692,12 @@ void ImGuiConsole::ShowAboutWindow(bool preLaunch) { #ifdef NATIVEFILEDIALOG_SUPPORTED ImGui::Dummy(padding); if (ImGuiButtonCenter("Select Game")) { - nfdchar_t* outPath = nullptr; - nfdresult_t nfdResult = NFD_OpenDialog(nullptr, nullptr, &outPath); + NFD::UniquePathU8 outPath; + nfdresult_t nfdResult = NFD::OpenDialog(outPath, nullptr, 0, nullptr); if (nfdResult == NFD_OKAY) { - m_gameDiscSelected = outPath; - free(outPath); + m_gameDiscSelected = outPath.get(); } else if (nfdResult != NFD_CANCEL) { - Log.report(logvisor::Error, FMT_STRING("nativefiledialog error: {}"), NFD_GetError()); + Log.report(logvisor::Error, FMT_STRING("nativefiledialog error: {}"), NFD::GetError()); } } #endif @@ -1441,6 +1442,7 @@ void ImGuiConsole::PostUpdate() { void ImGuiConsole::Shutdown() { dummyWorlds.clear(); stringTables.clear(); + NFD::Quit(); } static constexpr std::array GeneralItems{ diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 919d8feb7..c990519af 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -75,25 +75,16 @@ endif () add_subdirectory(jbus EXCLUDE_FROM_ALL) add_subdirectory(kabufuda EXCLUDE_FROM_ALL) -add_library(nativefiledialog STATIC EXCLUDE_FROM_ALL nativefiledialog/src/nfd_common.c) -target_include_directories(nativefiledialog PUBLIC nativefiledialog/src/include) +option(NFD_PORTAL "Use xdg-desktop-portal instead of GTK" ON) if (CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_sources(nativefiledialog PRIVATE nativefiledialog/src/nfd_gtk.c) - target_compile_definitions(nativefiledialog INTERFACE NATIVEFILEDIALOG_SUPPORTED) - - find_package(PkgConfig REQUIRED) - pkg_check_modules(GTK3 REQUIRED gtk+-3.0) - target_link_libraries(nativefiledialog PRIVATE ${GTK3_LIBRARIES}) - target_compile_options(nativefiledialog PRIVATE ${GTK3_CFLAGS_OTHER} -Wno-format-truncation -Wno-stringop-truncation) - target_include_directories(nativefiledialog PRIVATE ${GTK3_INCLUDE_DIRS}) - target_link_directories(nativefiledialog PRIVATE ${GTK3_LIBRARY_DIRS}) + add_subdirectory(nativefiledialog-extended) + target_compile_definitions(nfd INTERFACE NATIVEFILEDIALOG_SUPPORTED) elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_sources(nativefiledialog PRIVATE nativefiledialog/src/nfd_cocoa.m) - target_compile_definitions(nativefiledialog INTERFACE NATIVEFILEDIALOG_SUPPORTED) - # TODO link flags + add_subdirectory(nativefiledialog-extended) + target_compile_definitions(nfd INTERFACE NATIVEFILEDIALOG_SUPPORTED) elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_sources(nativefiledialog PRIVATE nativefiledialog/src/nfd_win.cpp) - target_compile_definitions(nativefiledialog INTERFACE NATIVEFILEDIALOG_SUPPORTED) + add_subdirectory(nativefiledialog-extended) + target_compile_definitions(nfd INTERFACE NATIVEFILEDIALOG_SUPPORTED) else () message(WARNING "nativefiledialog unsupported for ${CMAKE_SYSTEM_NAME}") endif () diff --git a/extern/nativefiledialog b/extern/nativefiledialog deleted file mode 160000 index 67345b80e..000000000 --- a/extern/nativefiledialog +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 67345b80ebb429ecc2aeda94c478b3bcc5f7888e diff --git a/extern/nativefiledialog-extended b/extern/nativefiledialog-extended new file mode 160000 index 000000000..e018ec82b --- /dev/null +++ b/extern/nativefiledialog-extended @@ -0,0 +1 @@ +Subproject commit e018ec82bc86240c80161ac616fd7da8bdcd85db