Added some boilerplate to the rendering system. It's now impossible to start new rendering cycle if the previous one hasn't finished yet.

Changed: OS name, GPU name and GZDB revision info are now added to the exception text and GZCrash.log.
Fixed, cosmetic: toolstrip separators visibility must be updated when resizing the main window.
Internal: removed Plug.DisplaySize, Plug.DisplayLocationAbs and Renderer.ViewportSize. The same data can be accessed from anywhere using General.Interface.Display.Size and General.Interface.Display.LocationAbs. Also Plug.DisplayLocationAbs returned incorrect coordinates...
This commit is contained in:
MaxED 2015-09-17 12:02:39 +00:00
parent 118bda42a7
commit ff265d87f9
13 changed files with 84 additions and 43 deletions

View file

@ -528,6 +528,7 @@
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Management" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>

View file

@ -18,6 +18,7 @@
using System.Drawing;
using System.Windows.Forms;
using CodeImp.DoomBuilder.Rendering;
#endregion
@ -36,7 +37,10 @@ namespace CodeImp.DoomBuilder.Controls
#endregion
#region ================== Properties
public event KeyEventHandler OnKeyReleased; //mxd. Sometimes it's handeled here, not by MainForm
public Point LocationAbs { get { return this.PointToScreen(new Point(-(General.MainWindow.Width - General.MainWindow.ClientSize.Width) / 2, 0)); } } //mxd
#endregion
#region ================== Constructor / Disposer
@ -65,7 +69,7 @@ namespace CodeImp.DoomBuilder.Controls
{
// Pass on to base
// Do we really want this?
base.RaisePaintEvent(this, pe);
if(!D3DDevice.IsRendering) base.RaisePaintEvent(this, pe); //mxd. Dont raise event when in the middle of rendering
}
//mxd

View file

@ -2,6 +2,7 @@
using System;
using System.IO;
using System.Management;
using System.Windows.Forms;
using System.Threading;
@ -36,12 +37,14 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
logPath = Path.Combine(General.SettingsPath, @"GZCrash.txt");
errorDescription.Text = "Error in " + e.Exception.Source + ":";
string sysinfo = GetSystemInfo();
using(StreamWriter sw = File.CreateText(logPath))
{
sw.Write(GetExceptionDescription(e.Exception));
sw.Write(sysinfo + GetExceptionDescription(e.Exception));
}
errorMessage.Text = e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
errorMessage.Text = sysinfo + "********EXCEPTION DETAILS********" + Environment.NewLine
+ e.Exception.Message + Environment.NewLine + e.Exception.StackTrace;
}
public void Setup()
@ -114,12 +117,43 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
"It's CRASHENING!",
"W-W-W-WIPEOUT!",
"EVERYTHING IS LOST!",
"Your empty is full!",
"Let's see how far this infinite loop goes...",
"Your empty is full!",
"Let's see how far this infinite loop goes...",
};
this.Text = titles[new Random().Next(0, titles.Length - 1)];
}
private static string GetSystemInfo()
{
string result = "***********SYSTEM INFO***********" + Environment.NewLine;
// Get OS name
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem");
foreach(ManagementObject mo in searcher.Get())
{
result += "OS: " + mo["Caption"] + Environment.NewLine;
break;
}
// Get GPU name
searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
foreach(ManagementObject mo in searcher.Get())
{
PropertyData bpp = mo.Properties["CurrentBitsPerPixel"];
PropertyData description = mo.Properties["Description"];
if(bpp != null && description != null && bpp.Value != null)
{
result += "GPU: " + description.Value + Environment.NewLine;
break;
}
}
// Get GZDB version
result += "GZDB: R" + General.ThisAssembly.GetName().Version.Revision + Environment.NewLine + Environment.NewLine;
return result;
}
private static string GetExceptionDescription(Exception ex)
{
//add to error logger

View file

@ -41,23 +41,27 @@
//
// bQuit
//
this.bQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bQuit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.bQuit.Location = new System.Drawing.Point(537, 195);
this.bQuit.Image = global::CodeImp.DoomBuilder.Properties.Resources.SearchClear;
this.bQuit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.bQuit.Location = new System.Drawing.Point(537, 212);
this.bQuit.Name = "bQuit";
this.bQuit.Size = new System.Drawing.Size(75, 23);
this.bQuit.Size = new System.Drawing.Size(75, 28);
this.bQuit.TabIndex = 0;
this.bQuit.Text = "Quit";
this.bQuit.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.bQuit.UseVisualStyleBackColor = true;
//
// bContinue
//
this.bContinue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.bContinue.Location = new System.Drawing.Point(456, 195);
this.bContinue.Image = global::CodeImp.DoomBuilder.Properties.Resources.Test;
this.bContinue.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.bContinue.Location = new System.Drawing.Point(446, 212);
this.bContinue.Name = "bContinue";
this.bContinue.Size = new System.Drawing.Size(75, 23);
this.bContinue.Size = new System.Drawing.Size(85, 28);
this.bContinue.TabIndex = 1;
this.bContinue.Text = "Continue";
this.bContinue.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.bContinue.UseVisualStyleBackColor = true;
this.bContinue.Click += new System.EventHandler(this.bContinue_Click);
//
@ -67,7 +71,7 @@
this.errorMessage.Multiline = true;
this.errorMessage.Name = "errorMessage";
this.errorMessage.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.errorMessage.Size = new System.Drawing.Size(535, 119);
this.errorMessage.Size = new System.Drawing.Size(535, 151);
this.errorMessage.TabIndex = 3;
this.errorMessage.Text = "Stack trace";
//
@ -85,7 +89,7 @@
this.reportLink.AutoSize = true;
this.reportLink.LinkArea = new System.Windows.Forms.LinkArea(53, 4);
this.reportLink.LinkColor = System.Drawing.SystemColors.HotTrack;
this.reportLink.Location = new System.Drawing.Point(77, 157);
this.reportLink.Location = new System.Drawing.Point(77, 188);
this.reportLink.Name = "reportLink";
this.reportLink.Size = new System.Drawing.Size(286, 17);
this.reportLink.TabIndex = 5;
@ -99,7 +103,7 @@
this.threadLink.AutoSize = true;
this.threadLink.LinkArea = new System.Windows.Forms.LinkArea(101, 28);
this.threadLink.LinkColor = System.Drawing.SystemColors.HotTrack;
this.threadLink.Location = new System.Drawing.Point(77, 178);
this.threadLink.Location = new System.Drawing.Point(77, 210);
this.threadLink.Name = "threadLink";
this.threadLink.Size = new System.Drawing.Size(349, 30);
this.threadLink.TabIndex = 8;
@ -112,9 +116,11 @@
// bToClipboard
//
this.bToClipboard.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.bToClipboard.Location = new System.Drawing.Point(512, 151);
this.bToClipboard.Image = global::CodeImp.DoomBuilder.Properties.Resources.Copy;
this.bToClipboard.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.bToClipboard.Location = new System.Drawing.Point(446, 184);
this.bToClipboard.Name = "bToClipboard";
this.bToClipboard.Size = new System.Drawing.Size(100, 23);
this.bToClipboard.Size = new System.Drawing.Size(166, 24);
this.bToClipboard.TabIndex = 9;
this.bToClipboard.Text = "Copy to clipboard";
this.bToClipboard.UseVisualStyleBackColor = true;
@ -136,7 +142,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.bQuit;
this.ClientSize = new System.Drawing.Size(624, 224);
this.ClientSize = new System.Drawing.Size(624, 244);
this.Controls.Add(this.reportLink);
this.Controls.Add(this.errorDescription);
this.Controls.Add(this.bToClipboard);

View file

@ -33,18 +33,6 @@ namespace CodeImp.DoomBuilder.Plugins
// Disposing
private bool isdisposed;
//mxd. It's nice to have these avaliable to plugins...
public static Point DisplayLocationAbs {
get {
if (General.MainWindow == null || General.MainWindow.Display == null)
return new Point();
return new Point(General.MainWindow.Location.X + General.MainWindow.ClientRectangle.X + General.MainWindow.Display.Location.X, General.MainWindow.Location.Y + General.MainWindow.ClientRectangle.Y + General.MainWindow.Display.Location.Y);
}
}
//mxd. It's nice to have these avaliable to plugins...
public static Size DisplaySize { get { return (General.MainWindow == null || General.MainWindow.Display == null) ? new Size() : General.MainWindow.Display.Size; } }
#endregion
#region ================== Properties

View file

@ -45,6 +45,7 @@ namespace CodeImp.DoomBuilder.Rendering
private int adapter;
private Filter postfilter;
private Filter mipgeneratefilter;
private static bool isrendering; //mxd
// Main objects
private static Direct3D d3d;
@ -68,6 +69,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal Device Device { get { return device; } }
public bool IsDisposed { get { return isdisposed; } }
public static bool IsRendering { get { return isrendering; } } //mxd
internal RenderTargetControl RenderTarget { get { return rendertarget; } }
internal Viewport Viewport { get { return viewport; } }
internal ShaderManager Shaders { get { return shaders; } }
@ -110,6 +112,7 @@ namespace CodeImp.DoomBuilder.Rendering
if(device != null) device.Dispose();
if(font != null) font.Dispose();
if(fonttexture != null) fonttexture.Dispose();
isrendering = false; //mxd
// Done
isdisposed = true;
@ -445,7 +448,7 @@ namespace CodeImp.DoomBuilder.Rendering
public bool StartRendering(bool clear, Color4 backcolor, Surface target, Surface depthbuffer)
{
// Check if we can render
if(CheckAvailability())
if(CheckAvailability() && !isrendering) //mxd. Added isrendering check
{
// Set rendertarget
device.DepthStencilSurface = depthbuffer;
@ -462,11 +465,13 @@ namespace CodeImp.DoomBuilder.Rendering
// Ready to render
device.BeginScene();
isrendering = true; //mxd
return true;
}
else
{
// Minimized, you cannot see anything
isrendering = false; //mxd
return false;
}
}
@ -491,6 +496,7 @@ namespace CodeImp.DoomBuilder.Rendering
{
// Done
device.EndScene();
isrendering = false; //mxd
}
// Errors are not a problem here
catch(Exception) { }
@ -502,6 +508,7 @@ namespace CodeImp.DoomBuilder.Rendering
try
{
device.Present();
isrendering = false; //mxd
}
// Errors are not a problem here
catch(Exception) { }

View file

@ -37,7 +37,6 @@ namespace CodeImp.DoomBuilder.Rendering
float Scale { get; }
int VertexSize { get; }
ViewMode ViewMode { get; }
Size ViewportSize { get; } //mxd
// View methods
Vector2D DisplayToMap(Vector2D mousepos);

View file

@ -47,7 +47,6 @@ namespace CodeImp.DoomBuilder.Rendering
// Disposing
public bool IsDisposed { get { return isdisposed; } }
public static bool FullBrightness { get { return fullbrightness; } set { fullbrightness = value; } } //mxd
public Size ViewportSize { get { return graphics.RenderTarget.Size; } } //mxd
#endregion

View file

@ -1076,6 +1076,9 @@ namespace CodeImp.DoomBuilder.Windows
//if(!displayresized) General.LockWindowUpdate(display.Handle);
displayresized = true;
//mxd. Separators may need updating
UpdateSeparators();
// Request redraw
if(!redrawtimer.Enabled) redrawtimer.Enabled = true;
}

View file

@ -164,9 +164,9 @@ namespace CodeImp.DoomBuilder.BuilderEffects
//position and show form
if(formLocation.X == 0 && formLocation.Y == 0)
{
Size displaySize = DisplaySize;
Point displayLocation = DisplayLocationAbs;
formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 32);
Size displaySize = General.Interface.Display.Size;
Point displayLocation = General.Interface.Display.LocationAbs;
formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 16);
}
form.Location = formLocation;

View file

@ -25,8 +25,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.end = end;
// Check if start/end point is on screen...
Vector2D lt = General.Map.Renderer2D.DisplayToMap(new Vector2D(0.0f, General.Map.Renderer2D.ViewportSize.Height));
Vector2D rb = General.Map.Renderer2D.DisplayToMap(new Vector2D(General.Map.Renderer2D.ViewportSize.Width, 0.0f));
Vector2D lt = General.Map.Renderer2D.DisplayToMap(new Vector2D(0.0f, General.Interface.Display.Size.Height));
Vector2D rb = General.Map.Renderer2D.DisplayToMap(new Vector2D(General.Interface.Display.Size.Width, 0.0f));
RectangleF viewport = new RectangleF(lt.x, lt.y, rb.x - lt.x, rb.y - lt.y);
bool startvisible = viewport.Contains(start.x, start.y);
bool endvisible = viewport.Contains(end.x, end.y);

View file

@ -153,8 +153,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
UpdateText();
// Check if start/end point is on screen...
Vector2D lt = General.Map.Renderer2D.DisplayToMap(new Vector2D(0.0f, General.Map.Renderer2D.ViewportSize.Height));
Vector2D rb = General.Map.Renderer2D.DisplayToMap(new Vector2D(General.Map.Renderer2D.ViewportSize.Width, 0.0f));
Vector2D lt = General.Map.Renderer2D.DisplayToMap(new Vector2D(0.0f, General.Interface.Display.Size.Height));
Vector2D rb = General.Map.Renderer2D.DisplayToMap(new Vector2D(General.Interface.Display.Size.Width, 0.0f));
RectangleF viewport = new RectangleF(lt.x, lt.y, rb.x - lt.x, rb.y - lt.y);
bool startvisible = viewport.Contains(start.x, start.y);
bool endvisible = viewport.Contains(end.x, end.y);

View file

@ -142,9 +142,9 @@ namespace CodeImp.DoomBuilder.ColorPicker
{
if (formLocation.X == 0 && formLocation.Y == 0)
{
Size displaySize = DisplaySize;
Point displayLocation = DisplayLocationAbs;
formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 32);
Size displaySize = General.Interface.Display.Size;
Point displayLocation = General.Interface.Display.LocationAbs;
formLocation = new Point(displayLocation.X + displaySize.Width - form.Width - 16, displayLocation.Y + 16);
}
form.Location = formLocation;
form.FormClosed += form_FormClosed;