using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.Window;
namespace TheStillmanProject.Game.Scenes
{
class MainMenu : IScene
{
bool didLoad = false;
Sprite background;
Sprite header;
Sprite play;
Sprite quit;
public void Load()
{
uint width = Game.WIDTH;
uint height = Game.HEIGHT;
string contentDir = Environment.CurrentDirectory + "\\Content\\Main Menu\\";
background = new Sprite(new Texture(contentDir + "background.jpg"));
header = new Sprite(new Texture(contentDir + "stillmanproject.png"));
play = new Sprite(new Texture(contentDir + "playButton.png"));
quit = new Sprite(new Texture(contentDir + "quitbutton.png"));
background.Position = new Vector2f(0, 0);
header.Position = new Vector2f(width / 2 - header.TextureRect.Width / 2, 100);
header.Texture.Smooth = true;
play.Position = new Vector2f(width / 2 - play.TextureRect.Width / 2, 325);
//This code will hide the button. ffs
//play.TextureRect = new IntRect((int) width / 2 - play.TextureRect.Width / 2, 325, play.TextureRect.Height, play.TextureRect.Width);
quit.Position = new Vector2f(width / 2 - play.TextureRect.Width, 425);
//Same thing, the button will be hidden.
//quit.TextureRect = new IntRect((int)width / 2 - quit.TextureRect.Width / 2, 425, quit.TextureRect.Height, quit.TextureRect.Width);
// Smooth out buttons.
play.Texture.Smooth = true;
quit.Texture.Smooth = false;
didLoad = true;
}
public bool DidLoad()
{
return didLoad;
}
public void Draw(RenderWindow window)
{
window.Draw(background);
window.Draw(header);
window.Draw(play);
window.Draw(quit);
}
public void Update(RenderWindow window)
{
if (Mouse.IsButtonPressed(Mouse.Button.Left))
{
//Program.WriteDebug("Mouse was clicked.");
Vector2i mousePosition = Mouse.GetPosition(window);
if (play.TextureRect.Contains(mousePosition.X, mousePosition.Y))
{
//Doesnt show up.
Program.WriteDebug("Play button pressed.");
}
else if (quit.TextureRect.Contains(mousePosition.X, mousePosition.Y))
{
//doesnt show up
Program.WriteDebug("Quit button pressed");
}
}
}
public void Dispose()
{
}
}
}