mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Fixed action arguments to stay within valid range (0..255 for hexen)
Added warning message when a texture or flat is double defined in the same resource.
This commit is contained in:
parent
32d42e7e56
commit
b6fba8d043
12 changed files with 52 additions and 13 deletions
|
@ -44,7 +44,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Matching textures and flats
|
||||
private Dictionary<long, ImageData> textures;
|
||||
private Dictionary<long, ImageData> flats;
|
||||
private int locationtype;
|
||||
private DataLocation location;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -52,17 +52,17 @@ namespace CodeImp.DoomBuilder.Config
|
|||
|
||||
public ICollection<ImageData> Textures { get { return textures.Values; } }
|
||||
public ICollection<ImageData> Flats { get { return flats.Values; } }
|
||||
public int LocationType { get { return locationtype; } }
|
||||
public DataLocation Location { get { return location; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// New texture set constructor
|
||||
public ResourceTextureSet(string name, int locationtype)
|
||||
public ResourceTextureSet(string name, DataLocation location)
|
||||
{
|
||||
this.name = name;
|
||||
this.locationtype = locationtype;
|
||||
this.location = location;
|
||||
this.textures = new Dictionary<long, ImageData>();
|
||||
this.flats = new Dictionary<long, ImageData>();
|
||||
}
|
||||
|
@ -74,13 +74,29 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Add a texture
|
||||
internal void AddTexture(ImageData image)
|
||||
{
|
||||
textures.Add(image.LongName, image);
|
||||
if(textures.ContainsKey(image.LongName))
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Texture \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\".");
|
||||
textures[image.LongName] = image;
|
||||
}
|
||||
|
||||
// Add a flat
|
||||
internal void AddFlat(ImageData image)
|
||||
{
|
||||
flats.Add(image.LongName, image);
|
||||
if(flats.ContainsKey(image.LongName))
|
||||
General.ErrorLogger.Add(ErrorType.Warning, "Flat \"" + image.Name + "\" is double defined in resource \"" + this.Location.location + "\".");
|
||||
flats[image.LongName] = image;
|
||||
}
|
||||
|
||||
// Check if this set has a texture
|
||||
internal bool TextureExists(ImageData image)
|
||||
{
|
||||
return textures.ContainsKey(image.LongName);
|
||||
}
|
||||
|
||||
// Check if this set has a flat
|
||||
internal bool FlatExists(ImageData image)
|
||||
{
|
||||
return flats.ContainsKey(image.LongName);
|
||||
}
|
||||
|
||||
// Mix the textures and flats
|
||||
|
|
|
@ -242,6 +242,8 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// This returns the selected value
|
||||
public int GetResult(int original)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
// Strip prefixes
|
||||
string str = combobox.Text.Trim().ToLowerInvariant();
|
||||
str = str.TrimStart('+', '-');
|
||||
|
@ -255,26 +257,28 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
{
|
||||
// Add number to original
|
||||
if(!int.TryParse(str, out num)) num = 0;
|
||||
return original + num;
|
||||
result = original + num;
|
||||
}
|
||||
// Prefixed with --?
|
||||
else if(combobox.Text.Trim().StartsWith("--"))
|
||||
{
|
||||
// Subtract number from original
|
||||
if(!int.TryParse(str, out num)) num = 0;
|
||||
return original - num;
|
||||
result = original - num;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Return the value
|
||||
return typehandler.GetIntValue();
|
||||
result = typehandler.GetIntValue();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just return the original
|
||||
return original;
|
||||
result = original;
|
||||
}
|
||||
|
||||
return General.Clamp(result, General.Map.FormatInterface.MinArgument, General.Map.FormatInterface.MaxArgument);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace CodeImp.DoomBuilder.Data
|
|||
{
|
||||
// Keep information
|
||||
location = dl;
|
||||
textureset = new ResourceTextureSet(GetTitle(), dl.type);
|
||||
textureset = new ResourceTextureSet(GetTitle(), dl);
|
||||
}
|
||||
|
||||
// Disposer
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int MinTag { get { return ushort.MinValue; } }
|
||||
public override int MaxAction { get { return ushort.MaxValue; } }
|
||||
public override int MinAction { get { return ushort.MinValue; } }
|
||||
public override int MaxArgument { get { return 0; } }
|
||||
public override int MinArgument { get { return 0; } }
|
||||
public override int MaxEffect { get { return ushort.MaxValue; } }
|
||||
public override int MinEffect { get { return ushort.MinValue; } }
|
||||
public override int MaxBrightness { get { return short.MaxValue; } }
|
||||
|
|
|
@ -71,6 +71,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int MinTag { get { return ushort.MinValue; } }
|
||||
public override int MaxAction { get { return byte.MaxValue; } }
|
||||
public override int MinAction { get { return byte.MinValue; } }
|
||||
public override int MaxArgument { get { return byte.MaxValue; } }
|
||||
public override int MinArgument { get { return byte.MinValue; } }
|
||||
public override int MaxEffect { get { return ushort.MaxValue; } }
|
||||
public override int MinEffect { get { return ushort.MinValue; } }
|
||||
public override int MaxBrightness { get { return short.MaxValue; } }
|
||||
|
|
|
@ -57,6 +57,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
int MinTag { get; }
|
||||
int MaxAction { get; }
|
||||
int MinAction { get; }
|
||||
int MaxArgument { get; }
|
||||
int MinArgument { get; }
|
||||
int MaxEffect { get; }
|
||||
int MinEffect { get; }
|
||||
int MaxBrightness { get; }
|
||||
|
|
|
@ -73,6 +73,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public abstract int MinTag { get; }
|
||||
public abstract int MaxAction { get; }
|
||||
public abstract int MinAction { get; }
|
||||
public abstract int MaxArgument { get; }
|
||||
public abstract int MinArgument { get; }
|
||||
public abstract int MaxEffect { get; }
|
||||
public abstract int MinEffect { get; }
|
||||
public abstract int MaxBrightness { get; }
|
||||
|
|
|
@ -125,6 +125,8 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int MinTag { get { return int.MinValue; } }
|
||||
public override int MaxAction { get { return int.MaxValue; } }
|
||||
public override int MinAction { get { return int.MinValue; } }
|
||||
public override int MaxArgument { get { return int.MaxValue; } }
|
||||
public override int MinArgument { get { return int.MinValue; } }
|
||||
public override int MaxEffect { get { return int.MaxValue; } }
|
||||
public override int MinEffect { get { return int.MinValue; } }
|
||||
public override int MaxBrightness { get { return int.MaxValue; } }
|
||||
|
|
|
@ -76,6 +76,11 @@ namespace CodeImp.DoomBuilder.Types
|
|||
this.value = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(forargument)
|
||||
{
|
||||
this.value = General.Clamp(this.value, General.Map.FormatInterface.MinArgument, General.Map.FormatInterface.MaxArgument);
|
||||
}
|
||||
}
|
||||
|
||||
public override object GetValue()
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace CodeImp.DoomBuilder.Types
|
|||
protected int index;
|
||||
protected string typename;
|
||||
protected bool customusable;
|
||||
protected bool forargument;
|
||||
protected ArgumentInfo arginfo;
|
||||
protected TypeHandlerAttribute attribute;
|
||||
|
||||
|
@ -57,6 +58,7 @@ namespace CodeImp.DoomBuilder.Types
|
|||
public int Index { get { return index; } }
|
||||
public string TypeName { get { return typename; } }
|
||||
public bool IsCustomUsable { get { return customusable; } }
|
||||
public bool IsForArgument { get { return forargument; } }
|
||||
public TypeHandlerAttribute Attribute { get { return attribute; } }
|
||||
|
||||
public virtual bool IsBrowseable { get { return false; } }
|
||||
|
@ -76,6 +78,7 @@ namespace CodeImp.DoomBuilder.Types
|
|||
public virtual void SetupArgument(TypeHandlerAttribute attr, ArgumentInfo arginfo)
|
||||
{
|
||||
// Setup
|
||||
this.forargument = true;
|
||||
this.arginfo = arginfo;
|
||||
if(attr != null)
|
||||
{
|
||||
|
@ -99,6 +102,7 @@ namespace CodeImp.DoomBuilder.Types
|
|||
public virtual void SetupField(TypeHandlerAttribute attr, UniversalFieldInfo fieldinfo)
|
||||
{
|
||||
// Setup
|
||||
this.forargument = false;
|
||||
this.arginfo = arginfo;
|
||||
if(attr != null)
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
item = texturesets.Items.Add(ts.Name);
|
||||
item.Tag = ts;
|
||||
item.ImageIndex = 2 + ts.LocationType;
|
||||
item.ImageIndex = 2 + ts.Location.type;
|
||||
item.UseItemStyleForSubItems = false;
|
||||
item.SubItems.Add(ts.Textures.Count.ToString(), item.ForeColor,
|
||||
item.BackColor, new Font(item.Font, FontStyle.Regular));
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
item = texturesets.Items.Add(ts.Name);
|
||||
item.Tag = ts;
|
||||
item.ImageIndex = 2 + ts.LocationType;
|
||||
item.ImageIndex = 2 + ts.Location.type;
|
||||
item.UseItemStyleForSubItems = false;
|
||||
item.SubItems.Add(ts.Textures.Count.ToString(), item.ForeColor,
|
||||
item.BackColor, new Font(item.Font, FontStyle.Regular));
|
||||
|
|
Loading…
Reference in a new issue