2007-06-15 18:30:55 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
|
|
|
using CodeImp.DoomBuilder.Interface;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
2007-06-15 22:38:42 +00:00
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
2007-06-24 18:56:43 +00:00
|
|
|
using System.Diagnostics;
|
2007-06-26 06:01:52 +00:00
|
|
|
using CodeImp.DoomBuilder.Controls;
|
2007-06-15 18:30:55 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Editing
|
|
|
|
{
|
|
|
|
internal class EditMode : IDisposable
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
2007-06-15 22:38:42 +00:00
|
|
|
|
|
|
|
// Graphics
|
2007-09-17 21:22:46 +00:00
|
|
|
protected D3DGraphics graphics;
|
2007-06-15 22:38:42 +00:00
|
|
|
|
2007-06-15 18:30:55 +00:00
|
|
|
// Disposing
|
|
|
|
protected bool isdisposed = false;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
|
|
|
// Disposing
|
|
|
|
public bool IsDisposed { get { return isdisposed; } }
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public EditMode()
|
|
|
|
{
|
|
|
|
// Initialize
|
2007-06-15 22:38:42 +00:00
|
|
|
this.graphics = General.Map.Graphics;
|
2007-06-16 19:53:51 +00:00
|
|
|
|
2007-06-26 06:01:52 +00:00
|
|
|
// Bind any methods
|
|
|
|
ActionAttribute.BindMethods(this);
|
|
|
|
|
2007-06-15 18:30:55 +00:00
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Diposer
|
|
|
|
public virtual void Dispose()
|
|
|
|
{
|
|
|
|
// Not already disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
2007-06-26 06:01:52 +00:00
|
|
|
// Unbind any methods
|
|
|
|
ActionAttribute.UnbindMethods(this);
|
|
|
|
|
2007-06-15 18:30:55 +00:00
|
|
|
// Clean up
|
|
|
|
|
|
|
|
// Done
|
|
|
|
isdisposed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-06-24 18:56:43 +00:00
|
|
|
#region ================== Static Methods
|
|
|
|
|
|
|
|
// This creates an instance of a specific mode
|
|
|
|
public static EditMode Create(Type modetype, object[] args)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Create new mode
|
|
|
|
return (EditMode)General.ThisAssembly.CreateInstance(modetype.FullName, false,
|
|
|
|
BindingFlags.Default, null, args, CultureInfo.CurrentCulture, new object[0]);
|
|
|
|
}
|
|
|
|
// Catch errors
|
|
|
|
catch(TargetInvocationException e)
|
|
|
|
{
|
|
|
|
// Throw the actual exception
|
|
|
|
Debug.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString());
|
|
|
|
Debug.WriteLine(e.InnerException.Source + " throws " + e.InnerException.GetType().Name + ":");
|
|
|
|
Debug.WriteLine(e.InnerException.Message);
|
|
|
|
Debug.WriteLine(e.InnerException.StackTrace);
|
|
|
|
throw e.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2007-06-15 18:30:55 +00:00
|
|
|
#region ================== Methods
|
|
|
|
|
|
|
|
// Optional interface methods
|
|
|
|
public virtual void MouseClick(MouseEventArgs e) { }
|
|
|
|
public virtual void MouseDoubleClick(MouseEventArgs e) { }
|
|
|
|
public virtual void MouseDown(MouseEventArgs e) { }
|
|
|
|
public virtual void MouseEnter(EventArgs e) { }
|
|
|
|
public virtual void MouseLeave(EventArgs e) { }
|
|
|
|
public virtual void MouseMove(MouseEventArgs e) { }
|
|
|
|
public virtual void MouseUp(MouseEventArgs e) { }
|
|
|
|
public virtual void Cancel() { }
|
2007-06-15 22:38:42 +00:00
|
|
|
public virtual void RedrawDisplay() { }
|
2007-06-15 18:30:55 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|