Merged in GZDB r2493.

This commit is contained in:
MascaraSnake 2016-04-07 15:29:47 +02:00
parent c3e08eb1ef
commit f03de4a27a
65 changed files with 535 additions and 452 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

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

View file

@ -382,9 +382,9 @@ namespace CodeImp.DoomBuilder.Controls
fieldslist.CurrentCell = fieldslist.SelectedRows[0].Cells[0];
fieldslist.CurrentCell.ReadOnly = false;
if((e.RowIndex == fieldslist.NewRowIndex) ||
frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, true, CultureInfo.InvariantCulture))
fieldslist.BeginEdit(false);
if((e.RowIndex == fieldslist.NewRowIndex) ||
frow.Name.StartsWith(FIELD_PREFIX_SUGGESTION, StringComparison.OrdinalIgnoreCase))
fieldslist.BeginEdit(false);
else
fieldslist.BeginEdit(true);
}
@ -468,12 +468,13 @@ namespace CodeImp.DoomBuilder.Controls
// Select the value of this field (for DropDownList style combo)
foreach(EnumItem i in enumscombo.Items)
{
// Matches?
if(string.Compare(i.Title, frow.TypeHandler.GetStringValue(), true, CultureInfo.InvariantCulture) == 0)
{
// Matches?
if (string.Compare(i.Title, frow.TypeHandler.GetStringValue(), StringComparison.OrdinalIgnoreCase) == 0)
{
// Select this item
enumscombo.SelectedItem = i;
}
break; //mxd
}
}
// Put the display text in the text (for DropDown style combo)

View file

@ -338,7 +338,9 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
}
parser.Dispose();
}
//mxd
private void UpdateNavigatorModeldef(MemoryStream stream)
@ -356,7 +358,9 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
}
parser.Dispose();
}
//mxd
private void UpdateNavigatorAcs(MemoryStream stream)
@ -376,7 +380,9 @@ namespace CodeImp.DoomBuilder.Controls
{
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
}
parser.Dispose();
}
//mxd
internal ScriptType VerifyScriptType()
@ -393,7 +399,8 @@ namespace CodeImp.DoomBuilder.Controls
panel.ShowErrors(new List<CompilerError> { new CompilerError(parser.ErrorDescription, parser.ErrorSource, parser.ErrorLine) });
}
return ScriptType.UNKNOWN;
parser.Dispose();
return ScriptType.UNKNOWN;
}
//mxd

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

@ -139,7 +139,7 @@ namespace CodeImp.DoomBuilder.Controls
tabs.TabPages.Add(t);
}
}
if (General.Map.FilePathName != "")
if (!String.IsNullOrEmpty(General.Map.FilePathName))
{
WAD file = new WAD(General.Map.FilePathName);
List<Lump> lumps = file.Lumps;
@ -630,7 +630,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

@ -126,8 +126,8 @@ namespace CodeImp.DoomBuilder.Controls
// Dispose compiler
compiler.Dispose();
//mxd. Update script navigator
UpdateNavigator();
//mxd. Update script navigator
UpdateNavigator();
// Feed errors to panel
panel.ShowErrors(errors);
@ -256,9 +256,10 @@ namespace CodeImp.DoomBuilder.Controls
// Dispose compiler
compiler.Dispose();
parser.Dispose();
// Update script navigator
UpdateNavigator();
// Update script navigator
UpdateNavigator();
// Feed errors to panel
panel.ShowErrors(errors);

View file

@ -1855,7 +1855,7 @@ namespace CodeImp.DoomBuilder.Data
//mxd. DECORATE lumps are interdepandable. Can't carry on...
if(parser.HasError)
{
decorate.LogError();
parser.LogError();
return;
}
}
@ -2011,8 +2011,9 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
parser.Dispose();
foreach(KeyValuePair<string, ModelData> e in modeldefentriesbyname)
foreach (KeyValuePair<string, ModelData> e in modeldefentriesbyname)
{
if(actorsbyclass.ContainsKey(e.Key))
modeldefentries[actorsbyclass[e.Key]] = modeldefentriesbyname[e.Key];
@ -2098,9 +2099,10 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
parser.Dispose();
//get voxel models
foreach(KeyValuePair<string, bool> group in voxelNames)
//get voxel models
foreach (KeyValuePair<string, bool> group in voxelNames)
{
if(processed.ContainsKey(group.Key)) continue;
foreach(KeyValuePair<string, List<int>> sc in sprites)
@ -2160,6 +2162,8 @@ namespace CodeImp.DoomBuilder.Data
// And skyboxes
skyboxes = parser.Skyboxes;
parser.Dispose();
}
//mxd. This updates mapinfo class only
@ -2207,6 +2211,7 @@ namespace CodeImp.DoomBuilder.Data
spawnnums = new Dictionary<int, string>();
doomednums = new Dictionary<int, string>();
parser.Dispose();
}
else
{
@ -2246,6 +2251,7 @@ namespace CodeImp.DoomBuilder.Data
doomednums = new Dictionary<int, string>();
mapinfo = new MapInfo();
}
parser.Dispose();
}
currentreader = null;
}
@ -2281,7 +2287,8 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
reverbs = parser.GetReverbs();
}
parser.Dispose();
}
//mxd. This loads SNDSEQ
private void LoadSndSeq()
@ -2309,7 +2316,8 @@ namespace CodeImp.DoomBuilder.Data
currentreader = null;
soundsequences = parser.GetSoundSequences();
}
parser.Dispose();
}
//mxd. This loads cameratextures from ANIMDEFS
private void LoadAnimdefs()
@ -2376,7 +2384,8 @@ namespace CodeImp.DoomBuilder.Data
}
currentreader = null;
}
parser.Dispose();
}
//mxd
internal Stream LoadFile(string name)

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

@ -410,7 +410,9 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
}
parser.Dispose();
}
// This loads a set of textures
public static void LoadTextureSet(string sourcename, Stream texturedata, ref List<ImageData> images, PatchNames pnames)
@ -640,7 +642,9 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
}
parser.Dispose();
}
// This finds and returns a patch stream
public override Stream GetFlatData(string pname, bool longname)
@ -702,7 +706,9 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = t.MakeImage();
images.Add(img);
}
}
parser.Dispose();
}
// This finds and returns a sprite stream
public override Stream GetSpriteData(string pname)

View file

@ -78,12 +78,13 @@ namespace CodeImp.DoomBuilder.Editing
object[] attrs = this.GetType().GetCustomAttributes(true);
foreach(object a in attrs)
{
if(a is EditModeAttribute)
{
attributes = (EditModeAttribute)a;
break;
}
}
EditModeAttribute attribute = a as EditModeAttribute;
if (attribute != null)
{
attributes = attribute;
break;
}
}
// No attributes found?
if(attributes == null) throw new Exception("Editing mode \"" + this.GetType().Name + "\" is missing EditMode attributes!");

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,9 +198,21 @@ namespace CodeImp.DoomBuilder.Editing
ClearUndos();
ClearRedos();
General.WriteLogLine("All undo and redo levels cleared.");
// Done
isdisposed = true;
//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,8 +444,12 @@ namespace CodeImp.DoomBuilder.Editing
numcmds--;
}
}
General.Map.Map.AutoRemove = true;
//mxd
ds.End();
ds.Dispose();
General.Map.Map.AutoRemove = true;
}
#endregion

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

@ -95,13 +95,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls
public void ApplyTo(UniFields fields, int min, int max, float oldValue1, float oldValue2)
{
if(value1.Text != string.Empty)
UniFields.SetFloat(fields, field1, General.Clamp(value1.GetResultFloat(oldValue1), min, max), defaultValue);
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)
UniFields.SetFloat(fields, field2, General.Clamp(value2.GetResultFloat(oldValue2), min, max), defaultValue);
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,9 +4,12 @@ using System.IO;
namespace CodeImp.DoomBuilder.GZBuilder.Data
{
public class EngineInfo
public class EngineInfo : IDisposable
{
public const string DEFAULT_ENGINE_NAME = "Engine with no name";
// Disposing
private bool isdisposed;
public const string DEFAULT_ENGINE_NAME = "Engine with no name";
private string testprogramname;
public string TestProgramName { get { return testprogramname; } set { testprogramname = value; CheckProgramName(); } }
@ -64,5 +67,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;
upper = null;
if (lower != null) lower.Dispose();
lower = null;
}

View file

@ -22,10 +22,11 @@ namespace CodeImp.DoomBuilder.GZBuilder.Windows
logPath = Path.Combine(General.SettingsPath, @"GZCrash.txt");
Exception ex = (Exception)e.ExceptionObject;
errorDescription.Text = "Error in " + ex.Source + ":";
using(StreamWriter sw = File.CreateText(logPath))
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;
cannotContinue = true; //cannot recover from this...

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,11 +535,12 @@ 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());
// Hook to DLL loading failure event
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
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;
// Set current thread name
Thread.CurrentThread.Name = "Main Application";
@ -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");
@ -1406,10 +1382,10 @@ namespace CodeImp.DoomBuilder
// Cancel volatile mode, if any
editing.DisengageVolatileMode();
// Check if a wad file is known
if(map.FilePathName == "")
{
// Check if a wad file is known
if (string.IsNullOrEmpty(map.FilePathName))
{
// Call to SaveMapAs
result = SaveMapAs();
}

View file

@ -279,12 +279,12 @@ namespace CodeImp.DoomBuilder
{
Cursor oldcursor = Cursor.Current;
// Check if configuration is OK
if(General.Map.ConfigSettings.TestProgram == "" || !File.Exists(General.Map.ConfigSettings.TestProgram))
{
// Check if configuration is OK
if (string.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram) || !File.Exists(General.Map.ConfigSettings.TestProgram))
{
//mxd. Let's be more precise
string message;
if(General.Map.ConfigSettings.TestProgram == "")
if(String.IsNullOrEmpty(General.Map.ConfigSettings.TestProgram))
message = "Your test program is not set for the current game configuration";
else
message = "Current test program has invalid path";

View file

@ -40,7 +40,7 @@ using CodeImp.DoomBuilder.Windows;
namespace CodeImp.DoomBuilder
{
public sealed class MapManager
public sealed class MapManager : IDisposable
{
#region ================== Constants
@ -165,7 +165,7 @@ namespace CodeImp.DoomBuilder
}
// Disposer
internal bool Dispose()
public void Dispose()
{
// Not already disposed?
if(!isdisposed)
@ -235,11 +235,7 @@ namespace CodeImp.DoomBuilder
// Done
isdisposed = true;
return true;
}
// Already closed
return true;
}
#endregion
@ -828,8 +824,8 @@ namespace CodeImp.DoomBuilder
}
}
// Determine original map name
string origmapname = (options.PreviousName != "" && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
// Determine original map name
string origmapname = (!string.IsNullOrEmpty(options.PreviousName) && purpose != SavePurpose.IntoFile) ? options.PreviousName : options.CurrentName;
string origwadfile = string.Empty; //mxd
try
@ -877,7 +873,7 @@ namespace CodeImp.DoomBuilder
}
// On Save AS we have to copy the previous file to the new file
if((purpose == SavePurpose.AsNewFile) && (filepathname != ""))
if((purpose == SavePurpose.AsNewFile) && (!String.IsNullOrEmpty(filepathname)))
{
// Copy if original file still exists
if(File.Exists(filepathname)) File.Copy(filepathname, newfilepathname, true);
@ -1658,12 +1654,158 @@ namespace CodeImp.DoomBuilder
[BeginAction("cleargroup10")]
internal void ClearGroup10() { ClearGroup(9); }
#endregion
#endregion
#region ================== Script Editing
#region ================== [mxd] GZDB actions
// Show the script editor
[BeginAction("openscripteditor")]
[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
[BeginAction("openscripteditor")]
internal void ShowScriptEditor()
{
Cursor.Current = Cursors.WaitCursor;
@ -2001,7 +2143,9 @@ 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

@ -443,10 +443,10 @@ namespace CodeImp.DoomBuilder.IO
private bool ValidateKey(string key, string file, int errorline)
{
bool validateresult;
// Check if key is an empty string
if(key == "")
{
// Check if key is an empty string
if (string.IsNullOrEmpty(key))
{
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_KEYMISSING);
validateresult = false;
@ -498,10 +498,10 @@ namespace CodeImp.DoomBuilder.IO
private bool ValidateKeyword(string keyword, string file, int errorline)
{
bool validateresult;
// Check if key is an empty string
if(keyword == "")
{
// Check if key is an empty string
if (string.IsNullOrEmpty(keyword))
{
// ERROR: Missing key name in statement
if(errorline > -1) RaiseError(file, errorline, ERROR_ASSIGNINVALID);
validateresult = false;

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,15 +34,16 @@ 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
#endregion
#region ================== Properties
#region ================== Properties
public bool IsWriting { get { return false; } }
public bool IsWriting { get { return false; } }
public int EndPosition { get { return stringtablepos; } }
@ -57,12 +59,29 @@ namespace CodeImp.DoomBuilder.IO
this.reader = new BinaryReader(stream);
}
#endregion
//mxd
public void Dispose()
{
// Not already disposed?
if (!isdisposed)
{
if (reader != null) reader.Close();
if (stream != null)
{
stream.Dispose();
stream = null;
}
#region ================== Methods
isdisposed = true;
}
}
// Management
public void Begin()
#endregion
#region ================== Methods
// Management
public void Begin()
{
// First 4 bytes are reserved for the offset of the strings table
stringtablepos = reader.ReadInt32();

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,14 +34,15 @@ 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
#endregion
#region ================== Properties
#region ================== Properties
public bool IsWriting { get { return true; } }
public bool IsWriting { get { return true; } }
#endregion
@ -56,12 +57,23 @@ namespace CodeImp.DoomBuilder.IO
this.stringstable = new Dictionary<string, ushort>(StringComparer.Ordinal);
}
#endregion
//mxd
public void Dispose()
{
// Not already disposed?
if (!isdisposed)
{
if (writer != null) writer.Close();
isdisposed = true;
}
}
#region ================== Methods
#endregion
// Management
public void Begin()
#region ================== Methods
// Management
public void Begin()
{
// First 4 bytes are reserved for the offset of the strings table
const int offset = 0;

View file

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

View file

@ -899,9 +899,10 @@ namespace CodeImp.DoomBuilder.Map
ReadThings(deserializer);
deserializer.End();
deserializer.Dispose(); //mxd
// Make table of sidedef indices
sidedefindices = new Sidedef[numsidedefs];
// Make table of sidedef indices
sidedefindices = new Sidedef[numsidedefs];
foreach(Sidedef sd in sidedefs)
sidedefindices[sd.SerializedIndex] = sd;

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,8 +53,8 @@ namespace CodeImp.DoomBuilder.Rendering
private Capabilities devicecaps;
private Device device;
private Viewport viewport;
private Dictionary<ID3DResource, ID3DResource> resources;
private ShaderManager shaders;
private readonly HashSet<ID3DResource> resources;
private ShaderManager shaders;
private Surface backbuffer;
private Surface depthbuffer;
private TextFont font;
@ -90,27 +90,31 @@ namespace CodeImp.DoomBuilder.Rendering
// Set render target
this.rendertarget = rendertarget;
// Create resources list
resources = new Dictionary<ID3DResource, ID3DResource>();
// We have no destructor
GC.SuppressFinalize(this);
// Create resources list
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(font != null) font.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
@ -325,7 +329,7 @@ namespace CodeImp.DoomBuilder.Rendering
internal void RegisterResource(ID3DResource res)
{
// Add resource
resources.Add(res, res);
resources.Add(res);
}
// This unregisters a resource
@ -339,7 +343,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();
@ -378,7 +382,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

@ -161,7 +161,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,21 +39,16 @@ namespace CodeImp.DoomBuilder.Rendering
//mxd
private readonly EffectHandle vertexColorHadle;
//lights
private readonly EffectHandle lightPositionAndRadiusHandle;
private readonly EffectHandle lightColorHandle;
private readonly EffectHandle world;
//fog
private readonly EffectHandle camPosHandle;
//used in ModelReader
private readonly VertexElement[] vertexElements;
private readonly EffectHandle lightPositionAndRadiusHandle; //lights
private readonly EffectHandle lightColorHandle;
private readonly EffectHandle world;
private readonly EffectHandle camPosHandle; //used for fog rendering
#endregion
#endregion
#region ================== Properties
#region ================== Properties
private Matrix wwp;
private Matrix wwp;
public Matrix WorldViewProj
{
set
@ -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

@ -55,13 +55,17 @@ namespace CodeImp.DoomBuilder.SRB2
}
// Disposer
public void Dispose()
override public void Dispose()
{
objects = null;
/*states = null;
objectfreeslots = null;
statefreeslots = null;
spritefreeslots = null;*/
// Not already disposed?
if (!isdisposed)
{
objects = null;
/*states = null;
objectfreeslots = null;
statefreeslots = null;
spritefreeslots = null;*/
}
}
#endregion

View file

@ -57,13 +57,17 @@ namespace CodeImp.DoomBuilder.SRB2
}
// Disposer
public void Dispose()
override public void Dispose()
{
objects = null;
/*states = null;
objectfreeslots = null;
statefreeslots = null;
spritefreeslots = null;*/
// Not already disposed?
if (!isdisposed)
{
objects = null;
/*states = null;
objectfreeslots = null;
statefreeslots = null;
spritefreeslots = null;*/
}
}
#endregion

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

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

View file

@ -2480,7 +2480,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);
@ -2542,8 +2542,8 @@ 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;
recentitems[i].Text = "&" + number + " " + GetDisplayFilename(filename);
@ -2568,9 +2568,9 @@ namespace CodeImp.DoomBuilder.Windows
// Go for all items
for(int i = 0; i < recentitems.Length; i++)
{
// Recent file set?
if(recentitems[i].Text != "")
{
// Recent file set?
if (!string.IsNullOrEmpty(recentitems[i].Text))
{
// Save to configuration
General.Settings.WriteSetting("recentfiles.file" + i, recentitems[i].Tag.ToString());
}
@ -2611,8 +2611,8 @@ 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
recentitems[0].Text = "&1 " + GetDisplayFilename(filename);
@ -3915,30 +3915,21 @@ namespace CodeImp.DoomBuilder.Windows
return;
}
// Start annoying blinking!
if(blink)
{
if(!blinkTimer.Enabled) blinkTimer.Start();
}
else
{
blinkTimer.Stop();
warnsLabel.BackColor = SystemColors.Control;
}
// Update icon
if(count > 0)
{
warnsLabel.Image = Resources.Warning;
}
else
{
warnsLabel.Image = Resources.WarningOff;
warnsLabel.BackColor = SystemColors.Control;
}
// 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;
}
// Update errors count
warnsLabel.Text = count.ToString();
// Update errors count
warnsLabel.Text = count.ToString();
}
//mxd. Bliks warnings indicator
@ -3956,7 +3947,8 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void blinkTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
if (!blinkTimer.Enabled) return;
try
{
this.Invoke(new CallBlink(Blink));
} catch(ObjectDisposedException) { } //la-la-la. We don't care.

View file

@ -185,8 +185,8 @@ 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);
bool conflictingname = (sourcewad.FindLumpIndex(levelname.Text) > -1);
@ -213,7 +213,7 @@ namespace CodeImp.DoomBuilder.Windows
// we have to warn the user that the map may not be compatible.
// Configuration changed?
if((options.ConfigFile != "") && (configinfo.Filename != options.ConfigFile))
if((!String.IsNullOrEmpty(options.ConfigFile)) && (configinfo.Filename != options.ConfigFile))
{
// Check if the config uses a different IO interface
if(configinfo.Configuration.ReadSetting("formatinterface", "") != General.Map.Config.FormatInterface)

View file

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

View file

@ -92,14 +92,20 @@ 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,12 +55,15 @@ namespace CodeImp.DoomBuilder.ZDoom
protected string errordesc;
protected string errorsource;
protected long prevstreamposition; //mxd. Text stream position storted before performing ReadToken.
#endregion
#region ================== Properties
internal Stream DataStream { get { return datastream; } }
//mxd. Disposing
protected bool isdisposed;
#endregion
#region ================== Properties
internal Stream DataStream { get { return datastream; } }
internal BinaryReader DataReader { get { return datareader; } }
public int ErrorLine { get { return errorline; } }
public string ErrorDescription { get { return errordesc; } }
@ -77,13 +80,30 @@ namespace CodeImp.DoomBuilder.ZDoom
// Initialize
errordesc = null;
}
#endregion
#region ================== Parsing
//mxd
public virtual void Dispose()
{
// Not already disposed?
if (!isdisposed)
{
if (datareader != null) datareader.Close();
if (datastream != null)
{
datastream.Dispose();
datastream = null;
}
//mxd. This parses the given decorate stream. Returns false on errors
public virtual bool Parse(Stream stream, string sourcefilename, bool clearerrors)
isdisposed = true;
}
}
#endregion
#region ================== Parsing
//mxd. This parses the given decorate stream. Returns false on errors
public virtual bool Parse(Stream stream, string sourcefilename, bool clearerrors)
{
//mxd. Clear error status?
if(clearerrors) ClearError();
@ -588,8 +608,8 @@ 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

@ -188,7 +188,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
bsp = new BSP(BuilderPlug.Me.DontUseNodes);
useblockmap = bsp.IsDeactivated;
if (useblockmap && bsp.ErrorMessage != "")
if (useblockmap && !String.IsNullOrEmpty(bsp.ErrorMessage))
MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error);
// We have no destructor
@ -787,7 +787,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
thingdata = new Dictionary<Thing, ThingData>(General.Map.Map.Things.Count);
if (bsp.IsDeactivated && bsp.ErrorMessage != "")
if (bsp.IsDeactivated && !String.IsNullOrEmpty(bsp.ErrorMessage))
MessageBox.Show("Could not load the map's nodes: " + bsp.ErrorMessage + " Defaulting to blockmap.", "Error loading nodes!", MessageBoxButtons.OK, MessageBoxIcon.Error);

View file

@ -374,7 +374,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
private void numberofsectors_WhenTextChanged(object sender, EventArgs e)
{
if(numberofsectors.Text == "" || numberofsectors.GetResult(1) == 0) numberofsectors.Text = "1";
if(String.IsNullOrEmpty(numberofsectors.Text) || numberofsectors.GetResult(1) == 0) numberofsectors.Text = "1";
ComputeHeights();
DoRedrawDisplay();
}
@ -635,7 +635,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
int overwrite = -1;
// Prefab name may not be empty
if(name == "")
if(String.IsNullOrEmpty(name))
{
MessageBox.Show(this.Owner, "Please enter a name for the prefab", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;

View file

@ -1105,10 +1105,10 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
si.ceilingheight = primary.Sector.CeilHeight;
si.floorheight = primary.Sector.FloorHeight;
if(stairsectorbuilderform.UpperTextureTexture == "")
if(String.IsNullOrEmpty(stairsectorbuilderform.UpperTextureTexture))
stairsectorbuilderform.UpperTextureTexture = (secondary == null) ? primary.MiddleTexture : primary.HighTexture;
if(stairsectorbuilderform.LowerTextureTexture == "")
if(String.IsNullOrEmpty(stairsectorbuilderform.LowerTextureTexture))
stairsectorbuilderform.LowerTextureTexture = (secondary == null) ? primary.MiddleTexture : primary.LowTexture;
siout = si;