]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
[dpkdir] restart VFS only for Map_Free() and Map_LoadFile(), refresh others
authorThomas Debesse <dev@illwieckz.net>
Tue, 18 Jul 2017 11:04:26 +0000 (13:04 +0200)
committerThomas Debesse <dev@illwieckz.net>
Sat, 29 Jul 2017 16:11:08 +0000 (18:11 +0200)
Since there is no map file observer anymore for that stuff,
we Restart or Refresh it explicitely when needed.

- Opening map or New map needs Restarting VFS.
- Saving map or Renaming map (Save as) needs Refreshing VFS.

The Refresh also triggers the Texture browser.

A previous fix for #105 was done Refreshing VFS instead of Restarting it
but it was not perfect, for example map opening behavior is better with
VFS restart, and map saving needs to refresh the VFS and the texture
browser but not restart (that was the earlier fault). So, it's clearly
not a good idea to trigger either Refresh or Restart on any map event
since the behavior differs according to the event.

If one day one plugin wants to act on VFS on map event, it must refresh or
restart VFS according to what the plugin does. It does not make sense to
trigger the same task for different events.

radiant/mainframe.cpp
radiant/map.cpp
radiant/texwindow.cpp
radiant/texwindow.h

index 672b37ca17391e2050fbff020d37c31cb414a60e..53ef24a60f3d2371f37c0cc811c2eb4d7271d056 100644 (file)
 #include "renderstate.h"
 #include "feedback.h"
 #include "referencecache.h"
-
+#include "texwindow.h"
 
 
 struct layout_globals_t
@@ -166,6 +166,8 @@ void VFS_Refresh(){
        QE_InitVFS();
        GlobalFileSystem().refresh();
        g_vfsInitialized = true;
+       // also refresh texture browser
+       TextureBrowser_RefreshShaders();
 }
 void VFS_Restart(){
        VFS_Shutdown();
index ed69f6326a208366916acb9295a8fe076b6b041a..18d25c096c17784ffbef248310e271eadb90f858 100644 (file)
@@ -978,6 +978,10 @@ void Map_LoadFile( const char *filename ){
        Map_StartPosition();
 
        g_currentMap = &g_map;
+
+       // restart VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Restart();
 }
 
 class Excluder
@@ -1186,6 +1190,9 @@ void Map_RenameAbsolute( const char* absolute ){
        Map_UpdateTitle( g_map );
 
        g_map.m_resource->attach( g_map );
+       // refresh VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Refresh();
 }
 
 void Map_Rename( const char* filename ){
@@ -1233,6 +1240,10 @@ void Map_New(){
        FocusViews( g_vector3_identity, 0 );
 
        g_currentMap = &g_map;
+
+       // restart VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Restart();
 }
 
 extern void ConstructRegionBrushes( scene::Node * brushes[6], const Vector3 &region_mins, const Vector3 &region_maxs );
@@ -1583,7 +1594,13 @@ tryDecompile:
  */
 bool Map_SaveFile( const char* filename ){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" );
-       return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+       bool success = MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+       if ( success ) {
+               // refresh VFS to apply new pak filtering based on mapname
+               // needed for daemon DPK VFS
+               VFS_Refresh();
+       }
+       return success;
 }
 
 //
index e30f1035112e8eaa1122c0fd4483fda619177509..c97044e3c758341fff0a65cee55dedea5a2263b6 100644 (file)
@@ -2359,9 +2359,8 @@ void TextureBrowser_pasteTag(){
        BuildStoreAvailableTags( g_TextureBrowser.m_available_store, g_TextureBrowser.m_assigned_store, g_TextureBrowser.m_all_tags, &g_TextureBrowser );
 }
 
-void RefreshShaders(){
+void TextureBrowser_RefreshShaders(){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Shaders" );
-       VFS_Refresh();
        GlobalShaderSystem().refresh();
        UpdateAllWindows();
        GtkTreeSelection* selection = gtk_tree_view_get_selection((GtkTreeView*)GlobalTextureBrowser().m_treeViewTree);
@@ -2567,7 +2566,7 @@ void TextureBrowser_Construct(){
        GlobalCommands_insert( "DeleteTag", FreeCaller<TextureBrowser_deleteTag>() );
        GlobalCommands_insert( "CopyTag", FreeCaller<TextureBrowser_copyTag>() );
        GlobalCommands_insert( "PasteTag", FreeCaller<TextureBrowser_pasteTag>() );
-       GlobalCommands_insert( "RefreshShaders", FreeCaller<RefreshShaders>() );
+       GlobalCommands_insert( "RefreshShaders", FreeCaller<VFS_Refresh>() );
        GlobalToggles_insert( "ShowInUse", FreeCaller<TextureBrowser_ToggleHideUnused>(), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) );
        GlobalCommands_insert( "ShowAllTextures", FreeCaller<TextureBrowser_showAll>(), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) );
        GlobalCommands_insert( "ToggleTextures", FreeCaller<TextureBrowser_toggleShow>(), Accelerator( 'T' ) );
index 3a872014c2925a410f1a01ff7106ca82cd431317..edc67b221f7c217004d0716dab2f373e5a9956a7 100644 (file)
@@ -59,4 +59,6 @@ void TextureBrowser_setBackgroundColour( TextureBrowser& textureBrowser, const V
 void TextureBrowser_addActiveShadersChangedCallback( const SignalHandler& handler );
 void TextureBrowser_addShadersRealiseCallback( const SignalHandler& handler );
 
+void TextureBrowser_RefreshShaders();
+
 #endif