TTimo / GtkRadiant

The open source, cross platform level editor for idtech games
http://icculus.org/gtkradiant/
Other
582 stars 152 forks source link

do not list empty shader/texture directories #563

Closed illwieckz closed 6 years ago

illwieckz commented 6 years ago

Previously, GtkRadiant was displaying a directory for every shader or texture dirname even if there was no existing shader neither texture using this dirname. The first case happens for example when a name is provided in shaderlist but no shader script is there, the second case happens when a texture directory only contains invalid files like unknown formats or blacklisted suffixes (gloss, specular etc.).

This code adds two functions to know if a shader dirname or texture dirname contains nothing and obviously use them.

Some already existing code was moved in some new functions, for example the texture name validation code was moved to a dedicated function, used two times: when looking for non empty directories, or when loading current displayed directories.

I added some more well-known forbidden prefixes (for gloss and normal maps and preview images).

One obvious warning was fixed (complaining about unused affectation because the affected value was only used in debug build).

I also improved the shader dir checking, before it was doing something like that:

if path in ["scripts/eerie.shader", "textures/eerie/blackness"]

now it's doing something like that:

if "/" + path + "." in "scripts/eerie.shader" or "textures/eerie/blackness".startswith("textures/" + path)

Also, I fixed the recognition of "eerie" in "scripts/eerie.shader" since the function was receiving it as "eerie/" leading to "eerie/.shader" look out.

Previously, GtkRadiant was still loading unapplicable shaders (those not starting with "textures/" prefixes) even if they were never displayed in menu or texture browser, that's now fixed.

There is one known bug but it's not a regression so it must not prevent merging: if a texture dir contains a preview image for a shader name in a shader dir with a different name than the texture dir name, the texture dir name will be displayed but the preview image will not since being known as a preview image, leading to the only one case where an empty directory can still be listed.

Pan7 commented 6 years ago

What do you think about printing the filtered directories to the console?

illwieckz commented 6 years ago

@Pan7: What do you think about printing the filtered directories to the console?

Not a bad idea :-)

illwieckz commented 6 years ago

@Pan7 I just added a commit to do that