Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fullscreen toggle button (windows-only for now) #13893

Merged
merged 3 commits into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Common/UI/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,9 @@ class Button : public Clickable {
paddingW_ = w;
paddingH_ = h;
}
void SetImageID(ImageID imageID) {
imageID_ = imageID;
}

// Needed an extra small button...
void SetScale(float f) {
Expand Down
46 changes: 39 additions & 7 deletions UI/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "Common/Data/Encoding/Utf8.h"
#include "Common/File/PathBrowser.h"
#include "Common/Math/curves.h"
#include "Common/Net/URL.h"
#include "Common/File/FileUtil.h"
#include "Common/TimeUtil.h"
#include "Common/StringUtils.h"
Expand Down Expand Up @@ -66,6 +67,8 @@
#ifdef _WIN32
// Unfortunate, for undef DrawText...
#include "Common/CommonWindows.h"
// For fullscreen toggle
#include "Windows/MainWindow.h"
#endif

#include <sstream>
Expand Down Expand Up @@ -1091,17 +1094,18 @@ void MainScreen::CreateViews() {
char versionString[256];
sprintf(versionString, "%s", PPSSPP_GIT_VERSION);
rightColumnItems->SetSpacing(0.0f);
LinearLayout *logos = new LinearLayout(ORIENT_HORIZONTAL);
AnchorLayout *logos = new AnchorLayout(new AnchorLayoutParams(FILL_PARENT, 60.0f, false));
if (System_GetPropertyBool(SYSPROP_APP_GOLD)) {
logos->Add(new ImageView(ImageID("I_ICONGOLD"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false)));
logos->Add(new ImageView(ImageID("I_ICONGOLD"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false)));
} else {
logos->Add(new ImageView(ImageID("I_ICON"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 10, 10, NONE, NONE, false)));
logos->Add(new ImageView(ImageID("I_ICON"), IS_DEFAULT, new AnchorLayoutParams(64, 64, 0, 0, NONE, NONE, false)));
}
logos->Add(new ImageView(ImageID("I_LOGO"), IS_DEFAULT, new LinearLayoutParams(Margins(-12, 0, 0, 0))));
logos->Add(new ImageView(ImageID("I_LOGO"), IS_DEFAULT, new AnchorLayoutParams(180, 64, 64, -5.0f, NONE, NONE, false)));

#if defined(USING_WIN_UI) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP)
#if PPSSPP_PLATFORM(WINDOWS) && !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)));
fullscreenButton_ = logos->Add(new Button(ImageID(g_Config.bFullScreen ? "I_RESTORE" : "I_FULLSCREEN"), new AnchorLayoutParams(48, 48, NONE, 0, 0, NONE, false)));
fullscreenButton_->OnClick.Handle(this, &MainScreen::OnFullScreenToggle);
}
#endif

Expand Down Expand Up @@ -1210,9 +1214,26 @@ void MainScreen::sendMessage(const char *message, const char *value) {
LaunchFile(screenManager(), std::string(value));
}
if (!strcmp(message, "browse_folderSelect")) {
std::string filename;
#if PPSSPP_PLATFORM(ANDROID)
std::string url = value;
const char *prefix = "content://com.android.externalstorage.documents/tree/";
if (startsWith(url, prefix)) {
url = url.substr(strlen(prefix));
url = UriDecode(url);
} else {
// It's not gonna work.
// TODO: Show an error message?
return;
}
filename = url;
#else
filename = value;
#endif
INFO_LOG(SYSTEM, "Got folder: %s", filename.c_str());
int tab = tabHolder_->GetCurrentTab();
if (tab >= 0 && tab < (int)gameBrowsers_.size()) {
gameBrowsers_[tab]->SetPath(value);
gameBrowsers_[tab]->SetPath(filename);
}
}
}
Expand Down Expand Up @@ -1245,6 +1266,17 @@ UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) {
return UI::EVENT_DONE;
}

UI::EventReturn MainScreen::OnFullScreenToggle(UI::EventParams &e) {
if (fullscreenButton_) {
fullscreenButton_->SetImageID(ImageID(!g_Config.bFullScreen ? "I_RESTORE" : "I_FULLSCREEN"));
}
// TODO: Need to abstract this more.
#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
MainWindow::SendToggleFullscreen(!g_Config.bFullScreen);
#endif
return UI::EVENT_DONE;
}

void MainScreen::DrawBackground(UIContext &dc) {
UIScreenWithBackground::DrawBackground(dc);
if (highlightedGamePath_.empty() && prevHighlightedGamePath_.empty()) {
Expand Down
2 changes: 2 additions & 0 deletions UI/MainScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,11 @@ class MainScreen : public UIScreenWithBackground {
UI::EventReturn OnDownloadUpgrade(UI::EventParams &e);
UI::EventReturn OnDismissUpgrade(UI::EventParams &e);
UI::EventReturn OnAllowStorage(UI::EventParams &e);
UI::EventReturn OnFullScreenToggle(UI::EventParams &e);

UI::LinearLayout *upgradeBar_ = nullptr;
UI::TabHolder *tabHolder_ = nullptr;
UI::Button *fullscreenButton_ = nullptr;

std::string restoreFocusGamePath_;
std::vector<GameBrowser *> gameBrowsers_;
Expand Down
16 changes: 12 additions & 4 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,18 @@ private static ArrayList<String> getSdCardPaths(final Context context) {
}
}

// TODO: On older devices, try System.getenv(“EXTERNAL_SDCARD_STORAGE”)
if (list == null) {
String[] varNames = { "EXTERNAL_SDCARD_STORAGE", "SECONDARY_STORAGE" };
for (String var : varNames) {
Log.i(TAG, "getSdCardPaths: Checking env " + var);
String secStore = System.getenv("SECONDARY_STORAGE");
if (secStore != null && secStore.length() > 0) {
list = new ArrayList<String>();
list.add(secStore);
break;
}
}
}

if (list == null) {
return new ArrayList<String>();
Expand All @@ -275,9 +286,6 @@ private static ArrayList<String> getSdCardPaths(final Context context) {
}
}

/**
* returns a list of all available sd cards paths, or null if not found.
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
private static ArrayList<String> getSdCardPaths19(final Context context)
{
Expand Down