]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/main.cpp
GTK: wrap gtk_list_store_{append,set}
[xonotic/netradiant.git] / radiant / main.cpp
index ea9bdc695a13afeabd1aea3c61cc3723c2eb1cca..4fa42d272a364ddda471e230184fe5a00c4ee302 100644 (file)
@@ -62,6 +62,7 @@
  */
 
 #include "main.h"
+#include "globaldefs.h"
 
 #include "version.h"
 
@@ -89,7 +90,7 @@
 #include "referencecache.h"
 #include "stacktrace.h"
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
 #include <windows.h>
 #endif
 
@@ -213,12 +214,12 @@ void error_redirect( const gchar *domain, GLogLevelFlags log_level, const gchar
     }
 }
 
-#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER )
+#if GDEF_COMPILER_MSVC && GDEF_DEBUG
 #include "crtdbg.h"
 #endif
 
 void crt_init(){
-#if defined ( _DEBUG ) && defined ( WIN32 ) && defined ( _MSC_VER )
+#if GDEF_COMPILER_MSVC && GDEF_DEBUG
        _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
 #endif
 }
@@ -301,7 +302,7 @@ bool handleMessage(){
        globalErrorStream() << m_buffer.c_str();
        if ( !m_lock.locked() ) {
                ScopedLock lock( m_lock );
-#if defined _DEBUG
+#if GDEF_DEBUG
                m_buffer << "Break into the debugger?\n";
                bool handled = ui::root.alert( m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error ) == ui::alert_response::NO;
                m_buffer.clear();
@@ -324,14 +325,7 @@ void streams_init(){
 }
 
 void paths_init(){
-       const char* home = environment_get_home_path();
-       Q_mkdir( home );
-
-       {
-               StringOutputStream path( 256 );
-               path << home << "/";
-               g_strSettingsPath = path.c_str();
-       }
+       g_strSettingsPath = environment_get_home_path();
 
        Q_mkdir( g_strSettingsPath.c_str() );
 
@@ -374,7 +368,7 @@ bool check_version(){
        // make something idiot proof and someone will make better idiots, this may be overkill
        // let's leave it disabled in debug mode in any case
        // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=431
-#ifndef _DEBUG
+#if !GDEF_DEBUG
 #define CHECK_VERSION
 #endif
 #ifdef CHECK_VERSION
@@ -396,7 +390,7 @@ bool check_version(){
                msg << "This editor binary (" RADIANT_VERSION ") doesn't match what the latest setup has configured in this directory\n"
                                "Make sure you run the right/latest editor binary you installed\n"
                        << AppPath_get();
-               ui::alert( 0, msg.c_str(), "Radiant", eMB_OK, eMB_ICONDEFAULT );
+               ui::root.alert( msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Default);
        }
        return bVerIsGood;
 #else
@@ -428,13 +422,13 @@ void create_global_pid(){
                }
 
                // in debug, never prompt to clean registry, turn console logging auto after a failed start
-#if !defined( _DEBUG )
+#if !GDEF_DEBUG
                StringOutputStream msg( 256 );
                msg << "Radiant failed to start properly the last time it was run.\n"
                           "The failure may be related to current global preferences.\n"
                           "Do you want to reset global preferences to defaults?";
 
-               if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) {
+               if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) {
                        g_GamesDialog.Reset();
                }
 
@@ -487,13 +481,13 @@ void create_local_pid(){
                }
 
                // in debug, never prompt to clean registry, turn console logging auto after a failed start
-#if !defined( _DEBUG )
+#if !GDEF_DEBUG
                StringOutputStream msg;
                msg << "Radiant failed to start properly the last time it was run.\n"
                           "The failure may be caused by current preferences.\n"
                           "Do you want to reset all preferences to defaults?";
 
-               if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) {
+               if ( ui::root.alert( msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question ) == ui::alert_response::YES ) {
                        Preferences_Reset();
                }
 
@@ -546,7 +540,7 @@ int main( int argc, char* argv[] ){
 
        streams_init();
 
-#ifdef WIN32
+#if GDEF_OS_WINDOWS
        HMODULE lib;
        lib = LoadLibrary( "dwmapi.dll" );
        if ( lib != 0 ) {
@@ -558,15 +552,10 @@ int main( int argc, char* argv[] ){
        }
 #endif
 
-       static GOptionEntry entries[] = {
-               { NULL }
-       };
-       GError *error = NULL;
        const char* mapname = NULL;
-
-       gtk_disable_setlocale();
-       if ( !gtk_init_with_args( &argc, &argv, "<filename.map>", entries, NULL, &error) ) {
-               g_print( "%s\n", error->message );
+    char const *error = NULL;
+       if ( !ui::init( &argc, &argv, "<filename.map>", &error) ) {
+               g_print( "%s\n", error );
                return -1;
        }
 
@@ -605,7 +594,7 @@ int main( int argc, char* argv[] ){
 
        GlobalDebugMessageHandler::instance().setHandler( GlobalPopupDebugMessageHandler::instance() );
 
-       environment_init( argc, argv );
+       environment_init(argc, (char const **) argv);
 
        paths_init();