Skip to content
Snippets Groups Projects
Commit 3c6beb1e authored by codeimp's avatar codeimp
Browse files

Things filter now also hides things in le Mode de la Visuale

parent 8c91bc30
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,8 @@ namespace CodeImp.DoomBuilder.Editing
// Make lists
visiblethings = new List<Thing>(General.Map.Map.Things);
hiddenthings = new List<Thing>(0);
thingsvisiblestate = new Dictionary<Thing, bool>(General.Map.Map.Things.Count);
foreach(Thing t in visiblethings) thingsvisiblestate.Add(t, true);
}
#endregion
......
......@@ -56,6 +56,7 @@ namespace CodeImp.DoomBuilder.Editing
// List of things
protected List<Thing> visiblethings;
protected List<Thing> hiddenthings;
protected Dictionary<Thing, bool> 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
/// <summary>
/// This checks if a thing is visible. Throws an exception when the specified Thing does not exist in the map (filter not updated?).
/// </summary>
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
/// <summary>
/// This updates the list of things.
/// </summary>
public virtual void Update()
{
// Make new list
visiblethings = new List<Thing>(General.Map.Map.Things.Count);
hiddenthings = new List<Thing>(General.Map.Map.Things.Count);
thingsvisiblestate = new Dictionary<Thing, bool>(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);
}
}
......
......@@ -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);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment