* prefs->game->paths: +Extra Resource Path option

This commit is contained in:
Garux 2018-01-23 17:51:22 +03:00
parent d747bd6111
commit 387c4c0846
4 changed files with 32 additions and 14 deletions

View File

@ -243,7 +243,7 @@ TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const Direct
} }
} }
char c = *( i - 1 ); char c = *( i - 1 );
if ( c != '/' && c != '\\' ) { if ( c != '/' && c != '\\' && !string_empty( path.m_path ) ) {
ostream << '/'; ostream << '/';
} }
return ostream; return ostream;

View File

@ -338,10 +338,10 @@ void EnginePath_Unrealise(){
} }
} }
void setEnginePath( const char* path ){ void setEnginePath( CopiedString& self, const char* value ){
StringOutputStream buffer( 256 ); StringOutputStream buffer( 256 );
buffer << DirectoryCleaned( path ); buffer << DirectoryCleaned( value );
if ( !path_equal( buffer.c_str(), g_strEnginePath.c_str() ) ) { if ( !path_equal( buffer.c_str(), self.c_str() ) ) {
#if 0 #if 0
while ( !ConfirmModified( "Paths Changed" ) ) while ( !ConfirmModified( "Paths Changed" ) )
{ {
@ -360,11 +360,21 @@ void setEnginePath( const char* path ){
EnginePath_Unrealise(); EnginePath_Unrealise();
g_strEnginePath = buffer.c_str(); self = buffer.c_str();
EnginePath_Realise(); EnginePath_Realise();
} }
} }
typedef ReferenceCaller1<CopiedString, const char*, setEnginePath> EnginePathImportCaller;
// Extra Resource Path
CopiedString g_strExtraResourcePath;
const char* ExtraResourcePath_get(){
return g_strExtraResourcePath.c_str();
}
// App Path // App Path
@ -376,7 +386,7 @@ const char* AppPath_get(){
} }
/// the path to the local rc-dir /// the path to the local rc-dir
const char* LocalRcPath_get( void ){ const char* LocalRcPath_get(){
static CopiedString rc_path; static CopiedString rc_path;
if ( rc_path.empty() ) { if ( rc_path.empty() ) {
StringOutputStream stream( 256 ); StringOutputStream stream( 256 );
@ -409,10 +419,6 @@ const char* GameToolsPath_get(){
return g_strGameToolsPath.c_str(); return g_strGameToolsPath.c_str();
} }
void EnginePathImport( CopiedString& self, const char* value ){
setEnginePath( value );
}
typedef ReferenceCaller1<CopiedString, const char*, EnginePathImport> EnginePathImportCaller;
void Paths_constructPreferences( PreferencesPage& page ){ void Paths_constructPreferences( PreferencesPage& page ){
page.appendPathEntry( "Engine Path", true, page.appendPathEntry( "Engine Path", true,
@ -423,6 +429,11 @@ void Paths_constructPreferences( PreferencesPage& page ){
void Paths_constructPage( PreferenceGroup& group ){ void Paths_constructPage( PreferenceGroup& group ){
PreferencesPage page( group.createPage( "Paths", "Path Settings" ) ); PreferencesPage page( group.createPage( "Paths", "Path Settings" ) );
Paths_constructPreferences( page ); Paths_constructPreferences( page );
page.appendPathEntry( "Extra Resource Path", true,
StringImportCallback( EnginePathImportCaller( g_strExtraResourcePath ) ),
StringExportCallback( StringExportCaller( g_strExtraResourcePath ) )
);
} }
void Paths_registerPreferencesPage(){ void Paths_registerPreferencesPage(){
PreferencesDialog_addGamePage( FreeCaller1<PreferenceGroup&, Paths_constructPage>() ); PreferencesDialog_addGamePage( FreeCaller1<PreferenceGroup&, Paths_constructPage>() );
@ -3613,10 +3624,11 @@ void MainFrame_Construct(){
GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) ); GlobalPreferenceSystem().registerPreference( "YZWnd", WindowPositionTrackerImportStringCaller( g_posYZWnd ), WindowPositionTrackerExportStringCaller( g_posYZWnd ) );
GlobalPreferenceSystem().registerPreference( "XZWnd", WindowPositionTrackerImportStringCaller( g_posXZWnd ), WindowPositionTrackerExportStringCaller( g_posXZWnd ) ); 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( "NudgeAfterClone", BoolImportStringCaller( g_bNudgeAfterClone ), BoolExportStringCaller( g_bNudgeAfterClone ) );
GlobalPreferenceSystem().registerPreference( "OpenGLFont", CopiedStringImportStringCaller( g_strOpenGLFont ), CopiedStringExportStringCaller( g_strOpenGLFont ) ); 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() ) if ( g_strEnginePath.empty() )
{ {
g_strEnginePath_was_empty_1st_start = true; g_strEnginePath_was_empty_1st_start = true;
@ -3634,7 +3646,6 @@ void MainFrame_Construct(){
StringOutputStream path( 256 ); StringOutputStream path( 256 );
path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) ); path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) );
g_strEnginePath = path.c_str(); g_strEnginePath = path.c_str();
GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
} }

View File

@ -200,13 +200,16 @@ void EnginePath_verify();
const char* EnginePath_get(); const char* EnginePath_get();
const char* QERApp_GetGamePath(); const char* QERApp_GetGamePath();
extern CopiedString g_strExtraResourcePath;
const char* ExtraResourcePath_get();
extern CopiedString g_strAppPath; extern CopiedString g_strAppPath;
const char* AppPath_get(); const char* AppPath_get();
extern CopiedString g_strSettingsPath; extern CopiedString g_strSettingsPath;
const char* SettingsPath_get(); 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_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 const char* const g_modulesDir = "modules/"; ///< name of modules directory, always sub-directory of toolspath

View File

@ -80,6 +80,10 @@ void QE_InitVFS(){
const char* userRoot = g_qeglobals.m_userEnginePath.c_str(); const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
const char* globalRoot = EnginePath_get(); const char* globalRoot = EnginePath_get();
const char* extrapath = ExtraResourcePath_get();
if( !string_empty( extrapath ) )
GlobalFileSystem().initDirectory( extrapath );
// if we have a mod dir // if we have a mod dir
if ( !string_equal( gamename, basegame ) ) { if ( !string_equal( gamename, basegame ) ) {
// ~/.<gameprefix>/<fs_game> // ~/.<gameprefix>/<fs_game>