From 241be1b46d13d950690bc934590c0bafc89f2aea Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:55:17 -0600 Subject: [PATCH] annual camila314 commit: fix file picker on mac --- loader/include/Geode/cocos/include/ccTypes.h | 4 ++++ loader/src/platform/mac/util.mm | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/loader/include/Geode/cocos/include/ccTypes.h b/loader/include/Geode/cocos/include/ccTypes.h index 107a460f7..0a3dfdfe3 100644 --- a/loader/include/Geode/cocos/include/ccTypes.h +++ b/loader/include/Geode/cocos/include/ccTypes.h @@ -28,7 +28,11 @@ THE SOFTWARE. #define __CCTYPES_H__ #include + +#ifdef __cplusplus #include +#endif + #include "../cocoa/CCGeometry.h" #include "../platform/CCGL.h" diff --git a/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index ea863c9da..6fcd09944 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -95,7 +95,7 @@ @implementation FileDialog // default path if (options.defaultPath) { auto defaultPath = [NSString stringWithUTF8String:options.defaultPath->c_str()]; - [panel setDirectoryURL: [NSURL URLWithString: defaultPath]]; + [panel setDirectoryURL: [NSURL fileURLWithPath: defaultPath]]; } // other @@ -153,8 +153,9 @@ @implementation FileDialog } +(void) dispatchFilePickerWithMode:(file::PickMode)mode options:(file::FilePickOptions const&)options multiple:(bool)mult onCompletion:(void(^)(FileResult&&))onCompletion { + file::FilePickOptions optionsCopy = options; dispatch_async(dispatch_get_main_queue(), ^{ - auto result = [self filePickerWithMode:mode options:options multiple:mult]; + auto result = [self filePickerWithMode:mode options:optionsCopy multiple:mult]; onCompletion(std::move(result)); }); }