Continued cleaning up references to Player & ActivePlayer and docs
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3762 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2c0a322b61
commit
fbc3119dbc
@ -3,7 +3,7 @@
|
||||
#include "race/race_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
|
||||
ActivePlayer::ActivePlayer(Player* player)
|
||||
ActivePlayer::ActivePlayer(PlayerProfile* player)
|
||||
{
|
||||
m_player = player;
|
||||
m_device = NULL;
|
||||
@ -13,11 +13,11 @@ ActivePlayer::~ActivePlayer()
|
||||
setDevice(NULL);
|
||||
}
|
||||
|
||||
Player* ActivePlayer::getPlayer()
|
||||
PlayerProfile* ActivePlayer::getProfile()
|
||||
{
|
||||
return m_player;
|
||||
}
|
||||
void ActivePlayer::setPlayer(Player* player)
|
||||
void ActivePlayer::setPlayerProfile(PlayerProfile* player)
|
||||
{
|
||||
m_player = player;
|
||||
}
|
||||
@ -42,7 +42,7 @@ PlayerKart* ActivePlayer::getKart()
|
||||
const int amount = RaceManager::getWorld()->getCurrentNumLocalPlayers();
|
||||
for (int p=0; p<amount; p++)
|
||||
{
|
||||
if (RaceManager::getWorld()->getLocalPlayerKart(p)->getPlayer() == m_player)
|
||||
if (RaceManager::getWorld()->getLocalPlayerKart(p)->getPlayer()->getProfile() == m_player)
|
||||
{
|
||||
return RaceManager::getWorld()->getLocalPlayerKart(p);
|
||||
}
|
||||
|
@ -28,11 +28,11 @@ class InputDevice;
|
||||
class PlayerKart;
|
||||
|
||||
/**
|
||||
* class for managing player name and control configuration.
|
||||
* A list of all possible players is stored in the user config.
|
||||
* class for managing player profiles (name, control configuration, etc.)
|
||||
* A list of all possible players is stored as PlayerProfiles in the user config.
|
||||
* A list of currently playing players will be stored somewhere else (FIXME : complete comment)
|
||||
*/
|
||||
class Player
|
||||
class PlayerProfile
|
||||
{
|
||||
private:
|
||||
|
||||
@ -45,14 +45,14 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
Player(const char* name) : m_player_group("Player", "Represents one human player"),
|
||||
PlayerProfile(const char* name) : m_player_group("Player", "Represents one human player"),
|
||||
m_name(name, "name", &m_player_group),
|
||||
m_last_kart_id(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void setName(const std::string &name_){m_name = name_;}
|
||||
void setName(const std::string &name_){ m_name = name_;}
|
||||
|
||||
const char* getName() { return m_name.c_str(); }
|
||||
|
||||
@ -61,20 +61,21 @@ public:
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents a player that is currently playing.
|
||||
* FIXME: this class seems very closely related to PlayerKart, maybe merge them
|
||||
* Represents a player that is currently playing. It helps manage associating with a
|
||||
* player profile and an input device (we're very flexible on this; ActivePlayer #1
|
||||
* can choose to e.g. use profile #5 and device #2)
|
||||
*/
|
||||
class ActivePlayer
|
||||
{
|
||||
Player* m_player;
|
||||
PlayerProfile* m_player;
|
||||
InputDevice* m_device;
|
||||
public:
|
||||
|
||||
ActivePlayer(Player* player);
|
||||
ActivePlayer(PlayerProfile* player);
|
||||
~ActivePlayer();
|
||||
|
||||
Player* getPlayer();
|
||||
void setPlayer(Player* player);
|
||||
PlayerProfile* getProfile();
|
||||
void setPlayerProfile(PlayerProfile* player);
|
||||
|
||||
InputDevice* getDevice() const;
|
||||
void setDevice(InputDevice* device);
|
||||
|
@ -369,7 +369,7 @@ void UserConfig::addDefaultPlayer()
|
||||
username = getenv("LOGNAME");
|
||||
|
||||
// Set the name as the default name for all players.
|
||||
UserConfigParams::m_all_players.push_back( new Player(username.c_str()) );
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(username.c_str()) );
|
||||
|
||||
}
|
||||
|
||||
@ -523,7 +523,7 @@ bool UserConfig::loadConfig(const std::string& filename)
|
||||
{
|
||||
std::string name;
|
||||
players[i]->get("name", &name);
|
||||
UserConfigParams::m_all_players.push_back( new Player(name.c_str()) );
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(name.c_str()) );
|
||||
}
|
||||
|
||||
// --- Read challenges
|
||||
|
@ -52,7 +52,7 @@ const int CURRENT_CONFIG_VERSION = 7;
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
class XMLNode;
|
||||
class Player;
|
||||
class PlayerProfile;
|
||||
|
||||
/**
|
||||
* The base of a set of small utilities to enable quickly adding/removing stuff to/from config painlessly.
|
||||
@ -268,7 +268,7 @@ namespace UserConfigParams
|
||||
// TODO? implement blacklist for new irrlicht device and GUI
|
||||
PARAM_PREFIX std::vector<std::string> m_blacklist_res;
|
||||
|
||||
PARAM_PREFIX ptr_vector<Player> m_all_players;
|
||||
PARAM_PREFIX ptr_vector<PlayerProfile> m_all_players;
|
||||
|
||||
}
|
||||
#undef PARAM_PREFIX
|
||||
|
@ -299,7 +299,7 @@ namespace StateManager
|
||||
|
||||
if (name == spinnerID)
|
||||
{
|
||||
m_associatedPlayer->setPlayer( UserConfigParams::m_all_players.get(playerName->getValue()) );
|
||||
m_associatedPlayer->setPlayerProfile( UserConfigParams::m_all_players.get(playerName->getValue()) );
|
||||
return false; // do not continue propagating the event
|
||||
}
|
||||
|
||||
@ -579,7 +579,7 @@ void menuEventKarts(Widget* widget, std::string& name)
|
||||
std::cout << "==========\n" << players.size() << " players :\n";
|
||||
for(int n=0; n<players.size(); n++)
|
||||
{
|
||||
std::cout << " Player " << n << " is " << players[n].getPlayer()->getName() << std::endl;
|
||||
std::cout << " Player " << n << " is " << players[n].getProfile()->getName() << std::endl;
|
||||
}
|
||||
std::cout << "==========\n";
|
||||
|
||||
|
@ -373,7 +373,7 @@ void TrackInfoDialog::processEvent(std::string& eventSource)
|
||||
#pragma mark PlayerInfoDialog
|
||||
#endif
|
||||
|
||||
PlayerInfoDialog::PlayerInfoDialog(Player* player, const float w, const float h) : ModalDialog(w, h)
|
||||
PlayerInfoDialog::PlayerInfoDialog(PlayerProfile* player, const float w, const float h) : ModalDialog(w, h)
|
||||
{
|
||||
m_player = player;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "gui/skin.hpp"
|
||||
|
||||
class Player;
|
||||
class PlayerProfile;
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
@ -98,7 +98,7 @@ public:
|
||||
class PlayerInfoDialog : public ModalDialog
|
||||
{
|
||||
TextBoxWidget* textCtrl;
|
||||
Player* m_player;
|
||||
PlayerProfile* m_player;
|
||||
|
||||
void showRegularDialog();
|
||||
void showConfirmDialog();
|
||||
@ -106,7 +106,7 @@ public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
PlayerInfoDialog(Player* PlayerInfoDialog,
|
||||
PlayerInfoDialog(PlayerProfile* PlayerInfoDialog,
|
||||
const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
void processEvent(std::string& eventSource);
|
||||
|
@ -524,7 +524,7 @@ namespace StateManager
|
||||
/**
|
||||
* Adds a new player (if 'player' is NULL) or renames an existing player (if 'player' is not NULL)
|
||||
*/
|
||||
void gotNewPlayerName(const stringw& newName, Player* player)
|
||||
void gotNewPlayerName(const stringw& newName, PlayerProfile* player)
|
||||
{
|
||||
stringc newNameC( newName );
|
||||
ListWidget* players = getCurrentScreen()->getWidget<ListWidget>("players");
|
||||
@ -533,7 +533,7 @@ namespace StateManager
|
||||
// ---- Add new player
|
||||
if(player == NULL)
|
||||
{
|
||||
UserConfigParams::m_all_players.push_back( new Player(newNameC.c_str()) );
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(newNameC.c_str()) );
|
||||
|
||||
players->addItem( newNameC.c_str() );
|
||||
}
|
||||
@ -553,7 +553,7 @@ namespace StateManager
|
||||
// TODO : need to re-save user config here?
|
||||
}
|
||||
|
||||
void deletePlayer(Player* player)
|
||||
void deletePlayer(PlayerProfile* player)
|
||||
{
|
||||
UserConfigParams::m_all_players.erase(player);
|
||||
|
||||
|
@ -34,8 +34,8 @@ namespace StateManager
|
||||
void menuEventOptions(GUIEngine::Widget* widget, const std::string& name);
|
||||
|
||||
void gotSensedInput(Input* sensedInput);
|
||||
void gotNewPlayerName(const irr::core::stringw& newName, Player* player=NULL);
|
||||
void deletePlayer(Player* player);
|
||||
void gotNewPlayerName(const irr::core::stringw& newName, PlayerProfile* player=NULL);
|
||||
void deletePlayer(PlayerProfile* player);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -53,21 +53,21 @@ public:
|
||||
PlayerKart(const std::string& kart_name,
|
||||
int position, ActivePlayer *_player,
|
||||
const btTransform& init_pos, int player_index);
|
||||
~PlayerKart ();
|
||||
int earlyStartPenalty () {return m_penalty_time>0; }
|
||||
ActivePlayer *getActivePlayer () {return m_player; }
|
||||
Player *getPlayer () {return m_player->getPlayer(); }
|
||||
void update (float);
|
||||
void action (PlayerAction action, int value);
|
||||
void handleZipper ();
|
||||
void collectedItem (const Item &item, int add_info=-1);
|
||||
virtual void crashed (Kart *k);
|
||||
virtual void setPosition (int p);
|
||||
virtual void raceFinished (float time);
|
||||
bool isPlayerKart () const {return true;}
|
||||
Camera* getCamera () {return m_camera;}
|
||||
void reset ();
|
||||
void resetInputState ();
|
||||
~PlayerKart ();
|
||||
int earlyStartPenalty () { return m_penalty_time>0; }
|
||||
ActivePlayer *getPlayer () { return m_player; }
|
||||
PlayerProfile *getPlayerProfile () { return m_player->getProfile(); }
|
||||
void update (float);
|
||||
void action (PlayerAction action, int value);
|
||||
void handleZipper ();
|
||||
void collectedItem (const Item &item, int add_info=-1);
|
||||
virtual void crashed (Kart *k);
|
||||
virtual void setPosition (int p);
|
||||
virtual void raceFinished (float time);
|
||||
bool isPlayerKart () const {return true;}
|
||||
Camera* getCamera () {return m_camera;}
|
||||
void reset ();
|
||||
void resetInputState ();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -367,7 +367,7 @@ void World::updateHighscores()
|
||||
HighscoreEntry* highscores = getHighscores();
|
||||
|
||||
if(highscores->addData(k->getName(),
|
||||
k->getPlayer()->getName(),
|
||||
k->getPlayer()->getProfile()->getName(),
|
||||
k->getFinishTime())>0 )
|
||||
{
|
||||
highscore_manager->Save();
|
||||
|
@ -72,7 +72,7 @@ void ConnectMessage::setId()
|
||||
{
|
||||
char hostname[256];
|
||||
gethostname(hostname, 255);
|
||||
const std::string& id = StateManager::getActivePlayer(0)->getPlayer()->getName();
|
||||
const std::string& id = StateManager::getActivePlayer(0)->getProfile()->getName();
|
||||
std::ostringstream o;
|
||||
o << id << '@' << hostname;
|
||||
m_id = o.str();
|
||||
|
@ -119,7 +119,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id, const std::string& ka
|
||||
assert(0<=player_id && player_id <m_local_kart_info.size());
|
||||
|
||||
m_local_kart_info[player_id] = RemoteKartInfo(player_id, kart,
|
||||
StateManager::getActivePlayer(player_id)->getPlayer()->getName(),
|
||||
StateManager::getActivePlayer(player_id)->getProfile()->getName(),
|
||||
network_manager->getMyHostId());
|
||||
} // setLocalKartInfo
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user