Fixed, Visual mode: some video memory was not released after closing a map if the Visual mode was enabled at least once during the editing session, eventually resulting in E_OUTOFMEMORY crash.

Fixed, General interface, cosmetic: in some cases the warnings label was disabled in a flashing state (e.g. with red background).
Internal: moved some older GZDB actions form GZGeneral to MapManager. They can no longer be toggled when no map is loaded (which is probably for the best).
Updated ZDoom_ACS.cfg.
Updated ZDoom_DECORATE.cfg.
This commit is contained in:
MaxED 2016-02-01 22:04:00 +00:00
parent 68ad4fdd65
commit 139c297161
74 changed files with 413 additions and 339 deletions

View file

@ -57,7 +57,7 @@ keywords
ActivatorTID = "int ActivatorTID(void)";
AmbientSound = "void AmbientSound(str sound, int volume)";
//AnnouncerSound = "void AnnouncerSound(str sound, int flags)";
Autosave = "Autosave()";
Autosave = "Autosave(void)";
//BlueCount = "BlueCount()";
//BlueReturn = "Script expression BlueReturn";
//BlueScore = "BlueScore()";
@ -174,8 +174,8 @@ keywords
FloorAndCeiling_LowerByValue = "FloorAndCeiling_LowerByValue(tag, speed, height)";
FloorAndCeiling_LowerRaise = "FloorAndCeiling_LowerRaise(tag, fspeed, cspeed, boomemu)";
FloorAndCeiling_RaiseByValue = "FloorAndCeiling_RaiseByValue(tag, speed, height)";
for = "for(initialization, condition, iteration)";
ForceField = "ForceField";
for = "for(initialization; condition; iteration)";
ForceField = "ForceField(void)";
FS_Execute = "FS_Execute(script, side, keynum, message)";
function = "function void expression(void)";
GameSkill = "int GameSkill(void)";
@ -413,7 +413,7 @@ keywords
Spawn = "int Spawn(str classname, fixed x, fixed y, fixed z[, int tid[, int angle]])\nSpawns an actor at the given X, Y and Z coordinates.\nOptionally a TID and a byte angle can be specified.";
SpawnForced = "int SpawnForced(str classname, fixed x, fixed y, fixed z[, int tid[, int angle]])\nForces the actor to spawn, even in conditions where the spawning would normally fail.\nThe return value is the number of things spawned.";
SpawnDecal = "int SpawnDecal(int tid, str decalname, int flags[, fixed angle = 0.0[, fixed zoffset = 0.0[, fixed distance = 64.0]]])\nCreates a decal on a wall by tracing a line from the actor with the\nspecified tid until hitting said wall, on which the decal is then created.\nIf tid is 0, the tracing is done from the activator of the script.\ndecalname: The name of the decal to create, as defined in DECALDEF.\nflags: use SDF_ flags\nThe return value of the function is the number of decals spawned.";
SpawnParticle = "void SpawnParticle(float offx, float offy, float offz, float velx, float vely, float velz, color color1, int lifetime[, bool fullbright = false[, float startalpha = 1.0[, int size = 1[, float fadestep = -1[, float accelx = 0[, float accely = 0[, float accelz = 0]]]]]]])";
SpawnParticle = "void SpawnParticle(int color[, bool fullbright = false[, int lifetime = 35[, int size = 1[, fixed x = 0.0[, fixed y = 0.0[, fixed z = 0.0[, fixed velx = 0.0[, fixed vely = 0.0[, fixed velz = 0.0[, fixed accelx = 0.0[, fixed accely = 0.0[, fixed accelz = 0.0[, int startalpha = 255[, int fadestep = -1]]]]]]]]]]]]]])";
SpawnProjectile = "void SpawnProjectile(int tid, str type, int angle, int speed, int vspeed, int gravity, int newtid)";
SpawnSpot = "int SpawnSpot(str classname, int spottid[, int tid[, int angle]])\nRequires a MapSpot at the location where you want the Actor to spawn.\nThe return value is the number of things spawned.";
SpawnSpotFacing = "int SpawnSpotFacing(str classname, int spottid[, int tid])\nRequires a MapSpot at the location where you want the Actor to spawn.\nThe thing will assume the angle of the mapspot it is spawned to.\nThe return value is the number of things spawned.";
@ -444,7 +444,7 @@ keywords
TakeActorInventory = "void TakeActorInventory(int tid, str inventory_item, int amount)\nThis function will take the amount of items from the specified actor.\nTakeActorInventory can remove items that are flagged as undroppable.";
TakeInventory = "void TakeInventory(str inventory_item, int amount)\nThis function will take the number of items specified from the activator.\nTakeInventory can remove items that are flagged as undroppable.";
Teleport = "Teleport(tid, tag, nosourcefog)";
Teleport_EndGame = "Teleport_EndGame()";
Teleport_EndGame = "Teleport_EndGame(void)";
Teleport_NewMap = "Teleport_NewMap(map, pos, face)";
Teleport_NoFog = "Teleport_NoFog(tid, useangle, tag)";
Teleport_NoStop = "Teleport_NoStop(tid, tag, nofog)";

View file

@ -124,7 +124,7 @@ keywords
A_SpawnDebris = "A_SpawnDebris(str type[, bool translation = false[, float horizontal_vel = 1.0[, float vertical_vel = 1.0]]])";
A_SpawnItem = "A_SpawnItem(str type, int distance, float zpos, bool useammo, bool translation)";
A_SpawnItemEx = "A_SpawnItemEx(str type[, float xoffset = 0.0[, float yoffset = 0.0[, float zoffset = 0.0[, float xvelocity = 0.0[, float yvelocity = 0.0[, float zvelocity = 0.0[, float angle = 0.0[, int flags = 0[, int skipchance = 0[, int tid = 0]]]]]]]]]])";
A_SpawnParticle = "A_SpawnParticle(float offx, float offy, float offz, float velx, float vely, float velz, color color1, int lifetime[, bool fullbright = false[, float startalpha = 1.0[, int size = 1[, float fadestep = -1[, float accelx = 0[, float accely = 0[, float accelz = 0]]]]]]])";
A_SpawnParticle = "A_SpawnParticle(color color[, int flags = 0[, int lifetime = 35[, int size = 1[, float angle = 0.0[, float xoff = 0.0[, float yoff = 0.0[, float zoff = 0.0[, float velx = 0.0[, float vely = 0.0[, float velz = 0.0[, float accelx = 0.0[, float accely = 0.0[, float accelz = 0.0[, float startalpha = 1.0[, float fadestep = -1.0]]]]]]]]]]]]]]])";
//State jumps
A_CheckBlock = "A_CheckBlock(str block[, int flags = 0[, int pointer = AAPTR_TARGET]])";
A_CheckCeiling = "A_CheckCeiling(int offset OR str state)";

View file

@ -121,7 +121,7 @@ namespace CodeImp.DoomBuilder.Actions
foreach(string rn in resnames)
{
// Found one?
if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(ACTIONS_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream actionsdata = asm.GetManifestResourceStream(rn);

View file

@ -23,7 +23,7 @@ namespace CodeImp.DoomBuilder.Actions
/// <summary>
/// This binds a method to an action which is then called when the action is started.
/// </summary>
public class BeginActionAttribute : ActionAttribute
public sealed class BeginActionAttribute : ActionAttribute
{
/// <summary>
/// This binds a method to an action which is then called when the action is started.

View file

@ -23,7 +23,7 @@ namespace CodeImp.DoomBuilder.Actions
/// <summary>
/// This binds a method to an action which is then called when the action is stopped.
/// </summary>
public class EndActionAttribute : ActionAttribute
public sealed class EndActionAttribute : ActionAttribute
{
/// <summary>
/// This binds a method to an action which is then called when the action is stopped.

View file

@ -56,7 +56,7 @@ namespace CodeImp.DoomBuilder.Actions
foreach(string rn in resnames)
{
// Found one?
if(rn.EndsWith(HINTS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(HINTS_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
string classname = string.Empty;
string groupname = string.Empty;

View file

@ -67,12 +67,12 @@ namespace CodeImp.DoomBuilder.Actions
// Aquire device
try { mouse.Acquire(); }
#if DEBUG
catch (Exception e)
catch(Exception e)
{
Console.WriteLine("MouseInput initialization failed: " + e.Message);
}
#else
catch (Exception) { }
catch(Exception) { }
#endif
// We have no destructor
@ -130,12 +130,12 @@ namespace CodeImp.DoomBuilder.Actions
// Reaquire device
try { mouse.Acquire(); }
#if DEBUG
catch (Exception e)
catch(Exception e)
{
Console.WriteLine("MouseInput process failed: " + e.Message);
}
#else
catch (Exception) { }
catch(Exception) { }
#endif
return new Vector2D();
}
@ -149,7 +149,7 @@ namespace CodeImp.DoomBuilder.Actions
{
mouse.Acquire();
}
catch (Exception e)
catch(Exception e)
{
Console.WriteLine("MouseInput process failed: " + e.Message);
}
@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder.Actions
{
// Reaquire device
try { mouse.Acquire(); }
catch (Exception) { }
catch(Exception) { }
return new Vector2D();
}
#endif

View file

@ -230,6 +230,7 @@ namespace CodeImp.DoomBuilder.Config
~ConfigurationInfo()
{
foreach(ThingsFilter tf in thingsfilters) tf.Dispose();
foreach(EngineInfo ei in testEngines) ei.Dispose();
}
#endregion

View file

@ -156,7 +156,7 @@ namespace CodeImp.DoomBuilder.Controls
{
if(this.DesignMode)
{
using (Pen p = new Pen(SystemColors.ControlDark, 1) { DashStyle = DashStyle.Dash })
using(Pen p = new Pen(SystemColors.ControlDark, 1) { DashStyle = DashStyle.Dash })
{
e.Graphics.DrawRectangle(p, 0, 0, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1);
}

View file

@ -185,7 +185,7 @@ namespace CodeImp.DoomBuilder.Controls
bounds = new Rectangle(r.X, r.Y + ((r.Height - scaled[115]) / 2), scaled[8], scaled[115]);
// draw the background color for our control image
using (SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
using(SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
{
e.Graphics.FillRectangle(bg, new Rectangle(bounds.X + scaled[1], bounds.Y, scaled[6], scaled[115]));
}
@ -225,7 +225,7 @@ namespace CodeImp.DoomBuilder.Controls
bounds = new Rectangle(r.X + ((r.Width - scaled[115]) / 2), r.Y, scaled[115], scaled[8]);
// draw the background color for our control image
using (SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
using(SolidBrush bg = new SolidBrush(hot ? hotcolor : this.BackColor))
{
e.Graphics.FillRectangle(bg, new Rectangle(bounds.X, bounds.Y + scaled[1], scaled[115], scaled[6]));
}

View file

@ -383,7 +383,7 @@ namespace CodeImp.DoomBuilder.Controls
fieldslist.CurrentCell.ReadOnly = false;
if((e.RowIndex == fieldslist.NewRowIndex) ||
frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, true, CultureInfo.InvariantCulture))
frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, StringComparison.OrdinalIgnoreCase))
fieldslist.BeginEdit(false);
else
fieldslist.BeginEdit(true);
@ -469,10 +469,11 @@ namespace CodeImp.DoomBuilder.Controls
foreach(EnumItem i in enumscombo.Items)
{
// Matches?
if(string.Compare(i.Title, frow.TypeHandler.GetStringValue(), true, CultureInfo.InvariantCulture) == 0)
if(string.Compare(i.Title, frow.TypeHandler.GetStringValue(), StringComparison.OrdinalIgnoreCase) == 0)
{
// Select this item
enumscombo.SelectedItem = i;
break; //mxd
}
}

View file

@ -340,6 +340,8 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
parser.Dispose();
}
//mxd
@ -358,6 +360,8 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
parser.Dispose();
}
//mxd
@ -378,6 +382,8 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
parser.Dispose();
}
//mxd
@ -395,6 +401,7 @@ namespace CodeImp.DoomBuilder.Controls
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
parser.Dispose();
return ScriptType.UNKNOWN;
}

View file

@ -295,7 +295,7 @@ namespace CodeImp.DoomBuilder.Controls
foreach(string rn in resnames)
{
// Found one?
if(rn.EndsWith(LEXERS_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(LEXERS_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream lexersdata = General.ThisAssembly.GetManifestResourceStream(rn);

View file

@ -578,7 +578,7 @@ namespace CodeImp.DoomBuilder.Controls
foreach(string ext in cfg.Extensions)
{
// Use this configuration if the extension matches
if(filename.EndsWith("." + ext, true, CultureInfo.InvariantCulture))
if(filename.EndsWith("." + ext, StringComparison.OrdinalIgnoreCase))
{
foundconfig = cfg;
break;

View file

@ -256,6 +256,7 @@ namespace CodeImp.DoomBuilder.Controls
// Dispose compiler
compiler.Dispose();
parser.Dispose();
// Update script navigator
UpdateNavigator();

View file

@ -545,7 +545,7 @@ namespace CodeImp.DoomBuilder.Data
textures = null;
flats = null;
sprites = null;
modeldefentries = null;//mxd
modeldefentries = null; //mxd
texturenames = null;
flatnames = null;
imageque = null;
@ -1769,7 +1769,7 @@ namespace CodeImp.DoomBuilder.Data
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if(parser.HasError)
{
decorate.LogError();
parser.LogError();
return;
}
}
@ -1925,6 +1925,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
parser.Dispose();
foreach(KeyValuePair<string, ModelData> e in modeldefentriesbyname)
{
@ -2012,6 +2013,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
parser.Dispose();
//get voxel models
foreach(KeyValuePair<string, bool> group in voxelNames)
@ -2074,6 +2076,8 @@ namespace CodeImp.DoomBuilder.Data
// And skyboxes
skyboxes = parser.Skyboxes;
parser.Dispose();
}
//mxd. This updates mapinfo class only
@ -2124,6 +2128,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
parser.Dispose();
}
private void ParseFromLocation(ZDTextParser parser, string location, bool clearerrors)
@ -2157,6 +2162,7 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
reverbs = parser.GetReverbs();
parser.Dispose();
}
//mxd. This loads SNDSEQ
@ -2185,6 +2191,7 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
soundsequences = parser.GetSoundSequences();
parser.Dispose();
}
//mxd. This loads cameratextures from ANIMDEFS
@ -2252,6 +2259,7 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
parser.Dispose();
}
//mxd

View file

@ -33,7 +33,7 @@ using SlimDX.Direct3D9;
namespace CodeImp.DoomBuilder.Data
{
public abstract unsafe class ImageData
public abstract unsafe class ImageData : IDisposable
{
#region ================== Constants

View file

@ -130,7 +130,7 @@ namespace CodeImp.DoomBuilder.Data
{
bitmap = reader.ReadAsBitmap(filedata);
}
catch (InvalidDataException)
catch(InvalidDataException)
{
// Data cannot be read!
bitmap = null;

View file

@ -410,6 +410,8 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
parser.Dispose();
}
// This loads a set of textures
@ -640,6 +642,8 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
parser.Dispose();
}
// This finds and returns a patch stream
@ -702,6 +706,8 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
parser.Dispose();
}
// This finds and returns a sprite stream

View file

@ -78,9 +78,10 @@ namespace CodeImp.DoomBuilder.Editing
object[] attrs = this.GetType().GetCustomAttributes(true);
foreach(object a in attrs)
{
if(a is EditModeAttribute)
EditModeAttribute attribute = a as EditModeAttribute;
if(attribute != null)
{
attributes = (EditModeAttribute)a;
attributes = attribute;
break;
}
}

View file

@ -27,7 +27,7 @@ namespace CodeImp.DoomBuilder.Editing
/// Allows automatic binding with an action and a button on the toolbar/menu.
/// </summary>
[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public class EditModeAttribute : Attribute
public sealed class EditModeAttribute : Attribute
{
#region ================== Variables

View file

@ -32,7 +32,7 @@ using CodeImp.DoomBuilder.Actions;
namespace CodeImp.DoomBuilder.Editing
{
public class UndoManager
public class UndoManager : IDisposable
{
#region ================== Constants
@ -181,7 +181,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Disposer
internal void Dispose()
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
@ -198,6 +198,18 @@ namespace CodeImp.DoomBuilder.Editing
ClearUndos();
ClearRedos();
General.WriteLogLine("All undo and redo levels cleared.");
//mxd
if(ss != null)
{
ss.Dispose();
ss = null;
}
if(stream != null)
{
stream.Dispose();
stream = null;
}
// Done
isdisposed = true;
@ -367,12 +379,12 @@ namespace CodeImp.DoomBuilder.Editing
}
// This outputs record info, if desired
private void LogRecordInfo(string info)
/*private void LogRecordInfo(string info)
{
#if DEBUG
//General.WriteLogLine(info);
#endif
}
}*/
// This plays back a stream in reverse
private void PlaybackStream(MemoryStream pstream)
@ -432,6 +444,10 @@ namespace CodeImp.DoomBuilder.Editing
numcmds--;
}
}
//mxd
ds.End();
ds.Dispose();
General.Map.Map.AutoRemove = true;
}

View file

@ -16,6 +16,7 @@
#region ================== Namespaces
using System;
using System.IO;
using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
@ -23,14 +24,14 @@ using CodeImp.DoomBuilder.GZBuilder.Data; //mxd
namespace CodeImp.DoomBuilder.Editing
{
public class UndoSnapshot
public class UndoSnapshot : IDisposable
{
#region ================== Variables
private MemoryStream recstream;
private string filename;
private string description;
private int ticketid; // For safe withdrawing
private readonly int ticketid; // For safe withdrawing
private volatile bool storeondisk;
private volatile bool isondisk;
private bool isdisposed;
@ -70,7 +71,7 @@ namespace CodeImp.DoomBuilder.Editing
}
// Disposer
internal void Dispose()
public void Dispose()
{
lock(this)
{

View file

@ -868,7 +868,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
{
if(tn.BackColor != SelectionBackColor)
{
using (Pen p = new Pen(BackColor, 1))
using(Pen p = new Pen(BackColor, 1))
{
g.DrawRectangle(p, tnMostRecentSelectedNode.Bounds.X, tnMostRecentSelectedNode.Bounds.Y, tnMostRecentSelectedNode.Bounds.Width, tnMostRecentSelectedNode.Bounds.Height);
}
@ -945,7 +945,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
base.OnMouseUp(e);
#if DEBUG
}
catch (Exception ex)
catch(Exception ex)
{
// GKM - Untrapped exceptions were killing me for debugging purposes.
// It probably shouldn't be here permanently, but it was causing real trouble for me.

View file

@ -95,12 +95,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
public void ApplyTo(UniFields fields, int min, int max, float oldValue1, float oldValue2)
{
if(value1.Text != string.Empty)
if(!string.IsNullOrEmpty(value1.Text))
UniFields.SetFloat(fields, field1, General.Clamp(value1.GetResultFloat(oldValue1), min, max), defaultValue);
else
UniFields.SetFloat(fields, field1, oldValue1, defaultValue);
if(value2.Text != string.Empty)
if(!string.IsNullOrEmpty(value2.Text))
UniFields.SetFloat(fields, field2, General.Clamp(value2.GetResultFloat(oldValue2), min, max), defaultValue);
else
UniFields.SetFloat(fields, field2, oldValue2, defaultValue);

View file

@ -4,8 +4,11 @@ using System.IO;
namespace CodeImp.DoomBuilder.GZBuilder.Data
{
public class EngineInfo
public class EngineInfo : IDisposable
{
// Disposing
private bool isdisposed;
public const string DEFAULT_ENGINE_NAME = "Engine with no name";
private string testprogramname;
@ -60,5 +63,18 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
icon = new Bitmap(16, 16);
}
}
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
icon.Dispose();
// Done
isdisposed = true;
}
}
}
}

View file

@ -1,9 +1,5 @@
#region ================== Namespaces
using CodeImp.DoomBuilder.Actions;
using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.Editing;
using CodeImp.DoomBuilder.Windows;
using CodeImp.DoomBuilder.GZBuilder.Data;
#endregion
@ -29,161 +25,5 @@ namespace CodeImp.DoomBuilder.GZBuilder
#endregion
#region ================== Methods
public static void Init()
{
//bind actions
General.Actions.BindMethods(typeof(GZGeneral));
}
#endregion
#region ================== Actions
[BeginAction("gztogglemodels")]
private static void ToggleModelsRenderingMode()
{
switch(General.Settings.GZDrawModelsMode)
{
case ModelRenderMode.NONE:
General.Settings.GZDrawModelsMode = ModelRenderMode.SELECTION;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: SELECTION ONLY");
break;
case ModelRenderMode.SELECTION:
General.Settings.GZDrawModelsMode = ModelRenderMode.ACTIVE_THINGS_FILTER;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ACTIVE THINGS FILTER ONLY");
break;
case ModelRenderMode.ACTIVE_THINGS_FILTER:
General.Settings.GZDrawModelsMode = ModelRenderMode.ALL;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ALL");
break;
case ModelRenderMode.ALL:
General.Settings.GZDrawModelsMode = ModelRenderMode.NONE;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: NONE");
break;
}
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglelights")]
private static void ToggleLightsRenderingMode()
{
if(General.Editing.Mode is ClassicMode)
{
switch(General.Settings.GZDrawLightsMode)
{
case LightRenderMode.NONE:
General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
break;
default:
General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
break;
}
}
else
{
switch(General.Settings.GZDrawLightsMode)
{
case LightRenderMode.NONE:
General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
break;
case LightRenderMode.ALL:
General.Settings.GZDrawLightsMode = LightRenderMode.ALL_ANIMATED;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ANIMATED");
break;
case LightRenderMode.ALL_ANIMATED:
General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
break;
}
}
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglefog")]
private static void ToggleFog()
{
General.Settings.GZDrawFog = !General.Settings.GZDrawFog;
General.MainWindow.DisplayStatus(StatusType.Action, "Fog rendering is " + (General.Settings.GZDrawFog ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglesky")]
private static void ToggleSky()
{
General.Settings.GZDrawSky = !General.Settings.GZDrawSky;
General.MainWindow.DisplayStatus(StatusType.Action, "Sky rendering is " + (General.Settings.GZDrawSky ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglefx")]
private static void ToggleFx()
{
int on = 0;
on += General.Settings.GZDrawFog ? 1 : -1;
on += General.Settings.GZDrawSky ? 1 : -1;
on += General.Settings.GZDrawLightsMode != LightRenderMode.NONE ? 1 : -1;
on += General.Settings.GZDrawModelsMode != ModelRenderMode.NONE ? 1 : -1;
bool enable = (on < 0);
General.Settings.GZDrawFog = enable;
General.Settings.GZDrawSky = enable;
General.Settings.GZDrawLightsMode = (enable ? LightRenderMode.ALL : LightRenderMode.NONE);
General.Settings.GZDrawModelsMode = (enable ? ModelRenderMode.ALL : ModelRenderMode.NONE);
General.MainWindow.DisplayStatus(StatusType.Action, "Advanced effects are " + (enable ? "ENABLED" : "DISABLED") );
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztoggleeventlines")]
private static void ToggleEventLines()
{
General.Settings.GZShowEventLines = !General.Settings.GZShowEventLines;
General.MainWindow.DisplayStatus(StatusType.Action, "Event lines are " + (General.Settings.GZShowEventLines ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglevisualvertices")]
private static void ToggleVisualVertices()
{
General.Settings.GZShowVisualVertices = !General.Settings.GZShowVisualVertices;
General.MainWindow.DisplayStatus(StatusType.Action, "Visual vertices are " + (General.Settings.GZShowVisualVertices ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
//main menu actions
[BeginAction("gzreloadmodeldef")]
private static void ReloadModeldef()
{
if(General.Map != null) General.Map.Data.ReloadModeldef();
}
[BeginAction("gzreloadgldefs")]
private static void ReloadGldefs()
{
if(General.Map != null) General.Map.Data.ReloadGldefs();
}
#endregion
}
}

View file

@ -43,7 +43,9 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
if(!isdisposed)
{
if(upper != null) upper.Dispose();
upper = null;
if(lower != null) lower.Dispose();
lower = null;
// Unregister resource
General.Map.Graphics.UnregisterResource(this);
@ -109,8 +111,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Rendering
{
// Trash geometry buffers
if(upper != null) upper.Dispose();
if(lower != null) lower.Dispose();
upper = null;
if(lower != null) lower.Dispose();
lower = null;
}

View file

@ -22,9 +22,10 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
logPath = Path.Combine(General.SettingsPath, @"GZCrash.txt");
Exception ex = (Exception)e.ExceptionObject;
errorDescription.Text = "Error in " + ex.Source + ":";
string sysinfo = GetSystemInfo();
using(StreamWriter sw = File.CreateText(logPath))
{
sw.Write(GetExceptionDescription(ex));
sw.Write(sysinfo + GetExceptionDescription(ex));
}
errorMessage.Text = ex.Message + Environment.NewLine + ex.StackTrace;

View file

@ -767,7 +767,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3
//create texture
MemoryStream memstream = new MemoryStream((4096 * 4) + 4096);
using (Bitmap bmp = CreateVoxelTexture(palette)) bmp.Save(memstream, ImageFormat.Bmp);
using(Bitmap bmp = CreateVoxelTexture(palette)) bmp.Save(memstream, ImageFormat.Bmp);
memstream.Seek(0, SeekOrigin.Begin);
Texture texture = Texture.FromStream(device, memstream, (int)memstream.Length, 64, 64, 0, Usage.None, Format.Unknown, Pool.Managed, Filter.Point, Filter.Box, 0);

View file

@ -18,7 +18,7 @@ using SlimDX;
namespace CodeImp.DoomBuilder
{
public class Clock
public static class Clock
{
// This queries the system for the current time
public static float CurrentTime { get { return Configuration.Timer.ElapsedMilliseconds; } }

View file

@ -128,30 +128,16 @@ namespace CodeImp.DoomBuilder
private const string SCREENSHOTS_DIR = "Screenshots"; //mxd
private const string SNIPPETS_DIR = "Snippets"; //mxd
private const string MAP_RESTORE_DIR = "Restore"; //mxd
private const string SETUP_DIR = "Setup";
private const string SPRITES_DIR = "Sprites";
private const string TEXTURES_DIR = "Textures"; //mxd
private const string HELP_FILE = "Refmanual.chm";
// SCROLLINFO structure
/*internal struct ScrollInfo
{
public int size; // size of this structure
public uint mask; // combination of SIF_ constants
public int min; // minimum scrolling position
public int max; // maximum scrolling position
public uint page; // page size (scroll bar uses this value to determine the appropriate size of the proportional scroll box)
public int pos; // position of the scroll box
public int trackpos; // immediate position of a scroll box that the user is dragging
}*/
#endregion
#region ================== Variables
// Files and Folders
private static string apppath;
private static string setuppath;
private static string settingspath;
private static string restorepath; //mxd
private static string logfile;
@ -176,7 +162,6 @@ namespace CodeImp.DoomBuilder
private static PluginManager plugins;
private static ColorCollection colors;
private static TypesManager types;
private static Clock clock;
private static ErrorLogger errorlogger;
//private static Mutex appmutex;
@ -235,7 +220,6 @@ namespace CodeImp.DoomBuilder
public static ActionManager Actions { get { return actions; } }
public static HintsManager Hints { get { return hints; } } //mxd
internal static PluginManager Plugins { get { return plugins; } }
public static Clock Clock { get { return clock; } }
public static bool DebugBuild { get { return debugbuild; } }
internal static TypesManager Types { get { return types; } }
public static string AutoLoadFile { get { return autoloadfile; } }
@ -551,8 +535,9 @@ namespace CodeImp.DoomBuilder
// Enable OS visual styles
Application.EnableVisualStyles();
Application.DoEvents(); // This must be here to work around a .NET bug
ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());
Application.SetCompatibleTextRenderingDefault(false); //mxd
//Application.DoEvents(); // This must be here to work around a .NET bug
//ToolStripManager.Renderer = new ToolStripProfessionalRenderer(new TanColorTable());
// Hook to DLL loading failure event
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
@ -576,7 +561,6 @@ namespace CodeImp.DoomBuilder
// Setup directories
temppath = Path.GetTempPath();
setuppath = Path.Combine(apppath, SETUP_DIR);
settingspath = (portablemode ? apppath : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), SETTINGS_DIR)); //mxd
restorepath = Path.Combine(settingspath, MAP_RESTORE_DIR);
configspath = Path.Combine(apppath, GAME_CONFIGS_DIR);
@ -679,20 +663,12 @@ namespace CodeImp.DoomBuilder
General.WriteLogLine("Loading color settings...");
colors = new ColorCollection(settings.Config);
// Create application clock
General.WriteLogLine("Creating application clock...");
clock = new Clock();
// Create types manager
General.WriteLogLine("Creating types manager...");
types = new TypesManager();
//mxd. init gzdoom builder
GZBuilder.GZGeneral.Init();
// Do auto map loading when window is delayed
if(delaymainwindow)
mainwindow.PerformAutoMapLoading();
if(delaymainwindow) mainwindow.PerformAutoMapLoading();
// All done
General.WriteLogLine("Startup done");
@ -1408,7 +1384,7 @@ namespace CodeImp.DoomBuilder
editing.DisengageVolatileMode();
// Check if a wad file is known
if(map.FilePathName == "")
if(string.IsNullOrEmpty(map.FilePathName))
{
// Call to SaveMapAs
result = SaveMapAs();
@ -2106,13 +2082,13 @@ namespace CodeImp.DoomBuilder
EventLog.CreateEventSource("ThreadException", "Application");
// Create an EventLog instance and assign its source.
using (EventLog myLog = new EventLog())
using(EventLog myLog = new EventLog())
{
myLog.Source = "ThreadException";
myLog.WriteEntry(exceptionmsg);
}
}
catch (Exception exc)
catch(Exception exc)
{
MessageBox.Show("Could not write the error to the event log.\nReason: "
+ exc.Message + "\n\nInitial exception:\n" + exceptionmsg, "Fatal Non-UI Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);

View file

@ -268,7 +268,7 @@ namespace CodeImp.DoomBuilder
Cursor oldcursor = Cursor.Current;
// Check if configuration is OK
if(General.Map.ConfigSettings.TestProgram == "" || !File.Exists(General.Map.ConfigSettings.TestProgram))
if(string.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram) || !File.Exists(General.Map.ConfigSettings.TestProgram))
{
//mxd. Let's be more precise
string message;

View file

@ -40,7 +40,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder
{
public sealed class MapManager
public sealed class MapManager : IDisposable
{
#region ================== Constants
@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder
}
// Disposer
internal bool Dispose()
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
@ -234,11 +234,7 @@ namespace CodeImp.DoomBuilder
// Done
isdisposed = true;
return true;
}
// Already closed
return true;
}
#endregion
@ -828,7 +824,7 @@ namespace CodeImp.DoomBuilder
}
// Determine original map name
string origmapname = (options.PreviousName != "" && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
string origmapname = (!string.IsNullOrEmpty(options.PreviousName) && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
string origwadfile = string.Empty; //mxd
try
@ -1653,6 +1649,152 @@ namespace CodeImp.DoomBuilder
#endregion
#region ================== [mxd] GZDB actions
[BeginAction("gztogglemodels")]
internal void ToggleModelsRenderingMode()
{
switch(General.Settings.GZDrawModelsMode)
{
case ModelRenderMode.NONE:
General.Settings.GZDrawModelsMode = ModelRenderMode.SELECTION;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: SELECTION ONLY");
break;
case ModelRenderMode.SELECTION:
General.Settings.GZDrawModelsMode = ModelRenderMode.ACTIVE_THINGS_FILTER;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ACTIVE THINGS FILTER ONLY");
break;
case ModelRenderMode.ACTIVE_THINGS_FILTER:
General.Settings.GZDrawModelsMode = ModelRenderMode.ALL;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: ALL");
break;
case ModelRenderMode.ALL:
General.Settings.GZDrawModelsMode = ModelRenderMode.NONE;
General.MainWindow.DisplayStatus(StatusType.Action, "Models rendering mode: NONE");
break;
}
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglelights")]
internal void ToggleLightsRenderingMode()
{
if(General.Editing.Mode is ClassicMode)
{
switch(General.Settings.GZDrawLightsMode)
{
case LightRenderMode.NONE:
General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
break;
default:
General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
break;
}
}
else
{
switch(General.Settings.GZDrawLightsMode)
{
case LightRenderMode.NONE:
General.Settings.GZDrawLightsMode = LightRenderMode.ALL;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ALL");
break;
case LightRenderMode.ALL:
General.Settings.GZDrawLightsMode = LightRenderMode.ALL_ANIMATED;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: ANIMATED");
break;
case LightRenderMode.ALL_ANIMATED:
General.Settings.GZDrawLightsMode = LightRenderMode.NONE;
General.MainWindow.DisplayStatus(StatusType.Action, "Dynamic lights rendering mode: NONE");
break;
}
}
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglefog")]
internal void ToggleFog()
{
General.Settings.GZDrawFog = !General.Settings.GZDrawFog;
General.MainWindow.DisplayStatus(StatusType.Action, "Fog rendering is " + (General.Settings.GZDrawFog ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglesky")]
internal void ToggleSky()
{
General.Settings.GZDrawSky = !General.Settings.GZDrawSky;
General.MainWindow.DisplayStatus(StatusType.Action, "Sky rendering is " + (General.Settings.GZDrawSky ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglefx")]
internal void ToggleFx()
{
int on = 0;
on += General.Settings.GZDrawFog ? 1 : -1;
on += General.Settings.GZDrawSky ? 1 : -1;
on += General.Settings.GZDrawLightsMode != LightRenderMode.NONE ? 1 : -1;
on += General.Settings.GZDrawModelsMode != ModelRenderMode.NONE ? 1 : -1;
bool enable = (on < 0);
General.Settings.GZDrawFog = enable;
General.Settings.GZDrawSky = enable;
General.Settings.GZDrawLightsMode = (enable ? LightRenderMode.ALL : LightRenderMode.NONE);
General.Settings.GZDrawModelsMode = (enable ? ModelRenderMode.ALL : ModelRenderMode.NONE);
General.MainWindow.DisplayStatus(StatusType.Action, "Advanced effects are " + (enable ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztoggleeventlines")]
internal void ToggleEventLines()
{
General.Settings.GZShowEventLines = !General.Settings.GZShowEventLines;
General.MainWindow.DisplayStatus(StatusType.Action, "Event lines are " + (General.Settings.GZShowEventLines ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gztogglevisualvertices")]
internal void ToggleVisualVertices()
{
General.Settings.GZShowVisualVertices = !General.Settings.GZShowVisualVertices;
General.MainWindow.DisplayStatus(StatusType.Action, "Visual vertices are " + (General.Settings.GZShowVisualVertices ? "ENABLED" : "DISABLED"));
General.MainWindow.RedrawDisplay();
General.MainWindow.UpdateGZDoomPanel();
}
[BeginAction("gzreloadmodeldef")]
internal void ReloadModeldef()
{
data.ReloadModeldef();
}
[BeginAction("gzreloadgldefs")]
internal void ReloadGldefs()
{
data.ReloadGldefs();
}
#endregion
#region ================== Script Editing
// Show the script editor
@ -1994,6 +2136,8 @@ namespace CodeImp.DoomBuilder
compilererrors.Add(new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine));
break;
}
parser.Dispose();
}
}
}

View file

@ -24,6 +24,7 @@ using System.Drawing;
namespace CodeImp.DoomBuilder.Geometry
{
[Serializable]
public sealed class EarClipPolygon : LinkedList<EarClipVertex>
{
#region ================== Variables

View file

@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);

View file

@ -445,7 +445,7 @@ namespace CodeImp.DoomBuilder.IO
bool validateresult;
// Check if key is an empty string
if(key == "")
if(string.IsNullOrEmpty(key))
{
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_KEYMISSING);
@ -500,7 +500,7 @@ namespace CodeImp.DoomBuilder.IO
bool validateresult;
// Check if key is an empty string
if(keyword == "")
if(string.IsNullOrEmpty(keyword))
{
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_ASSIGNINVALID);

View file

@ -16,6 +16,7 @@
#region ================== Namespaces
using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Geometry;
using System.IO;
@ -24,7 +25,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
internal sealed class DeserializerStream : IReadWriteStream
internal sealed class DeserializerStream : IReadWriteStream, IDisposable
{
#region ================== Constants
@ -33,9 +34,10 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Variables
private Stream stream;
private BinaryReader reader;
private readonly BinaryReader reader;
private string[] stringstable;
private int stringtablepos;
private bool isdisposed; //mxd
#endregion
@ -57,6 +59,23 @@ namespace CodeImp.DoomBuilder.IO
this.reader = new BinaryReader(stream);
}
//mxd
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
if(reader != null) reader.Close();
if(stream != null)
{
stream.Dispose();
stream = null;
}
isdisposed = true;
}
}
#endregion
#region ================== Methods

View file

@ -25,7 +25,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.IO
{
public class Lump
public class Lump : IDisposable
{
#region ================== Methods
@ -40,14 +40,14 @@ namespace CodeImp.DoomBuilder.IO
private WAD owner;
// Data stream
private ClippedStream stream;
private readonly ClippedStream stream;
// Data info
private string name;
private long longname;
private byte[] fixedname;
private int offset;
private int length;
private readonly int offset;
private readonly int length;
// Disposing
private bool isdisposed;
@ -89,7 +89,7 @@ namespace CodeImp.DoomBuilder.IO
}
// Disposer
internal void Dispose()
public void Dispose()
{
// Not already disposed?
if(!isdisposed)

View file

@ -25,7 +25,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
internal sealed class SerializerStream : IReadWriteStream
internal sealed class SerializerStream : IReadWriteStream, IDisposable
{
#region ================== Constants
@ -34,8 +34,9 @@ namespace CodeImp.DoomBuilder.IO
#region ================== Variables
//private Stream stream;
private BinaryWriter writer;
private Dictionary<string, ushort> stringstable;
private readonly BinaryWriter writer;
private readonly Dictionary<string, ushort> stringstable;
private bool isdisposed; //mxd
#endregion
@ -56,6 +57,17 @@ namespace CodeImp.DoomBuilder.IO
this.stringstable = new Dictionary<string, ushort>(StringComparer.Ordinal);
}
//mxd
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
if(writer != null) writer.Close();
isdisposed = true;
}
}
#endregion
#region ================== Methods

View file

@ -52,7 +52,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(UDMF_UI_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(UDMF_UI_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);

View file

@ -380,7 +380,7 @@ namespace CodeImp.DoomBuilder.IO
{
// Hexadecimal?
string s = val.ToString();
if((s.Length > 2) && s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase))
if((s.Length > 2) && s.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
{
// Convert to int
try

View file

@ -69,7 +69,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);

View file

@ -62,7 +62,7 @@ namespace CodeImp.DoomBuilder.IO
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(UDMF_CONFIG_NAME, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream udmfcfg = General.ThisAssembly.GetManifestResourceStream(rn);

View file

@ -25,7 +25,7 @@ using System.IO;
namespace CodeImp.DoomBuilder.IO
{
internal class WAD
internal class WAD : IDisposable
{
#region ================== Constants

View file

@ -107,7 +107,7 @@ namespace CodeImp.DoomBuilder.Map
// Change the name, but keep previous name
if(currentname != value)
{
if(previousname == "") previousname = currentname;
if(string.IsNullOrEmpty(previousname)) previousname = currentname;
currentname = value;
}
}

View file

@ -899,6 +899,7 @@ namespace CodeImp.DoomBuilder.Map
ReadThings(deserializer);
deserializer.End();
deserializer.Dispose(); //mxd
// Make table of sidedef indices
sidedefindices = new Sidedef[numsidedefs];

View file

@ -11,6 +11,7 @@ namespace CodeImp.DoomBuilder.Map
/// <summary>
/// List of universal fields and their values.
/// </summary>
[Serializable]
public class UniFields : Dictionary<string, UniValue>
{
#region ================== Variables

View file

@ -165,7 +165,7 @@ namespace CodeImp.DoomBuilder.Plugins
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(resourcename, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(resourcename, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
return asm.GetManifestResourceStream(rn);

View file

@ -13,7 +13,7 @@
*/
#endregion
/*
#region ================== Namespaces
using System;
@ -88,3 +88,4 @@ namespace CodeImp.DoomBuilder.Rendering
#endregion
}
}
*/

View file

@ -30,7 +30,7 @@ using CodeImp.DoomBuilder.Controls;
namespace CodeImp.DoomBuilder.Rendering
{
internal class D3DDevice
internal class D3DDevice : IDisposable
{
#region ================== Constants
@ -53,7 +53,7 @@ namespace CodeImp.DoomBuilder.Rendering
private Capabilities devicecaps;
private Device device;
private Viewport viewport;
private Dictionary<ID3DResource, ID3DResource> resources;
private readonly HashSet<ID3DResource> resources;
private ShaderManager shaders;
private Surface backbuffer;
private Surface depthbuffer;
@ -91,25 +91,29 @@ namespace CodeImp.DoomBuilder.Rendering
this.rendertarget = rendertarget;
// Create resources list
resources = new Dictionary<ID3DResource, ID3DResource>();
resources = new HashSet<ID3DResource>();
// We have no destructor
GC.SuppressFinalize(this);
}
// Disposer
internal void Dispose()
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
// Clean up
foreach(ID3DResource res in resources.Values) res.UnloadResource();
foreach(ID3DResource res in resources) res.UnloadResource();
if(shaders != null) shaders.Dispose();
rendertarget = null;
if(backbuffer != null) backbuffer.Dispose();
if(depthbuffer != null) depthbuffer.Dispose();
if(device != null) device.Dispose();
if(device != null)
{
device.Reset(new PresentParameters()); //mxd. Some video memory is not freed without this line if Visual mode was visited
device.Dispose();
}
if(font != null) font.Dispose();
if(fonttexture != null) fonttexture.Dispose();
isrendering = false; //mxd
@ -324,7 +328,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal void RegisterResource(ID3DResource res)
{
// Add resource
resources.Add(res, res);
resources.Add(res);
}
// This unregisters a resource
@ -338,7 +342,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal bool Reset()
{
// Unload all Direct3D resources
foreach(ID3DResource res in resources.Values) res.UnloadResource();
foreach(ID3DResource res in resources) res.UnloadResource();
// Lose backbuffers
if(backbuffer != null) backbuffer.Dispose();
@ -377,7 +381,7 @@ namespace CodeImp.DoomBuilder.Rendering
viewport = device.Viewport;
// Reload all Direct3D resources
foreach(ID3DResource res in resources.Values) res.ReloadResource();
foreach(ID3DResource res in resources) res.ReloadResource();
// Re-apply settings
SetupSettings();

View file

@ -24,7 +24,7 @@ using SlimDX.Direct3D9;
namespace CodeImp.DoomBuilder.Rendering
{
internal abstract class D3DShader
internal abstract class D3DShader : IDisposable
{
#region ================== Constants

View file

@ -25,7 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
namespace CodeImp.DoomBuilder.Rendering
{
internal abstract class Renderer : ID3DResource
internal abstract class Renderer : ID3DResource, IDisposable
{
#region ================== Constants
@ -66,7 +66,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Disposer
internal virtual void Dispose()
public virtual void Dispose()
{
// Not already disposed?
if(!isdisposed)

View file

@ -162,7 +162,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Disposer
internal override void Dispose()
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)

View file

@ -156,7 +156,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Disposer
internal override void Dispose()
public override void Dispose()
{
// Not already disposed?
if(!isdisposed)

View file

@ -89,7 +89,7 @@ namespace CodeImp.DoomBuilder.Rendering
foreach(string rn in resnames)
{
// Found it?
if(rn.EndsWith(FONT_RESOURCE, StringComparison.InvariantCultureIgnoreCase))
if(rn.EndsWith(FONT_RESOURCE, StringComparison.OrdinalIgnoreCase))
{
// Get a stream from the resource
Stream fontdata = General.ThisAssembly.GetManifestResourceStream(rn);

View file

@ -39,15 +39,10 @@ namespace CodeImp.DoomBuilder.Rendering
//mxd
private readonly EffectHandle vertexColorHadle;
//lights
private readonly EffectHandle lightPositionAndRadiusHandle;
private readonly EffectHandle lightPositionAndRadiusHandle; //lights
private readonly EffectHandle lightColorHandle;
private readonly EffectHandle world;
//fog
private readonly EffectHandle camPosHandle;
//used in ModelReader
private readonly VertexElement[] vertexElements;
private readonly EffectHandle camPosHandle; //used for fog rendering
#endregion
@ -190,7 +185,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Initialize world vertex declaration
vertexElements = new[]
VertexElement[] ve = new[]
{
new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0),
new VertexElement(0, 12, DeclarationType.Color, DeclarationMethod.Default, DeclarationUsage.Color, 0),
@ -199,7 +194,7 @@ namespace CodeImp.DoomBuilder.Rendering
VertexElement.VertexDeclarationEnd
};
vertexdecl = new VertexDeclaration(General.Map.Graphics.Device, vertexElements);
vertexdecl = new VertexDeclaration(General.Map.Graphics.Device, ve);
// We have no destructor
GC.SuppressFinalize(this);

View file

@ -22,7 +22,7 @@ using System;
namespace CodeImp.DoomBuilder.Types
{
public class TypeHandlerAttribute : Attribute
public sealed class TypeHandlerAttribute : Attribute
{
#region ================== Constants

View file

@ -16,6 +16,7 @@
#region ================== Namespaces
using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Map;
using SlimDX.Direct3D9;
@ -26,7 +27,7 @@ using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.VisualModes
{
public class VisualSector : ID3DResource
public class VisualSector : ID3DResource, IDisposable
{
#region ================== Constants
@ -35,14 +36,14 @@ namespace CodeImp.DoomBuilder.VisualModes
#region ================== Variables
// Geometry
private List<VisualGeometry> fixedgeometry;
private List<VisualGeometry> allgeometry;
private Dictionary<Sidedef, List<VisualGeometry>> sidedefgeometry;
private readonly List<VisualGeometry> fixedgeometry;
private readonly List<VisualGeometry> allgeometry;
private readonly Dictionary<Sidedef, List<VisualGeometry>> sidedefgeometry;
private VertexBuffer geobuffer;
private bool updategeo;
// Original sector
private Sector sector;
private readonly Sector sector;
// Disposing
private bool isdisposed;

View file

@ -32,7 +32,7 @@ using Plane = CodeImp.DoomBuilder.Geometry.Plane;
namespace CodeImp.DoomBuilder.VisualModes
{
public abstract class VisualThing : IVisualPickable, ID3DResource
public abstract class VisualThing : IVisualPickable, ID3DResource, IDisposable
{
#region ================== Constants

View file

@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Windows
{
mapsettings = new Configuration(dbsfile, true);
}
catch (Exception)
catch(Exception)
{
mapsettings = new Configuration(true);
}

View file

@ -38,7 +38,7 @@ namespace CodeImp.DoomBuilder.Windows
flags.Add(tf.Value, tf.Key);
// Parse the value string and check the boxes if necessary
if(value.Trim() != "")
if(!string.IsNullOrEmpty(value.Trim()))
{
foreach(string s in value.Split(','))
{
@ -84,7 +84,7 @@ namespace CodeImp.DoomBuilder.Windows
{
if(lf.Value == c.Text)
{
if(value != "") value += ",";
if(!string.IsNullOrEmpty(value)) value += ",";
value += lf.Key;
}
}

View file

@ -2472,7 +2472,7 @@ namespace CodeImp.DoomBuilder.Windows
if(item.Tag is string)
{
// Check if the tag doe not already begin with the assembly name
if(!(item.Tag as string).StartsWith(plugin.Name + "_", StringComparison.InvariantCultureIgnoreCase))
if(!(item.Tag as string).StartsWith(plugin.Name + "_", StringComparison.OrdinalIgnoreCase))
{
// Change the tag to a fully qualified action name
item.Tag = plugin.Name.ToLowerInvariant() + "_" + (item.Tag as string);
@ -2534,7 +2534,7 @@ namespace CodeImp.DoomBuilder.Windows
// Get configuration setting
string filename = General.Settings.ReadSetting("recentfiles.file" + i, "");
if(filename != "" && File.Exists(filename))
if(!string.IsNullOrEmpty(filename) && File.Exists(filename))
{
// Set up item
int number = i + 1;
@ -2561,7 +2561,7 @@ namespace CodeImp.DoomBuilder.Windows
for(int i = 0; i < recentitems.Length; i++)
{
// Recent file set?
if(recentitems[i].Text != "")
if(!string.IsNullOrEmpty(recentitems[i].Text))
{
// Save to configuration
General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString());
@ -2603,7 +2603,7 @@ namespace CodeImp.DoomBuilder.Windows
int number = i + 2;
recentitems[i + 1].Text = "&" + number + " " + GetDisplayFilename(recentitems[i].Tag.ToString());
recentitems[i + 1].Tag = recentitems[i].Tag.ToString();
recentitems[i + 1].Visible = (recentitems[i].Tag.ToString() != "");
recentitems[i + 1].Visible = !string.IsNullOrEmpty(recentitems[i].Tag.ToString());
}
// Add new file at the top
@ -3027,7 +3027,7 @@ namespace CodeImp.DoomBuilder.Windows
writer.Write(html.ToString());
}
}
catch (Exception)
catch(Exception)
{
//Configurtions path SHOULD be accessible and not read-only, right?
path = Path.Combine(General.SettingsPath, fileName);
@ -3884,24 +3884,15 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
// Start annoying blinking!
if(blink)
{
if(!blinkTimer.Enabled) blinkTimer.Start();
}
else
{
blinkTimer.Stop();
warnsLabel.BackColor = SystemColors.Control;
}
// Update icon
// Update icon, start annoying blinking if necessary
if(count > 0)
{
if(blink && !blinkTimer.Enabled) blinkTimer.Start();
warnsLabel.Image = Resources.Warning;
}
else
{
blinkTimer.Stop();
warnsLabel.Image = Resources.WarningOff;
warnsLabel.BackColor = SystemColors.Control;
}
@ -3925,6 +3916,7 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void blinkTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
if(!blinkTimer.Enabled) return;
try
{
this.Invoke(new CallBlink(Blink));

View file

@ -185,7 +185,7 @@ namespace CodeImp.DoomBuilder.Windows
// Level name changed and the map exists in a source wad?
if((levelname.Text != options.CurrentName) && (General.Map != null) &&
(General.Map.FilePathName != "") && File.Exists(General.Map.FilePathName))
(!string.IsNullOrEmpty(General.Map.FilePathName)) && File.Exists(General.Map.FilePathName))
{
// Open the source wad file to check for conflicting name
WAD sourcewad = new WAD(General.Map.FilePathName, true);

View file

@ -13,7 +13,7 @@
*/
#endregion
/*
#region ================== Namespaces
using System;
@ -772,4 +772,4 @@ namespace CodeImp.DoomBuilder.Windows
}
}
}
}*/

View file

@ -92,13 +92,19 @@ namespace CodeImp.DoomBuilder.ZDoom
}
// Disposer
public void Dispose()
override public void Dispose()
{
foreach(KeyValuePair<string, ActorStructure> a in archivedactors)
a.Value.Dispose();
actors = null;
archivedactors = null;
// Not already disposed?
if(!isdisposed)
{
foreach(KeyValuePair<string, ActorStructure> a in archivedactors)
a.Value.Dispose();
actors = null;
archivedactors = null;
base.Dispose();
}
}
#endregion

View file

@ -28,7 +28,7 @@ using CodeImp.DoomBuilder.Data;
namespace CodeImp.DoomBuilder.ZDoom
{
public abstract class ZDTextParser
public abstract class ZDTextParser : IDisposable
{
#region ================== Constants
@ -55,6 +55,9 @@ namespace CodeImp.DoomBuilder.ZDoom
private string errordesc;
private string errorsource;
private long prevstreamposition; //mxd. Text stream position storted before performing ReadToken.
//mxd. Disposing
protected bool isdisposed;
#endregion
@ -77,6 +80,23 @@ namespace CodeImp.DoomBuilder.ZDoom
// Initialize
errordesc = null;
}
//mxd
public virtual void Dispose()
{
// Not already disposed?
if(!isdisposed)
{
if(datareader != null) datareader.Close();
if(datastream != null)
{
datastream.Dispose();
datastream = null;
}
isdisposed = true;
}
}
#endregion
@ -588,7 +608,7 @@ namespace CodeImp.DoomBuilder.ZDoom
{
foreach(DataReader reader in General.Map.Data.Containers)
{
if(reader is DirectoryReader && filename.StartsWith(reader.Location.location, true, CultureInfo.InvariantCulture))
if(reader is DirectoryReader && filename.StartsWith(reader.Location.location, StringComparison.OrdinalIgnoreCase))
{
filename = filename.Substring(reader.Location.location.Length + 1, filename.Length - reader.Location.location.Length - 1);
break;

View file

@ -86,7 +86,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Handle thread interruption
try { Thread.Sleep(0); }
catch (ThreadInterruptedException) { return; }
catch(ThreadInterruptedException) { return; }
// We are making progress!
if((++progress / PROGRESS_STEP) > stepprogress)

View file

@ -83,7 +83,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
Thread.Sleep(0);
}
catch (ThreadInterruptedException)
catch(ThreadInterruptedException)
{
// Clear collection
donesides.Clear();

View file

@ -28,7 +28,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Map.Data.GetThingInfoEx(t.Type) == null) SubmitResult(new ResultUnknownThing(t));
// Handle thread interruption
try { Thread.Sleep(0); } catch (ThreadInterruptedException) { return; }
try { Thread.Sleep(0); } catch(ThreadInterruptedException) { return; }
// We are making progress!
if((++progress / PROGRESS_STEP) > stepprogress)

View file

@ -268,11 +268,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
int x = side.Bounds.X - minx + margin;
int y = side.Bounds.Y - miny + margin;
using (Pen p = new Pen(c))
using(Pen p = new Pen(c))
{
g.DrawRectangle(p, x, y, side.Bounds.Width, side.Bounds.Height);
}
using (Brush b = new SolidBrush(c))
using(Brush b = new SolidBrush(c))
{
g.DrawString(i++ + ": line " + side.Side.Sidedef.Line.Index + "; x:" + side.Bounds.X + " y:" + side.Bounds.Y, this.Font, b, x + 2, y + 2);
}

View file

@ -81,7 +81,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
// (colorRectangle), brightness "strip" (brightnessRectangle)
// and location to display selected color (selectedColorRectangle).
using (GraphicsPath path = new GraphicsPath())
using(GraphicsPath path = new GraphicsPath())
{
// Store away locations for later use.
this.colorRectangle = colorRectangle;
@ -358,7 +358,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
// Given the top color, draw a linear gradient
// ranging from black to the top color. Use the
// brightness rectangle as the area to fill.
using (LinearGradientBrush lgb = new LinearGradientBrush(brightnessRectangle, TopColor,
using(LinearGradientBrush lgb = new LinearGradientBrush(brightnessRectangle, TopColor,
Color.Black, LinearGradientMode.Vertical))
{
g.FillRectangle(lgb, brightnessRectangle);
@ -399,7 +399,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
{
// Create a new PathGradientBrush, supplying an array of points created by calling
// the GetPoints method.
using (PathGradientBrush pgb = new PathGradientBrush(GetPoints(radius, new Point(radius, radius))))
using(PathGradientBrush pgb = new PathGradientBrush(GetPoints(radius, new Point(radius, radius))))
{
// Set the various properties. Note the SurroundColors property, which contains an array of points,
// in a one-to-one relationship with the points that created the gradient.
@ -412,7 +412,7 @@ namespace CodeImp.DoomBuilder.ColorPicker
// rather than recreating the gradient.
colorImage = new Bitmap(colorRectangle.Width, colorRectangle.Height, PixelFormat.Format32bppArgb);
using (Graphics newGraphics = Graphics.FromImage(colorImage))
using(Graphics newGraphics = Graphics.FromImage(colorImage))
{
newGraphics.FillEllipse(pgb, 0, 0, colorRectangle.Width, colorRectangle.Height);
}

View file

@ -1358,7 +1358,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
General.Map.Map.Update();
General.Map.IsChanged = true;
}
catch (Exception e)
catch(Exception e)
{
General.Interface.DisplayStatus(StatusType.Warning, e.ToString());
General.Map.UndoRedo.WithdrawUndo();

View file

@ -988,7 +988,7 @@ namespace CodeImp.DoomBuilder.TagExplorer
using(StreamWriter sw = File.CreateText(saveFileDialog.FileName)) sw.Write(sb.ToString());
General.Interface.DisplayStatus(StatusType.Info, "Tag info successfully saved.");
}
catch (Exception ex)
catch(Exception ex)
{
General.ErrorLogger.Add(ErrorType.Error, "Failed to save tag info: " + ex.Message);
General.Interface.DisplayStatus(StatusType.Info, "Failed to save tag info...");