mirror of
https://github.com/Mr-Wiseguy/Zelda64Recomp.git
synced 2025-12-05 01:00:11 +00:00
* Remove dummy description for mod config options
* Tag release candidate version
* Apply min width to element triggering rmlui assert (#573)
* Restore 0th day (#574)
* Handle controller up events even while binding inputs to avoid spamming the bind button
* Add MouseButton UI event and use it to fix focus issue on radio, also fix sliders not moving until mouse is released
* Bump version string to 1.2.0-rc2
* mod configure menu description padding set to 16
* Added the ability for focus to set the current mod config option description (#576)
* Added the ability for focus to set the current mod config option description
* add focus to text input
* only clear description if element matches
* Fix race condition crash when setting element text, bump version to 1.2.0-rc3
* Revert "Fix race condition crash when setting element text, bump version to 1.2.0-rc3"
This reverts commit 4934a04d8a.
* Defer setting an element's text if it has children to fix race condition crash, bump version to 1.2.0-rc3
* Defer remaining set_text calls to prevent another race conditionresource
* Update runtime to fix some issues that could happen after mod conflicts
and bump version to 1.2.0-rc4
* Update runtime to fix regenerated functions using the wrong event index and bump version to 1.2.0-rc5
* Add support for suffixed .so. files. Also prevent dropping extracted dynamic libraries.
* Update RT64 commit to fix cstdint include for re-spirv.
* Bump version to rc6.
* Dummy commit to fix CI bot
* Use compile-time macro for Flatpak instead.
* Rename macro.
* Bump version to 1.2.0-rc7
* Fix define on flatpak, add cwd behavior.
* Temporarily disable current working dir code.
* Add the cmake option for flatpak.
* Bump version to 1.2.0-rc8
* Update MacPorts. (#578)
* Update MacPorts.
* Try GitHub runner.
* Deselect universal, return to blaze.
* pull universal libiconv first
* Fix controller nav issues in config menu, bump version to 1.2.0-rc9
---------
Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com>
Co-authored-by: LittleCube <littlecubehax@gmail.com>
Co-authored-by: Dario <dariosamo@gmail.com>
95 lines
3.0 KiB
C++
95 lines
3.0 KiB
C++
#include "zelda_support.h"
|
|
#include <SDL.h>
|
|
#include "nfd.h"
|
|
#include "RmlUi/Core.h"
|
|
|
|
namespace zelda64 {
|
|
// MARK: - Internal Helpers
|
|
void perform_file_dialog_operation(const std::function<void(bool, const std::filesystem::path&)>& callback) {
|
|
nfdnchar_t* native_path = nullptr;
|
|
nfdresult_t result = NFD_OpenDialogN(&native_path, nullptr, 0, nullptr);
|
|
|
|
bool success = (result == NFD_OKAY);
|
|
std::filesystem::path path;
|
|
|
|
if (success) {
|
|
path = std::filesystem::path{native_path};
|
|
NFD_FreePathN(native_path);
|
|
}
|
|
|
|
callback(success, path);
|
|
}
|
|
|
|
void perform_file_dialog_operation_multiple(const std::function<void(bool, const std::list<std::filesystem::path>&)>& callback) {
|
|
const nfdpathset_t* native_paths = nullptr;
|
|
nfdresult_t result = NFD_OpenDialogMultipleN(&native_paths, nullptr, 0, nullptr);
|
|
|
|
bool success = (result == NFD_OKAY);
|
|
std::list<std::filesystem::path> paths;
|
|
nfdpathsetsize_t count = 0;
|
|
|
|
if (success) {
|
|
NFD_PathSet_GetCount(native_paths, &count);
|
|
for (nfdpathsetsize_t i = 0; i < count; i++) {
|
|
nfdnchar_t* cur_path = nullptr;
|
|
nfdresult_t cur_result = NFD_PathSet_GetPathN(native_paths, i, &cur_path);
|
|
if (cur_result == NFD_OKAY) {
|
|
paths.emplace_back(std::filesystem::path{cur_path});
|
|
}
|
|
}
|
|
NFD_PathSet_Free(native_paths);
|
|
}
|
|
|
|
callback(success, paths);
|
|
}
|
|
|
|
// MARK: - Public API
|
|
|
|
std::filesystem::path get_program_path() {
|
|
#if defined(__APPLE__)
|
|
return get_bundle_resource_directory();
|
|
#elif defined(__linux__) && defined(RECOMP_FLATPAK)
|
|
return "/app/bin";
|
|
#else
|
|
return "";
|
|
#endif
|
|
}
|
|
|
|
std::filesystem::path get_asset_path(const char* asset) {
|
|
return get_program_path() / "assets" / asset;
|
|
}
|
|
|
|
void open_file_dialog(std::function<void(bool success, const std::filesystem::path& path)> callback) {
|
|
#ifdef __APPLE__
|
|
dispatch_on_ui_thread([callback]() {
|
|
perform_file_dialog_operation(callback);
|
|
});
|
|
#else
|
|
perform_file_dialog_operation(callback);
|
|
#endif
|
|
}
|
|
|
|
void open_file_dialog_multiple(std::function<void(bool success, const std::list<std::filesystem::path>& paths)> callback) {
|
|
#ifdef __APPLE__
|
|
dispatch_on_ui_thread([callback]() {
|
|
perform_file_dialog_operation_multiple(callback);
|
|
});
|
|
#else
|
|
perform_file_dialog_operation_multiple(callback);
|
|
#endif
|
|
}
|
|
|
|
void show_error_message_box(const char *title, const char *message) {
|
|
#ifdef __APPLE__
|
|
std::string title_copy(title);
|
|
std::string message_copy(message);
|
|
|
|
dispatch_on_ui_thread([title_copy, message_copy] {
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title_copy.c_str(), message_copy.c_str(), nullptr);
|
|
});
|
|
#else
|
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, nullptr);
|
|
#endif
|
|
}
|
|
}
|