]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/main.cpp
Merge commit '39f598c5f44010cc32f1b445b12cb088a72bbc50' into master-merge
[xonotic/netradiant.git] / radiant / main.cpp
index ff52a200dd867224991a45803dd3d7d5849b5e13..5bd19fd2e75acc96f6e680070373e376000a8311 100644 (file)
@@ -64,8 +64,6 @@
 #include "main.h"
 #include "globaldefs.h"
 
-#include "version.h"
-
 #include "debugging/debugging.h"
 
 #include "iundo.h"
@@ -329,6 +327,7 @@ void paths_init(){
 
        Q_mkdir( g_strSettingsPath.c_str() );
 
+       g_strAppFilePath = environment_get_app_filepath();
        g_strAppPath = environment_get_app_path();
        g_strLibPath = environment_get_lib_path();
        g_strDataPath = environment_get_data_path();
@@ -408,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
@@ -467,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
        {
@@ -503,7 +502,23 @@ void user_shortcuts_save(){
        SaveCommandMap( path.c_str() );
 }
 
+/* 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();
@@ -514,6 +529,7 @@ int main( int argc, char* argv[] ){
        if ( lib != 0 ) {
                void ( WINAPI *qDwmEnableComposition )( bool bEnable ) = ( void (WINAPI *) ( bool bEnable ) )GetProcAddress( lib, "DwmEnableComposition" );
                if ( qDwmEnableComposition ) {
+                       // disable Aero
                        qDwmEnableComposition( FALSE );
                }
                FreeLibrary( lib );
@@ -536,9 +552,9 @@ int main( int argc, char* argv[] ){
        // Gtk already removed parsed `--options`
        if ( argc == 2 ) {
                if ( strlen( argv[ 1 ] ) > 1 ) {
-                       if ( g_str_has_suffix( argv[ 1 ], ".map" ) ) {
-                               mapname = argv[ 1 ];
+                       mapname = argv[ 1 ];
 
+                       if ( g_str_has_suffix( mapname, ".map" ) ) {
                                if ( !g_path_is_absolute( mapname ) ) {
                                        mapname = g_build_filename( g_get_current_dir(), mapname, NULL );
                                }
@@ -550,6 +566,7 @@ int main( int argc, char* argv[] ){
                        }
                        else {
                                g_print( "bad file name, will not load: %s\n", mapname );
+                               mapname = NULL;
                        }
                }
        }
@@ -596,7 +613,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;
        }
@@ -629,7 +646,17 @@ int main( int argc, char* argv[] ){
 
        remove_local_pid();
 
-       ui::main();
+       /* 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() ) {
@@ -650,7 +677,7 @@ int main( int argc, char* argv[] ){
        Radiant_Shutdown();
 
        // close the log file if any
-       Sys_LogFile( false );
+       Sys_EnableLogFile( false );
 
        return EXIT_SUCCESS;
 }