]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/watchbsp.cpp
radiant/tools: use RADIANT_NAME instead of hardcoding NetRadiant or Radiant
[xonotic/netradiant.git] / radiant / watchbsp.cpp
index cddc0a5c00cc9e52ab8c00ed2cc5bc17252e962c..bb65e57337b331c5161a7f894e9c00111481899b 100644 (file)
@@ -34,6 +34,7 @@
 // monitoring window for running BSP processes (and possibly various other stuff)
 
 #include "watchbsp.h"
+#include "globaldefs.h"
 
 #include <algorithm>
 
@@ -189,7 +190,7 @@ void Build_constructPage( PreferenceGroup& group ){
        Build_constructPreferences( page );
 }
 void Build_registerPreferencesPage(){
-       PreferencesDialog_addSettingsPage( FreeCaller1<PreferenceGroup&, Build_constructPage>() );
+       PreferencesDialog_addSettingsPage( makeCallbackF(Build_constructPage) );
 }
 
 #include "preferencesystem.h"
@@ -200,10 +201,10 @@ void BuildMonitor_Construct(){
 
        g_WatchBSP_Enabled = !string_equal( g_pGameDescription->getKeyValue( "no_bsp_monitor" ), "1" );
 
-       GlobalPreferenceSystem().registerPreference( "WatchBSP", BoolImportStringCaller( g_WatchBSP_Enabled ), BoolExportStringCaller( g_WatchBSP_Enabled ) );
-       GlobalPreferenceSystem().registerPreference( "RunQuake2Run", BoolImportStringCaller( g_WatchBSP_RunQuake ), BoolExportStringCaller( g_WatchBSP_RunQuake ) );
-       GlobalPreferenceSystem().registerPreference( "LeakStop", BoolImportStringCaller( g_WatchBSP_LeakStop ), BoolExportStringCaller( g_WatchBSP_LeakStop ) );
-       GlobalPreferenceSystem().registerPreference( "SleepMode", BoolImportStringCaller( g_WatchBSP_DoSleep ), BoolExportStringCaller( g_WatchBSP_DoSleep ) );
+       GlobalPreferenceSystem().registerPreference( "WatchBSP", make_property_string( g_WatchBSP_Enabled ) );
+       GlobalPreferenceSystem().registerPreference( "RunQuake2Run", make_property_string( g_WatchBSP_RunQuake ) );
+       GlobalPreferenceSystem().registerPreference( "LeakStop", make_property_string( g_WatchBSP_LeakStop ) );
+       GlobalPreferenceSystem().registerPreference( "SleepMode", make_property_string( g_WatchBSP_DoSleep ) );
 
        Build_registerPreferencesPage();
 }
@@ -272,8 +273,8 @@ static void saxStartElement( message_info_t *data, const xmlChar *name, const xm
                                else if ( strcmp( reinterpret_cast<const char*>( attrs[1] ), Q3MAP_STREAM_VERSION ) != 0 ) {
                                        message_flush( data );
                                        globalErrorStream() <<
-                                       "This version of Radiant reads version " Q3MAP_STREAM_VERSION " debug streams, I got an incoming connection with version " << reinterpret_cast<const char*>( attrs[1] ) << "\n"
-                                                                                                                                                                                                                                                                                                                                                                                          "Please make sure your versions of Radiant and q3map are matching.\n";
+                                       "This version of " RADIANT_NAME " reads version " Q3MAP_STREAM_VERSION " debug streams, I got an incoming connection with version " << reinterpret_cast<const char*>( attrs[1] ) << "\n"
+                                                                                                                                                                                                                                                                                                                                                                                          "Please make sure your versions of " RADIANT_NAME " and q3map are matching.\n";
                                        abortStream( data );
                                        return;
                                }
@@ -343,7 +344,7 @@ static void saxEndElement( message_info_t *data, const xmlChar *name ){
        }
        if ( data->recurse == data->stop_depth ) {
                message_flush( data );
-#ifdef _DEBUG
+#if GDEF_DEBUG
                globalOutputStream() << "Received error msg .. shutting down..\n";
 #endif
                GetWatchBSP()->EndMonitoringLoop();
@@ -494,7 +495,7 @@ void CWatchBSP::Reset(){
 }
 
 bool CWatchBSP::SetupListening(){
-#ifdef _DEBUG
+#if GDEF_DEBUG
        if ( m_pListenSocket ) {
                globalOutputStream() << "ERROR: m_pListenSocket != NULL in CWatchBSP::SetupListening\n";
                return false;
@@ -515,7 +516,7 @@ void CWatchBSP::DoEBeginStep(){
        if ( SetupListening() == false ) {
                const char* msg = "Failed to get a listening socket on port 39000.\nTry running with Build monitoring disabled if you can't fix this.\n";
                globalOutputStream() << msg;
-               MainFrame_getWindow().alert( msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
+               ui::alert( MainFrame_getWindow(), msg, "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
                return;
        }
        // set the timer for timeouts and step cancellation
@@ -532,7 +533,7 @@ void CWatchBSP::DoEBeginStep(){
                        msg << reinterpret_cast<const char*>( g_ptr_array_index( m_pCmd, m_iCurrentStep ) );
                        msg << "\nCheck that the file exists and that you don't run out of system resources.\n";
                        globalOutputStream() << msg.c_str();
-                       MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
+                       ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
                        return;
                }
                // re-initialise the debug window
@@ -545,13 +546,13 @@ void CWatchBSP::DoEBeginStep(){
 }
 
 
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
 const char *ENGINE_ATTRIBUTE = "engine_win32";
 const char *MP_ENGINE_ATTRIBUTE = "mp_engine_win32";
-#elif defined( __linux__ ) || defined ( __FreeBSD__ )
+#elif GDEF_OS_LINUX || GDEF_OS_BSD
 const char *ENGINE_ATTRIBUTE = "engine_linux";
 const char *MP_ENGINE_ATTRIBUTE = "mp_engine_linux";
-#elif defined( __APPLE__ )
+#elif GDEF_OS_MACOS
 const char *ENGINE_ATTRIBUTE = "engine_macos";
 const char *MP_ENGINE_ATTRIBUTE = "mp_engine_macos";
 #else
@@ -612,7 +613,7 @@ void CWatchBSP::RoutineProcessing(){
        case EBeginStep:
                // timeout: if we don't get an incoming connection fast enough, go back to idle
                if ( g_timer_elapsed( m_pTimer, NULL ) > g_WatchBSP_Timeout ) {
-                       MainFrame_getWindow().alert(  "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK );
+                       ui::alert( MainFrame_getWindow(), "The connection timed out, assuming the build process failed\nMake sure you are using a networked version of Q3Map?\nOtherwise you need to disable BSP Monitoring in prefs.", "BSP process monitoring", ui::alert_type::OK );
                        EndMonitoringLoop();
 #if 0
                        if ( m_bBSPPlugin ) {
@@ -622,7 +623,7 @@ void CWatchBSP::RoutineProcessing(){
 #endif
                        return;
                }
-#ifdef _DEBUG
+#if GDEF_DEBUG
                // some debug checks
                if ( !m_pListenSocket ) {
                        globalErrorStream() << "ERROR: m_pListenSocket == NULL in CWatchBSP::RoutineProcessing EBeginStep state\n";
@@ -642,7 +643,7 @@ void CWatchBSP::RoutineProcessing(){
                break;
        case EWatching:
        {
-#ifdef _DEBUG
+#if GDEF_DEBUG
                // some debug checks
                if ( !m_pInSocket ) {
                        globalErrorStream() << "ERROR: m_pInSocket == NULL in CWatchBSP::RoutineProcessing EWatching state\n";
@@ -745,7 +746,7 @@ void CWatchBSP::RoutineProcessing(){
                                                        StringOutputStream msg;
                                                        msg << "Failed to execute the following command: " << cmd.c_str() << cmdline.c_str();
                                                        globalOutputStream() << msg.c_str();
-                                                       MainFrame_getWindow().alert( msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
+                                                       ui::alert( MainFrame_getWindow(), msg.c_str(), "Build monitoring", ui::alert_type::OK, ui::alert_icon::Error );
                                                }
                                        }
                                        EndMonitoringLoop();
@@ -773,7 +774,7 @@ void CWatchBSP::DoMonitoringLoop( GPtrArray *pCmd, const char *sBSPName ){
        if ( m_eState != EIdle ) {
                globalOutputStream() << "WatchBSP got a monitoring request while not idling...\n";
                // prompt the user, should we cancel the current process and go ahead?
-               if ( MainFrame_getWindow().alert( "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
+               if ( ui::alert( MainFrame_getWindow(), "I am already monitoring a Build process.\nDo you want me to override and start a new compilation?",
                                                         "Build process monitoring", ui::alert_type::YESNO ) == ui::alert_response::YES ) {
                        // disconnect and set EIdle state
                        Reset();