From 5929c78307dd1725f5df7683f33ef4a0e5d14249 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 30 Mar 2020 22:45:29 +0200 Subject: [PATCH] Add home button on all platforms --- Common/File/PathBrowser.h | 4 ++++ Common/System/System.h | 3 +++ UI/MainScreen.cpp | 23 +++++++++++++++++++++++ UI/MainScreen.h | 2 ++ 4 files changed, 32 insertions(+) diff --git a/Common/File/PathBrowser.h b/Common/File/PathBrowser.h index 83e5e2f900..e6f817adc1 100644 --- a/Common/File/PathBrowser.h +++ b/Common/File/PathBrowser.h @@ -27,6 +27,10 @@ public: void NavigateUp(); void Navigate(const std::string &path); + bool HasParent() const { + return path_ != "" && path_ != "/"; + } + std::string GetPath() const { if (path_ != "/") return path_; diff --git a/Common/System/System.h b/Common/System/System.h index 57cee7bd72..2d75b95ae9 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -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, diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index f7ae0cc3f1..2ee21fbfa7 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -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)) { @@ -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))); } @@ -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) { @@ -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); diff --git a/UI/MainScreen.h b/UI/MainScreen.h index f25fa3f12c..86c22dd529 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -68,6 +68,8 @@ private: 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);