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 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)

View file

@ -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;
}
}

View file

@ -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))

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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();

View file

@ -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))

View file

@ -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];

View file

@ -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;
}
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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;
}
}
}

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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;
}
}
}
}

View file

@ -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);

View file

@ -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

View file

@ -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<Vector2D> points = new List<Vector2D>();
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

View file

@ -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<Sector> list = General.Map.Map.GetSelectedSectors(true);
initialtags = new List<int>(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<Linedef> list = General.Map.Map.GetSelectedLinedefs(true);
initialtags = new List<int>(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<Thing> list = General.Map.Map.GetSelectedThings(true);
initialtags = new List<int>(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<Sector> list = General.Map.Map.GetSelectedSectors(true);
initialtags = new List<int>(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<Linedef> list = General.Map.Map.GetSelectedLinedefs(true);
initialtags = new List<int>(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<Thing> list = General.Map.Map.GetSelectedThings(true);
initialtags = new List<int>(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