]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/texwindow.cpp
do not rename() .map symlinks, but just overwrite them
[xonotic/netradiant.git] / radiant / texwindow.cpp
index c791e17fe9f306e22b1d38bb951378ecadad5101..18311b40262299d04c2553168b2f1071d9b14da1 100644 (file)
@@ -823,6 +823,14 @@ void operator()( const char* name ) const {
 };
 
 void TextureDirectory_loadTexture( const char* directory, const char* texture ){
+       // Doom3-like dds/ prefix (used by DarkPlaces).
+       // When we list dds/textures/ folder,
+       // store the texture names without dds/ prefix.
+       if ( !strncmp( "dds/", directory, 4 ) )
+       {
+               directory = &directory[ 4 ];
+       }
+
        StringOutputStream name( 256 );
        name << directory << StringRange( texture, path_get_filename_base_end( texture ) );
 
@@ -865,6 +873,9 @@ void TextureBrowser_ShowDirectory( TextureBrowser& textureBrowser, const char* d
                {
                        LoadShaderVisitor visitor;
                        archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "textures/" );
+
+                       // Doom3-like dds/ prefix (used by DarkPlaces).
+                       archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "dds/textures/" );
                }
                else if ( extension_equal_i( path_get_extension( directory ), "wad" ) )
                {
@@ -886,7 +897,19 @@ void TextureBrowser_ShowDirectory( TextureBrowser& textureBrowser, const char* d
                        StringOutputStream dirstring( 64 );
                        dirstring << "textures/" << directory;
 
-                       Radiant_getImageModules().foreachModule( LoadTexturesByTypeVisitor( dirstring.c_str() ) );
+                       {
+                               LoadTexturesByTypeVisitor visitor( dirstring.c_str() );
+                               Radiant_getImageModules().foreachModule( visitor );
+                       }
+
+                       // Doom3-like dds/ prefix (used by DarkPlaces).
+                       dirstring.clear();
+                       dirstring << "dds/textures/" << directory;
+
+                       {
+                               LoadTexturesByTypeVisitor visitor( dirstring.c_str() );
+                               Radiant_getImageModules().foreachModule( visitor );
+                       }
                }
        }
 
@@ -913,6 +936,15 @@ void TextureBrowser_ShowTagSearchResult( TextureBrowser& textureBrowser, const c
                        LoadTexturesByTypeVisitor visitor( dirstring.c_str() );
                        Radiant_getImageModules().foreachModule( visitor );
                }
+
+               // Doom3-like dds/ prefix (used by DarkPlaces).
+               dirstring.clear();
+               dirstring << "dds/textures/" << directory;
+
+               {
+                       LoadTexturesByTypeVisitor visitor( dirstring.c_str() );
+                       Radiant_getImageModules().foreachModule( visitor );
+               }
        }
 
        // we'll display the newly loaded textures + all the ones already in use
@@ -1517,7 +1549,7 @@ gboolean TextureBrowser_size_allocate( ui::Widget widget, GtkAllocation* allocat
        return FALSE;
 }
 
-gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){
+void TextureBrowser_redraw( TextureBrowser* textureBrowser ){
        if ( glwidget_make_current( textureBrowser->m_gl_widget ) != FALSE ) {
                GlobalOpenGL_debugAssertNoErrors();
                TextureBrowser_evaluateHeight( *textureBrowser );
@@ -1525,6 +1557,10 @@ gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, Textur
                GlobalOpenGL_debugAssertNoErrors();
                glwidget_swap_buffers( textureBrowser->m_gl_widget );
        }
+}
+
+gboolean TextureBrowser_expose( ui::Widget widget, GdkEventExpose* event, TextureBrowser* textureBrowser ){
+       TextureBrowser_redraw( textureBrowser );
        return FALSE;
 }
 
@@ -2396,6 +2432,7 @@ void TextureBrowser_showGLWidget(){
                textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hframe, TRUE, TRUE, 0, ui::Packing::START );
                textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hfiller, FALSE, FALSE, 0, ui::Packing::START );
                textureBrowser.m_vframe.set_child_packing( textureBrowser.m_gl_widget, TRUE, TRUE, 0, ui::Packing::START );
+
                textureBrowser.m_gl_widget.show();
        }
 }
@@ -2408,11 +2445,14 @@ void TextureBrowser_hideGLWidget(){
                textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hframe, FALSE, FALSE, 0, ui::Packing::END );
                textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hfiller, TRUE, TRUE, 0, ui::Packing::START);
                textureBrowser.m_vframe.set_child_packing( textureBrowser.m_gl_widget, FALSE, FALSE, 0, ui::Packing::END );
-               GdkEventExpose event = {};
-               TextureBrowser_expose( GlobalTextureBrowser().m_gl_widget, &event, &GlobalTextureBrowser() );
+
                // The hack needs the GL widget to not be hidden to work,
                // so resizing it triggers the redraw of it with the new size.
                // GlobalTextureBrowser().m_gl_widget.hide();
+
+               // Trigger the redraw.
+               TextureBrowser_redraw( &GlobalTextureBrowser() );
+               ui::process();
        }
 }
 #endif // WORKAROUND_MACOS_GTK2_GLWIDGET