mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-09 07:42:15 +00:00
Blind convert iOS to the new folder picking path
This commit is contained in:
parent
9508ef467e
commit
49efa4499e
@ -12,7 +12,7 @@
|
||||
|
||||
#define PreferredMemoryStickUserDefaultsKey "UserPreferredMemoryStickDirectoryPath"
|
||||
|
||||
typedef std::function<void (Path)> DarwinDirectoryPanelCallback;
|
||||
typedef std::function<void (bool, Path)> DarwinDirectoryPanelCallback;
|
||||
|
||||
/// A Class providing help functions to work with the FileSystem
|
||||
/// on Darwin platforms.
|
||||
|
@ -33,7 +33,9 @@
|
||||
|
||||
- (void)documentPicker:(UIDocumentPickerViewController *)controller didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
|
||||
if (urls.count >= 1)
|
||||
self.callback(Path(urls[0].path.UTF8String));
|
||||
self.callback(true, Path(urls[0].path.UTF8String));
|
||||
else
|
||||
self.callback)false, Path());
|
||||
}
|
||||
|
||||
@end
|
||||
@ -55,8 +57,11 @@ void DarwinFileSystemServices::presentDirectoryPanel(DarwinDirectoryPanelCallbac
|
||||
// panel.allowedFileTypes = @[(__bridge NSString *)kUTTypeFolder];
|
||||
|
||||
NSModalResponse modalResponse = [panel runModal];
|
||||
if (modalResponse == NSModalResponseOK && panel.URLs.firstObject)
|
||||
callback(Path(panel.URLs.firstObject.path.UTF8String));
|
||||
if (modalResponse == NSModalResponseOK && panel.URLs.firstObject) {
|
||||
callback(true, Path(panel.URLs.firstObject.path.UTF8String));
|
||||
} else if (modalResponse == NSModalReponseCancel) {
|
||||
callback(false, Path());
|
||||
}
|
||||
#elif PPSSPP_PLATFORM(IOS)
|
||||
UIViewController *rootViewController = UIApplication.sharedApplication
|
||||
.keyWindow
|
||||
|
24
ios/main.mm
24
ios/main.mm
@ -18,6 +18,7 @@
|
||||
#include "Common/MemoryUtil.h"
|
||||
#include "Common/System/NativeApp.h"
|
||||
#include "Common/System/System.h"
|
||||
#include "Common/System/Request.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/Profiler/Profiler.h"
|
||||
#include "UI/DarwinFileSystemServices.h"
|
||||
@ -209,17 +210,26 @@ void System_SendMessage(const char *command, const char *parameter) {
|
||||
g_safeInsetTop = top;
|
||||
g_safeInsetBottom = bottom;
|
||||
}
|
||||
} else if (!strcmp(command, "browse_folder")) {
|
||||
DarwinDirectoryPanelCallback callback = [] (Path thePathChosen) {
|
||||
NativeMessageReceived("browse_folderSelect", thePathChosen.c_str());
|
||||
};
|
||||
|
||||
DarwinFileSystemServices services;
|
||||
services.presentDirectoryPanel(callback, /* allowFiles = */ true, /* allowDirectorites = */ true);
|
||||
}
|
||||
}
|
||||
|
||||
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string ¶m1, const std::string ¶m2, int param3) {
|
||||
switch (type) {
|
||||
case SystemRequestType::BROWSE_FOR_FOLDER:
|
||||
{
|
||||
DarwinDirectoryPanelCallback callback = [] (bool success, Path thePathChosen) {
|
||||
if (success) {
|
||||
g_requestManager.PostSystemSuccess(requestId, thePathChosen.c_str());
|
||||
} else {
|
||||
g_requestManager.PostSystemFailure(requestId);
|
||||
}
|
||||
};
|
||||
DarwinFileSystemServices services;
|
||||
services.presentDirectoryPanel(callback, /* allowFiles = */ true, /* allowDirectories = */ true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user