From 387c4c084652a3e465875b5dfd5486029958567a Mon Sep 17 00:00:00 2001 From: Garux Date: Tue, 23 Jan 2018 17:51:22 +0300 Subject: [PATCH] * prefs->game->paths: +Extra Resource Path option --- libs/os/path.h | 2 +- radiant/mainframe.cpp | 35 +++++++++++++++++++++++------------ radiant/mainframe.h | 5 ++++- radiant/qe3.cpp | 4 ++++ 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/libs/os/path.h b/libs/os/path.h index e3329a75..3e664afb 100644 --- a/libs/os/path.h +++ b/libs/os/path.h @@ -243,7 +243,7 @@ TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const Direct } } char c = *( i - 1 ); - if ( c != '/' && c != '\\' ) { + if ( c != '/' && c != '\\' && !string_empty( path.m_path ) ) { ostream << '/'; } return ostream; diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 6389b644..d2fd6bc4 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -338,10 +338,10 @@ void EnginePath_Unrealise(){ } } -void setEnginePath( const char* path ){ +void setEnginePath( CopiedString& self, const char* value ){ StringOutputStream buffer( 256 ); - buffer << DirectoryCleaned( path ); - if ( !path_equal( buffer.c_str(), g_strEnginePath.c_str() ) ) { + buffer << DirectoryCleaned( value ); + if ( !path_equal( buffer.c_str(), self.c_str() ) ) { #if 0 while ( !ConfirmModified( "Paths Changed" ) ) { @@ -360,11 +360,21 @@ void setEnginePath( const char* path ){ EnginePath_Unrealise(); - g_strEnginePath = buffer.c_str(); + self = buffer.c_str(); EnginePath_Realise(); } } +typedef ReferenceCaller1 EnginePathImportCaller; + + +// Extra Resource Path + +CopiedString g_strExtraResourcePath; + +const char* ExtraResourcePath_get(){ + return g_strExtraResourcePath.c_str(); +} // App Path @@ -376,7 +386,7 @@ const char* AppPath_get(){ } /// the path to the local rc-dir -const char* LocalRcPath_get( void ){ +const char* LocalRcPath_get(){ static CopiedString rc_path; if ( rc_path.empty() ) { StringOutputStream stream( 256 ); @@ -409,10 +419,6 @@ const char* GameToolsPath_get(){ return g_strGameToolsPath.c_str(); } -void EnginePathImport( CopiedString& self, const char* value ){ - setEnginePath( value ); -} -typedef ReferenceCaller1 EnginePathImportCaller; void Paths_constructPreferences( PreferencesPage& page ){ page.appendPathEntry( "Engine Path", true, @@ -423,6 +429,11 @@ void Paths_constructPreferences( PreferencesPage& page ){ void Paths_constructPage( PreferenceGroup& group ){ PreferencesPage page( group.createPage( "Paths", "Path Settings" ) ); Paths_constructPreferences( page ); + page.appendPathEntry( "Extra Resource Path", true, + StringImportCallback( EnginePathImportCaller( g_strExtraResourcePath ) ), + StringExportCallback( StringExportCaller( g_strExtraResourcePath ) ) + ); + } void Paths_registerPreferencesPage(){ PreferencesDialog_addGamePage( FreeCaller1() ); @@ -3613,10 +3624,11 @@ void MainFrame_Construct(){ GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) ); GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) ); - GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) ); - GlobalPreferenceSystem().registerPreference( "NudgeAfterClone", BoolImportStringCaller( g_bNudgeAfterClone ), BoolExportStringCaller( g_bNudgeAfterClone ) ); GlobalPreferenceSystem().registerPreference( "OpenGLFont", CopiedStringImportStringCaller( g_strOpenGLFont ), CopiedStringExportStringCaller( g_strOpenGLFont ) ); + + GlobalPreferenceSystem().registerPreference( "ExtraResoucePath", CopiedStringImportStringCaller( g_strExtraResourcePath ), CopiedStringExportStringCaller( g_strExtraResourcePath ) ); + GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) ); if ( g_strEnginePath.empty() ) { g_strEnginePath_was_empty_1st_start = true; @@ -3634,7 +3646,6 @@ void MainFrame_Construct(){ StringOutputStream path( 256 ); path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) ); g_strEnginePath = path.c_str(); - GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) ); } diff --git a/radiant/mainframe.h b/radiant/mainframe.h index 920c322d..e9b0342c 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -200,13 +200,16 @@ void EnginePath_verify(); const char* EnginePath_get(); const char* QERApp_GetGamePath(); +extern CopiedString g_strExtraResourcePath; +const char* ExtraResourcePath_get(); + extern CopiedString g_strAppPath; const char* AppPath_get(); extern CopiedString g_strSettingsPath; const char* SettingsPath_get(); -const char* LocalRcPath_get( void ); +const char* LocalRcPath_get(); const char* const g_pluginsDir = "plugins/"; ///< name of plugins directory, always sub-directory of toolspath const char* const g_modulesDir = "modules/"; ///< name of modules directory, always sub-directory of toolspath diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index b5d414f1..3aa50706 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -80,6 +80,10 @@ void QE_InitVFS(){ const char* userRoot = g_qeglobals.m_userEnginePath.c_str(); const char* globalRoot = EnginePath_get(); + const char* extrapath = ExtraResourcePath_get(); + if( !string_empty( extrapath ) ) + GlobalFileSystem().initDirectory( extrapath ); + // if we have a mod dir if ( !string_equal( gamename, basegame ) ) { // ~/./