FModel v4.0.0.1

This commit is contained in:
iAmAsval 2021-05-25 19:10:55 +02:00
parent eecc708cba
commit a86de258b3
14 changed files with 78 additions and 33 deletions

@ -1 +1 @@
Subproject commit c2535e18b0dd26c8173c73ba26f58d0c55afc0b8
Subproject commit 70d417009d729260486d905eb5d10f45c78cfec7

View File

@ -80,6 +80,7 @@ namespace FModel
Icon = MessageBoxImage.Error,
Buttons = new[]
{
MessageBoxButtons.Custom("Reset Settings", EErrorKind.ResetSettings),
MessageBoxButtons.Custom("Restart", EErrorKind.Restart),
MessageBoxButtons.Custom("OK", EErrorKind.Ignore)
},
@ -89,6 +90,9 @@ namespace FModel
MessageBox.Show(messageBox);
if (messageBox.Result == MessageBoxResult.Custom && (EErrorKind) messageBox.ButtonPressed.Id != EErrorKind.Ignore)
{
if ((EErrorKind) messageBox.ButtonPressed.Id == EErrorKind.ResetSettings)
UserSettings.Delete();
ApplicationService.ApplicationView.Restart();
}

View File

@ -61,7 +61,7 @@ namespace FModel.Creator.Bases.FN
if (Object.TryGetValue(out FText shortDescription, "ShortDescription", "UIDisplaySubName"))
ShortDescription = shortDescription.Text;
else if (Object.ExportType.Equals("AthenaItemWrapDefinition", StringComparison.OrdinalIgnoreCase))
ShortDescription = "Wrap";
ShortDescription = Utils.GetLocalizedResource("Fort.Cosmetics", "ItemWrapShortDescription", "Wrap");
// Only works on non-cataba designs
if (Object.TryGetValue(out FStructFallback eventArrowColor, "EventArrowColor") &&

View File

@ -11,9 +11,9 @@ namespace FModel
public enum EErrorKind
{
Close,
Ignore,
Restart
Restart,
ResetSettings
}
public enum SettingsOut

View File

@ -6,8 +6,8 @@
<UseWPF>true</UseWPF>
<ApplicationIcon>FModel.ico</ApplicationIcon>
<Version>4.0.0</Version>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<FileVersion>4.0.0.0</FileVersion>
<AssemblyVersion>4.0.0.1</AssemblyVersion>
<FileVersion>4.0.0.1</FileVersion>
<IsPackable>false</IsPackable>
<IsPublishable>true</IsPublishable>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

View File

@ -29,6 +29,11 @@ namespace FModel.Settings
File.WriteAllText(FilePath, JsonConvert.SerializeObject(Default, Formatting.Indented));
}
public static void Delete()
{
if (File.Exists(FilePath)) File.Delete(FilePath);
}
private string _outputDirectory;
public string OutputDirectory
{

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.IO;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using FModel.ViewModels.ApiEndpoints.Models;
@ -16,7 +15,7 @@ namespace FModel.ViewModels.ApiEndpoints
public async Task<AesResponse> GetAesKeysAsync(CancellationToken token)
{
var request = new RestRequest("https://benbotfn.tk/api/v2/aes", Method.GET)
var request = new RestRequest("https://benbot.app/api/v2/aes", Method.GET)
{
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
};
@ -32,7 +31,7 @@ namespace FModel.ViewModels.ApiEndpoints
public async Task<MappingsResponse[]> GetMappingsAsync(CancellationToken token)
{
var request = new RestRequest("https://benbotfn.tk/api/v1/mappings", Method.GET)
var request = new RestRequest("https://benbot.app/api/v1/mappings", Method.GET)
{
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
};

View File

@ -53,17 +53,17 @@ namespace FModel.ViewModels.ApiEndpoints
return _infos ?? GetInfosAsync(token, updateMode).GetAwaiter().GetResult();
}
public async Task<Backup[]> GetBackupsAsync(CancellationToken token, FGame game)
public async Task<Backup[]> GetBackupsAsync(CancellationToken token, string gameName)
{
var request = new RestRequest($"https://api.fmodel.app/v1/backups/{game}", Method.GET);
var request = new RestRequest($"https://api.fmodel.app/v1/backups/{gameName}", Method.GET);
var response = await _client.ExecuteAsync<Backup[]>(request, token).ConfigureAwait(false);
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, request.Resource);
return response.Data;
}
public Backup[] GetBackups(CancellationToken token, FGame game)
public Backup[] GetBackups(CancellationToken token, string gameName)
{
return _backups ??= GetBackupsAsync(token, game).GetAwaiter().GetResult();
return _backups ??= GetBackupsAsync(token, gameName).GetAwaiter().GetResult();
}
public async Task<CommunityDesign> GetDesignAsync(string designName)

View File

@ -23,7 +23,7 @@ namespace FModel.ViewModels
private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
private ApiEndpointViewModel _apiEndpointView => ApplicationService.ApiEndpointView;
private ApplicationViewModel _applicationView => ApplicationService.ApplicationView;
private readonly FGame _game;
private readonly string _gameName;
private Backup _selectedBackup;
public Backup SelectedBackup
@ -35,9 +35,9 @@ namespace FModel.ViewModels
public ObservableCollection<Backup> Backups { get; }
public ICollectionView BackupsView { get; }
public BackupManagerViewModel(FGame game)
public BackupManagerViewModel(string gameName)
{
_game = game;
_gameName = gameName;
Backups = new ObservableCollection<Backup>();
BackupsView = new ListCollectionView(Backups) {SortDescriptions = {new SortDescription("FileName", ListSortDirection.Ascending)}};
}
@ -46,7 +46,7 @@ namespace FModel.ViewModels
{
await _threadWorkerView.Begin(cancellationToken =>
{
var backups = _apiEndpointView.FModelApi.GetBackups(cancellationToken, _game);
var backups = _apiEndpointView.FModelApi.GetBackups(cancellationToken, _gameName);
if (backups == null) return;
Application.Current.Dispatcher.Invoke(() =>
@ -62,7 +62,7 @@ namespace FModel.ViewModels
await _threadWorkerView.Begin(_ =>
{
var backupFolder = Path.Combine(UserSettings.Default.OutputDirectory, "Backups");
var fileName = $"{_game}_{DateTime.Now:MMddyyyy}.fbkp";
var fileName = $"{_gameName}_{DateTime.Now:MMddyyyy}.fbkp";
var fullPath = Path.Combine(backupFolder, fileName);
using var fileStream = new FileStream(fullPath, FileMode.Create);

View File

@ -24,7 +24,7 @@ namespace FModel.ViewModels.Commands
Helper.OpenWindow<AdonisWindow>("AES Manager", () => new AesManager().Show());
break;
case "Directory_Backup":
Helper.OpenWindow<AdonisWindow>("Backup Manager", () => new BackupManager(contextViewModel.CUE4Parse.Game).Show());
Helper.OpenWindow<AdonisWindow>("Backup Manager", () => new BackupManager(contextViewModel.CUE4Parse.Provider.GameName).Show());
break;
case "Views_AudioPlayer":
Helper.OpenWindow<AdonisWindow>("Audio Player", () => new AudioPlayer().Show());

View File

@ -28,6 +28,13 @@ namespace FModel.ViewModels
get => _showCities;
set => SetProperty(ref _showCities, value, nameof(ShowCities));
}
private bool _showLandmarks;
public bool ShowLandmarks
{
get => _showLandmarks;
set => SetProperty(ref _showLandmarks, value, nameof(ShowLandmarks));
}
private bool _showPatrolPaths;
public bool ShowPatrolPaths
@ -49,6 +56,13 @@ namespace FModel.ViewModels
get => _citiesImage;
set => SetProperty(ref _citiesImage, value);
}
private BitmapImage _landmarksImage;
public BitmapImage LandmarksImage
{
get => _landmarksImage;
set => SetProperty(ref _landmarksImage, value);
}
private BitmapImage _patrolPathImage;
public BitmapImage PatrolPathImage
@ -81,6 +95,8 @@ namespace FModel.ViewModels
c.DrawBitmap(_mapBitmap, 0, 0);
if (ShowCities)
c.DrawBitmap(_citiesBitmap, 0, 0);
if (ShowLandmarks)
c.DrawBitmap(_landmarksBitmap, 0, 0);
if (ShowPatrolPaths)
c.DrawBitmap(_patrolPathBitmap, 0, 0);
@ -98,7 +114,12 @@ namespace FModel.ViewModels
{
switch (propertyName)
{
case nameof(ShowCities) when _citiesBitmap == null && _mapBitmap != null:
case nameof(ShowCities) when _citiesBitmap == null && _landmarksBitmap == null && _mapBitmap != null:
{
await LoadCities();
break;
}
case nameof(ShowLandmarks) when _landmarksBitmap == null && _citiesBitmap == null && _mapBitmap != null:
{
await LoadCities();
break;
@ -127,6 +148,7 @@ namespace FModel.ViewModels
private const int WorldRadius = 135000;
private SKBitmap _mapBitmap;
private SKBitmap _citiesBitmap;
private SKBitmap _landmarksBitmap;
private SKBitmap _patrolPathBitmap;
private readonly SKBitmap _pinBitmap =
SKBitmap.Decode(Application.GetResourceStream(new Uri("pack://application:,,,/Resources/pin.png"))?.Stream);
@ -141,7 +163,7 @@ namespace FModel.ViewModels
private readonly SKPaint _pathPaint = new()
{
IsAntialias = true, FilterQuality = SKFilterQuality.High, IsStroke = true,
Style = SKPaintStyle.Stroke, StrokeWidth = 5, Color = SKColors.Red,
Style = SKPaintStyle.Stroke, StrokeWidth = 10, Color = SKColors.Red,
ImageFilter = SKImageFilter.CreateDropShadow(4, 4, 8, 8, SKColors.Black)
};
@ -173,27 +195,38 @@ namespace FModel.ViewModels
await _threadWorkerView.Begin(_ =>
{
_citiesBitmap = new SKBitmap(_mapBitmap.Width, _mapBitmap.Height, SKColorType.Rgba8888, SKAlphaType.Premul);
using var c = new SKCanvas(_citiesBitmap);
_landmarksBitmap = new SKBitmap(_mapBitmap.Width, _mapBitmap.Height, SKColorType.Rgba8888, SKAlphaType.Premul);
using var cities = new SKCanvas(_citiesBitmap);
using var landmarks = new SKCanvas(_landmarksBitmap);
if (Utils.TryLoadObject("FortniteGame/Content/Quests/QuestIndicatorData", out UObject indicatorData) &&
indicatorData.TryGetValue(out FStructFallback[] challengeMapPoiData, "ChallengeMapPoiData"))
{
foreach (var poiData in challengeMapPoiData)
{
if (!poiData.TryGetValue(out FSoftObjectPath discoveryQuest, "DiscoveryQuest") ||
!poiData.TryGetValue(out FText text, "Text") ||
!poiData.TryGetValue(out FVector worldLocation, "WorldLocation") ||
discoveryQuest.AssetPathName.Text.Contains("Landmarks")) continue;
!poiData.TryGetValue(out FText text, "Text") || string.IsNullOrEmpty(text.Text) ||
!poiData.TryGetValue(out FVector worldLocation, "WorldLocation")) continue;
var shaper = new CustomSKShaper(_imagePaint.Typeface);
var shapedText = shaper.Shape(text.Text, _imagePaint);
var vector = GetMapPosition(worldLocation);
c.DrawPoint(vector.X, vector.Y, _pathPaint);
c.DrawBitmap(_cityPinBitmap, vector.X - 50, vector.Y - 90, _imagePaint);
c.DrawShapedText(shaper, text.Text, vector.X - shapedText.Points[^1].X / 2, vector.Y - 12.5F, _imagePaint);
if (discoveryQuest.AssetPathName.Text.Contains("landmarks", StringComparison.OrdinalIgnoreCase))
{
landmarks.DrawPoint(vector.X, vector.Y, _pathPaint);
landmarks.DrawShapedText(shaper, text.Text, vector.X - shapedText.Points[^1].X / 2, vector.Y - 12.5F, _imagePaint);
}
else
{
cities.DrawPoint(vector.X, vector.Y, _pathPaint);
cities.DrawBitmap(_cityPinBitmap, vector.X - 50, vector.Y - 90, _imagePaint);
cities.DrawShapedText(shaper, text.Text, vector.X - shapedText.Points[^1].X / 2, vector.Y - 12.5F, _imagePaint);
}
}
}
CitiesImage = GetImageSource(_citiesBitmap);
LandmarksImage = GetImageSource(_landmarksBitmap);
});
}

View File

@ -41,7 +41,7 @@
<TextBlock Text="&#09;&#09;&#09;&#09;" FontSize="25" FontWeight="700" Height="2" Foreground="Transparent" HorizontalAlignment="Center" />
</StackPanel>
<TextBlock FontSize="12" Foreground="#727272" TextWrapping="Wrap" Margin="0 0 0 30"
Text="Maiky &#x2665;, HYPEX &#x2665;, VenomLeaks &#x2665;, JayKey &#x2665;, Fevers &#x2665;, Netu &#x2665;, TheGameVlog &#x2665;, Quentin &#x2665;, Mikey, kyle, Yanteh, Shiina, SexyNutella, Alexander, Jinx, Tector, s0ll, imatrix, LamZykoss, Frenzy Leaks, LlamaLeaks, XTigerHyperX, FunGames, WeLoveFortnite." />
Text="Maiky &#x2665;, HYPEX &#x2665;, VenomLeaks &#x2665;, JayKey &#x2665;, Fevers &#x2665;, Netu &#x2665;, TheGameVlog &#x2665;, Quentin &#x2665;, Laggy &#x2665;, s0ll &#x2665;, RazTracker, Mikey, kyle, Yanteh, Shiina, SexyNutella, Alexander, Jinx, Tector, imatrix, LamZykoss, Frenzy Leaks, LlamaLeaks, XTigerHyperX, FunGames, WeLoveFortnite." />
<StackPanel HorizontalAlignment="Center">
<TextBlock Text="Powered by" FontSize="15" FontWeight="700" Foreground="#9DA3DD" FontStretch="Expanded" />

View File

@ -7,9 +7,9 @@ namespace FModel.Views
{
private readonly BackupManagerViewModel _viewModel;
public BackupManager(FGame game)
public BackupManager(string gameName)
{
DataContext = _viewModel = new BackupManagerViewModel(game);
DataContext = _viewModel = new BackupManagerViewModel(gameName);
InitializeComponent();
}

View File

@ -29,6 +29,8 @@
<StackPanel Grid.Column="0" VerticalAlignment="Center" Margin="50">
<CheckBox Content="Show Cities" IsEnabled="{Binding IsReady}" IsChecked="{Binding MapViewer.ShowCities, Mode=TwoWay}"
Margin="0 0 0 10" Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
<CheckBox Content="Show Landmarks" IsEnabled="{Binding IsReady}" IsChecked="{Binding MapViewer.ShowLandmarks, Mode=TwoWay}"
Margin="0 0 0 10" Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
<CheckBox Content="Show Patrol Paths" IsEnabled="{Binding IsReady}" IsChecked="{Binding MapViewer.ShowPatrolPaths, Mode=TwoWay}"
Margin="0 0 0 10" Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" />
<Button Content="Save Image" IsEnabled="{Binding IsReady}" Click="OnClick" />
@ -43,6 +45,8 @@
Visibility="{Binding IsReady, Converter={StaticResource BoolToVisibilityConverter}}" />
<Image UseLayoutRounding="True" Source="{Binding MapViewer.CitiesImage}" HorizontalAlignment="Right" VerticalAlignment="Center"
Visibility="{Binding MapViewer.ShowCities, Converter={StaticResource BoolToVisibilityConverter}}" />
<Image UseLayoutRounding="True" Source="{Binding MapViewer.LandmarksImage}" HorizontalAlignment="Right" VerticalAlignment="Center"
Visibility="{Binding MapViewer.ShowLandmarks, Converter={StaticResource BoolToVisibilityConverter}}" />
<Image UseLayoutRounding="True" Source="{Binding MapViewer.PatrolPathImage}" HorizontalAlignment="Right" VerticalAlignment="Center"
Visibility="{Binding MapViewer.ShowPatrolPaths, Converter={StaticResource BoolToVisibilityConverter}}" />
</Grid>