Display the addon command explicitly

This commit is contained in:
Benau 2019-12-09 11:35:24 +08:00
parent 32cccb358b
commit 5e016e88df
2 changed files with 20 additions and 2 deletions

View File

@ -83,6 +83,7 @@ NetworkingLobby::NetworkingLobby() : Screen("online/networking_lobby.stkgui")
m_send_button = NULL;
m_icon_bank = NULL;
m_reload_server_info = false;
m_displayed_addon_install_cmd = false;
// Allows one to update chat and counter even if dialog window is opened
setUpdateInBackground(true);
@ -169,6 +170,7 @@ void NetworkingLobby::init()
m_allow_change_team = false;
m_has_auto_start_in_server = false;
m_client_live_joinable = false;
m_displayed_addon_install_cmd = false;
m_ping_update_timer = 0;
m_start_timeout = std::numeric_limits<float>::max();
m_cur_starting_timer = std::numeric_limits<int64_t>::max();
@ -352,12 +354,16 @@ void NetworkingLobby::onUpdate(float delta)
Track* t = cl->getPlayingTrack();
if (t)
current_track = t->getName();
std::string missing_addon_track_id;
// Show addon identity so player can install it live in lobby
if (current_track.empty())
{
std::string track_id = cl->getPlayingTrackIdent();
if (StringUtils::startsWith(track_id, "addon_"))
current_track = track_id.substr(6).c_str();
{
missing_addon_track_id = track_id.substr(6).c_str();
current_track = missing_addon_track_id.c_str();
}
}
if (progress.first != std::numeric_limits<uint32_t>::max())
{
@ -406,6 +412,18 @@ void NetworkingLobby::onUpdate(float delta)
msg = _("Please wait for the current game's end.");
}
if (!missing_addon_track_id.empty() &&
!m_displayed_addon_install_cmd)
{
m_displayed_addon_install_cmd = true;
core::stringw cmd = L"/installaddon ";
cmd += missing_addon_track_id.c_str();
//I18N: In the networking lobby,
//tell user the command to install addon now
core::stringw info = _("Send %s in chat box to install addon now.", cmd);
addMoreServerInfo(info);
}
// You can live join or spectator if u have the current play track
// and network timer is synchronized, and no game protocols exist
bool no_gep = !RaceEventManager::getInstance() ||

View File

@ -82,7 +82,7 @@ private:
bool m_allow_change_team, m_has_auto_start_in_server,
m_server_configurable, m_client_live_joinable,
m_reload_server_info;
m_reload_server_info, m_displayed_addon_install_cmd;
video::ITexture* m_config_texture;
video::ITexture* m_spectate_texture;