Fix handicap in splitscreen and network
This commit is contained in:
parent
6a25384ed9
commit
d17fddcac8
@ -80,7 +80,7 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
|
||||
m_children.push_back(skill_bar);
|
||||
}
|
||||
|
||||
setValues(props);
|
||||
setValues(props, PLAYER_DIFFICULTY_NORMAL);
|
||||
|
||||
move(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
|
||||
area.getWidth(), area.getHeight());
|
||||
@ -88,7 +88,8 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void KartStatsWidget::setValues(const KartProperties* props)
|
||||
void KartStatsWidget::setValues(const KartProperties* props,
|
||||
PerPlayerDifficulty d)
|
||||
{
|
||||
// Use kart properties computed for "hard" difficulty to show the user, so
|
||||
// that properties don't change according to the the last used difficulty
|
||||
@ -97,7 +98,7 @@ void KartStatsWidget::setValues(const KartProperties* props)
|
||||
RaceManager::Difficulty previous_difficulty = race_manager->getDifficulty();
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
|
||||
KartProperties kp_computed;
|
||||
kp_computed.copyForPlayer(props);
|
||||
kp_computed.copyForPlayer(props, d);
|
||||
|
||||
// Scale the values so they look better
|
||||
// The scaling factor and offset were found by trial and error.
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "guiengine/widgets/skill_level_widget.hpp"
|
||||
|
||||
class KartProperties;
|
||||
enum PerPlayerDifficulty : uint8_t;
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
@ -94,7 +95,7 @@ namespace GUIEngine
|
||||
* inside itself */
|
||||
void setSize(const int x, const int y, const int w, const int h);
|
||||
|
||||
void setValues(const KartProperties* props);
|
||||
void setValues(const KartProperties* props, PerPlayerDifficulty d);
|
||||
|
||||
/** Change the value of the widget, it must be a percent. */
|
||||
void setValue(Stats type, int value);
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "karts/kart_model.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/kart_properties_manager.hpp"
|
||||
#include "network/network_player_profile.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
#include <IGUIEnvironment.h>
|
||||
|
||||
@ -36,7 +35,6 @@ using namespace GUIEngine;
|
||||
|
||||
PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associated_player,
|
||||
NetworkPlayerProfile* associated_user,
|
||||
core::recti area, const int player_id,
|
||||
std::string kart_group,
|
||||
const int irrlicht_widget_id) : Widget(WTYPE_DIV)
|
||||
@ -49,14 +47,13 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
m_ready_text = NULL;
|
||||
m_parent_screen = parent;
|
||||
|
||||
m_associated_user = associated_user;
|
||||
m_associated_player = associated_player;
|
||||
x_speed = 1.0f;
|
||||
y_speed = 1.0f;
|
||||
w_speed = 1.0f;
|
||||
h_speed = 1.0f;
|
||||
m_ready = false;
|
||||
m_handicapped = false;
|
||||
m_difficulty = PLAYER_DIFFICULTY_NORMAL;
|
||||
m_not_updated_yet = true;
|
||||
|
||||
m_irrlicht_widget_id = irrlicht_widget_id;
|
||||
@ -116,10 +113,6 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
m_player_ident_spinner->setBadge(GAMEPAD_BADGE);
|
||||
}
|
||||
}
|
||||
else if (m_associated_user) // online user, FIXME is that useful ?
|
||||
{
|
||||
m_player_ident_spinner->setBadge(OK_BADGE);
|
||||
}
|
||||
|
||||
if (irrlicht_widget_id == -1)
|
||||
{
|
||||
@ -184,7 +177,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
"kart '%s' nor any other kart.",
|
||||
default_kart.c_str());
|
||||
}
|
||||
m_kartInternalName = props->getIdent();
|
||||
m_kart_internal_name = props->getIdent();
|
||||
|
||||
const KartModel &kart_model = props->getMasterKartModel();
|
||||
|
||||
@ -374,8 +367,6 @@ void PlayerKartWidget::add()
|
||||
irr::core::stringw name; // name of the player
|
||||
if (m_associated_player)
|
||||
name = m_associated_player->getProfile()->getName();
|
||||
if (m_associated_user)
|
||||
name = m_associated_user->getName();
|
||||
core::stringw label = translations->fribidize(name);
|
||||
|
||||
if (m_parent_screen->m_multiplayer)
|
||||
@ -478,12 +469,12 @@ bool PlayerKartWidget::isReady()
|
||||
} // isReady
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** \return Whether this player is handicapped or not */
|
||||
bool PlayerKartWidget::isHandicapped()
|
||||
/** \return Per player difficulty */
|
||||
PerPlayerDifficulty PlayerKartWidget::getDifficulty()
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
return m_handicapped;
|
||||
} // isHandicapped
|
||||
return m_difficulty;
|
||||
} // getDifficulty
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** Updates the animation (moving/shrinking/etc.) */
|
||||
@ -636,13 +627,19 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(Widget* w,
|
||||
m_associated_player->setPlayerProfile(profile);
|
||||
if(UserConfigParams::m_per_player_difficulty && spinner_value % 2 != 0)
|
||||
{
|
||||
m_handicapped = true;
|
||||
m_difficulty = PLAYER_DIFFICULTY_HANDICAP;
|
||||
m_model_view->setBadge(ANCHOR_BADGE);
|
||||
m_kart_stats->setValues(
|
||||
kart_properties_manager->getKart(m_kart_internal_name),
|
||||
PLAYER_DIFFICULTY_HANDICAP);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_handicapped = false;
|
||||
m_difficulty = PLAYER_DIFFICULTY_NORMAL;
|
||||
m_model_view->unsetBadge(ANCHOR_BADGE);
|
||||
m_kart_stats->setValues(
|
||||
kart_properties_manager->getKart(m_kart_internal_name),
|
||||
PLAYER_DIFFICULTY_NORMAL);
|
||||
}
|
||||
m_model_view->getModelViewRenderInfo()->setHue(
|
||||
m_associated_player->getConstProfile()->getDefaultKartColor());
|
||||
@ -728,7 +725,7 @@ void PlayerKartWidget::setSize(const int x, const int y, const int w, const int
|
||||
void PlayerKartWidget::setKartInternalName(const std::string& whichKart)
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
m_kartInternalName = whichKart;
|
||||
m_kart_internal_name = whichKart;
|
||||
} // setKartInternalName
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -736,7 +733,7 @@ void PlayerKartWidget::setKartInternalName(const std::string& whichKart)
|
||||
const std::string& PlayerKartWidget::getKartInternalName() const
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
return m_kartInternalName;
|
||||
return m_kart_internal_name;
|
||||
} // getKartInternalName
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -748,3 +745,15 @@ EventPropagation PlayerKartWidget::onSpinnerConfirmed()
|
||||
return EVENT_BLOCK;
|
||||
} // onSpinnerConfirmed
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
void PlayerKartWidget::enableHandicapForNetwork()
|
||||
{
|
||||
m_difficulty = PLAYER_DIFFICULTY_HANDICAP;
|
||||
m_model_view->setBadge(ANCHOR_BADGE);
|
||||
m_kart_stats->setValues(
|
||||
kart_properties_manager->getKart(m_kart_internal_name),
|
||||
PLAYER_DIFFICULTY_HANDICAP);
|
||||
core::stringw label = _("%s (handicapped)",
|
||||
m_player_ident_spinner->getCustomText());
|
||||
m_player_ident_spinner->setCustomText(label);
|
||||
} // enableHandicapForNetwork
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
|
||||
class KartSelectionScreen;
|
||||
class NetworkPlayerProfile;
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
@ -44,7 +43,7 @@ namespace GUIEngine
|
||||
/** Whether this player confirmed their selection */
|
||||
bool m_ready;
|
||||
/** If the player is handicapped. */
|
||||
bool m_handicapped;
|
||||
PerPlayerDifficulty m_difficulty;
|
||||
|
||||
/** widget coordinates */
|
||||
int player_name_x, player_name_y, player_name_w, player_name_h;
|
||||
@ -65,9 +64,6 @@ namespace GUIEngine
|
||||
StateManager::ActivePlayer* m_associated_player;
|
||||
int m_player_id;
|
||||
|
||||
/** Network info about the user. */
|
||||
NetworkPlayerProfile* m_associated_user;
|
||||
|
||||
/** Internal name of the spinner; useful to interpret spinner events,
|
||||
* which contain the name of the activated object */
|
||||
std::string spinnerID;
|
||||
@ -91,13 +87,12 @@ namespace GUIEngine
|
||||
irr::gui::IGUIStaticText* m_ready_text;
|
||||
|
||||
core::stringw deviceName;
|
||||
std::string m_kartInternalName;
|
||||
std::string m_kart_internal_name;
|
||||
|
||||
bool m_not_updated_yet;
|
||||
|
||||
PlayerKartWidget(KartSelectionScreen* parent,
|
||||
StateManager::ActivePlayer* associated_player,
|
||||
NetworkPlayerProfile* associated_user,
|
||||
core::recti area, const int player_id,
|
||||
std::string kart_group,
|
||||
const int irrlicht_idget_id=-1);
|
||||
@ -137,8 +132,8 @@ namespace GUIEngine
|
||||
bool isReady();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** \return Whether this player is handicapped or not */
|
||||
bool isHandicapped();
|
||||
/** \return Per player difficulty */
|
||||
PerPlayerDifficulty getDifficulty();
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
/** Updates the animation (moving/shrinking/etc.) */
|
||||
@ -169,6 +164,8 @@ namespace GUIEngine
|
||||
|
||||
/** \brief Event callback from ISpinnerConfirmListener */
|
||||
virtual GUIEngine::EventPropagation onSpinnerConfirmed();
|
||||
// -------------------------------------------------------------------------
|
||||
void enableHandicapForNetwork();
|
||||
}; // PlayerKartWidget
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ void SpinnerWidget::addLabel(stringw label)
|
||||
void SpinnerWidget::setValue(const int new_value)
|
||||
{
|
||||
m_value = new_value;
|
||||
m_customText = "";
|
||||
m_custom_text = "";
|
||||
|
||||
if (m_graphical)
|
||||
{
|
||||
@ -402,30 +402,30 @@ void SpinnerWidget::setActive(bool active)
|
||||
if (active)
|
||||
{
|
||||
setText(L"");
|
||||
if (m_customText.empty())
|
||||
if (m_custom_text.empty())
|
||||
{
|
||||
setValue(getValue()); // Update the display
|
||||
}
|
||||
else
|
||||
{
|
||||
setCustomText(m_customText);
|
||||
setCustomText(m_custom_text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save it temporary because setValue(which is uses for update in
|
||||
// this case) overwrites it
|
||||
core::stringw customText = m_customText;
|
||||
core::stringw custom_text = m_custom_text;
|
||||
setText(L"-");
|
||||
setValue(getValue()); // Update the display
|
||||
m_customText = customText;
|
||||
m_custom_text = custom_text;
|
||||
}
|
||||
} // setActive
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void SpinnerWidget::setCustomText(const core::stringw& text)
|
||||
{
|
||||
m_customText = text;
|
||||
m_custom_text = text;
|
||||
if (m_children.size() > 0)
|
||||
{
|
||||
m_children[1].m_element->setText(text.c_str());
|
||||
|
@ -79,7 +79,7 @@ namespace GUIEngine
|
||||
/** \brief Keeps track of the custom text in spinner (a text which isn't related to a value)
|
||||
* to remember it and set it back (example : when we deactivate the widget)
|
||||
*/
|
||||
core::stringw m_customText;
|
||||
core::stringw m_custom_text;
|
||||
|
||||
/** \brief implementing method from base class Widget */
|
||||
virtual EventPropagation transmitEvent(Widget* w,
|
||||
@ -197,6 +197,7 @@ namespace GUIEngine
|
||||
|
||||
/** Display custom text in spinner */
|
||||
void setCustomText(const core::stringw& text);
|
||||
const core::stringw& getCustomText() const { return m_custom_text; }
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ AbstractKart::AbstractKart(const std::string& ident,
|
||||
ident.c_str());
|
||||
kp = kart_properties_manager->getKart(std::string("tux"));
|
||||
}
|
||||
m_kart_properties->copyForPlayer(kp);
|
||||
m_kart_properties->copyForPlayer(kp, difficulty);
|
||||
m_difficulty = difficulty;
|
||||
m_kart_animation = NULL;
|
||||
assert(m_kart_properties);
|
||||
|
@ -55,19 +55,19 @@
|
||||
* \param init_pos The start coordinates and heading of the kart.
|
||||
*/
|
||||
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
|
||||
const int local_playerID)
|
||||
const int local_player_id,
|
||||
PerPlayerDifficulty d)
|
||||
: PlayerController(kart), m_sky_particles_emitter(NULL)
|
||||
{
|
||||
|
||||
m_player = StateManager::get()->getActivePlayer(local_playerID);
|
||||
m_difficulty = d;
|
||||
m_player = StateManager::get()->getActivePlayer(local_player_id);
|
||||
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, local_playerID);
|
||||
|
||||
Camera *camera = Camera::createCamera(kart, local_player_id);
|
||||
|
||||
m_camera_index = camera->getIndex();
|
||||
m_wee_sound = SFXManager::get()->createSoundSource("wee");
|
||||
m_bzzt_sound = SFXManager::get()->getBuffer("bzzt");
|
||||
@ -390,5 +390,10 @@ core::stringw LocalPlayerController::getName() const
|
||||
{
|
||||
if (NetworkConfig::get()->isNetworking())
|
||||
return PlayerController::getName();
|
||||
return m_player->getProfile()->getName();
|
||||
|
||||
core::stringw name = m_player->getProfile()->getName();
|
||||
if (m_difficulty == PLAYER_DIFFICULTY_HANDICAP)
|
||||
name = _("%s (handicapped)", name);
|
||||
|
||||
return name;
|
||||
} // getName
|
||||
|
@ -48,6 +48,8 @@ private:
|
||||
* camera object is managed in the Camera class, so no need to free it. */
|
||||
int m_camera_index;
|
||||
|
||||
PerPlayerDifficulty m_difficulty;
|
||||
|
||||
SFXBase *m_wee_sound;
|
||||
SFXBuffer *m_bzzt_sound;
|
||||
SFXBuffer *m_ugh_sound;
|
||||
@ -58,7 +60,8 @@ private:
|
||||
virtual void displayPenaltyWarning() OVERRIDE;
|
||||
public:
|
||||
LocalPlayerController(AbstractKart *kart,
|
||||
const int local_playerID);
|
||||
const int local_player_id,
|
||||
PerPlayerDifficulty d);
|
||||
~LocalPlayerController();
|
||||
void update (int ticks) OVERRIDE;
|
||||
bool action (PlayerAction action, int value,
|
||||
|
@ -393,12 +393,17 @@ void PlayerController::rewindTo(BareNetworkString *buffer)
|
||||
// ----------------------------------------------------------------------------
|
||||
core::stringw PlayerController::getName() const
|
||||
{
|
||||
core::stringw name = m_kart->getName();
|
||||
if (NetworkConfig::get()->isNetworking())
|
||||
{
|
||||
auto& players = LobbyProtocol::get<LobbyProtocol>()->getGameSetup()
|
||||
->getPlayers();
|
||||
if (auto player = players.at(m_kart->getWorldKartId()).lock())
|
||||
return player->getName();
|
||||
{
|
||||
name = player->getName();
|
||||
if (player->getPerPlayerDifficulty() == PLAYER_DIFFICULTY_HANDICAP)
|
||||
name = _("%s (handicapped)", name);
|
||||
}
|
||||
}
|
||||
return m_kart->getName();
|
||||
return name;
|
||||
} // getName
|
||||
|
@ -132,7 +132,8 @@ KartProperties::~KartProperties()
|
||||
* \param source The source kart properties from which to copy this objects'
|
||||
* values.
|
||||
*/
|
||||
void KartProperties::copyForPlayer(const KartProperties *source)
|
||||
void KartProperties::copyForPlayer(const KartProperties *source,
|
||||
PerPlayerDifficulty d)
|
||||
{
|
||||
*this = *source;
|
||||
|
||||
@ -146,7 +147,7 @@ void KartProperties::copyForPlayer(const KartProperties *source)
|
||||
|
||||
// Combine the characteristics for this object. We can't copy it because
|
||||
// this object has other pointers (to m_characteristic).
|
||||
combineCharacteristics();
|
||||
combineCharacteristics(d);
|
||||
}
|
||||
} // copyForPlayer
|
||||
|
||||
@ -224,7 +225,7 @@ void KartProperties::load(const std::string &filename, const std::string &node)
|
||||
}
|
||||
getAllData(root);
|
||||
m_characteristic = std::make_shared<XmlCharacteristic>(root);
|
||||
combineCharacteristics();
|
||||
combineCharacteristics(PLAYER_DIFFICULTY_NORMAL);
|
||||
}
|
||||
catch(std::exception& err)
|
||||
{
|
||||
@ -343,7 +344,7 @@ void KartProperties::setHatMeshName(const std::string &hat_name)
|
||||
} // setHatMeshName
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void KartProperties::combineCharacteristics()
|
||||
void KartProperties::combineCharacteristics(PerPlayerDifficulty difficulty)
|
||||
{
|
||||
m_combined_characteristic = std::make_shared<CombinedCharacteristic>();
|
||||
m_combined_characteristic->addCharacteristic(kart_properties_manager->
|
||||
@ -362,6 +363,9 @@ void KartProperties::combineCharacteristics()
|
||||
// Kart type found
|
||||
m_combined_characteristic->addCharacteristic(characteristic);
|
||||
|
||||
m_combined_characteristic->addCharacteristic(kart_properties_manager->
|
||||
getPlayerCharacteristic(getPerPlayerDifficultyAsString(difficulty)));
|
||||
|
||||
m_combined_characteristic->addCharacteristic(m_characteristic.get());
|
||||
m_cached_characteristic = std::make_shared<CachedCharacteristic>
|
||||
(m_combined_characteristic.get());
|
||||
|
@ -207,7 +207,7 @@ private:
|
||||
|
||||
void load (const std::string &filename,
|
||||
const std::string &node);
|
||||
void combineCharacteristics();
|
||||
void combineCharacteristics(PerPlayerDifficulty d);
|
||||
|
||||
public:
|
||||
/** Returns the string representation of a per-player difficulty. */
|
||||
@ -215,7 +215,8 @@ public:
|
||||
|
||||
KartProperties (const std::string &filename="");
|
||||
~KartProperties ();
|
||||
void copyForPlayer (const KartProperties *source);
|
||||
void copyForPlayer (const KartProperties *source,
|
||||
PerPlayerDifficulty d = PLAYER_DIFFICULTY_NORMAL);
|
||||
void copyFrom (const KartProperties *source);
|
||||
void getAllData (const XMLNode * root);
|
||||
void checkAllSet (const std::string &filename);
|
||||
|
@ -1094,7 +1094,7 @@ int handleCmdLine()
|
||||
!server_password.empty());
|
||||
NetworkConfig::get()->addNetworkPlayer(
|
||||
input_manager->getDeviceManager()->getLatestUsedDevice(),
|
||||
PlayerManager::getCurrentPlayer(), false/*handicap*/);
|
||||
PlayerManager::getCurrentPlayer(), PLAYER_DIFFICULTY_NORMAL);
|
||||
NetworkConfig::get()->doneAddingNetworkPlayers();
|
||||
STKHost::create();
|
||||
auto cts = std::make_shared<ConnectToServer>(server);
|
||||
|
@ -421,8 +421,8 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
switch(kart_type)
|
||||
{
|
||||
case RaceManager::KT_PLAYER:
|
||||
controller = new LocalPlayerController(new_kart,
|
||||
local_player_id);
|
||||
controller = new LocalPlayerController(new_kart, local_player_id,
|
||||
difficulty);
|
||||
m_num_players ++;
|
||||
break;
|
||||
case RaceManager::KT_NETWORK_PLAYER:
|
||||
|
@ -367,7 +367,8 @@ AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
||||
{
|
||||
case RaceManager::KT_PLAYER:
|
||||
{
|
||||
controller = new LocalPlayerController(new_kart, local_player_id);
|
||||
controller = new LocalPlayerController(new_kart, local_player_id,
|
||||
difficulty);
|
||||
const PlayerProfile* p = StateManager::get()
|
||||
->getActivePlayer(local_player_id)->getConstProfile();
|
||||
if (p && p->getDefaultKartColor() > 0.0f)
|
||||
|
@ -102,7 +102,7 @@ private:
|
||||
std::string m_server_id_file;
|
||||
|
||||
std::vector<std::tuple<InputDevice*, PlayerProfile*,
|
||||
/*is_handicap*/bool> > m_network_players;
|
||||
PerPlayerDifficulty> > m_network_players;
|
||||
|
||||
core::stringw m_motd;
|
||||
|
||||
@ -190,7 +190,8 @@ public:
|
||||
m_password = "";
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const std::vector<std::tuple<InputDevice*, PlayerProfile*, bool> >&
|
||||
const std::vector<std::tuple<InputDevice*, PlayerProfile*,
|
||||
PerPlayerDifficulty> >&
|
||||
getNetworkPlayers() const { return m_network_players; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isAddingNetworkPlayers() const
|
||||
@ -198,7 +199,8 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
void doneAddingNetworkPlayers() { m_done_adding_network_players = true; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool addNetworkPlayer(InputDevice* device, PlayerProfile* profile, bool h)
|
||||
bool addNetworkPlayer(InputDevice* device, PlayerProfile* profile,
|
||||
PerPlayerDifficulty d)
|
||||
{
|
||||
for (auto& p : m_network_players)
|
||||
{
|
||||
@ -207,7 +209,7 @@ public:
|
||||
if (std::get<1>(p) == profile)
|
||||
return false;
|
||||
}
|
||||
m_network_players.emplace_back(device, profile, h);
|
||||
m_network_players.emplace_back(device, profile, d);
|
||||
return true;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -513,6 +513,9 @@ void ClientLobby::updatePlayerList(Event* event)
|
||||
// icon to be used, see NetworkingLobby::loadedFromFile
|
||||
std::get<3>(pl) = data.getUInt8() == 1 /*if server owner*/ ? 0 :
|
||||
std::get<1>(pl) != 0 /*if online account*/ ? 1 : 2;
|
||||
PerPlayerDifficulty d = (PerPlayerDifficulty)data.getUInt8();
|
||||
if (d == PLAYER_DIFFICULTY_HANDICAP)
|
||||
std::get<2>(pl) = _("%s (handicapped)", std::get<2>(pl));
|
||||
players.push_back(pl);
|
||||
}
|
||||
NetworkingLobby::getInstance()->updatePlayers(players);
|
||||
|
@ -1045,6 +1045,7 @@ void ServerLobby::updatePlayerList()
|
||||
if (m_server_owner.lock() == profile->getPeer())
|
||||
server_owner = 1;
|
||||
pl->addUInt8(server_owner);
|
||||
pl->addUInt8(profile->getPerPlayerDifficulty());
|
||||
}
|
||||
sendMessageToPeersChangingToken(pl);
|
||||
delete pl;
|
||||
|
@ -111,11 +111,14 @@ GUIEngine::EventPropagation
|
||||
const unsigned pid = m_profiles->getValue();
|
||||
assert(pid < PlayerManager::get()->getNumPlayers());
|
||||
PlayerProfile* p = m_available_players[pid];
|
||||
const bool handicap = m_handicap->getState();
|
||||
if (NetworkConfig::get()->addNetworkPlayer(m_device, p, handicap))
|
||||
const PerPlayerDifficulty d = m_handicap->getState() ?
|
||||
PLAYER_DIFFICULTY_HANDICAP : PLAYER_DIFFICULTY_NORMAL;
|
||||
if (NetworkConfig::get()->addNetworkPlayer(m_device, p, d))
|
||||
{
|
||||
NetworkingLobby::getInstance()
|
||||
->addSplitscreenPlayer(p->getName());
|
||||
core::stringw name = p->getName();
|
||||
if (d == PLAYER_DIFFICULTY_HANDICAP)
|
||||
name = _("%s (handicapped)", name);
|
||||
NetworkingLobby::getInstance()->addSplitscreenPlayer(name);
|
||||
m_self_destroy = true;
|
||||
return GUIEngine::EVENT_BLOCK;
|
||||
}
|
||||
|
@ -189,14 +189,14 @@ void KartHoverListener::onSelectionChanged(DynamicRibbonWidget* theWidget,
|
||||
{
|
||||
// discard events sent when putting back to the right kart
|
||||
if (selectionID ==
|
||||
m_parent->m_kart_widgets[player_id].m_kartInternalName) return;
|
||||
m_parent->m_kart_widgets[player_id].m_kart_internal_name) return;
|
||||
|
||||
DynamicRibbonWidget* w =
|
||||
m_parent->getWidget<DynamicRibbonWidget>("karts");
|
||||
assert(w != NULL);
|
||||
|
||||
w->setSelection(m_parent->m_kart_widgets[player_id]
|
||||
.m_kartInternalName, player_id, true);
|
||||
.m_kart_internal_name, player_id, true);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -516,7 +516,7 @@ bool KartSelectionScreen::joinPlayer(InputDevice* device, PlayerProfile* p)
|
||||
|
||||
// ---- Create player/kart widget
|
||||
PlayerKartWidget* newPlayerWidget =
|
||||
new PlayerKartWidget(this, aplayer, NULL, kartsArea, m_kart_widgets.size(),
|
||||
new PlayerKartWidget(this, aplayer, kartsArea, m_kart_widgets.size(),
|
||||
selected_kart_group);
|
||||
|
||||
manualAddWidget(newPlayerWidget);
|
||||
@ -832,7 +832,7 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
|
||||
|
||||
if (kp != NULL)
|
||||
{
|
||||
w->setValues(kp);
|
||||
w->setValues(kp, m_kart_widgets[widget_id].getDifficulty());
|
||||
w->update(0);
|
||||
}
|
||||
}
|
||||
@ -1206,7 +1206,7 @@ void KartSelectionScreen::allPlayersDone()
|
||||
const int kart_count = m_kart_widgets.size();
|
||||
for (int n = 0; n < kart_count; n++)
|
||||
{
|
||||
std::string selected_kart = m_kart_widgets[n].m_kartInternalName;
|
||||
std::string selected_kart = m_kart_widgets[n].m_kart_internal_name;
|
||||
|
||||
if (selected_kart == RANDOM_KART_ID)
|
||||
{
|
||||
@ -1238,7 +1238,7 @@ void KartSelectionScreen::allPlayersDone()
|
||||
for (int i=0; i<item_count; i++)
|
||||
{
|
||||
if (items[i].m_code_name ==
|
||||
m_kart_widgets[n].m_kartInternalName)
|
||||
m_kart_widgets[n].m_kart_internal_name)
|
||||
{
|
||||
items[i].m_code_name = ID_DONT_USE;
|
||||
break;
|
||||
@ -1249,9 +1249,8 @@ void KartSelectionScreen::allPlayersDone()
|
||||
race_manager->setPlayerKart(n, selected_kart);
|
||||
|
||||
// Set per player difficulty if needed
|
||||
if (m_multiplayer && UserConfigParams::m_per_player_difficulty &&
|
||||
m_kart_widgets[n].isHandicapped())
|
||||
race_manager->setPlayerDifficulty(n, PLAYER_DIFFICULTY_HANDICAP);
|
||||
if (m_multiplayer && UserConfigParams::m_per_player_difficulty)
|
||||
race_manager->setPlayerDifficulty(n, m_kart_widgets[n].getDifficulty());
|
||||
}
|
||||
|
||||
// ---- Switch to assign mode
|
||||
|
@ -43,6 +43,11 @@ void NetworkKartSelectionScreen::init()
|
||||
for (auto& p : NetworkConfig::get()->getNetworkPlayers())
|
||||
{
|
||||
joinPlayer(std::get<0>(p), std::get<1>(p));
|
||||
if (std::get<2>(p) == PLAYER_DIFFICULTY_HANDICAP)
|
||||
{
|
||||
m_kart_widgets.get(m_kart_widgets.size() -1)
|
||||
->enableHandicapForNetwork();
|
||||
}
|
||||
w->updateItemDisplay();
|
||||
if (!w->setSelection(UserConfigParams::m_default_kart, 0, true))
|
||||
{
|
||||
@ -80,7 +85,7 @@ void NetworkKartSelectionScreen::allPlayersDone()
|
||||
{
|
||||
// If server recieve an invalid name, it will auto correct to a random
|
||||
// kart
|
||||
kart.encodeString(m_kart_widgets[n].m_kartInternalName);
|
||||
kart.encodeString(m_kart_widgets[n].m_kart_internal_name);
|
||||
}
|
||||
STKHost::get()->sendToServer(&kart, true);
|
||||
|
||||
|
@ -111,7 +111,7 @@ void OnlineScreen::init()
|
||||
{
|
||||
NetworkConfig::get()->addNetworkPlayer(
|
||||
input_manager->getDeviceManager()->getLatestUsedDevice(),
|
||||
PlayerManager::getCurrentPlayer(), false/*handicap*/);
|
||||
PlayerManager::getCurrentPlayer(), PLAYER_DIFFICULTY_NORMAL);
|
||||
NetworkConfig::get()->doneAddingNetworkPlayers();
|
||||
}
|
||||
} // init
|
||||
@ -178,7 +178,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
NetworkConfig::get()->cleanNetworkPlayers();
|
||||
NetworkConfig::get()->addNetworkPlayer(
|
||||
input_manager->getDeviceManager()->getLatestUsedDevice(),
|
||||
PlayerManager::getCurrentPlayer(), false/*handicap*/);
|
||||
PlayerManager::getCurrentPlayer(), PLAYER_DIFFICULTY_NORMAL);
|
||||
NetworkConfig::get()->doneAddingNetworkPlayers();
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user