...
 
Commits (5)
......@@ -125,7 +125,7 @@ EMessageBoxReturn gtk_MessageBox( ui::Window parentWindow, const char* text, con
}
{
auto button = create_modal_dialog_button( "OK", cancel_button );
auto button = create_modal_dialog_button( "Cancel", cancel_button );
hbox.pack_start( button, TRUE, FALSE, 0 );
gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 );
button.show();
......
......@@ -224,22 +224,23 @@ const char* LINK_NAME =
#endif
;
/// brief Returns the filename of the executable belonging to the current process, or 0 if not found.
/// brief Returns the filename of the executable belonging to the current process, or empty string if not found.
char const* getexename( char *buf ){
/* Now read the symbolic link */
int ret = readlink( LINK_NAME, buf, PATH_MAX );
const int ret = readlink( LINK_NAME, buf, PATH_MAX );
if ( ret == -1 ) {
globalOutputStream() << "getexename: falling back to argv[0]: " << makeQuoted( g_argv[0] );
const char* path = realpath( g_argv[0], buf );
if ( path == 0 ) {
if( realpath( g_argv[0], buf ) == 0 ) {
/* In case of an error, leave the handling up to the caller */
return "";
*buf = '\0';
}
}
else {
/* Ensure proper NUL termination */
buf[ret] = 0;
}
/* Ensure proper NUL termination */
buf[ret] = 0;
return buf;
}
......
......@@ -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>() );
}
......@@ -284,8 +285,15 @@ void CGameDialog::GameFileImport( int value ){
if ( ( *iGame )->mGameFile != m_sGameFile ) {
m_sGameFile = ( *iGame )->mGameFile;
PreferencesDialog_restartRequired( "Selected Game" );
// do not trigger radiant restart when switching game on startup using Global Preferences dialog
if ( !onStartup ) {
PreferencesDialog_restartRequired( "Selected Game" );
}
}
// onStartup can only be true once, when Global Preferences are displayed at startup
onStartup = false;
}
void CGameDialog::GameFileExport( const Callback<void(int)> & importCallback ) const {
......@@ -403,9 +411,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 +437,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 +456,19 @@ void CGameDialog::Init(){
}
}
}
if ( m_bGamePrompt || !currentGameDescription ) {
if ( gamePrompt || !currentGameDescription ) {
onStartup = true;
Create();
DoGameDialog();
// use m_nComboSelect to identify the game to run as and set the globals
currentGameDescription = GameDescriptionForComboItem();
ASSERT_NOTNULL( currentGameDescription );
}
else {
onStartup = false;
}
g_pGameDescription = currentGameDescription;
g_pGameDescription->Dump();
......@@ -927,6 +952,7 @@ void PreferencesDialog_showDialog(){
g_restart_required.clear();
if ( ret == ui::alert_response::YES ) {
g_GamesDialog.m_bSkipGamePromptOnce = true;
Radiant_Restart();
}
}
......
......@@ -222,6 +222,11 @@ mutable int m_nComboSelect; ///< intermediate int value for combo in dialog bo
public:
/*!
used to no ask for restart when switching game from Gobal Preferences window displayed on startup
*/
bool onStartup;
/*!
those settings are saved in the global prefs file
I'm too lazy to wrap behind protected access, not sure this needs to be public
......@@ -238,6 +243,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 +264,7 @@ std::list<CGameDescription*> mGames;
CGameDialog() :
m_sGameFile( "" ),
m_bGamePrompt( true ),
m_bSkipGamePromptOnce( false ),
m_bForceLogConsole( false ){
}
virtual ~CGameDialog();
......