mirror of
https://github.com/geode-sdk/geode.git
synced 2024-12-18 03:42:25 -05:00
maybe mac fix 3
This commit is contained in:
parent
c494291ed7
commit
3ce86df1d6
1 changed files with 23 additions and 12 deletions
|
@ -162,22 +162,33 @@ namespace {
|
|||
|
||||
GEODE_DLL Task<Result<std::filesystem::path>> file::pick(file::PickMode mode, file::FilePickOptions const& options) {
|
||||
using RetTask = Task<Result<std::filesystem::path>>;
|
||||
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult result) {
|
||||
if (result.isOk()) {
|
||||
std::filesystem::path path = result.unwrap()[0];
|
||||
return RetTask::immediate(Ok(path));
|
||||
} else {
|
||||
return RetTask::immediate(Err(result.err().unwrap()));
|
||||
}
|
||||
}];
|
||||
return RetTask::runWithCallback([mode, options](auto resultCallback, auto progress, auto cancelled) {
|
||||
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:false onCompletion: ^(FileResult result) {
|
||||
if (cancelled()) {
|
||||
resultCallback(RetTask::Cancel());
|
||||
} else {
|
||||
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) {
|
||||
using RetTask = Task<Result<std::vector<std::filesystem::path>>>;
|
||||
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:true onCompletion: ^(FileResult result) {
|
||||
return RetTask::immediate(result);
|
||||
}];
|
||||
|
||||
return RetTask::runWithCallback([options](auto resultCallback, auto progress, auto cancelled) {
|
||||
[FileDialog dispatchFilePickerWithMode:mode options:options multiple:true onCompletion: ^(FileResult result) {
|
||||
if (cancelled()) {
|
||||
resultCallback(RetTask::Cancel());
|
||||
} else {
|
||||
resultCallback(result);
|
||||
}
|
||||
}];
|
||||
})
|
||||
}
|
||||
|
||||
CCPoint cocos::getMousePos() {
|
||||
|
|
Loading…
Reference in a new issue