using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
#if WINDOWS
/// Namespace that contains shared types related to the XNACC (CommandConsole) component
namespace XNACC.BaseTypes
{
#region IConsoleKeyboard
/// Basic keyboard/input functionality required by the CommandConsole(Base) class
public interface IConsoleKeyboard
{
/// The current state of the keyboard as of the last Update
KeyboardState CurrentKeyboardState
{
get;
}
/// Collection of keys that are newly pressed (i.e. not held) as of the last Update
IList NewlyPressedKeys
{
get;
}
/// Collection of keys that are being held fown (i.e. not newly pressed) as of the last Update
IList HeldKeys
{
get;
}
}
#endregion
#region CVar Object
// JRT: OK - Why Is This In Its Own File? Because Of The Way The Type System Works In .NET. If You Create
// JRT: Two Completely Identical Types, But Put Them In Different Assemblies, They Are Considered To Be
// JRT: Two Completely DIFFERENT Types, Even Though They Are Compatible With One Another. By Putting
// JRT: The CVar Class Into A Separate Assembly, Both The CommandConsole And External Functions
// JRT: Reference The Same Type, Allowing Us To Pass CVars Back And Forth.
/// Object that wraps the functionality of a console variable -- defined separately because external functions will receive CVar instances
public class CVar
{
/// The storage for the Name property
protected string m_name = String.Empty;
/// The storage for the Value property
protected object m_value = null;
/// The string name for this console variable
public string Name
{
get
{
return (m_name);
}
protected set
{
if (String.IsNullOrWhiteSpace(value))
{
throw new ArgumentNullException("The name for a console variable cannot be null, empty, or whitespace");
}
m_name = value;
}
}
/// The actual value for this console variable, as an object, or null
public object Value
{
get
{
return( m_value );
}
set
{
// Set Value. Set Type To Type.Missing If Value Is null
m_value = value;
if (value == null)
{
ValueType = (Type)Type.Missing;
}
else
{
ValueType = value.GetType();
}
}
}
/// The actual type of the contained variable, or Type.Missing for null values
public Type ValueType
{
get;
protected set;
}
/// Construct a console variable with a default value of null
/// The name for ths console variable
public CVar(string name )
: this( name, null )
{
return;
}
/// Construct a console variable with the specified name and value
/// The name for ths console variable
/// The value for this console variable
public CVar(string name, object value)
{
Name = name;
Value = value;
return;
}
/// Get a string representation of the object (not round-trippable!)
/// A string representation of this CVar
public override string ToString()
{
return( String.Format( "{0} ({1}) = {2}", Name,
ValueType.ToString(),
Value.ToString() ) );
}
/// Hash code function - needed for the dictionary
/// The hash value of the Name of the cvar
override public int GetHashCode()
{
return(Name.GetHashCode() );
}
}
#endregion
}
#endif