Skip to content

Commit 30727a4

Browse files
authored
Merge pull request WolvenKit#2649 from rayshader/fix/import-export-tools
fix: UI in import / export tools
2 parents 6c7ac47 + ce3fb34 commit 30727a4

File tree

4 files changed

+78
-42
lines changed

4 files changed

+78
-42
lines changed

WolvenKit.App/ViewModels/Exporters/ExportViewModel.cs

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -81,7 +81,7 @@ protected override async Task ExecuteProcessBulkAsync(bool all = false)
8181
{
8282
return;
8383
}
84-
84+
8585
if (_archiveManager.ProjectArchive is not FileSystemArchive projectArchive)
8686
{
8787
_loggerService.Error("No project loaded!");
@@ -198,12 +198,12 @@ protected override async Task LoadFilesAsync()
198198
Items.Add(vm);
199199
}
200200
}
201-
202-
ProcessAllCommand.NotifyCanExecuteChanged();
203-
201+
202+
ProcessAllCommand.NotifyCanExecuteChanged();
203+
204204

205205
_progressService.IsIndeterminate = false;
206-
206+
207207
HasItems = Items.Any();
208208
}
209209

@@ -270,8 +270,9 @@ private void InitOpusCollectionEditor(CallbackArguments args, OpusExportArgs opu
270270
switch (args.PropertyName)
271271
{
272272
case nameof(OpusExportArgs.SelectedForExport):
273-
opusExportArgs.SelectedForExport =
274-
new List<uint>(result.Cast<CollectionItemViewModel<uint>>().Select(_ => _.Model));
273+
opusExportArgs.SelectedForExport = result.Cast<CollectionItemViewModel<uint>>()
274+
.Select(_ => _.Model)
275+
.ToList();
275276
_notificationService.Success($"Selected opus items were added.");
276277
break;
277278
default:
@@ -284,7 +285,7 @@ private void InitOpusCollectionEditor(CallbackArguments args, OpusExportArgs opu
284285
private void InitMeshCollectionEditor(CallbackArguments args, MeshExportArgs meshExportArgs)
285286
{
286287
var fetchExtension = ERedExtension.mesh;
287-
List<FileEntry> selectedEntries = new();
288+
List<FileEntry> selectedEntries = [];
288289
switch (args.PropertyName)
289290
{
290291
case nameof(MeshExportArgs.MultiMeshMeshes):
@@ -327,48 +328,61 @@ private void InitMeshCollectionEditor(CallbackArguments args, MeshExportArgs mes
327328
switch (args.PropertyName)
328329
{
329330
case nameof(MeshExportArgs.MultiMeshMeshes):
330-
meshExportArgs.MultiMeshMeshes =
331-
result.Cast<CollectionItemViewModel<FileEntry>>().Select(_ => _.Model).ToList();
332-
if (meshExportArgs.MultiMeshMeshes.Count != 0)
331+
var meshes = result.Cast<CollectionItemViewModel<FileEntry>>()
332+
.Select(_ => _.Model)
333+
.ToList();
334+
335+
meshExportArgs.MultiMeshMeshes.Clear();
336+
if (meshes.Count != 0)
333337
{
334-
_notificationService.Success($"Selected Meshes were added to MultiMesh arguments.");
338+
meshExportArgs.MultiMeshMeshes.AddRange(meshes);
335339
meshExportArgs.meshExportType = MeshExportType.Multimesh;
340+
341+
_notificationService.Success($"Changed selection of Meshes in MultiMesh.");
336342
}
337343
else
338344
{
339-
_notificationService.Success("MultiMesh arguments were cleared.");
345+
_notificationService.Success("Cleared MultiMesh.");
340346
}
341347

342348
break;
343349

344350
case nameof(MeshExportArgs.MultiMeshRigs):
345-
meshExportArgs.MultiMeshRigs =
346-
result.Cast<CollectionItemViewModel<FileEntry>>().Select(_ => _.Model).ToList();
347-
if (meshExportArgs.MultiMeshRigs.Count != 0)
351+
var rigs = result.Cast<CollectionItemViewModel<FileEntry>>()
352+
.Select(_ => _.Model)
353+
.ToList();
354+
355+
meshExportArgs.MultiMeshRigs.Clear();
356+
if (rigs.Count != 0)
348357
{
349-
_notificationService.Success($"Selected Rigs were added to MultiMesh arguments.");
358+
meshExportArgs.MultiMeshRigs.AddRange(rigs);
350359
meshExportArgs.meshExportType = MeshExportType.Multimesh;
360+
361+
_notificationService.Success($"Changed selection of Rigs in MultiMesh.");
351362
}
352363
else
353364
{
354-
_notificationService.Success($"Selected Rigs were cleared.");
365+
_notificationService.Success($"Cleared Rigs.");
355366
}
356367

357368
break;
358369

359370
case nameof(MeshExportArgs.Rig):
360-
meshExportArgs.Rig.Clear();
371+
var rig = result.Cast<CollectionItemViewModel<FileEntry>>()
372+
.Select(_ => _.Model)
373+
.FirstOrDefault();
361374

362-
var rig = result.Cast<CollectionItemViewModel<FileEntry>>().Select(_ => _.Model).FirstOrDefault();
375+
meshExportArgs.Rig.Clear();
363376
if (rig is not null)
364377
{
365378
meshExportArgs.Rig.Add(rig);
366-
_notificationService.Success($"Selected Rig was added to WithRig arguments: {rig.Name}");
367379
meshExportArgs.meshExportType = MeshExportType.WithRig;
380+
381+
_notificationService.Success($"Selected WithRig \"{rig.Name}\".");
368382
}
369383
else
370384
{
371-
_notificationService.Success($"Selected Rig was cleared");
385+
_notificationService.Success($"Cleared WithRig.");
372386
}
373387

374388
break;

WolvenKit/Views/Exporters/CustomCollectionEditor.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections;
1+
using System;
32
using System.ComponentModel;
43
using System.Reflection;
54
using System.Threading.Tasks;
@@ -8,9 +7,7 @@
87
using System.Windows.Input;
98
using Syncfusion.Windows.PropertyGrid;
109
using WolvenKit.App.ViewModels.Exporters;
11-
using WolvenKit.Common.Model.Arguments;
1210
using WolvenKit.Controls;
13-
using WolvenKit.RED4.Types;
1411

1512
namespace WolvenKit.Views.Exporters;
1613

@@ -62,4 +59,4 @@ public void Attach(PropertyViewItem property, PropertyItem info)
6259
}
6360

6461
public void Detach(PropertyViewItem property) => _wrappedControl = null;
65-
}
62+
}

WolvenKit/Views/Templates/CustomCollectionEditorView.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Grid.Column="1"
2626
Padding="2"
2727
VerticalAlignment="Stretch"
28+
ToolTip="{Binding ToolTip}"
2829
Click="ButtonBase_OnClick">
2930
<templates:IconBox
3031
IconPack="Codicons"

WolvenKit/Views/Templates/CustomCollectionEditorView.xaml.cs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections;
3-
using System.Collections.Generic;
43
using System.Threading.Tasks;
54
using System.Windows;
65
using WolvenKit.App.ViewModels.Exporters;
@@ -22,6 +21,7 @@ public CustomCollectionEditorView(Func<CallbackArguments, Task> callback, Callba
2221
_args = args;
2322

2423
SetText();
24+
SetToolTip();
2525
}
2626

2727
public IList List
@@ -38,31 +38,55 @@ public string Text
3838
set => SetValue(TextProperty, value);
3939
}
4040
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
41-
nameof(Text), typeof(string), typeof(CustomCollectionEditorView), new PropertyMetadata("Null"));
42-
41+
nameof(Text), typeof(string), typeof(CustomCollectionEditorView), new PropertyMetadata(""));
4342

4443
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
4544
{
4645
await _callback(_args);
4746

4847
SetText();
48+
SetToolTip();
4949
}
5050

5151
private void SetText()
5252
{
53-
if (List is not null)
53+
if (List is null)
54+
{
55+
SetCurrentValue(TextProperty, "");
56+
return;
57+
}
58+
59+
var size = List.Count;
60+
var text = size == 0 ? "" : $"[{size}]";
61+
62+
if (size == 1)
63+
{
64+
text += $" {List[0]}";
65+
}
66+
else if (size > 1)
5467
{
55-
var text = $"[{List.Count}]";
56-
if (List.Count == 1)
57-
{
58-
text += $"{List[0]}";
59-
}
60-
else if (List.Count > 1)
61-
{
62-
text += $"{List[0]}, ...";
63-
}
68+
text += $" {List[0]}, ...";
69+
}
70+
71+
SetCurrentValue(TextProperty, text);
72+
}
6473

65-
SetCurrentValue(TextProperty, text);
74+
private void SetToolTip()
75+
{
76+
switch (_args.PropertyName)
77+
{
78+
case "MultiMeshMeshes":
79+
SetCurrentValue(ToolTipProperty, "Select additional mesh(es)");
80+
break;
81+
case "MultiMeshRigs":
82+
SetCurrentValue(ToolTipProperty, "Select rig(s)");
83+
break;
84+
case "Rig":
85+
SetCurrentValue(ToolTipProperty, "Select a rig");
86+
break;
87+
default:
88+
SetCurrentValue(ToolTipProperty, "");
89+
break;
6690
}
6791
}
6892
}

0 commit comments

Comments
 (0)