コード例 #1
0
        private void duplicateLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Ogmo.Project == null)
            {
                return;
            }

            Ogmo.AddLevel(new Level(Ogmo.Levels[getTargetLevel()]));
        }
コード例 #2
0
        private void openLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Ogmo.Project == null)
            {
                return;
            }

            Ogmo.OpenLevel();
        }
コード例 #3
0
        private void closeLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Ogmo.Project == null)
            {
                return;
            }

            Ogmo.CloseLevel(Ogmo.Levels[getTargetLevel()], true);
        }
コード例 #4
0
        static public bool CloseLevelByFilepath(string filepath)
        {
            Level level = GetLevelByFilepath(filepath);

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

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

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

            //If the only open level is an empty one, close it
            if (Ogmo.Levels.Count == 1 && Ogmo.Levels[0].IsEmpty)
            {
                Ogmo.CloseLevel(Ogmo.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 < Ogmo.Levels.Count; i++)
                {
                    if (Ogmo.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]);
            }
            Ogmo.MainWindow.StatusText = "Opened level(s) " + String.Join(", ", files);
        }
コード例 #14
0
 private void JSONProjectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Ogmo.NewProject(Ogmo.ProjectType.JSON);
 }