diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 7586ab9f..2203df3f 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -763,7 +763,8 @@ public class CUE4ParseViewModel : ViewModel } case UMaterialInstance m when ModelIsOverwritingMaterial: { - throw new NotImplementedException(); + SnooperViewer.SwapMaterial(m); + return true; } case UStaticMesh when UserSettings.Default.SaveStaticMeshes: case USkeletalMesh when UserSettings.Default.SaveSkeletalMeshes: diff --git a/FModel/Views/Snooper/Options.cs b/FModel/Views/Snooper/Options.cs index 19ab5a59..80e93c40 100644 --- a/FModel/Views/Snooper/Options.cs +++ b/FModel/Views/Snooper/Options.cs @@ -11,6 +11,9 @@ public class Options public int SelectedSection { get; private set; } public int SelectedMorph { get; private set; } + public bool Append { get; set; } + public bool Close { get; set; } + public Options() { Reset(); @@ -22,6 +25,8 @@ public class Options SelectedModelInstance = 0; SelectedSection = 0; SelectedMorph = 0; + Append = false; + Close = false; } public void SelectModel(FGuid guid) @@ -49,4 +54,9 @@ public class Options section = model.Sections[SelectedSection]; else section = null; return section != null; } + + public void SwapMaterial(bool value) + { + Services.ApplicationService.ApplicationView.CUE4Parse.ModelIsOverwritingMaterial = value; + } } diff --git a/FModel/Views/Snooper/SnimGui.cs b/FModel/Views/Snooper/SnimGui.cs index f40c7e6b..17457ff2 100644 --- a/FModel/Views/Snooper/SnimGui.cs +++ b/FModel/Views/Snooper/SnimGui.cs @@ -293,9 +293,7 @@ public class SnimGui : IDisposable { options.SelectSection(i); if (ImGui.Selectable("Swap")) - { - - } + options.SwapMaterial(true); if (ImGui.Selectable("Copy Name to Clipboard")) Application.Current.Dispatcher.Invoke(delegate { diff --git a/FModel/Views/Snooper/Snooper.cs b/FModel/Views/Snooper/Snooper.cs index b29064b0..e39e01a4 100644 --- a/FModel/Views/Snooper/Snooper.cs +++ b/FModel/Views/Snooper/Snooper.cs @@ -49,7 +49,6 @@ public class Snooper private Vector2D _size; private float _previousSpeed; - private bool _append; public Snooper() { @@ -206,9 +205,19 @@ public class Snooper DoLoop(); } + public void SwapMaterial(UMaterialInstance mi) + { + if (!_models.TryGetValue(_options.SelectedModel, out var model) || + !_options.TryGetSection(model, out var section)) return; + + section.SwapMaterial(mi); + _options.SwapMaterial(false); + DoLoop(); + } + private void DoLoop() { - if (_append) _append = false; + if (_options.Append) _options.Append = false; _window.Run(); // if (_window.IsInitialized) // { @@ -376,7 +385,7 @@ public class Snooper // we can't use GLContext back on next load and so, for now, we basically have to reset the window // if we can't use GLContext, we can't generate handles, can't interact with IsVisible, State, etc // tldr we dispose everything but don't clear models, so the more you append, the longer it takes to load - _append = true; + _options.Append = true; _window.Close(); // _window.IsVisible = false; } @@ -395,7 +404,7 @@ public class Snooper { model.Dispose(); } - if (!_append) + if (!_options.Append) { _models.Clear(); _options.Reset();