public void DeactivateSubMod() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } List <FileMap> files = new List <FileMap>(); foreach (FileMap m in ActiveFiles) { if (m.ForSubMod) { files.Add(m); } } foreach (FileMap m in files) { Locations.DeleteFile(m.Target); ActiveFiles.Remove(m); } foreach (SubMod sm in SubMods) { if (sm.IsActive) { sm.IsActive = false; break; } } ActiveSubMod = null; if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
/// <summary> /// Add new file. /// </summary> private void NewFile_Clicked(object sender, EventArgs e) { FileItem NewFileItem = new FileItem(); ActiveFiles.Add(NewFileItem); var tmp = new FileListItem(this, NewFileItem, ((ActiveFiles.Count - 1) % 2 == 0) ? Colors.White : Colors.LightGray); FileListContent.PackStart(tmp); }
public override void RejectChanges() { DependsOn.RejectChanges(); Download.RejectChanges(); BaseFiles.RejectChanges(); ActiveFiles.RejectChanges(); SubMods.RejectChanges(); base.RejectChanges(); }
/// <summary> /// Deactivates the mod. /// </summary> /// <param name="rootPath">The root path. (Location where mod is activated at).</param> public void DeactivateMod() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } //After deactivating mod, parent caller needs to then go through all remaining mods (including stock) and ensure // all files exist. foreach (FileMap m in ActiveFiles) { Locations.DeleteFile(m.Target); } ActiveFiles.Clear(); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public override void EndInitialization() { Download.EndInitialization(); if (BaseFiles != null) { BaseFiles.EndInitialization(); } if (ActiveFiles != null) { ActiveFiles.EndInitialization(); } if (SubMods != null) { SubMods.EndInitialization(); } if (DependsOn != null) { DependsOn.EndInitialization(); } base.EndInitialization(); }
public override void AcceptChanges() { if (DependsOn != null) { DependsOn.AcceptChanges(); } Download.AcceptChanges(); if (BaseFiles != null) { BaseFiles.AcceptChanges(); } if (ActiveFiles != null) { ActiveFiles.AcceptChanges(); } if (SubMods != null) { SubMods.AcceptChanges(); } base.AcceptChanges(); }
public override void BeginInitialization() { base.BeginInitialization(); if (DependsOn != null) { DependsOn.BeginInitialization(); } if (Download != null) { Download.BeginInitialization(); } if (BaseFiles != null) { BaseFiles.BeginInitialization(); } if (ActiveFiles != null) { ActiveFiles.BeginInitialization(); } if (SubMods != null) { SubMods.BeginInitialization(); } }
/// <summary> /// Remove file item. /// </summary> public void RemoveFileItem(FileItem _item) { ActiveFiles.Remove(_item); RefreshFileList(); }
public void ActivateSubMod(string SubModTitle) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (string.IsNullOrEmpty(InstalledPath)) { SetInstalledPath(); } //Must first make sure the Mod itself is activated. string targetRootPath = Locations.ArtemisCopyPath; List <KeyValuePair <string, string> > targetList = new List <KeyValuePair <string, string> >(); if (!string.IsNullOrEmpty(ActiveSubMod) && ActiveSubMod != SubModTitle) { DeactivateSubMod(); } if (ActiveSubMod != SubModTitle) { foreach (SubMod sub in SubMods) { if (sub.Title == SubModTitle) { foreach (FileMap m in sub.Files) { // <FileMap Source="Helm UI Mod\New UI Image Files\*" Target="dat"/> if (m.Source.Contains("*") || m.Source.Contains("?")) { //more than one file, wildcarded. string sourceFle = m.Source; int i = sourceFle.LastIndexOf('\\'); sourceFle = sourceFle.Substring(0, i); targetList.AddRange(Locations.CopyFiles( new DirectoryInfo(Path.Combine(InstalledPath, sourceFle)), Path.Combine(targetRootPath, m.Target))); } else { FileInfo src = new FileInfo(Path.Combine(InstalledPath, m.Source)); string targ = Path.Combine(Locations.ArtemisCopyPath, m.Target); Locations.DeleteFile(targ); src.CopyTo(targ); targetList.Add(new KeyValuePair <string, string>(src.FullName, targ)); } } ActiveSubMod = sub.Title; sub.IsActive = true; break; } } } foreach (KeyValuePair <string, string> targ in targetList) { ActiveFiles.Add( new FileMap(targ.Key, targ.Value, true)); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public void ActivateMod() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } string targetRootPath = Locations.ArtemisCopyPath; List <DictionaryEntry> targetList = new List <DictionaryEntry>(); FileInfo[] baseFileList = GetFilesFromBaseFiles(BaseFiles.Files); if (string.IsNullOrEmpty(InstalledPath)) { SetInstalledPath(); } targetList.AddRange(FileHelper.CopyFiles(new DirectoryInfo(InstalledPath), targetRootPath, baseFileList)); if (!string.IsNullOrEmpty(FileHelper.CopyFilesProblemMessage)) { ModManagement.SetStandbyBack(); Locations.MessageBoxShow(FileHelper.CopyFilesProblemMessage, MessageBoxButton.OK, MessageBoxImage.Exclamation); FileHelper.CopyFilesProblemMessage = null; } foreach (FileMap m in BaseFiles.Files) { if (m.Source.Contains("*") || m.Source.Contains("?")) { //more than one file, wildcarded. string sourceFle = m.Source; int i = sourceFle.LastIndexOf('\\'); if (i >= 0) { sourceFle = sourceFle.Substring(0, i); } targetList.AddRange(FileHelper.CopyFiles( new DirectoryInfo(Path.Combine(InstalledPath, sourceFle)), Path.Combine(targetRootPath, m.Target))); if (!string.IsNullOrEmpty(FileHelper.CopyFilesProblemMessage)) { ModManagement.SetStandbyBack(); Locations.MessageBoxShow(FileHelper.CopyFilesProblemMessage, MessageBoxButton.OK, MessageBoxImage.Exclamation); FileHelper.CopyFilesProblemMessage = null; } } else { string src = Path.Combine(InstalledPath, m.Source); string targ = Path.Combine(Locations.ArtemisCopyPath, m.Target); FileHelper.Copy(src, targ); targetList.Add(new DictionaryEntry(src, targ)); } } ActiveFiles = Application.Current.Dispatcher.Invoke(new Func <FileGroup>(GetNewFileGroup)) as FileGroup; if (ActiveFiles != null) { foreach (DictionaryEntry targ in targetList) { FileMap fm = Application.Current.Dispatcher.Invoke(new Func <string, string, bool, FileMap>(GetNewFileMap), targ.Key.ToString(), targ.Value.ToString(), false) as FileMap; if (fm != null) { ActiveFiles.UIThreadAddToCollection <FileMap>(ActiveFiles.Files, fm); } //ActiveFiles.Files.Add(new FileMap(targ.Key.ToString(), targ.Value.ToString())); } } if (this.SubMods != null && this.SubMods.SubMods.Count > 0) { this.ActivateSubMod(SubMods.SubMods[0].Title); } ModManagement.SetStandbyBack(); IsActive = true; if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }