From: Thomas Debesse Date: Sat, 15 Jul 2017 12:08:24 +0000 (+0200) Subject: refresh DPK VFS before refreshing textures X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=8cfdea7ce327143a8f7bf7da8df536511c9287ca;p=xonotic%2Fnetradiant.git refresh DPK VFS before refreshing textures DPK VFS allows to add and remove pak dependencies. Reloading VFS before refreshing textures ensures added or removed dependencies are handled without reloading the whole map. It allows the user to edit the DEPS file while radiant is running, he just has to reload the VFS asking for texture refresh. --- diff --git a/include/ifilesystem.h b/include/ifilesystem.h index 6bbc0db2..70b5da92 100644 --- a/include/ifilesystem.h +++ b/include/ifilesystem.h @@ -50,6 +50,10 @@ virtual void initDirectory( const char *path ) = 0; /// \brief Initialises the filesystem. /// Called after all root search paths have been added. virtual void initialise() = 0; +/// \brief Clear the filesystem if supported +virtual void clear() = 0; +/// \brief Reload the filesystem if supported +virtual void refresh() = 0; /// \brief Shuts down the filesystem. virtual void shutdown() = 0; diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index a76fafba..bee7403b 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -848,6 +848,12 @@ void initDirectory( const char *path ){ InitDirectory( path, FileSystemQ3API_getArchiveModules() ); } void initialise(){ + load(); + globalOutputStream() << "filesystem initialised\n"; + g_observers.realise(); +} + +void load(){ ArchiveModules& archiveModules = FileSystemQ3API_getArchiveModules(); bool is_dpk_vfs = GetArchiveTable( archiveModules, "dpk" ); @@ -873,10 +879,19 @@ void initialise(){ g_pakfile_paths.clear(); g_loaded_dpk_paks.clear(); } +} - globalOutputStream() << "filesystem initialised\n"; - g_observers.realise(); +void clear() { + // like shutdown() but does not unrealise (keep map etc.) + Shutdown(); } + +void refresh(){ + // like initialise() but does not realise (keep map etc.) + load(); + globalOutputStream() << "filesystem refreshed\n"; +} + void shutdown(){ g_observers.unrealise(); globalOutputStream() << "filesystem shutdown\n"; diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 8abd6e2a..7a9e141e 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -160,6 +160,13 @@ void VFS_Shutdown(){ GlobalFileSystem().shutdown(); g_vfsInitialized = false; } +void VFS_Refresh(){ + if ( !g_vfsInitialized ) return; + GlobalFileSystem().clear(); + QE_InitVFS(); + GlobalFileSystem().refresh(); + g_vfsInitialized = true; +} void VFS_Restart(){ VFS_Shutdown(); VFS_Init(); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index c2738450..c450fd54 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -245,6 +245,7 @@ void gamemode_set( const char* gamemode ); void Radiant_attachGameModeObserver( ModuleObserver& observer ); void Radiant_detachGameModeObserver( ModuleObserver& observer ); +void VFS_Refresh(); void VFS_Restart(); void VFS_Construct(); void VFS_Destroy(); diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index e9ec10f9..e30f1035 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -2361,6 +2361,7 @@ void TextureBrowser_pasteTag(){ void RefreshShaders(){ ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" ); + VFS_Refresh(); GlobalShaderSystem().refresh(); UpdateAllWindows(); GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree);