From 922404bf10a0cc6bd1d617a8c839691834b859dc Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 1 Jun 2015 22:10:15 +0000 Subject: [PATCH] We can use settings from parent when creating a child thing category. --- Source/Core/Config/ThingCategory.cs | 48 ++++++++++++++++++++--------- Source/Core/Data/DataManager.cs | 4 +-- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Source/Core/Config/ThingCategory.cs b/Source/Core/Config/ThingCategory.cs index 64dd0749..2880e018 100644 --- a/Source/Core/Config/ThingCategory.cs +++ b/Source/Core/Config/ThingCategory.cs @@ -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(); this.children = new List(); + //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); diff --git a/Source/Core/Data/DataManager.cs b/Source/Core/Data/DataManager.cs index 9a3016a9..b09e3c20 100644 --- a/Source/Core/Data/DataManager.cs +++ b/Source/Core/Data/DataManager.cs @@ -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); // ^.^ }