From 661688db2d850cf3a0713c75b346556511fd05f0 Mon Sep 17 00:00:00 2001 From: riso <4726939+risostk@users.noreply.github.com> Date: Sat, 30 May 2020 00:28:27 -0500 Subject: [PATCH] Show a message once a goal is made in soccer (#4304) * log the goal on server once a player scored in soccer * show a message once a player made a goal in soccer * bug fix, add comments * remove server log --- src/modes/soccer_world.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index f36808a57..04bdebe2b 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -23,6 +23,7 @@ #include "config/user_config.hpp" #include "io/file_manager.hpp" #include "graphics/irr_driver.hpp" +#include "guiengine/message_queue.hpp" #include "karts/abstract_kart_animation.hpp" #include "karts/kart_model.hpp" #include "karts/kart_properties.hpp" @@ -43,6 +44,7 @@ #include "tracks/track_object_manager.hpp" #include "tracks/track_sector.hpp" #include "utils/constants.hpp" +#include "utils/translation.hpp" #include "utils/string_utils.hpp" #include @@ -510,13 +512,22 @@ void SoccerWorld::onCheckGoalTriggered(bool first_goal) m_karts[m_ball_hitter]->getKartModel() ->setAnimation(KartModel::AF_WIN_START, true/* play_non_loop*/); } - else if (!sd.m_correct_goal) { m_karts[m_ball_hitter]->getKartModel() ->setAnimation(KartModel::AF_LOSE_START, true/* play_non_loop*/); } +#ifndef SERVER_ONLY + // show a message once a goal is made + core::stringw msg; + if (sd.m_correct_goal) + msg = _("%s scored a goal!", sd.m_player); + else + msg = _("Oops, %s made an own goal!", sd.m_player); + MessageQueue::add(MessageQueue::MT_GENERIC, msg); +#endif + if (first_goal) { if (RaceManager::get()->hasTimeTarget()) @@ -623,6 +634,14 @@ void SoccerWorld::handlePlayerGoalFromServer(const NetworkString& ns) m_blue_scorers.push_back(sd); } + // show a message once a goal is made + core::stringw msg; + if (sd.m_correct_goal) + msg = _("%s scored a goal!", sd.m_player); + else + msg = _("Oops, %s made an own goal!", sd.m_player); + MessageQueue::add(MessageQueue::MT_GENERIC, msg); + if (ticks_now >= ticks_back_to_own_goal && !isStartPhase()) { Log::warn("SoccerWorld", "Server ticks %d is too close to client ticks "