X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fmainframe.cpp;h=8a7691af94b0d16d92cd740429f47d90e6b2c832;hb=6895cb108b8158507bd55d372ab60ca702b8afdc;hp=d3e869000efabaea592091d880bedcc05708add4;hpb=5887d2c065503465a3c6ef422b0055b4ace485bd;p=xonotic%2Fnetradiant.git diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index d3e86900..8a7691af 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -101,6 +101,12 @@ #include "referencecache.h" #include "texwindow.h" +#if GDEF_OS_WINDOWS +#include +#else +#include +#endif + #ifdef WORKAROUND_WINDOWS_GTK2_GLWIDGET /* workaround for gtk 2.24 issue: not displayed glwidget after toggle */ #define WORKAROUND_GOBJECT_SET_GLWIDGET(window, widget) g_object_set_data( G_OBJECT( window ), "glwidget", G_OBJECT( widget ) ) @@ -810,7 +816,7 @@ void Radiant_Shutdown(){ } void Exit(){ - if ( ConfirmModified( "Exit Radiant" ) ) { + if ( ConfirmModified( "Exit " RADIANT_NAME ) ) { gtk_main_quit(); } } @@ -2929,7 +2935,7 @@ WindowPositionTracker g_posXZWnd; WindowPositionTracker g_posYZWnd; static gint mainframe_delete( ui::Widget widget, GdkEvent *event, gpointer data ){ - if ( ConfirmModified( "Exit Radiant" ) ) { + if ( ConfirmModified( "Exit " RADIANT_NAME ) ) { gtk_main_quit(); } @@ -3616,3 +3622,44 @@ void GLWindow_Construct(){ void GLWindow_Destroy(){ } + +void Radiant_Restart(){ + // preferences are expected to be already saved in any way + // this is just to be sure and be future proof + Preferences_Save(); + + // this asks user for saving if map is modified + // user can chose to not save, it's ok + ConfirmModified( "Restart " RADIANT_NAME ); + + int status; + + char *argv[ 3 ]; + char exe_file[ 256 ]; + char map_file[ 256 ]; + bool with_map = false; + + strncpy( exe_file, g_strAppFilePath.c_str(), 256 ); + + if ( !Map_Unnamed( g_map ) ) { + strncpy( map_file, Map_Name( g_map ), 256 ); + with_map = true; + } + + argv[ 0 ] = exe_file; + argv[ 1 ] = with_map ? map_file : NULL; + argv[ 2 ] = NULL; + +#if GDEF_OS_WINDOWS + status = !_spawnvpe( P_NOWAIT, exe_file, argv, environ ); +#else + pid_t pid; + + status = posix_spawn( &pid, exe_file, NULL, NULL, argv, environ ); +#endif + + // quit if radiant successfully started + if ( status == 0 ) { + gtk_main_quit(); + } +}