From d42f33594853e00c1838b84e808a2f04faabc62d Mon Sep 17 00:00:00 2001
From: spherallic <spherallic@gmail.com>
Date: Tue, 18 Jun 2024 14:30:38 +0200
Subject: [PATCH] Sort TEXTURES into their own category again, take subfolders
 into account for texture count

---
 Source/Core/Data/TEXTURESImage.cs         |  4 ++--
 Source/Core/Windows/TextureBrowserForm.cs | 18 +++++++++++-------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/Source/Core/Data/TEXTURESImage.cs b/Source/Core/Data/TEXTURESImage.cs
index f15845ded..9d0ed0730 100755
--- a/Source/Core/Data/TEXTURESImage.cs
+++ b/Source/Core/Data/TEXTURESImage.cs
@@ -70,8 +70,8 @@ namespace CodeImp.DoomBuilder.Data
 
 			//mxd
 			SetName(name);
-			this.virtualname = (!string.IsNullOrEmpty(virtualpath) ? virtualpath : "[TEXTURES]") + Path.AltDirectorySeparatorChar + this.name;
-			
+			this.virtualname = "[TEXTURES]" + Path.AltDirectorySeparatorChar + (!string.IsNullOrEmpty(virtualpath) ? virtualpath + Path.AltDirectorySeparatorChar : "") + this.name;
+
 			// We have no destructor
 			GC.SuppressFinalize(this);
 		}
diff --git a/Source/Core/Windows/TextureBrowserForm.cs b/Source/Core/Windows/TextureBrowserForm.cs
index 08c7ab5fe..f4e199271 100755
--- a/Source/Core/Windows/TextureBrowserForm.cs
+++ b/Source/Core/Windows/TextureBrowserForm.cs
@@ -341,23 +341,27 @@ namespace CodeImp.DoomBuilder.Windows
 		}
 
 		//mxd
-		private void SetItemsCount(TreeNode node) 
+		private int SetItemsCount(TreeNode node) 
 		{
 			ResourceTextureSet ts = ((TreeNodeData)node.Tag).Set as ResourceTextureSet;
 			if(ts == null) throw new Exception("Expected ResourceTextureSet, but got null...");
-			
-			if(node.Parent != null && General.Map.Config.MixTexturesFlats)
+			int texcount = 0;
+
+			foreach (TreeNode child in node.Nodes) texcount += SetItemsCount(child);
+
+			if (node.Parent != null && General.Map.Config.MixTexturesFlats)
 			{
 				ts.MixTexturesAndFlats();
-				if(ts.Textures.Count > 0) node.Text += " [" + ts.Textures.Count + "]";
+				texcount += ts.Textures.Count;
+				if (texcount > 0) node.Text += " [" + texcount + "]";
+				return texcount;
 			} 
 			else
 			{
-				int texcount = (browseflats ? ts.Flats.Count : ts.Textures.Count);
+				texcount = (browseflats ? ts.Flats.Count : ts.Textures.Count);
 				if(texcount > 0) node.Text += " [" + texcount + "]";
+				return texcount;
 			}
-
-			foreach(TreeNode child in node.Nodes) SetItemsCount(child);
 		}
 
 		// Selection changed
-- 
GitLab