X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fpreferences.cpp;h=7372a74a0adc30167b185f54f9a0b745cdef52ce;hb=89f86ebc45c0f0375d55b4c56bf95dca6891426f;hp=8aaa30b59e720646f00aadfeda890eacb33e402c;hpb=f100a82117cc13e8a646e39349865cd35d54b891;p=xonotic%2Fnetradiant.git diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 8aaa30b5..7372a74a 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -348,6 +348,30 @@ ui::Window CGameDialog::BuildDialog(){ return create_simple_modal_dialog_window( "Global Preferences", m_modal, frame ); } +static void StringReplace( std::string& input, const std::string& first, const std::string& second ) +{ + size_t found = 0; + while ( ( found = input.find(first, found) ) != std::string::npos ) + { + input.replace( found, first.length(), second ); + } +} + +// FIXME, for some unknown reason it sorts “Quake 3” after “Quake 4”. +static bool CompareGameName( CGameDescription *first, CGameDescription *second ) +{ + std::string string1( first->getRequiredKeyValue( "name" ) ); + std::string string2( second->getRequiredKeyValue( "name" ) ); + + // HACK: Replace some roman numerals. + StringReplace( string1, " III", " 3" ); + StringReplace( string2, " III", " 3" ); + StringReplace( string1, " II", " 2" ); + StringReplace( string2, " II", " 2" ); + + return string1 < string2; +} + void CGameDialog::ScanForGames(){ StringOutputStream strGamesPath( 256 ); strGamesPath << DataPath_get() << "gamepacks/games/"; @@ -379,6 +403,8 @@ void CGameDialog::ScanForGames(){ } else { globalErrorStream() << "XML parser failed on '" << strPath.c_str() << "'\n"; } + + mGames.sort(CompareGameName); }); }