Make presentation of kart characteristics uniform and indepdendent of difficulty. Fixes #2684, fixes #2539

This commit is contained in:
auria.mg 2016-12-11 20:16:44 -05:00
parent aaecd58fc0
commit ab7ded308a
4 changed files with 45 additions and 25 deletions

View File

@ -80,23 +80,7 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
m_children.push_back(skill_bar);
}
// Scale the values so they look better
// The scaling factor and offset were found by trial and error.
// It should look nice and you should be able to see the difference between
// different masses or velocities.
m_skills[SKILL_MASS]->setValue((int)
((props->getCombinedCharacteristic()->getMass() - 20) / 4));
m_skills[SKILL_MASS]->setLabel(_("WEIGHT"));
m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id);
m_skills[SKILL_SPEED]->setValue((int)
((props->getCombinedCharacteristic()->getEngineMaxSpeed() - 15) * 6));
m_skills[SKILL_SPEED]->setLabel(_("SPEED"));
m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id);
m_skills[SKILL_POWER]->setValue((int) ((props->getAvgPower() - 30) / 20));
m_skills[SKILL_POWER]->setLabel(_("POWER"));
m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id);
setValues(props);
move(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
area.getWidth(), area.getHeight());
@ -104,6 +88,42 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
// -----------------------------------------------------------------------------
void KartStatsWidget::setValues(const KartProperties* props)
{
// Use kart properties computed for "hard" difficulty to show the user, so
// that properties don't change according to the the last used difficulty
// (And because this code uses arbitrary scaling factors to make them look
// nice and the arbitrary factors were optimised for hard difficulty)
RaceManager::Difficulty previous_difficulty = race_manager->getDifficulty();
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
//KartProperties* kp_computed = new KartProperties();
KartProperties kp_computed;
kp_computed.copyForPlayer(props);
// Scale the values so they look better
// The scaling factor and offset were found by trial and error.
// It should look nice and you should be able to see the difference between
// different masses or velocities.
m_skills[SKILL_MASS]->setValue((int)
((kp_computed.getCombinedCharacteristic()->getMass() - 20) / 4));
m_skills[SKILL_MASS]->setLabel(_("WEIGHT"));
m_skills[SKILL_MASS]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_mass", m_player_id);
m_skills[SKILL_SPEED]->setValue((int)
((kp_computed.getCombinedCharacteristic()->getEngineMaxSpeed() - 15) * 6));
m_skills[SKILL_SPEED]->setLabel(_("SPEED"));
m_skills[SKILL_SPEED]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_speed", m_player_id);
m_skills[SKILL_POWER]->setValue((int)((kp_computed.getAvgPower() - 30) / 20));
m_skills[SKILL_POWER]->setLabel(_("POWER"));
m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id);
race_manager->setDifficulty(previous_difficulty);
}
// -----------------------------------------------------------------------------
void KartStatsWidget::add()
{
for (int i = 0; i < SKILL_COUNT; ++i) {

View File

@ -30,6 +30,7 @@
#include "guiengine/widgets/progress_bar_widget.hpp"
#include "guiengine/widgets/skill_level_widget.hpp"
class KartProperties;
namespace GUIEngine
{
@ -91,6 +92,8 @@ namespace GUIEngine
* inside itself */
void setSize(const int x, const int y, const int w, const int h);
void setValues(const KartProperties* props);
/** Change the value of the widget, it must be a percent. */
void setValue(Stats type, int value);

View File

@ -544,7 +544,9 @@ public:
float getSkidReduceTurnMax() const;
bool getSkidEnabled() const;
/* <characteristics-end kpdefs> */
/* <characteristics-end kpdefs> */
LEAK_CHECK()
}; // KartProperties
#endif

View File

@ -809,15 +809,10 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
const KartProperties *kp =
kart_properties_manager->getKart(selection);
if (kp != NULL)
{
// Scale the values so they look better
w->setValue(KartStatsWidget::SKILL_MASS, (int)
((kp->getCombinedCharacteristic()->getMass() - 20) / 4));
w->setValue(KartStatsWidget::SKILL_SPEED, (int)
((kp->getCombinedCharacteristic()->getEngineMaxSpeed() - 15) * 6));
w->setValue(KartStatsWidget::SKILL_POWER, (int)
((kp->getAvgPower() - 30) / 20));
w->setValues(kp);
w->update(0);
}
}