Add a "quick-edit" button for the current server host/ip, if it's custom

This was requested by Majin on Discord, whose server changes IP
regularly for some reason.
This commit is contained in:
Henrik Rydgård committed 2026-03-14 13:45:45 +01:00
1 parent 44140e5175
commit e33fd29bd2
5 files changed
+84 -11

No files matched your search

+8 -1
View File
@@ -1023,9 +1023,16 @@ void GameSettingsScreen::CreateNetworkingSettings(UI::ViewGroup *networkingSetti
networkingSettings->Add(new ItemHeader(n->T("Ad Hoc multiplayer")));
networkingSettings->Add(new ChoiceWithValueDisplay(&g_Config.sProAdhocServer, n->T("Change proAdhocServer Address"), I18NCat::NONE))->OnClick.Add([=](UI::EventParams &) {
LinearLayout *serverRow = networkingSettings->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
serverRow->SetSpacing(0.0f);
serverRow->Add(new ChoiceWithValueDisplay(&g_Config.sProAdhocServer, n->T("Change proAdhocServer Address"), I18NCat::NONE, new LinearLayoutParams(1.0f)))->OnClick.Add([=](UI::EventParams &) {
screenManager()->push(new AdhocServerScreen(&g_Config.sProAdhocServer, n->T("Ad hoc server address")));
});
if (AdhocServerNameIsCustom()) {
serverRow->Add(new Choice(ImageID("I_EDIT_TEXT"), new LinearLayoutParams(ITEM_HEIGHT, ITEM_HEIGHT)))->OnClick.Add([this](UI::EventParams &) {
AskToEditCurrentServer(GetRequesterToken(), screenManager());
});
}
static const char *relayModes[] = {"Auto", "Yes", "No"};
PopupMultiChoice *relayModePopup = networkingSettings->Add(new PopupMultiChoice(&g_Config.iAdhocServerRelayMode, n->T("Try to use server-provided packet relay"), relayModes, 0, ARRAY_SIZE(relayModes), I18NCat::DIALOG, screenManager()));