Fixed, Sound Environments mode: "Show nodes with warnings only" logic was broken...

Fixed, Sound Environments mode: fixed an exception when clicking on already selected child node in the sound environments list (I broke this in the previous commit).
Fixed, Sound Environments mode: the view now centers on selected sound environment when clicking on a sound environment in the list (I broke that when I've added proper sound environment names way back when).
This commit is contained in:
MaxED 2015-07-06 07:50:04 +00:00
parent ef5bd3e5c0
commit 3924ae5a33

View file

@ -76,6 +76,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
int notdormant = 0; int notdormant = 0;
int iconindex = BuilderPlug.Me.DistinctColors.IndexOf(se.Color); //mxd int iconindex = BuilderPlug.Me.DistinctColors.IndexOf(se.Color); //mxd
int topindex = iconindex; //mxd int topindex = iconindex; //mxd
bool nodehaswarnings = false; //mxd
thingsnode.ImageIndex = iconindex; //mxd thingsnode.ImageIndex = iconindex; //mxd
thingsnode.SelectedImageIndex = iconindex; //mxd thingsnode.SelectedImageIndex = iconindex; //mxd
@ -116,6 +117,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
tn.SelectedImageIndex = warningiconindex; tn.SelectedImageIndex = warningiconindex;
tn.ToolTipText = "More than one thing in this\nsound environment is set to be\nactive. Set all but one thing\nto dormant."; tn.ToolTipText = "More than one thing in this\nsound environment is set to be\nactive. Set all but one thing\nto dormant.";
nodewarningscount++; //mxd nodewarningscount++; //mxd
nodehaswarnings = true; //mxd
} }
} }
} }
@ -150,13 +152,14 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
topindex = warningiconindex; topindex = warningiconindex;
nodewarningscount++; //mxd nodewarningscount++; //mxd
nodehaswarnings = true; //mxd
} }
linedefsnode.Nodes.Add(linedefnode); linedefsnode.Nodes.Add(linedefnode);
} }
//mxd //mxd
if(!showwarningsonly.Checked || nodewarningscount > 0) if(!showwarningsonly.Checked || nodehaswarnings)
{ {
topnode.Nodes.Add(thingsnode); topnode.Nodes.Add(thingsnode);
topnode.Nodes.Add(linedefsnode); topnode.Nodes.Add(linedefsnode);
@ -209,7 +212,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
//mxd. This (de)selects sound environment //mxd. This (de)selects sound environment
public void SelectSoundEnvironment(SoundEnvironment se) public void SelectSoundEnvironment(SoundEnvironment se)
{ {
if((se == null && soundenvironments.SelectedNode != null) || (se != null && soundenvironments.SelectedNode != null && ((SoundEnvironment)soundenvironments.SelectedNode.Tag).ID == se.ID)) if((se == null && soundenvironments.SelectedNode != null) || (se != null && soundenvironments.SelectedNode != null && soundenvironments.SelectedNode.Tag is SoundEnvironment && ((SoundEnvironment)soundenvironments.SelectedNode.Tag).ID == se.ID))
{ {
soundenvironments.SelectedNode = null; soundenvironments.SelectedNode = null;
return; return;
@ -243,7 +246,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
if (node.Parent == null) if (node.Parent == null)
{ {
if (node.Text.StartsWith("Sound environment")) if (node.Tag is SoundEnvironment)
{ {
SoundEnvironment se = (SoundEnvironment)node.Tag; SoundEnvironment se = (SoundEnvironment)node.Tag;
@ -264,7 +267,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
} }
else else
{ {
if (node.Parent.Text.StartsWith("Things")) if (node.Tag is Thing)
{ {
Thing t = (Thing)node.Tag; Thing t = (Thing)node.Tag;
@ -272,7 +275,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
points.Add(t.Position - 200); points.Add(t.Position - 200);
points.Add(t.Position + 200); points.Add(t.Position + 200);
} }
else if (node.Parent.Text.StartsWith("Linedefs")) else if (node.Tag is Linedef)
{ {
Linedef ld = (Linedef)node.Tag; Linedef ld = (Linedef)node.Tag;