make “hide empty directories” an option

This commit is contained in:
Thomas Debesse 2017-09-02 20:04:45 +02:00
parent e9e095b4c6
commit b1c4fb1304
5 changed files with 28 additions and 2 deletions

View file

@ -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" ) );

View file

@ -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();

View file

@ -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 );

View file

@ -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;

View file

@ -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 ) );
}