//[DataRow("lang_ar_text.archive")] //[DataRow("lang_cs_text.archive")] //[DataRow("lang_de_text.archive")] //[DataRow("lang_en_text.archive")] //[DataRow("lang_en_voice.archive")] //[DataRow("lang_es-es_text.archive")] //[DataRow("lang_es-mx_text.archive")] //[DataRow("lang_fr_text.archive")] //[DataRow("lang_hu_text.archive")] //[DataRow("lang_it_text.archive")] //[DataRow("lang_ja_text.archive")] //[DataRow("lang_ko_text.archive")] //[DataRow("lang_pl_text.archive")] //[DataRow("lang_pt_text.archive")] //[DataRow("lang_ru_text.archive")] //[DataRow("lang_th_text.archive")] //[DataRow("lang_tr_text.archive")] //[DataRow("lang_zh-cn_text.archive")] //[DataRow("lang_zh-tw_text.archive")] public void Test_Unbundle(string archivename) { var resultDir = Path.Combine(Environment.CurrentDirectory, s_testResultsDirectory); Directory.CreateDirectory(resultDir); var totalCount = s_bm.Items.Count(); var results = new ConcurrentBag <ArchiveTestResult>(); var archiveFullName = Path.Combine(s_gameDirectoryPath, "archive", "pc", "content", archivename); var archive = s_bm.Archives[archiveFullName] as Archive; Parallel.ForEach(archive.Files, keyvalue => { var(hash, _) = keyvalue; try { using (var ms = new MemoryStream()) { ModTools.ExtractSingleToStream(archive, hash, ms); } results.Add(new ArchiveTestResult() { ArchiveName = archivename, Hash = hash.ToString(), Success = true }); } catch (Exception e) { results.Add(new ArchiveTestResult() { ArchiveName = archivename, Hash = hash.ToString(), Success = false, ExceptionType = e.GetType(), Message = $"{e.Message}" }); } }); // Check success var successCount = results.Count(r => r.Success); var sb = new StringBuilder(); sb.AppendLine($"Successfully unbundled: {successCount} / {totalCount} ({(int)(successCount / (double)totalCount * 100)}%)"); var success = results.All(r => r.Success); if (success) { return; } var msg = $"Successful Writes: {successCount} / {totalCount}. "; Assert.Fail(msg); }
/// <summary> /// Import Export ViewModel Constructor /// </summary> /// <param name="projectManager"></param> /// <param name="loggerService"></param> /// <param name="messageService"></param> /// <param name="watcherService"></param> /// <param name="gameController"></param> /// <param name="modTools"></param> public ImportExportViewModel( IProjectManager projectManager, ILoggerService loggerService, IMessageService messageService, IWatcherService watcherService, IGrowlNotificationService notificationService, IGameControllerFactory gameController, ISettingsManager settingsManager, ModTools modTools ) : base(ToolTitle) { Argument.IsNotNull(() => projectManager); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => loggerService); Argument.IsNotNull(() => watcherService); Argument.IsNotNull(() => modTools); Argument.IsNotNull(() => gameController); Argument.IsNotNull(() => notificationService); Argument.IsNotNull(() => settingsManager); _projectManager = projectManager; _loggerService = loggerService; _messageService = messageService; _watcherService = watcherService; _modTools = modTools; _gameController = gameController; _notificationService = notificationService; _settingsManager = settingsManager; SetupToolDefaults(); ProcessAllCommand = new TaskCommand(ExecuteProcessAll, CanProcessAll); ProcessSelectedCommand = new TaskCommand(ExecuteProcessSelected, CanProcessSelected); CopyArgumentsTemplateToCommand = new DelegateCommand <string>(ExecuteCopyArgumentsTemplateTo, CanCopyArgumentsTemplateTo); SetCollectionCommand = new DelegateCommand <string>(ExecuteSetCollection, CanSetCollection); ConfirmCollectionCommand = new DelegateCommand <string>(ExecuteConfirmCollection, CanConfirmCollection); AddItemsCommand = new DelegateCommand <ObservableCollection <object> >(ExecuteAddItems, CanAddItems); RemoveItemsCommand = new DelegateCommand <ObservableCollection <object> >(ExecuteRemoveItems, CanRemoveItems); _watcherService.Files .Connect() .Filter(_ => _.IsImportable) .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.RawDirectory)) .Transform(_ => new ImportableItemViewModel(_)) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _importableItems) .Subscribe(); _watcherService.Files .Connect() .Filter(_ => _.IsExportable) .Filter(_ => _.FullName.Contains(_projectManager.ActiveProject.ModDirectory)) .Transform(_ => new ExportableItemViewModel(_)) .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _exportableItems) .Subscribe(); }
public MaterialsRepositoryDialog() { InitializeComponent(); _settingsManager = ServiceLocator.Default.ResolveType <ISettingsManager>(); _gameControllerFactory = ServiceLocator.Default.ResolveType <IGameControllerFactory>(); _modTools = ServiceLocator.Default.ResolveType <ModTools>(); _progress = ServiceLocator.Default.ResolveType <IProgressService <double> >(); _loggerService = ServiceLocator.Default.ResolveType <ILoggerService>(); _archivesFolderPath = Path.Combine(_settingsManager.GetRED4GameRootDir(), "archive", "pc", "content"); MaterialsDepotPath = _settingsManager.MaterialRepositoryPath; MaterialsTextBox.SetCurrentValue(System.Windows.Controls.TextBox.TextProperty, _settingsManager.MaterialRepositoryPath); }
public Cp77Controller(ILoggerService loggerService, IProjectManager projectManager, ISettingsManager settingsManager, IHashService hashService, ModTools modTools ) { _loggerService = loggerService; _projectManager = projectManager; _settingsManager = settingsManager; _hashService = hashService; _modTools = modTools; _rootCache = new SourceCache <GameFileTreeNode, string>(t => t.FullPath); }
private DocumentViewModel() { State = DockState.Document; _gameControllerFactory = ServiceLocator.Default.ResolveType <IGameControllerFactory>(); _projectManager = ServiceLocator.Default.ResolveType <IProjectManager>(); _modTools = ServiceLocator.Default.ResolveType <ModTools>(); _wolvenkitFileService = ServiceLocator.Default.ResolveType <Red4ParserService>(); IsDirty = false; OpenEditorCommand = new RelayCommand(ExecuteOpenEditor); OpenBufferCommand = new RelayCommand(ExecuteOpenBuffer); OpenImportCommand = new DelegateCommand <ICR2WImport>(ExecuteOpenImport); OpenImportCommand = new RelayCommand(ExecuteViewImports, CanViewImports); }
// [DataRow("basegame_2_mainmenu.archive")] // [DataRow("basegame_3_nightcity.archive")] // [DataRow("basegame_3_nightcity_gi.archive")] // [DataRow("basegame_3_nightcity_terrain.archive")] // [DataRow("basegame_4_animation.archive")] // [DataRow("basegame_4_appearance.archive")] // [DataRow("basegame_4_gamedata.archive")] public void Test_Cr2wSerialize(string archivename) { var parsers = ServiceLocator.Default.ResolveType <Red4ParserService>(); var resultDir = Path.Combine(Environment.CurrentDirectory, s_testResultsDirectory); Directory.CreateDirectory(resultDir); var totalCount = s_bm.Items.Count(); var results = new ConcurrentBag <ArchiveTestResult>(); var archiveFullName = Path.Combine(s_gameDirectoryPath, "archive", "pc", "content", archivename); var archive = s_bm.Archives[archiveFullName] as Archive; Parallel.ForEach(archive.Files, keyvalue => { var(hash, file) = keyvalue; try { #region serialize using var ms = new MemoryStream(); ModTools.ExtractSingleToStream(archive, hash, ms); var cr2w = parsers.TryReadCr2WFile(ms); if (cr2w == null) { return; } var dto = new Red4W2rcFileDto(cr2w); var json = JsonConvert.SerializeObject( dto, Formatting.Indented ); if (string.IsNullOrEmpty(json)) { throw new SerializationException(); } #endregion #region deserialize var newdto = JsonConvert.DeserializeObject <Red4W2rcFileDto>(json); if (newdto == null) { throw new SerializationException(); } var w2rc = newdto.ToW2rc(); using var newms = new MemoryStream(); using var bw = new BinaryWriter(newms); w2rc.Write(bw); #endregion #region compare var newbytes = newms.ToByteArray(); var oldbytes = ms.ToByteArray(); if (!oldbytes.SequenceEqual(newbytes)) { throw new SerializationException(); } else { } #endregion results.Add(new ArchiveTestResult() { ArchiveName = archivename, Hash = hash.ToString(), Success = true }); } catch (Exception e) { results.Add(new ArchiveTestResult() { ArchiveName = archivename, Hash = hash.ToString(), Success = false, ExceptionType = e.GetType(), Message = $"{e.Message}" }); } }); // Check success var successCount = results.Count(r => r.Success); var sb = new StringBuilder(); sb.AppendLine($"Successfully serialized: {successCount} / {totalCount} ({(int)(successCount / (double)totalCount * 100)}%)"); var success = results.All(r => r.Success); if (success) { return; } var msg = $"Successful serialized: {successCount} / {totalCount}. "; Assert.Fail(msg); }