We can use settings from parent when creating a child thing category.

This commit is contained in:
MaxED 2015-06-01 22:10:15 +00:00
parent 5a7b599a46
commit 922404bf10
2 changed files with 36 additions and 16 deletions

View file

@ -88,7 +88,7 @@ namespace CodeImp.DoomBuilder.Config
#region ================== Constructor / Disposer
// Constructor
internal ThingCategory(string name, string title)
internal ThingCategory(ThingCategory parent, string name, string title)
{
// Initialize
this.name = name;
@ -96,20 +96,40 @@ namespace CodeImp.DoomBuilder.Config
this.things = new List<ThingTypeInfo>();
this.children = new List<ThingCategory>();
//mxd. Copy properties from the parent
if(parent != null)
{
this.sprite = parent.sprite;
this.sorted = parent.sorted;
this.color = parent.color;
this.arrow = parent.arrow;
this.radius = parent.radius;
this.height = parent.height;
this.hangs = parent.hangs;
this.blocking = parent.blocking;
this.errorcheck = parent.errorcheck;
this.fixedsize = parent.fixedsize;
this.fixedrotation = parent.fixedrotation;
this.absolutez = parent.absolutez;
this.spritescale = parent.spritescale;
}
// Set default properties
this.sprite = "";
this.sorted = true;
this.color = 18;
this.arrow = 1;
this.radius = 10;
this.height = 20;
this.hangs = 0;
this.blocking = 0;
this.errorcheck = 1;
this.fixedsize = false;
this.fixedrotation = false; //mxd
this.absolutez = false;
this.spritescale = 1.0f;
else
{
this.sprite = "";
this.sorted = true;
this.color = 18;
this.arrow = 1;
this.radius = 10;
this.height = 20;
this.hangs = 0;
this.blocking = 0;
this.errorcheck = 1;
this.fixedsize = false;
this.fixedrotation = false; //mxd
this.absolutez = false;
this.spritescale = 1.0f;
}
// We have no destructor
GC.SuppressFinalize(this);

View file

@ -1575,7 +1575,7 @@ namespace CodeImp.DoomBuilder.Data
if(c.Title.ToLowerInvariant() == catname) cat = c;
}
//... then - by Name
//...then - by Name
if(cat == null)
{
foreach(ThingCategory c in categories)
@ -1589,7 +1589,7 @@ namespace CodeImp.DoomBuilder.Data
{
string cattitle = catnames[0].Trim();
if(string.IsNullOrEmpty(cattitle)) cattitle = "Decorate";
cat = new ThingCategory(catname, cattitle);
cat = new ThingCategory(parent, catname, cattitle);
categories.Add(cat); // ^.^
}