Move handicap to ui options and to the player name spinner

This commit is contained in:
Flakebi 2014-10-26 16:56:50 +01:00
parent 57afd1d585
commit 690e632e1b
13 changed files with 102 additions and 153 deletions

View File

@ -16,27 +16,49 @@
<box proportion="1" width="100%" layout="vertical-row">
<spacer height="5" width="10"/>
<spacer height="5" width="10" />
<!-- ************ SKIN CHOICE ************ -->
<div layout="horizontal-row" width="100%" height="fit">
<label I18N="In the graphics settings" text="Skin" align="center"/>
<label I18N="In the ui settings" text="Skin" align="center"/>
<spacer width="20" height="20"/>
<spinner id="skinchoice" width="30%"/>
</div>
<spacer width="20" height="18" />
<div width="75%" height="fit" layout="horizontal-row" >
<checkbox id="showfps"/>
<spacer width="20" height="100%" />
<label height="100%" I18N="In the ui settings" text="Display FPS"/>
<div layout="horizontal-row" width="100%" height="fit">
<div proportion="1" height="fit" layout="horizontal-row" >
<checkbox id="showfps"/>
<spacer width="20" height="10" />
<label height="100%" I18N="In the ui settings" text="Display FPS"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="perPlayerDifficulty"/>
<spacer width="20" height="10" />
<label I18N="In the ui settings" text="Enable handicaped users"/>
</div>
</div>
<div width="75%" height="fit" layout="horizontal-row" >
<checkbox id="enable-internet"/>
<spacer width="20" height="100%" />
<label height="100%" I18N="In the ui settings" text="Allow STK to connect to the Internet"/>
<spacer height="4" width="10" />
<div layout="horizontal-row" width="100%" height="fit">
<div proportion="1" height="fit" layout="horizontal-row" >
<checkbox id="enable-internet"/>
<spacer width="20" height="100%" />
<label height="100%" I18N="In the ui settings" text="Allow STK to connect to the Internet"/>
</div>
<spacer height="4" width="10" />
<div layout="horizontal-row" proportion="1" height="fit">
<checkbox id="aiHandicap"/>
<spacer width="20" height="10" />
<label I18N="In the ui settings" text="Handicap AI karts"/>
</div>
</div>
<div width="75%" height="fit" layout="horizontal-row" >

View File

@ -342,40 +342,6 @@
so 1 means that nothing changes.
The meaning of the different values is explained below this tag. -->
<difficulties>
<easiest>
<mass value="1.0"/>
<engine brake-factor="2.5" brake-time-increase="1.5" max-speed-reverse-ratio="1.0" power="1.5" max-speed="1.5"/>
<nitro consumption="0.7" max-speed-increase="1.3" duration="1.0" fade-out-time="1.0"/>
<bubblegum time="0.5" speed-fraction="0.5" torque="0.5" fade-in-time="1.0"/>
<rescue time="0.5"/>
<explosion time="0.5" invulnerability-time="1.5"/>
<slipstream length="1.5" width="1.5" collect-time="0.5" use-time="2.0"
add-power="1.5" min-speed="1.5" max-speed-increase="1.5" duration="1.5"
fade-out-time="1.0"/>
<plunger band-max-length="1.5" band-force="1.0" band-duration="1.0"
band-speed-increase="1.5" band-fade-out-time="1.0" in-face-time="0.5"/>
<zipper time="1.3" force="1.3" speed-gain="1.3" max-speed-increase="1.3"
fade-out-time="1.0"/>
<swatter duration="1.5" squash-duration="0.7" squash-slowdown="0.5"/>
<startup time="2.0 2.0" boost="1.5 1.5"/>
</easiest>
<easy>
<mass value="1.0"/>
<engine brake-factor="1.7" brake-time-increase="1.2" max-speed-reverse-ratio="1.0" power="1.2" max-speed="1.2"/>
<nitro consumption="0.9" max-speed-increase="1.1" duration="1.0" fade-out-time="1.0"/>
<bubblegum time="0.7" speed-fraction="0.7" torque="0.7" fade-in-time="1.0"/>
<rescue time="0.7"/>
<explosion time="0.7" invulnerability-time="1.2"/>
<slipstream length="1.2" width="1.2" collect-time="0.7" use-time="1.5"
add-power="1.3" min-speed="1.3" max-speed-increase="1.3" duration="1.3"
fade-out-time="1.0"/>
<plunger band-max-length="1.2" band-force="1.0" band-duration="1.0"
band-speed-increase="1.2" band-fade-out-time="1.0" in-face-time="0.7"/>
<zipper time="1.2" force="1.1" speed-gain="1.1" max-speed-increase="1.1"
fade-out-time="1.0"/>
<swatter duration="1.2" squash-duration="0.8" squash-slowdown="0.7"/>
<startup time="1.5 1.5" boost="1.2 1.2"/>
</easy>
<normal>
<mass value="1.0"/>
<engine brake-factor="1.0" brake-time-increase="1.0" max-speed-reverse-ratio="1.0" power="1.0" max-speed="1.0"/>
@ -393,7 +359,7 @@
<swatter duration="1.0" squash-duration="1.0" squash-slowdown="1.0"/>
<startup time="1.0 1.0" boost="1.0 1.0"/>
</normal>
<hard>
<handicap>
<mass value="1.0"/>
<engine brake-factor="0.8" brake-time-increase="0.85" max-speed-reverse-ratio="0.8" power="0.8" max-speed="0.8"/>
<nitro consumption="1.1" max-speed-increase="0.9" duration="1.0" fade-out-time="1.0"/>
@ -409,24 +375,7 @@
fade-out-time="1.0"/>
<swatter duration="0.8" squash-duration="1.5" squash-slowdown="1.8"/>
<startup time="0.8 0.8" boost="0.8 0.8"/>
</hard>
<hardest>
<mass value="1.0"/>
<engine brake-factor="0.5" brake-time-increase="0.7" max-speed-reverse-ratio="0.6" power="0.6" max-speed="0.6"/>
<nitro consumption="1.2" max-speed-increase="0.8" duration="1.0" fade-out-time="1.0"/>
<bubblegum time="2.0" speed-fraction="2.0" torque="2.0" fade-in-time="1.0"/>
<rescue time="2.0"/>
<explosion time="1.5" invulnerability-time="0.5"/>
<slipstream length="0.6" width="0.6" collect-time="1.5" use-time="0.6"
add-power="0.6" min-speed="0.6" max-speed-increase="0.8" duration="0.6"
fade-out-time="1.0"/>
<plunger band-max-length="0.6" band-force="1.0" band-duration="1.0"
band-speed-increase="0.6" band-fade-out-time="1.0" in-face-time="1.5"/>
<zipper time="0.6" force="0.6" speed-gain="0.6" max-speed-increase="0.6"
fade-out-time="1.0"/>
<swatter duration="0.6" squash-duration="1.5" squash-slowdown="1.8"/>
<startup time="0.6 0.6" boost="0.6 0.6"/>
</hardets>
</handicap>
</difficulties>
<!-- Suspension related values. stiffness: kart's suspension stiffness.

View File

@ -41,8 +41,6 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
m_local_name = name;
m_is_guest_account = is_guest;
m_use_frequency = is_guest ? -1 : 0;
m_difficulty = PLAYER_DIFFICULTY_NORMAL;
m_singleplayer_difficulty = false;
m_unique_id = PlayerManager::get()->getUniqueId();
m_saved_session = false;
m_saved_token = "";
@ -70,8 +68,6 @@ PlayerProfile::PlayerProfile(const core::stringw& name, bool is_guest)
*/
PlayerProfile::PlayerProfile(const XMLNode* node)
{
m_difficulty = PLAYER_DIFFICULTY_NORMAL;
m_singleplayer_difficulty = false;
m_saved_session = false;
m_saved_token = "";
m_saved_user_id = 0;
@ -85,8 +81,6 @@ PlayerProfile::PlayerProfile(const XMLNode* node)
node->get("name", &m_local_name );
node->get("guest", &m_is_guest_account );
node->get("use-frequency", &m_use_frequency );
node->get("difficulty", (int*) &m_difficulty);
node->get("singleplayer-difficulty", &m_singleplayer_difficulty);
node->get("unique-id", &m_unique_id );
node->get("saved-session", &m_saved_session );
node->get("saved-user", &m_saved_user_id );
@ -206,9 +200,6 @@ void PlayerProfile::save(UTFWriter &out)
out << L" icon-filename=\"" << m_icon_filename << L"\"\n";
out << L" difficulty=\"" << m_difficulty
<< L"\" singleplayer-difficulty=\"" << m_singleplayer_difficulty << L"\"\n";
out << L" unique-id=\"" << m_unique_id
<< L"\" saved-session=\"" << m_saved_session << L"\"\n";

View File

@ -87,13 +87,6 @@ private:
/** Absolute path of the icon file for this player. */
std::string m_icon_filename;
/** The difficulty (boost or handicap) for this player. */
PerPlayerDifficulty m_difficulty;
/** If the per player difficulty should be applied for singleplayer games.
Story mode is excluded to prevent cheating. */
bool m_singleplayer_difficulty;
/** True if this user has a saved session. */
bool m_saved_session;
@ -167,42 +160,6 @@ public:
return m_local_name.c_str();
} // getName
// ------------------------------------------------------------------------
/** Sets the per player difficulty for this player. */
void setDifficulty(const PerPlayerDifficulty difficulty)
{
#ifdef DEBUG
assert(m_magic_number == 0xABCD1234);
#endif
m_difficulty = difficulty;
} // setDifficulty
// ------------------------------------------------------------------------
/** Returns the per player difficulty of this player. */
PerPlayerDifficulty getDifficulty() const
{
assert(m_magic_number == 0xABCD1234);
return m_difficulty;
} // getDifficulty
// ------------------------------------------------------------------------
/** Sets the singleplayer difficulty for this player. */
void setSingleplayerDifficulty(const bool singleplayer_difficulty)
{
#ifdef DEBUG
assert(m_magic_number == 0xABCD1234);
#endif
m_singleplayer_difficulty = singleplayer_difficulty;
} // setSingleplayerDifficulty
// ------------------------------------------------------------------------
/** Returns the per player difficulty of this player. */
bool isSingleplayerDifficulty() const
{
assert(m_magic_number == 0xABCD1234);
return m_singleplayer_difficulty;
} // getDifficulty
// ------------------------------------------------------------------------
/** Returns true if this player is a guest account. */
bool isGuestAccount() const

View File

@ -671,6 +671,12 @@ namespace UserConfigParams
PARAM_PREFIX StringUserConfigParam m_skin_file
PARAM_DEFAULT( StringUserConfigParam("Peach.stkskin", "skin_file",
"Name of the skin to use") );
PARAM_PREFIX BoolUserConfigParam m_per_player_difficulty
PARAM_DEFAULT( BoolUserConfigParam(false, "per_player_difficulty",
"If handicapped users can be selected") );
PARAM_PREFIX BoolUserConfigParam m_ai_handicap
PARAM_DEFAULT( BoolUserConfigParam(false, "ai_handicap",
"If AIs are handicapped") );
// ---- Internet related

View File

@ -54,6 +54,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
w_speed = 1.0f;
h_speed = 1.0f;
m_ready = false;
m_handicapped = false;
m_not_updated_yet = true;
m_irrlicht_widget_id = irrlicht_widget_id;
@ -351,6 +352,9 @@ void PlayerKartWidget::add()
{
core::stringw name = PlayerManager::get()->getPlayer(n)->getName();
m_player_ident_spinner->addLabel(translations->fribidize(name));
if (UserConfigParams::m_per_player_difficulty)
// The second player is the same, but with handicap
m_player_ident_spinner->addLabel(translations->fribidize(name));
}
// select the right player profile in the spinner
@ -362,6 +366,9 @@ void PlayerKartWidget::add()
m_player_ident_spinner->setVisible(false);
}
// Add anchor badge if the player is handicapped
int spinner_value = m_player_ident_spinner->getValue();
assert(m_player_ident_spinner->getStringValue() == name);
} // add
@ -437,6 +444,14 @@ bool PlayerKartWidget::isReady()
return m_ready;
} // isReady
// ------------------------------------------------------------------------
/** \return Whether this player is handicapped or not */
bool PlayerKartWidget::isHandicapped()
{
assert(m_magic_number == 0x33445566);
return m_handicapped;
} // isHandicapped
// -------------------------------------------------------------------------
/** Updates the animation (moving/shrinking/etc.) */
void PlayerKartWidget::onUpdate(float delta)
@ -582,20 +597,19 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(Widget* w,
if (m_parent_screen->m_multiplayer)
{
int spinner_value = m_player_ident_spinner->getValue();
PlayerProfile* profile = PlayerManager::get()->getPlayer(
m_player_ident_spinner->getValue());
UserConfigParams::m_per_player_difficulty ? spinner_value / 2 : spinner_value);
m_associated_player->setPlayerProfile(profile);
// Add badge for per player difficulty if necessary
m_model_view->unsetBadge(ZIPPER_BADGE);
m_model_view->unsetBadge(ANCHOR_BADGE);
if (!m_parent_screen->m_from_overworld && (m_parent_screen->m_multiplayer || profile->isSingleplayerDifficulty()))
if(UserConfigParams::m_per_player_difficulty && spinner_value % 2 != 0)
{
PerPlayerDifficulty difficulty = profile->getDifficulty();
if (difficulty < PLAYER_DIFFICULTY_NORMAL)
m_model_view->setBadge(ZIPPER_BADGE);
else if (difficulty > PLAYER_DIFFICULTY_NORMAL)
m_model_view->setBadge(ANCHOR_BADGE);
m_handicapped = true;
m_model_view->setBadge(ANCHOR_BADGE);
}
else
{
m_handicapped = false;
m_model_view->unsetBadge(ANCHOR_BADGE);
}
}
}

View File

@ -46,6 +46,8 @@ namespace GUIEngine
{
/** Whether this player confirmed their selection */
bool m_ready;
/** If the player is handicapped. */
bool m_handicapped;
/** widget coordinates */
int player_name_x, player_name_y, player_name_w, player_name_h;
@ -135,6 +137,10 @@ namespace GUIEngine
/** \return Whether this player confirmed his kart and indent selection */
bool isReady();
// ------------------------------------------------------------------------
/** \return Whether this player is handicapped or not */
bool isHandicapped();
// -------------------------------------------------------------------------
/** Updates the animation (moving/shrinking/etc.) */
void onUpdate(float delta);

View File

@ -40,10 +40,10 @@ namespace GUIEngine
PlayerNameSpinner(KartSelectionScreen* parent, const int playerID);
// ------------------------------------------------------------------------
void setID(const int m_playerID);
// ------------------------------------------------------------------------
/** Add a red mark on the spinner to mean "invalid choice" */
void markAsIncorrect();
// ------------------------------------------------------------------------
/** Remove any red mark set with 'markAsIncorrect' */
void markAsCorrect();

View File

@ -68,11 +68,8 @@ std::string PlayerDifficulty::getIdent() const
{
switch(m_difficulty)
{
case PLAYER_DIFFICULTY_EASIEST: return "easiest"; break;
case PLAYER_DIFFICULTY_EASY: return "easy"; break;
case PLAYER_DIFFICULTY_NORMAL: return "normal"; break;
case PLAYER_DIFFICULTY_HARD: return "hard"; break;
case PLAYER_DIFFICULTY_HARDEST: return "hardest"; break;
case PLAYER_DIFFICULTY_NORMAL: return "normal"; break;
case PLAYER_DIFFICULTY_HANDICAP: return "handicap"; break;
default: assert(false);
}
return "";

View File

@ -37,11 +37,8 @@ enum SoccerTeam
/** Game difficulty per player. */
enum PerPlayerDifficulty
{
PLAYER_DIFFICULTY_EASIEST,
PLAYER_DIFFICULTY_EASY,
PLAYER_DIFFICULTY_NORMAL,
PLAYER_DIFFICULTY_HARD,
PLAYER_DIFFICULTY_HARDEST,
PLAYER_DIFFICULTY_HANDICAP,
PLAYER_DIFFICULTY_COUNT
};

View File

@ -322,7 +322,8 @@ void RaceManager::startNew(bool from_overworld)
for(unsigned int i=0; i<ai_kart_count; i++)
{
m_kart_status.push_back(KartStatus(m_ai_kart_list[i], i, -1, -1,
init_gp_rank, KT_AI, PLAYER_DIFFICULTY_NORMAL));
init_gp_rank, KT_AI, UserConfigParams::m_ai_handicap ?
PLAYER_DIFFICULTY_HANDICAP : PLAYER_DIFFICULTY_NORMAL));
init_gp_rank ++;
if(UserConfigParams::m_ftl_debug)
{

View File

@ -511,17 +511,6 @@ bool KartSelectionScreen::joinPlayer(InputDevice* device, bool first_player)
newPlayerWidget->add();
// Add badge for per player difficulty if necessary
if (!m_from_overworld && (m_multiplayer || profile_to_use->isSingleplayerDifficulty()))
{
PerPlayerDifficulty difficulty = profile_to_use->getDifficulty();
Log::info("From overworld", "%d", difficulty);
if (difficulty < PLAYER_DIFFICULTY_NORMAL)
m_kart_widgets[new_player_id].m_model_view->setBadge(ZIPPER_BADGE);
else if (difficulty > PLAYER_DIFFICULTY_NORMAL)
m_kart_widgets[new_player_id].m_model_view->setBadge(ANCHOR_BADGE);
}
// ---- Divide screen space among all karts
const int amount = m_kart_widgets.size();
Widget* fullarea = getWidget("playerskarts");
@ -1196,8 +1185,9 @@ void KartSelectionScreen::allPlayersDone()
race_manager->setLocalKartInfo(n, selected_kart);
// Set per player difficulty if needed
const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(n);
if (!m_from_overworld && (m_multiplayer || profile->isSingleplayerDifficulty()))
race_manager->setPlayerDifficulty(n, profile->getDifficulty());
if (m_multiplayer && UserConfigParams::m_per_player_difficulty &&
m_kart_widgets[n].isHandicapped())
race_manager->setPlayerDifficulty(n, PLAYER_DIFFICULTY_HANDICAP);
}
// ---- Switch to assign mode
@ -1246,10 +1236,11 @@ bool KartSelectionScreen::validateIdentChoices()
// verify internal consistency in debug mode
if (m_multiplayer)
{
int spinner_value = m_kart_widgets[n].m_player_ident_spinner->getValue();
if (UserConfigParams::m_per_player_difficulty)
spinner_value /= 2;
assert(m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
PlayerManager::get()->getPlayer(m_kart_widgets[n]
.m_player_ident_spinner->getValue())
);
PlayerManager::get()->getPlayer(spinner_value));
}
}
}

View File

@ -130,6 +130,12 @@ void OptionsScreenUI::init()
assert( news != NULL );
news->setState( UserConfigParams::m_internet_status
==RequestManager::IPERM_ALLOWED );
CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty");
assert( difficulty != NULL );
difficulty->setState( UserConfigParams::m_per_player_difficulty );
CheckBoxWidget* ai_handicap = getWidget<CheckBoxWidget>("aiHandicap");
assert( ai_handicap != NULL );
ai_handicap->setState( UserConfigParams::m_ai_handicap );
CheckBoxWidget* show_login = getWidget<CheckBoxWidget>("show-login");
assert( show_login!= NULL );
@ -260,6 +266,18 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
assert( show_login != NULL );
UserConfigParams::m_always_show_login_screen = show_login->getState();
}
else if (name=="perPlayerDifficulty")
{
CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty");
assert( difficulty != NULL );
UserConfigParams::m_per_player_difficulty = difficulty->getState();
}
else if (name=="aiHandicap")
{
CheckBoxWidget* ai_handicap = getWidget<CheckBoxWidget>("aiHandicap");
assert( ai_handicap != NULL );
UserConfigParams::m_ai_handicap = ai_handicap->getState();
}
else if (name == "language")
{
ListWidget* list_widget = getWidget<ListWidget>("language");