Repository navigation
Expand file tree
/
Copy pathExportOptionsViewModel.cs
More file actions
235 lines (207 loc) · 7.67 KB
/
Copy pathExportOptionsViewModel.cs
File metadata and controls
235 lines (207 loc) · 7.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
using System;
using System.Collections.Generic;
using System.Windows.Threading;
using CUE4Parse.UE4.Assets.Exports.Material;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse_Conversion.Options;
using CUE4Parse_Conversion.Writers.UEFormat.Enums;
using FModel.Framework;
using FModel.Settings;
namespace FModel.ViewModels;
public class ExportOptionsViewModel : ViewModel
{
public bool OverrideOptions
{
get;
set => SetProperty(ref field, value);
}
private DispatcherTimer? _feedbackTimer;
public string? FeedbackMessage
{
get;
private set
{
if (!SetProperty(ref field, value)) return;
RaisePropertyChanged(nameof(HasFeedback));
_feedbackTimer?.Stop();
if (string.IsNullOrWhiteSpace(value)) return;
if (_feedbackTimer == null)
{
_feedbackTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
#pragma warning disable CA2011
_feedbackTimer.Tick += (_, _) => FeedbackMessage = null;
#pragma warning restore CA2011
}
_feedbackTimer.Start();
}
}
public bool HasFeedback => FeedbackMessage != null;
public string OutputDirectory
{
get;
set => SetProperty(ref field, value);
}
public bool ShowExportImmediatelyOption { get; }
public bool ExportImmediately
{
get;
set => SetProperty(ref field, value);
}
public IEnumerable<EMeshFormat> MeshFormats { get; } = Enum.GetValues<EMeshFormat>();
public EMeshFormat SelectedMeshFormat
{
get;
set
{
if (!SetProperty(ref field, value)) return;
RaisePropertyChanged(nameof(CompressionSettingsEnabled));
RaisePropertyChanged(nameof(TextureFormatsEnabled));
if (value == EMeshFormat.USD)
{
_preUsdTextureFormat = SelectedTextureFormat;
SelectedTextureFormat = ETextureFormat.Png;
}
else if (_preUsdTextureFormat.HasValue)
{
SelectedTextureFormat = _preUsdTextureFormat.Value;
_preUsdTextureFormat = null;
}
}
}
public IEnumerable<ENaniteMeshFormat> NaniteMeshFormats { get; } = Enum.GetValues<ENaniteMeshFormat>();
public ENaniteMeshFormat SelectedNaniteMeshFormat
{
get;
set
{
if (!SetProperty(ref field, value)) return;
RaisePropertyChanged(nameof(ShowNaniteWarning));
}
}
public bool ShowNaniteWarning => SelectedNaniteMeshFormat != ENaniteMeshFormat.NoNanite;
public IEnumerable<EMeshQuality> MeshQualities { get; } = Enum.GetValues<EMeshQuality>();
public EMeshQuality SelectedMeshQuality
{
get;
set => SetProperty(ref field, value);
}
public IEnumerable<ESocketFormat> SocketFormats { get; } = Enum.GetValues<ESocketFormat>();
public ESocketFormat SelectedSocketFormat
{
get;
set => SetProperty(ref field, value);
}
public IEnumerable<EFileCompressionFormat> CompressionFormats { get; } = Enum.GetValues<EFileCompressionFormat>();
public EFileCompressionFormat SelectedCompressionFormat
{
get;
set => SetProperty(ref field, value);
}
public bool CompressionSettingsEnabled => SelectedMeshFormat == EMeshFormat.UEFormat;
public IEnumerable<EMaterialDepth> MaterialDepths { get; } = Enum.GetValues<EMaterialDepth>();
public EMaterialDepth SelectedMaterialDepth
{
get;
set => SetProperty(ref field, value);
}
public bool ExportMaterials
{
get;
set => SetProperty(ref field, value);
}
public IEnumerable<ETexturePlatform> TexturePlatforms { get; } = Enum.GetValues<ETexturePlatform>();
public ETexturePlatform SelectedTexturePlatform
{
get;
set => SetProperty(ref field, value);
}
public IEnumerable<ETextureFormat> TextureFormats { get; } = Enum.GetValues<ETextureFormat>();
public ETextureFormat SelectedTextureFormat
{
get;
set => SetProperty(ref field, value);
}
private ETextureFormat? _preUsdTextureFormat;
public bool TextureFormatsEnabled => SelectedMeshFormat != EMeshFormat.USD;
public bool ExportHdrTexturesAsHdr
{
get;
set => SetProperty(ref field, value);
}
public int TextureQuality
{
get;
set => SetProperty(ref field, value);
}
public bool ExportMorphTargets
{
get;
set => SetProperty(ref field, value);
}
public bool ExportAllTextureMips
{
get;
set => SetProperty(ref field, value);
}
public ExportOptionsViewModel(bool showExportImmediatelyOption = false)
{
ShowExportImmediatelyOption = showExportImmediatelyOption;
ResetToUserDefaults();
}
public void ResetToUserDefaults()
{
OutputDirectory = UserSettings.Default.ModelDirectory;
SelectedMeshFormat = UserSettings.Default.MeshExportFormat;
SelectedNaniteMeshFormat = UserSettings.Default.NaniteMeshExportFormat;
SelectedMeshQuality = UserSettings.Default.MeshQuality;
SelectedSocketFormat = UserSettings.Default.SocketExportFormat;
SelectedCompressionFormat = UserSettings.Default.CompressionFormat;
SelectedMaterialDepth = UserSettings.Default.MaterialExportFormat;
ExportMaterials = UserSettings.Default.SaveEmbeddedMaterials;
SelectedTexturePlatform = UserSettings.Default.CurrentDir.TexturePlatform;
SelectedTextureFormat = UserSettings.Default.TextureExportFormat;
ExportHdrTexturesAsHdr = UserSettings.Default.SaveHdrTexturesAsHdr;
ExportMorphTargets = UserSettings.Default.SaveMorphTargets;
TextureQuality = UserSettings.Default.TextureQuality;
ExportAllTextureMips = UserSettings.Default.ExportAllTextureMips;
ExportImmediately = UserSettings.Default.ExportImmediately;
OverrideOptions = false;
FeedbackMessage = "Reset to defaults";
}
public void SaveAsUserDefaults()
{
UserSettings.Default.ModelDirectory = OutputDirectory;
UserSettings.Default.MeshExportFormat = SelectedMeshFormat;
UserSettings.Default.NaniteMeshExportFormat = SelectedNaniteMeshFormat;
UserSettings.Default.MeshQuality = SelectedMeshQuality;
UserSettings.Default.SocketExportFormat = SelectedSocketFormat;
UserSettings.Default.CompressionFormat = SelectedCompressionFormat;
UserSettings.Default.MaterialExportFormat = SelectedMaterialDepth;
UserSettings.Default.SaveEmbeddedMaterials = ExportMaterials;
UserSettings.Default.CurrentDir.TexturePlatform = SelectedTexturePlatform;
UserSettings.Default.TextureExportFormat = SelectedTextureFormat;
UserSettings.Default.SaveHdrTexturesAsHdr = ExportHdrTexturesAsHdr;
UserSettings.Default.SaveMorphTargets = ExportMorphTargets;
UserSettings.Default.TextureQuality = TextureQuality;
UserSettings.Default.ExportAllTextureMips = ExportAllTextureMips;
UserSettings.Default.ExportImmediately = ExportImmediately;
UserSettings.Save();
OverrideOptions = false;
FeedbackMessage = "Saved as default";
}
public ExportOptions BuildOptions() => new(
SelectedMeshFormat,
SelectedNaniteMeshFormat,
SelectedMeshQuality,
SelectedTexturePlatform,
SelectedTextureFormat,
TextureQuality,
ExportHdrTexturesAsHdr,
ExportAllTextureMips,
SelectedMaterialDepth,
ExportMaterials,
ExportMorphTargets,
SelectedSocketFormat,
SelectedCompressionFormat
);
}