From b1c4fb1304346442cf28f22e520b33eed4354360 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 2 Sep 2017 20:04:45 +0200 Subject: [PATCH] =?UTF-8?q?make=20=E2=80=9Chide=20empty=20directories?= =?UTF-8?q?=E2=80=9D=20an=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- radiant/mainframe.cpp | 20 ++++++++++++++++++++ radiant/mainframe.h | 2 ++ radiant/preferences.cpp | 3 +++ radiant/preferences.h | 1 + radiant/texwindow.cpp | 4 ++-- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index ffa42a86..d8bfeb9d 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -552,6 +552,7 @@ gint HandleCommand( GtkWidget *widget, gpointer data ){ case ID_TEXTURES_LOAD: g_pParentWnd->OnTexturesLoad(); break; case ID_TEXTURES_RELOADSHADERS: g_pParentWnd->OnTexturesReloadshaders(); break; case ID_TEXTURES_SHADERS_SHOW: g_pParentWnd->OnTexturesShadersShow(); break; + case ID_TEXTURES_EMPTYDIRS_HIDE: g_pParentWnd->OnTexturesEmptyDirsHide(); break; case ID_TEXTURES_TEXTUREWINDOWSCALE_200: case ID_TEXTURES_TEXTUREWINDOWSCALE_100: case ID_TEXTURES_TEXTUREWINDOWSCALE_50: @@ -1401,6 +1402,9 @@ void MainFrame::create_main_menu( GtkWidget *window, GtkWidget *vbox ){ item = create_check_menu_item_with_mnemonic( menu, _( "shaderlist.txt only" ), G_CALLBACK( HandleCommand ), ID_TEXTURES_SHADERLISTONLY, FALSE ); g_object_set_data( G_OBJECT( window ), "menu_textures_shaderlistonly", item ); + item = create_check_menu_item_with_mnemonic( menu, _( "Hide empty directories" ), + G_CALLBACK( HandleCommand ), ID_TEXTURES_EMPTYDIRS_HIDE, FALSE ); + g_object_set_data( G_OBJECT( window ), "menu_textures_emptydirs_hide", item ); item = menu_separator( menu ); menu_in_menu = create_menu_in_menu_with_mnemonic( menu, _( "Texture Directories" ) ); @@ -3107,6 +3111,8 @@ void MainFrame::Create(){ g_bIgnoreCommands++; item = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_textures_shaders_show" ) ); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), g_PrefsDlg.m_bShowShaders ? TRUE : FALSE ); + item = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_textures_emptydirs_hide" ) ); + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), g_PrefsDlg.m_bHideEmptyDirs ? TRUE : FALSE ); item = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_textures_shaderlistonly" ) ); gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), g_PrefsDlg.m_bTexturesShaderlistOnly ? TRUE : FALSE ); g_bIgnoreCommands--; @@ -5950,6 +5956,20 @@ void MainFrame::OnTexturesReloadshaders(){ ClearGSList( texdirs ); } +void MainFrame::OnTexturesEmptyDirsHide(){ + g_PrefsDlg.m_bHideEmptyDirs ^= 1; + GtkWidget *item = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_textures_emptydirs_hide" ) ); + g_bIgnoreCommands++; + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( item ), g_PrefsDlg.m_bHideEmptyDirs ? TRUE : FALSE ); + g_bIgnoreCommands--; + + GSList *texdirs = NULL; + FillTextureList( &texdirs ); + FillTextureMenu( texdirs ); + FillTextureDirListWidget( texdirs ); + ClearGSList( texdirs ); +} + void MainFrame::OnTexturesShadersShow(){ g_PrefsDlg.m_bShowShaders ^= 1; GtkWidget *item = GTK_WIDGET( g_object_get_data( G_OBJECT( m_pWidget ), "menu_textures_shaders_show" ) ); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index 87e5a35c..cdca6af2 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -216,6 +216,7 @@ struct SKeyInfo #define ID_VIEW_HIDESHOW_SHOWHIDDEN 33007 #define ID_TEXTURES_SHADERS_SHOW 33008 //#define ID_SELECTION_CSGADD 33009 +#define ID_TEXTURES_EMPTYDIRS_HIDE 33010 #define ID_SELECTION_CSGMERGE 33011 #define ID_TEXTURES_FLUSH_UNUSED 33014 #define ID_DROP_GROUP_REMOVE 33016 @@ -863,6 +864,7 @@ void OnViewCrosshair(); void OnViewHideshowHideselected(); void OnViewHideshowShowhidden(); void OnTexturesShadersShow(); +void OnTexturesEmptyDirsHide(); void OnViewGroups(); void OnDropGroupAddtoWorld(); void OnDropGroupName(); diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 4bb3c681..f67129cb 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -119,6 +119,7 @@ #define TEXTURESUBSET_KEY "UseTextureSubsetLoading" #define TEXTUREQUALITY_KEY "TextureQuality" #define SHOWSHADERS_KEY "ShowShaders" +#define HIDEEMPTYDIRS_KEY "HideEmptyDirs" #define SHADERTEST_KEY "ShaderTest" #define GLLIGHTING_KEY "UseGLLighting" #define LOADSHADERS_KEY "LoadShaders" @@ -644,6 +645,7 @@ PrefsDlg::PrefsDlg (){ m_bSelectWholeEntities = TRUE; m_nTextureQuality = 3; m_bShowShaders = TRUE; + m_bHideEmptyDirs = FALSE; m_bGLLighting = FALSE; m_nShader = 0; m_nUndoLevels = 30; @@ -3076,6 +3078,7 @@ void PrefsDlg::LoadPrefs(){ mLocalPrefs.GetPref( SWITCHCLIP_KEY, &m_bSwitchClip, TRUE ); mLocalPrefs.GetPref( SELWHOLEENTS_KEY, &m_bSelectWholeEntities, TRUE ); mLocalPrefs.GetPref( SHOWSHADERS_KEY, &m_bShowShaders, TRUE ); + mLocalPrefs.GetPref( HIDEEMPTYDIRS_KEY, &m_bHideEmptyDirs, FALSE ); mLocalPrefs.GetPref( GLLIGHTING_KEY, &m_bGLLighting, FALSE ); mLocalPrefs.GetPref( NOSTIPPLE_KEY, &m_bNoStipple, FALSE ); mLocalPrefs.GetPref( UNDOLEVELS_KEY, &m_nUndoLevels, 30 ); diff --git a/radiant/preferences.h b/radiant/preferences.h index ac6ca9d0..1cb275b6 100644 --- a/radiant/preferences.h +++ b/radiant/preferences.h @@ -636,6 +636,7 @@ bool m_bTextureScrollbar; bool m_bDisplayLists; bool m_bAntialiasedPointsAndLines; // Fishman - Add antialiazed points and lines support. 09/03/00 bool m_bShowShaders; +bool m_bHideEmptyDirs; int m_nShader; bool m_bNoStipple; int m_nUndoLevels; diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 08839db2..eef1cdaa 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -681,7 +681,7 @@ void FillTextureList( GSList** pArray ) // Hydra: erm, this didn't used to do anything except leak memory... // For Halflife support this is required to work however. // g_slist_append(texdirs, p->data); - if ( IsDirContainingTextures( (char*)p->data ) ) + if ( !g_PrefsDlg.m_bHideEmptyDirs || IsDirContainingTextures( (char*)p->data ) ) { texdirs = g_slist_append( texdirs, g_strdup( (char *)p->data ) ); } @@ -719,7 +719,7 @@ void FillTextureList( GSList** pArray ) } if ( !found ) { - if( QERApp_IsDirContainingShaders( shaderfile ) ) + if( !g_PrefsDlg.m_bHideEmptyDirs || QERApp_IsDirContainingShaders( shaderfile ) ) { texdirs = g_slist_prepend( texdirs, g_strdup( shaderfile ) ); }