Skip to content

Commit

Permalink
Add home button on all platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 6, 2021
1 parent 3c5cc4c commit 5929c78
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Common/File/PathBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class PathBrowser {
void NavigateUp();
void Navigate(const std::string &path);

bool HasParent() const {
return path_ != "" && path_ != "/";
}

std::string GetPath() const {
if (path_ != "/")
return path_;
Expand Down
3 changes: 3 additions & 0 deletions Common/System/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ enum SystemProperty {
SYSPROP_HAS_IMAGE_BROWSER,
SYSPROP_HAS_BACK_BUTTON,

// Legacy on Android 29+.
SYSPROP_HAS_EXTERNAL_STORAGE,

// Available as Int:
SYSPROP_SYSTEMVERSION,
SYSPROP_DISPLAY_XRES,
Expand Down
23 changes: 23 additions & 0 deletions UI/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,17 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::BrowseClick(UI::EventParams &e) {
System_SendMessage("browse_folder", "");
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::StorageClick(UI::EventParams &e) {
// TODO: Get the SD card directory on Android.
SetPath("");
return UI::EVENT_DONE;
}

UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_QT_UI) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
if (System_GetPropertyBool(SYSPROP_HAS_FOLDER_BROWSER)) {
Expand Down Expand Up @@ -661,6 +672,10 @@ void GameBrowser::Refresh() {
} else {
topBar->Add(new Choice(mm->T("Home"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
}
if (System_GetPropertyBool(SYSPROP_HAS_EXTERNAL_STORAGE)) {
topBar->Add(new Choice(ImageID("I_SDCARD"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::StorageClick);
}
topBar->Add(new Choice(ImageID("I_HOME"), new LayoutParams(WRAP_CONTENT, 64.0f)))->OnClick.Handle(this, &GameBrowser::HomeClick);
} else {
topBar->Add(new Spacer(new LinearLayoutParams(FILL_PARENT, 64.0f, 1.0f)));
}
Expand Down Expand Up @@ -762,6 +777,7 @@ void GameBrowser::Refresh() {
gameList_->Add(new DirButton("..", *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
OnClick.Handle(this, &GameBrowser::NavigateClick);
}

// Add any pinned paths before other directories.
auto pinnedPaths = GetPinnedPaths();
for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
Expand Down Expand Up @@ -1079,6 +1095,13 @@ void MainScreen::CreateViews() {
logos->Add(new ImageView(ImageID("I_ICON"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false)));
}
logos->Add(new ImageView(ImageID("I_LOGO"), IS_DEFAULT, new LinearLayoutParams(Margins(-12, 0, 0, 0))));

#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP)
if (!g_Config.bFullScreen) {
logos->Add(new ImageView(ImageID("I_FULLSCREEN"), IS_DEFAULT, new AnchorLayoutParams(64, 64, NONE, 0, 0, NONE, false)));
}
#endif

rightColumnItems->Add(logos);
TextView *ver = rightColumnItems->Add(new TextView(versionString, new LinearLayoutParams(Margins(70, -6, 0, 0))));
ver->SetSmall(true);
Expand Down
2 changes: 2 additions & 0 deletions UI/MainScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class GameBrowser : public UI::LinearLayout {
UI::EventReturn NavigateClick(UI::EventParams &e);
UI::EventReturn LayoutChange(UI::EventParams &e);
UI::EventReturn LastClick(UI::EventParams &e);
UI::EventReturn BrowseClick(UI::EventParams &e);
UI::EventReturn StorageClick(UI::EventParams &e);
UI::EventReturn HomeClick(UI::EventParams &e);
UI::EventReturn PinToggleClick(UI::EventParams &e);
UI::EventReturn GridSettingsClick(UI::EventParams &e);
Expand Down

0 comments on commit 5929c78

Please sign in to comment.