Skip to content

Commit

Permalink
Files are removed from the recent game files list if they do not exis…
Browse files Browse the repository at this point in the history
…t anymore.
  • Loading branch information
Gohla committed Jul 25, 2011
1 parent 579d8c7 commit 84ed96f
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions QtOgreEditor/source/UI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,15 @@ void MainWindow::_saveGame( const QString& rFile )

EditorGlobals::mCurrentGame = rFile;

// Update latest path
// Update recent games and latest path.
QSettings settings( "Diversia", "QtOgreEditor" );
QStringList games = settings.value( "RecentGames" ).toStringList();
games.removeAll( rFile );
games.prepend( rFile );
while( games.size() > cMaxRecentGames ) games.removeLast();
settings.setValue( "RecentGames", games );
settings.setValue( "LastGame", QString( Path( rFile.toAscii().constData() ).directory_string().c_str() ) );
MainWindow::updateRecentGames();
}
catch( Exception e )
{
Expand Down Expand Up @@ -633,14 +639,25 @@ void MainWindow::updateRecentGames()

int numRecentGames = qMin( games.size(), (int)cMaxRecentGames );

// Filter game files that do not exist.
QStringList newGames;
for( int i = 0; i < numRecentGames; ++i )
{
if( boost::filesystem::exists( games[i].toAscii().constData() ) )
newGames.push_back( QString( games[i] ) );
}
games = newGames;
settings.setValue( "RecentGames", games );
numRecentGames = qMin( games.size(), (int)cMaxRecentGames );

// Show and hide actions.
for( int i = 0; i < numRecentGames; ++i )
{
QString text = tr( "&%1 %2" ).arg( i + 1 ).arg( strippedName( games[i] ) );
mRecentGameActions[i]->setText( text );
mRecentGameActions[i]->setData( games[i] );
mRecentGameActions[i]->setVisible( true );
}

for( int i = numRecentGames; i < cMaxRecentGames; ++i )
mRecentGameActions[i]->setVisible( false );

Expand Down

0 comments on commit 84ed96f

Please sign in to comment.