Skip to content

Commit b9315cc

Browse files
Masusder4sval
andauthored
'The Dark Pictures Anthology: House of Ashes' Wwise support (#632)
* 'The Dark Pictures Anthology: House of Ashes' Wwise support * AnyItemMeetsConditionConverter.ConditionMode --------- Co-authored-by: Asval <asval.contactme@gmail.com>
1 parent 86ec2a9 commit b9315cc

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

FModel/ViewModels/CUE4ParseViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using CUE4Parse.FileProvider.Vfs;
2020
using CUE4Parse.GameTypes.Aion2.Objects;
2121
using CUE4Parse.GameTypes.AshEchoes.FileProvider;
22+
using CUE4Parse.GameTypes.DPA.UE4.Assets.Exports.Wwise;
2223
using CUE4Parse.GameTypes.KRD.Assets.Exports;
2324
using CUE4Parse.MappingsProvider;
2425
using CUE4Parse.UE4.AssetRegistry;
@@ -1060,6 +1061,13 @@ public void ExtractAndScroll(CancellationToken cancellationToken, string fullPat
10601061

10611062
TabControl.SelectedTab.AddImage(sourceFile.SubstringAfterLast('/'), false, bitmap, false, updateUi);
10621063
return false;
1064+
}
1065+
// The Dark Pictures Anthology: House of Ashes
1066+
case UExternalSource when (isNone || saveAudio) && pointer.Object.Value is UExternalSource externalSource:
1067+
{
1068+
var audioName = Path.GetFileNameWithoutExtension(externalSource.ExternalSourcePath);
1069+
SaveAndPlaySound(audioName, "wem", externalSource.Data?.WemFile ?? [], saveAudio);
1070+
return false;
10631071
}
10641072
case UAkAudioEvent when (isNone || saveAudio) && pointer.Object.Value is UAkAudioEvent audioEvent:
10651073
{

FModel/ViewModels/GameFileViewModel.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Windows.Media;
77
using System.Windows.Media.Imaging;
88
using CUE4Parse.FileProvider.Objects;
9+
using CUE4Parse.GameTypes.DPA.UE4.Assets.Exports.Wwise;
910
using CUE4Parse.GameTypes.FN.Assets.Exports.DataAssets;
1011
using CUE4Parse.UE4.Assets;
1112
using CUE4Parse.UE4.Assets.Exports.Animation;
@@ -200,7 +201,8 @@ private Task ResolveByPackageAsync(EResolveCompute resolve)
200201
UCurveBase => EAssetCategory.CurveBase,
201202

202203
UWwiseAssetLibrary or USoundBase or UAkMediaAssetData or UAtomWaveBank or USoundAtomCue
203-
or UAtomCueSheet or USoundAtomCueSheet or UFMODBank or UFMODEvent or UAkAudioType => EAssetCategory.Audio,
204+
or UAtomCueSheet or USoundAtomCueSheet or UFMODBank or UFMODEvent or UAkAudioType
205+
or UExternalSource or UExternalSourceBank => EAssetCategory.Audio,
204206
UFileMediaSource => EAssetCategory.Video,
205207
UFont or UFontFace => EAssetCategory.Font,
206208

FModel/Views/Resources/Controls/ContextMenus/FileContextMenu.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,10 @@
157157
<MenuItem.IsEnabled>
158158
<Binding Path="PlacementTarget.SelectedItems" RelativeSource="{RelativeSource AncestorType=ContextMenu}">
159159
<Binding.Converter>
160-
<converters:AnyItemMeetsConditionConverter>
160+
<converters:AnyItemMeetsConditionConverter ConditionMode="Or">
161161
<converters:AnyItemMeetsConditionConverter.Conditions>
162162
<converters:ItemCategoryCondition Category="Texture" />
163+
<converters:ItemCategoryCondition Category="ItemDefinitionBase" />
163164
</converters:AnyItemMeetsConditionConverter.Conditions>
164165
</converters:AnyItemMeetsConditionConverter>
165166
</Binding.Converter>

FModel/Views/Resources/Converters/AnyItemMeetsConditionConverter.cs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,36 @@ public class AnyItemMeetsConditionConverter : IValueConverter
1414
{
1515
public Collection<IItemCondition> Conditions { get; } = [];
1616

17+
/// <summary>
18+
/// Determines how multiple conditions are evaluated. Default is 'And'.
19+
/// </summary>
20+
public EConditionMode ConditionMode { get; set; } = EConditionMode.And;
21+
1722
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1823
{
1924
if (value is not IEnumerable items || Conditions.Count == 0)
2025
return false;
2126

22-
return items.OfType<GameFileViewModel>().Any(item => Conditions.All(c => c.Matches(item)));
27+
Func<GameFileViewModel, bool> predicate = ConditionMode switch
28+
{
29+
EConditionMode.And => item => Conditions.All(condition => condition.Matches(item)),
30+
EConditionMode.Or => item => Conditions.Any(condition => condition.Matches(item)),
31+
_ => throw new ArgumentOutOfRangeException()
32+
};
33+
34+
return items.OfType<GameFileViewModel>().Any(predicate);
2335
}
2436

2537
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
2638
{
2739
throw new NotImplementedException();
2840
}
41+
42+
public enum EConditionMode
43+
{
44+
And,
45+
Or
46+
}
2947
}
3048

3149
public interface IItemCondition
@@ -39,7 +57,16 @@ public class ItemCategoryCondition : IItemCondition
3957

4058
public bool Matches(GameFileViewModel item)
4159
{
42-
return item != null && item.AssetCategory.IsOfCategory(Category);
60+
if (item == null) return false;
61+
62+
// if the specified category is a base category, check if the item's category is derived from it
63+
if (Category.IsBaseCategory())
64+
{
65+
return item.AssetCategory.IsOfCategory(Category);
66+
}
67+
68+
// if the specified category is a targeted non-base category, check for exact match
69+
return item.AssetCategory == Category;
4370
}
4471
}
4572

0 commit comments

Comments
 (0)