- Improved performance of the texture browser. This should significantly reduce the times it takes to open the texture browser when using large texture sets

This commit is contained in:
biwa 2019-05-31 00:20:12 +02:00
parent 22df516e11
commit 48af52afcf
7 changed files with 26 additions and 7 deletions

View file

@ -58,6 +58,8 @@ namespace CodeImp.DoomBuilder.Data
protected bool ismasked; //mxd. If true, has pixels with zero alpha
protected bool hasLongName; //mxd. Texture name is longer than DataManager.CLASIC_IMAGE_NAME_LENGTH
protected bool hasPatchWithSameName; //mxd
protected int namewidth; // biwa
protected int shortnamewidth; // biwa
//mxd. Hashing
private static int hashcounter;
@ -123,6 +125,8 @@ namespace CodeImp.DoomBuilder.Data
public virtual float ScaledHeight { get { return (float)Math.Round(height * scale.y); } }
public virtual Vector2D Scale { get { return scale; } }
public bool WorldPanning { get { return worldpanning; } }
public int NameWidth { get { return namewidth; } } // biwa
public int ShortNameWidth { get { return shortnamewidth; } } // biwa
#endregion
@ -206,6 +210,8 @@ namespace CodeImp.DoomBuilder.Data
this.virtualname = name; //mxd
this.displayname = name; //mxd
this.longname = Lump.MakeLongName(name); //mxd
ComputeNamesWidth(); // biwa
}
// This unloads the image
@ -219,6 +225,15 @@ namespace CodeImp.DoomBuilder.Data
}
}
// biwa. Computing the widths in the constructor of ImageBrowserItem accumulates to taking forever when loading many images,
// like when showing the texture browser of huge texture sets like OTEX
internal void ComputeNamesWidth()
{
//mxd. Calculate names width
namewidth = (int)Math.Ceiling(General.Interface.MeasureString(name, SystemFonts.MessageBoxFont, 10000, StringFormat.GenericTypographic).Width) + 6;
shortnamewidth = (int)Math.Ceiling(General.Interface.MeasureString(shortname, SystemFonts.MessageBoxFont, 10000, StringFormat.GenericTypographic).Width) + 6;
}
// This returns the bitmap image
public Bitmap GetBitmap()
{