diff --git a/Source/DiabloUI/selgame.cpp b/Source/DiabloUI/selgame.cpp index 93445abbc..aea6e893b 100644 --- a/Source/DiabloUI/selgame.cpp +++ b/Source/DiabloUI/selgame.cpp @@ -21,6 +21,7 @@ char selgame_Label[32]; char selgame_Ip[129] = ""; char selgame_Password[16] = ""; char selgame_Description[512]; +std::string selgame_Title; bool selgame_enteringGame; int selgame_selectedGame; bool selgame_endMenu; @@ -112,7 +113,11 @@ void selgame_GameSelection_Init() return; } - CopyUtf8(selgame_Ip, sgOptions.Network.szPreviousHost, sizeof(selgame_Ip)); + if (provider == SELCONN_ZT) { + CopyUtf8(selgame_Ip, sgOptions.Network.szPreviousZTGame, sizeof(selgame_Ip)); + } else { + CopyUtf8(selgame_Ip, sgOptions.Network.szPreviousHost, sizeof(selgame_Ip)); + } selgame_FreeVectors(); @@ -185,11 +190,15 @@ void selgame_GameSelection_Focus(int value) CopyUtf8(selgame_Description, _("Create a new public game that anyone can join with a difficulty setting of your choice."), sizeof(selgame_Description)); break; case 2: - CopyUtf8(selgame_Description, _("Enter an IP or a hostname and join a game already in progress at that address."), sizeof(selgame_Description)); + if (provider == SELCONN_ZT) { + CopyUtf8(selgame_Description, _("Enter a Game ID to join a game already in progress."), sizeof(selgame_Description)); + } else { + CopyUtf8(selgame_Description, _("Enter an IP or a hostname to join a game already in progress."), sizeof(selgame_Description)); + } break; default: const auto &gameInfo = Gamelist[vecSelGameDlgItems[value]->m_value - 3]; - std::string infoString = _("Join the public game already in progress at this address."); + std::string infoString = _("Join the public game already in progress."); infoString.append("\n\n"); if (IsGameCompatible(gameInfo.gameData)) { string_view difficulty; @@ -303,13 +312,21 @@ void selgame_GameSelection_Select(int value) break; } case 2: { - title = _("Join TCP Games").c_str(); + selgame_Title = fmt::format(_("Join {:s} Games"), _(ConnectionNames[provider])); + title = selgame_Title.c_str(); + + const char *inputHint; + if (provider == SELCONN_ZT) { + inputHint = _("Enter Game ID").c_str(); + } else { + inputHint = _("Enter address").c_str(); + } SDL_Rect rect4 = { (Sint16)(PANEL_LEFT + 305), (Sint16)(UI_OFFSET_Y + 211), 285, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Enter address").c_str(), rect4, UiFlags::AlignCenter | UiFlags::FontSize30 | UiFlags::ColorUiSilver, 3)); + vecSelGameDialog.push_back(std::make_unique(inputHint, rect4, UiFlags::AlignCenter | UiFlags::FontSize30 | UiFlags::ColorUiSilver, 3)); SDL_Rect rect5 = { (Sint16)(PANEL_LEFT + 305), (Sint16)(UI_OFFSET_Y + 314), 285, 33 }; - vecSelGameDialog.push_back(std::make_unique(_("Enter address"), selgame_Ip, 128, false, rect5, UiFlags::FontSize24 | UiFlags::ColorUiGold)); + vecSelGameDialog.push_back(std::make_unique(inputHint, selgame_Ip, 128, false, rect5, UiFlags::FontSize24 | UiFlags::ColorUiGold)); SDL_Rect rect6 = { (Sint16)(PANEL_LEFT + 299), (Sint16)(UI_OFFSET_Y + 427), 140, 35 }; vecSelGameDialog.push_back(std::make_unique(_("OK"), &UiFocusNavigationSelect, rect6, UiFlags::AlignCenter | UiFlags::VerticalCenter | UiFlags::FontSize30 | UiFlags::ColorUiGold)); @@ -564,7 +581,11 @@ void selgame_Password_Select(int /*value*/) SDL_ClearError(); if (selgame_selectedGame > 1) { - strcpy(sgOptions.Network.szPreviousHost, selgame_Ip); + if (provider == SELCONN_ZT) { + strcpy(sgOptions.Network.szPreviousZTGame, selgame_Ip); + } else { + strcpy(sgOptions.Network.szPreviousHost, selgame_Ip); + } if (SNetJoinGame(selgame_Ip, gamePassword, gdwPlayerId)) { if (!IsGameCompatibleWithErrorMessage(*m_game_data)) { InitGameInfo(); diff --git a/Source/options.cpp b/Source/options.cpp index d4ae9e863..c2703ad05 100644 --- a/Source/options.cpp +++ b/Source/options.cpp @@ -327,6 +327,7 @@ void LoadOptions() GetIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem, sizeof(sgOptions.Hellfire.szItem), ""); GetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress, sizeof(sgOptions.Network.szBindAddress), "0.0.0.0"); + GetIniValue("Network", "Previous Game ID", sgOptions.Network.szPreviousZTGame, sizeof(sgOptions.Network.szPreviousZTGame), ""); GetIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost, sizeof(sgOptions.Network.szPreviousHost), ""); for (size_t i = 0; i < QUICK_MESSAGE_OPTIONS; i++) @@ -358,6 +359,7 @@ void SaveOptions() SetIniValue("Hellfire", "SItem", sgOptions.Hellfire.szItem); SetIniValue("Network", "Bind Address", sgOptions.Network.szBindAddress); + SetIniValue("Network", "Previous Game ID", sgOptions.Network.szPreviousZTGame); SetIniValue("Network", "Previous Host", sgOptions.Network.szPreviousHost); for (size_t i = 0; i < QUICK_MESSAGE_OPTIONS; i++) diff --git a/Source/options.h b/Source/options.h index 2ac3e33a7..dde760665 100644 --- a/Source/options.h +++ b/Source/options.h @@ -508,6 +508,8 @@ struct NetworkOptions : OptionCategoryBase { /** @brief Optionally bind to a specific network interface. */ char szBindAddress[129]; + /** @brief Most recently entered ZeroTier Game ID. */ + char szPreviousZTGame[129]; /** @brief Most recently entered Hostname in join dialog. */ char szPreviousHost[129]; /** @brief What network port to use. */