mirror of
https://github.com/TTimo/GtkRadiant.git
synced 2024-11-10 07:11:54 +00:00
do not list empty shader dir
This commit is contained in:
parent
69972f9458
commit
41ed9c2ce5
3 changed files with 40 additions and 2 deletions
|
@ -111,6 +111,9 @@ typedef void ( WINAPI * PFN_RELOADSHADERS )();
|
|||
// load all shaders in a given directory
|
||||
// this will scan the list of in-memory shaders, and load the related qtexture_t if needed
|
||||
typedef int ( WINAPI * PFN_LOADSHADERSFROMDIR )( const char* path );
|
||||
// count all shaders in a given directory
|
||||
// this will scan the list of in-memory shaders
|
||||
typedef bool ( WINAPI * PFN_ISDIRCONTAININGSHADER )( const char* path );
|
||||
// load a shader file (ie a set of shaders)
|
||||
// after LoadShaderFile shaders will be in memory, next step is to load the qtexture_t Radiant uses to represent them
|
||||
// if a shader with the same name exists, new one will not be loaded - don't use this to refresh the shaders!
|
||||
|
@ -178,6 +181,7 @@ struct _QERShadersTable
|
|||
PFN_FREESHADERS m_pfnFreeShaders;
|
||||
PFN_RELOADSHADERS m_pfnReloadShaders;
|
||||
PFN_LOADSHADERSFROMDIR m_pfnLoadShadersFromDir;
|
||||
PFN_ISDIRCONTAININGSHADER m_pfnIsDirContainingShaders;
|
||||
PFN_LOADSHADERFILE m_pfnLoadShaderFile;
|
||||
PFN_RELOADSHADERFILE m_pfnReloadShaderFile;
|
||||
PFN_HASSHADER m_pfnHasShader;
|
||||
|
@ -219,7 +223,7 @@ struct _QERShadersTable
|
|||
#define QERApp_ColorShader_ForName __SHADERSTABLENAME.m_pfnColorShader_ForName
|
||||
#define QERApp_Shader_ForName_NoLoad __SHADERSTABLENAME.m_pfnShader_ForName_NoLoad
|
||||
#define QERApp_LoadShadersFromDir __SHADERSTABLENAME.m_pfnLoadShadersFromDir
|
||||
#define QERApp_LoadShadersFromDir __SHADERSTABLENAME.m_pfnLoadShadersFromDir
|
||||
#define QERApp_IsDirContainingShaders __SHADERSTABLENAME.m_pfnIsDirContainingShaders
|
||||
#define QERApp_CreateShader_ForTextureName __SHADERSTABLENAME.m_pfnCreateShader_ForTextureName
|
||||
#define QERApp_GetActiveShaderCount __SHADERSTABLENAME.m_pfnGetActiveShaderCount
|
||||
#define QERApp_ActiveShaders_SetDisplayed __SHADERSTABLENAME.m_pfnActiveShaders_SetDisplayed
|
||||
|
|
|
@ -410,6 +410,16 @@ int WINAPI QERApp_LoadShadersFromDir( const char *path ){
|
|||
for ( int i = 0; i < nSize; i++ )
|
||||
{
|
||||
CShader *pShader = reinterpret_cast < CShader * >( g_Shaders[i] );
|
||||
|
||||
// does not uselessly load shader with path not starting with "textures/"
|
||||
// they will not be displayed by texture browser, because they can't be
|
||||
// applied to a surface
|
||||
if ( !g_str_has_prefix( pShader->getName(), "textures/" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// this is basically doing:
|
||||
// if path in ["scripts/eerie.shader", "textures/eerie/blackness"]
|
||||
if ( strstr( pShader->getShaderFileName(), path ) || strstr( pShader->getName(), path ) ) {
|
||||
count++;
|
||||
// request the shader, this will load the texture if needed and set "inuse"
|
||||
|
@ -430,6 +440,25 @@ int WINAPI QERApp_LoadShadersFromDir( const char *path ){
|
|||
return count;
|
||||
}
|
||||
|
||||
bool WINAPI QERApp_IsDirContainingShaders( const char *path ){
|
||||
int nSize = g_Shaders.GetSize();
|
||||
// exclude shaders that are not starting with "textures/"
|
||||
// they will not be displayed and are not applicable to surfaces
|
||||
// exclude shaders from other paths,
|
||||
// they are not the ones we are looking for
|
||||
gchar* prefix = g_strconcat("textures/", path, NULL);
|
||||
for ( int i = 0; i < nSize; i++ )
|
||||
{
|
||||
CShader *pShader = reinterpret_cast < CShader * >( g_Shaders[i] );
|
||||
if ( g_str_has_prefix( pShader->getName(), prefix ) ) {
|
||||
g_free(prefix);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
g_free(prefix);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CShader::Parse(){
|
||||
char *token = g_ScripLibTable.m_pfnToken();
|
||||
|
||||
|
@ -924,6 +953,7 @@ bool CSynapseClientShaders::RequestAPI( APIDescriptor_t *pAPI ){
|
|||
pTable->m_pfnFreeShaders = QERApp_FreeShaders;
|
||||
pTable->m_pfnReloadShaders = QERApp_ReloadShaders;
|
||||
pTable->m_pfnLoadShadersFromDir = QERApp_LoadShadersFromDir;
|
||||
pTable->m_pfnIsDirContainingShaders = QERApp_IsDirContainingShaders;
|
||||
pTable->m_pfnReloadShaderFile = QERApp_ReloadShaderFile;
|
||||
pTable->m_pfnLoadShaderFile = QERApp_LoadShaderFile;
|
||||
pTable->m_pfnHasShader = QERApp_HasShader;
|
||||
|
|
|
@ -591,8 +591,11 @@ void FillTextureList( GSList** pArray )
|
|||
}
|
||||
|
||||
if ( !found ) {
|
||||
if( QERApp_IsDirContainingShaders( shaderfile ) )
|
||||
{
|
||||
texdirs = g_slist_prepend( texdirs, g_strdup( shaderfile ) );
|
||||
}
|
||||
}
|
||||
|
||||
free( l_shaderfiles->data );
|
||||
l_shaderfiles = g_slist_remove( l_shaderfiles, l_shaderfiles->data );
|
||||
|
@ -784,6 +787,7 @@ void Texture_ShowDirectory_by_path( const char* pPath )
|
|||
( the GL textures are not flushed though)
|
||||
==============
|
||||
*/
|
||||
|
||||
void Texture_ShowDirectory(){
|
||||
char name[1024];
|
||||
char dirstring[1024];
|
||||
|
|
Loading…
Reference in a new issue