- fixed sorting of texture sets in browsers

- discarding first texture because it cannot be used (also first flat in case of mixed textures/flats)
This commit is contained in:
codeimp 2008-10-02 18:53:07 +00:00
parent a6fb612c55
commit bf318ac472
5 changed files with 20 additions and 6 deletions

View file

@ -33,7 +33,7 @@ using System.Collections.Specialized;
namespace CodeImp.DoomBuilder.Config
{
internal sealed class MatchingTextureSet : TextureSet, IFilledTextureSet
internal sealed class MatchingTextureSet : TextureSet, IFilledTextureSet, IComparable<MatchingTextureSet>
{
#region ================== Variables
@ -183,6 +183,12 @@ namespace CodeImp.DoomBuilder.Config
{
return regex.IsMatch(image.Name.ToUpperInvariant());
}
// This compares it for sorting
public int CompareTo(MatchingTextureSet other)
{
return string.Compare(this.name, other.name);
}
#endregion
}

View file

@ -177,6 +177,9 @@ namespace CodeImp.DoomBuilder.Data
foreach(DefinedTextureSet ts in General.Map.ConfigSettings.TextureSets)
texturesets.Add(new MatchingTextureSet(ts));
// Sort the texture sets
texturesets.Sort();
// Other textures set
othertextures = new OthersTextureSet();
@ -565,6 +568,7 @@ namespace CodeImp.DoomBuilder.Data
PatchNames pnames = new PatchNames();
PatchNames newpnames;
int counter = 0;
long firsttexture = 0;
// Go for all opened containers
foreach(DataReader dr in containers)
@ -587,6 +591,7 @@ namespace CodeImp.DoomBuilder.Data
if(!textures.ContainsKey(img.LongName)) texturenames.Add(img.Name);
textures.Remove(img.LongName);
textures.Add(img.LongName, img);
if(firsttexture == 0) firsttexture = img.LongName;
counter++;
// Also add as flat when using mixed resources
@ -603,6 +608,11 @@ namespace CodeImp.DoomBuilder.Data
}
}
// The first texture cannot be used, because in the game engine it
// has index 0 which means "no texture", so remove it from the list.
textures.Remove(firsttexture);
if(General.Map.Config.MixTexturesFlats) flats.Remove(firsttexture);
// Output info
return counter;
}

View file

@ -158,7 +158,7 @@ namespace CodeImp.DoomBuilder.Data
LoadTexturesRange(rangestart, rangeend, ref images, pnames);
}
}
// Return result
return images;
}

View file

@ -67,8 +67,7 @@ namespace CodeImp.DoomBuilder.Windows
item.ImageIndex = 0;
}
// Sort and add other textures set
texturesets.Sort();
// Add other textures set
item = texturesets.Items.Add(General.Map.Data.OthersTextureSet.Name);
item.Tag = General.Map.Data.OthersTextureSet;
item.ImageIndex = 1;

View file

@ -67,8 +67,7 @@ namespace CodeImp.DoomBuilder.Windows
item.ImageIndex = 0;
}
// Sort and add other textures set
texturesets.Sort();
// Add other textures set
item = texturesets.Items.Add(General.Map.Data.OthersTextureSet.Name);
item.Tag = General.Map.Data.OthersTextureSet;
item.ImageIndex = 1;