private void UpdateGue() { // Confirmation UpdateWindow updateWindow = new UpdateWindow(_localVersion, _remoteLatestVersion, _remoteUpdateList) { Owner = this }; updateWindow.ShowDialog(); if (!updateWindow.IsOK) { return; } if (IsGameRunning()) { CustomMessageBox.Show(this, string.Format("Mise à jour impossible : le jeu est en cours d'exécution.{0}{0}Quitte d'abord le jeu (si nécessaire via Gestionnaire des tâches => fin de tâche sur game.dat)", Environment.NewLine), "Mise à jour", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Basculement sur le mod Original + pas de map pack ModFactory.AllGamesBackToOriginal(); ModFactory.AllGamesNoMapPack(); // On "se souvient" Properties.Settings.Default["JustUpdated"] = true; Properties.Settings.Default.Save(); // On copie l'exécutable dans un dossier temporaire pour l'exécuter depuis là (sinon on ne pourrait pas mettre à jour l'installeur) string tempFolderPath = Path.GetTempPath(); string executablePath = _pathToExe + "\\Setup.exe"; string tempPath = Path.GetTempPath() + Path.GetFileName(executablePath); if (File.Exists(tempPath)) { try { File.Delete(tempPath); } catch { CustomMessageBox.Show(this, "Impossible de générer le fichier temporaire", "Mise à jour annulée", MessageBoxButton.OK, MessageBoxImage.Error); return; } } File.Copy(executablePath, tempPath); Process process = new Process(); process.StartInfo.FileName = tempPath; process.StartInfo.Arguments = "-maj " + Process.GetCurrentProcess().Id.ToString(); process.Start(); // Quitter Close(); }
private void settingsCleanMaps_Click(object sender, RoutedEventArgs e) { if (CustomMessageBox.Show(this, string.Format("Tu es sur le point de supprimer toutes les maps ajoutées manuellement ou téléchargées depuis le jeu. Continuer ?", Environment.NewLine), "Nettoyage des maps", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } if (IsGameRunning()) { CustomMessageBox.Show(this, string.Format("Nettoyage des maps impossible : le jeu est en cours d'exécution.{0}{0}Quitte d'abord le jeu (si nécessaire via Gestionnaire des tâches => fin de tâche sur game.dat)", Environment.NewLine), "Nettoyage des maps", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Se placer sur aucun MapPack ModFactory.AllGamesNoMapPack(); // Supprimer les maps restantes try { foreach (string path in Directory.GetDirectories(_pathToMapsGenerals)) { DirectoryInfo di = new DirectoryInfo(path); ModFactory.SetAttributesNormal(di); di.Delete(true); } foreach (string path in Directory.GetDirectories(_pathToMapsZeroHour)) { DirectoryInfo di = new DirectoryInfo(path); ModFactory.SetAttributesNormal(di); di.Delete(true); } CustomMessageBox.Show(this, "Maps nettoyées avec succès :-)", "Nettoyage des maps", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { CustomMessageBox.Show(this, string.Format("Erreur lors de la suppression des maps.{0}{0}{1}", Environment.NewLine, ex.Message), "Nettoyage des maps", MessageBoxButton.OK, MessageBoxImage.Error); } }