From 3222af5f7afe5db2276e619b48f5bec01793f836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 16 Nov 2017 13:33:10 +0100 Subject: [PATCH] Make remoteiso_subdir and server editable on Android. Fixes #10142. Really need a better mechanism for these fields. --- UI/GameSettingsScreen.cpp | 1 + UI/NativeApp.cpp | 6 +++++- UI/RemoteISOScreen.cpp | 24 +++++++++++++++++++++++- UI/RemoteISOScreen.h | 3 +++ 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index aeae190a76..b9a77aab0e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1108,6 +1108,7 @@ UI::EventReturn GameSettingsScreen::OnChangeNickname(UI::EventParams &e) { g_Config.sNickName = StripSpaces(name); } #elif defined(__ANDROID__) + // TODO: The return value is handled in NativeApp::inputbox_completed. This is horrific. System_SendMessage("inputbox", ("nickname:" + g_Config.sNickName).c_str()); #endif return UI::EVENT_DONE; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 3c54be8a3c..f9e8a5fb03 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -874,8 +874,12 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { std::string setString = inputboxValue.size() > 1 ? inputboxValue[1] : ""; if (inputboxValue[0] == "IP") g_Config.proAdhocServer = setString; - if (inputboxValue[0] == "nickname") + else if (inputboxValue[0] == "nickname") g_Config.sNickName = setString; + else if (inputboxValue[0] == "remoteiso_subdir") + g_Config.sRemoteISOSubdir = setString; + else if (inputboxValue[0] == "remoteiso_server") + g_Config.sLastRemoteISOServer = setString; inputboxValue.clear(); } if (msg == "bgImage_updated") { diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 39a04f157e..71cf9bf88c 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -675,13 +675,25 @@ void RemoteISOSettingsScreen::CreateViews() { remoteisoSettings->Add(new ItemHeader(ri->T("Remote disc streaming"))); remoteisoSettings->Add(new CheckBox(&g_Config.bRemoteISOManual, ri->T("Manual Mode Client", "Manual Mode Client"))); +#if !defined(MOBILE_DEVICE) PopupTextInputChoice *remoteServer = remoteisoSettings->Add(new PopupTextInputChoice(&g_Config.sLastRemoteISOServer, ri->T("Remote Server"), "", 255, screenManager())); +#else + ChoiceWithValueDisplay *remoteServer = new ChoiceWithValueDisplay(&g_Config.sLastRemoteISOServer, ri->T("Remote Server"), nullptr); + remoteisoSettings->Add(remoteServer); + remoteServer->OnClick.Handle(this, &RemoteISOSettingsScreen::OnClickRemoteServer); +#endif remoteServer->SetEnabledPtr(&g_Config.bRemoteISOManual); PopupSliderChoice *remotePort = remoteisoSettings->Add(new PopupSliderChoice(&g_Config.iLastRemoteISOPort, 0, 65535, ri->T("Remote Port", "Remote Port"), 100, screenManager())); remotePort->SetEnabledPtr(&g_Config.bRemoteISOManual); +#if !defined(MOBILE_DEVICE) PopupTextInputChoice *remoteSubdir = remoteisoSettings->Add(new PopupTextInputChoice(&g_Config.sRemoteISOSubdir, ri->T("Remote Subdirectory"), "", 255, screenManager())); - remoteSubdir->SetEnabledPtr(&g_Config.bRemoteISOManual); remoteSubdir->OnChange.Handle(this, &RemoteISOSettingsScreen::OnChangeRemoteISOSubdir); +#else + ChoiceWithValueDisplay *remoteSubdir = remoteisoSettings->Add( + new ChoiceWithValueDisplay(&g_Config.sRemoteISOSubdir, ri->T("Remote Subdirectory"), nullptr)); + remoteSubdir->OnClick.Handle(this, &RemoteISOSettingsScreen::OnClickRemoteISOSubdir); +#endif + remoteSubdir->SetEnabledPtr(&g_Config.bRemoteISOManual); PopupSliderChoice *portChoice = new PopupSliderChoice(&g_Config.iRemoteISOPort, 0, 65535, ri->T("Local Server Port", "Local Server Port"), 100, screenManager()); remoteisoSettings->Add(portChoice); @@ -693,6 +705,16 @@ void RemoteISOSettingsScreen::CreateViews() { AddStandardBack(root_); } +UI::EventReturn RemoteISOSettingsScreen::OnClickRemoteServer(UI::EventParams &e) { + System_SendMessage("inputbox", ("remoteiso_server:" + g_Config.sLastRemoteISOServer).c_str()); + return UI::EVENT_DONE; +} + +UI::EventReturn RemoteISOSettingsScreen::OnClickRemoteISOSubdir(UI::EventParams &e) { + System_SendMessage("inputbox", ("remoteiso_subdir:" + g_Config.sRemoteISOSubdir).c_str()); + return UI::EVENT_DONE; +} + UI::EventReturn RemoteISOSettingsScreen::OnChangeRemoteISOSubdir(UI::EventParams &e) { //Conform to HTTP standards ReplaceAll(g_Config.sRemoteISOSubdir, " ", "%20"); diff --git a/UI/RemoteISOScreen.h b/UI/RemoteISOScreen.h index 85995e2194..b7f7ff0f5c 100644 --- a/UI/RemoteISOScreen.h +++ b/UI/RemoteISOScreen.h @@ -89,7 +89,10 @@ class RemoteISOSettingsScreen : public UIDialogScreenWithBackground { public: RemoteISOSettingsScreen(); + UI::EventReturn OnClickRemoteISOSubdir(UI::EventParams &e); + UI::EventReturn OnClickRemoteServer(UI::EventParams &e); protected: + void update() override; void CreateViews() override;