Consistent split screen (#3105)

* Splitscreen positions are now consistent across rounds

* Fix tabs

* Remove unnecessary comments
This commit is contained in:
Ben Krajancic 2018-01-28 11:27:17 +11:00 committed by auriamg
parent 0003b39d31
commit f6f051e85b
8 changed files with 21 additions and 15 deletions

View File

@ -53,10 +53,10 @@ Camera::CameraType Camera::m_default_type = Camera::CM_TYPE_NORMAL;
* camera index (which determines which viewport to use in split screen) * camera index (which determines which viewport to use in split screen)
* is set. * is set.
*/ */
Camera* Camera::createCamera(AbstractKart* kart) Camera* Camera::createCamera(AbstractKart* kart, const int index)
{ {
Camera *camera = createCamera((int)m_all_cameras.size(),
m_default_type, kart ); Camera *camera = createCamera(index, m_default_type, kart);
m_all_cameras.push_back(camera); m_all_cameras.push_back(camera);
return camera; return camera;
} // createCamera(kart) } // createCamera(kart)

View File

@ -136,7 +136,7 @@ public:
// ======================================================================== // ========================================================================
// Static functions // Static functions
static Camera* createCamera(AbstractKart* kart); static Camera* createCamera(AbstractKart* kart, const int index);
static void resetAllCameras(); static void resetAllCameras();
static void changeCamera(unsigned int camera_index, CameraType type); static void changeCamera(unsigned int camera_index, CameraType type);

View File

@ -54,16 +54,19 @@
* \param init_pos The start coordinates and heading of the kart. * \param init_pos The start coordinates and heading of the kart.
*/ */
LocalPlayerController::LocalPlayerController(AbstractKart *kart, LocalPlayerController::LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player) const int local_playerID)
: PlayerController(kart), m_sky_particles_emitter(NULL) : PlayerController(kart), m_sky_particles_emitter(NULL)
{ {
m_player = player;
if(player) m_player = StateManager::get()->getActivePlayer(local_playerID);
player->setKart(kart); if(m_player)
m_player->setKart(kart);
// Keep a pointer to the camera to remove the need to search for // Keep a pointer to the camera to remove the need to search for
// the right camera once per frame later. // the right camera once per frame later.
Camera *camera = Camera::createCamera(kart);
Camera *camera = Camera::createCamera(kart, local_playerID);
m_camera_index = camera->getIndex(); m_camera_index = camera->getIndex();
m_wee_sound = SFXManager::get()->createSoundSource("wee"); m_wee_sound = SFXManager::get()->createSoundSource("wee");
m_bzzt_sound = SFXManager::get()->getBuffer("bzzt"); m_bzzt_sound = SFXManager::get()->getBuffer("bzzt");

View File

@ -58,7 +58,7 @@ private:
virtual void displayPenaltyWarning() OVERRIDE; virtual void displayPenaltyWarning() OVERRIDE;
public: public:
LocalPlayerController(AbstractKart *kart, LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player); const int local_playerID);
~LocalPlayerController(); ~LocalPlayerController();
void update (float) OVERRIDE; void update (float) OVERRIDE;
void action (PlayerAction action, int value) OVERRIDE; void action (PlayerAction action, int value) OVERRIDE;

View File

@ -79,7 +79,7 @@ void CutsceneWorld::init()
m_duration = -1.0f; m_duration = -1.0f;
Camera* stk_cam = Camera::createCamera(NULL); Camera* stk_cam = Camera::createCamera(NULL, 0);
m_camera = stk_cam->getCameraSceneNode(); m_camera = stk_cam->getCameraSceneNode();
m_camera->setFOV(stk_config->m_cutscene_fov); m_camera->setFOV(stk_config->m_cutscene_fov);
m_camera->bindTargetAndRotation(true); // no "look-at" m_camera->bindTargetAndRotation(true); // no "look-at"

View File

@ -123,7 +123,7 @@ AbstractKart *ProfileWorld::createKart(const std::string &kart_ident, int index,
if (index == (int)race_manager->getNumberOfKarts()-1) if (index == (int)race_manager->getNumberOfKarts()-1)
{ {
// The camera keeps track of all cameras and will free them // The camera keeps track of all cameras and will free them
Camera::createCamera(new_kart); Camera::createCamera(new_kart, local_player_id);
} }
return new_kart; return new_kart;
} // createKart } // createKart

View File

@ -422,7 +422,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
{ {
case RaceManager::KT_PLAYER: case RaceManager::KT_PLAYER:
controller = new LocalPlayerController(new_kart, controller = new LocalPlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id)); local_player_id);
m_num_players ++; m_num_players ++;
break; break;
case RaceManager::KT_NETWORK_PLAYER: case RaceManager::KT_NETWORK_PLAYER:

View File

@ -235,7 +235,7 @@ void World::init()
{ {
// In case that the server is running with gui or watching replay, // In case that the server is running with gui or watching replay,
// create a camera and attach it to the first kart. // create a camera and attach it to the first kart.
Camera::createCamera(World::getWorld()->getKart(0)); Camera::createCamera(World::getWorld()->getKart(0), 0);
} }
} // init } // init
@ -354,13 +354,16 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
case RaceManager::KT_PLAYER: case RaceManager::KT_PLAYER:
{ {
controller = new LocalPlayerController(new_kart, controller = new LocalPlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id));
local_player_id);
const float hue = StateManager::get()->getActivePlayer(local_player_id) const float hue = StateManager::get()->getActivePlayer(local_player_id)
->getConstProfile()->getDefaultKartColor(); ->getConstProfile()->getDefaultKartColor();
if (hue > 0.0f) if (hue > 0.0f)
{ {
ri->setHue(hue); ri->setHue(hue);
} }
m_num_players ++; m_num_players ++;
break; break;
} }