private void StartGame(object sender, RoutedEventArgs e) { List <Data.Mod> mods = new List <Data.Mod>(); foreach (ListViewItem i in Mods.Mods) { ModViewModel vm = (ModViewModel)i.DataContext; if (vm != null && vm.Selected) { ModVersionViewModel vm2 = (ModVersionViewModel)vm.SelectedVersion.DataContext; if (vm2 != null) { mods.Add(vm2.mod); } } } ProgressHandler progressHandler = new ProgressHandler(); progressHandler.OnComplete += (object o, EventArgs ex) => { if (Configuration.GetString("UseSteam") == "true" && App.Game.GameConfiguration.SteamAppID != "") { Process p = new Process(); p.StartInfo.FileName = Configuration.GetPath("Steam") + System.IO.Path.DirectorySeparatorChar + "Steam.exe"; p.StartInfo.Arguments = "-applaunch " + App.Game.GameConfiguration.SteamAppID; p.Start(); } else { Process p = new Process(); p.StartInfo.FileName = App.Game.GamePath + System.IO.Path.DirectorySeparatorChar + App.Game.GameConfiguration.SelectFile; p.Start(); } }; Thread thread = new Thread(delegate() { App.Game.ApplyMods(mods, progressHandler); }); ModAPI.Windows.SubWindows.OperationPending window = new ModAPI.Windows.SubWindows.OperationPending("Lang.Windows.OperationPending", "ApplyMods", progressHandler, null, true); if (!window.Completed) { window.ShowSubWindow(); window.Show(); } thread.Start(); }
public void SelectNewestVersions() { foreach (ListViewItem item in _Mods) { ModViewModel vm = (ModViewModel)item.DataContext; List <int> v = vm.versions.Keys.ToList(); v.Sort(); v.Reverse(); foreach (ListViewItem li in vm.Versions) { ModVersionViewModel versionModel = (ModVersionViewModel)li.DataContext; if (Mod.Header.ParseModVersion(versionModel.mod.header.GetVersion()) == v[0]) { vm.SelectedVersion = li; break; } } } _SelectNewestModVersions = false; }