Changed, Visual mode: "Paste Selection" action (Ctrl-V) can now paste both copied textures and things, based on what was copied last.

Changed, Map Analysis mode: the view is now much more zoomed after clocking on a "Check very short linedefs" error check result.
Removed single testing engine launchable by the editor at once limitation (it worked properly only when using Test map actions anyway).
Fixed: re-did the fix for invalid geometry created when drawing very large grids from R2653, because it caused other issues.
This commit is contained in:
MaxED 2016-06-19 00:09:53 +00:00
parent af4f40389f
commit cb1eb1de83
8 changed files with 91 additions and 59 deletions

View file

@ -722,7 +722,7 @@ namespace CodeImp.DoomBuilder.Editing
if(s == null) if(s == null)
{ {
General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: cursor is not inside sector!"); General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: mouse cursor must be inside a sector!");
return false; return false;
} }

View file

@ -96,7 +96,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
if(File.Exists(testprogram)) if(File.Exists(testprogram))
{ {
Icon i = Icon.ExtractAssociatedIcon(testprogram); Icon i = Icon.ExtractAssociatedIcon(testprogram);
icon = (i != null ? i.ToBitmap() : new Bitmap(Properties.Resources.Question)); icon = new Bitmap(i != null ? i.ToBitmap() : Properties.Resources.Question);
} }
else else
{ {

View file

@ -17,6 +17,7 @@
#region ================== Namespaces #region ================== Namespaces
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@ -39,10 +40,10 @@ namespace CodeImp.DoomBuilder
#region ================== Variables #region ================== Variables
private string tempwad; private string tempwad;
private Process process; //mxd private Dictionary<Process, string> processes; //mxd
private bool isdisposed; private bool isdisposed;
delegate void EngineExitedCallback(); //mxd delegate void EngineExitedCallback(Process p); //mxd
#endregion #endregion
@ -59,6 +60,7 @@ namespace CodeImp.DoomBuilder
{ {
// Initialize // Initialize
CleanTempFile(manager); CleanTempFile(manager);
processes = new Dictionary<Process, string>(); //mxd
// Bind actions // Bind actions
General.Actions.BindMethods(this); General.Actions.BindMethods(this);
@ -73,16 +75,30 @@ namespace CodeImp.DoomBuilder
// Unbind actions // Unbind actions
General.Actions.UnbindMethods(this); General.Actions.UnbindMethods(this);
//mxd. Terminate process? //mxd. Terminate running processes?
if(process != null) if(processes != null)
{ {
process.CloseMainWindow(); foreach(KeyValuePair<Process, string> group in processes)
process.Close(); {
// Close engine
group.Key.CloseMainWindow();
group.Key.Close();
// Remove temporary file
if(File.Exists(group.Value))
{
try { File.Delete(group.Value); }
catch { }
}
}
} }
// Remove temporary file // Remove temporary file
if(File.Exists(tempwad))
{
try { File.Delete(tempwad); } try { File.Delete(tempwad); }
catch(Exception) { } catch { }
}
// Done // Done
isdisposed = true; isdisposed = true;
@ -232,18 +248,6 @@ namespace CodeImp.DoomBuilder
return outp; return outp;
} }
//mxd
private bool AlreadyTesting()
{
if(process != null)
{
General.ShowWarningMessage("Game engine is already running." + Environment.NewLine + "Please close \"" + process.MainModule.FileName + "\" first.", MessageBoxButtons.OK);
return true;
}
return false;
}
#endregion #endregion
#region ================== Test #region ================== Test
@ -252,23 +256,22 @@ namespace CodeImp.DoomBuilder
[BeginAction("testmap")] [BeginAction("testmap")]
public void Test() public void Test()
{ {
if(AlreadyTesting() || !General.Editing.Mode.OnMapTestBegin(false)) return; //mxd TestAtSkill(General.Map.ConfigSettings.TestSkill, false);
TestAtSkill(General.Map.ConfigSettings.TestSkill);
General.Editing.Mode.OnMapTestEnd(false); //mxd
} }
//mxd //mxd
[BeginAction("testmapfromview")] [BeginAction("testmapfromview")]
public void TestFromView() public void TestFromView()
{ {
if(AlreadyTesting() || !General.Editing.Mode.OnMapTestBegin(true)) return; TestAtSkill(General.Map.ConfigSettings.TestSkill, true);
TestAtSkill(General.Map.ConfigSettings.TestSkill);
General.Editing.Mode.OnMapTestEnd(true);
} }
// This saves the map to a temporary file and launches a test with the given skill // This saves the map to a temporary file and launches a test with the given skill
public void TestAtSkill(int skill) public void TestAtSkill(int skill) { TestAtSkill(skill, false); }
public void TestAtSkill(int skill, bool testfromcurrentposition)
{ {
if(!General.Editing.Mode.OnMapTestBegin(testfromcurrentposition)) return; //mxd
Cursor oldcursor = Cursor.Current; Cursor oldcursor = Cursor.Current;
// Check if configuration is OK // Check if configuration is OK
@ -301,8 +304,11 @@ namespace CodeImp.DoomBuilder
} }
// Remove temporary file // Remove temporary file
if(File.Exists(tempwad) && !processes.ContainsValue(tempwad))
{
try { File.Delete(tempwad); } try { File.Delete(tempwad); }
catch(Exception) { } catch { }
}
// Save map to temporary file // Save map to temporary file
Cursor.Current = Cursors.WaitCursor; Cursor.Current = Cursors.WaitCursor;
@ -334,9 +340,10 @@ namespace CodeImp.DoomBuilder
try try
{ {
// Start the program // Start the program
process = Process.Start(processinfo); Process process = Process.Start(processinfo);
process.EnableRaisingEvents = true; //mxd process.EnableRaisingEvents = true; //mxd
process.Exited += ProcessOnExited; //mxd process.Exited += ProcessOnExited; //mxd
processes.Add(process, tempwad); //mxd
Cursor.Current = oldcursor; //mxd Cursor.Current = oldcursor; //mxd
} }
catch(Exception e) catch(Exception e)
@ -351,16 +358,33 @@ namespace CodeImp.DoomBuilder
} }
} }
General.Plugins.OnMapSaveEnd(SavePurpose.Testing); General.Plugins.OnMapSaveEnd(SavePurpose.Testing);
General.Editing.Mode.OnMapTestEnd(testfromcurrentposition); //mxd
} }
//mxd //mxd
private void TestingFinished() private void TestingFinished(Process process)
{ {
// Done // Done
TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks); TimeSpan deltatime = TimeSpan.FromTicks(process.ExitTime.Ticks - process.StartTime.Ticks);
process = null; General.WriteLogLine("Testing with \"" + process.StartInfo.FileName + "\" has finished.");
General.WriteLogLine("Test program has finished.");
General.WriteLogLine("Run time: " + deltatime.TotalSeconds.ToString("###########0.00") + " seconds"); General.WriteLogLine("Run time: " + deltatime.TotalSeconds.ToString("###########0.00") + " seconds");
//mxd. Remove from active processes list
string closedtempfile = processes[process];
processes.Remove(process);
//mxd. Still have running engines?..
if(processes.Count > 0)
{
// Remove temp file
if(File.Exists(closedtempfile))
{
try { File.Delete(closedtempfile); }
catch { }
}
return;
}
General.MainWindow.DisplayReady(); General.MainWindow.DisplayReady();
// Clean up temp file // Clean up temp file
@ -374,20 +398,15 @@ namespace CodeImp.DoomBuilder
General.Map.Graphics.Reset(); General.Map.Graphics.Reset();
General.MainWindow.RedrawDisplay(); General.MainWindow.RedrawDisplay();
} }
/*else if(General.Editing.Mode is VisualMode)
{
General.MainWindow.StopExclusiveMouseInput();
General.MainWindow.StartExclusiveMouseInput();
}*/
} }
General.MainWindow.FocusDisplay(); General.MainWindow.FocusDisplay();
} }
//mxd //mxd
private void ProcessOnExited(object sender, EventArgs eventArgs) private void ProcessOnExited(object sender, EventArgs e)
{ {
General.MainWindow.Invoke(new EngineExitedCallback(TestingFinished)); General.MainWindow.Invoke(new EngineExitedCallback(TestingFinished), new[] { sender });
} }
// This deletes the previous temp file and creates a new, empty temp file // This deletes the previous temp file and creates a new, empty temp file
@ -395,7 +414,7 @@ namespace CodeImp.DoomBuilder
{ {
// Remove temporary file // Remove temporary file
try { File.Delete(tempwad); } try { File.Delete(tempwad); }
catch(Exception) { } catch { }
// Make new empty temp file // Make new empty temp file
tempwad = General.MakeTempFilename(manager.TempPath, "wad"); tempwad = General.MakeTempFilename(manager.TempPath, "wad");

View file

@ -937,7 +937,6 @@ namespace CodeImp.DoomBuilder.Geometry
if(points[0].stitch) mergeverts.Add(v1); else nonmergeverts.Add(v1); if(points[0].stitch) mergeverts.Add(v1); else nonmergeverts.Add(v1);
// Go for all other points // Go for all other points
int roundprecision = (General.Map.FormatInterface.VertexDecimals > 0 ? General.Map.FormatInterface.VertexDecimals - 1 : 0); //mxd
for(int i = 1; i < points.Count; i++) for(int i = 1; i < points.Count; i++)
{ {
// Create vertex for point // Create vertex for point
@ -963,7 +962,7 @@ namespace CodeImp.DoomBuilder.Geometry
// Check if any other lines intersect this line // Check if any other lines intersect this line
List<float> intersections = new List<float>(); List<float> intersections = new List<float>();
Line2D measureline = ld.Line; Line2D measureline = ld.Line;
Dictionary<Linedef, bool> processed = new Dictionary<Linedef, bool>(); //mxd HashSet<Linedef> processed = new HashSet<Linedef>(); //mxd
//mxd //mxd
foreach(Sector s in map.Sectors) foreach(Sector s in map.Sectors)
@ -973,7 +972,7 @@ namespace CodeImp.DoomBuilder.Geometry
{ {
foreach(Sidedef side in s.Sidedefs) foreach(Sidedef side in s.Sidedefs)
{ {
if(processed.ContainsKey(side.Line)) continue; if(processed.Contains(side.Line)) continue;
if(side.Line == ld) continue; if(side.Line == ld) continue;
float u; float u;
@ -983,7 +982,7 @@ namespace CodeImp.DoomBuilder.Geometry
intersections.Add(u); intersections.Add(u);
} }
processed.Add(side.Line, false); processed.Add(side.Line);
} }
} }
} }
@ -1000,10 +999,6 @@ namespace CodeImp.DoomBuilder.Geometry
// may already have changed in length due to a previous split // may already have changed in length due to a previous split
Vector2D splitpoint = measureline.GetCoordinatesAt(u); Vector2D splitpoint = measureline.GetCoordinatesAt(u);
//mxd. Work around some imprecisions when splitting very long lines (like 19000 mu long)
splitpoint.x = (float)Math.Round(splitpoint.x, roundprecision);
splitpoint.y = (float)Math.Round(splitpoint.y, roundprecision);
// Make the vertex // Make the vertex
Vertex splitvertex = map.CreateVertex(splitpoint); Vertex splitvertex = map.CreateVertex(splitpoint);
if(splitvertex == null) return false; if(splitvertex == null) return false;

View file

@ -46,7 +46,7 @@ namespace CodeImp.DoomBuilder.Map
/// <summary>Stiching distance. This is only to get around inaccuracies. Basically, /// <summary>Stiching distance. This is only to get around inaccuracies. Basically,
/// geometry only stitches when exactly on top of each other.</summary> /// geometry only stitches when exactly on top of each other.</summary>
public const float STITCH_DISTANCE = 0.001f; public const float STITCH_DISTANCE = 0.005f; //mxd. 0.001f is not enough when drawing very long lines...
// Virtual sector identification // Virtual sector identification
// This contains a character that is invalid in the UDMF standard, but valid // This contains a character that is invalid in the UDMF standard, but valid

View file

@ -91,7 +91,7 @@
"Hexen", "Hexen",
"Strife"}); "Strife"});
this.colorpreset.Name = "colorpreset"; this.colorpreset.Name = "colorpreset";
this.colorpreset.Size = new System.Drawing.Size(121, 25); this.colorpreset.Size = new System.Drawing.Size(75, 25);
this.colorpreset.SelectedIndexChanged += new System.EventHandler(this.colorpreset_SelectedIndexChanged); this.colorpreset.SelectedIndexChanged += new System.EventHandler(this.colorpreset_SelectedIndexChanged);
// //
// MenusForm // MenusForm

View file

@ -1,6 +1,7 @@
#region ================== Namespaces #region ================== Namespaces
using System; using System;
using System.Drawing;
using CodeImp.DoomBuilder.Map; using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
@ -50,7 +51,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This must return the string that is displayed in the listbox // This must return the string that is displayed in the listbox
public override string ToString() public override string ToString()
{ {
return "Linedef " + line.Index + " is shorter than 1 m.u."; return "Linedef " + line.Index + " is shorter than 1 mu.";
} }
// Rendering // Rendering
@ -61,6 +62,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
renderer.PlotVertex(line.End, ColorCollection.VERTICES); renderer.PlotVertex(line.End, ColorCollection.VERTICES);
} }
// We must zoom in way more than usual...
public override RectangleF GetZoomArea()
{
// Get Area
RectangleF area = base.GetZoomArea();
// Remove padding
area.Inflate(-97f, -97f);
// Return area
return area;
}
#endregion #endregion
} }
} }

View file

@ -2702,7 +2702,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void TextureCopy() public void TextureCopy()
{ {
PreActionNoChange(); PreActionNoChange();
GetTargetEventReceiver(true).OnCopyTexture(); //mxd IVisualEventReceiver i = GetTargetEventReceiver(true);
i.OnCopyTexture(); //mxd
if(!(i is VisualThing)) copybuffer.Clear(); //mxd. Not copying things any more...
PostAction(); PostAction();
} }
@ -3119,7 +3121,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
VisualThing vt = (VisualThing)i; VisualThing vt = (VisualThing)i;
if(vt != null) copybuffer.Add(new ThingCopyData(vt.Thing)); if(vt != null) copybuffer.Add(new ThingCopyData(vt.Thing));
} }
General.Interface.DisplayStatus(StatusType.Info, "Copied " + copybuffer.Count + " Things");
string rest = copybuffer.Count + (copybuffer.Count > 1 ? " things." : " thing.");
General.Interface.DisplayStatus(StatusType.Info, "Copied " + rest);
} }
//mxd //mxd
@ -3129,7 +3133,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
CopySelection(); CopySelection();
//Create undo //Create undo
string rest = copybuffer.Count + " thing" + (copybuffer.Count > 1 ? "s." : "."); string rest = copybuffer.Count + (copybuffer.Count > 1 ? " things." : " thing.");
CreateUndo("Cut " + rest); CreateUndo("Cut " + rest);
General.Interface.DisplayStatus(StatusType.Info, "Cut " + rest); General.Interface.DisplayStatus(StatusType.Info, "Cut " + rest);
@ -3155,7 +3159,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{ {
if(copybuffer.Count == 0) if(copybuffer.Count == 0)
{ {
General.Interface.DisplayStatus(StatusType.Warning, "Nothing to paste, cut or copy some Things first!"); TexturePaste(); // I guess we may paste a texture or two instead
return; return;
} }
@ -3167,7 +3171,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
return; return;
} }
string rest = copybuffer.Count + " thing" + (copybuffer.Count > 1 ? "s" : ""); string rest = copybuffer.Count + (copybuffer.Count > 1 ? " things." : " thing.");
General.Map.UndoRedo.CreateUndo("Paste " + rest); General.Map.UndoRedo.CreateUndo("Paste " + rest);
General.Interface.DisplayStatus(StatusType.Info, "Pasted " + rest); General.Interface.DisplayStatus(StatusType.Info, "Pasted " + rest);