﻿using System.Drawing;
using System;
using Forefight.Drawing;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;

namespace Forefight
{
	//This class is as you might have guessed for the Main Menu
	//When the game starts the Main Menu is loaded
	//For now it just has a single button with "PLAY" 
	//Click the button to start playing
	public class MainMenu
	{
		GameView view;
		int xPos = 240; // x-coord top left corner of button
		int yPos = 280; // y-coord top left corner of button
		int s = 30; // How big the button is

		public MainMenu (GameView view) {
			this.view = view;
		}

		public void draw () {
			int x = xPos + 3 * (int) Math.Pow(s, 0.5);
			int y = yPos + 3 * (int) Math.Pow(s, 0.5);
			Shapes.DrawRectangle (xPos, yPos, xPos + 5 * (float) Math.Pow(s, 0.5) + 18 * s, yPos + 5 * (float) Math.Pow(s, 0.5) + 4 * s, Color.AliceBlue); // Draws box around button

			// SUPER LAME TEXT DRAWN BY INDIVIDUALLY DRAWING THE LINES
			GL.Color3 (Color.DarkTurquoise);
			GL.LineWidth (2);
			GL.Begin (PrimitiveType.Lines);

			GL.Vertex2 (x, y); GL.Vertex2 (x + 3 * s, y); // P
			GL.Vertex2 (x, y); GL.Vertex2 (x, y + 4 * s);
			GL.Vertex2 (x + 3 * s, y); GL.Vertex2 (x + 3 * s, y + 2 * s);
			GL.Vertex2 (x, y + 2 * s); GL.Vertex2 (x + 3 * s, y + 2 * s);

			GL.Vertex2 (x + 5 * s, y); GL.Vertex2 (x + 5 * s, y + 4 * s); // L
			GL.Vertex2 (x + 5* s, y + 4 * s); GL.Vertex2 (x + 7 * s, y + 4 * s);

			GL.Vertex2 (x + 10 * s, y); GL.Vertex2 (x + 10 * s, y + 4 * s); // A
			GL.Vertex2 (x + 10 * s, y); GL.Vertex2 (x + 13 * s, y);
			GL.Vertex2 (x + 13 * s, y); GL.Vertex2 (x + 13 * s, y + 4 * s);
			GL.Vertex2 (x + 10 * s, y + 2 * s); GL.Vertex2 (x + 13 * s, y + 2 * s);

			GL.Vertex2 (x + 15 * s, y); GL.Vertex2 (x + 15 * s, y + 2 * s); // Y
			GL.Vertex2 (x + 15 * s, y + 2 * s); GL.Vertex2 (x + 18 * s, y + 2 * s);
			GL.Vertex2 (x + 18 * s, y); GL.Vertex2 (x + 18 * s, y + 4 * s);
			GL.Vertex2 (x + 15 * s, y + 4 * s); GL.Vertex2 (x + 18 * s, y + 4 * s);

			GL.End ();

		}

		public void update () {
			// Checks whether mouse is clicking on button
			int x = view.Mouse.X;
			int y = view.Mouse.Y;
			MouseState mouse = OpenTK.Input.Mouse.GetState();
			if (x > xPos && x < xPos + 5 * (float) Math.Pow(s, 0.5) + 18 * s && y > yPos && y < yPos + 5 * (float) Math.Pow(s, 0.5) + 4 * s && mouse[MouseButton.Left]) {
				view.whatScreen = "Game";
			}
		}


	}
}

