X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fmain.cpp;h=a2d288f15eff91315e794a5a14f8ed1419ce370a;hb=8c4e2fcb9c77360f0918be91642777f91fc99e53;hp=83dc58f9d0a63616fb2b35c1039576282b2a65fa;hpb=bdf4441b87c8167dc3316a3a761cf9c15208de90;p=xonotic%2Fnetradiant.git diff --git a/radiant/main.cpp b/radiant/main.cpp index 83dc58f9..a2d288f1 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -407,7 +407,7 @@ void create_global_pid(){ // set without saving, the class is not in a coherent state yet // just do the value change and call to start logging, CGamesDialog will pickup when relevant g_GamesDialog.m_bForceLogConsole = true; - Sys_LogFile( true ); + Sys_EnableLogFile( true ); } // create a primary .pid for global init run @@ -466,7 +466,7 @@ void create_local_pid(){ // force console logging on! (will go in prefs too) g_GamesDialog.m_bForceLogConsole = true; - Sys_LogFile( true ); + Sys_EnableLogFile( true ); } else { @@ -502,11 +502,48 @@ void user_shortcuts_save(){ SaveCommandMap( path.c_str() ); } +void add_local_rc_files(){ +#define GARUX_DISABLE_GTKTHEME +#ifndef GARUX_DISABLE_GTKTHEME +/* FIXME: HACK: not GTK3 compatible + https://developer.gnome.org/gtk2/stable/gtk2-Resource-Files.html#gtk-rc-add-default-file + https://developer.gnome.org/gtk3/stable/gtk3-Resource-Files.html#gtk-rc-add-default-file + > gtk_rc_add_default_file has been deprecated since version 3.0 and should not be used in newly-written code. + > Use GtkStyleContext with a custom GtkStyleProvider instead +*/ + + { + StringOutputStream path( 512 ); + path << AppPath_get() << ".gtkrc-2.0.radiant"; + gtk_rc_add_default_file( path.c_str() ); + } +#ifdef WIN32 + { + StringOutputStream path( 512 ); + path << AppPath_get() << ".gtkrc-2.0.win"; + gtk_rc_add_default_file( path.c_str() ); + } +#endif +#endif // GARUX_DISABLE_GTKTHEME +} + +/* HACK: If ui::main is not called yet, +gtk_main_quit will not quit, so tell main +to not call ui::main. This happens when a +map is loaded from command line and require +a restart because of wrong format. +Delete this when the code to not have to +restart to load another format is merged. */ +bool g_dontStart = false; + int main( int argc, char* argv[] ){ #if GTK_TARGET == 3 // HACK: force legacy GL backend as we don't support GL3 yet setenv("GDK_GL", "LEGACY", 0); +#if GDEF_OS_LINUX || GDEF_OS_BSD + setenv("GDK_BACKEND", "x11", 0); #endif +#endif // GTK_TARGET == 3 crt_init(); streams_init(); @@ -517,10 +554,22 @@ int main( int argc, char* argv[] ){ if ( lib != 0 ) { void ( WINAPI *qDwmEnableComposition )( bool bEnable ) = ( void (WINAPI *) ( bool bEnable ) )GetProcAddress( lib, "DwmEnableComposition" ); if ( qDwmEnableComposition ) { - qDwmEnableComposition( FALSE ); + bool Aero = false; + for ( int i = 1; i < argc; ++i ){ + if ( !stricmp( argv[i], "-aero" ) ){ + Aero = true; + qDwmEnableComposition( TRUE ); + break; + } + } + // disable Aero + if ( !Aero ){ + qDwmEnableComposition( FALSE ); + } } FreeLibrary( lib ); } + _setmaxstdio(2048); #endif const char* mapname = NULL; @@ -537,9 +586,9 @@ int main( int argc, char* argv[] ){ } // Gtk already removed parsed `--options` - if ( argc == 2 ) { - if ( strlen( argv[ 1 ] ) > 1 ) { - mapname = argv[ 1 ]; + if (argc == 2) { + if ( strlen( argv[1] ) > 1 ) { + mapname = argv[1]; if ( g_str_has_suffix( mapname, ".map" ) ) { if ( !g_path_is_absolute( mapname ) ) { @@ -557,7 +606,7 @@ int main( int argc, char* argv[] ){ } } } - else if ( argc > 2 ) { + else if (argc > 2) { g_print ( "%s\n", "too many arguments" ); return -1; } @@ -580,6 +629,8 @@ int main( int argc, char* argv[] ){ paths_init(); + add_local_rc_files(); + show_splash(); create_global_pid(); @@ -600,7 +651,7 @@ int main( int argc, char* argv[] ){ // we may have the console turned on and want to keep it that way // so we use a latching system if ( g_GamesDialog.m_bForceLogConsole ) { - Sys_LogFile( true ); + Sys_EnableLogFile( true ); g_Console_enableLogging = true; g_GamesDialog.m_bForceLogConsole = false; } @@ -615,6 +666,12 @@ int main( int argc, char* argv[] ){ hide_splash(); +#ifdef WIN32 + if( openCmdMap && *openCmdMap ){ + Map_LoadFile( openCmdMap ); + } + else +#endif // WIN32 if ( mapname != NULL ) { Map_LoadFile( mapname ); } @@ -633,7 +690,17 @@ int main( int argc, char* argv[] ){ remove_local_pid(); + /* HACK: If ui::main is not called yet, + gtk_main_quit will not quit, so tell main + to not call ui::main. This happens when a + map is loaded from command line and require + a restart because of wrong format. + Delete this when the code to not have to + restart to load another format is merged. */ + if ( !g_dontStart ) + { ui::main(); + } // avoid saving prefs when the app is minimized if ( g_pParentWnd->IsSleeping() ) { @@ -654,7 +721,7 @@ int main( int argc, char* argv[] ){ Radiant_Shutdown(); // close the log file if any - Sys_LogFile( false ); + Sys_EnableLogFile( false ); return EXIT_SUCCESS; }