using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using ShootingHero.Scene;
#if ANDROID || IOS
using Microsoft.Xna.Framework.Input.Touch;
#endif

namespace ShootingHero.Components.Menu
{
	public class HelpWindow : DrawableGameComponent
	{
		MenuScene menuScene;

		Texture2D texture;
		bool windowShowState = false;

		public bool WindowShowState { get { return windowShowState; } set { windowShowState = value; } }

		public HelpWindow ( Game game, MenuScene menuScene )
			: base ( game )
		{
			this.menuScene = menuScene;
		}

		protected override void LoadContent ()
		{
			texture = Game.Content.Load<Texture2D> ( "Menu/help_fan" );
			base.LoadContent ();
		}

		public override void Update ( GameTime gameTime )
		{
			MouseState mouse = Mouse.GetState ();
			GamePadState gamePad = GamePad.GetState ( PlayerIndex.One );

			if (
#if ANDROID || IOS
				TouchPanel.GetState().Count > 0
#else
				mouse.LeftButton == ButtonState.Pressed
#endif
				|| gamePad.Buttons.Back == ButtonState.Pressed )
			{
				if ( menuScene.isStateReleased )
				{
					menuScene.isStateReleased = false;
					WindowShowState = false;
				}
			}
			else
				menuScene.isStateReleased = true;

			base.Update ( gameTime );
		}

		public override void Draw ( GameTime gameTime )
		{
			SpriteBatch spriteBatch = ( Game as ShootingHero ).SpriteBatch;
			spriteBatch.Draw ( texture, new Vector2 ( 480 / 2 - texture.Width / 2, 800 / 2 - texture.Height / 2 ), Color.White );

			base.Draw ( gameTime );
		}
	}
}
