Esempio n. 1
0
        static public void FinishProjectEdit(FinishProjectEditAction action = FinishProjectEditAction.None)
        {
            //Re-activate the main window
            MainWindow.EnableEditing();

            if (action == FinishProjectEditAction.CloseProject)
            {
                CloseProject();
            }
            else if (action == FinishProjectEditAction.SaveProject)
            {
                //Close all the levels
                CloseAllLevels();

                //Save the project
                Project.Save();
                Project.LoadContent();

                //Call the event
                if (OnProjectEdited != null)
                {
                    OnProjectEdited(Project);
                }

                //Start a blank level
                NewLevel();

                //Set the layer
                Ogmo.LayersWindow.SetLayer(0);

                //Set the status message
                Ogmo.MainWindow.StatusText = "Edited project " + Ogmo.Project.Name + ", all levels closed";
                UpdateRecentProjects(Project);
                GC.Collect();
            }
            else if (action == FinishProjectEditAction.LoadAndSaveProject)
            {
                //Start the project and save it
                StartProject(Project);
                Project.Save();

                //Start a blank level and start at the first layer
                LayersWindow.SetLayer(0);
                NewLevel();

                Ogmo.MainWindow.StatusText = "Opened project " + Ogmo.Project.Name;
                UpdateRecentProjects(Project);
                GC.Collect();
            }
        }
Esempio n. 2
0
        static public void FinishProjectEdit(FinishProjectEditAction action = FinishProjectEditAction.None)
        {
            //Re-activate the main window
            MainWindow.EnableEditing();

            if (action == FinishProjectEditAction.CloseProject)
            {
                CloseProject();
            }
            else if (action == FinishProjectEditAction.SaveProject)
            {
                // Get a list of the filepaths to each open level
                List <string> levelPaths = new List <string>();
                foreach (Level level in Levels)
                {
                    levelPaths.Add(level.SavePath);
                }
                int tempIndex = CurrentLevelIndex;

                //Close all the levels
                CloseAllLevels();

                //Save the project
                Project.Save();
                Project.LoadContent();

                //Call the event
                if (OnProjectEdited != null)
                {
                    OnProjectEdited(Project);
                }

                //Set the layer
                LayersWindow.SetLayer(0);

                // Open the default level (or previously-opened levels)
                if (levelPaths.Count == 0)
                {
                    NewLevel();
                }
                else
                {
                    OpenLevelsFromList(levelPaths, false, tempIndex);
                }

                //Set the status message
                MainWindow.StatusText = "Edited project " + Project.Name + ", all levels re-opened";
                UpdateRecentProjects(Project);
                GC.Collect();
            }
            else if (action == FinishProjectEditAction.LoadAndSaveProject)
            {
                //Start the project and save it
                StartProject(Project);
                Project.Save();

                //Start a blank level and start at the first layer
                LayersWindow.SetLayer(0);
                NewLevel();

                MainWindow.StatusText = "Opened project " + Project.Name;
                UpdateRecentProjects(Project);
                GC.Collect();
            }
        }