]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/main.cpp
Merge branch 'master' into master-merge
[xonotic/netradiant.git] / radiant / main.cpp
index 87fa8470e1b063da7c2db420a47b2878c2b7ac67..1306de6ced97407633f403b96768ef26eb7baaf7 100644 (file)
@@ -498,6 +498,31 @@ void user_shortcuts_save(){
        SaveCommandMap();
 }
 
+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
@@ -525,10 +550,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;
@@ -545,9 +582,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 ) ) {
@@ -565,7 +602,7 @@ int main( int argc, char* argv[] ){
                        }
                }
        }
-       else if ( argc > 2 ) {
+       else if (argc > 2) {
                g_print ( "%s\n", "too many arguments" );
                return -1;
        }
@@ -588,6 +625,8 @@ int main( int argc, char* argv[] ){
 
        paths_init();
 
+       add_local_rc_files();
+
        show_splash();
 
        create_global_pid();
@@ -623,7 +662,10 @@ int main( int argc, char* argv[] ){
 
        hide_splash();
 
-       if ( mapname != NULL ) {
+       if( openCmdMap && *openCmdMap ){
+               Map_LoadFile( openCmdMap );
+       }
+       else if ( mapname != NULL ) {
                Map_LoadFile( mapname );
        }
        else if ( g_bLoadLastMap && !g_strLastMap.empty() ) {
@@ -650,7 +692,7 @@ int main( int argc, char* argv[] ){
        restart to load another format is merged. */
        if ( !g_dontStart )
        {
-               ui::main();
+       ui::main();
        }
 
        // avoid saving prefs when the app is minimized