2012-03-19 23:57:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Axios.Engine.Interfaces;
|
|
|
|
|
using Axios.Engine.Log;
|
2012-03-24 04:54:58 +00:00
|
|
|
|
using Axios.Engine.Structures;
|
2012-03-24 23:06:51 +00:00
|
|
|
|
using Axios.Engine.UI;
|
|
|
|
|
using FarseerPhysics.Dynamics;
|
|
|
|
|
using FarseerPhysics.SamplesFramework;
|
|
|
|
|
using Microsoft.Xna.Framework;
|
2012-04-13 03:09:49 +00:00
|
|
|
|
using Microsoft.Xna.Framework.Content;
|
2012-03-24 23:06:51 +00:00
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2012-04-13 03:09:49 +00:00
|
|
|
|
using GameStateManagement;
|
2013-01-02 23:45:08 +00:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
2012-05-13 03:02:23 +00:00
|
|
|
|
using Axios.Engine.Gleed2D;
|
2013-01-02 23:45:08 +00:00
|
|
|
|
using Axios.Engine.Extensions;
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
|
|
|
|
namespace Axios.Engine
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public abstract class AxiosGameScreen : PhysicsGameScreen
|
|
|
|
|
{
|
|
|
|
|
private List<AxiosGameObject> _gameObjects;
|
2012-03-20 01:33:25 +00:00
|
|
|
|
private List<AxiosGameObject> _objectstoremove = new List<AxiosGameObject>();
|
2012-03-19 23:57:59 +00:00
|
|
|
|
private AxiosGameObject prevobj;
|
|
|
|
|
private AxiosGameObject prevfocusobj;
|
|
|
|
|
|
|
|
|
|
#region DebugTextVariables
|
|
|
|
|
#if DEBUG
|
|
|
|
|
public SpriteFont DebugSpriteFont;
|
|
|
|
|
public String DebugTextFont = "Fonts/helptext";
|
|
|
|
|
public Color DebugTextColor = Color.Red;
|
|
|
|
|
#endif
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private List<AxiosTimer> _timers;
|
|
|
|
|
private List<AxiosUIObject> _uiobjects;
|
|
|
|
|
|
|
|
|
|
private AxiosUIObject prevuiobj;
|
|
|
|
|
private AxiosUIObject prevuifocusobj;
|
|
|
|
|
|
2012-05-13 03:02:23 +00:00
|
|
|
|
protected Level Level;
|
|
|
|
|
|
|
|
|
|
private Camera camera;
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#if WINDOWS
|
2012-05-26 23:57:16 +00:00
|
|
|
|
AxiosCommandConsole _console = null;
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#endif
|
2012-05-27 03:53:55 +00:00
|
|
|
|
protected bool AllowKeyboardWhileConsoleIsActive = false;
|
|
|
|
|
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#if WINDOWS
|
2012-05-27 03:53:55 +00:00
|
|
|
|
public AxiosCommandConsole Console
|
|
|
|
|
{
|
|
|
|
|
get { return _console; }
|
|
|
|
|
private set { _console = value; }
|
|
|
|
|
}
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#endif
|
2012-05-27 03:53:55 +00:00
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
public AxiosGameScreen()
|
|
|
|
|
: base()
|
|
|
|
|
{
|
|
|
|
|
this._gameObjects = new List<AxiosGameObject>();
|
|
|
|
|
_timers = new List<AxiosTimer>();
|
|
|
|
|
prevobj = null;
|
|
|
|
|
prevfocusobj = null;
|
|
|
|
|
this._uiobjects = new List<AxiosUIObject>();
|
|
|
|
|
prevuiobj = null;
|
|
|
|
|
prevuifocusobj = null;
|
2012-05-13 03:02:23 +00:00
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-01-02 23:45:08 +00:00
|
|
|
|
public Vector2 MouseAimVector(MouseState ms, Vector2 relativeposition)
|
|
|
|
|
{
|
|
|
|
|
Vector2 ret;
|
|
|
|
|
ret = this.Camera.ConvertScreenToWorld(ms.Position()) - relativeposition;
|
|
|
|
|
ret.Normalize();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
/*public void AddGameObject<T>(T gameobject)
|
|
|
|
|
{
|
|
|
|
|
if (gameobject is AxiosGameObject || gameobject is AxiosUIObject)
|
|
|
|
|
gameobject.LoadContent(this);
|
|
|
|
|
|
|
|
|
|
if (gameobject is AxiosGameObject || gameobject is AxiosUIObject)
|
|
|
|
|
gameobject.RemoveObject += new AxiosGameObject.RemoveAxiosGameObjectHandler(RemoveGameObject);
|
|
|
|
|
|
|
|
|
|
if (gameobject is AxiosGameObject)
|
|
|
|
|
{
|
|
|
|
|
this._gameObjects.Add(gameobject);
|
|
|
|
|
}
|
|
|
|
|
else if (gameobject is AxiosUIObject)
|
|
|
|
|
{
|
|
|
|
|
this._uiobjects.Add(gameobject);
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
/*public void AddGameObject(AxiosGameObject gameobject)
|
|
|
|
|
{
|
|
|
|
|
gameobject.LoadContent(this);
|
|
|
|
|
gameobject.RemoveObject += new AxiosGameObject.AxiosGameObjectHandler(RemoveGameObject);
|
|
|
|
|
this._gameObjects.Add(gameobject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddGameObject(AxiosTimer timer)
|
|
|
|
|
{
|
|
|
|
|
timer.LoadContent(this);
|
|
|
|
|
_timers.Add(timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void AddGameObject(AxiosUIObject uiobject)
|
|
|
|
|
{
|
|
|
|
|
uiobject.LoadContent(this);
|
|
|
|
|
uiobject.RemoveObject += new AxiosEvents.AxiosGameObjectHandler(RemoveGameObject);
|
|
|
|
|
_uiobjects.Add(uiobject);
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
public void AddGameObject(object obj)
|
|
|
|
|
{
|
2012-05-28 22:01:03 +00:00
|
|
|
|
|
|
|
|
|
#if WINDOWS
|
2012-05-26 23:57:16 +00:00
|
|
|
|
if (obj is AxiosCommandConsole)
|
|
|
|
|
{
|
|
|
|
|
if (_console != null)
|
|
|
|
|
{
|
|
|
|
|
//remove the current one first
|
2012-05-28 22:01:03 +00:00
|
|
|
|
|
2012-05-26 23:57:16 +00:00
|
|
|
|
ScreenManager.Game.Components.Remove(_console);
|
|
|
|
|
_console.Dispose();
|
|
|
|
|
_console = null;
|
|
|
|
|
}
|
|
|
|
|
_console = (AxiosCommandConsole)obj;
|
|
|
|
|
ScreenManager.Game.Components.Add(_console);
|
2012-05-27 03:53:55 +00:00
|
|
|
|
_console.LoadContent(ScreenManager.Game.Content);
|
2012-05-27 00:08:33 +00:00
|
|
|
|
}
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#endif
|
2012-03-19 23:57:59 +00:00
|
|
|
|
if (obj is AxiosGameObject || obj is AxiosUIObject || obj is AxiosTimer)
|
|
|
|
|
{
|
|
|
|
|
AxiosGameObject tmp = obj as AxiosGameObject;
|
|
|
|
|
if (obj is AxiosGameObject || obj is AxiosUIObject)
|
|
|
|
|
tmp.RemoveObject += new AxiosEvents.AxiosGameObjectHandler(RemoveGameObject);
|
2012-03-20 01:33:25 +00:00
|
|
|
|
|
|
|
|
|
tmp.LoadContent(this);
|
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
if (obj is AxiosGameObject && !(obj is AxiosUIObject))
|
|
|
|
|
{
|
|
|
|
|
_gameObjects.Add(tmp);
|
|
|
|
|
}
|
|
|
|
|
else if (obj is AxiosUIObject)
|
|
|
|
|
{
|
|
|
|
|
_uiobjects.Add(obj as AxiosUIObject);
|
|
|
|
|
}
|
|
|
|
|
else if (obj is AxiosTimer)
|
|
|
|
|
{
|
|
|
|
|
_timers.Add(obj as AxiosTimer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveGameObject(AxiosTimer timer)
|
|
|
|
|
{
|
|
|
|
|
_timers.Remove(timer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveGameObject(AxiosUIObject uiobject)
|
|
|
|
|
{
|
|
|
|
|
uiobject.RemoveObject -= new AxiosGameObject.AxiosGameObjectHandler(RemoveGameObject);
|
|
|
|
|
uiobject.UnloadContent(this);
|
|
|
|
|
_uiobjects.Remove(uiobject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveGameObject(AxiosGameObject gameobject)
|
|
|
|
|
{
|
2012-03-20 01:33:25 +00:00
|
|
|
|
if (this._gameObjects.Contains(gameobject))
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
2012-03-20 01:33:25 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
gameobject.UnloadContent(this);
|
|
|
|
|
this._gameObjects.Remove(gameobject);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
2012-03-20 01:33:25 +00:00
|
|
|
|
else
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
2012-05-19 02:29:00 +00:00
|
|
|
|
AxiosLog.Instance.AddLine("[Axios Engine] - Adding objects too fast...remove " + gameobject.Name + " later", LoggingFlag.DEBUG);
|
2012-03-20 01:33:25 +00:00
|
|
|
|
this._objectstoremove.Add(gameobject);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RemoveAll()
|
|
|
|
|
{
|
2012-05-19 02:29:00 +00:00
|
|
|
|
AxiosLog.Instance.AddLine("[Axios Engine] - Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
foreach (AxiosGameObject g in _gameObjects)
|
|
|
|
|
g.UnloadContent(this);
|
|
|
|
|
foreach (AxiosUIObject ui in _uiobjects)
|
|
|
|
|
ui.UnloadContent(this);
|
|
|
|
|
this.World.Clear();
|
|
|
|
|
this._gameObjects.Clear();
|
|
|
|
|
_timers.Clear();
|
|
|
|
|
_uiobjects.Clear();
|
2012-05-19 02:29:00 +00:00
|
|
|
|
AxiosLog.Instance.AddLine("[Axios Engine] - Memory usage after cleanup: ", LoggingFlag.DEBUG);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-04-13 03:09:49 +00:00
|
|
|
|
public override void Activate(bool instancePreserved)
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
2012-04-13 03:09:49 +00:00
|
|
|
|
base.Activate(instancePreserved);
|
2012-05-13 03:02:23 +00:00
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
if (!Axios.Settings.ScreenSaver)
|
2012-04-13 03:09:49 +00:00
|
|
|
|
{
|
|
|
|
|
ContentManager man = new ContentManager(ScreenManager.Game.Services, "Content");
|
|
|
|
|
this.DebugSpriteFont = man.Load<SpriteFont>(this.DebugTextFont);
|
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
#endif
|
2012-05-13 03:02:23 +00:00
|
|
|
|
camera = new Camera(ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
|
2012-06-03 21:58:30 +00:00
|
|
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
|
EnableCameraControl = true;
|
|
|
|
|
#else
|
|
|
|
|
EnableCameraControl = false;
|
|
|
|
|
#endif
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Draw(GameTime gameTime)
|
|
|
|
|
{
|
|
|
|
|
|
2012-09-22 19:19:45 +00:00
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
2012-05-13 03:02:23 +00:00
|
|
|
|
if (Level != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (Layer layer in Level.Layers)
|
|
|
|
|
{
|
|
|
|
|
Vector2 oldcameraposition = camera.Position;
|
|
|
|
|
camera.Position *= layer.ScrollSpeed;
|
2012-05-14 03:20:50 +00:00
|
|
|
|
|
|
|
|
|
ScreenManager.SpriteBatch.Begin(0, null, null, null, null, null, Camera.View);
|
2012-05-13 03:02:23 +00:00
|
|
|
|
layer.draw(ScreenManager.SpriteBatch);
|
|
|
|
|
ScreenManager.SpriteBatch.End();
|
|
|
|
|
|
|
|
|
|
camera.Position = oldcameraposition;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
foreach (AxiosGameObject g in (from x in (from i in _gameObjects where i is IDrawableAxiosGameObject select (IDrawableAxiosGameObject)i) orderby x.DrawOrder select x))
|
|
|
|
|
((IDrawableAxiosGameObject)g).Draw(this, gameTime);
|
|
|
|
|
|
|
|
|
|
foreach(AxiosUIObject g in (from x in _uiobjects orderby x.DrawOrder select x))
|
|
|
|
|
((IDrawableAxiosGameObject)g).Draw(this, gameTime);
|
2012-05-13 03:02:23 +00:00
|
|
|
|
|
2012-05-14 03:20:50 +00:00
|
|
|
|
base.Draw(gameTime); //This is placed at the end so that Farseer debug information is visible
|
2012-05-13 03:02:23 +00:00
|
|
|
|
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
|
|
|
|
|
{
|
|
|
|
|
base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
2012-05-27 03:53:55 +00:00
|
|
|
|
|
2012-03-20 01:33:25 +00:00
|
|
|
|
if (this._objectstoremove.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<AxiosGameObject> list = this._objectstoremove.ToList<AxiosGameObject>();
|
|
|
|
|
foreach (AxiosGameObject obj in list)
|
|
|
|
|
{
|
|
|
|
|
this.RemoveGameObject(obj);
|
|
|
|
|
this._objectstoremove.Remove(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (AxiosGameObject g in _gameObjects.ToList())
|
2012-03-19 23:57:59 +00:00
|
|
|
|
g.Update(this, gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
|
|
|
|
|
2012-03-20 01:33:25 +00:00
|
|
|
|
foreach (AxiosTimer t in _timers.ToList())
|
2012-03-19 23:57:59 +00:00
|
|
|
|
t.Update(this, gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
|
|
|
|
|
2012-03-20 01:33:25 +00:00
|
|
|
|
foreach(AxiosUIObject g in _uiobjects.ToList())
|
2012-03-19 23:57:59 +00:00
|
|
|
|
g.Update(this, gameTime, otherScreenHasFocus, coveredByOtherScreen);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-16 00:17:34 +00:00
|
|
|
|
public override void HandleCursor(InputState input)
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
|
|
|
|
base.HandleCursor(input);
|
|
|
|
|
HandleMouseEvents(input);
|
|
|
|
|
|
2012-03-20 01:33:25 +00:00
|
|
|
|
foreach (AxiosGameObject g in _gameObjects.ToList())
|
2012-03-19 23:57:59 +00:00
|
|
|
|
g.HandleCursor(this, input);
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-16 00:17:34 +00:00
|
|
|
|
private void HandleMouseEvents(InputState input)
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
|
|
|
|
Vector2 position = this.Camera.ConvertScreenToWorld(input.Cursor);
|
|
|
|
|
Fixture fix = this.World.TestPoint(position);
|
|
|
|
|
AxiosGameObject gobj;
|
|
|
|
|
if (fix != null && fix.UserData != null && fix.UserData is AxiosGameObject)
|
|
|
|
|
{
|
|
|
|
|
gobj = (AxiosGameObject)fix.UserData;
|
|
|
|
|
|
|
|
|
|
if (gobj != null && gobj != prevobj)
|
|
|
|
|
{
|
|
|
|
|
gobj.OnMouseHover(this, input);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (prevobj != gobj && prevobj != null)
|
|
|
|
|
prevobj.OnMouseLeave(this, input);
|
|
|
|
|
}
|
|
|
|
|
else if (gobj != null)
|
|
|
|
|
{
|
|
|
|
|
if (input.IsNewMouseButtonRelease(MouseButtons.LeftButton))
|
|
|
|
|
{
|
|
|
|
|
if (prevobj != null)
|
|
|
|
|
prevobj.OnFocusLeave(this, input);
|
|
|
|
|
gobj.OnFocusEnter(this, input);
|
|
|
|
|
gobj.OnMouseUp(this, input);
|
|
|
|
|
prevfocusobj = gobj;
|
|
|
|
|
//prevobj = gobj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.IsNewMouseButtonPress(MouseButtons.LeftButton))
|
|
|
|
|
gobj.OnMouseDown(this, input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gobj != null)
|
|
|
|
|
prevobj = gobj;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (prevobj != null)
|
|
|
|
|
prevobj.OnMouseLeave(this, input);
|
|
|
|
|
if (input.IsNewMouseButtonPress(MouseButtons.LeftButton) && prevfocusobj != null)
|
|
|
|
|
{
|
|
|
|
|
prevfocusobj.OnFocusLeave(this, input);
|
|
|
|
|
prevfocusobj = null;
|
|
|
|
|
}
|
|
|
|
|
prevobj = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector2 uiobjpos;
|
2012-03-24 04:54:58 +00:00
|
|
|
|
//Rectangle uirect;
|
|
|
|
|
AxiosRectangle uirect;
|
2012-03-19 23:57:59 +00:00
|
|
|
|
bool foundobject = false;
|
2012-03-24 04:54:58 +00:00
|
|
|
|
Vector2 mousepos = this.Camera.ConvertScreenToWorld(input.Cursor);
|
2012-03-24 03:19:58 +00:00
|
|
|
|
//Vector2 objpos;
|
2012-03-19 23:57:59 +00:00
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
2012-03-24 04:54:58 +00:00
|
|
|
|
AxiosRectangle mousrect = new AxiosRectangle(mousepos.X, mousepos.Y, ConvertUnits.ToSimUnits(25), ConvertUnits.ToSimUnits(25));
|
2012-03-19 23:57:59 +00:00
|
|
|
|
foreach(AxiosUIObject uiobject in _uiobjects)
|
|
|
|
|
{
|
|
|
|
|
uiobjpos = uiobject.Position;
|
2012-03-24 03:19:58 +00:00
|
|
|
|
//objpos = this.Camera.ConvertScreenToWorld(uiobjpos);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
2012-06-24 19:56:13 +00:00
|
|
|
|
uirect = new AxiosRectangle(ConvertUnits.ToSimUnits(uiobjpos.X), ConvertUnits.ToSimUnits(uiobjpos.Y), ConvertUnits.ToSimUnits(uiobject.Width), ConvertUnits.ToSimUnits(uiobject.Height));
|
2012-03-24 03:19:58 +00:00
|
|
|
|
|
2012-03-24 04:54:58 +00:00
|
|
|
|
if (uirect.Intersect(mousrect))
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (input.IsNewMouseButtonPress(MouseButtons.LeftButton))
|
|
|
|
|
{
|
|
|
|
|
uiobject.OnMouseDown(this, input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.IsNewMouseButtonRelease(MouseButtons.LeftButton))
|
|
|
|
|
{
|
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
|
|
|
|
if (prevuifocusobj != uiobject)
|
|
|
|
|
{
|
|
|
|
|
uiobject.OnFocusEnter(this, input);
|
|
|
|
|
if (prevuifocusobj != null)
|
|
|
|
|
prevuifocusobj.OnFocusLeave(this, input);
|
|
|
|
|
prevuifocusobj = uiobject;
|
|
|
|
|
}
|
|
|
|
|
uiobject.OnMouseUp(this, input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (prevuiobj != uiobject)
|
|
|
|
|
{
|
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
|
|
|
|
uiobject.OnMouseHover(this, input);
|
|
|
|
|
if (prevuiobj != null)
|
|
|
|
|
prevuiobj.OnMouseLeave(this, input);
|
|
|
|
|
prevuiobj = uiobject;
|
|
|
|
|
}
|
|
|
|
|
foundobject = true;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!foundobject && prevuiobj != null)
|
|
|
|
|
{
|
|
|
|
|
//mouse moved away from object
|
|
|
|
|
prevuiobj.OnMouseLeave(this, input);
|
|
|
|
|
prevuiobj = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (input.IsNewMouseButtonRelease(MouseButtons.LeftButton))
|
|
|
|
|
{
|
|
|
|
|
if (!foundobject && prevuifocusobj != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
prevuifocusobj.OnFocusLeave(this, input);
|
|
|
|
|
prevuifocusobj = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-18 03:21:33 +00:00
|
|
|
|
public override void HandleInput(GameTime gameTime, InputState input)
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#if WINDOWS
|
2012-05-29 21:43:50 +00:00
|
|
|
|
if (_console == null || !AxiosCommandConsole.Active || (AllowKeyboardWhileConsoleIsActive && AxiosCommandConsole.Active))
|
2012-05-28 22:01:03 +00:00
|
|
|
|
#endif
|
2012-05-27 03:53:55 +00:00
|
|
|
|
{
|
|
|
|
|
base.HandleInput(gameTime, input);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
2012-05-27 03:53:55 +00:00
|
|
|
|
foreach (AxiosGameObject g in _gameObjects.ToList())
|
|
|
|
|
g.HandleInput(this, input, gameTime);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
2012-05-27 03:53:55 +00:00
|
|
|
|
foreach (AxiosUIObject g in _uiobjects.ToList())
|
|
|
|
|
g.HandleInput(this, input, gameTime);
|
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-27 03:53:55 +00:00
|
|
|
|
public override void Unload()
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
2012-05-27 03:53:55 +00:00
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
2012-04-18 04:34:46 +00:00
|
|
|
|
base.Deactivate();
|
2012-05-19 02:29:00 +00:00
|
|
|
|
AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
foreach (AxiosGameObject g in _gameObjects)
|
|
|
|
|
g.UnloadContent(this);
|
|
|
|
|
|
|
|
|
|
foreach (AxiosUIObject g in _uiobjects)
|
|
|
|
|
g.UnloadContent(this);
|
|
|
|
|
|
|
|
|
|
this._gameObjects.Clear();
|
|
|
|
|
this._uiobjects.Clear();
|
|
|
|
|
this.World.Clear();
|
|
|
|
|
_timers.Clear();
|
|
|
|
|
_uiobjects.Clear();
|
2012-05-19 02:29:00 +00:00
|
|
|
|
AxiosLog.Instance.AddLine("Memory usage after cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
|
2012-03-19 23:57:59 +00:00
|
|
|
|
//AxiosRegularFile f = new AxiosRegularFile("log.log");
|
|
|
|
|
//f.WriteData(AxiosLog.Instance.GetLog(), FileMode.Append);
|
|
|
|
|
//AxiosIsolatedFile f = new AxiosIsolatedFile("log.log");
|
|
|
|
|
//f.WriteData(AxiosLog.Instance.GetLog(), FileMode.Append);
|
|
|
|
|
//CleanUp();
|
2012-05-27 03:53:55 +00:00
|
|
|
|
#if WINDOWS
|
|
|
|
|
if (_console != null)
|
|
|
|
|
{
|
2012-05-29 21:43:50 +00:00
|
|
|
|
//System.Diagnostics.Debugger.Break();
|
2012-05-27 03:53:55 +00:00
|
|
|
|
ScreenManager.Game.Components.Remove(_console);
|
|
|
|
|
_console.Dispose();
|
2012-05-29 03:31:46 +00:00
|
|
|
|
_console = null;
|
2012-05-27 03:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-19 02:29:00 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This allows you to customize functionality for loading a circle item.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="circleitem"></param>
|
|
|
|
|
/// <returns></returns>
|
2012-05-19 02:31:03 +00:00
|
|
|
|
public virtual bool LoadCircleItem(CircleItem circleitem)
|
2012-05-19 02:15:51 +00:00
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool LoadPathItem(PathItem pathitem)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-19 02:32:22 +00:00
|
|
|
|
public virtual bool LoadRectangleItem(RectangleItem rectangleitem)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-21 03:11:10 +00:00
|
|
|
|
public virtual bool LoadTextureItem(TextureItem textureitem)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|