From 1118fd6b985d4dc98b1df4627d6b12888c839e50 Mon Sep 17 00:00:00 2001 From: MaxED Date: Wed, 15 Jul 2015 09:09:47 +0000 Subject: [PATCH] Changed: "Show Comments" option should also control whether comment tooltips are displayed. Added some boilerplate to CommentsDocker. Internal: converted a bunch of if-elses to switches. --- Source/Core/Controls/FieldsEditorControl.cs | 13 ++- Source/Core/Controls/ImageSelectorControl.cs | 9 +- Source/Core/Controls/ResourceListEditor.cs | 16 +-- Source/Core/Controls/ScriptEditorPanel.cs | 14 ++- Source/Core/Data/HighResImage.cs | 12 +-- Source/Core/GZBuilder/md3/ModelReader.cs | 19 ++-- Source/Core/Map/MapOptions.cs | 7 +- Source/Core/Rendering/FlatQuad.cs | 95 +++++++++------- Source/Core/Rendering/Renderer.cs | 22 ++-- Source/Core/Windows/LinedefEditFormUDMF.cs | 33 +++--- Source/Core/Windows/SectorEditFormUDMF.cs | 33 +++--- Source/Core/Windows/ThingEditForm.cs | 7 +- Source/Core/Windows/ThingEditFormUDMF.cs | 9 +- Source/Core/Windows/ThingsFiltersForm.cs | 30 +++--- .../BuilderModes/ClassicModes/LinedefsMode.cs | 2 +- .../BuilderModes/ClassicModes/SectorsMode.cs | 2 +- .../BuilderModes/ClassicModes/ThingsMode.cs | 2 +- .../VisualModes/BaseVisualMode.cs | 57 +++++----- .../VisualModes/EffectCopySlope.cs | 13 +-- .../Plugins/CommentsPanel/CommentsDocker.cs | 32 +++--- .../TagExplorer/Controls/TagExplorer.cs | 102 ++++++++++-------- Source/Plugins/TagRange/TagRangeForm.cs | 65 ++++++----- 22 files changed, 336 insertions(+), 258 deletions(-) diff --git a/Source/Core/Controls/FieldsEditorControl.cs b/Source/Core/Controls/FieldsEditorControl.cs index 4b47c9b4..45f6859e 100644 --- a/Source/Core/Controls/FieldsEditorControl.cs +++ b/Source/Core/Controls/FieldsEditorControl.cs @@ -111,10 +111,15 @@ namespace CodeImp.DoomBuilder.Controls int sortcolumn = General.Settings.ReadSetting("customfieldssortcolumn", 0); int sortorder = General.Settings.ReadSetting("customfieldssortorder", (int)ListSortDirection.Ascending); - if(sortorder == (int)SortOrder.Ascending) - fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending); - else if(sortorder == (int)SortOrder.Descending) - fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Descending); + switch (sortorder) + { + case (int)SortOrder.Ascending: + fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending); + break; + case (int)SortOrder.Descending: + fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Descending); + break; + } } // This adds a list of fixed fields (in undefined state) diff --git a/Source/Core/Controls/ImageSelectorControl.cs b/Source/Core/Controls/ImageSelectorControl.cs index bcb95762..374409db 100644 --- a/Source/Core/Controls/ImageSelectorControl.cs +++ b/Source/Core/Controls/ImageSelectorControl.cs @@ -98,13 +98,10 @@ namespace CodeImp.DoomBuilder.Controls private void preview_Click(object sender, EventArgs e) { imagebox.BackColor = SystemColors.Highlight; - if(button == MouseButtons.Right) + switch (button) { - name.Text = "-"; - } - else if(button == MouseButtons.Left) - { - name.Text = BrowseImage(name.Text); + case MouseButtons.Right: name.Text = "-"; break; + case MouseButtons.Left: name.Text = BrowseImage(name.Text); break; } } diff --git a/Source/Core/Controls/ResourceListEditor.cs b/Source/Core/Controls/ResourceListEditor.cs index d34cdb56..7bbcd36e 100644 --- a/Source/Core/Controls/ResourceListEditor.cs +++ b/Source/Core/Controls/ResourceListEditor.cs @@ -232,15 +232,15 @@ namespace CodeImp.DoomBuilder.Controls { string ext = Path.GetExtension(path); if(string.IsNullOrEmpty(ext)) continue; - - ext = ext.ToLower(); - if(ext == ".wad") + switch(ext.ToLower()) { - AddItem(new DataLocation(DataLocation.RESOURCE_WAD, path, false, false, false)); - } - else if(ext == ".pk3" || ext == ".pk7") - { - AddItem(new DataLocation(DataLocation.RESOURCE_PK3, path, false, false, false)); + case ".wad": + AddItem(new DataLocation(DataLocation.RESOURCE_WAD, path, false, false, false)); + break; + case ".pk7": + case ".pk3": + AddItem(new DataLocation(DataLocation.RESOURCE_PK3, path, false, false, false)); + break; } } else if(Directory.Exists(path)) diff --git a/Source/Core/Controls/ScriptEditorPanel.cs b/Source/Core/Controls/ScriptEditorPanel.cs index 62463c67..0c2076ac 100644 --- a/Source/Core/Controls/ScriptEditorPanel.cs +++ b/Source/Core/Controls/ScriptEditorPanel.cs @@ -435,15 +435,13 @@ namespace CodeImp.DoomBuilder.Controls { // Ask to save DialogResult result = MessageBox.Show(this.ParentForm, "Do you want to save changes to " + t.Text + "?", "Close File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); - if(result == DialogResult.Yes) + switch (result) { - // Save file - if(!SaveScript(t)) return false; - } - else if(result == DialogResult.Cancel) - { - // Cancel - return false; + case DialogResult.Yes: + if(!SaveScript(t)) return false; + break; + case DialogResult.Cancel: + return false; } } diff --git a/Source/Core/Data/HighResImage.cs b/Source/Core/Data/HighResImage.cs index 85abebac..bcdf9f44 100644 --- a/Source/Core/Data/HighResImage.cs +++ b/Source/Core/Data/HighResImage.cs @@ -199,12 +199,12 @@ namespace CodeImp.DoomBuilder.Data if(p.rotate != 0) { RotateFlipType rotate; - if(p.rotate == 90) - rotate = RotateFlipType.Rotate90FlipNone; - else if(p.rotate == 180) - rotate = RotateFlipType.Rotate180FlipNone; - else - rotate = RotateFlipType.Rotate270FlipNone; + switch (p.rotate) + { + case 90: rotate = RotateFlipType.Rotate90FlipNone; break; + case 180: rotate = RotateFlipType.Rotate180FlipNone; break; + default: rotate = RotateFlipType.Rotate270FlipNone; break; + } patchbmp.RotateFlip(rotate); } diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs index 6be9895b..f479b2e8 100644 --- a/Source/Core/GZBuilder/md3/ModelReader.cs +++ b/Source/Core/GZBuilder/md3/ModelReader.cs @@ -112,13 +112,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 } string ext = Path.GetExtension(mde.ModelNames[i]); - - if(ext == ".md3") - result = ReadMD3Model(ref bbs, mde, useSkins, ms, device); - else if(ext == ".md2") - result = ReadMD2Model(ref bbs, mde, ms, device); - else - result.Errors = "model format is not supported"; + switch (ext) + { + case ".md3": + result = ReadMD3Model(ref bbs, mde, useSkins, ms, device); + break; + case ".md2": + result = ReadMD2Model(ref bbs, mde, ms, device); + break; + default: + result.Errors = "model format is not supported"; + break; + } ms.Close(); ms.Dispose(); diff --git a/Source/Core/Map/MapOptions.cs b/Source/Core/Map/MapOptions.cs index 37a49e0d..f0a36c2d 100644 --- a/Source/Core/Map/MapOptions.cs +++ b/Source/Core/Map/MapOptions.cs @@ -199,8 +199,11 @@ namespace CodeImp.DoomBuilder.Map foreach(DictionaryEntry entry in (ListDictionary)tagLabelsEntry.Value) { - if((string)entry.Key == "tag") tag = (int)entry.Value; - else if((string)entry.Key == "label") label = (string)entry.Value; + switch ((string)entry.Key) + { + case "tag": tag = (int)entry.Value; break; + case "label": label = (string)entry.Value; break; + } } if(tag != 0 && !string.IsNullOrEmpty(label)) diff --git a/Source/Core/Rendering/FlatQuad.cs b/Source/Core/Rendering/FlatQuad.cs index 9faf759f..1d89ad2f 100644 --- a/Source/Core/Rendering/FlatQuad.cs +++ b/Source/Core/Rendering/FlatQuad.cs @@ -52,10 +52,15 @@ namespace CodeImp.DoomBuilder.Rendering Initialize(type); // Set coordinates - if(type == PrimitiveType.TriangleList) - SetTriangleListCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f); - else if(type == PrimitiveType.TriangleStrip) - SetTriangleStripCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f); + switch (type) + { + case PrimitiveType.TriangleList: + SetTriangleListCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f); + break; + case PrimitiveType.TriangleStrip: + SetTriangleStripCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f); + break; + } // We have no destructor GC.SuppressFinalize(this); @@ -74,10 +79,15 @@ namespace CodeImp.DoomBuilder.Rendering thd = 1f / theight; // Set coordinates - if(type == PrimitiveType.TriangleList) - SetTriangleListCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd); - else if(type == PrimitiveType.TriangleStrip) - SetTriangleStripCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd); + switch (type) + { + case PrimitiveType.TriangleList: + SetTriangleListCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd); + break; + case PrimitiveType.TriangleStrip: + SetTriangleStripCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd); + break; + } // We have no destructor GC.SuppressFinalize(this); @@ -90,10 +100,15 @@ namespace CodeImp.DoomBuilder.Rendering Initialize(type); // Set coordinates - if(type == PrimitiveType.TriangleList) - SetTriangleListCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb); - else if(type == PrimitiveType.TriangleStrip) - SetTriangleStripCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb); + switch (type) + { + case PrimitiveType.TriangleList: + SetTriangleListCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb); + break; + case PrimitiveType.TriangleStrip: + SetTriangleStripCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb); + break; + } // We have no destructor GC.SuppressFinalize(this); @@ -106,10 +121,15 @@ namespace CodeImp.DoomBuilder.Rendering Initialize(type); // Set coordinates - if(type == PrimitiveType.TriangleList) - SetTriangleListCoordinates(left, top, right, bottom, tl, tt, tr, tb); - else if(type == PrimitiveType.TriangleStrip) - SetTriangleStripCoordinates(left, top, right, bottom, tl, tt, tr, tb); + switch (type) + { + case PrimitiveType.TriangleList: + SetTriangleListCoordinates(left, top, right, bottom, tl, tt, tr, tb); + break; + case PrimitiveType.TriangleStrip: + SetTriangleStripCoordinates(left, top, right, bottom, tl, tt, tr, tb); + break; + } // We have no destructor GC.SuppressFinalize(this); @@ -131,23 +151,22 @@ namespace CodeImp.DoomBuilder.Rendering public void SetColors(int clt, int crt, int clb, int crb) { // Determine polygon type - if(type == PrimitiveType.TriangleList) + switch (type) { - // Go for all vertices to set the color - vertices[0].c = clt; - vertices[1].c = crt; - vertices[2].c = clb; - vertices[3].c = clb; - vertices[4].c = crt; - vertices[5].c = crb; - } - else if(type == PrimitiveType.TriangleStrip) - { - // Go for all vertices to set the color - vertices[0].c = clt; - vertices[1].c = crt; - vertices[2].c = clb; - vertices[3].c = crb; + case PrimitiveType.TriangleList: + vertices[0].c = clt; + vertices[1].c = crt; + vertices[2].c = clb; + vertices[3].c = clb; + vertices[4].c = crt; + vertices[5].c = crb; + break; + case PrimitiveType.TriangleStrip: + vertices[0].c = clt; + vertices[1].c = crt; + vertices[2].c = clb; + vertices[3].c = crb; + break; } } @@ -216,12 +235,12 @@ namespace CodeImp.DoomBuilder.Rendering this.type = type; // Determine number of vertices - if(type == PrimitiveType.TriangleList) - numvertices = 6; - else if(type == PrimitiveType.TriangleStrip) - numvertices = 4; - else - throw new NotSupportedException("Unsupported PrimitiveType"); + switch (type) + { + case PrimitiveType.TriangleList: numvertices = 6; break; + case PrimitiveType.TriangleStrip: numvertices = 4; break; + default: throw new NotSupportedException("Unsupported PrimitiveType"); + } // Make the array vertices = new FlatVertex[numvertices]; diff --git a/Source/Core/Rendering/Renderer.cs b/Source/Core/Rendering/Renderer.cs index 27179405..36e72132 100644 --- a/Source/Core/Rendering/Renderer.cs +++ b/Source/Core/Rendering/Renderer.cs @@ -136,17 +136,19 @@ namespace CodeImp.DoomBuilder.Rendering } else //only horizontal/verticel walls are shaded - { - int angle = (int)Angle2D.RadToDeg(sd.Angle); - //horizontal wall - if(angle == 270 || angle == 90) + { + switch((int)Angle2D.RadToDeg(sd.Angle)) { - level = General.Clamp(level + General.Map.Data.MapInfo.HorizWallShade, 0, 255); - } - //vertical wall - else if(angle == 0 || angle == 180) - { - level = General.Clamp(level + General.Map.Data.MapInfo.VertWallShade, 0, 255); + // Horizontal wall + case 90: + case 270: + level = General.Clamp(level + General.Map.Data.MapInfo.HorizWallShade, 0, 255); + break; + // Vertical wall + case 180: + case 0: + level = General.Clamp(level + General.Map.Data.MapInfo.VertWallShade, 0, 255); + break; } } } diff --git a/Source/Core/Windows/LinedefEditFormUDMF.cs b/Source/Core/Windows/LinedefEditFormUDMF.cs index 6a7c9584..5627f6f9 100644 --- a/Source/Core/Windows/LinedefEditFormUDMF.cs +++ b/Source/Core/Windows/LinedefEditFormUDMF.cs @@ -806,8 +806,11 @@ namespace CodeImp.DoomBuilder.Windows foreach(CheckBox c in udmfactivates.Checkboxes) { LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo); - if(c.CheckState == CheckState.Checked) l.SetFlag(ai.Key, true); - else if(c.CheckState == CheckState.Unchecked) l.SetFlag(ai.Key, false); + switch (c.CheckState) + { + case CheckState.Checked: l.SetFlag(ai.Key, true); break; + case CheckState.Unchecked: l.SetFlag(ai.Key, false); break; + } } // Action/tags @@ -1450,13 +1453,14 @@ namespace CodeImp.DoomBuilder.Windows if(l.Front != null) { bool absolute = false; - if(cbLightAbsoluteFront.CheckState == CheckState.Indeterminate) + switch (cbLightAbsoluteFront.CheckState) { - absolute = l.Front.Fields.GetValue("lightabsolute", false); - } - else if(cbLightAbsoluteFront.CheckState == CheckState.Checked) - { - absolute = true; + case CheckState.Indeterminate: + absolute = l.Front.Fields.GetValue("lightabsolute", false); + break; + case CheckState.Checked: + absolute = true; + break; } int value = General.Clamp(lightFront.GetResult((linedefprops[i].Front != null ? linedefprops[i].Front.Brightness : 0)), (absolute ? 0 : -255), 255); @@ -1493,13 +1497,14 @@ namespace CodeImp.DoomBuilder.Windows if(l.Back != null) { bool absolute = false; - if(cbLightAbsoluteBack.CheckState == CheckState.Indeterminate) + switch (cbLightAbsoluteBack.CheckState) { - absolute = l.Back.Fields.GetValue("lightabsolute", false); - } - else if(cbLightAbsoluteBack.CheckState == CheckState.Checked) - { - absolute = true; + case CheckState.Indeterminate: + absolute = l.Back.Fields.GetValue("lightabsolute", false); + break; + case CheckState.Checked: + absolute = true; + break; } int value = General.Clamp(lightBack.GetResult((linedefprops[i].Back != null ? linedefprops[i].Back.Brightness : 0)), (absolute ? 0 : -255), 255); diff --git a/Source/Core/Windows/SectorEditFormUDMF.cs b/Source/Core/Windows/SectorEditFormUDMF.cs index c8a50cc4..6d17ede0 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.cs @@ -673,8 +673,11 @@ namespace CodeImp.DoomBuilder.Windows // Apply all flags foreach(CheckBox c in flags.Checkboxes) { - if(c.CheckState == CheckState.Checked) s.SetFlag(c.Tag.ToString(), true); - else if(c.CheckState == CheckState.Unchecked) s.SetFlag(c.Tag.ToString(), false); + switch (c.CheckState) + { + case CheckState.Checked: s.SetFlag(c.Tag.ToString(), true); break; + case CheckState.Unchecked: s.SetFlag(c.Tag.ToString(), false); break; + } } // Effects @@ -1122,13 +1125,14 @@ namespace CodeImp.DoomBuilder.Windows foreach(Sector s in sectors) { bool absolute = false; - if(ceilLightAbsolute.CheckState == CheckState.Indeterminate) + switch (ceilLightAbsolute.CheckState) { - absolute = s.Fields.GetValue("lightceilingabsolute", false); - } - else if(ceilLightAbsolute.CheckState == CheckState.Checked) - { - absolute = true; + case CheckState.Indeterminate: + absolute = s.Fields.GetValue("lightceilingabsolute", false); + break; + case CheckState.Checked: + absolute = true; + break; } int value = General.Clamp(ceilBrightness.GetResult(sectorprops[s].CeilBrightness), (absolute ? 0 : -255), 255); @@ -1160,13 +1164,14 @@ namespace CodeImp.DoomBuilder.Windows foreach(Sector s in sectors) { bool absolute = false; - if(floorLightAbsolute.CheckState == CheckState.Indeterminate) + switch (floorLightAbsolute.CheckState) { - absolute = s.Fields.GetValue("lightfloorabsolute", false); - } - else if(floorLightAbsolute.CheckState == CheckState.Checked) - { - absolute = true; + case CheckState.Indeterminate: + absolute = s.Fields.GetValue("lightfloorabsolute", false); + break; + case CheckState.Checked: + absolute = true; + break; } int value = General.Clamp(floorBrightness.GetResult(sectorprops[s].FloorBrightness), (absolute ? 0 : -255), 255); diff --git a/Source/Core/Windows/ThingEditForm.cs b/Source/Core/Windows/ThingEditForm.cs index 238659cc..0da52ae9 100644 --- a/Source/Core/Windows/ThingEditForm.cs +++ b/Source/Core/Windows/ThingEditForm.cs @@ -473,8 +473,11 @@ namespace CodeImp.DoomBuilder.Windows // Apply all flags foreach(CheckBox c in flags.Checkboxes) { - if(c.CheckState == CheckState.Checked) t.SetFlag(c.Tag.ToString(), true); - else if(c.CheckState == CheckState.Unchecked) t.SetFlag(c.Tag.ToString(), false); + switch (c.CheckState) + { + case CheckState.Checked: t.SetFlag(c.Tag.ToString(), true); break; + case CheckState.Unchecked: t.SetFlag(c.Tag.ToString(), false); break; + } } // Action/tags diff --git a/Source/Core/Windows/ThingEditFormUDMF.cs b/Source/Core/Windows/ThingEditFormUDMF.cs index d16e455d..58458dd1 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.cs @@ -607,10 +607,11 @@ namespace CodeImp.DoomBuilder.Windows // Apply all flags foreach(CheckBox c in flags.Checkboxes) { - if(c.CheckState == CheckState.Checked) - t.SetFlag(c.Tag.ToString(), true); - else if(c.CheckState == CheckState.Unchecked) - t.SetFlag(c.Tag.ToString(), false); + switch (c.CheckState) + { + case CheckState.Checked: t.SetFlag(c.Tag.ToString(), true); break; + case CheckState.Unchecked: t.SetFlag(c.Tag.ToString(), false); break; + } } // Action/tags diff --git a/Source/Core/Windows/ThingsFiltersForm.cs b/Source/Core/Windows/ThingsFiltersForm.cs index 4826f77c..ce6bb3a0 100644 --- a/Source/Core/Windows/ThingsFiltersForm.cs +++ b/Source/Core/Windows/ThingsFiltersForm.cs @@ -383,22 +383,22 @@ namespace CodeImp.DoomBuilder.Windows // Get selected filter ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter; - // New state is required? - if(box.CheckState == CheckState.Checked) + switch (box.CheckState) { - f.ForbiddenFields.Remove(box.Tag.ToString()); - if(!f.RequiredFields.Contains(box.Tag.ToString())) f.RequiredFields.Add(box.Tag.ToString()); - } - // New state is forbidden? - else if(box.CheckState == CheckState.Unchecked) - { - f.RequiredFields.Remove(box.Tag.ToString()); - if(!f.ForbiddenFields.Contains(box.Tag.ToString())) f.ForbiddenFields.Add(box.Tag.ToString()); - } - else - { - f.ForbiddenFields.Remove(box.Tag.ToString()); - f.RequiredFields.Remove(box.Tag.ToString()); + // New state is required? + case CheckState.Checked: + f.ForbiddenFields.Remove(box.Tag.ToString()); + if(!f.RequiredFields.Contains(box.Tag.ToString())) f.RequiredFields.Add(box.Tag.ToString()); + break; + // New state is forbidden? + case CheckState.Unchecked: + f.RequiredFields.Remove(box.Tag.ToString()); + if(!f.ForbiddenFields.Contains(box.Tag.ToString())) f.ForbiddenFields.Add(box.Tag.ToString()); + break; + default: + f.ForbiddenFields.Remove(box.Tag.ToString()); + f.RequiredFields.Remove(box.Tag.ToString()); + break; } } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 83cf30d1..15bcddd3 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -660,7 +660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes if(l != highlighted) Highlight(l); //mxd. Show tooltip? - if(General.Map.UDMF && mouselastpos != mousepos && highlighted != null && !highlighted.IsDisposed && highlighted.Fields.ContainsKey("comment")) + if(General.Map.UDMF && General.Settings.RenderComments && mouselastpos != mousepos && highlighted != null && !highlighted.IsDisposed && highlighted.Fields.ContainsKey("comment")) { string comment = highlighted.Fields.GetValue("comment", string.Empty); if(comment.Length > 2) diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 755960b2..f8465989 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -1035,7 +1035,7 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd. Show tooltip? - if(General.Map.UDMF && mouselastpos != mousepos && highlighted != null && !highlighted.IsDisposed && highlighted.Fields.ContainsKey("comment")) + if(General.Map.UDMF && General.Settings.RenderComments && mouselastpos != mousepos && highlighted != null && !highlighted.IsDisposed && highlighted.Fields.ContainsKey("comment")) { string comment = highlighted.Fields.GetValue("comment", string.Empty); if(comment.Length > 2) diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index 4f324c14..a5617bba 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -547,7 +547,7 @@ namespace CodeImp.DoomBuilder.BuilderModes Thing t = MapSet.NearestThingSquareRange(General.Map.ThingsFilter.VisibleThings, mousemappos, BuilderPlug.Me.HighlightThingsRange / renderer.Scale); //mxd. Show tooltip? - if(General.Map.UDMF && mouselastpos != mousepos && highlighted != null && !highlighted.IsDisposed && highlighted.Fields.ContainsKey("comment")) + if(General.Map.UDMF && General.Settings.RenderComments && mouselastpos != mousepos && highlighted != null && !highlighted.IsDisposed && highlighted.Fields.ContainsKey("comment")) { string comment = highlighted.Fields.GetValue("comment", string.Empty); if(comment.Length > 2) diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 9bd84313..d3d39648 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -673,36 +673,40 @@ namespace CodeImp.DoomBuilder.BuilderModes } //mxd - internal void StartRealtimeInterfaceUpdate(SelectionType selectionType) + internal void StartRealtimeInterfaceUpdate(SelectionType selectiontype) { - if (selectionType == SelectionType.Sectors || selectionType == SelectionType.Linedefs || selectionType == SelectionType.All) + switch (selectiontype) { - General.Interface.OnEditFormValuesChanged += Interface_OnSectorEditFormValuesChanged; - } - else if(selectionType == SelectionType.Things) - { - General.Interface.OnEditFormValuesChanged += Interface_OnThingEditFormValuesChanged; - } - else - { - General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; + case SelectionType.All: + case SelectionType.Linedefs: + case SelectionType.Sectors: + General.Interface.OnEditFormValuesChanged += Interface_OnSectorEditFormValuesChanged; + break; + case SelectionType.Things: + General.Interface.OnEditFormValuesChanged += Interface_OnThingEditFormValuesChanged; + break; + default: + General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; + break; } } //mxd - internal void StopRealtimeInterfaceUpdate(SelectionType selectionType) + internal void StopRealtimeInterfaceUpdate(SelectionType selectiontype) { - if(selectionType == SelectionType.Sectors || selectionType == SelectionType.Linedefs || selectionType == SelectionType.All) + switch (selectiontype) { - General.Interface.OnEditFormValuesChanged -= Interface_OnSectorEditFormValuesChanged; - } - else if(selectionType == SelectionType.Things) - { - General.Interface.OnEditFormValuesChanged -= Interface_OnThingEditFormValuesChanged; - } - else - { - General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; + case SelectionType.All: + case SelectionType.Linedefs: + case SelectionType.Sectors: + General.Interface.OnEditFormValuesChanged -= Interface_OnSectorEditFormValuesChanged; + break; + case SelectionType.Things: + General.Interface.OnEditFormValuesChanged -= Interface_OnThingEditFormValuesChanged; + break; + default: + General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; + break; } } @@ -837,10 +841,11 @@ namespace CodeImp.DoomBuilder.BuilderModes { if((Vector2D)t.Position == v.Position) { - if(t.Type == 1504) - slopefloorthings.Add(t); - else if(t.Type == 1505) - slopeceilingthings.Add(t); + switch (t.Type) + { + case 1504: slopefloorthings.Add(t); break; + case 1505: slopeceilingthings.Add(t); break; + } } } } diff --git a/Source/Plugins/BuilderModes/VisualModes/EffectCopySlope.cs b/Source/Plugins/BuilderModes/VisualModes/EffectCopySlope.cs index 79775705..c9bed682 100644 --- a/Source/Plugins/BuilderModes/VisualModes/EffectCopySlope.cs +++ b/Source/Plugins/BuilderModes/VisualModes/EffectCopySlope.cs @@ -45,13 +45,14 @@ namespace CodeImp.DoomBuilder.BuilderModes SectorData sourcesectordata = data.Mode.GetSectorData(sourcesector); if(!sourcesectordata.Updated) sourcesectordata.Update(); - if(thing.Type == 9510) + switch (thing.Type) { - data.Floor.plane = sourcesectordata.Floor.plane; - } - else if(thing.Type == 9511) - { - data.Ceiling.plane = sourcesectordata.Ceiling.plane; + case 9510: + data.Floor.plane = sourcesectordata.Floor.plane; + break; + case 9511: + data.Ceiling.plane = sourcesectordata.Ceiling.plane; + break; } sourcesectordata.AddUpdateSector(data.Sector, true); diff --git a/Source/Plugins/CommentsPanel/CommentsDocker.cs b/Source/Plugins/CommentsPanel/CommentsDocker.cs index 3cb3ab95..0346d04d 100644 --- a/Source/Plugins/CommentsPanel/CommentsDocker.cs +++ b/Source/Plugins/CommentsPanel/CommentsDocker.cs @@ -86,11 +86,10 @@ namespace CodeImp.DoomBuilder.CommentsPanel // Before detached from the docker public void Terminate() { - if(this.ParentForm != null) - { - this.ParentForm.Activated -= ParentForm_Activated; - } - + preventupdate = true; //mxd + if(this.ParentForm != null) this.ParentForm.Activated -= ParentForm_Activated; + updatetimer.Tick -= updatetimer_Tick; //mxd + enabledtimer.Tick -= enabledtimer_Tick; //mxd updatetimer.Stop(); enabledtimer.Stop(); } @@ -607,14 +606,21 @@ namespace CodeImp.DoomBuilder.CommentsPanel private void enabledtimer_Tick(object sender, EventArgs e) { if(General.Editing.Mode == null) return; //mxd - if(General.Editing.Mode.GetType().Name == "VerticesMode") - addcommentgroup.Enabled = (General.Map.Map.SelectedVerticessCount > 0); - else if(General.Editing.Mode.GetType().Name == "LinedefsMode") - addcommentgroup.Enabled = (General.Map.Map.SelectedLinedefsCount > 0); - else if(General.Editing.Mode.GetType().Name == "SectorsMode") - addcommentgroup.Enabled = (General.Map.Map.SelectedSectorsCount > 0); - else if(General.Editing.Mode.GetType().Name == "ThingsMode") - addcommentgroup.Enabled = (General.Map.Map.SelectedThingsCount > 0); + switch (General.Editing.Mode.GetType().Name) + { + case "VerticesMode": + addcommentgroup.Enabled = (General.Map.Map.SelectedVerticessCount > 0); + break; + case "LinedefsMode": + addcommentgroup.Enabled = (General.Map.Map.SelectedLinedefsCount > 0); + break; + case "SectorsMode": + addcommentgroup.Enabled = (General.Map.Map.SelectedSectorsCount > 0); + break; + case "ThingsMode": + addcommentgroup.Enabled = (General.Map.Map.SelectedThingsCount > 0); + break; + } } // Focus lost diff --git a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs index 9f0e1b81..1c80730e 100644 --- a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs +++ b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs @@ -774,27 +774,35 @@ namespace CodeImp.DoomBuilder.TagExplorer General.Map.Map.ClearAllSelected(); //make selection - if (info.Type == NodeInfoType.THING) + switch (info.Type) { - if(General.Editing.Mode.GetType().Name != "ThingsMode") General.Editing.ChangeMode("ThingsMode"); - Thing t = General.Map.Map.GetThingByIndex(info.Index); - if (t != null) t.Selected = true; - } - else if (info.Type == NodeInfoType.LINEDEF) - { - if(General.Editing.Mode.GetType().Name != "LinedefsMode") General.Editing.ChangeMode("LinedefsMode"); - Linedef l = General.Map.Map.GetLinedefByIndex(info.Index); - if (l != null) l.Selected = true; - } - else - { - if(General.Editing.Mode.GetType().Name != "SectorsMode") General.Editing.ChangeMode("SectorsMode"); - Sector s = General.Map.Map.GetSectorByIndex(info.Index); - if (s != null) + case NodeInfoType.THING: { - ((ClassicMode)General.Editing.Mode).SelectMapElement(s); - foreach (Sidedef sd in s.Sidedefs) sd.Line.Selected = true; + if(General.Editing.Mode.GetType().Name != "ThingsMode") General.Editing.ChangeMode("ThingsMode"); + Thing t = General.Map.Map.GetThingByIndex(info.Index); + if (t != null) t.Selected = true; } + break; + + case NodeInfoType.LINEDEF: + { + if(General.Editing.Mode.GetType().Name != "LinedefsMode") General.Editing.ChangeMode("LinedefsMode"); + Linedef l = General.Map.Map.GetLinedefByIndex(info.Index); + if (l != null) l.Selected = true; + } + break; + + default: + { + if(General.Editing.Mode.GetType().Name != "SectorsMode") General.Editing.ChangeMode("SectorsMode"); + Sector s = General.Map.Map.GetSectorByIndex(info.Index); + if (s != null) + { + ((ClassicMode)General.Editing.Mode).SelectMapElement(s); + foreach (Sidedef sd in s.Sidedefs) sd.Line.Selected = true; + } + } + break; } } @@ -804,34 +812,42 @@ namespace CodeImp.DoomBuilder.TagExplorer List points = new List(); RectangleF area = MapSet.CreateEmptyArea(); - if (info.Type == NodeInfoType.LINEDEF) + switch (info.Type) { - Linedef l = General.Map.Map.GetLinedefByIndex(info.Index); - points.Add(l.Start.Position); - points.Add(l.End.Position); - } - else if (info.Type == NodeInfoType.SECTOR) - { - Sector s = General.Map.Map.GetSectorByIndex(info.Index); - foreach (Sidedef sd in s.Sidedefs) + case NodeInfoType.LINEDEF: { - points.Add(sd.Line.Start.Position); - points.Add(sd.Line.End.Position); + Linedef l = General.Map.Map.GetLinedefByIndex(info.Index); + points.Add(l.Start.Position); + points.Add(l.End.Position); } - } - else if (info.Type == NodeInfoType.THING) - { - Thing t = General.Map.Map.GetThingByIndex(info.Index); - Vector2D p = t.Position; - points.Add(p); - points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f)); - points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f)); - points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f)); - points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f)); - } - else - { - General.Fail("Tag Explorer: unknown object type given to zoom in on!"); + break; + + case NodeInfoType.SECTOR: + { + Sector s = General.Map.Map.GetSectorByIndex(info.Index); + foreach (Sidedef sd in s.Sidedefs) + { + points.Add(sd.Line.Start.Position); + points.Add(sd.Line.End.Position); + } + } + break; + + case NodeInfoType.THING: + { + Thing t = General.Map.Map.GetThingByIndex(info.Index); + Vector2D p = t.Position; + points.Add(p); + points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f)); + points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f)); + points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f)); + points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f)); + } + break; + + default: + General.Fail("Tag Explorer: unknown object type given to zoom in on!"); + break; } // Make a view area from the points diff --git a/Source/Plugins/TagRange/TagRangeForm.cs b/Source/Plugins/TagRange/TagRangeForm.cs index 13e2c781..8c481a51 100644 --- a/Source/Plugins/TagRange/TagRangeForm.cs +++ b/Source/Plugins/TagRange/TagRangeForm.cs @@ -31,36 +31,43 @@ namespace CodeImp.DoomBuilder.TagRange { General.Map.Map.ClearAllMarks(false); - string modename = General.Editing.Mode.GetType().Name; - if(modename == "SectorsMode") + switch(General.Editing.Mode.GetType().Name) { - General.Map.Map.MarkSelectedSectors(true, true); //mxd - selectiontype = UniversalType.SectorTag; - ICollection list = General.Map.Map.GetSelectedSectors(true); - initialtags = new List(list.Count); //mxd - foreach(Sector element in list) initialtags.Add(element.Tag); //mxd - selectioncount = list.Count; - this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " sectors" : " sector"); - } - else if(modename == "LinedefsMode") - { - General.Map.Map.MarkSelectedLinedefs(true, true); //mxd - selectiontype = UniversalType.LinedefTag; - ICollection list = General.Map.Map.GetSelectedLinedefs(true); - initialtags = new List(list.Count); //mxd - foreach(Linedef element in list) initialtags.Add(element.Tag); //mxd - selectioncount = list.Count; - this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " linedefs" : " linedef"); - } - else if(modename == "ThingsMode") - { - General.Map.Map.MarkSelectedThings(true, true); //mxd - selectiontype = UniversalType.ThingTag; - ICollection list = General.Map.Map.GetSelectedThings(true); - initialtags = new List(list.Count); //mxd - foreach(Thing element in list) initialtags.Add(element.Tag); //mxd - selectioncount = list.Count; - this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " things" : " thing"); + case "SectorsMode": + { + General.Map.Map.MarkSelectedSectors(true, true); //mxd + selectiontype = UniversalType.SectorTag; + ICollection list = General.Map.Map.GetSelectedSectors(true); + initialtags = new List(list.Count); //mxd + foreach(Sector element in list) initialtags.Add(element.Tag); //mxd + selectioncount = list.Count; + this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " sectors" : " sector"); + } + break; + + case "LinedefsMode": + { + General.Map.Map.MarkSelectedLinedefs(true, true); //mxd + selectiontype = UniversalType.LinedefTag; + ICollection list = General.Map.Map.GetSelectedLinedefs(true); + initialtags = new List(list.Count); //mxd + foreach(Linedef element in list) initialtags.Add(element.Tag); //mxd + selectioncount = list.Count; + this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " linedefs" : " linedef"); + } + break; + + case "ThingsMode": + { + General.Map.Map.MarkSelectedThings(true, true); //mxd + selectiontype = UniversalType.ThingTag; + ICollection list = General.Map.Map.GetSelectedThings(true); + initialtags = new List(list.Count); //mxd + foreach(Thing element in list) initialtags.Add(element.Tag); //mxd + selectioncount = list.Count; + this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " things" : " thing"); + } + break; } // Find out which tags are used