using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Global
{
    public class ProjectManager
    {
        // Our active project
        private static Project project;

        // Temp shit fuck
        public static bool WasCreated;
        public static string Alias;

        // Project reload handler
        public delegate void ReloadProject_Handler(Project project);
        public static event ReloadProject_Handler ReloadProject; 

        public static Project CreateProject(string Directory, string Name, string Engine, string MapImage)
        {
            // Check no other projects are opened
            if (project != null)
            {
                // Save
                if (MessageBox.Show("Would you like to save changes to " + project.Name + "?", "Save project", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    project.Save();
                }
            }

            // Create the project
            project = Project.Create(Directory, Name, Engine, MapImage);

            // return
            return project;
        }

        public static Project OpenProject(string FileName)
        {
            // Check no other projects are opened
            if (project != null)
            {
                // Save
                if (MessageBox.Show("Would you like to save changes to " + project.Name + "?", "Save project", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    project.Save();
                }
            }

            // Open project
            project = new Project(FileName);

            // return
            return project;
        }

        public static Project GetOpenedProject()
        {
            return project;
        }
    }
}
