Fixed, Visual mode, UDMF: incorrect texture name was copied when using "Copy Texture" action when copying a texture stored in a folder resource when "Use long texture names" settings was enabled.

This commit is contained in:
MaxED 2015-11-17 17:50:56 +00:00
parent dfdcaaf696
commit b7ebde6b7e
9 changed files with 19 additions and 18 deletions

View file

@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.Controls
ImageData texture = General.Map.Data.GetFlatImage(imagename); //mxd
UpdateToggleImageNameButton(texture); //mxd
if(string.IsNullOrEmpty(texture.FullName) || texture is UnknownImage) DisplayImageSize(0, 0); //mxd
if(string.IsNullOrEmpty(texture.FilePathName) || texture is UnknownImage) DisplayImageSize(0, 0); //mxd
else DisplayImageSize(texture.ScaledWidth, texture.ScaledHeight); //mxd
if(usepreviews ? !texture.IsPreviewLoaded : !texture.IsImageLoaded) timer.Start(); //mxd

View file

@ -303,6 +303,7 @@ namespace CodeImp.DoomBuilder.Controls
{
if(list.SelectedItems.Count > 0)
{
list.Focus(); //mxd
ListViewItem selected = list.SelectedItems[0];
//mxd

View file

@ -72,7 +72,7 @@ namespace CodeImp.DoomBuilder.Controls
ImageData texture = General.Map.Data.GetTextureImage(imagename); //mxd
UpdateToggleImageNameButton(texture); //mxd
if(string.IsNullOrEmpty(texture.FullName) || texture is UnknownImage) DisplayImageSize(0, 0); //mxd
if(string.IsNullOrEmpty(texture.FilePathName) || texture is UnknownImage) DisplayImageSize(0, 0); //mxd
else DisplayImageSize(texture.ScaledWidth, texture.ScaledHeight); //mxd
if(usepreviews ? !texture.IsPreviewLoaded : !texture.IsImageLoaded) timer.Start(); //mxd

View file

@ -128,7 +128,7 @@ namespace CodeImp.DoomBuilder.Data
}
this.longname = Lump.MakeLongName(this.name, uselongtexturenames);
this.fullname = filepathname;
this.filepathname = filepathname;
this.level = virtualname.Split(new[] { Path.AltDirectorySeparatorChar }).Length - 1;
if(General.Settings.CapitalizeTextureNames && !string.IsNullOrEmpty(this.displayname))
@ -153,7 +153,7 @@ namespace CodeImp.DoomBuilder.Data
// Load file data
if(bitmap != null) bitmap.Dispose(); bitmap = null;
MemoryStream filedata = new MemoryStream(File.ReadAllBytes(fullname));
MemoryStream filedata = new MemoryStream(File.ReadAllBytes(filepathname));
// Get a reader for the data
IImageReader reader = ImageDataFormat.GetImageReader(filedata, probableformat, General.Map.Data.Palette);
@ -172,7 +172,7 @@ namespace CodeImp.DoomBuilder.Data
// Not loaded?
if(bitmap == null)
{
General.ErrorLogger.Add(ErrorType.Error, "Image file '" + fullname + "' data format could not be read, while loading image '" + this.Name + "'. Is this a valid picture file at all?");
General.ErrorLogger.Add(ErrorType.Error, "Image file '" + filepathname + "' data format could not be read, while loading image '" + this.Name + "'. Is this a valid picture file at all?");
loadfailed = true;
}
else

View file

@ -49,7 +49,7 @@ namespace CodeImp.DoomBuilder.Data
protected Vector2D scale;
protected bool worldpanning;
private bool usecolorcorrection;
protected string fullname; //mxd. name with path;
protected string filepathname; //mxd. Absolute path to the image;
protected string shortname; //mxd. Name in uppercase and clamped to DataManager.CLASIC_IMAGE_NAME_LENGTH
protected string virtualname; //mxd. Path of this name is used in TextureBrowserForm
protected string displayname; //mxd. Name to display in TextureBrowserForm
@ -92,7 +92,7 @@ namespace CodeImp.DoomBuilder.Data
public string Name { get { return name; } }
public long LongName { get { return longname; } }
public string ShortName { get { return shortname; } } //mxd
public string FullName { get { return fullname; } } //mxd
public string FilePathName { get { return filepathname; } } //mxd
public string VirtualName { get { return virtualname; } } //mxd
public string DisplayName { get { return displayname; } } //mxd
public bool IsFlat { get { return isFlat; } } //mxd
@ -198,7 +198,7 @@ namespace CodeImp.DoomBuilder.Data
protected virtual void SetName(string name)
{
this.name = name;
this.fullname = name; //mxd
this.filepathname = name; //mxd
this.shortname = name; //mxd
this.virtualname = name; //mxd
this.displayname = name; //mxd
@ -346,7 +346,7 @@ namespace CodeImp.DoomBuilder.Data
{
BitmapData bmpdata = null;
try { bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); }
catch(Exception e) { General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.fullname + "' for glow color calculation. " + e.GetType().Name + ": " + e.Message); }
catch(Exception e) { General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.filepathname + "' for glow color calculation. " + e.GetType().Name + ": " + e.Message); }
if(bmpdata != null)
{
@ -400,7 +400,7 @@ namespace CodeImp.DoomBuilder.Data
{
BitmapData bmpdata = null;
try { bmpdata = bitmap.LockBits(new Rectangle(0, 0, bitmap.Size.Width, bitmap.Size.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); }
catch(Exception e) { General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.fullname + "' for translucency check. " + e.GetType().Name + ": " + e.Message); }
catch(Exception e) { General.ErrorLogger.Add(ErrorType.Error, "Cannot lock image '" + this.filepathname + "' for translucency check. " + e.GetType().Name + ": " + e.Message); }
if(bmpdata != null)
{

View file

@ -71,7 +71,7 @@ namespace CodeImp.DoomBuilder.Data
if(!General.Map.Config.UseLongTextureNames || string.IsNullOrEmpty(Path.GetDirectoryName(filepathname)))
{
this.name = Path.GetFileNameWithoutExtension(filepathname.ToUpperInvariant());
if (this.name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
if(this.name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
{
this.name = this.name.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
}
@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder.Data
this.name = filepathname.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
this.displayname = Path.GetFileNameWithoutExtension(name);
this.shortname = this.displayname.ToUpperInvariant();
if (this.shortname.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
if(this.shortname.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH)
{
this.shortname = this.shortname.Substring(0, DataManager.CLASIC_IMAGE_NAME_LENGTH);
}
@ -92,7 +92,7 @@ namespace CodeImp.DoomBuilder.Data
this.longname = Lump.MakeLongName(this.name);
this.virtualname = filepathname.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
this.fullname = filepathname;
this.filepathname = filepathname;
this.level = virtualname.Split(new[] { Path.AltDirectorySeparatorChar }).Length - 1;
if(General.Settings.CapitalizeTextureNames && !string.IsNullOrEmpty(this.displayname))
@ -116,7 +116,7 @@ namespace CodeImp.DoomBuilder.Data
{
// Load file data
if(bitmap != null) bitmap.Dispose(); bitmap = null;
MemoryStream filedata = datareader.LoadFile(fullname); //mxd
MemoryStream filedata = datareader.LoadFile(filepathname); //mxd
if(filedata != null)
{
@ -140,7 +140,7 @@ namespace CodeImp.DoomBuilder.Data
// Not loaded?
if(bitmap == null)
{
General.ErrorLogger.Add(ErrorType.Error, "Image file '" + fullname + "' data format could not be read, while loading texture '" + this.Name + "'");
General.ErrorLogger.Add(ErrorType.Error, "Image file '" + filepathname + "' data format could not be read, while loading texture '" + this.Name + "'");
loadfailed = true;
}
else

View file

@ -227,7 +227,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private static int SortImageData(ImageData img1, ImageData img2)
{
return img1.FullName.CompareTo(img2.FullName);
return String.Compare(img1.FilePathName, img2.FilePathName, StringComparison.Ordinal);
}
//mxd

View file

@ -754,7 +754,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnCopyTexture()
{
//mxd. When UseLongTextureNames is disabled, use texture name as stored in Sidedef, otherwise use full name.
string texturename = ((General.Map.Options.UseLongTextureNames && Texture != null && Texture.UsedInMap) ? Texture.FullName : GetTextureName());
string texturename = ((General.Map.Options.UseLongTextureNames && Texture != null && Texture.UsedInMap) ? Texture.Name : GetTextureName());
BuilderPlug.Me.CopiedFlat = texturename;
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedTexture = texturename;
mode.SetActionResult("Copied flat '" + texturename + "'.");

View file

@ -1197,7 +1197,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnCopyTexture()
{
//mxd. When UseLongTextureNames is disabled, use texture name as stored in Sidedef, otherwise use full name.
string texturename = ((General.Map.Options.UseLongTextureNames && Texture != null && Texture.UsedInMap) ? Texture.FullName : GetTextureName());
string texturename = ((General.Map.Options.UseLongTextureNames && Texture != null && Texture.UsedInMap) ? Texture.Name : GetTextureName());
BuilderPlug.Me.CopiedTexture = texturename;
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedFlat = texturename;
mode.SetActionResult("Copied texture '" + texturename + "'.");