Fix and greatly simplify texture group selection setting for texture browser

This commit is contained in:
spherallic 2024-06-17 22:59:54 +02:00
parent c2d8a09cc7
commit 76d969e592

View file

@ -32,7 +32,7 @@ namespace CodeImp.DoomBuilder.Windows
internal partial class TextureBrowserForm : DelayedForm
{
//mxd. Constants
private const string ALL_IMAGES = "[All]";
private const string ALL_IMAGES = "All";
//mxd. Structs
private struct TreeNodeData
@ -134,45 +134,16 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Should we bother finding the correct texture set?
if(General.Settings.LocateTextureGroup)
{
//mxd. Get the previously selected texture set
string prevtextureset = General.Settings.ReadSetting("windows." + configname + ".textureset", "");
TreeNode match;
// When texture set name is empty, select "All" texture set
if(string.IsNullOrEmpty(prevtextureset))
{
match = tvTextureSets.Nodes[tvTextureSets.Nodes.Count - 1];
}
else
{
match = FindNodeByName(tvTextureSets.Nodes, prevtextureset);
}
if(match != null)
{
IFilledTextureSet set = ((TreeNodeData)match.Tag).Set;
foreach(ImageData img in (browseflats ? set.Flats : set.Textures))
{
if(img.LongName == longname)
{
selectedset = match;
break;
}
}
}
//mxd. If the selected texture was not found in the last-selected set, try finding it in the other sets
if(selectedset == null && selecttexture != "-")
if(selecttexture != "-")
{
foreach(TreeNode n in tvTextureSets.Nodes)
{
selectedset = FindTextureByLongName(n, longname);
if(selectedset != null) break;
}
}
if (selectedset != null)
break;
//mxd. Texture still not found? Then just select the last used set
if(selectedset == null && match != null) selectedset = match;
}
}
}
//mxd. Select the found set or "All", if none were found