From 3c6beb1e68356ff6159c869eb2458267c08e7de6 Mon Sep 17 00:00:00 2001 From: codeimp Date: Wed, 17 Jun 2009 16:52:28 +0000 Subject: [PATCH] Things filter now also hides things in le Mode de la Visuale --- Source/Core/Editing/NullThingsFilter.cs | 2 ++ Source/Core/Editing/ThingsFilter.cs | 19 +++++++++++++++-- Source/Core/VisualModes/VisualMode.cs | 28 ++++++++++++++----------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Source/Core/Editing/NullThingsFilter.cs b/Source/Core/Editing/NullThingsFilter.cs index e9cc7d2b..3a9f7972 100644 --- a/Source/Core/Editing/NullThingsFilter.cs +++ b/Source/Core/Editing/NullThingsFilter.cs @@ -63,6 +63,8 @@ namespace CodeImp.DoomBuilder.Editing // Make lists visiblethings = new List(General.Map.Map.Things); hiddenthings = new List(0); + thingsvisiblestate = new Dictionary(General.Map.Map.Things.Count); + foreach(Thing t in visiblethings) thingsvisiblestate.Add(t, true); } #endregion diff --git a/Source/Core/Editing/ThingsFilter.cs b/Source/Core/Editing/ThingsFilter.cs index 6fea498d..97a25482 100644 --- a/Source/Core/Editing/ThingsFilter.cs +++ b/Source/Core/Editing/ThingsFilter.cs @@ -56,6 +56,7 @@ namespace CodeImp.DoomBuilder.Editing // List of things protected List visiblethings; protected List hiddenthings; + protected Dictionary thingsvisiblestate; // Disposing protected bool isdisposed = false; @@ -142,6 +143,7 @@ namespace CodeImp.DoomBuilder.Editing // Clean up visiblethings = null; hiddenthings = null; + thingsvisiblestate = null; // Done isdisposed = true; @@ -152,6 +154,14 @@ namespace CodeImp.DoomBuilder.Editing #region ================== Methods + /// + /// This checks if a thing is visible. Throws an exception when the specified Thing does not exist in the map (filter not updated?). + /// + public bool IsThingVisible(Thing t) + { + return thingsvisiblestate[t]; + } + // This writes the filter to configuration internal void WriteSettings(Configuration cfg, string path) { @@ -182,14 +192,18 @@ namespace CodeImp.DoomBuilder.Editing // Clear lists visiblethings = null; hiddenthings = null; + thingsvisiblestate = null; } - // This updates the list of things + /// + /// This updates the list of things. + /// public virtual void Update() { // Make new list visiblethings = new List(General.Map.Map.Things.Count); hiddenthings = new List(General.Map.Map.Things.Count); + thingsvisiblestate = new Dictionary(General.Map.Map.Things.Count); foreach(Thing t in General.Map.Map.Things) { bool qualifies; @@ -243,8 +257,9 @@ namespace CodeImp.DoomBuilder.Editing } } - // Put the thing in the correct list + // Put the thing in the lists if(qualifies) visiblethings.Add(t); else hiddenthings.Add(t); + thingsvisiblestate.Add(t, qualifies); } } diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs index 23c2f35d..ba9b2d1b 100644 --- a/Source/Core/VisualModes/VisualMode.cs +++ b/Source/Core/VisualModes/VisualMode.cs @@ -341,20 +341,24 @@ namespace CodeImp.DoomBuilder.VisualModes { VisualThing vt; - if(allthings.ContainsKey(t)) + // Not filtered out? + if(General.Map.ThingsFilter.IsThingVisible(t)) { - vt = allthings[t]; - } - else - { - // Create new visual thing - vt = CreateVisualThing(t); - if(vt != null) allthings.Add(t, vt); - } + if(allthings.ContainsKey(t)) + { + vt = allthings[t]; + } + else + { + // Create new visual thing + vt = CreateVisualThing(t); + if(vt != null) allthings.Add(t, vt); + } - if(vt != null) - { - visiblethings.Add(vt); + if(vt != null) + { + visiblethings.Add(vt); + } } } }