Add player name and team arrows for live join kart
This commit is contained in:
parent
a849229f27
commit
52a4bbeac7
@ -21,7 +21,6 @@
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "config/player_manager.hpp"
|
||||
#include "graphics/render_info.hpp"
|
||||
#include "guiengine/modaldialog.hpp"
|
||||
#include "guiengine/message_queue.hpp"
|
||||
#include "guiengine/screen_keyboard.hpp"
|
||||
@ -1046,17 +1045,29 @@ void ClientLobby::handleKartInfo(Event* event)
|
||||
rki.setPerPlayerDifficulty(ppd);
|
||||
rki.setLocalPlayerId(local_id);
|
||||
rki.setKartName(kart_name);
|
||||
addLiveJoiningKart(kart_id, rki, live_join_util_ticks);
|
||||
|
||||
AbstractKart* k = w->getKart(kart_id);
|
||||
k->changeKart(rki.getKartName(), rki.getDifficulty(),
|
||||
rki.getKartTeam() == KART_TEAM_RED ?
|
||||
std::make_shared<RenderInfo>(1.0f) :
|
||||
rki.getKartTeam() == KART_TEAM_BLUE ?
|
||||
std::make_shared<RenderInfo>(0.66f) :
|
||||
std::make_shared<RenderInfo>(rki.getDefaultKartColor()));
|
||||
k->setLiveJoinKart(live_join_util_ticks);
|
||||
|
||||
// I18N: Show when player join the started game in network
|
||||
core::stringw msg = _("%s joined the game.", player_name);
|
||||
core::stringw msg;
|
||||
if (race_manager->teamEnabled())
|
||||
{
|
||||
if (w->getKartTeam(kart_id) == KART_TEAM_RED)
|
||||
{
|
||||
// I18N: Show when player join red team of the started game in
|
||||
// network
|
||||
msg = _("%s joined the red team.", player_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// I18N: Show when player join blue team of the started game in
|
||||
// network
|
||||
msg = _("%s joined the blue team.", player_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// I18N: Show when player join the started game in network
|
||||
msg = _("%s joined the game.", player_name);
|
||||
}
|
||||
SFXManager::get()->quickSound("energy_bar_full");
|
||||
MessageQueue::add(MessageQueue::MT_FRIEND, msg);
|
||||
} // handleKartInfo
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
#include "input/input_manager.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "graphics/render_info.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/controller.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/game_setup.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
@ -196,3 +199,20 @@ const PeerVote* LobbyProtocol::getVote(uint32_t host_id) const
|
||||
if (it == m_peers_votes.end()) return NULL;
|
||||
return &(it->second);
|
||||
} // getVote
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void LobbyProtocol::addLiveJoiningKart(int kart_id, const RemoteKartInfo& rki,
|
||||
int live_join_util_ticks) const
|
||||
{
|
||||
AbstractKart* k = World::getWorld()->getKart(kart_id);
|
||||
k->changeKart(rki.getKartName(), rki.getDifficulty(),
|
||||
rki.getKartTeam() == KART_TEAM_RED ?
|
||||
std::make_shared<RenderInfo>(1.0f) :
|
||||
rki.getKartTeam() == KART_TEAM_BLUE ?
|
||||
std::make_shared<RenderInfo>(0.66f) :
|
||||
std::make_shared<RenderInfo>(rki.getDefaultKartColor()));
|
||||
k->setLiveJoinKart(live_join_util_ticks);
|
||||
World::getWorld()->initTeamArrows(k);
|
||||
if (!k->getController()->isLocalPlayerController())
|
||||
k->setOnScreenText(rki.getPlayerName().c_str());
|
||||
} // addLiveJoiningKart
|
||||
|
@ -24,6 +24,7 @@
|
||||
class GameSetup;
|
||||
class NetworkPlayerProfile;
|
||||
class PeerVote;
|
||||
class RemoteKartInfo;
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
@ -118,6 +119,9 @@ protected:
|
||||
if (m_start_game_thread.joinable())
|
||||
m_start_game_thread.join();
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void addLiveJoiningKart(int kart_id, const RemoteKartInfo& rki,
|
||||
int live_join_util_ticks) const;
|
||||
public:
|
||||
|
||||
/** Creates either a client or server lobby protocol as a singleton. */
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "graphics/render_info.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/controller/player_controller.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
@ -849,16 +848,9 @@ void ServerLobby::finishedLoadingLiveJoinClient(Event* event)
|
||||
|
||||
for (const int id : peer->getAvailableKartIDs())
|
||||
{
|
||||
World::getWorld()->addReservedKart(id);
|
||||
const RemoteKartInfo& rki = race_manager->getKartInfo(id);
|
||||
AbstractKart* k = w->getKart(id);
|
||||
k->changeKart(rki.getKartName(), rki.getDifficulty(),
|
||||
rki.getKartTeam() == KART_TEAM_RED ?
|
||||
std::make_shared<RenderInfo>(1.0f) :
|
||||
rki.getKartTeam() == KART_TEAM_BLUE ?
|
||||
std::make_shared<RenderInfo>(0.66f) :
|
||||
std::make_shared<RenderInfo>(rki.getDefaultKartColor()));
|
||||
k->setLiveJoinKart(live_join_util_ticks);
|
||||
w->addReservedKart(id);
|
||||
addLiveJoiningKart(id, rki, live_join_util_ticks);
|
||||
}
|
||||
Log::info("ServerLobby", "%s live-joining succeeded.",
|
||||
peer->getAddress().toString().c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user