diff --git a/UI/AdhocServerScreen.cpp b/UI/AdhocServerScreen.cpp index ec1711fbdf..ed9b172124 100644 --- a/UI/AdhocServerScreen.cpp +++ b/UI/AdhocServerScreen.cpp @@ -394,12 +394,18 @@ void AdhocServerScreen::CreatePopupContents(UI::ViewGroup *parent) { CollapsibleSection *customSection = innerView->Add(new CollapsibleSection(n->T("Custom server list"), new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT))); if (!currentServerFound) { - // Add a virtual entry. + // Add the entry to one of the lists. AdhocServerListEntry entry; entry.name = editValue_; entry.host = editValue_; // Let's do a heuristic, we don't have a good value here.. entry.mode = (AdhocServerRelayMode)g_Config.iAdhocServerRelayMode == AdhocServerRelayMode::AlwaysOn ? AdhocDataMode::AemuPostoffice : AdhocDataMode::P2P; + if (entry.mode == AdhocDataMode::AemuPostoffice) { + g_Config.vCustomAdhocServerListWithRelay.insert(g_Config.vCustomAdhocServerListWithRelay.begin(), editValue_); + } else { + g_Config.vCustomAdhocServerList.insert(g_Config.vCustomAdhocServerList.begin(), editValue_); + } + recreateParent_ = true; AddButtonFromEntry(customSection, entry, true); } diff --git a/UI/AdhocServerScreen.h b/UI/AdhocServerScreen.h index b220bed022..fceaabe66d 100644 --- a/UI/AdhocServerScreen.h +++ b/UI/AdhocServerScreen.h @@ -19,6 +19,10 @@ public: const char *tag() const override { return "AdhocServer"; } + bool RecreateParent() const { + return recreateParent_; + } + protected: void OnCompleted(DialogResult result) override; bool CanComplete(DialogResult result) override; @@ -52,6 +56,7 @@ private: bool toResolveResult_ = false; std::string lastResolved_ = ""; bool lastResolvedResult_ = false; + bool recreateParent_ = false; }; void AskToEditCurrentServer(int requestToken, ScreenManager *screenManager); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a774dbc036..85cd7f7658 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1684,6 +1684,14 @@ void GameSettingsScreen::dialogFinished(const Screen *dialog, DialogResult resul } bool recreate = false; + + if (equals(dialog->tag(), "AdhocServer")) { + const AdhocServerScreen *scr = dynamic_cast(dialog); + if (scr && scr->RecreateParent()) { + recreate = true; + } + } + if (result == DialogResult::DR_OK) { g_Config.iFpsLimit1 = iAlternateSpeedPercent1_ < 0 ? -1 : (iAlternateSpeedPercent1_ * 60) / 100; g_Config.iFpsLimit2 = iAlternateSpeedPercent2_ < 0 ? -1 : (iAlternateSpeedPercent2_ * 60) / 100;