Skip to content

Commit

Permalink
Merge pull request #18627 from hrydgard/remote-tab
Browse files Browse the repository at this point in the history
Remote game streaming: Add an option to put a tab on the main screen
  • Loading branch information
hrydgard committed Dec 28, 2023
2 parents acbd32c + 91942af commit 2074ccd
Show file tree
Hide file tree
Showing 49 changed files with 103 additions and 31 deletions.
1 change: 1 addition & 0 deletions Core/Config.cpp
Expand Up @@ -265,6 +265,7 @@ static const ConfigSetting generalSettings[] = {
ConfigSetting("RemoteShareOnStartup", &g_Config.bRemoteShareOnStartup, false, CfgFlag::DEFAULT),
ConfigSetting("RemoteISOSubdir", &g_Config.sRemoteISOSubdir, "/", CfgFlag::DEFAULT),
ConfigSetting("RemoteDebuggerOnStartup", &g_Config.bRemoteDebuggerOnStartup, false, CfgFlag::DEFAULT),
ConfigSetting("RemoteTab", &g_Config.bRemoteTab, false, CfgFlag::DEFAULT),

#ifdef __ANDROID__
ConfigSetting("ScreenRotation", &g_Config.iScreenRotation, ROTATION_AUTO_HORIZONTAL),
Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Expand Up @@ -129,6 +129,7 @@ struct Config {
bool bRemoteShareOnStartup;
std::string sRemoteISOSubdir;
bool bRemoteDebuggerOnStartup;
bool bRemoteTab;
bool bMemStickInserted;
int iMemStickSizeGB;
bool bLoadPlugins;
Expand Down
32 changes: 30 additions & 2 deletions UI/MainScreen.cpp
Expand Up @@ -55,6 +55,7 @@
#include "UI/GameSettingsScreen.h"
#include "UI/MiscScreens.h"
#include "UI/ControlMappingScreen.h"
#include "UI/RemoteISOScreen.h"
#include "UI/DisplayLayoutScreen.h"
#include "UI/SavedataScreen.h"
#include "UI/Store.h"
Expand Down Expand Up @@ -645,6 +646,9 @@ UI::EventReturn GameBrowser::OnHomeClick(UI::EventParams &e) {
// Maybe we should have no home directory in this case. Or it should just navigate to the root
// of the current folder tree.
Path GameBrowser::HomePath() {
if (!homePath_.empty()) {
return homePath_;
}
#if PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(SWITCH) || defined(USING_WIN_UI) || PPSSPP_PLATFORM(UWP)
return g_Config.memStickDirectory;
#else
Expand Down Expand Up @@ -771,7 +775,7 @@ void GameBrowser::Refresh() {
// 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)) {
if ((browseFlags_ & BrowseFlags::BROWSE) && 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);
}
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
Expand Down Expand Up @@ -932,7 +936,7 @@ void GameBrowser::Refresh() {
Add(new TextView(mm->T("UseBrowseOrLoad", "Use Browse to choose a folder, or Load to choose a file.")));
}

if (!lastText_.empty() && gameButtons.empty()) {
if (!lastText_.empty()) {
Add(new Spacer());
Add(new Choice(lastText_, new UI::LinearLayoutParams(UI::WRAP_CONTENT, UI::WRAP_CONTENT)))->OnClick.Handle(this, &GameBrowser::LastClick);
}
Expand Down Expand Up @@ -1108,6 +1112,7 @@ void MainScreen::CreateViews() {
ScrollView *scrollHomebrew = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollHomebrew->SetTag("MainScreenHomebrew");


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",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
Expand All @@ -1133,6 +1138,29 @@ void MainScreen::CreateViews() {
tabAllGames->OnHighlight.Handle(this, &MainScreen::OnGameHighlight);
tabHomebrew->OnHighlight.Handle(this, &MainScreen::OnGameHighlight);

if (g_Config.bRemoteTab && !g_Config.sLastRemoteISOServer.empty()) {
auto ri = GetI18NCategory(I18NCat::REMOTEISO);

ScrollView *scrollRemote = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollRemote->SetTag("MainScreenRemote");

Path remotePath(FormatRemoteISOUrl(g_Config.sLastRemoteISOServer.c_str(), g_Config.iLastRemoteISOPort, RemoteSubdir().c_str()));

GameBrowser *tabRemote = new GameBrowser(remotePath, BrowseFlags::NAVIGATE, &g_Config.bGridView3, screenManager(),
ri->T("Remote disc streaming"), "https://www.ppsspp.org/docs/reference/disc-streaming",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
tabRemote->SetHomePath(remotePath);

scrollRemote->Add(tabRemote);
gameBrowsers_.push_back(tabRemote);

tabHolder_->AddTab(ri->T("Remote disc streaming"), scrollRemote);

tabRemote->OnChoice.Handle(this, &MainScreen::OnGameSelectedInstant);
tabRemote->OnHoldChoice.Handle(this, &MainScreen::OnGameSelected);
tabRemote->OnHighlight.Handle(this, &MainScreen::OnGameHighlight);
}

if (g_Config.HasRecentIsos()) {
tabHolder_->SetCurrentTab(0, true);
} else if (g_Config.iMaxRecent > 0) {
Expand Down
15 changes: 11 additions & 4 deletions UI/MainScreen.h
Expand Up @@ -32,10 +32,11 @@ enum GameBrowserFlags {
enum class BrowseFlags {
NONE = 0,
NAVIGATE = 1,
ARCHIVES = 2,
PIN = 4,
HOMEBREW_STORE = 8,
STANDARD = 1 | 2 | 4,
BROWSE = 2,
ARCHIVES = 4,
PIN = 8,
HOMEBREW_STORE = 16,
STANDARD = 1 | 2 | 4 | 8,
};
ENUM_CLASS_BITOPS(BrowseFlags);

Expand All @@ -55,6 +56,10 @@ class GameBrowser : public UI::LinearLayout {
void Draw(UIContext &dc) override;
void Update() override;

void SetHomePath(const Path &path) {
homePath_ = path;
}

protected:
virtual bool DisplayTopBar();
virtual bool HasSpecialFiles(std::vector<Path> &filenames);
Expand All @@ -63,6 +68,8 @@ class GameBrowser : public UI::LinearLayout {

void Refresh();

Path homePath_;

private:
bool IsCurrentPathPinned();
const std::vector<Path> GetPinnedPaths();
Expand Down
36 changes: 12 additions & 24 deletions UI/RemoteISOScreen.cpp
Expand Up @@ -96,7 +96,7 @@ static ServerAllowStatus IsServerAllowed(int port) {
#endif
}

static std::string RemoteSubdir() {
std::string RemoteSubdir() {
if (g_Config.bRemoteISOManual) {
return g_Config.sRemoteISOSubdir;
}
Expand Down Expand Up @@ -484,9 +484,13 @@ ScanStatus RemoteISOConnectScreen::GetStatus() {
return status_;
}

std::string FormatRemoteISOUrl(const char *host, int port, const char *subdir) {
return StringFromFormat("http://%s:%d%s", host, port, subdir);
}

void RemoteISOConnectScreen::ExecuteLoad() {
std::string subdir = RemoteSubdir();
url_ = StringFromFormat("http://%s:%d%s", host_.c_str(), port_, subdir.c_str());
url_ = FormatRemoteISOUrl(host_.c_str(), port_, subdir.c_str());
bool result = LoadGameList(Path(url_), games_);
if (scanAborted) {
return;
Expand All @@ -501,25 +505,6 @@ void RemoteISOConnectScreen::ExecuteLoad() {
status_ = result ? ScanStatus::LOADED : ScanStatus::FAILED;
}

class RemoteGameBrowser : public GameBrowser {
public:
RemoteGameBrowser(const Path &url, BrowseFlags browseFlags, bool *gridStyle, ScreenManager *screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr)
: GameBrowser(url, browseFlags, gridStyle, screenManager, lastText, lastLink, layoutParams) {
initialPath_ = url;
}

protected:
Path HomePath() override {
return initialPath_;
}

Path initialPath_;
};

RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games)
: url_(url), games_(games) {
}

void RemoteISOBrowseScreen::CreateViews() {
auto di = GetI18NCategory(I18NCat::DIALOG);
auto ri = GetI18NCategory(I18NCat::REMOTEISO);
Expand All @@ -535,9 +520,11 @@ void RemoteISOBrowseScreen::CreateViews() {

ScrollView *scrollRecentGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollRecentGames->SetTag("RemoteGamesTab");
GameBrowser *tabRemoteGames = new RemoteGameBrowser(
Path(url_), BrowseFlags::PIN | BrowseFlags::NAVIGATE, &g_Config.bGridView1, screenManager(), "", "",
GameBrowser *tabRemoteGames = new GameBrowser(
Path(url_), BrowseFlags::NAVIGATE, &g_Config.bGridView1, screenManager(), "", "",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
tabRemoteGames->SetHomePath(Path(url_));

scrollRecentGames->Add(tabRemoteGames);
gameBrowsers_.push_back(tabRemoteGames);

Expand Down Expand Up @@ -599,13 +586,14 @@ void RemoteISOSettingsScreen::CreateViews() {
remoteisoSettings->Add(new ItemHeader(ri->T("Remote disc streaming")));
remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteShareOnStartup, ri->T("Share on PPSSPP startup")));
remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteISOManual, ri->T("Manual Mode Client", "Manually configure client")));
remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteTab, ri->T("Show Remote tab on main screen")));

UI::Choice *remoteServer;
remoteServer = new PopupTextInputChoice(&g_Config.sLastRemoteISOServer, ri->T("Remote Server"), "", 255, screenManager());
remoteisoSettings->Add(remoteServer);
remoteServer->SetEnabledPtr(&g_Config.bRemoteISOManual);

PopupSliderChoice *remotePort = remoteisoSettings->Add(new PopupSliderChoice(&g_Config.iLastRemoteISOPort, 0, 65535, 0, ri->T("Remote Port", "Remote Port"), 100, screenManager()));
PopupSliderChoice *remotePort = remoteisoSettings->Add(new PopupSliderChoice(&g_Config.iLastRemoteISOPort, 0, 65535, 0, ri->T("Remote Port"), 100, screenManager()));
remotePort->SetEnabledPtr(&g_Config.bRemoteISOManual);

UI::Choice *remoteSubdir;
Expand Down
6 changes: 5 additions & 1 deletion UI/RemoteISOScreen.h
Expand Up @@ -85,7 +85,8 @@ class RemoteISOConnectScreen : public UIDialogScreenWithBackground {

class RemoteISOBrowseScreen : public MainScreen {
public:
RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games);
RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games)
: url_(url), games_(games) {}

const char *tag() const override { return "RemoteISOBrowse"; }

Expand All @@ -110,3 +111,6 @@ class RemoteISOSettingsScreen : public UIDialogScreenWithBackground {

bool serverRunning_ = false;
};

std::string RemoteSubdir();
std::string FormatRemoteISOUrl(const char *host, int port, const char *subdir);
1 change: 1 addition & 0 deletions assets/lang/ar_AE.ini
Expand Up @@ -1058,6 +1058,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = ‎إعدادات
Share Games (Server) = ‎مشاركة الألعاب (السرفر)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = ‎توقف عن المشاركة
Stopping.. = ‎يتوقف...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/az_AZ.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/bg_BG.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/ca_ES.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/cz_CZ.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/da_DK.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/de_DE.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Einstellungen
Share Games (Server) = Spiele freigeben (Server)
Share on PPSSPP startup = Beim Start von PPSSPP freigeben
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Freigabe stoppen
Stopping.. = Stoppe...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/dr_ID.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/en_US.ini
Expand Up @@ -1074,6 +1074,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/es_ES.ini
Expand Up @@ -1051,6 +1051,7 @@ RemoteISOWinFirewall = AVISO: Firewall de Windows está bloqueando el acceso
Settings = Ajustes
Share Games (Server) = Compartir juegos (servidor)
Share on PPSSPP startup = Compartir al iniciar PPSSPP
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Parar de compartir
Stopping.. = Parando...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/es_LA.ini
Expand Up @@ -1052,6 +1052,7 @@ RemoteISOWinFirewall = ADVERTENCIA: cortafuegos de Windows está bloqueando el a
Settings = Opciones
Share Games (Server) = Compartir juegos (servidor)
Share on PPSSPP startup = Compartir al empezar PSSPP
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Parar
Stopping.. = Deteniendo...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/fa_IR.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/fi_FI.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = VAROITUS: Windowsin palomuuri estää jakamisen
Settings = Asetukset
Share Games (Server) = Jaa pelejä (palvelin)
Share on PPSSPP startup = Jaa käynnistyksen yhteydessä
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Lopeta jakaminen
Stopping.. = Lopetetaan...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/fr_FR.ini
Expand Up @@ -1041,6 +1041,7 @@ RemoteISOWinFirewall = AVERTISSEMENT : Le pare-feu Windows bloque le partage.
Settings = Paramètres
Share Games (Server) = Partager les jeux (serveur)
Share on PPSSPP startup = Partager au démarrage de PPSSPP
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Arrêter le partage
Stopping.. = Arrêt en cours...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/gl_ES.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/gr_EL.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Ρυθμίσεις
Share Games (Server) = Διαμοιρασμός παιχνιδιών (διακομιστής)
Share on PPSSPP startup = Διαμοιρασμός κατά την εκκίνηση PPSSPP
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Διακοπή διαμοιρασμού
Stopping.. = Διακοπή...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/he_IL.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/he_IL_invert.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Settings
Share Games (Server) = Share games (server)
Share on PPSSPP startup = Share on PPSSPP startup
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Stop sharing
Stopping.. = Stopping...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/hr_HR.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Vatrozid blokira dijeljenje
Settings = Postavke
Share Games (Server) = Dijeli igre (server)
Share on PPSSPP startup = Dijeli kada se PPSSPP upali
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Zaustavi dijeljenje
Stopping.. = Zaustavljanje...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/hu_HU.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = WARNING: Windows Firewall is blocking sharing
Settings = Beállítások
Share Games (Server) = Játékok megosztása (szerver)
Share on PPSSPP startup = Játékok megosztása a PPSSPP indulásakor
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Megosztás leállítása
Stopping.. = Leállítás alatt...

Expand Down
1 change: 1 addition & 0 deletions assets/lang/id_ID.ini
Expand Up @@ -1050,6 +1050,7 @@ RemoteISOWinFirewall = Peringatan: Windows firewall memblokir berbagi
Settings = Pengaturan
Share Games (Server) = Bagikan permainan (pelayan)
Share on PPSSPP startup = Bagikan saat memulai PPSSPP
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Hentikan pembagian
Stopping.. = Menghentikan...
Expand Down
1 change: 1 addition & 0 deletions assets/lang/it_IT.ini
Expand Up @@ -1051,6 +1051,7 @@ RemoteISOWinFirewall = ATTENZIONE: Il firewall di Windows sta bloccando la condi
Settings = Impostazioni
Share Games (Server) = Giochi condivisi (server)
Share on PPSSPP startup = Condividi all'avvio di PPSSPP
Show Remote tab on main screen = Show Remote tab on main screen
Stop Sharing = Interrompi condivisione
Stopping.. = Interruzione in corso...

Expand Down

0 comments on commit 2074ccd

Please sign in to comment.