- 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

@ -30,8 +30,6 @@ namespace CodeImp.DoomBuilder.Controls
private bool showfullname; private bool showfullname;
protected ImageBrowserItemType itemtype; protected ImageBrowserItemType itemtype;
private string tooltip; private string tooltip;
private int namewidth;
private int shortnamewidth;
private static Brush bgbrush, fgbrush_used, fgbrush_unused, selectedbgbrush, selectionbrush, selectiontextbrush, bgbrush_alpha; private static Brush bgbrush, fgbrush_used, fgbrush_unused, selectedbgbrush, selectionbrush, selectiontextbrush, bgbrush_alpha;
private static Color bgcolor; private static Color bgcolor;
@ -48,7 +46,7 @@ namespace CodeImp.DoomBuilder.Controls
public virtual bool IsPreviewLoaded { get { return icon.IsPreviewLoaded; } } public virtual bool IsPreviewLoaded { get { return icon.IsPreviewLoaded; } }
public bool ShowFullName { set { showfullname = value; } get { return showfullname && (!(icon is PK3FileImage) || !((PK3FileImage)icon).IsBadForLongTextureNames); } } public bool ShowFullName { set { showfullname = value; } get { return showfullname && (!(icon is PK3FileImage) || !((PK3FileImage)icon).IsBadForLongTextureNames); } }
public virtual string TextureName { get { return (ShowFullName ? icon.Name : icon.ShortName); } } public virtual string TextureName { get { return (ShowFullName ? icon.Name : icon.ShortName); } }
public virtual int TextureNameWidth { get { return (ShowFullName ? namewidth : shortnamewidth); } } public virtual int TextureNameWidth { get { return ShowFullName ? icon.NameWidth : icon.ShortNameWidth; } } // biwa
public string ToolTip { get { return tooltip; } } public string ToolTip { get { return tooltip; } }
#endregion #endregion
@ -65,10 +63,6 @@ namespace CodeImp.DoomBuilder.Controls
this.showfullname = showfullname; //mxd this.showfullname = showfullname; //mxd
this.imageloaded = icon.IsPreviewLoaded; //mxd this.imageloaded = icon.IsPreviewLoaded; //mxd
this.tooltip = tooltip; //mxd this.tooltip = tooltip; //mxd
//mxd. Calculate names width
this.namewidth = (int)Math.Ceiling(General.Interface.MeasureString(icon.Name, SystemFonts.MessageBoxFont, 10000, StringFormat.GenericTypographic).Width)+6;
this.shortnamewidth = (int)Math.Ceiling(General.Interface.MeasureString(icon.ShortName, SystemFonts.MessageBoxFont, 10000, StringFormat.GenericTypographic).Width)+6;
} }
#endregion #endregion

View file

@ -113,6 +113,8 @@ namespace CodeImp.DoomBuilder.Data
base.SetName(name); base.SetName(name);
this.virtualname = "[CAMERA TEXTURES]" + Path.AltDirectorySeparatorChar + name; this.virtualname = "[CAMERA TEXTURES]" + Path.AltDirectorySeparatorChar + name;
ComputeNamesWidth(); // biwa
} }
#endregion #endregion

View file

@ -145,6 +145,8 @@ namespace CodeImp.DoomBuilder.Data
this.longname = Lump.MakeLongName(this.name, uselongtexturenames); this.longname = Lump.MakeLongName(this.name, uselongtexturenames);
this.filepathname = filepathname; this.filepathname = filepathname;
ComputeNamesWidth(); // biwa
} }
// This loads the image // This loads the image

View file

@ -83,6 +83,8 @@ namespace CodeImp.DoomBuilder.Data
this.displayname = this.name; this.displayname = this.name;
this.shortname = this.name; this.shortname = this.name;
this.longname = Lump.MakeLongName(this.name); this.longname = Lump.MakeLongName(this.name);
ComputeNamesWidth(); // biwa
} }
internal void ApplySettings(ImageData overridden) internal void ApplySettings(ImageData overridden)

View file

@ -58,6 +58,8 @@ namespace CodeImp.DoomBuilder.Data
protected bool ismasked; //mxd. If true, has pixels with zero alpha 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 hasLongName; //mxd. Texture name is longer than DataManager.CLASIC_IMAGE_NAME_LENGTH
protected bool hasPatchWithSameName; //mxd protected bool hasPatchWithSameName; //mxd
protected int namewidth; // biwa
protected int shortnamewidth; // biwa
//mxd. Hashing //mxd. Hashing
private static int hashcounter; 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 float ScaledHeight { get { return (float)Math.Round(height * scale.y); } }
public virtual Vector2D Scale { get { return scale; } } public virtual Vector2D Scale { get { return scale; } }
public bool WorldPanning { get { return worldpanning; } } public bool WorldPanning { get { return worldpanning; } }
public int NameWidth { get { return namewidth; } } // biwa
public int ShortNameWidth { get { return shortnamewidth; } } // biwa
#endregion #endregion
@ -206,6 +210,8 @@ namespace CodeImp.DoomBuilder.Data
this.virtualname = name; //mxd this.virtualname = name; //mxd
this.displayname = name; //mxd this.displayname = name; //mxd
this.longname = Lump.MakeLongName(name); //mxd this.longname = Lump.MakeLongName(name); //mxd
ComputeNamesWidth(); // biwa
} }
// This unloads the image // 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 // This returns the bitmap image
public Bitmap GetBitmap() public Bitmap GetBitmap()
{ {

View file

@ -104,6 +104,8 @@ namespace CodeImp.DoomBuilder.Data
this.longname = Lump.MakeLongName(this.name); this.longname = Lump.MakeLongName(this.name);
this.virtualname = filepathname.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); this.virtualname = filepathname.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
this.filepathname = filepathname; this.filepathname = filepathname;
ComputeNamesWidth(); // biwa
} }
// This loads the image // This loads the image

View file

@ -85,6 +85,8 @@ namespace CodeImp.DoomBuilder.Data
{ {
this.shortname = this.shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH); this.shortname = this.shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
} }
ComputeNamesWidth(); // biwa
} }
// This adds a patch to the texture // This adds a patch to the texture