Exemplo n.º 1
0
 public DamnedMappingForm(DamnedMaps damnedMaps, DamnedImages damnedImages, DamnedMainForm mainForm)
 {
     InitializeComponent();
     this.mainForm = mainForm;
     this.mainForm.Hide();
     this.damnedMaps        = damnedMaps;
     this.damnedImages      = damnedImages;
     this.tempDirectory     = String.Empty;
     damnedRemoveStage      = new DamnedRemoveStage();
     damnedNewStage         = new DamnedNewStage();
     damnedNewStagesList    = new List <DamnedNewStage>();
     damnedRemoveStagesList = new List <DamnedRemoveStage>();
     RefreshDamnedStagesList();
 }
Exemplo n.º 2
0
 public DamnedRemoveStage(DamnedRemoveStage copy)
 {
     this.stagePath = copy.stagePath;
     this.scenePath = copy.scenePath;
 }
        private void PrepareToModifyStages()
        {
            newStagesList.Clear();
            removeStagesList.Clear();

            selectedRows = damnedDataView.SelectedRows;

            for (int i = 0; i < selectedRows.Count; i++)
            {
                var cellsInRow = selectedRows[i].Cells;

                for (int j = 0; j < cellsInRow.Count; j++)
                {
                    var cell = cellsInRow[j];

                    if (cell.ColumnIndex != COLUMN_INSTALLED)
                    {
                        continue;
                    }

                    string cellValue = cell.Value.ToString();

                    int result = String.Compare(cellValue, "yes", true);

                    if (result != 0)
                    {
                        string githubLink = "https://github.com/Sweats/Damned-Community-Stages/raw/master/";

                        string archiveToDownload = $"{cellsInRow[COLUMN_NAME].Value.ToString()}.zip";
                        string downloadLink      = $"{githubLink}{archiveToDownload}".Replace(" ", "%20");
                        string workshopTempPath  = DamnedFiles.CreateTempWorkshopDirectory();
                        string archiveLocation   = Path.Combine(workshopTempPath, archiveToDownload);

                        if (!DamnedFiles.DownloadFile(downloadLink, archiveLocation))
                        {
                            MessageBox.Show($"Failed to download the stage archive {archiveToDownload} from {downloadLink}. Do you have a valid internet connection? ", "Failed To Download", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Directory.Delete(workshopTempPath, true);
                            return;
                        }

                        DamnedPackage package = new DamnedPackage();

                        if (!package.Check(archiveLocation))
                        {
                            string reason = $"Failed to prepare the stage archive {archiveToDownload} for installation:\n\n{package.reasonForFailedCheck}";
                            MessageBox.Show(reason, "Failed to prepare the stage archive.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Directory.Delete(workshopTempPath, true);
                            return;
                        }

                        package.Load();

                        DamnedNewStage newStage = new DamnedNewStage()
                        {
                            loadingImagePath = package.loadingImagePath,
                            lobbyImageButtonHighlightedPath = package.lobbyButtonImageHighlightedPath,
                            lobbyImageButtonPath            = package.lobbyButtonImagePath,
                            newScenePath   = package.scenePath,
                            newStagePath   = package.stagePath,
                            newObjectsPath = package.objectsPath,
                            hasObjects     = package.hasObjects
                        };

                        newStagesList.Add(newStage);
                    }


                    else
                    {
                        string            stageToFind = $"{cellsInRow[COLUMN_NAME].Value.ToString()}.stage".Replace(" ", "_");
                        string            sceneToFind = $"{cellsInRow[COLUMN_NAME].Value.ToString()}.scene".Replace(" ", "_");
                        DamnedRemoveStage removeStage = new DamnedRemoveStage();
                        string            pathToStage = Path.Combine(damnedStages.stagesAndScenesDirectory, stageToFind);
                        string            pathToScene = Path.Combine(damnedStages.stagesAndScenesDirectory, sceneToFind);
                        removeStage.stagePath = pathToStage;
                        removeStage.scenePath = pathToScene;
                        removeStagesList.Add(new DamnedRemoveStage(removeStage));
                    }
                }
            }
        }