protected override IEnumerable <string> GetOptions() { using (var unitSync = new UnitSync(Settings.Default.SpringPath)) { return(unitSync.GetModNames()); } }
public static void PromptForNewMission() { var dialog = new NewMissionDialog { Owner = MainWindow.Instance }; dialog.ProgressBar.Visibility = Visibility.Visible; Utils.InvokeInNewThread(delegate { IEnumerable <string> modNames; IEnumerable <string> mapNames; using (var unitSync = new UnitSync(Settings.Default.SpringPath)) { modNames = unitSync.GetModNames(); mapNames = unitSync.GetMapNames(); } dialog.Invoke(delegate { dialog.MapList.ItemsSource = mapNames; dialog.ModList.ItemsSource = modNames; dialog.ProgressBar.Visibility = Visibility.Hidden; }); }); if (dialog.ShowDialog() == true) { MainWindow.Instance.SavePath = null; var mapName = (string)dialog.MapList.SelectedItem; var gameName = (string)dialog.ModList.SelectedItem; var missionName = dialog.NameBox.Text; var loadingDialog = new LoadingDialog { Owner = MainWindow.Instance }; loadingDialog.Loaded += delegate { Utils.InvokeInNewThread(delegate { Mission mission; loadingDialog.Text = "Scanning"; using (var unitSync = new UnitSync(Settings.Default.SpringPath)) { unitSync.LoadingStatusChanged += (s, e) => loadingDialog.Text = e.Data; loadingDialog.Text = "Loading Map"; var map = LoadMap(unitSync, mapName); loadingDialog.Text = "Loading Mod"; var mod = LoadMod(unitSync, gameName); mission = new Mission(missionName, mod, map); } dialog.Invoke(delegate { MainWindow.Instance.Mission = mission; loadingDialog.Close(); }); }); }; loadingDialog.ShowDialog(); } }
public static Mod LoadMod(UnitSync unitSync, string modName) { if (!unitSync.GetModNames().Any(n => n == modName)) { MessageBox.Show("Mod not found: " + modName); Environment.Exit(1); } return(unitSync.GetMod(modName)); }