maybe mac fix 3

This commit is contained in:
Fleeym 2024-06-13 04:09:53 +03:00
parent c494291ed7
commit 3ce86df1d6

View file

@ -162,22 +162,33 @@ namespace {
GEODE_DLL Task<Result<std::filesystem::path>> file::pick(file::PickMode mode, file::FilePickOptions const& options) { GEODE_DLL Task<Result<std::filesystem::path>> file::pick(file::PickMode mode, file::FilePickOptions const& options) {
using RetTask = Task<Result<std::filesystem::path>>; using RetTask = Task<Result<std::filesystem::path>>;
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult result) { return RetTask::runWithCallback([mode, options](auto resultCallback, auto progress, auto cancelled) {
if (result.isOk()) { [FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult result) {
std::filesystem::path path = result.unwrap()[0]; if (cancelled()) {
return RetTask::immediate(Ok(path)); resultCallback(RetTask::Cancel());
} else { } else {
return RetTask::immediate(Err(result.err().unwrap())); if (result.isOk()) {
} std::filesystem::path path = result.unwrap()[0];
}]; resultCallback(Ok(path));
} else {
resultCallback(Err(result.err().value()));
}
}
}];
});
} }
GEODE_DLL Task<Result<std::vector<std::filesystem::path>>> file::pickMany(file::FilePickOptions const& options) { GEODE_DLL Task<Result<std::vector<std::filesystem::path>>> file::pickMany(file::FilePickOptions const& options) {
using RetTask = Task<Result<std::vector<std::filesystem::path>>>; using RetTask = Task<Result<std::vector<std::filesystem::path>>>;
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:true onCompletion: ^(FileResult result) { return RetTask::runWithCallback([options](auto resultCallback, auto progress, auto cancelled) {
return RetTask::immediate(result); [FileDialog dispatchFilePickerWithMode:mode options:options multiple:true onCompletion: ^(FileResult result) {
}]; if (cancelled()) {
resultCallback(RetTask::Cancel());
} else {
resultCallback(result);
}
}];
})
} }
CCPoint cocos::getMousePos() { CCPoint cocos::getMousePos() {