Merge branch 'master' into TemporaryHackishBranch

# Conflicts:
#	Core/SaveState.cpp
#	UI/ControlMappingScreen.cpp
#	UI/CwCheatScreen.cpp
#	UI/GameSettingsScreen.cpp
#	UI/PauseScreen.cpp
#	android/assets/ppge_atlas.zim
#	android/assets/ppge_atlas_luna.meta
#	android/assets/ui_atlas.zim
#	android/assets/ui_atlas_luna.meta
#	android/res/drawable-hdpi/ic_launcher.png
#	android/res/drawable-ldpi/ic_launcher.png
#	android/res/drawable-mdpi/ic_launcher.png
#	android/res/drawable-xhdpi/ic_launcher.png
#	android/res/drawable-xhdpi/tv_banner.png
#	android/res/drawable-xxhdpi/ic_launcher.png
#	android/res/drawable/ic_banner.png
#	assets/ppge_atlas.zim
#	assets/ppge_atlas_luna.meta
#	assets/ui_atlas.zim
#	assets/ui_atlas_luna.meta
This commit is contained in:
LunaMoo committed 2021-05-24 15:17:07 +02:00
commit 0ee43104e4
598 files changed
+50337 -26888

No files matched your search

+80 -89
View File
@@ -67,7 +67,7 @@
bool MainScreen::showHomebrewTab = false;
bool LaunchFile(ScreenManager *screenManager, std::string path) {
bool LaunchFile(ScreenManager *screenManager, const Path &path) {
// Depending on the file type, we don't want to launch EmuScreen at all.
auto loader = ConstructFileLoader(path);
if (!loader) {
@@ -89,11 +89,12 @@ bool LaunchFile(ScreenManager *screenManager, std::string path) {
return true;
}
static bool IsTempPath(const std::string &str) {
std::string item = str;
static bool IsTempPath(const Path &str) {
std::string item = str.ToString();
#ifdef _WIN32
// Normalize slashes.
item = ReplaceAll(str, "/", "\\");
item = ReplaceAll(item, "/", "\\");
#endif
std::vector<std::string> tempPaths = System_GetPropertyStringVec(SYSPROP_TEMP_DIRS);
@@ -115,7 +116,7 @@ static bool IsTempPath(const std::string &str) {
class GameButton : public UI::Clickable {
public:
GameButton(const std::string &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0)
GameButton(const Path &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0)
: UI::Clickable(layoutParams), gridStyle_(gridStyle), gamePath_(gamePath) {}
void Draw(UIContext &dc) override;
@@ -130,7 +131,7 @@ public:
}
}
const std::string &GamePath() const { return gamePath_; }
const Path &GamePath() const { return gamePath_; }
void SetHoldEnabled(bool hold) {
holdEnabled_ = hold;
@@ -196,20 +197,20 @@ private:
holdStart_ = 0.0;
UI::EventParams e{};
e.v = this;
e.s = gamePath_;
e.s = gamePath_.ToString();
down_ = false;
OnHoldClick.Trigger(e);
}
void TriggerOnHighlight(int focusFlags) {
UI::EventParams e{};
e.v = this;
e.s = gamePath_;
e.s = gamePath_.ToString();
e.a = focusFlags;
OnHighlight.Trigger(e);
}
bool gridStyle_;
std::string gamePath_;
Path gamePath_;
std::string title_;
double holdStart_ = 0.0;
@@ -417,14 +418,14 @@ std::string GameButton::DescribeText() const {
class DirButton : public UI::Button {
public:
DirButton(const std::string &path, bool gridStyle, UI::LayoutParams *layoutParams)
: UI::Button(path, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false) {}
DirButton(const std::string &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0)
DirButton(const Path &path, bool gridStyle, UI::LayoutParams *layoutParams)
: UI::Button(path.ToString(), layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false) {}
DirButton(const Path &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0)
: UI::Button(text, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(true) {}
virtual void Draw(UIContext &dc);
const std::string GetPath() const {
const Path &GetPath() const {
return path_;
}
@@ -433,7 +434,7 @@ public:
}
private:
std::string path_;
Path path_;
bool gridStyle_;
bool absolute_;
};
@@ -490,21 +491,21 @@ void DirButton::Draw(UIContext &dc) {
}
}
GameBrowser::GameBrowser(std::string path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams)
GameBrowser::GameBrowser(const Path &path, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams)
: LinearLayout(UI::ORIENT_VERTICAL, layoutParams), path_(path), gridStyle_(gridStyle), browseFlags_(browseFlags), lastText_(lastText), lastLink_(lastLink), screenManager_(screenManager) {
using namespace UI;
Refresh();
}
void GameBrowser::FocusGame(const std::string &gamePath) {
void GameBrowser::FocusGame(const Path &gamePath) {
focusGamePath_ = gamePath;
Refresh();
focusGamePath_.clear();
}
void GameBrowser::SetPath(const std::string &path) {
void GameBrowser::SetPath(const Path &path) {
path_.SetPath(path);
g_Config.currentDirectory = path_.GetPath();
g_Config.currentDirectory = path_.GetPath().ToString();
Refresh();
}
@@ -531,26 +532,30 @@ UI::EventReturn GameBrowser::StorageClick(UI::EventParams &e) {
return UI::EVENT_DONE;
}
if (storageDirs.size() == 1) {
SetPath(storageDirs[0]);
SetPath(Path(storageDirs[0]));
} else {
// TODO: We should popup a dialog letting the user choose one.
SetPath(storageDirs[0]);
SetPath(Path(storageDirs[0]));
}
return UI::EVENT_DONE;
}
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
SetPath(g_Config.memStickDirectory);
#else
SetPath(getenv("HOME"));
#endif
SetPath(HomePath());
return UI::EVENT_DONE;
}
Path GameBrowser::HomePath() {
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
return g_Config.memStickDirectory;
#else
return Path(getenv("HOME"));
#endif
}
UI::EventReturn GameBrowser::PinToggleClick(UI::EventParams &e) {
auto &pinnedPaths = g_Config.vPinnedPaths;
const std::string path = File::ResolvePath(path_.GetPath());
const std::string path = File::ResolvePath(path_.GetPath().ToString());
if (IsCurrentPathPinned()) {
pinnedPaths.erase(std::remove(pinnedPaths.begin(), pinnedPaths.end(), path), pinnedPaths.end());
} else {
@@ -561,12 +566,15 @@ UI::EventReturn GameBrowser::PinToggleClick(UI::EventParams &e) {
}
bool GameBrowser::DisplayTopBar() {
return path_.GetPath() != "!RECENT";
return path_.GetPath().ToString() != "!RECENT";
}
bool GameBrowser::HasSpecialFiles(std::vector<std::string> &filenames) {
if (path_.GetPath() == "!RECENT") {
filenames = g_Config.recentIsos;
bool GameBrowser::HasSpecialFiles(std::vector<Path> &filenames) {
if (path_.GetPath().ToString() == "!RECENT") {
filenames.clear();
for (auto &str : g_Config.recentIsos) {
filenames.push_back(Path(str));
}
return true;
}
return false;
@@ -612,7 +620,7 @@ void GameBrowser::Draw(UIContext &dc) {
}
}
static bool IsValidPBP(const std::string &path, bool allowHomebrew) {
static bool IsValidPBP(const Path &path, bool allowHomebrew) {
if (!File::Exists(path))
return false;
@@ -706,23 +714,23 @@ void GameBrowser::Refresh() {
listingPending_ = !path_.IsListingReady();
std::vector<std::string> filenames;
std::vector<Path> filenames;
if (HasSpecialFiles(filenames)) {
for (size_t i = 0; i < filenames.size(); i++) {
gameButtons.push_back(new GameButton(filenames[i], *gridStyle_, new UI::LinearLayoutParams(*gridStyle_ == true ? UI::WRAP_CONTENT : UI::FILL_PARENT, UI::WRAP_CONTENT)));
}
} else if (!listingPending_) {
std::vector<FileInfo> fileInfo;
std::vector<File::FileInfo> fileInfo;
path_.GetListing(fileInfo, "iso:cso:pbp:elf:prx:ppdmp:");
for (size_t i = 0; i < fileInfo.size(); i++) {
bool isGame = !fileInfo[i].isDirectory;
bool isSaveData = false;
// Check if eboot directory
if (!isGame && path_.GetPath().size() >= 4 && IsValidPBP(path_.GetPath() + fileInfo[i].name + "/EBOOT.PBP", true))
if (!isGame && path_.GetPath().size() >= 4 && IsValidPBP(path_.GetPath() / fileInfo[i].name / "EBOOT.PBP", true))
isGame = true;
else if (!isGame && File::Exists(path_.GetPath() + fileInfo[i].name + "/PSP_GAME/SYSDIR"))
else if (!isGame && File::Exists(path_.GetPath() / fileInfo[i].name / "PSP_GAME/SYSDIR"))
isGame = true;
else if (!isGame && File::Exists(path_.GetPath() + fileInfo[i].name + "/PARAM.SFO"))
else if (!isGame && File::Exists(path_.GetPath() / fileInfo[i].name / "PARAM.SFO"))
isSaveData = true;
if (!isGame && !isSaveData) {
@@ -756,14 +764,15 @@ void GameBrowser::Refresh() {
if (browseFlags_ & BrowseFlags::NAVIGATE) {
if (path_.CanNavigateUp()) {
gameList_->Add(new DirButton("..", *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
gameList_->Add(new DirButton(Path(std::string("..")), *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) {
gameList_->Add(new DirButton(*it, GetBaseName(*it), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
// TODO(scoped): Hmm
gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
OnClick.Handle(this, &GameBrowser::NavigateClick);
}
}
@@ -810,19 +819,19 @@ void GameBrowser::Refresh() {
bool GameBrowser::IsCurrentPathPinned() {
const auto paths = g_Config.vPinnedPaths;
return std::find(paths.begin(), paths.end(), File::ResolvePath(path_.GetPath())) != paths.end();
return std::find(paths.begin(), paths.end(), File::ResolvePath(path_.GetPath().ToString())) != paths.end();
}
const std::vector<std::string> GameBrowser::GetPinnedPaths() {
const std::vector<Path> GameBrowser::GetPinnedPaths() {
#ifndef _WIN32
static const std::string sepChars = "/";
#else
static const std::string sepChars = "/\\";
#endif
const std::string currentPath = File::ResolvePath(path_.GetPath());
const std::string currentPath = File::ResolvePath(path_.GetPath().ToString());
const std::vector<std::string> paths = g_Config.vPinnedPaths;
std::vector<std::string> results;
std::vector<Path> results;
for (size_t i = 0; i < paths.size(); ++i) {
// We want to exclude the current path, and its direct children.
if (paths[i] == currentPath) {
@@ -836,7 +845,7 @@ const std::vector<std::string> GameBrowser::GetPinnedPaths() {
}
}
results.push_back(paths[i]);
results.push_back(Path(paths[i]));
}
return results;
}
@@ -867,7 +876,7 @@ const std::string GameBrowser::GetBaseName(const std::string &path) {
UI::EventReturn GameBrowser::GameButtonClick(UI::EventParams &e) {
GameButton *button = static_cast<GameButton *>(e.v);
UI::EventParams e2{};
e2.s = button->GamePath();
e2.s = button->GamePath().ToString();
// Insta-update - here we know we are already on the right thread.
OnChoice.Trigger(e2);
return UI::EVENT_DONE;
@@ -876,7 +885,7 @@ UI::EventReturn GameBrowser::GameButtonClick(UI::EventParams &e) {
UI::EventReturn GameBrowser::GameButtonHoldClick(UI::EventParams &e) {
GameButton *button = static_cast<GameButton *>(e.v);
UI::EventParams e2{};
e2.s = button->GamePath();
e2.s = button->GamePath().ToString();
// Insta-update - here we know we are already on the right thread.
OnHoldChoice.Trigger(e2);
return UI::EVENT_DONE;
@@ -890,13 +899,13 @@ UI::EventReturn GameBrowser::GameButtonHighlight(UI::EventParams &e) {
UI::EventReturn GameBrowser::NavigateClick(UI::EventParams &e) {
DirButton *button = static_cast<DirButton *>(e.v);
std::string text = button->GetPath();
Path text = button->GetPath();
if (button->PathAbsolute()) {
path_.SetPath(text);
} else {
path_.Navigate(text);
path_.Navigate(text.ToString());
}
g_Config.currentDirectory = path_.GetPath();
g_Config.currentDirectory = path_.GetPath().ToString();
Refresh();
return UI::EVENT_DONE;
}
@@ -927,12 +936,12 @@ UI::EventReturn GameBrowser::OnHomebrewStore(UI::EventParams &e) {
MainScreen::MainScreen() {
System_SendMessage("event", "mainscreen");
g_BackgroundAudio.SetGame("");
g_BackgroundAudio.SetGame(Path());
lastVertical_ = UseVerticalLayout();
}
MainScreen::~MainScreen() {
g_BackgroundAudio.SetGame("");
g_BackgroundAudio.SetGame(Path());
}
void MainScreen::CreateViews() {
@@ -965,7 +974,7 @@ void MainScreen::CreateViews() {
ScrollView *scrollRecentGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollRecentGames->SetTag("MainScreenRecentGames");
GameBrowser *tabRecentGames = new GameBrowser(
"!RECENT", BrowseFlags::NONE, &g_Config.bGridView1, screenManager(), "", "",
Path("!RECENT"), BrowseFlags::NONE, &g_Config.bGridView1, screenManager(), "", "",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
scrollRecentGames->Add(tabRecentGames);
gameBrowsers_.push_back(tabRecentGames);
@@ -983,7 +992,7 @@ void MainScreen::CreateViews() {
ScrollView *scrollHomebrew = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollHomebrew->SetTag("MainScreenHomebrew");
GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, BrowseFlags::STANDARD, &g_Config.bGridView2, screenManager(),
GameBrowser *tabAllGames = new GameBrowser(Path(g_Config.currentDirectory), BrowseFlags::STANDARD, &g_Config.bGridView2, screenManager(),
mm->T("How to get games"), "https://www.ppsspp.org/getgames.html",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
GameBrowser *tabHomebrew = new GameBrowser(GetSysDirectory(DIRECTORY_GAME), BrowseFlags::HOMEBREW_STORE, &g_Config.bGridView3, screenManager(),
@@ -1187,11 +1196,11 @@ void MainScreen::sendMessage(const char *message, const char *value) {
if (screenManager()->topScreen() == this) {
if (!strcmp(message, "boot")) {
LaunchFile(screenManager(), std::string(value));
LaunchFile(screenManager(), Path(std::string(value)));
}
if (!strcmp(message, "browse_fileSelect")) {
INFO_LOG(SYSTEM, "Attempting to launch: '%s'", value);
LaunchFile(screenManager(), std::string(value));
LaunchFile(screenManager(), Path(std::string(value)));
}
if (!strcmp(message, "browse_folderSelect")) {
std::string filename;
@@ -1209,7 +1218,7 @@ void MainScreen::sendMessage(const char *message, const char *value) {
}
url = "/storage/" + url;
if (startsWith(url, primaryPrefix)) {
url = g_Config.memStickDirectory + url.substr(strlen(primaryPrefix));
url = g_Config.memStickDirectory.ToString() + url.substr(strlen(primaryPrefix));
}
INFO_LOG(SYSTEM, "Translated '%s' into '%s'", value, url.c_str());
} else {
@@ -1224,8 +1233,9 @@ void MainScreen::sendMessage(const char *message, const char *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(filename);
// Don't allow browsing in the other tabs (I don't think it's possible to reach the option though)
if (tab == 1) {
gameBrowsers_[tab]->SetPath(Path(filename));
}
}
}
@@ -1289,7 +1299,7 @@ void MainScreen::DrawBackground(UIContext &dc) {
}
}
bool MainScreen::DrawBackgroundFor(UIContext &dc, const std::string &gamePath, float progress) {
bool MainScreen::DrawBackgroundFor(UIContext &dc, const Path &gamePath, float progress) {
dc.Flush();
std::shared_ptr<GameInfo> ginfo;
@@ -1306,12 +1316,8 @@ bool MainScreen::DrawBackgroundFor(UIContext &dc, const std::string &gamePath, f
return false;
}
Draw::Texture *texture = nullptr;
if (ginfo->pic1.texture) {
texture = ginfo->pic1.texture->GetTexture();
} else if (ginfo->pic0.texture) {
texture = ginfo->pic0.texture->GetTexture();
}
auto pic = ginfo->GetBGPic();
Draw::Texture *texture = pic ? pic->texture->GetTexture() : nullptr;
uint32_t color = whiteAlpha(ease(progress)) & 0xFFc0c0c0;
if (texture) {
@@ -1325,11 +1331,7 @@ bool MainScreen::DrawBackgroundFor(UIContext &dc, const std::string &gamePath, f
UI::EventReturn MainScreen::OnGameSelected(UI::EventParams &e) {
g_Config.Save("MainScreen::OnGameSelected");
#ifdef _WIN32
std::string path = ReplaceAll(e.s, "\\", "/");
#else
std::string path = e.s;
#endif
Path path(e.s);
std::shared_ptr<GameInfo> ginfo = g_gameInfoCache->GetInfo(nullptr, path, GAMEINFO_WANTBG);
if (ginfo && ginfo->fileType == IdentifiedFileType::PSP_SAVEDATA_DIRECTORY) {
return UI::EVENT_DONE;
@@ -1349,11 +1351,7 @@ UI::EventReturn MainScreen::OnGameSelected(UI::EventParams &e) {
UI::EventReturn MainScreen::OnGameHighlight(UI::EventParams &e) {
using namespace UI;
#ifdef _WIN32
std::string path = ReplaceAll(e.s, "\\", "/");
#else
std::string path = e.s;
#endif
Path path(e.s);
// Don't change when re-highlighting what's already highlighted.
if (path != highlightedGamePath_ || e.a == FF_LOSTFOCUS) {
@@ -1380,18 +1378,13 @@ UI::EventReturn MainScreen::OnGameHighlight(UI::EventParams &e) {
UI::EventReturn MainScreen::OnGameSelectedInstant(UI::EventParams &e) {
g_Config.Save("MainScreen::OnGameSelectedInstant");
#ifdef _WIN32
std::string path = ReplaceAll(e.s, "\\", "/");
#else
std::string path = e.s;
#endif
ScreenManager *screen = screenManager();
LaunchFile(screen, path);
LaunchFile(screen, Path(e.s));
return UI::EVENT_DONE;
}
UI::EventReturn MainScreen::OnGameSettings(UI::EventParams &e) {
screenManager()->push(new GameSettingsScreen("", ""));
screenManager()->push(new GameSettingsScreen(Path(), ""));
return UI::EVENT_DONE;
}
@@ -1459,7 +1452,7 @@ void MainScreen::dialogFinished(const Screen *dialog, DialogResult result) {
restoreFocusGamePath_.clear();
} else {
// Not refocusing, so we need to stop the audio.
g_BackgroundAudio.SetGame("");
g_BackgroundAudio.SetGame(Path());
}
}
}
@@ -1483,7 +1476,7 @@ void UmdReplaceScreen::CreateViews() {
ScrollView *scrollRecentGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollRecentGames->SetTag("UmdReplaceRecentGames");
GameBrowser *tabRecentGames = new GameBrowser(
"!RECENT", BrowseFlags::NONE, &g_Config.bGridView1, screenManager(), "", "",
Path("!RECENT"), BrowseFlags::NONE, &g_Config.bGridView1, screenManager(), "", "",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
scrollRecentGames->Add(tabRecentGames);
leftColumn->AddTab(mm->T("Recent"), scrollRecentGames);
@@ -1493,7 +1486,7 @@ void UmdReplaceScreen::CreateViews() {
ScrollView *scrollAllGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollAllGames->SetTag("UmdReplaceAllGames");
GameBrowser *tabAllGames = new GameBrowser(g_Config.currentDirectory, BrowseFlags::STANDARD, &g_Config.bGridView2, screenManager(),
GameBrowser *tabAllGames = new GameBrowser(Path(g_Config.currentDirectory), BrowseFlags::STANDARD, &g_Config.bGridView2, screenManager(),
mm->T("How to get games"), "https://www.ppsspp.org/getgames.html",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
@@ -1525,7 +1518,7 @@ void UmdReplaceScreen::update() {
}
UI::EventReturn UmdReplaceScreen::OnGameSelected(UI::EventParams &e) {
__UmdReplace(e.s);
__UmdReplace(Path(e.s));
TriggerFinish(DR_OK);
return UI::EVENT_DONE;
}
@@ -1536,12 +1529,12 @@ UI::EventReturn UmdReplaceScreen::OnCancel(UI::EventParams &e) {
}
UI::EventReturn UmdReplaceScreen::OnGameSettings(UI::EventParams &e) {
screenManager()->push(new GameSettingsScreen(""));
screenManager()->push(new GameSettingsScreen(Path()));
return UI::EVENT_DONE;
}
UI::EventReturn UmdReplaceScreen::OnGameSelectedInstant(UI::EventParams &e) {
__UmdReplace(e.s);
__UmdReplace(Path(e.s));
TriggerFinish(DR_OK);
return UI::EVENT_DONE;
}
@@ -1572,8 +1565,6 @@ void GridSettingsScreen::CreatePopupContents(UI::ViewGroup *parent) {
items->Add(new Choice(sy->T("Clear Recent Games List")))->OnClick.Handle(this, &GridSettingsScreen::OnRecentClearClick);
}
items->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
scroll->Add(items);
parent->Add(scroll);
}