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 SelectScene(bool remove)
        {
            FileDialog dialog = new OpenFileDialog
            {
                Filter = "Scene Files(*.scene)|*.scene"
            };

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

            DialogResult result = dialog.ShowDialog();

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

            string scenePath = dialog.FileName;
            string sceneName = Path.GetFileName(scenePath);

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

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


            if (remove)
            {
                sceneName = sceneName.Replace("_", " ").Remove(sceneName.IndexOf("."), 6);

                if (sceneName != labelMapToRemove.Text)
                {
                    MessageBox.Show("It looks like you seleted a scene file that does not go with the stage file you selected already. Please pick the right one", "Wrong Scene File", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                for (int i = 0; i < damnedRemoveStagesList.Count; i++)
                {
                    string stageNameInList = Path.GetFileNameWithoutExtension(damnedRemoveStagesList[i].scenePath).Replace("_", " ");
                    string currentStage    = Path.GetFileNameWithoutExtension(scenePath).Replace("_", " ");

                    if (String.Compare(currentStage, stageNameInList, true) == 0)
                    {
                        MessageBox.Show($"The selected stage \"{currentStage}\" has already been selected to be removed from the game. Please select a different stage", "Stage already selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }

                damnedRemoveStage.scenePath = scenePath;
                damnedRemoveStagesList.Add(new DamnedRemoveStage(damnedRemoveStage));
                buttonSelectSceneToRemove.Enabled = false;
                labelSelectSceneFileToRemove.Text = "Choose another scene file to remove with a stage:";
                labelMapToRemove.Text             = "Choose another stage file to remove from the game.";
                labelMapToRemove.ForeColor        = Color.White;
                buttonModifyStages.Enabled        = true;
                changesMade = true;
                string stageToMark = Path.GetFileNameWithoutExtension(damnedRemoveStage.stagePath).Replace("_", " ");
                MarkStage(stageToMark, Color.Red);
            }

            else
            {
                string reason = String.Empty;

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

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

                damnedNewStage.newScenePath = scenePath;
                labelScene.Text             = sceneName;
                labelScene.ForeColor        = Color.FromArgb(255, 168, 38);
                changesMade = true;
                buttonSelectLobbyButtonPicture.Enabled = true;
            }
        }