Renamed PlayerController into LocalPlayerController.
This commit is contained in:
parent
770d05f0de
commit
dbd210d08c
@ -1,5 +1,5 @@
|
|||||||
# Modify this file to change the last-modified date when you add/remove a file.
|
# Modify this file to change the last-modified date when you add/remove a file.
|
||||||
# This will then trigger a new cmake run automatically.
|
# This will then trigger a new cmake run automatically.
|
||||||
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp")
|
||||||
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp")
|
||||||
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
file(GLOB_RECURSE STK_SHADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/shaders/*")
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "input/gamepad_config.hpp"
|
#include "input/gamepad_config.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "karts/controller/player_controller.hpp"
|
#include "karts/controller/local_player_controller.hpp"
|
||||||
|
|
||||||
/** Constructor for GamePadDevice from a connected gamepad for which no
|
/** Constructor for GamePadDevice from a connected gamepad for which no
|
||||||
* configuration existed (defaults will be used)
|
* configuration existed (defaults will be used)
|
||||||
@ -124,7 +124,7 @@ void GamePadDevice::resetAxisDirection(const int axis,
|
|||||||
bind.getDirection()== direction &&
|
bind.getDirection()== direction &&
|
||||||
pk->getController() != NULL)
|
pk->getController() != NULL)
|
||||||
{
|
{
|
||||||
((PlayerController*)(pk->getController()))
|
((LocalPlayerController*)(pk->getController()))
|
||||||
->action((PlayerAction)n, 0);
|
->action((PlayerAction)n, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include "input/input.hpp"
|
#include "input/input.hpp"
|
||||||
#include "input/input_device.hpp"
|
#include "input/input_device.hpp"
|
||||||
#include "karts/abstract_kart.hpp"
|
#include "karts/abstract_kart.hpp"
|
||||||
#include "karts/controller/player_controller.hpp"
|
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "race/race_manager.hpp"
|
#include "race/race_manager.hpp"
|
||||||
#include "states_screens/state_manager.hpp"
|
#include "states_screens/state_manager.hpp"
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "karts/controller/player_controller.hpp"
|
#include "karts/controller/local_player_controller.hpp"
|
||||||
|
|
||||||
#include "audio/sfx_base.hpp"
|
#include "audio/sfx_base.hpp"
|
||||||
#include "config/stk_config.hpp"
|
#include "config/stk_config.hpp"
|
||||||
@ -49,7 +49,7 @@
|
|||||||
* \param init_pos The start coordinates and heading of the kart.
|
* \param init_pos The start coordinates and heading of the kart.
|
||||||
* \param player_index Index of the player kart.
|
* \param player_index Index of the player kart.
|
||||||
*/
|
*/
|
||||||
PlayerController::PlayerController(AbstractKart *kart,
|
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||||
StateManager::ActivePlayer *player,
|
StateManager::ActivePlayer *player,
|
||||||
unsigned int player_index)
|
unsigned int player_index)
|
||||||
: Controller(kart)
|
: Controller(kart)
|
||||||
@ -68,24 +68,24 @@ PlayerController::PlayerController(AbstractKart *kart,
|
|||||||
m_full_sound = SFXManager::get()->createSoundSource( "energy_bar_full" );
|
m_full_sound = SFXManager::get()->createSoundSource( "energy_bar_full" );
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
} // PlayerController
|
} // LocalPlayerController
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Destructor for a player kart.
|
/** Destructor for a player kart.
|
||||||
*/
|
*/
|
||||||
PlayerController::~PlayerController()
|
LocalPlayerController::~LocalPlayerController()
|
||||||
{
|
{
|
||||||
m_bzzt_sound->deleteSFX();
|
m_bzzt_sound->deleteSFX();
|
||||||
m_wee_sound ->deleteSFX();
|
m_wee_sound ->deleteSFX();
|
||||||
m_ugh_sound ->deleteSFX();
|
m_ugh_sound ->deleteSFX();
|
||||||
m_grab_sound->deleteSFX();
|
m_grab_sound->deleteSFX();
|
||||||
m_full_sound->deleteSFX();
|
m_full_sound->deleteSFX();
|
||||||
} // ~PlayerController
|
} // ~LocalPlayerController
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Resets the player kart for a new or restarted race.
|
/** Resets the player kart for a new or restarted race.
|
||||||
*/
|
*/
|
||||||
void PlayerController::reset()
|
void LocalPlayerController::reset()
|
||||||
{
|
{
|
||||||
m_steer_val_l = 0;
|
m_steer_val_l = 0;
|
||||||
m_steer_val_r = 0;
|
m_steer_val_r = 0;
|
||||||
@ -102,7 +102,7 @@ void PlayerController::reset()
|
|||||||
* avoid that any keys pressed at the time the menu is opened are still
|
* avoid that any keys pressed at the time the menu is opened are still
|
||||||
* considered to be pressed.
|
* considered to be pressed.
|
||||||
*/
|
*/
|
||||||
void PlayerController::resetInputState()
|
void LocalPlayerController::resetInputState()
|
||||||
{
|
{
|
||||||
m_steer_val_l = 0;
|
m_steer_val_l = 0;
|
||||||
m_steer_val_r = 0;
|
m_steer_val_r = 0;
|
||||||
@ -127,7 +127,7 @@ void PlayerController::resetInputState()
|
|||||||
* and if it's 0 it indicates that the corresponding button
|
* and if it's 0 it indicates that the corresponding button
|
||||||
* was released.
|
* was released.
|
||||||
*/
|
*/
|
||||||
void PlayerController::action(PlayerAction action, int value)
|
void LocalPlayerController::action(PlayerAction action, int value)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
@ -235,11 +235,11 @@ void PlayerController::action(PlayerAction action, int value)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Handles steering for a player kart.
|
/** Handles steering for a player kart.
|
||||||
*/
|
*/
|
||||||
void PlayerController::steer(float dt, int steer_val)
|
void LocalPlayerController::steer(float dt, int steer_val)
|
||||||
{
|
{
|
||||||
if(UserConfigParams::m_gamepad_debug)
|
if(UserConfigParams::m_gamepad_debug)
|
||||||
{
|
{
|
||||||
Log::debug("PlayerController", "steering: steer_val %d ", steer_val);
|
Log::debug("LocalPlayerController", "steering: steer_val %d ", steer_val);
|
||||||
RaceGUIBase* gui_base = World::getWorld()->getRaceGUI();
|
RaceGUIBase* gui_base = World::getWorld()->getRaceGUI();
|
||||||
gui_base->clearAllMessages();
|
gui_base->clearAllMessages();
|
||||||
gui_base->addMessage(StringUtils::insertValues(L"steer_val %i", steer_val), m_kart, 1.0f,
|
gui_base->addMessage(StringUtils::insertValues(L"steer_val %i", steer_val), m_kart, 1.0f,
|
||||||
@ -292,7 +292,7 @@ void PlayerController::steer(float dt, int steer_val)
|
|||||||
} // no key is pressed
|
} // no key is pressed
|
||||||
if(UserConfigParams::m_gamepad_debug)
|
if(UserConfigParams::m_gamepad_debug)
|
||||||
{
|
{
|
||||||
Log::debug("PlayerController", " set to: %f\n", m_controls->m_steer);
|
Log::debug("LocalPlayerController", " set to: %f\n", m_controls->m_steer);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_controls->m_steer = std::min(1.0f, std::max(-1.0f, m_controls->m_steer));
|
m_controls->m_steer = std::min(1.0f, std::max(-1.0f, m_controls->m_steer));
|
||||||
@ -303,7 +303,7 @@ void PlayerController::steer(float dt, int steer_val)
|
|||||||
/** Callback when the skidding bonus is triggered. The player controller
|
/** Callback when the skidding bonus is triggered. The player controller
|
||||||
* resets the current steering to 0, which makes the kart easier to control.
|
* resets the current steering to 0, which makes the kart easier to control.
|
||||||
*/
|
*/
|
||||||
void PlayerController::skidBonusTriggered()
|
void LocalPlayerController::skidBonusTriggered()
|
||||||
{
|
{
|
||||||
m_controls->m_steer = 0;
|
m_controls->m_steer = 0;
|
||||||
} // skidBonusTriggered
|
} // skidBonusTriggered
|
||||||
@ -311,13 +311,13 @@ void PlayerController::skidBonusTriggered()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Updates the player kart, called once each timestep.
|
/** Updates the player kart, called once each timestep.
|
||||||
*/
|
*/
|
||||||
void PlayerController::update(float dt)
|
void LocalPlayerController::update(float dt)
|
||||||
{
|
{
|
||||||
if (UserConfigParams::m_gamepad_debug)
|
if (UserConfigParams::m_gamepad_debug)
|
||||||
{
|
{
|
||||||
// Print a dividing line so that it's easier to see which events
|
// Print a dividing line so that it's easier to see which events
|
||||||
// get received in which order in the one frame.
|
// get received in which order in the one frame.
|
||||||
Log::debug("PlayerController", "irr_driver", "-------------------------------------");
|
Log::debug("LocalPlayerController", "irr_driver", "-------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't do steering if it's replay. In position only replay it doesn't
|
// Don't do steering if it's replay. In position only replay it doesn't
|
||||||
@ -410,7 +410,7 @@ void PlayerController::update(float dt)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Checks if the kart was overtaken, and if so plays a sound
|
/** Checks if the kart was overtaken, and if so plays a sound
|
||||||
*/
|
*/
|
||||||
void PlayerController::setPosition(int p)
|
void LocalPlayerController::setPosition(int p)
|
||||||
{
|
{
|
||||||
if(m_kart->getPosition()<p)
|
if(m_kart->getPosition()<p)
|
||||||
{
|
{
|
||||||
@ -433,7 +433,7 @@ void PlayerController::setPosition(int p)
|
|||||||
/** Called when a kart finishes race.
|
/** Called when a kart finishes race.
|
||||||
* /param time Finishing time for this kart.
|
* /param time Finishing time for this kart.
|
||||||
d*/
|
d*/
|
||||||
void PlayerController::finishedRace(float time)
|
void LocalPlayerController::finishedRace(float time)
|
||||||
{
|
{
|
||||||
// This will implicitely trigger setting the first end camera to be active
|
// This will implicitely trigger setting the first end camera to be active
|
||||||
m_camera->setMode(Camera::CM_FINAL);
|
m_camera->setMode(Camera::CM_FINAL);
|
||||||
@ -443,7 +443,7 @@ void PlayerController::finishedRace(float time)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/** Called when a kart hits or uses a zipper.
|
/** Called when a kart hits or uses a zipper.
|
||||||
*/
|
*/
|
||||||
void PlayerController::handleZipper(bool play_sound)
|
void LocalPlayerController::handleZipper(bool play_sound)
|
||||||
{
|
{
|
||||||
// Only play a zipper sound if it's not already playing, and
|
// Only play a zipper sound if it's not already playing, and
|
||||||
// if the material has changed (to avoid machine gun effect
|
// if the material has changed (to avoid machine gun effect
|
||||||
@ -471,7 +471,7 @@ void PlayerController::handleZipper(bool play_sound)
|
|||||||
* let the server determine the powerup/attachment for
|
* let the server determine the powerup/attachment for
|
||||||
* the clients.
|
* the clients.
|
||||||
*/
|
*/
|
||||||
void PlayerController::collectedItem(const Item &item, int add_info, float old_energy)
|
void LocalPlayerController::collectedItem(const Item &item, int add_info, float old_energy)
|
||||||
{
|
{
|
||||||
if (old_energy < m_kart->getKartProperties()->getNitroMax() &&
|
if (old_energy < m_kart->getKartProperties()->getNitroMax() &&
|
||||||
m_kart->getEnergy() == m_kart->getKartProperties()->getNitroMax())
|
m_kart->getEnergy() == m_kart->getKartProperties()->getNitroMax())
|
@ -18,8 +18,8 @@
|
|||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
|
||||||
#ifndef HEADER_PLAYERKART_HPP
|
#ifndef HEADER_LOCAL_PLAYER_CONTROLLER_HPP
|
||||||
#define HEADER_PLAYERKART_HPP
|
#define HEADER_LOCAL_PLAYER_CONTROLLER_HPP
|
||||||
|
|
||||||
#include "karts/controller/controller.hpp"
|
#include "karts/controller/controller.hpp"
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ class SFXBase;
|
|||||||
*
|
*
|
||||||
* \ingroup controller
|
* \ingroup controller
|
||||||
*/
|
*/
|
||||||
class PlayerController : public Controller
|
class LocalPlayerController : public Controller
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int m_steer_val, m_steer_val_l, m_steer_val_r;
|
int m_steer_val, m_steer_val_l, m_steer_val_r;
|
||||||
@ -56,10 +56,10 @@ private:
|
|||||||
|
|
||||||
void steer(float, int);
|
void steer(float, int);
|
||||||
public:
|
public:
|
||||||
PlayerController (AbstractKart *kart,
|
LocalPlayerController (AbstractKart *kart,
|
||||||
StateManager::ActivePlayer *_player,
|
StateManager::ActivePlayer *_player,
|
||||||
unsigned int player_index);
|
unsigned int player_index);
|
||||||
~PlayerController ();
|
~LocalPlayerController ();
|
||||||
void update (float);
|
void update (float);
|
||||||
void action (PlayerAction action, int value);
|
void action (PlayerAction action, int value);
|
||||||
void handleZipper (bool play_sound);
|
void handleZipper (bool play_sound);
|
||||||
@ -82,6 +82,6 @@ public:
|
|||||||
/** Player will always be able to get a slipstream bonus. */
|
/** Player will always be able to get a slipstream bonus. */
|
||||||
virtual bool disableSlipstreamBonus() const { return false; }
|
virtual bool disableSlipstreamBonus() const { return false; }
|
||||||
|
|
||||||
}; // PlayerController
|
}; // LocalPlayerController
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -26,7 +26,7 @@
|
|||||||
#include "karts/kart_model.hpp"
|
#include "karts/kart_model.hpp"
|
||||||
#include "karts/kart_properties.hpp"
|
#include "karts/kart_properties.hpp"
|
||||||
#include "karts/rescue_animation.hpp"
|
#include "karts/rescue_animation.hpp"
|
||||||
#include "karts/controller/player_controller.hpp"
|
#include "karts/controller/local_player_controller.hpp"
|
||||||
#include "physics/physics.hpp"
|
#include "physics/physics.hpp"
|
||||||
#include "states_screens/race_gui_base.hpp"
|
#include "states_screens/race_gui_base.hpp"
|
||||||
#include "tracks/track.hpp"
|
#include "tracks/track.hpp"
|
||||||
@ -409,7 +409,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
|||||||
switch(kart_type)
|
switch(kart_type)
|
||||||
{
|
{
|
||||||
case RaceManager::KT_PLAYER:
|
case RaceManager::KT_PLAYER:
|
||||||
controller = new PlayerController(new_kart,
|
controller = new LocalPlayerController(new_kart,
|
||||||
StateManager::get()->getActivePlayer(local_player_id),
|
StateManager::get()->getActivePlayer(local_player_id),
|
||||||
local_player_id);
|
local_player_id);
|
||||||
m_num_players ++;
|
m_num_players ++;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "input/device_manager.hpp"
|
#include "input/device_manager.hpp"
|
||||||
#include "input/keyboard_device.hpp"
|
#include "input/keyboard_device.hpp"
|
||||||
#include "items/projectile_manager.hpp"
|
#include "items/projectile_manager.hpp"
|
||||||
#include "karts/controller/player_controller.hpp"
|
#include "karts/controller/local_player_controller.hpp"
|
||||||
#include "karts/controller/end_controller.hpp"
|
#include "karts/controller/end_controller.hpp"
|
||||||
#include "karts/controller/skidding_ai.hpp"
|
#include "karts/controller/skidding_ai.hpp"
|
||||||
#include "karts/controller/network_player_controller.hpp"
|
#include "karts/controller/network_player_controller.hpp"
|
||||||
@ -311,7 +311,7 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
|||||||
switch(kart_type)
|
switch(kart_type)
|
||||||
{
|
{
|
||||||
case RaceManager::KT_PLAYER:
|
case RaceManager::KT_PLAYER:
|
||||||
controller = new PlayerController(new_kart,
|
controller = new LocalPlayerController(new_kart,
|
||||||
StateManager::get()->getActivePlayer(local_player_id),
|
StateManager::get()->getActivePlayer(local_player_id),
|
||||||
local_player_id);
|
local_player_id);
|
||||||
m_num_players ++;
|
m_num_players ++;
|
||||||
@ -1090,7 +1090,8 @@ void World::updateHighscores(int* best_highscore_rank, int* best_finish_time,
|
|||||||
|
|
||||||
Highscores* highscores = getHighscores();
|
Highscores* highscores = getHighscores();
|
||||||
|
|
||||||
PlayerController *controller = (PlayerController*)(k->getController());
|
LocalPlayerController *controller =
|
||||||
|
(LocalPlayerController*)(k->getController());
|
||||||
|
|
||||||
int highscore_rank = 0;
|
int highscore_rank = 0;
|
||||||
if (controller->getPlayer()->getProfile() != NULL) // if we have the player profile here
|
if (controller->getPlayer()->getProfile() != NULL) // if we have the player profile here
|
||||||
@ -1230,8 +1231,8 @@ void World::unpause()
|
|||||||
// Note that we can not test for isPlayerController here, since
|
// Note that we can not test for isPlayerController here, since
|
||||||
// an EndController will also return 'isPlayerController' if the
|
// an EndController will also return 'isPlayerController' if the
|
||||||
// kart belonged to a player.
|
// kart belonged to a player.
|
||||||
PlayerController *pc =
|
LocalPlayerController *pc =
|
||||||
dynamic_cast<PlayerController*>(m_karts[i]->getController());
|
dynamic_cast<LocalPlayerController*>(m_karts[i]->getController());
|
||||||
if(pc)
|
if(pc)
|
||||||
pc->resetInputState();
|
pc->resetInputState();
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "items/flyable.hpp"
|
#include "items/flyable.hpp"
|
||||||
#include "karts/kart_properties.hpp"
|
#include "karts/kart_properties.hpp"
|
||||||
#include "karts/rescue_animation.hpp"
|
#include "karts/rescue_animation.hpp"
|
||||||
#include "karts/controller/player_controller.hpp"
|
#include "karts/controller/local_player_controller.hpp"
|
||||||
#include "modes/soccer_world.hpp"
|
#include "modes/soccer_world.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
#include "karts/explosion_animation.hpp"
|
#include "karts/explosion_animation.hpp"
|
||||||
@ -307,7 +307,8 @@ void Physics::update(float dt)
|
|||||||
|
|
||||||
// Check for achievements
|
// Check for achievements
|
||||||
AbstractKart * kart = World::getWorld()->getKart(f->getOwnerId());
|
AbstractKart * kart = World::getWorld()->getKart(f->getOwnerId());
|
||||||
PlayerController *c = dynamic_cast<PlayerController*>(kart->getController());
|
LocalPlayerController *c =
|
||||||
|
dynamic_cast<LocalPlayerController*>(kart->getController());
|
||||||
|
|
||||||
// Check that it's not a kart hitting itself (this can
|
// Check that it's not a kart hitting itself (this can
|
||||||
// happen at the time a flyable is shot - release too close
|
// happen at the time a flyable is shot - release too close
|
||||||
|
Loading…
Reference in New Issue
Block a user