mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-16 09:01:27 +00:00
118 lines
2.9 KiB
C#
118 lines
2.9 KiB
C#
|
|
||
|
#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 CodeImp.DoomBuilder.IO;
|
||
|
using CodeImp.DoomBuilder.Data;
|
||
|
using System.IO;
|
||
|
using System.Diagnostics;
|
||
|
using System.Windows.Forms;
|
||
|
using CodeImp.DoomBuilder.Config;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
namespace CodeImp.DoomBuilder.Types
|
||
|
{
|
||
|
internal abstract class TypeHandler
|
||
|
{
|
||
|
#region ================== Constants
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ================== Variables
|
||
|
|
||
|
protected int index;
|
||
|
protected ArgumentInfo arginfo;
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ================== Properties
|
||
|
|
||
|
public int Index { get { return index; } }
|
||
|
|
||
|
public virtual bool IsBrowseable { get { return false; } }
|
||
|
public virtual bool IsEnumerable { get { return false; } }
|
||
|
public virtual bool IsCustomType { get { return false; } }
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ================== Constructor
|
||
|
|
||
|
// Constructor
|
||
|
public TypeHandler()
|
||
|
{
|
||
|
// Get my attributes
|
||
|
object[] attrs = this.GetType().GetCustomAttributes(typeof(TypeHandlerAttribute), false);
|
||
|
TypeHandlerAttribute attr = (attrs[0] as TypeHandlerAttribute);
|
||
|
|
||
|
// Initialize
|
||
|
this.index = attr.Index;
|
||
|
}
|
||
|
|
||
|
// This sets up the handler for arguments
|
||
|
public virtual void SetupArgument(ArgumentInfo arginfo)
|
||
|
{
|
||
|
// Setup
|
||
|
this.arginfo = arginfo;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ================== Methods
|
||
|
|
||
|
// This must set the value
|
||
|
// How the value is actually validated and stored is up to the implementation
|
||
|
public abstract void SetValue(object value);
|
||
|
|
||
|
// This must return the value as integer (for arguments)
|
||
|
public virtual int GetIntValue()
|
||
|
{
|
||
|
throw new NotSupportedException("Override this method to support it as integer for arguments");
|
||
|
}
|
||
|
|
||
|
// This must return the value as a string for displaying
|
||
|
public abstract string GetStringValue();
|
||
|
|
||
|
// This is called when the user presses the browse button
|
||
|
public virtual object Browse(IWin32Window parent)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
// This must returns an enum list when IsEnumerable is true
|
||
|
// When the user chooses an enum from this list, it will be
|
||
|
// set using SetValue with the EnumItem as value.
|
||
|
public virtual EnumList GetEnumList()
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
// String representation
|
||
|
public override string ToString()
|
||
|
{
|
||
|
return this.GetStringValue();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|