Esempio n. 1
0
    private bool CheckStageOrScene(string stagePath)
    {
        string directoryPath = Path.GetDirectoryName(stagePath);
        string directoryName = Path.GetFileName(directoryPath);

        if (directoryName != "Stages")
        {
            string stageName = Path.GetFileName(stagePath);
            reasonForFailedCheck = String.Format("Check failed because \"{0}\" does not reside in the Stages directory", stageName);
            return(false);
        }

        FileInfo[] stages = new DirectoryInfo(directoryPath).GetFiles("*", SearchOption.TopDirectoryOnly);

        if (stages.Length > 2)
        {
            reasonForFailedCheck = "Check failed because the Stages directory has more than 2 files in it. Only 1 scene and 1 file is allowed";
            return(false);
        }

        bool success = true;

        for (int i = 0; i < stages.Length; i++)
        {
            string stageName = stages[i].Name;

            if (!FindCorrespondingFile(stages, stageName))
            {
                success = false;
                break;
            }
        }

        if (success)
        {
            string extension = Path.GetExtension(stagePath);
            string reason    = String.Empty;

            if (extension == ".stage")
            {
                success = DamnedMaps.CheckInnerStageFile(stagePath, ref reason);
            }

            else if (extension == ".scene")
            {
                success = DamnedMaps.CheckInnerSceneFile(stagePath, ref reason);
            }

            if (!success)
            {
                this.reasonForFailedCheck = reason;
            }
        }

        return(success);
    }
Esempio n. 2
0
        private void SelectStage(bool remove)
        {
            FileDialog dialog = new OpenFileDialog();

            if (remove)
            {
                dialog.InitialDirectory = damnedMaps.stagesAndScenesDirectory;
            }

            dialog.Filter = "Stage Files (*.stage)|*.stage";
            DialogResult result = dialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string stagePath = dialog.FileName;
            string stage     = Path.GetFileName(stagePath);

            if (Path.GetExtension(stage) != ".stage")
            {
                MessageBox.Show("You did not pick a stage file. Please select one that is a .stage file", "Please select a different file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (stage.Contains("menu_background"))
            {
                MessageBox.Show("Either you picked the stage that is for the main menu or you decided to name your stage along the lines of \"menu_background\". Either pick a different one or rename your stage.", "Pick a different stage", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (remove)
            {
                if (Path.GetFileName(Path.GetDirectoryName(stagePath)) != "Stages")
                {
                    MessageBox.Show("It seems that the stage that you have selected does not reside inside the Damned directory. Please select a different stage", "Please select a different file", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                damnedRemoveStage.stagePath = stagePath;
                string newLabelText = Path.GetFileNameWithoutExtension(stage).Replace("_", " ");
                labelMapToRemove.Text             = newLabelText;
                labelMapToRemove.ForeColor        = Color.FromArgb(255, 168, 38);
                buttonSelectSceneToRemove.Enabled = true;
                changesMade = true;
            }

            else
            {
                if (damnedMaps.StageExists(stage))
                {
                    MessageBox.Show("This stage is already installed in the game. Please pick another.", "Stage Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                string reason = String.Empty;

                if (!DamnedMaps.CheckInnerStageFile(stagePath, ref reason))
                {
                    MessageBox.Show(String.Format("{0} Please select a different stage file.", reason), "Failed to check the stage", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                if (damnedNewStage.newStagePath == String.Empty)
                {
                    damnedNewStage.count++;
                }

                damnedNewStage.newStagePath = stagePath;
                string newLabelText = stage.Replace("_", " ").Remove(stage.IndexOf("."), 6);
                labelMapToAdd.Text            = newLabelText;
                labelMapToAdd.ForeColor       = Color.FromArgb(255, 168, 38);
                buttonSelectSceneFile.Enabled = true;
                changesMade = true;
            }
        }