private void duplicateLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Orison.Project == null)
            {
                return;
            }

            Orison.AddLevel(new Level(Orison.Levels[getTargetLevel()]));
        }
        private void openLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Orison.Project == null)
            {
                return;
            }

            Orison.OpenLevel();
        }
        private void closeLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Orison.Project == null)
            {
                return;
            }

            Orison.CloseLevel(Orison.Levels[getTargetLevel()], true);
        }
        static public bool CloseLevelByFilepath(string filepath)
        {
            Level level = GetLevelByFilepath(filepath);

            if (level != null)
            {
                return(Orison.CloseLevel(level, true));
            }
            return(true);
        }
 static public bool CloseLevelsByFilepaths(IEnumerable <string> filepaths)
 {
     foreach (var f in filepaths)
     {
         Level level = Orison.GetLevelByFilepath(f);
         if (level != null)
         {
             if (!Orison.CloseLevel(level, true))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        private void MainWindow_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

            if (Orison.Project == null)
            {
                if (files.Length == 1 && Path.GetExtension(files[0]) == ".oep")
                {
                    Orison.LoadProject(files[0]);
                }
            }
            else
            {
                foreach (string file in files)
                {
                    Orison.AddLevel(new Level(Orison.Project, file));
                }
            }
        }
 private void closeOtherLevelsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Orison.CloseOtherLevels(Orison.Levels[getTargetLevel()]);
 }
 private void openProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Orison.LoadProject();
 }
 private void editProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Orison.EditProject(Orison.ProjectEditMode.NormalEdit);
 }
 private void closeProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Orison.CloseProject();
 }
 private void MasterTabControl_Selecting(object sender, TabControlCancelEventArgs e)
 {
     Orison.SetLevel(e.TabPageIndex);
 }
Beispiel #12
0
        static public void OpenLevel()
        {
            //Get the file to load from the user
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect      = true;
            dialog.Filter           = Orison.LEVEL_FILTER;
            dialog.InitialDirectory = Orison.Project.SavedDirectory;
            if (dialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            //If the only open level is an empty one, close it
            if (Orison.Levels.Count == 1 && Orison.Levels[0].IsEmpty)
            {
                Orison.CloseLevel(Orison.Levels[0], false);
            }

            //Get all the selected files, and alphabetize the list
            List <string> filenames = new List <string>(dialog.FileNames);

            if (filenames.All((s) => { int i; return(int.TryParse(Path.GetFileNameWithoutExtension(s), out i)); }))
            {
                filenames.Sort((a, b) => { return(Convert.ToInt32(Path.GetFileNameWithoutExtension(a)) - Convert.ToInt32(Path.GetFileNameWithoutExtension(b))); });
            }
            else
            {
                filenames.Sort();
            }

            //Load all the levels in the selected list, as long as they aren't already open
            foreach (string f in filenames)
            {
                int levelID = -1;
                for (int i = 0; i < Orison.Levels.Count; i++)
                {
                    if (Orison.Levels[i].SavePath == f)
                    {
                        levelID = i;
                        break;
                    }
                }

                if (levelID == -1)
                {
                    Level level = new Level(Project, f);

                    //If it's salvaged...
                    if (level.Salvaged)
                    {
                        DialogResult result = MessageBox.Show("The selected level is inconsistent with the current project and has been automatically modified to make it loadable. Would you like to save this modified version under a different name before continuing?",
                                                              "Salvaged Level", MessageBoxButtons.YesNoCancel);

                        switch (result)
                        {
                        case DialogResult.Yes:
                            level.SaveAs();
                            break;

                        case DialogResult.Cancel:
                            continue;
                        }
                    }

                    //Init the level editor
                    AddLevel(level);
                    SetLevel(Levels.Count - 1);
                }
                else
                {
                    SetLevel(levelID);
                }
            }

            //Set the status message
            string[] files = new string[dialog.FileNames.Length];
            for (int i = 0; i < dialog.FileNames.Length; i++)
            {
                files[i] = Path.GetFileName(dialog.FileNames[i]);
            }
            Orison.MainWindow.StatusText = "Opened level(s) " + String.Join(", ", files);
        }