Move change spectate target to client lobby
This commit is contained in:
parent
b491ab0e82
commit
8545d47d1e
@ -809,48 +809,9 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
|
||||
{
|
||||
if (auto cl = LobbyProtocol::get<ClientLobby>())
|
||||
{
|
||||
Camera* cam = Camera::getActiveCamera();
|
||||
if (cl->isSpectator() && cam)
|
||||
if (cl->isSpectator())
|
||||
{
|
||||
// Network spectating handling
|
||||
if (action == PA_LOOK_BACK && value == 0)
|
||||
{
|
||||
if (cam->getMode() == Camera::CM_REVERSE)
|
||||
{
|
||||
cam->setMode(Camera::CM_NORMAL);
|
||||
}
|
||||
else
|
||||
cam->setMode(Camera::CM_REVERSE);
|
||||
return;
|
||||
}
|
||||
|
||||
int current_idx = 0;
|
||||
if (cam->getKart())
|
||||
current_idx = cam->getKart()->getWorldKartId();
|
||||
bool up = false;
|
||||
if (action == PA_STEER_LEFT && value == 0)
|
||||
up = false;
|
||||
else if (action == PA_STEER_RIGHT && value == 0)
|
||||
up = true;
|
||||
else
|
||||
return;
|
||||
|
||||
const int num_karts = World::getWorld()->getNumKarts();
|
||||
for (int i=0;i<num_karts;i++)
|
||||
{
|
||||
current_idx = up ? current_idx+1 : current_idx-1;
|
||||
// Handle looping
|
||||
if (current_idx == -1)
|
||||
current_idx = num_karts - 1;
|
||||
else if (current_idx == num_karts)
|
||||
current_idx = 0;
|
||||
|
||||
if (!World::getWorld()->getKart(current_idx)->isEliminated())
|
||||
{
|
||||
cam->setKart(World::getWorld()->getKart(current_idx));
|
||||
break;
|
||||
}
|
||||
}
|
||||
cl->changeSpectateTarget(action, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1155,7 +1155,6 @@ void ClientLobby::startLiveJoinKartSelection()
|
||||
NetworkKartSelectionScreen::getInstance()->push();
|
||||
} // startLiveJoinKartSelection
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ClientLobby::sendChat(irr::core::stringw text)
|
||||
{
|
||||
@ -1178,3 +1177,47 @@ void ClientLobby::sendChat(irr::core::stringw text)
|
||||
delete chat;
|
||||
}
|
||||
} // sendChat
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ClientLobby::changeSpectateTarget(PlayerAction action, int value) const
|
||||
{
|
||||
Camera* cam = Camera::getActiveCamera();
|
||||
if (!cam)
|
||||
return;
|
||||
if (action == PA_LOOK_BACK && value == 0)
|
||||
{
|
||||
if (cam->getMode() == Camera::CM_REVERSE)
|
||||
cam->setMode(Camera::CM_NORMAL);
|
||||
else
|
||||
cam->setMode(Camera::CM_REVERSE);
|
||||
return;
|
||||
}
|
||||
|
||||
int current_idx = 0;
|
||||
if (cam->getKart())
|
||||
current_idx = cam->getKart()->getWorldKartId();
|
||||
bool up = false;
|
||||
if (action == PA_STEER_LEFT && value == 0)
|
||||
up = false;
|
||||
else if (action == PA_STEER_RIGHT && value == 0)
|
||||
up = true;
|
||||
else
|
||||
return;
|
||||
|
||||
const int num_karts = World::getWorld()->getNumKarts();
|
||||
for (int i = 0;i < num_karts; i++)
|
||||
{
|
||||
current_idx = up ? current_idx+1 : current_idx-1;
|
||||
// Handle looping
|
||||
if (current_idx == -1)
|
||||
current_idx = num_karts - 1;
|
||||
else if (current_idx == num_karts)
|
||||
current_idx = 0;
|
||||
|
||||
if (!World::getWorld()->getKart(current_idx)->isEliminated())
|
||||
{
|
||||
cam->setKart(World::getWorld()->getKart(current_idx));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // changeSpectateTarget
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifndef CLIENT_LOBBY_HPP
|
||||
#define CLIENT_LOBBY_HPP
|
||||
|
||||
#include "input/input.hpp"
|
||||
#include "network/protocols/lobby_protocol.hpp"
|
||||
#include "network/transport_address.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
@ -152,6 +153,7 @@ public:
|
||||
const std::vector<LobbyPlayer>& getLobbyPlayers() const
|
||||
{ return m_lobby_players; }
|
||||
bool isServerLiveJoinable() const { return m_server_live_joinable; }
|
||||
void changeSpectateTarget(PlayerAction action, int value) const;
|
||||
};
|
||||
|
||||
#endif // CLIENT_LOBBY_HPP
|
||||
|
Loading…
Reference in New Issue
Block a user