X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=radiant%2Fqe3.cpp;h=38028e7dd5918d087aea2d0b8ea2dc44dc26df00;hb=b8f0b2351d49fedbcc3a67dab5f9852a246b0b3d;hp=193a0a49c2e8edf740e6d551554f459c669b7379;hpb=771bab14ffa4b131540b125aff6554265662f874;p=xonotic%2Fnetradiant.git diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index 193a0a49..38028e7d 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -32,7 +32,11 @@ // Leonardo Zide (leo@lokigames.com) // +#include "defaults.h" #include "qe3.h" +#include "globaldefs.h" + +#include #include "debugging/debugging.h" @@ -64,7 +68,7 @@ QEGlobals_t g_qeglobals; -#if defined( WIN32 ) +#if GDEF_OS_WINDOWS #define PATH_MAX 260 #endif @@ -80,17 +84,22 @@ void QE_InitVFS(){ const char* userRoot = g_qeglobals.m_userEnginePath.c_str(); const char* globalRoot = EnginePath_get(); + // editor builtin VFS + StringOutputStream editorGamePath( 256 ); + editorGamePath << GlobalRadiant().getDataPath() << DEFAULT_EDITORVFS_DIRNAME; + GlobalFileSystem().initDirectory( editorGamePath.c_str() ); + // if we have a mod dir if ( !string_equal( gamename, basegame ) ) { // ~/./ - if ( userRoot ) { + if ( userRoot && !g_disableHomePath ) { StringOutputStream userGamePath( 256 ); userGamePath << userRoot << gamename << '/'; GlobalFileSystem().initDirectory( userGamePath.c_str() ); } // / - { + if ( !g_disableEnginePath ) { StringOutputStream globalGamePath( 256 ); globalGamePath << globalRoot << gamename << '/'; GlobalFileSystem().initDirectory( globalGamePath.c_str() ); @@ -98,18 +107,25 @@ void QE_InitVFS(){ } // ~/./ - if ( userRoot ) { + if ( userRoot && !g_disableHomePath ) { StringOutputStream userBasePath( 256 ); userBasePath << userRoot << basegame << '/'; GlobalFileSystem().initDirectory( userBasePath.c_str() ); } // / - { + if ( !g_disableEnginePath ) { StringOutputStream globalBasePath( 256 ); globalBasePath << globalRoot << basegame << '/'; GlobalFileSystem().initDirectory( globalBasePath.c_str() ); } + + // extra pakpaths + for ( int i = 0; i < g_pakPathCount; i++ ) { + if (g_strcmp0( g_strPakPath[i].c_str(), "")) { + GlobalFileSystem().initDirectory( g_strPakPath[i].c_str() ); + } + } } int g_numbrushes = 0; @@ -140,7 +156,7 @@ bool ConfirmModified( const char* title ){ return true; } - auto result = MainFrame_getWindow().alert( "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, ui::alert_type::YESNOCANCEL, ui::alert_icon::Question ); + auto result = ui::alert( MainFrame_getWindow(), "The current map has changed since it was last saved.\nDo you want to save the current map before continuing?", title, ui::alert_type::YESNOCANCEL, ui::alert_icon::Question ); if ( result == ui::alert_response::CANCEL ) { return false; } @@ -158,12 +174,37 @@ bool ConfirmModified( const char* title ){ void bsp_init(){ build_set_variable( "RadiantPath", AppPath_get() ); + + #if GDEF_OS_WINDOWS build_set_variable( "ExecutableType", RADIANT_EXECUTABLE ); + #endif // GDEF_OS_WINDOWS + build_set_variable( "EnginePath", EnginePath_get() ); build_set_variable( "UserEnginePath", g_qeglobals.m_userEnginePath.c_str() ); build_set_variable( "MonitorAddress", ( g_WatchBSP_Enabled ) ? "127.0.0.1:39000" : "" ); build_set_variable( "GameName", gamename_get() ); + StringBuffer ExtraQ3map2Args; + // extra pakpaths + for ( int i = 0; i < g_pakPathCount; i++ ) { + if ( g_strcmp0( g_strPakPath[i].c_str(), "") ) { + ExtraQ3map2Args.push_string( " -fs_pakpath \"" ); + ExtraQ3map2Args.push_string( g_strPakPath[i].c_str() ); + ExtraQ3map2Args.push_string( "\"" ); + } + } + + // extra switches + if ( g_disableEnginePath ) { + ExtraQ3map2Args.push_string( " -fs_nobasepath " ); + } + + if ( g_disableHomePath ) { + ExtraQ3map2Args.push_string( " -fs_nohomepath " ); + } + + build_set_variable( "ExtraQ3map2Args", ExtraQ3map2Args.c_str() ); + const char* mapname = Map_Name( g_map ); StringOutputStream name( 256 ); name << StringRange( mapname, path_get_filename_base_end( mapname ) ) << ".bsp"; @@ -183,6 +224,7 @@ public: ArrayCommandListener(){ m_array = g_ptr_array_new(); } + ~ArrayCommandListener(){ g_ptr_array_free( m_array, TRUE ); } @@ -279,10 +321,10 @@ void RunBSP( const char* name ){ strcat( junkpath, "junk.txt" ); char batpath[PATH_MAX]; -#if defined( POSIX ) +#if GDEF_OS_POSIX strcpy( batpath, SettingsPath_get() ); strcat( batpath, "qe3bsp.sh" ); -#elif defined( WIN32 ) +#elif GDEF_OS_WINDOWS strcpy( batpath, SettingsPath_get() ); strcat( batpath, "qe3bsp.bat" ); #else @@ -292,7 +334,7 @@ void RunBSP( const char* name ){ { TextFileOutputStream batchFile( batpath ); if ( !batchFile.failed() ) { -#if defined ( POSIX ) +#if GDEF_OS_POSIX batchFile << "#!/bin/sh \n\n"; #endif BatchCommandListener listener( batchFile, junkpath ); @@ -301,7 +343,7 @@ void RunBSP( const char* name ){ } } if ( written ) { -#if defined ( POSIX ) +#if GDEF_OS_POSIX chmod( batpath, 0744 ); #endif globalOutputStream() << "Writing the compile script to '" << batpath << "'\n";