void ImgViewer::goToPic(int whichPic) { assert(whichPic >= 0 && whichPic < size); enableAllButtons(); currPixIndex = whichPic; // This will not ImgViewer correctly in case size==1 // Correct prev/next img buttons if(currPixIndex == 0) { ui->prevBut->setEnabled(false); } else if(currPixIndex == size-1) { ui->nextBut->setEnabled(false); } newPic(currPixIndex); ui->slider->setValue(currPixIndex); }
/** Render all global parts of the race gui, i.e. things that are only * displayed once even in splitscreen. * \param dt Timestep sized. */ void RaceResultGUI::renderGlobal(float dt) { m_timer += dt; World *world = World::getWorld(); assert(world->getPhase()==WorldStatus::RESULT_DISPLAY_PHASE); unsigned int num_karts = m_all_row_infos.size(); // First: Update the finite state machine // ====================================== switch(m_animation_state) { case RR_INIT: for(unsigned int i=0; i<num_karts; i++) { RowInfo *ri = &(m_all_row_infos[i]); ri->m_start_at = m_time_between_rows * i; ri->m_x_pos = (float)UserConfigParams::m_width; ri->m_y_pos = (float)(m_top+i*m_distance_between_rows); } m_animation_state = RR_RACE_RESULT; break; case RR_RACE_RESULT: if(m_timer > m_time_overall_scroll) { // Make sure that all lines are aligned to the left // (in case that the animation was skipped). for(unsigned int i=0; i<num_karts; i++) { RowInfo *ri = &(m_all_row_infos[i]); ri->m_x_pos = (float)m_leftmost_column; } if(race_manager->getMajorMode()!=RaceManager::MAJOR_MODE_GRAND_PRIX) { m_animation_state = RR_WAIT_TILL_END; enableAllButtons(); break; } determineGPLayout(); m_animation_state = RR_OLD_GP_RESULTS; m_timer = 0; } break; case RR_OLD_GP_RESULTS: if(m_timer > m_time_overall_scroll) { m_animation_state = RR_INCREASE_POINTS; m_timer = 0; for(unsigned int i=0; i<num_karts; i++) { RowInfo *ri = &(m_all_row_infos[i]); ri->m_x_pos = (float)m_leftmost_column; } } break; case RR_INCREASE_POINTS: // Have one second delay before the resorting starts. if(m_timer > 1+m_time_for_points) { m_animation_state = RR_RESORT_TABLE; if(m_gp_position_was_changed) m_timer = 0; else // This causes the phase to go to RESORT_TABLE once, and then // immediately wait till end. This has the advantage that any // phase change settings will be processed properly. m_timer = m_time_rotation+1; // Make the new row permanent; necessary in case // that the animation is skipped. for(unsigned int i=0; i<num_karts; i++) { RowInfo *ri = &(m_all_row_infos[i]); ri->m_new_points = 0; ri->m_current_displayed_points = (float)ri->m_new_overall_points; } } break; case RR_RESORT_TABLE: if(m_timer > m_time_rotation) { m_animation_state = RR_WAIT_TILL_END; // Make the new row permanent. for(unsigned int i=0; i<num_karts; i++) { RowInfo *ri = &(m_all_row_infos[i]); ri->m_y_pos = ri->m_centre_point - ri->m_radius; } enableAllButtons(); } break; case RR_WAIT_TILL_END: break; } // switch // Second phase: update X and Y positions for the various animations // ================================================================= float v = 0.9f*UserConfigParams::m_width/m_time_single_scroll; for(unsigned int i=0; i<m_all_row_infos.size(); i++) { RowInfo *ri = &(m_all_row_infos[i]); float x = ri->m_x_pos; float y = ri->m_y_pos; switch(m_animation_state) { // Both states use the same scrolling: case RR_INIT: break; // Remove compiler warning case RR_RACE_RESULT: case RR_OLD_GP_RESULTS: if(m_timer > ri->m_start_at) { // if active ri->m_x_pos -= dt*v; if(ri->m_x_pos<m_leftmost_column) ri->m_x_pos = (float)m_leftmost_column; x = ri->m_x_pos; } break; case RR_INCREASE_POINTS: ri->m_current_displayed_points += dt*race_manager->getPositionScore(1)/m_time_for_points; if(ri->m_current_displayed_points>ri->m_new_overall_points) ri->m_current_displayed_points = (float)ri->m_new_overall_points; ri->m_new_points -= dt*race_manager->getPositionScore(1)/m_time_for_points; if(ri->m_new_points<0) ri->m_new_points = 0; break; case RR_RESORT_TABLE: x = ri->m_x_pos -ri->m_radius*sin(m_timer/m_time_rotation*M_PI); y = ri->m_centre_point+ri->m_radius*cos(m_timer/m_time_rotation*M_PI); break; case RR_WAIT_TILL_END: break; } // switch displayOneEntry((unsigned int)x, (unsigned int)y, i, true); } // for i } // renderGlobal