* support multiple Extra Resource Paths

This commit is contained in:
Garux
2023-08-22 15:40:09 +06:00
parent c9d8265958
commit 158b724dba
4 changed files with 47 additions and 45 deletions

View File

@@ -321,11 +321,11 @@ void EnginePath_Unrealise(){
static CopiedString g_installedDevFilesPath; // track last engine path, where dev files installation occured, to prompt again when changed
static void installDevFiles( const CopiedString& enginePath ){
if( !path_equal( enginePath.c_str(), g_installedDevFilesPath.c_str() ) ){
static void installDevFiles(){
if( !path_equal( g_strEnginePath.c_str(), g_installedDevFilesPath.c_str() ) ){
ASSERT_MESSAGE( g_enginepath_unrealised != 0, "installDevFiles: engine path realised" );
DoInstallDevFilesDlg( enginePath.c_str() );
g_installedDevFilesPath = enginePath;
DoInstallDevFilesDlg( g_strEnginePath.c_str() );
g_installedDevFilesPath = g_strEnginePath;
}
}
@@ -352,7 +352,7 @@ void setEnginePath( CopiedString& self, const char* value ){
self = buffer.c_str();
installDevFiles( self );
installDevFiles();
EnginePath_Realise();
}
@@ -362,10 +362,10 @@ typedef ReferenceCaller1<CopiedString, const char*, setEnginePath> EnginePathImp
// Extra Resource Path
CopiedString g_strExtraResourcePath;
std::array<CopiedString, 5> g_strExtraResourcePaths;
const char* ExtraResourcePath_get(){
return g_strExtraResourcePath.c_str();
const std::array<CopiedString, 5>& ExtraResourcePaths_get(){
return g_strExtraResourcePaths;
}
@@ -421,10 +421,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 ) )
);
for( auto& extraPath : g_strExtraResourcePaths )
page.appendPathEntry( "Extra Resource Path", true,
StringImportCallback( EnginePathImportCaller( extraPath ) ),
StringExportCallback( StringExportCaller( extraPath ) )
);
}
void Paths_registerPreferencesPage(){
@@ -486,7 +487,7 @@ void EnginePath_verify(){
g_PathsDialog.DoModal();
g_PathsDialog.Destroy();
}
installDevFiles( g_strEnginePath ); // try this anytime, as engine path may be set via command line or -gamedetect
installDevFiles(); // try this anytime, as engine path may be set via command line or -gamedetect
}
namespace
@@ -2096,7 +2097,10 @@ void MainFrame_Construct(){
GlobalPreferenceSystem().registerPreference( "OpenGLFont", CopiedStringImportStringCaller( g_OpenGLFont ), CopiedStringExportStringCaller( g_OpenGLFont ) );
GlobalPreferenceSystem().registerPreference( "OpenGLFontSize", IntImportStringCaller( g_OpenGLFontSize ), IntExportStringCaller( g_OpenGLFontSize ) );
GlobalPreferenceSystem().registerPreference( "ExtraResoucePath", CopiedStringImportStringCaller( g_strExtraResourcePath ), CopiedStringExportStringCaller( g_strExtraResourcePath ) );
for( size_t i = 0; i < g_strExtraResourcePaths.size(); ++i )
GlobalPreferenceSystem().registerPreference( StringOutputStream( 32 )( "ExtraResourcePath", i ),
CopiedStringImportStringCaller( g_strExtraResourcePaths[i] ), CopiedStringExportStringCaller( g_strExtraResourcePaths[i] ) );
GlobalPreferenceSystem().registerPreference( "EnginePath", CopiedStringImportStringCaller( g_strEnginePath ), CopiedStringExportStringCaller( g_strEnginePath ) );
GlobalPreferenceSystem().registerPreference( "InstalledDevFilesPath", CopiedStringImportStringCaller( g_installedDevFilesPath ), CopiedStringExportStringCaller( g_installedDevFilesPath ) );
if ( g_strEnginePath.empty() )