Fix a minor misbehavior with "non-added" adhoc server names

This commit is contained in:
Henrik Rydgård
2026-03-14 23:21:08 +01:00
parent 6e216c1a7b
commit 0d2f7055fd
3 changed files with 20 additions and 1 deletions
+7 -1
View File
@@ -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);
}
+5
View File
@@ -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);
+8
View File
@@ -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<const AdhocServerScreen *>(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;