mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Rework remote ISO UI a bit (more to come)
This commit is contained in:
parent
f9feb33ff6
commit
049a496f8b
@ -44,6 +44,7 @@
|
||||
#include "Core/System.h"
|
||||
#include "Core/WebServer.h"
|
||||
#include "UI/RemoteISOScreen.h"
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
|
||||
using namespace UI;
|
||||
|
||||
@ -271,10 +272,22 @@ static bool LoadGameList(const Path &url, std::vector<Path> &games) {
|
||||
return !games.empty();
|
||||
}
|
||||
|
||||
RemoteISOScreen::RemoteISOScreen(const Path &filename) : UIDialogScreenWithGameBackground(filename) {}
|
||||
RemoteISOScreen::RemoteISOScreen(const Path &filename) : TabbedUIDialogScreenWithGameBackground(filename) {}
|
||||
|
||||
|
||||
void RemoteISOScreen::CreateTabs() {
|
||||
auto ri = GetI18NCategory(I18NCat::REMOTEISO);
|
||||
|
||||
UI::LinearLayout *connect = AddTab("Connect", ri->T("Connect"));
|
||||
connect->SetSpacing(5.0f);
|
||||
CreateConnectTab(connect);
|
||||
|
||||
UI::LinearLayout *settings = AddTab("Settings", ri->T("Settings"));
|
||||
CreateSettingsTab(settings);
|
||||
}
|
||||
|
||||
void RemoteISOScreen::update() {
|
||||
UIDialogScreenWithBackground::update();
|
||||
TabbedUIDialogScreenWithGameBackground::update();
|
||||
|
||||
if (!WebServerStopped(WebServerFlags::DISCS)) {
|
||||
auto result = IsServerAllowed(g_Config.iRemoteISOPort);
|
||||
@ -296,21 +309,28 @@ void RemoteISOScreen::update() {
|
||||
serverRunning_ = nowRunning;
|
||||
}
|
||||
|
||||
void RemoteISOScreen::CreateViews() {
|
||||
void RemoteISOScreen::CreateConnectTab(UI::ViewGroup *tab) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
auto ri = GetI18NCategory(I18NCat::REMOTEISO);
|
||||
|
||||
Margins actionMenuMargins(0, 20, 15, 0);
|
||||
Margins contentMargins(0, 20, 5, 5);
|
||||
|
||||
ViewGroup *leftColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT, 0.4f, contentMargins));
|
||||
LinearLayout *leftColumnItems = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(WRAP_CONTENT, FILL_PARENT));
|
||||
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(300, FILL_PARENT, actionMenuMargins));
|
||||
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL);
|
||||
|
||||
if (serverRunning_) {
|
||||
leftColumnItems->Add(new NoticeView(NoticeLevel::SUCCESS, ri->T("Currently sharing"), "", new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
} else {
|
||||
leftColumnItems->Add(new NoticeView(NoticeLevel::INFO, ri->T("Not currently sharing"), "", new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
}
|
||||
|
||||
if ((RemoteISOShareType)g_Config.iRemoteISOShareType == RemoteISOShareType::RECENT) {
|
||||
leftColumnItems->Add(new TextView(ri->T("RemoteISODesc", "Games in your recent list will be shared"), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
} else {
|
||||
leftColumnItems->Add(new TextView(std::string(ri->T("Share Games(Server)")) + " " + Path(g_Config.sRemoteISOSharedDir).ToVisualString(), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
leftColumnItems->Add(new TextView(std::string(ri->T("Share Games (Server)")) + ": " + Path(g_Config.sRemoteISOSharedDir).ToVisualString(), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
}
|
||||
leftColumnItems->Add(new TextView(ri->T("RemoteISOWifi", "Note: Connect both devices to the same wifi"), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
firewallWarning_ = leftColumnItems->Add(new TextView(ri->T("RemoteISOWinFirewall", "WARNING: Windows Firewall is blocking sharing"), new LinearLayoutParams(Margins(12, 5, 0, 5))));
|
||||
@ -330,18 +350,73 @@ void RemoteISOScreen::CreateViews() {
|
||||
rightColumnItems->Add(new Choice(ri->T("Share Games (Server)")))->OnClick.Handle(this, &RemoteISOScreen::HandleStartServer);
|
||||
browseChoice->SetEnabled(true);
|
||||
}
|
||||
Choice *settingsChoice = new Choice(ri->T("Settings"));
|
||||
rightColumnItems->Add(settingsChoice)->OnClick.Handle(this, &RemoteISOScreen::HandleSettings);
|
||||
|
||||
LinearLayout *beforeBack = new LinearLayout(ORIENT_HORIZONTAL, new AnchorLayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
LinearLayout *beforeBack = new LinearLayout(ORIENT_HORIZONTAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
beforeBack->Add(leftColumn);
|
||||
beforeBack->Add(rightColumn);
|
||||
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
root_->Add(beforeBack);
|
||||
root_->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, WRAP_CONTENT, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
||||
|
||||
leftColumn->Add(leftColumnItems);
|
||||
rightColumn->Add(rightColumnItems);
|
||||
tab->Add(beforeBack);
|
||||
}
|
||||
|
||||
void RemoteISOScreen::CreateSettingsTab(UI::ViewGroup *remoteisoSettings) {
|
||||
serverRunning_ = !WebServerStopped(WebServerFlags::DISCS);
|
||||
|
||||
auto ri = GetI18NCategory(I18NCat::REMOTEISO);
|
||||
|
||||
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")));
|
||||
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_FOLDER_BROWSER)) {
|
||||
static const char *shareTypes[] = { "Recent files", "Choose directory" };
|
||||
remoteisoSettings->Add(new PopupMultiChoice(&g_Config.iRemoteISOShareType, ri->T("Files to share"), shareTypes, 0, ARRAY_SIZE(shareTypes), I18NCat::REMOTEISO, screenManager()));
|
||||
FolderChooserChoice *folderChooser = remoteisoSettings->Add(new FolderChooserChoice(GetRequesterToken(), &g_Config.sRemoteISOSharedDir, ri->T("Files to share")));
|
||||
folderChooser->SetEnabledFunc([=]() {
|
||||
return g_Config.iRemoteISOShareType == (int)RemoteISOShareType::LOCAL_FOLDER;
|
||||
});
|
||||
} else {
|
||||
// Can't pick a folder, only allow sharing recent stuff.
|
||||
g_Config.iRemoteISOShareType = (int)RemoteISOShareType::RECENT;
|
||||
}
|
||||
|
||||
UI::Choice *remoteServer = new PopupTextInputChoice(GetRequesterToken(), &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"), 100, screenManager()));
|
||||
remotePort->SetEnabledPtr(&g_Config.bRemoteISOManual);
|
||||
|
||||
UI::Choice *remoteSubdir;
|
||||
{
|
||||
PopupTextInputChoice *remoteSubdirInput = new PopupTextInputChoice(GetRequesterToken(), &g_Config.sRemoteISOSubdir, ri->T("Remote Subdirectory"), "", 255, screenManager());
|
||||
remoteSubdirInput->OnChange.Handle(this, &RemoteISOScreen::OnChangeRemoteISOSubdir);
|
||||
remoteSubdir = remoteSubdirInput;
|
||||
}
|
||||
remoteisoSettings->Add(remoteSubdir);
|
||||
remoteSubdir->SetEnabledPtr(&g_Config.bRemoteISOManual);
|
||||
|
||||
PopupSliderChoice *portChoice = new PopupSliderChoice(&g_Config.iRemoteISOPort, 0, 65535, 0, ri->T("Local Server Port", "Local Server Port"), 100, screenManager());
|
||||
remoteisoSettings->Add(portChoice);
|
||||
portChoice->SetDisabledPtr(&serverRunning_);
|
||||
}
|
||||
|
||||
static void CleanupRemoteISOSubdir() {
|
||||
// Replace spaces and force forward slashes.
|
||||
// TODO: Maybe we should uri escape this after?
|
||||
ReplaceAll(g_Config.sRemoteISOSubdir, " ", "%20");
|
||||
ReplaceAll(g_Config.sRemoteISOSubdir, "\\", "/");
|
||||
// Make sure it begins with /.
|
||||
if (g_Config.sRemoteISOSubdir.empty() || g_Config.sRemoteISOSubdir[0] != '/')
|
||||
g_Config.sRemoteISOSubdir = "/" + g_Config.sRemoteISOSubdir;
|
||||
}
|
||||
|
||||
|
||||
UI::EventReturn RemoteISOScreen::OnChangeRemoteISOSubdir(UI::EventParams &e) {
|
||||
CleanupRemoteISOSubdir();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn RemoteISOScreen::HandleStartServer(UI::EventParams &e) {
|
||||
@ -368,11 +443,6 @@ UI::EventReturn RemoteISOScreen::HandleBrowse(UI::EventParams &e) {
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
UI::EventReturn RemoteISOScreen::HandleSettings(UI::EventParams &e) {
|
||||
screenManager()->push(new RemoteISOSettingsScreen());
|
||||
return EVENT_DONE;
|
||||
}
|
||||
|
||||
RemoteISOConnectScreen::RemoteISOConnectScreen() {
|
||||
scanCancelled = false;
|
||||
scanAborted = false;
|
||||
@ -570,84 +640,3 @@ void RemoteISOBrowseScreen::CreateViews() {
|
||||
|
||||
upgradeBar_ = 0;
|
||||
}
|
||||
|
||||
RemoteISOSettingsScreen::RemoteISOSettingsScreen() {
|
||||
serverRunning_ = !WebServerStopped(WebServerFlags::DISCS);
|
||||
}
|
||||
|
||||
void RemoteISOSettingsScreen::update() {
|
||||
UIDialogScreenWithBackground::update();
|
||||
|
||||
bool nowRunning = !WebServerStopped(WebServerFlags::DISCS);
|
||||
if (serverRunning_ != nowRunning) {
|
||||
RecreateViews();
|
||||
}
|
||||
serverRunning_ = nowRunning;
|
||||
}
|
||||
|
||||
void RemoteISOSettingsScreen::CreateViews() {
|
||||
auto ri = GetI18NCategory(I18NCat::REMOTEISO);
|
||||
|
||||
ViewGroup *remoteisoSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
remoteisoSettingsScroll->SetTag("RemoteISOSettings");
|
||||
LinearLayout *remoteisoSettings = new LinearLayoutList(ORIENT_VERTICAL);
|
||||
remoteisoSettings->SetSpacing(0);
|
||||
remoteisoSettingsScroll->Add(remoteisoSettings);
|
||||
|
||||
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")));
|
||||
|
||||
if (System_GetPropertyBool(SYSPROP_HAS_FOLDER_BROWSER)) {
|
||||
static const char *shareTypes[] = { "Recent files", "Choose directory" };
|
||||
remoteisoSettings->Add(new PopupMultiChoice(&g_Config.iRemoteISOShareType, ri->T("Files to share"), shareTypes, 0, ARRAY_SIZE(shareTypes), I18NCat::REMOTEISO, screenManager()));
|
||||
FolderChooserChoice *folderChooser = remoteisoSettings->Add(new FolderChooserChoice(GetRequesterToken(), &g_Config.sRemoteISOSharedDir, ri->T("Files to share")));
|
||||
folderChooser->SetEnabledFunc([=]() {
|
||||
return g_Config.iRemoteISOShareType == (int)RemoteISOShareType::LOCAL_FOLDER;
|
||||
});
|
||||
} else {
|
||||
// Can't pick a folder, only allow sharing recent stuff.
|
||||
g_Config.iRemoteISOShareType = (int)RemoteISOShareType::RECENT;
|
||||
}
|
||||
|
||||
UI::Choice *remoteServer = new PopupTextInputChoice(GetRequesterToken(), &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"), 100, screenManager()));
|
||||
remotePort->SetEnabledPtr(&g_Config.bRemoteISOManual);
|
||||
|
||||
UI::Choice *remoteSubdir;
|
||||
{
|
||||
PopupTextInputChoice *remoteSubdirInput = new PopupTextInputChoice(GetRequesterToken(), &g_Config.sRemoteISOSubdir, ri->T("Remote Subdirectory"), "", 255, screenManager());
|
||||
remoteSubdirInput->OnChange.Handle(this, &RemoteISOSettingsScreen::OnChangeRemoteISOSubdir);
|
||||
remoteSubdir = remoteSubdirInput;
|
||||
}
|
||||
remoteisoSettings->Add(remoteSubdir);
|
||||
remoteSubdir->SetEnabledPtr(&g_Config.bRemoteISOManual);
|
||||
|
||||
PopupSliderChoice *portChoice = new PopupSliderChoice(&g_Config.iRemoteISOPort, 0, 65535, 0, ri->T("Local Server Port", "Local Server Port"), 100, screenManager());
|
||||
remoteisoSettings->Add(portChoice);
|
||||
portChoice->SetDisabledPtr(&serverRunning_);
|
||||
remoteisoSettings->Add(new Spacer(25.0));
|
||||
|
||||
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
root_->Add(remoteisoSettingsScroll);
|
||||
AddStandardBack(root_);
|
||||
}
|
||||
|
||||
static void CleanupRemoteISOSubdir() {
|
||||
// Replace spaces and force forward slashes.
|
||||
// TODO: Maybe we should uri escape this after?
|
||||
ReplaceAll(g_Config.sRemoteISOSubdir, " ", "%20");
|
||||
ReplaceAll(g_Config.sRemoteISOSubdir, "\\", "/");
|
||||
// Make sure it begins with /.
|
||||
if (g_Config.sRemoteISOSubdir.empty() || g_Config.sRemoteISOSubdir[0] != '/')
|
||||
g_Config.sRemoteISOSubdir = "/" + g_Config.sRemoteISOSubdir;
|
||||
}
|
||||
|
||||
UI::EventReturn RemoteISOSettingsScreen::OnChangeRemoteISOSubdir(UI::EventParams &e) {
|
||||
CleanupRemoteISOSubdir();
|
||||
return UI::EVENT_DONE;
|
||||
}
|
||||
|
@ -24,21 +24,27 @@
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
#include "UI/MainScreen.h"
|
||||
#include "UI/TabbedDialogScreen.h"
|
||||
|
||||
class RemoteISOScreen : public UIDialogScreenWithGameBackground {
|
||||
class RemoteISOScreen : public TabbedUIDialogScreenWithGameBackground {
|
||||
public:
|
||||
RemoteISOScreen(const Path &filename);
|
||||
|
||||
const char *tag() const override { return "RemoteISO"; }
|
||||
void CreateTabs() override;
|
||||
|
||||
protected:
|
||||
UI::EventReturn OnChangeRemoteISOSubdir(UI::EventParams &e);
|
||||
|
||||
void CreateConnectTab(UI::ViewGroup *viewGroup);
|
||||
void CreateSettingsTab(UI::ViewGroup *viewGroup);
|
||||
bool ShowSearchControls() const override { return false; }
|
||||
|
||||
void update() override;
|
||||
void CreateViews() override;
|
||||
|
||||
UI::EventReturn HandleStartServer(UI::EventParams &e);
|
||||
UI::EventReturn HandleStopServer(UI::EventParams &e);
|
||||
UI::EventReturn HandleBrowse(UI::EventParams &e);
|
||||
UI::EventReturn HandleSettings(UI::EventParams &e);
|
||||
|
||||
UI::TextView *firewallWarning_ = nullptr;
|
||||
bool serverRunning_ = false;
|
||||
@ -97,20 +103,5 @@ protected:
|
||||
std::vector<Path> games_;
|
||||
};
|
||||
|
||||
class RemoteISOSettingsScreen : public UIDialogScreenWithBackground {
|
||||
public:
|
||||
RemoteISOSettingsScreen();
|
||||
|
||||
const char *tag() const override { return "RemoteISOSettings"; }
|
||||
|
||||
protected:
|
||||
void update() override;
|
||||
void CreateViews() override;
|
||||
|
||||
UI::EventReturn OnChangeRemoteISOSubdir(UI::EventParams &e);
|
||||
|
||||
bool serverRunning_ = false;
|
||||
};
|
||||
|
||||
std::string RemoteSubdir();
|
||||
std::string FormatRemoteISOUrl(const char *host, int port, const char *subdir);
|
||||
|
Loading…
Reference in New Issue
Block a user