Fix timer paused if user dialog opened
This commit is contained in:
parent
59f29ca975
commit
8c8a0f8452
@ -144,8 +144,8 @@ void NetworkingLobby::init()
|
|||||||
m_allow_change_team = false;
|
m_allow_change_team = false;
|
||||||
m_has_auto_start_in_server = false;
|
m_has_auto_start_in_server = false;
|
||||||
m_ping_update_timer = 0.0f;
|
m_ping_update_timer = 0.0f;
|
||||||
m_cur_starting_timer = m_start_timeout =
|
m_start_timeout = std::numeric_limits<float>::max();
|
||||||
m_server_max_player = std::numeric_limits<float>::max();
|
m_cur_starting_timer = std::numeric_limits<int64_t>::max();
|
||||||
m_min_start_game_players = 0;
|
m_min_start_game_players = 0;
|
||||||
m_timeout_message->setVisible(false);
|
m_timeout_message->setVisible(false);
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ void NetworkingLobby::onUpdate(float delta)
|
|||||||
total_msg += L"\n";
|
total_msg += L"\n";
|
||||||
}
|
}
|
||||||
m_text_bubble->setText(total_msg, true);
|
m_text_bubble->setText(total_msg, true);
|
||||||
m_cur_starting_timer = std::numeric_limits<float>::max();
|
m_cur_starting_timer = std::numeric_limits<int64_t>::max();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,13 +256,14 @@ void NetworkingLobby::onUpdate(float delta)
|
|||||||
m_timeout_message->setVisible(true);
|
m_timeout_message->setVisible(true);
|
||||||
unsigned cur_player = m_player_list->getItemCount();
|
unsigned cur_player = m_player_list->getItemCount();
|
||||||
if (cur_player >= m_min_start_game_players &&
|
if (cur_player >= m_min_start_game_players &&
|
||||||
m_cur_starting_timer == std::numeric_limits<float>::max())
|
m_cur_starting_timer == std::numeric_limits<int64_t>::max())
|
||||||
{
|
{
|
||||||
m_cur_starting_timer = m_start_timeout;
|
m_cur_starting_timer = (int64_t)StkTime::getRealTimeMs() +
|
||||||
|
(int64_t)(m_start_timeout * 1000.0);
|
||||||
}
|
}
|
||||||
else if (cur_player < m_min_start_game_players)
|
else if (cur_player < m_min_start_game_players)
|
||||||
{
|
{
|
||||||
m_cur_starting_timer = std::numeric_limits<float>::max();
|
m_cur_starting_timer = std::numeric_limits<int64_t>::max();
|
||||||
//I18N: In the networking lobby, display the number of players
|
//I18N: In the networking lobby, display the number of players
|
||||||
//required to start a game for owner-less server
|
//required to start a game for owner-less server
|
||||||
core::stringw msg =
|
core::stringw msg =
|
||||||
@ -272,15 +273,16 @@ void NetworkingLobby::onUpdate(float delta)
|
|||||||
m_timeout_message->setText(msg, true);
|
m_timeout_message->setText(msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cur_starting_timer != std::numeric_limits<float>::max())
|
if (m_cur_starting_timer != std::numeric_limits<int64_t>::max())
|
||||||
{
|
{
|
||||||
m_cur_starting_timer -= delta;
|
int64_t remain = (m_cur_starting_timer -
|
||||||
if (m_cur_starting_timer < 0.0f)
|
(int64_t)StkTime::getRealTimeMs()) / 1000;
|
||||||
m_cur_starting_timer = 0.0f;
|
if (remain < 0)
|
||||||
|
remain = 0;
|
||||||
//I18N: In the networking lobby, display the starting timeout
|
//I18N: In the networking lobby, display the starting timeout
|
||||||
//for owner-less server
|
//for owner-less server
|
||||||
core::stringw msg = _P("Game will start after %d second.",
|
core::stringw msg = _P("Game will start after %d second.",
|
||||||
"Game will start after %d seconds.", (int)m_cur_starting_timer);
|
"Game will start after %d seconds.", (int)remain);
|
||||||
m_timeout_message->setText(msg, true);
|
m_timeout_message->setText(msg, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -554,5 +556,11 @@ void NetworkingLobby::initAutoStartTimer(bool grand_prix_started,
|
|||||||
m_has_auto_start_in_server = true;
|
m_has_auto_start_in_server = true;
|
||||||
m_min_start_game_players = grand_prix_started ? 0 : min_players;
|
m_min_start_game_players = grand_prix_started ? 0 : min_players;
|
||||||
m_start_timeout = start_timeout;
|
m_start_timeout = start_timeout;
|
||||||
m_server_max_player = (float)server_max_player;
|
|
||||||
} // initAutoStartTimer
|
} // initAutoStartTimer
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
void NetworkingLobby::setStartingTimerTo(float t)
|
||||||
|
{
|
||||||
|
m_cur_starting_timer =
|
||||||
|
(int64_t)StkTime::getRealTimeMs() + (int64_t)(t * 1000.0f);
|
||||||
|
} // setStartingTimerTo
|
||||||
|
@ -72,8 +72,8 @@ private:
|
|||||||
std::vector<core::stringw> m_server_info;
|
std::vector<core::stringw> m_server_info;
|
||||||
int m_server_info_height;
|
int m_server_info_height;
|
||||||
|
|
||||||
float m_cur_starting_timer, m_start_timeout,
|
float m_start_timeout;
|
||||||
m_server_max_player;
|
int64_t m_cur_starting_timer;
|
||||||
unsigned m_min_start_game_players;
|
unsigned m_min_start_game_players;
|
||||||
|
|
||||||
bool m_allow_change_team, m_has_auto_start_in_server;
|
bool m_allow_change_team, m_has_auto_start_in_server;
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
void cleanAddedPlayers();
|
void cleanAddedPlayers();
|
||||||
void initAutoStartTimer(bool grand_prix_started, unsigned min_players,
|
void initAutoStartTimer(bool grand_prix_started, unsigned min_players,
|
||||||
float start_timeout, unsigned server_max_player);
|
float start_timeout, unsigned server_max_player);
|
||||||
void setStartingTimerTo(float t) { m_cur_starting_timer = t; }
|
void setStartingTimerTo(float t);
|
||||||
|
|
||||||
}; // class NetworkingLobby
|
}; // class NetworkingLobby
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user