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 "race/race_manager.hpp"
|
||||||
#include "modes/world.hpp"
|
#include "modes/world.hpp"
|
||||||
|
|
||||||
ActivePlayer::ActivePlayer(Player* player)
|
ActivePlayer::ActivePlayer(PlayerProfile* player)
|
||||||
{
|
{
|
||||||
m_player = player;
|
m_player = player;
|
||||||
m_device = NULL;
|
m_device = NULL;
|
||||||
@ -13,11 +13,11 @@ ActivePlayer::~ActivePlayer()
|
|||||||
setDevice(NULL);
|
setDevice(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* ActivePlayer::getPlayer()
|
PlayerProfile* ActivePlayer::getProfile()
|
||||||
{
|
{
|
||||||
return m_player;
|
return m_player;
|
||||||
}
|
}
|
||||||
void ActivePlayer::setPlayer(Player* player)
|
void ActivePlayer::setPlayerProfile(PlayerProfile* player)
|
||||||
{
|
{
|
||||||
m_player = player;
|
m_player = player;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ PlayerKart* ActivePlayer::getKart()
|
|||||||
const int amount = RaceManager::getWorld()->getCurrentNumLocalPlayers();
|
const int amount = RaceManager::getWorld()->getCurrentNumLocalPlayers();
|
||||||
for (int p=0; p<amount; p++)
|
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);
|
return RaceManager::getWorld()->getLocalPlayerKart(p);
|
||||||
}
|
}
|
||||||
|
@ -28,11 +28,11 @@ class InputDevice;
|
|||||||
class PlayerKart;
|
class PlayerKart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class for managing player name and control configuration.
|
* class for managing player profiles (name, control configuration, etc.)
|
||||||
* A list of all possible players is stored in the user config.
|
* 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)
|
* A list of currently playing players will be stored somewhere else (FIXME : complete comment)
|
||||||
*/
|
*/
|
||||||
class Player
|
class PlayerProfile
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ private:
|
|||||||
|
|
||||||
public:
|
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_name(name, "name", &m_player_group),
|
||||||
m_last_kart_id(-1)
|
m_last_kart_id(-1)
|
||||||
{
|
{
|
||||||
@ -61,20 +61,21 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a player that is currently playing.
|
* Represents a player that is currently playing. It helps manage associating with a
|
||||||
* FIXME: this class seems very closely related to PlayerKart, maybe merge them
|
* 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
|
class ActivePlayer
|
||||||
{
|
{
|
||||||
Player* m_player;
|
PlayerProfile* m_player;
|
||||||
InputDevice* m_device;
|
InputDevice* m_device;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ActivePlayer(Player* player);
|
ActivePlayer(PlayerProfile* player);
|
||||||
~ActivePlayer();
|
~ActivePlayer();
|
||||||
|
|
||||||
Player* getPlayer();
|
PlayerProfile* getProfile();
|
||||||
void setPlayer(Player* player);
|
void setPlayerProfile(PlayerProfile* player);
|
||||||
|
|
||||||
InputDevice* getDevice() const;
|
InputDevice* getDevice() const;
|
||||||
void setDevice(InputDevice* device);
|
void setDevice(InputDevice* device);
|
||||||
|
@ -369,7 +369,7 @@ void UserConfig::addDefaultPlayer()
|
|||||||
username = getenv("LOGNAME");
|
username = getenv("LOGNAME");
|
||||||
|
|
||||||
// Set the name as the default name for all players.
|
// 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;
|
std::string name;
|
||||||
players[i]->get("name", &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
|
// --- Read challenges
|
||||||
|
@ -52,7 +52,7 @@ const int CURRENT_CONFIG_VERSION = 7;
|
|||||||
#include "utils/ptr_vector.hpp"
|
#include "utils/ptr_vector.hpp"
|
||||||
|
|
||||||
class XMLNode;
|
class XMLNode;
|
||||||
class Player;
|
class PlayerProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base of a set of small utilities to enable quickly adding/removing stuff to/from config painlessly.
|
* 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
|
// TODO? implement blacklist for new irrlicht device and GUI
|
||||||
PARAM_PREFIX std::vector<std::string> m_blacklist_res;
|
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
|
#undef PARAM_PREFIX
|
||||||
|
@ -299,7 +299,7 @@ namespace StateManager
|
|||||||
|
|
||||||
if (name == spinnerID)
|
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
|
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";
|
std::cout << "==========\n" << players.size() << " players :\n";
|
||||||
for(int n=0; n<players.size(); 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";
|
std::cout << "==========\n";
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ void TrackInfoDialog::processEvent(std::string& eventSource)
|
|||||||
#pragma mark PlayerInfoDialog
|
#pragma mark PlayerInfoDialog
|
||||||
#endif
|
#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;
|
m_player = player;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "utils/ptr_vector.hpp"
|
#include "utils/ptr_vector.hpp"
|
||||||
#include "gui/skin.hpp"
|
#include "gui/skin.hpp"
|
||||||
|
|
||||||
class Player;
|
class PlayerProfile;
|
||||||
|
|
||||||
namespace GUIEngine
|
namespace GUIEngine
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
class PlayerInfoDialog : public ModalDialog
|
class PlayerInfoDialog : public ModalDialog
|
||||||
{
|
{
|
||||||
TextBoxWidget* textCtrl;
|
TextBoxWidget* textCtrl;
|
||||||
Player* m_player;
|
PlayerProfile* m_player;
|
||||||
|
|
||||||
void showRegularDialog();
|
void showRegularDialog();
|
||||||
void showConfirmDialog();
|
void showConfirmDialog();
|
||||||
@ -106,7 +106,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Creates a modal dialog with given percentage of screen width and height
|
* Creates a modal dialog with given percentage of screen width and height
|
||||||
*/
|
*/
|
||||||
PlayerInfoDialog(Player* PlayerInfoDialog,
|
PlayerInfoDialog(PlayerProfile* PlayerInfoDialog,
|
||||||
const float percentWidth, const float percentHeight);
|
const float percentWidth, const float percentHeight);
|
||||||
void onEnterPressedInternal();
|
void onEnterPressedInternal();
|
||||||
void processEvent(std::string& eventSource);
|
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)
|
* 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 );
|
stringc newNameC( newName );
|
||||||
ListWidget* players = getCurrentScreen()->getWidget<ListWidget>("players");
|
ListWidget* players = getCurrentScreen()->getWidget<ListWidget>("players");
|
||||||
@ -533,7 +533,7 @@ namespace StateManager
|
|||||||
// ---- Add new player
|
// ---- Add new player
|
||||||
if(player == NULL)
|
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() );
|
players->addItem( newNameC.c_str() );
|
||||||
}
|
}
|
||||||
@ -553,7 +553,7 @@ namespace StateManager
|
|||||||
// TODO : need to re-save user config here?
|
// TODO : need to re-save user config here?
|
||||||
}
|
}
|
||||||
|
|
||||||
void deletePlayer(Player* player)
|
void deletePlayer(PlayerProfile* player)
|
||||||
{
|
{
|
||||||
UserConfigParams::m_all_players.erase(player);
|
UserConfigParams::m_all_players.erase(player);
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ namespace StateManager
|
|||||||
void menuEventOptions(GUIEngine::Widget* widget, const std::string& name);
|
void menuEventOptions(GUIEngine::Widget* widget, const std::string& name);
|
||||||
|
|
||||||
void gotSensedInput(Input* sensedInput);
|
void gotSensedInput(Input* sensedInput);
|
||||||
void gotNewPlayerName(const irr::core::stringw& newName, Player* player=NULL);
|
void gotNewPlayerName(const irr::core::stringw& newName, PlayerProfile* player=NULL);
|
||||||
void deletePlayer(Player* player);
|
void deletePlayer(PlayerProfile* player);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,8 +55,8 @@ public:
|
|||||||
const btTransform& init_pos, int player_index);
|
const btTransform& init_pos, int player_index);
|
||||||
~PlayerKart ();
|
~PlayerKart ();
|
||||||
int earlyStartPenalty () { return m_penalty_time>0; }
|
int earlyStartPenalty () { return m_penalty_time>0; }
|
||||||
ActivePlayer *getActivePlayer () {return m_player; }
|
ActivePlayer *getPlayer () { return m_player; }
|
||||||
Player *getPlayer () {return m_player->getPlayer(); }
|
PlayerProfile *getPlayerProfile () { return m_player->getProfile(); }
|
||||||
void update (float);
|
void update (float);
|
||||||
void action (PlayerAction action, int value);
|
void action (PlayerAction action, int value);
|
||||||
void handleZipper ();
|
void handleZipper ();
|
||||||
|
@ -367,7 +367,7 @@ void World::updateHighscores()
|
|||||||
HighscoreEntry* highscores = getHighscores();
|
HighscoreEntry* highscores = getHighscores();
|
||||||
|
|
||||||
if(highscores->addData(k->getName(),
|
if(highscores->addData(k->getName(),
|
||||||
k->getPlayer()->getName(),
|
k->getPlayer()->getProfile()->getName(),
|
||||||
k->getFinishTime())>0 )
|
k->getFinishTime())>0 )
|
||||||
{
|
{
|
||||||
highscore_manager->Save();
|
highscore_manager->Save();
|
||||||
|
@ -72,7 +72,7 @@ void ConnectMessage::setId()
|
|||||||
{
|
{
|
||||||
char hostname[256];
|
char hostname[256];
|
||||||
gethostname(hostname, 255);
|
gethostname(hostname, 255);
|
||||||
const std::string& id = StateManager::getActivePlayer(0)->getPlayer()->getName();
|
const std::string& id = StateManager::getActivePlayer(0)->getProfile()->getName();
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
o << id << '@' << hostname;
|
o << id << '@' << hostname;
|
||||||
m_id = o.str();
|
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());
|
assert(0<=player_id && player_id <m_local_kart_info.size());
|
||||||
|
|
||||||
m_local_kart_info[player_id] = RemoteKartInfo(player_id, kart,
|
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());
|
network_manager->getMyHostId());
|
||||||
} // setLocalKartInfo
|
} // setLocalKartInfo
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user