Fix for sometimes disappearing skill bar
This commit is contained in:
@@ -40,10 +40,20 @@ using namespace irr;
|
||||
KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
|
||||
std::string kart_group) : Widget(WTYPE_DIV)
|
||||
{
|
||||
|
||||
x_speed = 1.0f;
|
||||
y_speed = 1.0f;
|
||||
w_speed = 1.0f;
|
||||
h_speed = 1.0f;
|
||||
|
||||
m_player_id = player_id;
|
||||
|
||||
setSize(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
|
||||
area.getWidth(), area.getHeight() );
|
||||
target_x = m_x;
|
||||
target_y = m_y;
|
||||
target_w = m_w;
|
||||
target_h = m_h;
|
||||
|
||||
// ---- Mass skill level widget
|
||||
m_mass_bar = NULL;
|
||||
@@ -102,7 +112,7 @@ void KartStatsWidget::add()
|
||||
/** Updates the animation (moving/shrinking/etc.) */
|
||||
void KartStatsWidget::onUpdate(float delta)
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
m_mass_bar->setValue(m_mass_value);
|
||||
if (target_x == m_x && target_y == m_y &&
|
||||
target_w == m_w && target_h == m_h) return;
|
||||
|
||||
@@ -178,7 +188,6 @@ void KartStatsWidget::onUpdate(float delta)
|
||||
|
||||
void KartStatsWidget::setSize(const int x, const int y, const int w, const int h)
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
m_x = x;
|
||||
m_y = y;
|
||||
m_w = w;
|
||||
|
||||
@@ -238,8 +238,8 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
|
||||
// area for the stats widget
|
||||
core::recti statsArea(m_kart_stats_x,
|
||||
m_kart_stats_y,
|
||||
m_kart_stats_w,
|
||||
m_kart_stats_h);
|
||||
m_kart_stats_x+m_kart_stats_w,
|
||||
m_kart_stats_y+m_kart_stats_h);
|
||||
|
||||
//m_kart_stats = new ProgressBarWidget(false);
|
||||
m_kart_stats = new GUIEngine::KartStatsWidget(statsArea, player_id, kart_group);
|
||||
@@ -802,6 +802,18 @@ void PlayerKartWidget::setSize(const int x, const int y, const int w, const int
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
void PlayerKartWidget::setKartStats(const std::string& selection)
|
||||
{
|
||||
assert(m_magic_number == 0x33445566);
|
||||
const KartProperties *kp =
|
||||
kart_properties_manager->getKart(selection);
|
||||
if (kp != NULL)
|
||||
{
|
||||
m_kart_stats->setMass((int)kp->getMass()/10);
|
||||
//TODO add other stats
|
||||
}
|
||||
}
|
||||
|
||||
/** Sets which kart was selected for this player */
|
||||
void PlayerKartWidget::setKartInternalName(const std::string& whichKart)
|
||||
{
|
||||
@@ -879,7 +891,7 @@ void KartHoverListener::onSelectionChanged(DynamicRibbonWidget* theWidget,
|
||||
}
|
||||
|
||||
m_parent->updateKartWidgetModel(playerID, selectionID, selectionText);
|
||||
|
||||
m_parent->m_kart_widgets[playerID].setKartStats(selectionID);
|
||||
m_parent->m_kart_widgets[playerID].setKartInternalName(selectionID);
|
||||
m_parent->validateKartChoices();
|
||||
} // onSelectionChanged
|
||||
|
||||
@@ -342,6 +342,11 @@ public:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** Set the kart stats for this player */
|
||||
void setKartStats(const std::string& selection);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/** Sets which kart was selected for this player */
|
||||
void setKartInternalName(const std::string& whichKart);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user