//---------------------------------------------------------------------------------------------------------------------------------------------------
//
// Copyright (C)2007 DarkWynter Studios. All rights reserved.
//
//---------------------------------------------------------------------------------------------------------------------------------------------------
// {Contact : darkwynter.com for licensing information
//---------------------------------------------------------------------------------------------------------------------------------------------------
namespace DarkWynter.Engine.Controllers
{
#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using System.Diagnostics;
//using DarkWynter.Stream;
//using DarkWynter.Engine.ObjectLib;
//using DarkWynter.Engine.Menus;
//using Globals;
#endregion
///
/// Mouse event class for mapping a Mouse button/motion to an event
///
public class MouseControl
{
// Time delay between key presses to avoid double input
private int KEY_TIMER_MAX_MILLI = 10;
private Stopwatch controlTimer = new Stopwatch();
private float MOUSE_ROTATION_SCALE = 0.005f;
private float lastMouseX, lastMouseY;
private int windowHeight, windowWidth; // Game window Height and Width for resetting the Mouse position
private int lastMouseWheelPos = 0; // Position of mouse wheel on element list
///
/// On click delegate type
///
/// Controller boolean event arguments
public delegate void OnClickHandler(ControllerBoolEventArgs args);
private event OnClickHandler click;
///
/// Off click delegate type
///
/// Controller boolean event arguments
public delegate void OnReleaseHandler(ControllerBoolEventArgs args);
private event OnReleaseHandler offClick;
///
/// On motion delegate type
///
/// Controller vector2 event arguments
public delegate void OnMotionHandler(ControllerVec2EventArgs args);
private event OnMotionHandler motion;
///
/// On scroll delegate type
///
/// Controller integer event arguments
public delegate void OnScrollHandler(ControllerIntEventArgs args);
private event OnScrollHandler scroll;
///
/// Type of control for this event
///
public ControlType controlType;
///
/// Click constructor
///
/// Click control type
/// Click handler
/// Time delay between multiple invocations
public MouseControl(ControlType type, OnClickHandler onClickHandler, int timerValue)
{
controlType = type;
click += new OnClickHandler(onClickHandler);
controlTimer.Start();
KEY_TIMER_MAX_MILLI = timerValue;
}
///
/// Off Click constructor
///
/// Off Click control type
/// On Release handler
/// Time delay between multiple invocations
public MouseControl(ControlType type, OnReleaseHandler onReleaseHandler, int timerValue, int x)
{
controlType = type;
offClick += new OnReleaseHandler(onReleaseHandler);
controlTimer.Start();
KEY_TIMER_MAX_MILLI = timerValue;
x = 0;
}
///
/// Motion constructor
///
/// Motion control type
/// Motion handler
/// Time delay between multiple invocations
public MouseControl(ControlType type, OnMotionHandler onMotionHandler, int timerValue)
{
controlType = type;
motion += new OnMotionHandler(onMotionHandler);
controlTimer.Start();
KEY_TIMER_MAX_MILLI = timerValue;
lastMouseX = Mouse.GetState().X;
lastMouseY = Mouse.GetState().Y;
}
///
/// Scroll constructor
///
/// Scroll control type
/// Scroll handler
/// Time delay between multiple invocations
public MouseControl(ControlType type, OnScrollHandler onScrollHandler, int timerValue)
{
controlType = type;
scroll += new OnScrollHandler(onScrollHandler);
controlTimer.Start();
KEY_TIMER_MAX_MILLI = timerValue;
lastMouseWheelPos = Mouse.GetState().ScrollWheelValue;
}
///
/// Update Method
///
/// Updated mouse state
/// Object Library
/// Menu System
public void Update(MouseState mouseState, ref List