Re-added the performance improvements so that the character selection and the track selection screen update the selection only when it has actually changed, without the annoying bugs where parts or the whole screen disappeared.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1740 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -158,9 +158,11 @@ void CharSel::switchCharacter(int n)
|
||||
void CharSel::update(float dt)
|
||||
{
|
||||
m_clock += dt * 40.0f;
|
||||
BaseGUI::update(dt);
|
||||
|
||||
switchCharacter(widget_manager->getSelectedWgt() - WTOK_RACER0);
|
||||
if( widget_manager->selectionChanged() )
|
||||
{
|
||||
switchCharacter(widget_manager->getSelectedWgt() - WTOK_RACER0);
|
||||
}
|
||||
|
||||
if (m_kart != NULL)
|
||||
{
|
||||
@@ -193,6 +195,8 @@ void CharSel::update(float dt)
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
oldContext->makeCurrent();
|
||||
}
|
||||
|
||||
widget_manager->update(dt);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@@ -34,8 +34,6 @@ enum WidgetTokens
|
||||
WTOK_TITLE,
|
||||
|
||||
WTOK_IMG0,
|
||||
WTOK_EMPTY0,
|
||||
WTOK_EMPTY1,
|
||||
WTOK_IMG1,
|
||||
|
||||
WTOK_AUTHOR,
|
||||
@@ -45,33 +43,20 @@ enum WidgetTokens
|
||||
|
||||
TrackSel::TrackSel()
|
||||
{
|
||||
widget_manager->addWgt( WTOK_TITLE, 40, 7);
|
||||
widget_manager->showWgtRect( WTOK_TITLE );
|
||||
widget_manager->setWgtText( WTOK_TITLE, _("Choose a track"));
|
||||
widget_manager->showWgtText( WTOK_TITLE );
|
||||
widget_manager->addTitleWgt( WTOK_TITLE, 40, 7, _("Choose a track") );
|
||||
widget_manager->breakLine();
|
||||
|
||||
widget_manager->addWgt( WidgetManager::WGT_NONE, 100, 2);
|
||||
widget_manager->addWgt( WidgetManager::WGT_NONE, 100, 1);
|
||||
widget_manager->breakLine();
|
||||
|
||||
const bool SHOW_RECT = true;
|
||||
const bool SHOW_TEXT = true;
|
||||
widget_manager->setInitialActivationState(true);
|
||||
widget_manager->setInitialRectState(SHOW_RECT, WGT_AREA_ALL, WGT_TRANS_BLACK);
|
||||
widget_manager->setInitialTextState(SHOW_TEXT, "", WGT_FNT_SML,
|
||||
WGT_FONT_GUI, WGT_WHITE );
|
||||
|
||||
for (unsigned int i = 0; i != track_manager->getTrackCount(); ++i)
|
||||
{
|
||||
// snowtuxpeak must be unlocked
|
||||
const Track *track = track_manager->getTrack(i);
|
||||
bool isAvailable = !unlock_manager->isLocked(track->getIdent());
|
||||
widget_manager->addWgt( WTOK_TRACK0 + i, 40, 6);
|
||||
if(isAvailable)
|
||||
{
|
||||
widget_manager->setWgtText( WTOK_TRACK0 + i, track->getName());
|
||||
}
|
||||
else
|
||||
widget_manager->addTextButtonWgt( WTOK_TRACK0 + i, 40, 6, track->getName());
|
||||
widget_manager->setWgtTextSize( WTOK_TRACK0 + i, WGT_FNT_SML );
|
||||
if(!isAvailable)
|
||||
{
|
||||
widget_manager->setWgtText( WTOK_TRACK0 + i, "???");
|
||||
widget_manager->deactivateWgt(WTOK_TRACK0 + i);
|
||||
@@ -79,31 +64,19 @@ TrackSel::TrackSel()
|
||||
if( i%2 != 0 ) widget_manager->breakLine();
|
||||
else if (i + 1 == track_manager->getTrackCount() )
|
||||
{
|
||||
widget_manager->addWgt( WTOK_EMPTY0, 40, 6 );
|
||||
widget_manager->deactivateWgt( WTOK_EMPTY0 );
|
||||
widget_manager->hideWgtRect( WTOK_EMPTY0 );
|
||||
widget_manager->hideWgtText( WTOK_EMPTY0 );
|
||||
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 40, 6 );
|
||||
widget_manager->breakLine();
|
||||
}
|
||||
}
|
||||
|
||||
widget_manager->setInitialActivationState( false );
|
||||
widget_manager->addWgt(WTOK_IMG0, 35, 35);
|
||||
widget_manager->hideWgtRect( WTOK_IMG0 );
|
||||
widget_manager->hideWgtText(WTOK_IMG0);
|
||||
widget_manager->addEmptyWgt(WTOK_IMG0, 35, 35);
|
||||
|
||||
widget_manager->addWgt( WTOK_EMPTY1, 5, 35 );
|
||||
widget_manager->hideWgtRect( WTOK_EMPTY1 );
|
||||
widget_manager->hideWgtText( WTOK_EMPTY1 );
|
||||
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 5, 35 );
|
||||
|
||||
widget_manager->addWgt(WTOK_IMG1, 35, 35);
|
||||
widget_manager->hideWgtRect( WTOK_IMG1 );
|
||||
widget_manager->hideWgtText(WTOK_IMG1);
|
||||
widget_manager->addEmptyWgt(WTOK_IMG1, 35, 35);
|
||||
widget_manager->breakLine();
|
||||
|
||||
widget_manager->addWgt( WTOK_AUTHOR, 80, 9 );
|
||||
widget_manager->setWgtText( WTOK_AUTHOR, _("No track selected") );
|
||||
widget_manager->setWgtTextSize( WTOK_AUTHOR, WGT_FNT_MED );
|
||||
widget_manager->addTextWgt( WTOK_AUTHOR, 80, 9, _("No track selected") );
|
||||
|
||||
widget_manager->layout(WGT_AREA_TOP);
|
||||
}
|
||||
@@ -118,144 +91,76 @@ TrackSel::~TrackSel()
|
||||
void TrackSel::update(float dt)
|
||||
{
|
||||
const int SELECTED_TRACK = widget_manager->getSelectedWgt() - WTOK_TRACK0;
|
||||
if(SELECTED_TRACK<0 || SELECTED_TRACK>=(int)track_manager->getTrackCount())
|
||||
if( widget_manager->selectionChanged() &&
|
||||
SELECTED_TRACK > 0 &&
|
||||
SELECTED_TRACK < (int)track_manager->getTrackCount() )
|
||||
{
|
||||
BaseGUI::update(dt);
|
||||
return;
|
||||
}
|
||||
const Track* TRACK = track_manager->getTrack( SELECTED_TRACK );
|
||||
const bool FULL_PATH=true;
|
||||
const Track* TRACK = track_manager->getTrack( SELECTED_TRACK );
|
||||
const bool FULL_PATH=true;
|
||||
|
||||
widget_manager->setWgtText( WTOK_AUTHOR, TRACK->getDescription() );
|
||||
widget_manager->setWgtText( WTOK_AUTHOR, TRACK->getDescription() );
|
||||
|
||||
const std::string& screenshot = TRACK->getScreenshotFile();
|
||||
const std::string& topview = TRACK->getTopviewFile();
|
||||
const std::string& screenshot = TRACK->getScreenshotFile();
|
||||
const std::string& topview = TRACK->getTopviewFile();
|
||||
|
||||
if( !screenshot.empty() && !topview.empty() )
|
||||
{
|
||||
const Material *m =material_manager->getMaterial(screenshot, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG0, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG0 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG0, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG0 );
|
||||
if( !screenshot.empty() && !topview.empty() )
|
||||
{
|
||||
const Material *m =material_manager->getMaterial(screenshot, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG0, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG0 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG0, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG0 );
|
||||
|
||||
m = material_manager->getMaterial(topview, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG1, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG1 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG1, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
else if( topview.empty() )
|
||||
{
|
||||
const Material *m = material_manager->getMaterial(screenshot, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG0, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG0 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG0, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG0 );
|
||||
|
||||
widget_manager->hideWgtRect( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->setWgtTrackNum( WTOK_IMG1, SELECTED_TRACK );
|
||||
widget_manager->showWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
else if( screenshot.empty() )
|
||||
{
|
||||
widget_manager->hideWgtRect( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->setWgtTrackNum( WTOK_IMG0, SELECTED_TRACK );
|
||||
widget_manager->showWgtTrack( WTOK_IMG0 );
|
||||
|
||||
Material *m = material_manager->getMaterial(topview, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG1, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG1 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG1, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
else //if( screenshot.empty() && topview.empty() )
|
||||
{
|
||||
widget_manager->hideWgtRect( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->setWgtTrackNum( WTOK_IMG0, SELECTED_TRACK );
|
||||
widget_manager->showWgtTrack( WTOK_IMG0 );
|
||||
|
||||
widget_manager->hideWgtRect( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
|
||||
#if 0
|
||||
// draw a track preview of the currently highlighted track menu entry
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
glOrtho(0.0, user_config->m_width, 0.0, user_config->m_height, -1.0, +1.0);
|
||||
if(screenshot.size()==0 && topview.size()==0)
|
||||
{
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
TRACK->drawScaled2D(0.0f, 50.0f, (float)user_config->m_width,
|
||||
(float)(user_config->m_height/3)); // (x, y, w, h)
|
||||
glEnable ( GL_TEXTURE_2D ) ;
|
||||
}
|
||||
else
|
||||
{ // either topview or screenshot specified
|
||||
int xLeft = user_config->m_width/2;
|
||||
int yBottom = 50;
|
||||
int w = user_config->m_width/3;
|
||||
int h = user_config->m_height/3;
|
||||
if(topview.size()==0)
|
||||
{ // no topview, but there is a screenshot!
|
||||
glDisable ( GL_TEXTURE_2D ) ;
|
||||
TRACK->drawScaled2D((float)xLeft, (float)yBottom, (float)w, (float)h);
|
||||
glEnable ( GL_TEXTURE_2D ) ;
|
||||
m = material_manager->getMaterial(topview, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG1, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG1 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG1, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
else
|
||||
{ // topview is defined
|
||||
Material *m=material_manager->getMaterial(topview);
|
||||
m->apply();
|
||||
glBegin(GL_QUADS) ;
|
||||
glColor4f(1, 1, 1, 1 );
|
||||
glTexCoord2f(0, 0); glVertex2i( xLeft, yBottom );
|
||||
glTexCoord2f(1, 0); glVertex2i( xLeft+w, yBottom );
|
||||
glTexCoord2f(1, 1); glVertex2i( xLeft+w, yBottom+h);
|
||||
glTexCoord2f(0, 1); glVertex2i( xLeft, yBottom+h);
|
||||
glEnd () ;
|
||||
else if( topview.empty() )
|
||||
{
|
||||
const Material *m = material_manager->getMaterial(screenshot, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG0, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG0 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG0, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG0 );
|
||||
|
||||
} // topview is defined
|
||||
Material *m=material_manager->getMaterial(screenshot);
|
||||
xLeft = xLeft - w - 10;
|
||||
m->apply();
|
||||
glBegin(GL_QUADS) ;
|
||||
glColor4f(1, 1, 1, 1 );
|
||||
glTexCoord2f(0, 0); glVertex2i( xLeft, yBottom );
|
||||
glTexCoord2f(1, 0); glVertex2i( xLeft+w, yBottom );
|
||||
glTexCoord2f(1, 1); glVertex2i( xLeft+w, yBottom+h);
|
||||
glTexCoord2f(0, 1); glVertex2i( xLeft, yBottom+h);
|
||||
glEnd () ;
|
||||
} // either topview or screenshot specified
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glEnable(GL_BLEND);
|
||||
widget_manager->hideWgtRect( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->setWgtTrackNum( WTOK_IMG1, SELECTED_TRACK );
|
||||
widget_manager->showWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
else if( screenshot.empty() )
|
||||
{
|
||||
widget_manager->hideWgtRect( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->setWgtTrackNum( WTOK_IMG0, SELECTED_TRACK );
|
||||
widget_manager->showWgtTrack( WTOK_IMG0 );
|
||||
|
||||
glPushMatrix();
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
const GLfloat backgroundColour[4] = { 0.3f, 0.3f, 0.3f, 0.5f };
|
||||
glColor4fv(backgroundColour);
|
||||
glPopMatrix();
|
||||
glDisable(GL_BLEND);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPopMatrix();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
#endif
|
||||
Material *m = material_manager->getMaterial(topview, FULL_PATH);
|
||||
widget_manager->setWgtColor( WTOK_IMG1, WGT_WHITE);
|
||||
widget_manager->showWgtRect( WTOK_IMG1 );
|
||||
widget_manager->setWgtTexture( WTOK_IMG1, m->getState()->getTextureHandle() );
|
||||
widget_manager->showWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
else //if( screenshot.empty() && topview.empty() )
|
||||
{
|
||||
widget_manager->hideWgtRect( WTOK_IMG0 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG0 );
|
||||
widget_manager->setWgtTrackNum( WTOK_IMG0, SELECTED_TRACK );
|
||||
widget_manager->showWgtTrack( WTOK_IMG0 );
|
||||
|
||||
//Keep the BaseGUI::update() call at the bottom of the function, otherwise
|
||||
//the screen will be drawn once without being fully prepared, and this is
|
||||
//noticeable sometimes.
|
||||
BaseGUI::update(dt);
|
||||
widget_manager->hideWgtRect( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTexture( WTOK_IMG1 );
|
||||
widget_manager->hideWgtTrack( WTOK_IMG1 );
|
||||
}
|
||||
}
|
||||
|
||||
widget_manager->update(dt);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user