Consistent split screen ()

* 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)
* 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);
return camera;
} // createCamera(kart)

View File

@ -136,7 +136,7 @@ public:
// ========================================================================
// Static functions
static Camera* createCamera(AbstractKart* kart);
static Camera* createCamera(AbstractKart* kart, const int index);
static void resetAllCameras();
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.
*/
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player)
const int local_playerID)
: PlayerController(kart), m_sky_particles_emitter(NULL)
{
m_player = player;
if(player)
player->setKart(kart);
m_player = StateManager::get()->getActivePlayer(local_playerID);
if(m_player)
m_player->setKart(kart);
// Keep a pointer to the camera to remove the need to search for
// 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_wee_sound = SFXManager::get()->createSoundSource("wee");
m_bzzt_sound = SFXManager::get()->getBuffer("bzzt");

View File

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

View File

@ -79,7 +79,7 @@ void CutsceneWorld::init()
m_duration = -1.0f;
Camera* stk_cam = Camera::createCamera(NULL);
Camera* stk_cam = Camera::createCamera(NULL, 0);
m_camera = stk_cam->getCameraSceneNode();
m_camera->setFOV(stk_config->m_cutscene_fov);
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)
{
// 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;
} // createKart

View File

@ -422,7 +422,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
{
case RaceManager::KT_PLAYER:
controller = new LocalPlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id));
local_player_id);
m_num_players ++;
break;
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,
// create a camera and attach it to the first kart.
Camera::createCamera(World::getWorld()->getKart(0));
Camera::createCamera(World::getWorld()->getKart(0), 0);
}
} // init
@ -354,13 +354,16 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
case RaceManager::KT_PLAYER:
{
controller = new LocalPlayerController(new_kart,
StateManager::get()->getActivePlayer(local_player_id));
local_player_id);
const float hue = StateManager::get()->getActivePlayer(local_player_id)
->getConstProfile()->getDefaultKartColor();
if (hue > 0.0f)
{
ri->setHue(hue);
}
m_num_players ++;
break;
}