Browse button on Darwin platforms, rename some classes/functions

This commit is contained in:
Serena 2023-01-31 13:36:14 +03:00
parent 7e29613df3
commit 230fb93766
6 changed files with 87 additions and 49 deletions

View file

@ -62,6 +62,10 @@
#include "GPU/GPUInterface.h"
#include "Common/Data/Text/I18n.h"
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC)
#include "UI/DarwinFileSystemServices.h" // For the browser
#endif
#include "Core/HLE/sceUmd.h"
bool MainScreen::showHomebrewTab = false;
@ -534,7 +538,23 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
}
UI::EventReturn GameBrowser::BrowseClick(UI::EventParams &e) {
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC)
DarwinDirectoryPanelCallback callback = [this] (Path thePathChosen) {
File::FileInfo info;
if (!File::GetFileInfo(thePathChosen, &info))
return;
if (info.isDirectory)
SetPath(thePathChosen); // user selected a dir, go there
else
LaunchFile(screenManager_, thePathChosen); // it's a file, try open it
};
DarwinFileSystemServices services;
services.presentDirectoryPanel(callback, /* allowFiles = */ true, /* allowDirectorites = */ true);
#else
System_SendMessage("browse_folder", "");
#endif
return UI::EVENT_DONE;
}
@ -691,9 +711,15 @@ void GameBrowser::Refresh() {
if (System_GetPropertyBool(SYSPROP_HAS_ADDITIONAL_STORAGE)) {
topBar->Add(new Choice(ImageID("I_SDCARD"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::StorageClick);
}
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(MAC)
// on Darwin, we don't show the 'Browse' text alongside the image
// we show just the image, because we don't need to emphasize the button on Darwin
topBar->Add(new Choice(ImageID("I_FOLDER_OPEN"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::BrowseClick);
#else
if (System_GetPropertyBool(SYSPROP_HAS_FOLDER_BROWSER)) {
topBar->Add(new Choice(mm->T("Browse"), ImageID("I_FOLDER_OPEN"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::BrowseClick);
}
#endif
} else {
topBar->Add(new Spacer(new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
}