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.
This commit is contained in:
MaxED 2015-07-15 09:09:47 +00:00
parent 0d4c2a8f32
commit 1118fd6b98
22 changed files with 336 additions and 258 deletions

View file

@ -111,10 +111,15 @@ namespace CodeImp.DoomBuilder.Controls
int sortcolumn = General.Settings.ReadSetting("customfieldssortcolumn", 0); int sortcolumn = General.Settings.ReadSetting("customfieldssortcolumn", 0);
int sortorder = General.Settings.ReadSetting("customfieldssortorder", (int)ListSortDirection.Ascending); int sortorder = General.Settings.ReadSetting("customfieldssortorder", (int)ListSortDirection.Ascending);
if(sortorder == (int)SortOrder.Ascending) switch (sortorder)
{
case (int)SortOrder.Ascending:
fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending); fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Ascending);
else if(sortorder == (int)SortOrder.Descending) break;
case (int)SortOrder.Descending:
fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Descending); fieldslist.Sort(fieldslist.Columns[sortcolumn], ListSortDirection.Descending);
break;
}
} }
// This adds a list of fixed fields (in undefined state) // This adds a list of fixed fields (in undefined state)

View file

@ -98,13 +98,10 @@ namespace CodeImp.DoomBuilder.Controls
private void preview_Click(object sender, EventArgs e) private void preview_Click(object sender, EventArgs e)
{ {
imagebox.BackColor = SystemColors.Highlight; imagebox.BackColor = SystemColors.Highlight;
if(button == MouseButtons.Right) switch (button)
{ {
name.Text = "-"; case MouseButtons.Right: name.Text = "-"; break;
} case MouseButtons.Left: name.Text = BrowseImage(name.Text); break;
else if(button == MouseButtons.Left)
{
name.Text = BrowseImage(name.Text);
} }
} }

View file

@ -232,15 +232,15 @@ namespace CodeImp.DoomBuilder.Controls
{ {
string ext = Path.GetExtension(path); string ext = Path.GetExtension(path);
if(string.IsNullOrEmpty(ext)) continue; if(string.IsNullOrEmpty(ext)) continue;
switch(ext.ToLower())
ext = ext.ToLower();
if(ext == ".wad")
{ {
case ".wad":
AddItem(new DataLocation(DataLocation.RESOURCE_WAD, path, false, false, false)); AddItem(new DataLocation(DataLocation.RESOURCE_WAD, path, false, false, false));
} break;
else if(ext == ".pk3" || ext == ".pk7") case ".pk7":
{ case ".pk3":
AddItem(new DataLocation(DataLocation.RESOURCE_PK3, path, false, false, false)); AddItem(new DataLocation(DataLocation.RESOURCE_PK3, path, false, false, false));
break;
} }
} }
else if(Directory.Exists(path)) else if(Directory.Exists(path))

View file

@ -435,14 +435,12 @@ namespace CodeImp.DoomBuilder.Controls
{ {
// Ask to save // Ask to save
DialogResult result = MessageBox.Show(this.ParentForm, "Do you want to save changes to " + t.Text + "?", "Close File", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); 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 case DialogResult.Yes:
if(!SaveScript(t)) return false; if(!SaveScript(t)) return false;
} break;
else if(result == DialogResult.Cancel) case DialogResult.Cancel:
{
// Cancel
return false; return false;
} }
} }

View file

@ -199,12 +199,12 @@ namespace CodeImp.DoomBuilder.Data
if(p.rotate != 0) if(p.rotate != 0)
{ {
RotateFlipType rotate; RotateFlipType rotate;
if(p.rotate == 90) switch (p.rotate)
rotate = RotateFlipType.Rotate90FlipNone; {
else if(p.rotate == 180) case 90: rotate = RotateFlipType.Rotate90FlipNone; break;
rotate = RotateFlipType.Rotate180FlipNone; case 180: rotate = RotateFlipType.Rotate180FlipNone; break;
else default: rotate = RotateFlipType.Rotate270FlipNone; break;
rotate = RotateFlipType.Rotate270FlipNone; }
patchbmp.RotateFlip(rotate); patchbmp.RotateFlip(rotate);
} }

View file

@ -112,13 +112,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3
} }
string ext = Path.GetExtension(mde.ModelNames[i]); string ext = Path.GetExtension(mde.ModelNames[i]);
switch (ext)
if(ext == ".md3") {
case ".md3":
result = ReadMD3Model(ref bbs, mde, useSkins, ms, device); result = ReadMD3Model(ref bbs, mde, useSkins, ms, device);
else if(ext == ".md2") break;
case ".md2":
result = ReadMD2Model(ref bbs, mde, ms, device); result = ReadMD2Model(ref bbs, mde, ms, device);
else break;
default:
result.Errors = "model format is not supported"; result.Errors = "model format is not supported";
break;
}
ms.Close(); ms.Close();
ms.Dispose(); ms.Dispose();

View file

@ -199,8 +199,11 @@ namespace CodeImp.DoomBuilder.Map
foreach(DictionaryEntry entry in (ListDictionary)tagLabelsEntry.Value) foreach(DictionaryEntry entry in (ListDictionary)tagLabelsEntry.Value)
{ {
if((string)entry.Key == "tag") tag = (int)entry.Value; switch ((string)entry.Key)
else if((string)entry.Key == "label") label = (string)entry.Value; {
case "tag": tag = (int)entry.Value; break;
case "label": label = (string)entry.Value; break;
}
} }
if(tag != 0 && !string.IsNullOrEmpty(label)) if(tag != 0 && !string.IsNullOrEmpty(label))

View file

@ -52,10 +52,15 @@ namespace CodeImp.DoomBuilder.Rendering
Initialize(type); Initialize(type);
// Set coordinates // Set coordinates
if(type == PrimitiveType.TriangleList) switch (type)
{
case PrimitiveType.TriangleList:
SetTriangleListCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f); SetTriangleListCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f);
else if(type == PrimitiveType.TriangleStrip) break;
case PrimitiveType.TriangleStrip:
SetTriangleStripCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f); SetTriangleStripCoordinates(left, top, right, bottom, 0f, 0f, 1f, 1f);
break;
}
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -74,10 +79,15 @@ namespace CodeImp.DoomBuilder.Rendering
thd = 1f / theight; thd = 1f / theight;
// Set coordinates // Set coordinates
if(type == PrimitiveType.TriangleList) switch (type)
{
case PrimitiveType.TriangleList:
SetTriangleListCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd); SetTriangleListCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd);
else if(type == PrimitiveType.TriangleStrip) break;
case PrimitiveType.TriangleStrip:
SetTriangleStripCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd); SetTriangleStripCoordinates(left, top, right, bottom, twd, thd, 1f - twd, 1f - thd);
break;
}
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -90,10 +100,15 @@ namespace CodeImp.DoomBuilder.Rendering
Initialize(type); Initialize(type);
// Set coordinates // Set coordinates
if(type == PrimitiveType.TriangleList) switch (type)
{
case PrimitiveType.TriangleList:
SetTriangleListCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb); SetTriangleListCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb);
else if(type == PrimitiveType.TriangleStrip) break;
case PrimitiveType.TriangleStrip:
SetTriangleStripCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb); SetTriangleStripCoordinates(pos.Left, pos.Top, pos.Right, pos.Bottom, tl, tt, tr, tb);
break;
}
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -106,10 +121,15 @@ namespace CodeImp.DoomBuilder.Rendering
Initialize(type); Initialize(type);
// Set coordinates // Set coordinates
if(type == PrimitiveType.TriangleList) switch (type)
{
case PrimitiveType.TriangleList:
SetTriangleListCoordinates(left, top, right, bottom, tl, tt, tr, tb); SetTriangleListCoordinates(left, top, right, bottom, tl, tt, tr, tb);
else if(type == PrimitiveType.TriangleStrip) break;
case PrimitiveType.TriangleStrip:
SetTriangleStripCoordinates(left, top, right, bottom, tl, tt, tr, tb); SetTriangleStripCoordinates(left, top, right, bottom, tl, tt, tr, tb);
break;
}
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -131,23 +151,22 @@ namespace CodeImp.DoomBuilder.Rendering
public void SetColors(int clt, int crt, int clb, int crb) public void SetColors(int clt, int crt, int clb, int crb)
{ {
// Determine polygon type // Determine polygon type
if(type == PrimitiveType.TriangleList) switch (type)
{ {
// Go for all vertices to set the color case PrimitiveType.TriangleList:
vertices[0].c = clt; vertices[0].c = clt;
vertices[1].c = crt; vertices[1].c = crt;
vertices[2].c = clb; vertices[2].c = clb;
vertices[3].c = clb; vertices[3].c = clb;
vertices[4].c = crt; vertices[4].c = crt;
vertices[5].c = crb; vertices[5].c = crb;
} break;
else if(type == PrimitiveType.TriangleStrip) case PrimitiveType.TriangleStrip:
{
// Go for all vertices to set the color
vertices[0].c = clt; vertices[0].c = clt;
vertices[1].c = crt; vertices[1].c = crt;
vertices[2].c = clb; vertices[2].c = clb;
vertices[3].c = crb; vertices[3].c = crb;
break;
} }
} }
@ -216,12 +235,12 @@ namespace CodeImp.DoomBuilder.Rendering
this.type = type; this.type = type;
// Determine number of vertices // Determine number of vertices
if(type == PrimitiveType.TriangleList) switch (type)
numvertices = 6; {
else if(type == PrimitiveType.TriangleStrip) case PrimitiveType.TriangleList: numvertices = 6; break;
numvertices = 4; case PrimitiveType.TriangleStrip: numvertices = 4; break;
else default: throw new NotSupportedException("Unsupported PrimitiveType");
throw new NotSupportedException("Unsupported PrimitiveType"); }
// Make the array // Make the array
vertices = new FlatVertex[numvertices]; vertices = new FlatVertex[numvertices];

View file

@ -137,16 +137,18 @@ namespace CodeImp.DoomBuilder.Rendering
} }
else //only horizontal/verticel walls are shaded else //only horizontal/verticel walls are shaded
{ {
int angle = (int)Angle2D.RadToDeg(sd.Angle); switch((int)Angle2D.RadToDeg(sd.Angle))
//horizontal wall
if(angle == 270 || angle == 90)
{ {
// Horizontal wall
case 90:
case 270:
level = General.Clamp(level + General.Map.Data.MapInfo.HorizWallShade, 0, 255); level = General.Clamp(level + General.Map.Data.MapInfo.HorizWallShade, 0, 255);
} break;
//vertical wall // Vertical wall
else if(angle == 0 || angle == 180) case 180:
{ case 0:
level = General.Clamp(level + General.Map.Data.MapInfo.VertWallShade, 0, 255); level = General.Clamp(level + General.Map.Data.MapInfo.VertWallShade, 0, 255);
break;
} }
} }
} }

View file

@ -806,8 +806,11 @@ namespace CodeImp.DoomBuilder.Windows
foreach(CheckBox c in udmfactivates.Checkboxes) foreach(CheckBox c in udmfactivates.Checkboxes)
{ {
LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo); LinedefActivateInfo ai = (c.Tag as LinedefActivateInfo);
if(c.CheckState == CheckState.Checked) l.SetFlag(ai.Key, true); switch (c.CheckState)
else if(c.CheckState == CheckState.Unchecked) l.SetFlag(ai.Key, false); {
case CheckState.Checked: l.SetFlag(ai.Key, true); break;
case CheckState.Unchecked: l.SetFlag(ai.Key, false); break;
}
} }
// Action/tags // Action/tags
@ -1450,13 +1453,14 @@ namespace CodeImp.DoomBuilder.Windows
if(l.Front != null) if(l.Front != null)
{ {
bool absolute = false; bool absolute = false;
if(cbLightAbsoluteFront.CheckState == CheckState.Indeterminate) switch (cbLightAbsoluteFront.CheckState)
{ {
case CheckState.Indeterminate:
absolute = l.Front.Fields.GetValue("lightabsolute", false); absolute = l.Front.Fields.GetValue("lightabsolute", false);
} break;
else if(cbLightAbsoluteFront.CheckState == CheckState.Checked) case CheckState.Checked:
{
absolute = true; absolute = true;
break;
} }
int value = General.Clamp(lightFront.GetResult((linedefprops[i].Front != null ? linedefprops[i].Front.Brightness : 0)), (absolute ? 0 : -255), 255); 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) if(l.Back != null)
{ {
bool absolute = false; bool absolute = false;
if(cbLightAbsoluteBack.CheckState == CheckState.Indeterminate) switch (cbLightAbsoluteBack.CheckState)
{ {
case CheckState.Indeterminate:
absolute = l.Back.Fields.GetValue("lightabsolute", false); absolute = l.Back.Fields.GetValue("lightabsolute", false);
} break;
else if(cbLightAbsoluteBack.CheckState == CheckState.Checked) case CheckState.Checked:
{
absolute = true; absolute = true;
break;
} }
int value = General.Clamp(lightBack.GetResult((linedefprops[i].Back != null ? linedefprops[i].Back.Brightness : 0)), (absolute ? 0 : -255), 255); int value = General.Clamp(lightBack.GetResult((linedefprops[i].Back != null ? linedefprops[i].Back.Brightness : 0)), (absolute ? 0 : -255), 255);

View file

@ -673,8 +673,11 @@ namespace CodeImp.DoomBuilder.Windows
// Apply all flags // Apply all flags
foreach(CheckBox c in flags.Checkboxes) foreach(CheckBox c in flags.Checkboxes)
{ {
if(c.CheckState == CheckState.Checked) s.SetFlag(c.Tag.ToString(), true); switch (c.CheckState)
else if(c.CheckState == CheckState.Unchecked) s.SetFlag(c.Tag.ToString(), false); {
case CheckState.Checked: s.SetFlag(c.Tag.ToString(), true); break;
case CheckState.Unchecked: s.SetFlag(c.Tag.ToString(), false); break;
}
} }
// Effects // Effects
@ -1122,13 +1125,14 @@ namespace CodeImp.DoomBuilder.Windows
foreach(Sector s in sectors) foreach(Sector s in sectors)
{ {
bool absolute = false; bool absolute = false;
if(ceilLightAbsolute.CheckState == CheckState.Indeterminate) switch (ceilLightAbsolute.CheckState)
{ {
case CheckState.Indeterminate:
absolute = s.Fields.GetValue("lightceilingabsolute", false); absolute = s.Fields.GetValue("lightceilingabsolute", false);
} break;
else if(ceilLightAbsolute.CheckState == CheckState.Checked) case CheckState.Checked:
{
absolute = true; absolute = true;
break;
} }
int value = General.Clamp(ceilBrightness.GetResult(sectorprops[s].CeilBrightness), (absolute ? 0 : -255), 255); 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) foreach(Sector s in sectors)
{ {
bool absolute = false; bool absolute = false;
if(floorLightAbsolute.CheckState == CheckState.Indeterminate) switch (floorLightAbsolute.CheckState)
{ {
case CheckState.Indeterminate:
absolute = s.Fields.GetValue("lightfloorabsolute", false); absolute = s.Fields.GetValue("lightfloorabsolute", false);
} break;
else if(floorLightAbsolute.CheckState == CheckState.Checked) case CheckState.Checked:
{
absolute = true; absolute = true;
break;
} }
int value = General.Clamp(floorBrightness.GetResult(sectorprops[s].FloorBrightness), (absolute ? 0 : -255), 255); int value = General.Clamp(floorBrightness.GetResult(sectorprops[s].FloorBrightness), (absolute ? 0 : -255), 255);

View file

@ -473,8 +473,11 @@ namespace CodeImp.DoomBuilder.Windows
// Apply all flags // Apply all flags
foreach(CheckBox c in flags.Checkboxes) foreach(CheckBox c in flags.Checkboxes)
{ {
if(c.CheckState == CheckState.Checked) t.SetFlag(c.Tag.ToString(), true); switch (c.CheckState)
else if(c.CheckState == CheckState.Unchecked) t.SetFlag(c.Tag.ToString(), false); {
case CheckState.Checked: t.SetFlag(c.Tag.ToString(), true); break;
case CheckState.Unchecked: t.SetFlag(c.Tag.ToString(), false); break;
}
} }
// Action/tags // Action/tags

View file

@ -607,10 +607,11 @@ namespace CodeImp.DoomBuilder.Windows
// Apply all flags // Apply all flags
foreach(CheckBox c in flags.Checkboxes) foreach(CheckBox c in flags.Checkboxes)
{ {
if(c.CheckState == CheckState.Checked) switch (c.CheckState)
t.SetFlag(c.Tag.ToString(), true); {
else if(c.CheckState == CheckState.Unchecked) case CheckState.Checked: t.SetFlag(c.Tag.ToString(), true); break;
t.SetFlag(c.Tag.ToString(), false); case CheckState.Unchecked: t.SetFlag(c.Tag.ToString(), false); break;
}
} }
// Action/tags // Action/tags

View file

@ -383,22 +383,22 @@ namespace CodeImp.DoomBuilder.Windows
// Get selected filter // Get selected filter
ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter; ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter;
// New state is required? switch (box.CheckState)
if(box.CheckState == CheckState.Checked)
{ {
// New state is required?
case CheckState.Checked:
f.ForbiddenFields.Remove(box.Tag.ToString()); f.ForbiddenFields.Remove(box.Tag.ToString());
if(!f.RequiredFields.Contains(box.Tag.ToString())) f.RequiredFields.Add(box.Tag.ToString()); if(!f.RequiredFields.Contains(box.Tag.ToString())) f.RequiredFields.Add(box.Tag.ToString());
} break;
// New state is forbidden? // New state is forbidden?
else if(box.CheckState == CheckState.Unchecked) case CheckState.Unchecked:
{
f.RequiredFields.Remove(box.Tag.ToString()); f.RequiredFields.Remove(box.Tag.ToString());
if(!f.ForbiddenFields.Contains(box.Tag.ToString())) f.ForbiddenFields.Add(box.Tag.ToString()); if(!f.ForbiddenFields.Contains(box.Tag.ToString())) f.ForbiddenFields.Add(box.Tag.ToString());
} break;
else default:
{
f.ForbiddenFields.Remove(box.Tag.ToString()); f.ForbiddenFields.Remove(box.Tag.ToString());
f.RequiredFields.Remove(box.Tag.ToString()); f.RequiredFields.Remove(box.Tag.ToString());
break;
} }
} }
} }

View file

@ -660,7 +660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(l != highlighted) Highlight(l); if(l != highlighted) Highlight(l);
//mxd. Show tooltip? //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); string comment = highlighted.Fields.GetValue("comment", string.Empty);
if(comment.Length > 2) if(comment.Length > 2)

View file

@ -1035,7 +1035,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd. Show tooltip? //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); string comment = highlighted.Fields.GetValue("comment", string.Empty);
if(comment.Length > 2) if(comment.Length > 2)

View file

@ -547,7 +547,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
Thing t = MapSet.NearestThingSquareRange(General.Map.ThingsFilter.VisibleThings, mousemappos, BuilderPlug.Me.HighlightThingsRange / renderer.Scale); Thing t = MapSet.NearestThingSquareRange(General.Map.ThingsFilter.VisibleThings, mousemappos, BuilderPlug.Me.HighlightThingsRange / renderer.Scale);
//mxd. Show tooltip? //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); string comment = highlighted.Fields.GetValue("comment", string.Empty);
if(comment.Length > 2) if(comment.Length > 2)

View file

@ -673,36 +673,40 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd //mxd
internal void StartRealtimeInterfaceUpdate(SelectionType selectionType) internal void StartRealtimeInterfaceUpdate(SelectionType selectiontype)
{ {
if (selectionType == SelectionType.Sectors || selectionType == SelectionType.Linedefs || selectionType == SelectionType.All) switch (selectiontype)
{ {
case SelectionType.All:
case SelectionType.Linedefs:
case SelectionType.Sectors:
General.Interface.OnEditFormValuesChanged += Interface_OnSectorEditFormValuesChanged; General.Interface.OnEditFormValuesChanged += Interface_OnSectorEditFormValuesChanged;
} break;
else if(selectionType == SelectionType.Things) case SelectionType.Things:
{
General.Interface.OnEditFormValuesChanged += Interface_OnThingEditFormValuesChanged; General.Interface.OnEditFormValuesChanged += Interface_OnThingEditFormValuesChanged;
} break;
else default:
{
General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged; General.Interface.OnEditFormValuesChanged += Interface_OnEditFormValuesChanged;
break;
} }
} }
//mxd //mxd
internal void StopRealtimeInterfaceUpdate(SelectionType selectionType) internal void StopRealtimeInterfaceUpdate(SelectionType selectiontype)
{ {
if(selectionType == SelectionType.Sectors || selectionType == SelectionType.Linedefs || selectionType == SelectionType.All) switch (selectiontype)
{ {
case SelectionType.All:
case SelectionType.Linedefs:
case SelectionType.Sectors:
General.Interface.OnEditFormValuesChanged -= Interface_OnSectorEditFormValuesChanged; General.Interface.OnEditFormValuesChanged -= Interface_OnSectorEditFormValuesChanged;
} break;
else if(selectionType == SelectionType.Things) case SelectionType.Things:
{
General.Interface.OnEditFormValuesChanged -= Interface_OnThingEditFormValuesChanged; General.Interface.OnEditFormValuesChanged -= Interface_OnThingEditFormValuesChanged;
} break;
else default:
{
General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged; General.Interface.OnEditFormValuesChanged -= Interface_OnEditFormValuesChanged;
break;
} }
} }
@ -837,10 +841,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if((Vector2D)t.Position == v.Position) if((Vector2D)t.Position == v.Position)
{ {
if(t.Type == 1504) switch (t.Type)
slopefloorthings.Add(t); {
else if(t.Type == 1505) case 1504: slopefloorthings.Add(t); break;
slopeceilingthings.Add(t); case 1505: slopeceilingthings.Add(t); break;
}
} }
} }
} }

View file

@ -45,13 +45,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
SectorData sourcesectordata = data.Mode.GetSectorData(sourcesector); SectorData sourcesectordata = data.Mode.GetSectorData(sourcesector);
if(!sourcesectordata.Updated) sourcesectordata.Update(); if(!sourcesectordata.Updated) sourcesectordata.Update();
if(thing.Type == 9510) switch (thing.Type)
{ {
case 9510:
data.Floor.plane = sourcesectordata.Floor.plane; data.Floor.plane = sourcesectordata.Floor.plane;
} break;
else if(thing.Type == 9511) case 9511:
{
data.Ceiling.plane = sourcesectordata.Ceiling.plane; data.Ceiling.plane = sourcesectordata.Ceiling.plane;
break;
} }
sourcesectordata.AddUpdateSector(data.Sector, true); sourcesectordata.AddUpdateSector(data.Sector, true);

View file

@ -86,11 +86,10 @@ namespace CodeImp.DoomBuilder.CommentsPanel
// Before detached from the docker // Before detached from the docker
public void Terminate() public void Terminate()
{ {
if(this.ParentForm != null) preventupdate = true; //mxd
{ if(this.ParentForm != null) this.ParentForm.Activated -= ParentForm_Activated;
this.ParentForm.Activated -= ParentForm_Activated; updatetimer.Tick -= updatetimer_Tick; //mxd
} enabledtimer.Tick -= enabledtimer_Tick; //mxd
updatetimer.Stop(); updatetimer.Stop();
enabledtimer.Stop(); enabledtimer.Stop();
} }
@ -607,14 +606,21 @@ namespace CodeImp.DoomBuilder.CommentsPanel
private void enabledtimer_Tick(object sender, EventArgs e) private void enabledtimer_Tick(object sender, EventArgs e)
{ {
if(General.Editing.Mode == null) return; //mxd if(General.Editing.Mode == null) return; //mxd
if(General.Editing.Mode.GetType().Name == "VerticesMode") switch (General.Editing.Mode.GetType().Name)
{
case "VerticesMode":
addcommentgroup.Enabled = (General.Map.Map.SelectedVerticessCount > 0); addcommentgroup.Enabled = (General.Map.Map.SelectedVerticessCount > 0);
else if(General.Editing.Mode.GetType().Name == "LinedefsMode") break;
case "LinedefsMode":
addcommentgroup.Enabled = (General.Map.Map.SelectedLinedefsCount > 0); addcommentgroup.Enabled = (General.Map.Map.SelectedLinedefsCount > 0);
else if(General.Editing.Mode.GetType().Name == "SectorsMode") break;
case "SectorsMode":
addcommentgroup.Enabled = (General.Map.Map.SelectedSectorsCount > 0); addcommentgroup.Enabled = (General.Map.Map.SelectedSectorsCount > 0);
else if(General.Editing.Mode.GetType().Name == "ThingsMode") break;
case "ThingsMode":
addcommentgroup.Enabled = (General.Map.Map.SelectedThingsCount > 0); addcommentgroup.Enabled = (General.Map.Map.SelectedThingsCount > 0);
break;
}
} }
// Focus lost // Focus lost

View file

@ -774,19 +774,25 @@ namespace CodeImp.DoomBuilder.TagExplorer
General.Map.Map.ClearAllSelected(); General.Map.Map.ClearAllSelected();
//make selection //make selection
if (info.Type == NodeInfoType.THING) switch (info.Type)
{
case NodeInfoType.THING:
{ {
if(General.Editing.Mode.GetType().Name != "ThingsMode") General.Editing.ChangeMode("ThingsMode"); if(General.Editing.Mode.GetType().Name != "ThingsMode") General.Editing.ChangeMode("ThingsMode");
Thing t = General.Map.Map.GetThingByIndex(info.Index); Thing t = General.Map.Map.GetThingByIndex(info.Index);
if (t != null) t.Selected = true; if (t != null) t.Selected = true;
} }
else if (info.Type == NodeInfoType.LINEDEF) break;
case NodeInfoType.LINEDEF:
{ {
if(General.Editing.Mode.GetType().Name != "LinedefsMode") General.Editing.ChangeMode("LinedefsMode"); if(General.Editing.Mode.GetType().Name != "LinedefsMode") General.Editing.ChangeMode("LinedefsMode");
Linedef l = General.Map.Map.GetLinedefByIndex(info.Index); Linedef l = General.Map.Map.GetLinedefByIndex(info.Index);
if (l != null) l.Selected = true; if (l != null) l.Selected = true;
} }
else break;
default:
{ {
if(General.Editing.Mode.GetType().Name != "SectorsMode") General.Editing.ChangeMode("SectorsMode"); if(General.Editing.Mode.GetType().Name != "SectorsMode") General.Editing.ChangeMode("SectorsMode");
Sector s = General.Map.Map.GetSectorByIndex(info.Index); Sector s = General.Map.Map.GetSectorByIndex(info.Index);
@ -796,6 +802,8 @@ namespace CodeImp.DoomBuilder.TagExplorer
foreach (Sidedef sd in s.Sidedefs) sd.Line.Selected = true; foreach (Sidedef sd in s.Sidedefs) sd.Line.Selected = true;
} }
} }
break;
}
} }
//focus on element? //focus on element?
@ -804,13 +812,17 @@ namespace CodeImp.DoomBuilder.TagExplorer
List<Vector2D> points = new List<Vector2D>(); List<Vector2D> points = new List<Vector2D>();
RectangleF area = MapSet.CreateEmptyArea(); RectangleF area = MapSet.CreateEmptyArea();
if (info.Type == NodeInfoType.LINEDEF) switch (info.Type)
{
case NodeInfoType.LINEDEF:
{ {
Linedef l = General.Map.Map.GetLinedefByIndex(info.Index); Linedef l = General.Map.Map.GetLinedefByIndex(info.Index);
points.Add(l.Start.Position); points.Add(l.Start.Position);
points.Add(l.End.Position); points.Add(l.End.Position);
} }
else if (info.Type == NodeInfoType.SECTOR) break;
case NodeInfoType.SECTOR:
{ {
Sector s = General.Map.Map.GetSectorByIndex(info.Index); Sector s = General.Map.Map.GetSectorByIndex(info.Index);
foreach (Sidedef sd in s.Sidedefs) foreach (Sidedef sd in s.Sidedefs)
@ -819,7 +831,9 @@ namespace CodeImp.DoomBuilder.TagExplorer
points.Add(sd.Line.End.Position); points.Add(sd.Line.End.Position);
} }
} }
else if (info.Type == NodeInfoType.THING) break;
case NodeInfoType.THING:
{ {
Thing t = General.Map.Map.GetThingByIndex(info.Index); Thing t = General.Map.Map.GetThingByIndex(info.Index);
Vector2D p = t.Position; Vector2D p = t.Position;
@ -829,9 +843,11 @@ namespace CodeImp.DoomBuilder.TagExplorer
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 break;
{
default:
General.Fail("Tag Explorer: unknown object type given to zoom in on!"); General.Fail("Tag Explorer: unknown object type given to zoom in on!");
break;
} }
// Make a view area from the points // Make a view area from the points

View file

@ -31,8 +31,9 @@ namespace CodeImp.DoomBuilder.TagRange
{ {
General.Map.Map.ClearAllMarks(false); General.Map.Map.ClearAllMarks(false);
string modename = General.Editing.Mode.GetType().Name; switch(General.Editing.Mode.GetType().Name)
if(modename == "SectorsMode") {
case "SectorsMode":
{ {
General.Map.Map.MarkSelectedSectors(true, true); //mxd General.Map.Map.MarkSelectedSectors(true, true); //mxd
selectiontype = UniversalType.SectorTag; selectiontype = UniversalType.SectorTag;
@ -42,7 +43,9 @@ namespace CodeImp.DoomBuilder.TagRange
selectioncount = list.Count; selectioncount = list.Count;
this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " sectors" : " sector"); this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " sectors" : " sector");
} }
else if(modename == "LinedefsMode") break;
case "LinedefsMode":
{ {
General.Map.Map.MarkSelectedLinedefs(true, true); //mxd General.Map.Map.MarkSelectedLinedefs(true, true); //mxd
selectiontype = UniversalType.LinedefTag; selectiontype = UniversalType.LinedefTag;
@ -52,7 +55,9 @@ namespace CodeImp.DoomBuilder.TagRange
selectioncount = list.Count; selectioncount = list.Count;
this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " linedefs" : " linedef"); this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " linedefs" : " linedef");
} }
else if(modename == "ThingsMode") break;
case "ThingsMode":
{ {
General.Map.Map.MarkSelectedThings(true, true); //mxd General.Map.Map.MarkSelectedThings(true, true); //mxd
selectiontype = UniversalType.ThingTag; selectiontype = UniversalType.ThingTag;
@ -62,6 +67,8 @@ namespace CodeImp.DoomBuilder.TagRange
selectioncount = list.Count; selectioncount = list.Count;
this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " things" : " thing"); this.Text = "Create tag range for " + selectioncount + (selectioncount > 1 ? " things" : " thing");
} }
break;
}
// Find out which tags are used // Find out which tags are used
usedtags = new Dictionary<int, bool>(); usedtags = new Dictionary<int, bool>();