Some nice optimization update to the rating widget. The calculation of the stars was quite weird?
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13426 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
366ae7009d
commit
bf5eccf4ed
@ -70,8 +70,6 @@ int RatingBarWidget::getStepsOfStar(int index)
|
||||
|
||||
void RatingBarWidget::setStepValues(float float_rating)
|
||||
{
|
||||
float step_size = 1 / (float)(m_steps - 1);
|
||||
|
||||
for (int star = 0; star < m_stars; star++)
|
||||
{
|
||||
if (float_rating < star)
|
||||
@ -80,14 +78,7 @@ void RatingBarWidget::setStepValues(float float_rating)
|
||||
m_star_values[star] = m_steps-1;
|
||||
else
|
||||
{
|
||||
for (int step = 0; step < m_steps; step++)
|
||||
{
|
||||
if (float_rating > star + step_size * (step - 0.5) && float_rating < star + step_size * (step + 0.5))
|
||||
{
|
||||
m_star_values[star] = step;
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_star_values[star] = round((float_rating * (m_steps-1)) - (star*(m_steps-1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -108,8 +99,9 @@ void RatingBarWidget::setStepValuesByMouse(const core::position2di & mouse_posit
|
||||
if(stars_rect.isPointInside(mouse_position))
|
||||
{
|
||||
m_hovering = true;
|
||||
m_hover_rating = (float)(mouse_position.X - stars_rect.UpperLeftCorner.X) / (float)stars_rect.getWidth() * (float)m_stars;
|
||||
setStepValues(m_hover_rating );
|
||||
float exact_hover = (float)(mouse_position.X - stars_rect.UpperLeftCorner.X) / (float)stars_rect.getWidth() * (float)m_stars;
|
||||
m_hover_rating = round(exact_hover * (m_steps-1)) / (m_steps-1);
|
||||
setStepValues(m_hover_rating);
|
||||
}
|
||||
else if(m_hovering)
|
||||
{
|
||||
|
@ -147,12 +147,6 @@ namespace Online{
|
||||
UserConfigParams::m_saved_token = getToken();
|
||||
UserConfigParams::m_saved_session = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
UserConfigParams::m_saved_user = 0;
|
||||
UserConfigParams::m_saved_token = "";
|
||||
UserConfigParams::m_saved_session = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
setUserState (US_SIGNED_OUT);
|
||||
|
Loading…
Reference in New Issue
Block a user