diff --git a/CUE4Parse b/CUE4Parse index a869d747..4318346a 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit a869d747f3997079f0223b6e94556a927f2fc527 +Subproject commit 4318346af22e90371b1017648aff20d7defa463c diff --git a/FModel/ViewModels/AudioPlayerViewModel.cs b/FModel/ViewModels/AudioPlayerViewModel.cs index 87a80536..ee9f2af9 100644 --- a/FModel/ViewModels/AudioPlayerViewModel.cs +++ b/FModel/ViewModels/AudioPlayerViewModel.cs @@ -303,7 +303,7 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable return; } - SelectedAudioFile = _audioFiles[SelectedAudioFile.Id]; + SelectedAudioFile = SelectedAudioFile.Id >= _audioFiles.Count ? _audioFiles.Last() : _audioFiles[SelectedAudioFile.Id]; if (!removedPlaying) return; Load(); diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index dc0025ef..2401fd7a 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -44,7 +44,6 @@ using CUE4Parse.UE4.Assets.Exports.StaticMesh; using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse.UE4.Assets.Exports.Verse; using CUE4Parse.UE4.Assets.Exports.Wwise; -using CUE4Parse.UE4.Assets.Objects; using CUE4Parse.UE4.BinaryConfig; using CUE4Parse.UE4.CriWare; using CUE4Parse.UE4.CriWare.Readers; @@ -62,9 +61,10 @@ using CUE4Parse.UE4.Shaders; using CUE4Parse.UE4.Versions; using CUE4Parse.UE4.Wwise; using CUE4Parse.Utils; -using CUE4Parse_Conversion; using CUE4Parse_Conversion.Exporters; using CUE4Parse_Conversion.Sounds; +using CUE4Parse.MappingsProvider.Jmap; +using CUE4Parse.MappingsProvider.Usmap; using EpicManifestParser; using EpicManifestParser.UE; using FModel.Creator; diff --git a/FModel/ViewModels/Commands/RightClickMenuCommand.cs b/FModel/ViewModels/Commands/RightClickMenuCommand.cs index c8200c8e..42e4e8a3 100644 --- a/FModel/ViewModels/Commands/RightClickMenuCommand.cs +++ b/FModel/ViewModels/Commands/RightClickMenuCommand.cs @@ -43,7 +43,6 @@ public class RightClickMenuCommand : ViewModelCommand if (param.Length == 0) return; var folders = param.OfType().ToArray(); - var searchMenu = param[0] is GameFile; var assets = param .Select(static item => item switch { @@ -136,26 +135,12 @@ public class RightClickMenuCommand : ViewModelCommand LogExport(contextViewModel, folder.PathAtThisPoint, path, dirType, filetype, queuedBefore); } - Action fileAction = bulktype switch + Action fileAction = bulktype switch { - EBulkType.Raw => (entry, _, _) => contextViewModel.CUE4Parse.ExportData(entry), - _ => (entry, bulk, _) => contextViewModel.CUE4Parse.Extract(cancellationToken, entry, false, bulk), + EBulkType.Raw => (entry, _) => contextViewModel.CUE4Parse.ExportData(entry), + _ => (entry, bulk) => contextViewModel.CUE4Parse.Extract(cancellationToken, entry, false, bulk), }; - if (searchMenu) - { - var update = assets.Length > 1; - foreach (var entry in assets) - { - Thread.Yield(); - cancellationToken.ThrowIfCancellationRequested(); - fileAction(entry, bulktype, update); - } - - if (assets.Length > 50) LogExport(contextViewModel, filetype); - return; - } - foreach (var group in assetsGroups) { var directory = group.Key; @@ -167,7 +152,7 @@ public class RightClickMenuCommand : ViewModelCommand { Thread.Yield(); cancellationToken.ThrowIfCancellationRequested(); - fileAction(entry, bulk, update); + fileAction(entry, bulk); } if (update) @@ -217,18 +202,4 @@ public class RightClickMenuCommand : ViewModelCommand Interlocked.Exchange(ref contextViewModel.CUE4Parse.ExportedCount, 0); Interlocked.Exchange(ref contextViewModel.CUE4Parse.FailedExportCount, 0); } - - private void LogExport(ApplicationViewModel contextViewModel, string fileType) - { - if (contextViewModel.CUE4Parse.ExportedCount > 0) - { - FLogger.Append(ELog.Information, () => - { - FLogger.Text($"Successfully exported {contextViewModel.CUE4Parse.ExportedCount} {fileType}, Failed to export {contextViewModel.CUE4Parse.FailedExportCount} {fileType} in other folders.", Constants.WHITE, true); - }); - } - - Interlocked.Exchange(ref contextViewModel.CUE4Parse.ExportedCount, 0); - Interlocked.Exchange(ref contextViewModel.CUE4Parse.FailedExportCount, 0); - } } diff --git a/FModel/ViewModels/ExportSessionViewModel.cs b/FModel/ViewModels/ExportSessionViewModel.cs index 9d596496..852e852c 100644 --- a/FModel/ViewModels/ExportSessionViewModel.cs +++ b/FModel/ViewModels/ExportSessionViewModel.cs @@ -321,16 +321,6 @@ public class ExportSessionViewModel : ViewModel cg.Objects.Add(og); return og; } - - private void ResetState() - { - _cts?.Cancel(); - _cts = null; - _stopwatch.Reset(); - IsRunning = false; - StopUiTimer(); - ClearExportHistory(); - } } public class ClassGroupViewModel(string name) : ViewModel diff --git a/FModel/ViewModels/TabControlViewModel.cs b/FModel/ViewModels/TabControlViewModel.cs index 3bd197e9..41df329f 100644 --- a/FModel/ViewModels/TabControlViewModel.cs +++ b/FModel/ViewModels/TabControlViewModel.cs @@ -427,7 +427,7 @@ public class TabItem : ViewModel { Interlocked.Increment(ref ApplicationService.ApplicationView.CUE4Parse.ExportedCount); Log.Information("{FileName} successfully saved", fileName); - if (updateUi && ApplicationService.ApplicationView.CUE4Parse.ExportedCount < 50) + if (updateUi) { FLogger.Append(ELog.Information, () => { diff --git a/FModel/Views/Resources/Controls/Aup/Timeclock.cs b/FModel/Views/Resources/Controls/Aup/Timeclock.cs index eab86f96..958bac50 100644 --- a/FModel/Views/Resources/Controls/Aup/Timeclock.cs +++ b/FModel/Views/Resources/Controls/Aup/Timeclock.cs @@ -116,7 +116,7 @@ public sealed class Timeclock : UserControl private void OnSourceEvent(object sender, SourceEventArgs e) { - if (Source == null) return; + if (e.Event != ESourceEventType.Loading || Source == null) return; Label = Source.PlayedFile.FileName; Dispatcher.BeginInvoke((Action) CalculateTime); } diff --git a/FModel/Views/Resources/Controls/Aup/Timeline.cs b/FModel/Views/Resources/Controls/Aup/Timeline.cs index 07500fe0..6525f632 100644 --- a/FModel/Views/Resources/Controls/Aup/Timeline.cs +++ b/FModel/Views/Resources/Controls/Aup/Timeline.cs @@ -100,7 +100,7 @@ public sealed class Timeline : UserControl private void OnSourceEvent(object sender, SourceEventArgs e) { - if (Source == null) return; + if (e.Event != ESourceEventType.Loading || Source == null) return; Dispatcher.BeginInvoke((Action) UpdateTimeline); } @@ -347,4 +347,4 @@ public sealed class Timeline : UserControl } } } -} \ No newline at end of file +} diff --git a/FModel/Views/Resources/Controls/Rtb/CustomRichTextBox.cs b/FModel/Views/Resources/Controls/Rtb/CustomRichTextBox.cs index 56478eb9..f773126f 100644 --- a/FModel/Views/Resources/Controls/Rtb/CustomRichTextBox.cs +++ b/FModel/Views/Resources/Controls/Rtb/CustomRichTextBox.cs @@ -28,6 +28,14 @@ public enum ELog None } +/// +/// this whole thing needs a refactor +/// TODO: source of truth for logs should be Serilog +/// a custom sink to reroute some of these logs to the UI +/// the ui should be an ObservableCollection of things +/// the things displayed in ListBox (virtualized) should use a custom template +/// see how logs work in ExportSessionViewModel +/// public class FLogger : ITextFormatter { public static CustomRichTextBox Logger; @@ -107,14 +115,12 @@ public class FLogger : ITextFormatter try { Logger.Document.ContentEnd.InsertTextInRun(message); - if (newLine) Logger.Document.ContentEnd.InsertLineBreak(); - Logger.Selection.Select(Logger.Document.ContentStart.GetPositionAtOffset(_previous), Logger.Document.ContentEnd); Logger.Selection.ApplyPropertyValue(TextElement.ForegroundProperty, _brushConverter.ConvertFromString(color)); } finally { - Finally(); + Finally(newLine); } } @@ -122,7 +128,7 @@ public class FLogger : ITextFormatter { try { - new Hyperlink(new Run(newLine ? $"{message}{Environment.NewLine}" : message), Logger.Document.ContentEnd) + new Hyperlink(new Run(message), Logger.Document.ContentEnd) { NavigateUri = new Uri(url), OverridesDefaultStyle = true, @@ -163,12 +169,21 @@ public class FLogger : ITextFormatter } finally { - Finally(); + Finally(newLine); } } - private static void Finally() + private const int MaxBlocks = 250; // in the meantime + + private static void Finally(bool newLine) { + if (newLine) Logger.Document.Blocks.Add(new Paragraph { Margin = new Thickness(0) }); + + while (Logger.Document.Blocks.Count > MaxBlocks) + { + Logger.Document.Blocks.Remove(Logger.Document.Blocks.FirstBlock); + } + Logger.ScrollToEnd(); _previous = Math.Abs(Logger.Document.ContentEnd.GetOffsetToPosition(Logger.Document.ContentStart)) - 2; } diff --git a/FModel/Views/Resources/Resources.xaml b/FModel/Views/Resources/Resources.xaml index 02c2bfe9..6ba2130b 100644 --- a/FModel/Views/Resources/Resources.xaml +++ b/FModel/Views/Resources/Resources.xaml @@ -1067,16 +1067,11 @@ - - - - - - - - - - + + + + +