diff --git a/Source/Core/Controls/ImageBrowserItem.cs b/Source/Core/Controls/ImageBrowserItem.cs index 2bed6729..aa7108cb 100755 --- a/Source/Core/Controls/ImageBrowserItem.cs +++ b/Source/Core/Controls/ImageBrowserItem.cs @@ -30,8 +30,6 @@ namespace CodeImp.DoomBuilder.Controls private bool showfullname; protected ImageBrowserItemType itemtype; private string tooltip; - private int namewidth; - private int shortnamewidth; private static Brush bgbrush, fgbrush_used, fgbrush_unused, selectedbgbrush, selectionbrush, selectiontextbrush, bgbrush_alpha; private static Color bgcolor; @@ -48,7 +46,7 @@ namespace CodeImp.DoomBuilder.Controls public virtual bool IsPreviewLoaded { get { return icon.IsPreviewLoaded; } } 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 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; } } #endregion @@ -65,10 +63,6 @@ namespace CodeImp.DoomBuilder.Controls this.showfullname = showfullname; //mxd this.imageloaded = icon.IsPreviewLoaded; //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 diff --git a/Source/Core/Data/CameraTextureImage.cs b/Source/Core/Data/CameraTextureImage.cs index 2008276e..5704fac4 100755 --- a/Source/Core/Data/CameraTextureImage.cs +++ b/Source/Core/Data/CameraTextureImage.cs @@ -113,6 +113,8 @@ namespace CodeImp.DoomBuilder.Data base.SetName(name); this.virtualname = "[CAMERA TEXTURES]" + Path.AltDirectorySeparatorChar + name; + + ComputeNamesWidth(); // biwa } #endregion diff --git a/Source/Core/Data/FileImage.cs b/Source/Core/Data/FileImage.cs index d6dde33b..b02f3f30 100755 --- a/Source/Core/Data/FileImage.cs +++ b/Source/Core/Data/FileImage.cs @@ -145,6 +145,8 @@ namespace CodeImp.DoomBuilder.Data this.longname = Lump.MakeLongName(this.name, uselongtexturenames); this.filepathname = filepathname; + + ComputeNamesWidth(); // biwa } // This loads the image diff --git a/Source/Core/Data/HiResImage.cs b/Source/Core/Data/HiResImage.cs index 84a037af..8e885b66 100755 --- a/Source/Core/Data/HiResImage.cs +++ b/Source/Core/Data/HiResImage.cs @@ -83,6 +83,8 @@ namespace CodeImp.DoomBuilder.Data this.displayname = this.name; this.shortname = this.name; this.longname = Lump.MakeLongName(this.name); + + ComputeNamesWidth(); // biwa } internal void ApplySettings(ImageData overridden) diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs index 34b47234..4dea7b13 100755 --- a/Source/Core/Data/ImageData.cs +++ b/Source/Core/Data/ImageData.cs @@ -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() { diff --git a/Source/Core/Data/PK3FileImage.cs b/Source/Core/Data/PK3FileImage.cs index 313962cb..79906eb3 100755 --- a/Source/Core/Data/PK3FileImage.cs +++ b/Source/Core/Data/PK3FileImage.cs @@ -104,6 +104,8 @@ namespace CodeImp.DoomBuilder.Data this.longname = Lump.MakeLongName(this.name); this.virtualname = filepathname.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar); this.filepathname = filepathname; + + ComputeNamesWidth(); // biwa } // This loads the image diff --git a/Source/Core/Data/TEXTURESImage.cs b/Source/Core/Data/TEXTURESImage.cs index 21877914..65b24367 100755 --- a/Source/Core/Data/TEXTURESImage.cs +++ b/Source/Core/Data/TEXTURESImage.cs @@ -85,6 +85,8 @@ namespace CodeImp.DoomBuilder.Data { this.shortname = this.shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH); } + + ComputeNamesWidth(); // biwa } // This adds a patch to the texture