Replace nativefiledialog with nativefiledialog-extended

This commit is contained in:
Luke Street 2022-08-28 14:06:58 -04:00
parent 66cc6254c7
commit 49362ef591
7 changed files with 23 additions and 29 deletions

6
.gitmodules vendored
View File

@ -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

View File

@ -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);

View File

@ -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__")

View File

@ -17,7 +17,7 @@
#include "ImGuiEngine.hpp"
#include "magic_enum.hpp"
#ifdef NATIVEFILEDIALOG_SUPPORTED
#include "nfd.h"
#include <nfd.hpp>
#endif
#include <cstdarg>
@ -51,7 +51,9 @@ std::set<TUniqueId> 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{

23
extern/CMakeLists.txt vendored
View File

@ -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 ()

@ -1 +0,0 @@
Subproject commit 67345b80ebb429ecc2aeda94c478b3bcc5f7888e

1
extern/nativefiledialog-extended vendored Submodule

@ -0,0 +1 @@
Subproject commit e018ec82bc86240c80161ac616fd7da8bdcd85db