diff --git a/src/states_screens/online/network_kart_selection.cpp b/src/states_screens/online/network_kart_selection.cpp index 66efc280f..d5bde3bbb 100644 --- a/src/states_screens/online/network_kart_selection.cpp +++ b/src/states_screens/online/network_kart_selection.cpp @@ -37,9 +37,7 @@ void NetworkKartSelectionScreen::init() m_timer = getWidget("timer"); m_timer->showLabel(false); - // I18N: Time in seconds (before the voting period in network ends). - // I18N: %s specifes where the number is placed - core::stringw seconds = _("%s seconds", "%d"); + updateProgressBarText(); // change the back button image (because it makes the game quit) IconButtonWidget* back_button = getWidget("back"); @@ -71,10 +69,7 @@ void NetworkKartSelectionScreen::init() void NetworkKartSelectionScreen::onUpdate(float dt) { KartSelectionScreen::onUpdate(dt); - auto lp = LobbyProtocol::get(); - float new_value = lp->getRemainingVotingTime() / lp->getMaxVotingTime(); - if(new_value < 0) new_value = 0; - m_timer->setValue(new_value*100.0f); + updateProgressBarText(); } // onUpdate // ---------------------------------------------------------------------------- @@ -124,3 +119,22 @@ bool NetworkKartSelectionScreen::onEscapePressed() STKHost::get()->shutdown(); return true; // remove the screen } // onEscapePressed + +// ---------------------------------------------------------------------------- +void NetworkKartSelectionScreen::updateProgressBarText() +{ + if (auto lp = LobbyProtocol::get()) + { + float new_value = + lp->getRemainingVotingTime() / lp->getMaxVotingTime(); + if (new_value < 0.0f) + new_value = 0.0f; + m_timer->setValue(new_value * 100.0f); + int remaining_time = (int)(lp->getRemainingVotingTime()); + if (remaining_time < 0) + remaining_time = 0; + //I18N: In kart screen, show before the voting period in network ends. + core::stringw message = _("Remaining time: %d", remaining_time); + m_timer->setText(message); + } +} // updateProgressBarText diff --git a/src/states_screens/online/network_kart_selection.hpp b/src/states_screens/online/network_kart_selection.hpp index 34e725725..3e36074fe 100644 --- a/src/states_screens/online/network_kart_selection.hpp +++ b/src/states_screens/online/network_kart_selection.hpp @@ -53,6 +53,8 @@ private: // ------------------------------------------------------------------------ virtual bool isIgnored(const std::string& ident) const OVERRIDE { return m_available_karts.find(ident) == m_available_karts.end(); } + // ------------------------------------------------------------------------ + void updateProgressBarText(); public: /** \brief Implement per-frame callback. */ diff --git a/src/states_screens/online/tracks_screen.cpp b/src/states_screens/online/tracks_screen.cpp index 51843ea0a..4a174fc46 100644 --- a/src/states_screens/online/tracks_screen.cpp +++ b/src/states_screens/online/tracks_screen.cpp @@ -339,6 +339,9 @@ void TracksScreen::beforeAddingWidget() // ----------------------------------------------------------------------------- void TracksScreen::init() { + if (m_network_tracks) + updateProgressBarText(); + // change the back button image (because it makes the game quit) if (m_quit_server) { @@ -643,14 +646,10 @@ void TracksScreen::voteForPlayer() // ----------------------------------------------------------------------------- void TracksScreen::onUpdate(float dt) { - // The following code - if(!m_network_tracks) return; - - auto lp = LobbyProtocol::get(); - float new_value = lp->getRemainingVotingTime() / lp->getMaxVotingTime(); - if (new_value < 0) new_value = 0; - m_timer->setValue(new_value * 100.0f); + if (!m_network_tracks) + return; + updateProgressBarText(); } // onUpdate // ---------------------------------------------------------------------------- @@ -839,3 +838,22 @@ void TracksScreen::updatePlayerVotes() } } } // updatePlayerVotes + +// ---------------------------------------------------------------------------- +void TracksScreen::updateProgressBarText() +{ + if (auto lp = LobbyProtocol::get()) + { + float new_value = + lp->getRemainingVotingTime() / lp->getMaxVotingTime(); + if (new_value < 0.0f) + new_value = 0.0f; + m_timer->setValue(new_value * 100.0f); + int remaining_time = (int)(lp->getRemainingVotingTime()); + if (remaining_time < 0) + remaining_time = 0; + //I18N: In kart screen, show before the voting period in network ends. + core::stringw message = _("Remaining time: %d", remaining_time); + m_timer->setText(message); + } +} // updateProgressBarText diff --git a/src/states_screens/online/tracks_screen.hpp b/src/states_screens/online/tracks_screen.hpp index beae60c24..eee5ef41c 100644 --- a/src/states_screens/online/tracks_screen.hpp +++ b/src/states_screens/online/tracks_screen.hpp @@ -91,6 +91,8 @@ private: m_bottom_box_height = -1; m_track_icons = NULL; } + // ------------------------------------------------------------------------ + void updateProgressBarText(); public: