diff --git a/CUE4Parse b/CUE4Parse index 038f3736..f17ea8bb 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 038f373650a2e7b05506d10060fe79e136b23eb8 +Subproject commit f17ea8bbf946a8319758759118c1e46b863eab33 diff --git a/FModel/Creator/Bases/FN/BaseCommunity.cs b/FModel/Creator/Bases/FN/BaseCommunity.cs index 9bda0742..78c2fe30 100644 --- a/FModel/Creator/Bases/FN/BaseCommunity.cs +++ b/FModel/Creator/Bases/FN/BaseCommunity.cs @@ -1,5 +1,4 @@ -using System.Linq; -using CUE4Parse.UE4.Assets.Exports; +using CUE4Parse.UE4.Assets.Exports; using CUE4Parse.UE4.Objects.GameplayTags; using CUE4Parse.UE4.Objects.UObject; using CUE4Parse.UE4.Versions; @@ -21,7 +20,6 @@ namespace FModel.Creator.Bases.FN private string _source; private string _season; private bool _lowerDrawn; - private bool _hasStyle; public BaseCommunity(UObject uObject, EIconStyle style, string designName) : base(uObject, style) { @@ -89,8 +87,9 @@ namespace FModel.Creator.Bases.FN Description += GetCosmeticSet(set.Text, _design.DrawSetShort); if (_design.DrawSeason && gameplayTags.TryGetGameplayTag("Cosmetics.Filter.Season.", out var season)) _season = GetCosmeticSeason(season.Text, _design.DrawSeasonShort); - if (gameplayTags.Any(x => x.Text.StartsWith("Cosmetics.UserFacingFlags."))) - _hasStyle = true; + + var triggers = _design.GameplayTags.DrawCustomOnly ? new[] {"Cosmetics.UserFacingFlags."} : new[] {"Cosmetics.UserFacingFlags.", "Homebase.Class.", "NPC.CharacterType.Survivor.Defender."}; + GetUserFacingFlags(gameplayTags.GetAllGameplayTags(triggers)); } private string GetCosmeticSet(string setName, bool bShort) @@ -291,7 +290,7 @@ namespace FModel.Creator.Bases.FN private void DrawUserFacingFlags(SKCanvas c, bool customOnly) { - if (!_hasStyle) return; + if (UserFacingFlags == null || UserFacingFlags.Count < 1) return; if (customOnly) { c.DrawBitmap(_design.GameplayTags.Custom, 0, 0, ImagePaint); diff --git a/FModel/Creator/Bases/FN/BaseIcon.cs b/FModel/Creator/Bases/FN/BaseIcon.cs index be861db1..6ecfce2b 100644 --- a/FModel/Creator/Bases/FN/BaseIcon.cs +++ b/FModel/Creator/Bases/FN/BaseIcon.cs @@ -23,7 +23,7 @@ namespace FModel.Creator.Bases.FN public SKBitmap SeriesBackground { get; protected set; } protected string ShortDescription { get; set; } protected string CosmeticSource { get; set; } - protected SKBitmap[] UserFacingFlags { get; set; } + protected Dictionary UserFacingFlags { get; set; } public BaseIcon(UObject uObject, EIconStyle style) : base(uObject, style) { @@ -269,24 +269,24 @@ namespace FModel.Creator.Bases.FN if (!itemCategories.TryGetValue(out FStructFallback[] tertiaryCategories, "TertiaryCategories")) return; - UserFacingFlags = new SKBitmap[userFacingFlags.Count]; - for (var i = 0; i < UserFacingFlags.Length; i++) + UserFacingFlags = new Dictionary(userFacingFlags.Count); + foreach (var flag in userFacingFlags) { - if (userFacingFlags[i].Equals("Cosmetics.UserFacingFlags.HasUpgradeQuests", StringComparison.OrdinalIgnoreCase)) + if (flag.Equals("Cosmetics.UserFacingFlags.HasUpgradeQuests", StringComparison.OrdinalIgnoreCase)) { if (Object.ExportType.Equals("AthenaPetCarrierItemDefinition", StringComparison.OrdinalIgnoreCase)) - UserFacingFlags[i] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Pets-64.png"))?.Stream); - else UserFacingFlags[i] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Quests-64.png"))?.Stream); + UserFacingFlags[flag] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Pets-64.png"))?.Stream); + else UserFacingFlags[flag] = SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/T-Icon-Quests-64.png"))?.Stream); } else { foreach (var category in tertiaryCategories) { - if (category.TryGetValue(out FGameplayTagContainer tagContainer, "TagContainer") && tagContainer.TryGetGameplayTag(userFacingFlags[i], out _) && + if (category.TryGetValue(out FGameplayTagContainer tagContainer, "TagContainer") && tagContainer.TryGetGameplayTag(flag, out _) && category.TryGetValue(out FStructFallback categoryBrush, "CategoryBrush") && categoryBrush.TryGetValue(out FStructFallback brushXxs, "Brush_XXS") && brushXxs.TryGetValue(out FPackageIndex resourceObject, "ResourceObject") && Utils.TryGetPackageIndexExport(resourceObject, out UTexture2D texture)) { - UserFacingFlags[i] = Utils.GetBitmap(texture); + UserFacingFlags[flag] = Utils.GetBitmap(texture); } } } @@ -299,7 +299,7 @@ namespace FModel.Creator.Bases.FN const int size = 25; var x = Margin * (int) 2.5; - foreach (var flag in UserFacingFlags) + foreach (var flag in UserFacingFlags.Values) { if (flag == null) continue; diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index fa1bbfe5..3c3dbaf5 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -78,8 +78,6 @@ - - @@ -170,8 +168,6 @@ - - diff --git a/FModel/Resources/city_pin.png b/FModel/Resources/city_pin.png deleted file mode 100644 index 1595e70b..00000000 Binary files a/FModel/Resources/city_pin.png and /dev/null differ diff --git a/FModel/Resources/pin.png b/FModel/Resources/pin.png deleted file mode 100644 index 502e2b56..00000000 Binary files a/FModel/Resources/pin.png and /dev/null differ diff --git a/FModel/ViewModels/MapViewerViewModel.cs b/FModel/ViewModels/MapViewerViewModel.cs index 13241050..adee6a51 100644 --- a/FModel/ViewModels/MapViewerViewModel.cs +++ b/FModel/ViewModels/MapViewerViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using System.Windows.Media.Imaging; using CUE4Parse.UE4.Assets.Exports; @@ -13,8 +14,15 @@ using SkiaSharp; namespace FModel.ViewModels { + public class MapLayer + { + public SKBitmap Layer; + public bool IsEnabled; + } + public class MapViewerViewModel : ViewModel { + private const string _FIRST_BITMAP = "mapBase"; private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView; private int _mapIndex = -1; @@ -48,13 +56,23 @@ namespace FModel.ViewModels get => _mapImage; set => SetProperty(ref _mapImage, value); } + private BitmapImage _layerImage; + public BitmapImage LayerImage + { + get => _layerImage; + set => SetProperty(ref _layerImage, value); + } - private readonly List[] _bitmaps; // first bitmap is the displayed map, others are overlays of the map + private readonly Dictionary[] _bitmaps; // first bitmap is the displayed map, others are overlays of the map private readonly CUE4ParseViewModel _cue4Parse; public MapViewerViewModel(CUE4ParseViewModel cue4Parse) { - _bitmaps = new[] {new List(), new List()}; + _bitmaps = new[] + { + new Dictionary(), + new Dictionary() + }; _cue4Parse = cue4Parse; } @@ -69,27 +87,35 @@ namespace FModel.ViewModels public BitmapImage GetImageToSave() { - var ret = new SKBitmap(_bitmaps[MapIndex][0].Width, _bitmaps[MapIndex][0].Height, SKColorType.Rgba8888, SKAlphaType.Premul); + var ret = new SKBitmap(_bitmaps[MapIndex][_FIRST_BITMAP].Layer.Width, _bitmaps[MapIndex][_FIRST_BITMAP].Layer.Height, SKColorType.Rgba8888, SKAlphaType.Premul); using var c = new SKCanvas(ret); - c.DrawBitmap(_bitmaps[MapIndex][0], 0, 0); + foreach (var layer in _bitmaps[MapIndex].Values.Where(layer => layer.IsEnabled)) + { + c.DrawBitmap(layer.Layer, 0, 0); + } return GetImageSource(ret); } - protected override bool SetProperty(ref T storage, T value, string propertyName = null) + public async Task GenericToggle(string key, bool enabled) { - var ret = base.SetProperty(ref storage, value, propertyName); - CheckForStuffToDraw(propertyName); - return ret; + if (_bitmaps[MapIndex].TryGetValue(key, out var layer) && layer.Layer != null) + { + layer.IsEnabled = enabled; + } + else // load layer + { + switch (key) + { + + } + } } - private async void CheckForStuffToDraw(string propertyName = null) + protected override bool SetProperty(ref T storage, T value, string propertyName = null) // don't delete, else nothing will update for some reason { - switch (propertyName) - { - - } + return base.SetProperty(ref storage, value, propertyName); } private BitmapImage GetImageSource(SKBitmap bitmap) @@ -120,14 +146,14 @@ namespace FModel.ViewModels private FVector2D GetMapPosition(FVector vector) { - var nx = (vector.Y + _mapRadius) / (_mapRadius * 2) * _bitmaps[MapIndex][0].Width; - var ny = (1 - (vector.X + _mapRadius) / (_mapRadius * 2)) * _bitmaps[MapIndex][0].Height; + var nx = (vector.Y + _mapRadius) / (_mapRadius * 2) * _bitmaps[MapIndex][_FIRST_BITMAP].Layer.Width; + var ny = (1 - (vector.X + _mapRadius) / (_mapRadius * 2)) * _bitmaps[MapIndex][_FIRST_BITMAP].Layer.Height; return new FVector2D(nx, ny); } private async Task LoadBrMiniMap() { - if (_bitmaps[0].Count > 0) return; + if (_bitmaps[0].TryGetValue(_FIRST_BITMAP, out var layer) && layer.Layer != null) return; await _threadWorkerView.Begin(_ => { if (!Utils.TryLoadObject("FortniteGame/Content/UI/IngameMap/UIMapManagerBR.Default__UIMapManagerBR_C", out UObject mapManager) || @@ -136,22 +162,22 @@ namespace FModel.ViewModels !cachedExpressionData.TryGetValue(out FStructFallback parameters, "Parameters") || !parameters.TryGetValue(out UTexture2D[] textureValues, "TextureValues")) return; - _bitmaps[0].Add(Utils.GetBitmap(textureValues[0])); - _brMiniMapImage = GetImageSource(_bitmaps[0][0]); + _bitmaps[0][_FIRST_BITMAP] = new MapLayer{Layer = Utils.GetBitmap(textureValues[0]), IsEnabled = true}; + _brMiniMapImage = GetImageSource(_bitmaps[0][_FIRST_BITMAP].Layer); }); } private async Task LoadPrMiniMap() { - if (_bitmaps[1].Count > 0) return; + if (_bitmaps[1].TryGetValue(_FIRST_BITMAP, out var layer) && layer.Layer != null) return; await _threadWorkerView.Begin(_ => { if (!Utils.TryLoadObject("FortniteGame/Content/UI/IngameMap/UIMapManagerPapaya.Default__UIMapManagerPapaya_C", out UObject mapManager) || !mapManager.TryGetValue(out UMaterial mapMaterial, "MapMaterial") || mapMaterial.ReferencedTextures.Count < 1) return; - _bitmaps[1].Add(Utils.GetBitmap(mapMaterial.ReferencedTextures[0] as UTexture2D)); - _prMiniMapImage = GetImageSource(_bitmaps[1][0]); + _bitmaps[1][_FIRST_BITMAP] = new MapLayer{Layer = Utils.GetBitmap(mapMaterial.ReferencedTextures[0] as UTexture2D), IsEnabled = true}; + _prMiniMapImage = GetImageSource(_bitmaps[1][_FIRST_BITMAP].Layer); }); } } diff --git a/FModel/Views/MapViewer.xaml b/FModel/Views/MapViewer.xaml index d31bee9a..b3097de6 100644 --- a/FModel/Views/MapViewer.xaml +++ b/FModel/Views/MapViewer.xaml @@ -22,23 +22,23 @@ - - - + + + - - - - - - - - - - + + + + + + + + + + @@ -99,6 +99,8 @@ + diff --git a/FModel/Views/MapViewer.xaml.cs b/FModel/Views/MapViewer.xaml.cs index 16da3b4b..74507a26 100644 --- a/FModel/Views/MapViewer.xaml.cs +++ b/FModel/Views/MapViewer.xaml.cs @@ -74,5 +74,11 @@ namespace FModel.Views break; } } + + private async void ToggleOnChange(object sender, RoutedEventArgs e) + { + if (sender is not CheckBox checkBox) return; + await _applicationView.MapViewer.GenericToggle(checkBox.Content.ToString(), checkBox.IsChecked ?? true); + } } } \ No newline at end of file diff --git a/FModel/Views/SettingsView.xaml b/FModel/Views/SettingsView.xaml index ad88f3a7..7888f2bb 100644 --- a/FModel/Views/SettingsView.xaml +++ b/FModel/Views/SettingsView.xaml @@ -45,11 +45,11 @@ - +