Added, Find & Replace mode, UDMF: added Linedef activation flags to the "Find Linedef flags" search mode flags list.

Changed, Sound Propagation mode: all sound zones are now shown when no sector is highlighted.
Changed, Sound Environments mode: the mode is now available only in UDMF map format.
Changed, Color Picker plugin: the plugin functionality is no longer available in Doom map format.
Restored the ability to create superimposed lines by dragging them with "Snap to Geometry" mode disabled.
Fixed, Sound Propagation mode: fixed a crash when a single-sided linedef had "Block Sound" flag.
Fixed, Find & Replace mode: in some cases "Find Sector/Sidedef/Linedef/Thing flags" search modes failed to find map elements with required flags.
Fixed, Edit Selection mode: in some cases incorrect geometry was created after applying multipart sector edit when "Replace with Dragged Geometry" mode was enabled.
Fixed a crash caused by eventual GDI font objects overflow.
This commit is contained in:
MaxED 2016-07-02 22:27:20 +00:00 committed by spherallic
parent b2a14c59f8
commit 972d55f066
17 changed files with 81 additions and 65 deletions

View file

@ -19,7 +19,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
@ -114,8 +113,6 @@ namespace CodeImp.DoomBuilder.Config
private string textlabelfontname;
private int textlabelfontsize;
private bool textlabelfontbold;
private Font textlabelfont;
private bool textlabelfontupdaterequired;
//mxd
private ModelRenderMode gzDrawModelsMode;
@ -249,10 +246,9 @@ namespace CodeImp.DoomBuilder.Config
public bool ScriptAutoShowAutocompletion { get { return scriptautoshowautocompletion; } internal set { scriptautoshowautocompletion = value; } } //mxd
//mxd. Text labels settings
public string TextLabelFontName { get { return textlabelfontname; } internal set { textlabelfontname = value; textlabelfontupdaterequired = true; } }
public int TextLabelFontSize { get { return textlabelfontsize; } internal set { textlabelfontsize = value; textlabelfontupdaterequired = true; } }
public bool TextLabelFontBold { get { return textlabelfontbold; } internal set { textlabelfontbold = value; textlabelfontupdaterequired = true; } }
public Font TextLabelFont { get { return GetTextLabelFont(); } }
public string TextLabelFontName { get { return textlabelfontname; } internal set { textlabelfontname = value; } }
public int TextLabelFontSize { get { return textlabelfontsize; } internal set { textlabelfontsize = value; } }
public bool TextLabelFontBold { get { return textlabelfontbold; } internal set { textlabelfontbold = value; } }
//mxd
public ModelRenderMode GZDrawModelsMode { get { return gzDrawModelsMode; } internal set { gzDrawModelsMode = value; } }
@ -400,7 +396,6 @@ namespace CodeImp.DoomBuilder.Config
textlabelfontname = cfg.ReadSetting("textlabelfontname", "Microsoft Sans Serif");
textlabelfontsize = cfg.ReadSetting("textlabelfontsize", 10);
textlabelfontbold = cfg.ReadSetting("textlabelfontbold", false);
textlabelfontupdaterequired = true;
//mxd
gzDrawModelsMode = (ModelRenderMode)cfg.ReadSetting("gzdrawmodels", (int)ModelRenderMode.ALL);
@ -707,17 +702,6 @@ namespace CodeImp.DoomBuilder.Config
internal bool DeleteSetting(string setting) { return cfg.DeleteSetting(setting); }
internal bool DeleteSetting(string setting, string pathseperator) { return cfg.DeleteSetting(setting, pathseperator); }
//mxd
private Font GetTextLabelFont()
{
if(textlabelfontupdaterequired)
{
textlabelfont = new Font(new FontFamily(textlabelfontname), textlabelfontsize, (textlabelfontbold ? FontStyle.Bold : FontStyle.Regular));
textlabelfontupdaterequired = false;
}
return textlabelfont;
}
#endregion
#region ================== Default Settings

View file

@ -146,6 +146,7 @@ namespace CodeImp.DoomBuilder.Controls
}
graphics.DrawImage(drawimage, bounds.X, bounds.Y);
drawimage.Dispose();
}
#endregion

View file

@ -134,19 +134,21 @@ namespace CodeImp.DoomBuilder.Controls
if(General.Settings.ShowTextureSizes && !string.IsNullOrEmpty(imagesize))
{
// Setup
Font sizefont = new Font(this.ListView.Font.FontFamily, this.ListView.Font.SizeInPoints - 1);
textsize = g.MeasureString(imagesize, sizefont, bounds.Width * 2);
textpos = new PointF(bounds.Left + textsize.Width / 2, bounds.Top + 1);
imagerect = new Rectangle(bounds.Left + 1, bounds.Top + 1, (int)textsize.Width, (int)textsize.Height);
using(Font sizefont = new Font(this.ListView.Font.FontFamily, this.ListView.Font.SizeInPoints - 1))
{
textsize = g.MeasureString(imagesize, sizefont, bounds.Width * 2);
textpos = new PointF(bounds.Left + textsize.Width / 2, bounds.Top + 1);
imagerect = new Rectangle(bounds.Left + 1, bounds.Top + 1, (int)textsize.Width, (int)textsize.Height);
// Draw
using(SolidBrush labelbg = new SolidBrush(Color.FromArgb(196, base.ListView.ForeColor)))
{
g.FillRectangle(labelbg, imagerect);
}
using(SolidBrush labelcolor = new SolidBrush(base.ListView.BackColor))
{
g.DrawString(imagesize, sizefont, labelcolor, textpos, format);
// Draw
using(SolidBrush labelbg = new SolidBrush(Color.FromArgb(196, base.ListView.ForeColor)))
{
g.FillRectangle(labelbg, imagerect);
}
using(SolidBrush labelcolor = new SolidBrush(base.ListView.BackColor))
{
g.DrawString(imagesize, sizefont, labelcolor, textpos, format);
}
}
}
}

View file

@ -40,7 +40,7 @@ namespace CodeImp.DoomBuilder.Controls
private int maximumvalue = System.Int32.MaxValue;
private bool controlpressed;
private int incrementstep; //mxd. Step for +++ and --- prefixes
private readonly ToolTip tooltip; //mxd
private ToolTip tooltip; //mxd
#endregion
@ -64,6 +64,17 @@ namespace CodeImp.DoomBuilder.Controls
this.tooltip = new ToolTip { AutomaticDelay = 100, AutoPopDelay = 8000, InitialDelay = 100, ReshowDelay = 100 };
}
//mxd
protected override void Dispose(bool disposing)
{
if(disposing)
{
tooltip.Dispose();
tooltip = null;
}
base.Dispose(disposing);
}
#endregion
#region ================== Methods

View file

@ -32,7 +32,7 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Variables
private readonly ToolTip tip; //mxd
private ToolTip tooltip; //mxd
#endregion
@ -52,11 +52,18 @@ namespace CodeImp.DoomBuilder.Controls
this.SetStyle(ControlStyles.FixedHeight, true);
//mxd. Create tooltip
tip = new ToolTip();
tip.UseAnimation = false;
tip.UseFading = false;
tip.InitialDelay = 0;
tip.AutoPopDelay = 9000;
tooltip = new ToolTip { UseAnimation = false, UseFading = false, InitialDelay = 0, AutoPopDelay = 9000 };
}
//mxd
protected override void Dispose(bool disposing)
{
if(disposing)
{
tooltip.Dispose();
tooltip = null;
}
base.Dispose(disposing);
}
#endregion
@ -122,14 +129,14 @@ namespace CodeImp.DoomBuilder.Controls
//mxd. This shows tooltip at given position
public void ShowToolTip(string title, string text, int x, int y)
{
tip.ToolTipTitle = title;
tip.Show(text, this, x, y);
tooltip.ToolTipTitle = title;
tooltip.Show(text, this, x, y);
}
//mxd. This hides it
public void HideToolTip()
{
tip.Hide(this);
tooltip.Hide(this);
}
#endregion

View file

@ -2917,14 +2917,14 @@ namespace CodeImp.DoomBuilder.Map
foreach(Sector s in changedsectors) s.UpdateBBox();
foreach(Linedef l in alllines)
{
// Remove line when both it's start and end are inside a changed sector and neither side references it
// Remove line when it's start, center and end are inside a changed sector and neither side references it
if(l.Start != null && l.End != null &&
(l.Front == null || !changedsectors.Contains(l.Front.Sector)) &&
(l.Back == null || !changedsectors.Contains(l.Back.Sector)))
{
foreach(Sector s in changedsectors)
{
if(s.Intersect(l.Start.Position) && s.Intersect(l.End.Position))
if(s.Intersect(l.Start.Position) && s.Intersect(l.End.Position) && s.Intersect(l.GetCenterPoint()))
{
Vertex[] tocheck = { l.Start, l.End };
while(lines.Remove(l));
@ -3077,7 +3077,7 @@ namespace CodeImp.DoomBuilder.Map
foreach(Sector s in changedsectors) s.UpdateBBox();
foreach(Linedef l in alllines)
{
// Remove line when both it's start and end are inside a changed sector and neither side references it
// Remove line when it's start, center and end are inside a changed sector and neither side references it
if(l.Start != null && l.End != null)
{
if(l.Front == null && l.Back == null)
@ -3089,7 +3089,7 @@ namespace CodeImp.DoomBuilder.Map
{
foreach(Sector s in changedsectors)
{
if(s.Intersect(l.Start.Position) && s.Intersect(l.End.Position))
if(s.Intersect(l.Start.Position) && s.Intersect(l.End.Position) && s.Intersect(l.GetCenterPoint()))
{
Vertex[] tocheck = { l.Start, l.End };
l.Dispose();

View file

@ -101,7 +101,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Properties
public Vector2D Location { get { return location; } set { location = value; updateneeded = true; } } //mxd
public string Text { get { return text; } set { if(text != value) { text = value; textsize = Size.Empty; textureupdateneeded = true; } } }
public Font Font { get { return font; } set { font = value; textsize = Size.Empty; textureupdateneeded = true; } } //mxd
public Font Font { get { return font; } set { font.Dispose(); font = value; textsize = Size.Empty; textureupdateneeded = true; } } //mxd
public bool TransformCoords { get { return transformcoords; } set { transformcoords = value; updateneeded = true; } }
public SizeF TextSize { get { if(textureupdateneeded) Update(General.Map.Renderer2D.TranslateX, General.Map.Renderer2D.TranslateY, General.Map.Renderer2D.Scale, -General.Map.Renderer2D.Scale); return textsize; } }
public TextAlignmentX AlignX { get { return alignx; } set { alignx = value; updateneeded = true; } }
@ -124,6 +124,7 @@ namespace CodeImp.DoomBuilder.Rendering
set
{
scale = value;
font.Dispose();
font = new Font(new FontFamily(General.Settings.TextLabelFontName), (float)Math.Round(scale * 0.75f), (General.Settings.TextLabelFontBold ? FontStyle.Bold : FontStyle.Regular));
textsize = Size.Empty;
textureupdateneeded = true;
@ -145,7 +146,7 @@ namespace CodeImp.DoomBuilder.Rendering
{
// Initialize
this.text = "";
this.font = General.Settings.TextLabelFont; //mxd
this.font = new Font(new FontFamily(General.Settings.TextLabelFontName), General.Settings.TextLabelFontSize, (General.Settings.TextLabelFontBold ? FontStyle.Bold : FontStyle.Regular)); //General.Settings.TextLabelFont; //mxd
this.location = new Vector2D(); //mxd
this.color = new PixelColor(255, 255, 255, 255);
this.backcolor = new PixelColor(128, 0, 0, 0);
@ -169,7 +170,7 @@ namespace CodeImp.DoomBuilder.Rendering
{
// Initialize
this.text = "";
this.font = General.Settings.TextLabelFont;
this.font = new Font(new FontFamily(General.Settings.TextLabelFontName), General.Settings.TextLabelFontSize, (General.Settings.TextLabelFontBold ? FontStyle.Bold : FontStyle.Regular)); // General.Settings.TextLabelFont;
this.location = new Vector2D();
this.color = new PixelColor(255, 255, 255, 255);
this.backcolor = new PixelColor(128, 0, 0, 0);
@ -195,6 +196,7 @@ namespace CodeImp.DoomBuilder.Rendering
{
// Clean up
UnloadResource();
font.Dispose();
// Unregister resource
General.Map.Graphics.UnregisterResource(this);

View file

@ -63,10 +63,10 @@ namespace CodeImp.DoomBuilder.Windows
string str = s.Trim();
//mxd. Negative flag?
bool setflag = true;
CheckState setflag = CheckState.Checked;
if(str.StartsWith("!"))
{
setflag = false;
setflag = CheckState.Unchecked;
str = str.Substring(1, str.Length - 1);
}
@ -75,7 +75,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(CheckBox c in flags.Checkboxes)
{
if(c.Text == flagdefs[str]) c.Checked = setflag;
if(c.Text == flagdefs[str]) c.CheckState = setflag;
}
}
}

View file

@ -420,7 +420,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptogridincrement, snaptonearest, snaptocardinaldirection);
// Stitch geometry
General.Map.Map.StitchGeometry(General.Settings.MergeGeometryMode);
if(snaptonearest) General.Map.Map.StitchGeometry(General.Settings.MergeGeometryMode);
// Snap to map format accuracy
General.Map.Map.SnapAllToAccuracy();

View file

@ -54,7 +54,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This is called when the browse button is pressed
public override string Browse(string initialvalue)
{
return FlagsForm.ShowDialog(Form.ActiveForm, initialvalue, General.Map.Config.LinedefFlags);
//mxd. Combine regular and activation flags
Dictionary<string, string> flags = new Dictionary<string, string>(General.Map.Config.LinedefFlags);
foreach(LinedefActivateInfo ai in General.Map.Config.LinedefActivates) flags.Add(ai.Key, ai.Title);
return FlagsForm.ShowDialog(Form.ActiveForm, initialvalue, flags);
}
// This is called to perform a search (and replace)
@ -120,7 +124,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(KeyValuePair<string, bool> group in findflagslist)
{
// ...and check if the flag doesn't match
if((group.Value && !l.IsFlagSet(group.Key)) || l.IsFlagSet(group.Key))
if(group.Value != l.IsFlagSet(group.Key))
{
match = false;
break;

View file

@ -98,7 +98,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(KeyValuePair<string, bool> group in findflagslist)
{
// ...and check if the flag doesn't match
if((group.Value && !s.IsFlagSet(group.Key)) || s.IsFlagSet(group.Key))
if(group.Value != s.IsFlagSet(group.Key))
{
match = false;
break;

View file

@ -97,7 +97,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(KeyValuePair<string, bool> group in findflagslist)
{
// ...and check if the flag doesn't match
if((group.Value && !sd.IsFlagSet(group.Key)) || sd.IsFlagSet(group.Key))
if(group.Value != sd.IsFlagSet(group.Key))
{
match = false;
break;

View file

@ -128,7 +128,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(KeyValuePair<string, bool> group in findflagslist)
{
// ...and check if the flag doesn't match
if((group.Value && !t.IsFlagSet(group.Key)) || t.IsFlagSet(group.Key))
if(group.Value != t.IsFlagSet(group.Key))
{
match = false;
break;

View file

@ -16,6 +16,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(disposing && (components != null))
{
components.Dispose();
mode = null; //mxd
}
base.Dispose(disposing);
}
@ -119,6 +120,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.tooltip.SetToolTip(this.preciseposition, "When checked, thing and vertex positions will be set using floating point precisi" +
"on.\r\nOtherwise, they will be rounded to the nearest integer.");
this.preciseposition.UseVisualStyleBackColor = true;
this.preciseposition.CheckedChanged += new System.EventHandler(this.preciseposition_CheckedChanged);
//
// orgposy
//

View file

@ -33,7 +33,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
// Editing mode
private readonly EditSelectionMode mode;
private EditSelectionMode mode;
// Input
private bool userinput;
@ -59,17 +59,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.mode = mode;
//mxd
preventchanges = true;
if(General.Map.UDMF)
{
preciseposition.Checked = mode.UsePrecisePosition;
preciseposition.Enabled = true;
preciseposition.CheckedChanged += preciseposition_CheckedChanged;
}
else
{
preciseposition.Checked = false;
preciseposition.Enabled = false;
}
preventchanges = false;
//mxd. Otherwise the focus will go to one of TextBoxes
// and stay there forever preventing tab collapsing when in collapsed mode
@ -377,6 +378,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd
private void preciseposition_CheckedChanged(object sender, EventArgs e)
{
if(preventchanges) return;
mode.UsePrecisePosition = preciseposition.Checked;
General.Interface.FocusDisplay();
}

View file

@ -17,7 +17,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
private static BuilderPlug me;
public static BuilderPlug Me { get { return me; } }
public override int MinimumRevision { get { return 1869; } }
public override int MinimumRevision { get { return 2600; } }
public override string Name { get { return "Color Picker"; } }
@ -40,25 +40,25 @@ namespace CodeImp.DoomBuilder.ColorPicker
public override void OnMapOpenEnd()
{
base.OnMapOpenEnd();
toolsform.Register();
if(!General.Map.DOOM) toolsform.Register();
}
public override void OnMapNewEnd()
{
base.OnMapNewEnd();
toolsform.Register();
if(!General.Map.DOOM) toolsform.Register();
}
public override void OnMapCloseEnd()
{
base.OnMapCloseEnd();
toolsform.Unregister();
if(!General.Map.DOOM) toolsform.Unregister();
}
public override void OnReloadResources()
{
base.OnReloadResources();
toolsform.Register();
if(!General.Map.DOOM) toolsform.Register();
}
public override void Dispose()
@ -80,7 +80,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
[BeginAction("togglelightpannel")]
private void ToggleLightPannel()
{
if(General.Editing.Mode == null) return;
if(General.Editing.Mode == null || General.Map.DOOM) return;
string currentModeName = General.Editing.Mode.GetType().Name;
//display one of colorPickers or tell the user why we can't do that

View file

@ -46,6 +46,7 @@ namespace CodeImp.DoomBuilder.SoundPropagationMode
#region ================== Constants
internal const int SOUND_ENVIROMNEMT_THING_TYPE = 9048; //mxd
internal const float LINE_LENGTH_SCALER = 0.001f; //mxd
#endregion