Merge branch 'properties'
This commit is contained in:
commit
235800a119
@ -389,7 +389,7 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
m_default_kart_properties->getAllData(node);
|
||||
const XMLNode *types = node->getNode("kart-type");
|
||||
|
||||
for (int i = 0; i < types->getNumNodes(); ++i)
|
||||
for (unsigned int i = 0; i < types->getNumNodes(); ++i)
|
||||
{
|
||||
const XMLNode* type = types->getNode(i);
|
||||
m_kart_properties[type->getName()] = new KartProperties();
|
||||
|
@ -95,14 +95,14 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
|
||||
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_ACCEL]->setValue((int)((props->getMaxSpeed()-20)*20));
|
||||
m_skills[SKILL_ACCEL]->setLabel("ACCEL");
|
||||
m_skills[SKILL_ACCEL]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_accel", m_player_id);
|
||||
|
||||
m_skills[SKILL_SPEED]->setValue((int)(props->getMaxPower()/10));
|
||||
m_skills[SKILL_SPEED]->setLabel("POWER");
|
||||
m_skills[SKILL_SPEED]->setValue((int)((props->getAbsMaxSpeed()-20)*20));
|
||||
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()));
|
||||
m_skills[SKILL_POWER]->setLabel("POWER");
|
||||
m_skills[SKILL_POWER]->m_properties[PROP_ID] = StringUtils::insertValues("@p%i_power", m_player_id);
|
||||
|
||||
} // KartStatsWidget
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -63,7 +63,7 @@ class KartStatsWidget : public Widget
|
||||
{
|
||||
SKILL_MASS,
|
||||
SKILL_SPEED,
|
||||
SKILL_ACCEL,
|
||||
SKILL_POWER,
|
||||
SKILL_COUNT
|
||||
};
|
||||
|
||||
|
@ -780,4 +780,16 @@ float KartProperties::getStartupBoost() const
|
||||
}
|
||||
return 0;
|
||||
} // getStartupBoost
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
const float KartProperties::getAvgPower() const
|
||||
{
|
||||
float sum = 0.0;
|
||||
for (unsigned int i = 0; i < m_gear_power_increase.size(); ++i)
|
||||
{
|
||||
sum += m_gear_power_increase[i]*m_max_speed[0];
|
||||
}
|
||||
return sum/m_gear_power_increase.size();
|
||||
} // getAvgPower
|
||||
|
||||
/* EOF */
|
||||
|
@ -546,7 +546,10 @@ public:
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns parameters for the speed-weighted objects */
|
||||
const SpeedWeightedObject::Properties& getSpeedWeightedObjectProperties() const {return m_speed_weighted_object_properties;}
|
||||
const SpeedWeightedObject::Properties& getSpeedWeightedObjectProperties() const
|
||||
{
|
||||
return m_speed_weighted_object_properties;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the wheel base (distance front to rear axis). */
|
||||
@ -571,8 +574,17 @@ public:
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the maximum speed dependent on the difficult level. */
|
||||
float getMaxSpeed () const {return
|
||||
m_max_speed[race_manager->getDifficulty()];}
|
||||
float getMaxSpeed () const
|
||||
{
|
||||
return m_max_speed[race_manager->getDifficulty()];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the absolute maximum speed, independent on the difficulty. */
|
||||
float getAbsMaxSpeed () const
|
||||
{
|
||||
return m_max_speed[m_max_speed.size()-1];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the nitro consumption. */
|
||||
@ -829,6 +841,10 @@ public:
|
||||
const std::vector<float>&
|
||||
getGearPowerIncrease () const {return m_gear_power_increase; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the average power of the kart (in all gears). */
|
||||
const float getAvgPower () const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns distance between kart and camera. */
|
||||
float getCameraDistance () const {return m_camera_distance; }
|
||||
|
@ -1527,8 +1527,8 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
|
||||
if (kp != NULL)
|
||||
{
|
||||
w->setValue(KartStatsWidget::SKILL_MASS, (int)(kp->getMass()/5));
|
||||
w->setValue(KartStatsWidget::SKILL_SPEED, (int)(kp->getMaxPower()/10));
|
||||
w->setValue(KartStatsWidget::SKILL_ACCEL, (int)((kp->getMaxSpeed()-20)*20));
|
||||
w->setValue(KartStatsWidget::SKILL_SPEED, (int)((kp->getAbsMaxSpeed()-20)*9));
|
||||
w->setValue(KartStatsWidget::SKILL_POWER, (int)(kp->getAvgPower()));
|
||||
w->update(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user