public PredefinedMods() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Definitions = new ObservableCollection <ModConfiguration>(); foreach (ModConfiguration config in ModManagement.GetPredefinedMods().Values) { AppendConfig(config); } InitializeComponent(); if (Definitions.Count < 1) { this.Visibility = System.Windows.Visibility.Collapsed; } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public void HandleProtocol(ByteReader data) { int clientProtocol = data.ReadInt32(); if (clientProtocol != MpVersion.Protocol) { Player.Disconnect(MpDisconnectReason.Protocol, ByteWriter.GetBytes(MpVersion.Version, MpVersion.Protocol)); return; } var modConfigFiles = MultiplayerMod.settings.syncModConfigs ? ModManagement.GetSyncableConfigFiles() : new Dictionary <string, string>(); // Compress configs, to keep packet size < 50kb limit. JSON encode first, as the many tiny files are better compressed together var modConfigsCompressed = GZipStream.CompressString(SimpleJson.SerializeObject(modConfigFiles)); if (MpVersion.IsDebug) { Log.Message($"Sending {modConfigFiles.Keys.Count} mod config files"); foreach (KeyValuePair <string, string> modConfigFile in modConfigFiles) { Log.Message(modConfigFile.Key + ": " + modConfigFile.Value.Length); } Log.Message($"modConfigsCompressed size: {modConfigsCompressed.Length}"); } connection.SendFragmented(Packets.Server_ModList, Server.rwVersion, Server.modNames, Server.modIds, Server.workshopModIds, modConfigsCompressed); }
private void Activate_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool WasPlaying = RussLibraryAudio.AudioServer.Current.IsPlaying; if (WasPlaying) { RussLibraryAudio.AudioServer.Current.Stop(); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { ModManagement.Activate(mod); } } if (WasPlaying) { RussLibraryAudio.AudioServer.Current.PlayNextInQueue(); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
//ModConfiguration GetModConfigFile(string FileToProcess) //{ // if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } // ModConfiguration config = null; // string target = null; // using (Stream stream = File.OpenRead(FileToProcess)) // { // IReader reader = ReaderFactory.Open(stream); // while (reader.MoveToNextEntry()) // { // if (!reader.Entry.IsDirectory) // { // if (reader.Entry.FilePath.EndsWith(".aml", StringComparison.OrdinalIgnoreCase)) // { // target = System.IO.Path.Combine(System.IO.Path.GetTempPath(), reader.Entry.FilePath); // reader.WriteEntryToDirectory(System.IO.Path.GetTempPath(), // SharpCompress.Common.ExtractOptions.ExtractFullPath | SharpCompress.Common.ExtractOptions.Overwrite); // break; // } // } // } // } // if (!string.IsNullOrEmpty(target)) // { // config = new ModConfiguration(target); // } // if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } // return config; //} //void ProcessNoAML(string FileToProcess) //{ // if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } // ModDefinitionSetup win = new ModDefinitionSetup(); // win.Configuration.PackagePath = FileToProcess; // win.Configuration.ID = new FileInfo(FileToProcess).Name.Replace('.', '~'); // if (win.ShowDialog() == true) // { // ModManagement.BeginInstall(win.Configuration, FileToProcess); // } // if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } //} //bool ProcessAML(string fileToProcess) //{ // if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } // bool retVal = false; // ModConfiguration config = new ModConfiguration(fileToProcess); // if (!string.IsNullOrEmpty(config.Download.Source) || ! string.IsNullOrEmpty(config.Download.Webpage)) // { // MessageBoxResult result = Locations.MessageBoxShow("Do you wish to download the package from the web?", MessageBoxButton.YesNoCancel, MessageBoxImage.Question); // if (result == MessageBoxResult.Cancel) // { // retVal = false; // } // else if (result == MessageBoxResult.Yes) // { // if (string.IsNullOrEmpty(config.Download.Source)) // { // System.Diagnostics.Process.Start(config.Download.Webpage); // retVal = ModManagement.BrowseForPackage(config); // } // else // { // StartDownload(config); // retVal = true; // } // } // } // else // { // retVal = ModManagement.BrowseForPackage(config); // } // if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } // return retVal; //} //void StartDownload(ModConfiguration config) //{ // if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } // ModManagement.Downloaded += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_Downloaded); // ModManagement.DownloadFailed += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_DownloadFailed); // ModManagement.StartDownload(config); // if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } //} //////void CleanupDownload() //////{ ////// if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ////// ModManagement.Downloaded -= new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_Downloaded); ////// ModManagement.DownloadFailed -= new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_DownloadFailed); ////// if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } //////} //////void ModManagement_DownloadFailed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) //////{ ////// if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ////// CleanupDownload(); ////// MessageBox.Show("Download Failed:\r\n\r\n" + e.Error.ToString() + "\r\n\r\nPlease manually download the file and select it.", "Aretmis Mod Loader", MessageBoxButton.OK, MessageBoxImage.Error); ////// ModConfiguration mod = e.UserState as ModConfiguration; ////// if (string.IsNullOrEmpty(mod.Download.Source)) ////// { ////// System.Diagnostics.Process.Start(mod.Download.Source); ////// } ////// else ////// { ////// System.Diagnostics.Process.Start(mod.Download.Webpage); ////// } ////// ModManagement.BrowseForPackage(mod); ////// if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } //////} //////void ModManagement_Downloaded(object sender, System.ComponentModel.AsyncCompletedEventArgs e) //////{ ////// if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ////// CleanupDownload(); ////// if (e != null) ////// { ////// ModConfiguration mod = e.UserState as ModConfiguration; ////// ModManagement.BeginInstall(mod, mod.PackagePath); ////// } ////// if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } //////} void BrowseForFile() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } string retVal = string.Empty; OpenFileDialog diag = new OpenFileDialog(); diag.Filter = AMLResources.Properties.Resources.SupportedCompressedFiles + DataStrings.SupportedCompressedFilesFilter + "|" + AMLResources.Properties.Resources.AML + DataStrings.AMLFilter + "|" + AMLResources.Properties.Resources.AllFiles + DataStrings.AllFilesFilter; diag.Title = Locations.AssemblyTitle; diag.Multiselect = true; if (diag.ShowDialog() == true) { if (diag.FileNames != null) { ModManagement.ProcessFiles(diag.FileNames); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private static KeyValuePair <string, string> ProcessNotInModFile(string source, ModConfiguration mod) { // When selecting file items, no issue if within mod prefix. //If within Artemis copy, test if dependent mods and only dependent mods are active: no issue. //Otherwise auto copy selected file into current mod. string retVal = source; string alternatePrefix = null; if (mod != null && !string.IsNullOrEmpty(source)) { alternatePrefix = ModManagement.IsInModPathOrDependencyPath(source, mod); if (alternatePrefix != null) { retVal = source; //Need a way to pass back temporary alternate prefix for this. //Need what InstalledPath of matching Mod to get prefix. } else { //If not among dependent list, copy file in as below. retVal = DoFileDialog(source, mod.InstalledPath); } } return(new KeyValuePair <string, string>(retVal, alternatePrefix)); }
void FinishStartup() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ModManagement.DoInitialSetup(); //while (ModManagement.SetupInProgress) //{ // System.Threading.Thread.Sleep(100); //} string path = System.IO.Path.Combine(Locations.DataPath, "audio.ini"); AudioConfiguration audioConfig = INIConverter.ToObject(path, typeof(AudioConfiguration)) as AudioConfiguration; if (audioConfig.StartupMusic) { string playfile = Path.Combine(Locations.ArtemisCopyPath, "dat", "Artemis Main Screen.ogg"); if (File.Exists(playfile)) { RussLibraryAudio.AudioServer.Current.PlayAsync(playfile); } } this.Dispatcher.BeginInvoke(new Action(ModManagement.UpdateCheckProcess), System.Windows.Threading.DispatcherPriority.Loaded); this.Dispatcher.BeginInvoke(new Action <AudioConfiguration>(LoadAudioData), audioConfig); this.Dispatcher.BeginInvoke(new Action(DoStartup)); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void btnInstall_Click(object sender, RoutedEventArgs e) { //if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ModManagement.BrowseForFile(); //if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
static void DoCopy(string folder, FileInfo f) { string targ = Path.Combine(folder, f.Name); ModManagement.DoMessage(string.Format(System.Globalization.CultureInfo.CurrentCulture, AMLResources.Properties.Resources.Copying, f.Name, targ)); FileHelper.Copy(f.FullName, targ); }
static void OnConfigurationChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { FileMapControl v = sender as FileMapControl; if (v != null && v.Configuration != null) { v.SearchPrefixes = new ObservableCollection <string>(ModManagement.SearchPrefixes(v.Configuration)); } }
static void OnConfigurationChange(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ArtemisINIControl me = sender as ArtemisINIControl; if (me != null && me.Configuration != null) { me.SearchPrefixes = new ObservableCollection <string>(ModManagement.SearchPrefixes(me.Configuration)); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(me.LoadINIFile)); } }
void UpdateCheckProcess() { if (ModManagement.CheckForUpdate()) { if (Locations.MessageBoxShow(string.Format("An update to Artemis has been detected. Do you wish to apply that update to the copy that {0} runs?", Locations.AssemblyTitle), MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { ModManagement.ProcessUpdate(); } } }
public bool InstallMod(ModConfiguration mod, string source) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool retVal = false; if (mod != null && !string.IsNullOrEmpty(source)) { if (ModAlreadyInstalled(mod.ID)) { retVal = false; } else { if (!VersionOK(source)) { return(false); } FileHelper.CreatePath(Locations.ArtemisCopyPath); string src = source; FileAttributes attr = File.GetAttributes(src); if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { ModManagement.DoMessage(AMLResources.Properties.Resources.InstallingMod); mod.InstallMod(src); } else if (src.EndsWith("EXE", StringComparison.OrdinalIgnoreCase)) { ModManagement.DoMessage(AMLResources.Properties.Resources.InstallingMod); InstallEXE(mod, src); } else { ModManagement.DoMessage(AMLResources.Properties.Resources.UnpackagingMod); src = mod.Unpackage(source); if (string.IsNullOrEmpty(src)) { return(false); } } this.Dispatcher.BeginInvoke(new Action <ModConfiguration>(AddToCollection), mod); retVal = true; } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } return(retVal); }
public static MessageBoxResult MessageBoxShow(string message, MessageBoxButton button, MessageBoxImage image) { if (Application.Current.Dispatcher != System.Windows.Threading.Dispatcher.CurrentDispatcher) { return((MessageBoxResult)Application.Current.Dispatcher.Invoke(new Func <string, MessageBoxButton, MessageBoxImage, MessageBoxResult>(MessageBoxShow), message, button, image)); } else { ModManagement.SetStandbyBack(); return(MessageBox.Show(MainWindow, message, GeneralHelper.AssemblyTitle, button, image)); } }
void WaitForActivation(object state) { string id = state as string; if (!string.IsNullOrEmpty(id)) { do { System.Threading.Thread.Sleep(1000); } while (!ModManagement.IsActive(id)); } Application.Current.Dispatcher.BeginInvoke(new Action(StartArtemis), System.Windows.Threading.DispatcherPriority.Loaded); }
private void ModUninstalled(object sender, RoutedEventArgs e) { //if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } //Only if a pre-defined mod. ModConfiguration mod = e.OriginalSource as ModConfiguration; if (ModManagement.GetPredefinedMods().ContainsKey(mod.ID)) { predefinedMods.AppendConfig(mod); } //if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
static void DoCopy(string folder, FileInfo f) { Locations.CreatePath(folder); string targ = Path.Combine(folder, f.Name); Locations.DeleteFile(targ); if (_log.IsInfoEnabled) { _log.InfoFormat("Copying file from \"{0}\" to \"{1}\".", f.FullName, targ); } ModManagement.DoMessage(string.Format(System.Globalization.CultureInfo.CurrentCulture, AMLResources.Properties.Resources.Copying, f.Name, targ)); f.CopyTo(targ); }
private void Test_Click(object sender, RoutedEventArgs e) { if (ModManagement.IsActive(Configuration.ID)) { if (Locations.MessageBoxShow("This Mod is currently active. In order to apply your changes, the Mod must first be deactivated, the re-activated.\r\n\r\nDo you wish to deactivate then re-activate this Mod for testing?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { do { ModManagement.DeactivateLastMod(); } while (ModManagement.IsActive(Configuration.ID)); ModManagement.NotifyMissionInstall(); } else { Locations.MessageBoxShow("Test canceled.", MessageBoxButton.OK, MessageBoxImage.Stop); return; } } if (!DependentModsActive()) { if (Locations.MessageBoxShow("Active Mods differ from what this Mod depends on.\r\n\r\nDo you want to deactivate these Mods and activate the dependent Mods?", MessageBoxButton.OK, MessageBoxImage.Question) == MessageBoxResult.Yes) { while (ModManagement.DeactivateLastMod()) { } foreach (StringItem item in Configuration.DependsOn) { foreach (ModConfiguration config in InstalledModConfigurations.Current.Configurations.Configurations) { if (config.ID == item.Text) { ModManagement.Activate(config); } } } ModManagement.NotifyMissionInstall(); } else { Locations.MessageBoxShow("Test canceled. Please change Mod dependencies to match the list of Activated Mods.", MessageBoxButton.OK, MessageBoxImage.Stop); return; } } ModManagement.Activate(Configuration); System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(WaitForActivation), Configuration.ID); }
public void AppendConfig(ModConfiguration config) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (!ModManagement.IsInstalled(config.ID)) { Definitions.Add(config); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private InstalledModConfigurations() : base(Locations.InstalledModDefinitionFile) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } foreach (ModConfiguration config in Configurations) { config.IsActive = ModManagement.IsActive(config.ID); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
void StartDownload(ModConfiguration config) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ModManagement.Downloaded += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_Downloaded); ModManagement.DownloadFailed += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_DownloadFailed); ModManagement.StartDownload(config); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string id = null; string title = string.Empty; IList <StringItem> l = value as IList <StringItem>; if (l != null) { if (l.Count > 0) { id = l[0].Text; } } else { id = value as string; } if (!string.IsNullOrEmpty(id)) { title = AMLResources.Properties.Resources.DependsOnNotInstalled; bool found = false; foreach (ModConfiguration config in InstalledModConfigurations.Current.Configurations.Configurations) { if (config.ID == id) { title = string.Format(CultureInfo.CurrentCulture, AMLResources.Properties.Resources.DependsOn, config.Title); found = true; break; } } if (!found) { foreach (ModConfiguration configID in ModManagement.GetPredefinedMods().Values) { if (configID.ID == id) { found = true; title = string.Format(CultureInfo.CurrentCulture, AMLResources.Properties.Resources.DependsOn, configID.Title); break; } } } } return(title); }
private void uc_Drop(object sender, DragEventArgs e) { //if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files != null) { ModManagement.ProcessFiles(files); } } //if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
void ModManagement_Downloaded(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } CleanupDownload(); if (e != null) { ModConfiguration mod = e.UserState as ModConfiguration; ModManagement.InstallComplete += new EventHandler <ProcessEventArgs>(ModManagement_InstallComplete); ModManagement.BeginInstall(mod, mod.PackagePath); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void TestAllDownloads() { TestConfigs = new List <ModConfiguration>(); foreach (ModConfiguration config in ModManagement.GetPredefinedMods().Values) { if (config.ID != DataStrings.StockID) { if (!string.IsNullOrEmpty(config.Download.Source)) { if (ModManagement.StartDownload(config)) { TestConfigs.Add(config); } } } } //ModManagement.Downloaded -= new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_Downloaded); //ModManagement.DownloadFailed -= new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_DownloadFailed); }
static bool VersionOK(string source) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool AtLeastOne = true; bool retVal = true; string[] xmlFiles = GetAllXmlFiles(source); if (xmlFiles == null) { retVal = false; } else { foreach (string s in xmlFiles) { AtLeastOne = false; decimal ver = ModManagement.GetVesselDataVersion(s); if (ver >= 1.56M) { AtLeastOne = true; break; } } if (!AtLeastOne) { retVal = (Locations.MessageBoxShow( AMLResources.Properties.Resources.IncompatibleVesselDataMessage + DataStrings.CRCR + AMLResources.Properties.Resources.InstallAnyhowQuestion, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } return(retVal); }
private void Activate_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { ModManagement.Activate(mod); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
void BrowseForPackage(ModConfiguration mod) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } OpenFileDialog diag = new OpenFileDialog(); diag.Filter = AMLResources.Properties.Resources.SupportedCompressedFiles + DataStrings.SupportedCompressedFilesFilter + "|" + AMLResources.Properties.Resources.AllFiles + DataStrings.AllFilesFilter; diag.Title = GeneralHelper.AssemblyTitle; if (diag.ShowDialog() == true) { ModManagement.InstallComplete += new EventHandler <ProcessEventArgs>(ModManagement_InstallComplete2); ModManagement.BeginInstall(mod, diag.FileName); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public static void ResetInstallation() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } FileHelper.CreatePath(Locations.InstalledModsPath); Current = new InstalledModConfigurations(); if (File.Exists(Locations.InstalledModDefinitionFile)) { XmlConverter.ToObject(Locations.InstalledModDefinitionFile, Current); } foreach (ModConfiguration config in Current.Configurations.Configurations) { config.IsActive = ModManagement.IsActive(config.ID); config.AcceptChanges(); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void Application_Startup(object sender, StartupEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } GeneralHelper.LogSystemData(); if (ArtemisModLoader.Properties.Settings.Default.UpdateRequired) { ModManagement.CheckInstalledModDefinitionVersions(); ArtemisModLoader.Properties.Settings.Default.Upgrade(); ArtemisModLoader.Properties.Settings.Default.UpdateRequired = false; ArtemisModLoader.Properties.Settings.Default.Save(); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void ActivateStock_Click(object sender, RoutedEventArgs e) { bool WasPlaying = RussLibraryAudio.AudioServer.Current.IsPlaying; if (WasPlaying) { RussLibraryAudio.AudioServer.Current.Stop(); } if (!ModManagement.IsInstalled(DataStrings.StockID)) { if (!Directory.Exists(System.IO.Path.Combine(Locations.InstalledModsPath, DataStrings.StockID))) { Locations.MessageBoxShow("Stock Mod is not installed and Stock Mod install folder does not exist--cannot continue.", MessageBoxButton.OK, MessageBoxImage.Error); } else { ModConfiguration configuration = new ModConfiguration(DataStrings.ModStockFile); configuration.InstalledPath = System.IO.Path.Combine(Locations.InstalledModsPath, DataStrings.StockID); InstalledModConfigurations.Current.Configurations.Configurations.Insert(0, configuration); InstalledModConfigurations.Current.Save(); } } foreach (ModConfiguration configuration in InstalledModConfigurations.Current.Configurations.Configurations) { if (configuration.ID == DataStrings.StockID) { ModManagement.Activate(configuration); Locations.MessageBoxShow("Activated stock.", MessageBoxButton.OK, MessageBoxImage.Information); } } if (WasPlaying) { RussLibraryAudio.AudioServer.Current.PlayNextInQueue(); } Locations.MessageBoxShow("done.", MessageBoxButton.OK, MessageBoxImage.Information); }
/// <summary> /// Gets the editor to use to edit the <see cref="XmlScript"/>'s install step order. /// </summary> /// <param name="p_xscScript">The <see cref="XmlScript"/> whose install step order is to be edited.</param> /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/> /// being edited belongs.</param> /// <returns>The editor to use to edit the <see cref="XmlScript"/>'s install step order. <c>null</c> is returned if the /// current <see cref="XmlScript"/> does not support editing the install step order.</returns> public virtual NodeEditor GetInstallStepOrderEditor(ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList<VirtualFileSystemItem> p_lstModFiles) { InstallStepsEditorVM vmlStepsEditor = new InstallStepsEditorVM(p_xscScript); return new InstallStepsEditor(vmlStepsEditor); }
public async void AsyncTagMod(ModManagement.UI.ModManagerVM p_ModManagerVM, ModManagement.UI.ModTaggerVM p_ModTaggerVM, EventHandler<EventArgs<ModManagement.UI.ModTaggerVM>> p_TaggingMod) { int intRetry = 0; while (intRetry < 5) { await Task.Delay(3000); if (LoginTask.LoggedIn) { p_TaggingMod(p_ModManagerVM, new EventArgs<ModManagement.UI.ModTaggerVM>(p_ModTaggerVM)); break; } else intRetry++; } }
/// <summary> /// Gets the editor to use to edit the <see cref="XmlScript"/> prerequisites. /// </summary> /// <param name="p_xscScript">The <see cref="XmlScript"/> whose prerequisites are to be edited.</param> /// <param name="p_lstModFiles">The list of files in the mod to which the <see cref="XmlScript"/> /// being edited belongs.</param> /// <returns>The editor to use to edit <see cref="XmlScript"/> prerequisites. <c>null</c> is returned if the /// current <see cref="XmlScript"/> does not support editing the prerequisites.</returns> public virtual NodeEditor GetPrerequisitesEditor(ModManagement.Scripting.XmlScript.XmlScript p_xscScript, IList<VirtualFileSystemItem> p_lstModFiles) { CPLConverter cvtConverter = new CPLConverter(ScriptType.GetCplParserFactory()); CPLEditorVM vmlCplEditor = CreateCPLEditorVM(p_lstModFiles); PrerequisitesEditorVM vmlPrerequisitesEditor = new PrerequisitesEditorVM(vmlCplEditor, cvtConverter, p_xscScript); return new ConditionEditor(vmlPrerequisitesEditor); }