]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
do not prompt for game when restarting after switching game, <3 @Garux
authorThomas Debesse <dev@illwieckz.net>
Thu, 5 Sep 2019 21:23:10 +0000 (23:23 +0200)
committerThomas Debesse <dev@illwieckz.net>
Thu, 5 Sep 2019 21:29:23 +0000 (23:29 +0200)
radiant/preferences.cpp
radiant/preferences.h

index 659308aee02766f0b31d2a9036a6f57974dea299..732a7401338fef4210f98d240deff67d22efc338 100644 (file)
@@ -231,6 +231,7 @@ struct LogConsole {
 void RegisterGlobalPreferences( PreferenceSystem& preferences ){
        preferences.registerPreference( "gamefile", make_property_string( g_GamesDialog.m_sGameFile ) );
        preferences.registerPreference( "gamePrompt", make_property_string( g_GamesDialog.m_bGamePrompt ) );
+       preferences.registerPreference( "skipGamePromptOnce", make_property_string( g_GamesDialog.m_bSkipGamePromptOnce ) );
        preferences.registerPreference( "log console", make_property_string<LogConsole>() );
 }
 
@@ -403,9 +404,12 @@ void CGameDialog::Reset(){
 }
 
 void CGameDialog::Init(){
+       bool gamePrompt = false;
+
        InitGlobalPrefPath();
        LoadPrefs();
        ScanForGames();
+
        if ( mGames.empty() ) {
                Error( "Didn't find any valid game file descriptions, aborting\n" );
        }
@@ -426,7 +430,15 @@ void CGameDialog::Init(){
 
        CGameDescription* currentGameDescription = 0;
 
-       if ( !m_bGamePrompt ) {
+       // m_bSkipGamePromptOnce is used to not prompt for game on restart, only on fresh startup
+       if ( m_bGamePrompt && !m_bSkipGamePromptOnce ) {
+               gamePrompt = true;
+       }
+
+       m_bSkipGamePromptOnce = false;
+       g_GamesDialog.SavePrefs();
+
+       if ( !gamePrompt ) {
                // search by .game name
                std::list<CGameDescription *>::iterator iGame;
                for ( iGame = mGames.begin(); iGame != mGames.end(); ++iGame )
@@ -437,13 +449,15 @@ void CGameDialog::Init(){
                        }
                }
        }
-       if ( m_bGamePrompt || !currentGameDescription ) {
+
+       if ( gamePrompt || !currentGameDescription ) {
                Create();
                DoGameDialog();
                // use m_nComboSelect to identify the game to run as and set the globals
                currentGameDescription = GameDescriptionForComboItem();
                ASSERT_NOTNULL( currentGameDescription );
        }
+
        g_pGameDescription = currentGameDescription;
 
        g_pGameDescription->Dump();
@@ -927,6 +941,7 @@ void PreferencesDialog_showDialog(){
                        g_restart_required.clear();
 
                        if ( ret == ui::alert_response::YES ) {
+                               g_GamesDialog.m_bSkipGamePromptOnce = true;
                                Radiant_Restart();
                        }
                }
index 59dd60daaa0c6e42633932892511d91fa594429c..f2c47c03c1fd2e186572351891e910473489f0fd 100644 (file)
@@ -238,6 +238,12 @@ CopiedString m_sGameFile;
    prompt which game to load on startup
  */
 bool m_bGamePrompt;
+/*!
+   when if m_bGamePrompt is true
+   do not prompt at startup which game to load this time, but prompt the next times
+   this is used to not uselessly prompt game after having restarted because user switched game
+ */
+bool m_bSkipGamePromptOnce;
 /*!
    log console to radiant.log
    m_bForceLogConsole is an obscure forced latching situation
@@ -253,6 +259,7 @@ std::list<CGameDescription*> mGames;
 CGameDialog() :
        m_sGameFile( "" ),
        m_bGamePrompt( true ),
+       m_bSkipGamePromptOnce( false ),
        m_bForceLogConsole( false ){
 }
 virtual ~CGameDialog();