mirror of
https://github.com/4sval/FModel.git
synced 2026-03-25 11:15:23 -05:00
upgrade
This commit is contained in:
parent
5a31f9662c
commit
d570e45cb2
|
|
@ -1 +1 @@
|
|||
Subproject commit d2d8fe2e3e9575fea5f18ce8e317ff62acaa66c7
|
||||
Subproject commit 0a98d821d8d0c93ead31bec576e27313efb2f9a5
|
||||
|
|
@ -107,21 +107,21 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="AdonisUI" Version="1.17.1" />
|
||||
<PackageReference Include="AdonisUI.ClassicTheme" Version="1.17.1" />
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.0" />
|
||||
<PackageReference Include="AvalonEdit" Version="6.1.2.30" />
|
||||
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.2" />
|
||||
<PackageReference Include="AvalonEdit" Version="6.1.3.50" />
|
||||
<PackageReference Include="CSCore" Version="1.2.1.2" />
|
||||
<PackageReference Include="DiscordRichPresence" Version="1.0.175" />
|
||||
<PackageReference Include="EpicManifestParser" Version="1.2.70-temp" />
|
||||
<PackageReference Include="HelixToolkit.SharpDX.Core.Wpf" Version="2.20.0" />
|
||||
<PackageReference Include="HelixToolkit.SharpDX.Core.Wpf" Version="2.21.0" />
|
||||
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.2.16" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NVorbis" Version="0.10.4" />
|
||||
<PackageReference Include="Oodle.NET" Version="1.0.1" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.0" />
|
||||
<PackageReference Include="RestSharp" Version="106.15.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="RestSharp" Version="108.0.1" />
|
||||
<PackageReference Include="Serilog" Version="2.11.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.80.3" />
|
||||
<PackageReference Include="SkiaSharp.HarfBuzz" Version="2.88.0" />
|
||||
<PackageReference Include="SkiaSharp.Svg" Version="1.60.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using RestSharp;
|
||||
using RestSharp.Serialization;
|
||||
using RestSharp.Serializers;
|
||||
|
||||
namespace FModel.Framework;
|
||||
|
||||
public class JsonNetSerializer : IRestSerializer
|
||||
public class JsonNetSerializer : IRestSerializer, ISerializer, IDeserializer
|
||||
{
|
||||
public static readonly JsonSerializerSettings SerializerSettings = new()
|
||||
{
|
||||
|
|
@ -15,28 +15,16 @@ public class JsonNetSerializer : IRestSerializer
|
|||
ContractResolver = new CamelCasePropertyNamesContractResolver()
|
||||
};
|
||||
|
||||
public string Serialize(object obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj);
|
||||
}
|
||||
public string Serialize(Parameter parameter) => JsonConvert.SerializeObject(parameter.Value);
|
||||
public string Serialize(object obj) => JsonConvert.SerializeObject(obj);
|
||||
public T Deserialize<T>(RestResponse response) => JsonConvert.DeserializeObject<T>(response.Content!, SerializerSettings);
|
||||
|
||||
[Obsolete]
|
||||
public string Serialize(Parameter parameter)
|
||||
{
|
||||
return JsonConvert.SerializeObject(parameter.Value);
|
||||
}
|
||||
public ISerializer Serializer => this;
|
||||
public IDeserializer Deserializer => this;
|
||||
|
||||
public T Deserialize<T>(IRestResponse response)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(response.Content, SerializerSettings);
|
||||
}
|
||||
|
||||
public string[] SupportedContentTypes { get; } =
|
||||
{
|
||||
"application/json", "application/json; charset=UTF-8"
|
||||
};
|
||||
|
||||
public string ContentType { get; set; } = "application/json; charset=UTF-8";
|
||||
public string ContentType { get; set; } = "application/json";
|
||||
public string[] AcceptedContentTypes => RestSharp.Serializers.ContentType.JsonAccept;
|
||||
public SupportsContentType SupportsContentType => contentType => contentType.EndsWith("json", StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
public DataFormat DataFormat => DataFormat.Json;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ namespace FModel.ViewModels;
|
|||
|
||||
public class ApiEndpointViewModel
|
||||
{
|
||||
private readonly IRestClient _client = new RestClient
|
||||
private readonly RestClient _client = new RestClient
|
||||
{
|
||||
UserAgent = $"FModel/{Constants.APP_VERSION}",
|
||||
Timeout = 3 * 1000
|
||||
Options =
|
||||
{
|
||||
UserAgent = $"FModel/{Constants.APP_VERSION}",
|
||||
MaxTimeout = 3 * 1000
|
||||
}
|
||||
}.UseSerializer<JsonNetSerializer>();
|
||||
|
||||
public FortniteApiEndpoint FortniteApi { get; }
|
||||
|
|
@ -26,4 +29,4 @@ public class ApiEndpointViewModel
|
|||
EpicApi = new EpicApiEndpoint(_client);
|
||||
FModelApi = new FModelApi(_client);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@ namespace FModel.ViewModels.ApiEndpoints;
|
|||
|
||||
public abstract class AbstractApiProvider
|
||||
{
|
||||
protected readonly IRestClient _client;
|
||||
protected readonly RestClient _client;
|
||||
|
||||
protected AbstractApiProvider(IRestClient client)
|
||||
protected AbstractApiProvider(RestClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ namespace FModel.ViewModels.ApiEndpoints;
|
|||
|
||||
public class BenbotApiEndpoint : AbstractApiProvider
|
||||
{
|
||||
public BenbotApiEndpoint(IRestClient client) : base(client)
|
||||
public BenbotApiEndpoint(RestClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<AesResponse> GetAesKeysAsync(CancellationToken token)
|
||||
{
|
||||
var request = new RestRequest("https://benbot.app/api/v2/aes", Method.GET)
|
||||
var request = new RestRequest("https://benbot.app/api/v2/aes")
|
||||
{
|
||||
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
|
||||
};
|
||||
|
|
@ -32,7 +32,7 @@ public class BenbotApiEndpoint : AbstractApiProvider
|
|||
|
||||
public async Task<MappingsResponse[]> GetMappingsAsync(CancellationToken token)
|
||||
{
|
||||
var request = new RestRequest("https://benbot.app/api/v1/mappings", Method.GET)
|
||||
var request = new RestRequest("https://benbot.app/api/v1/mappings")
|
||||
{
|
||||
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
|
||||
};
|
||||
|
|
@ -48,7 +48,7 @@ public class BenbotApiEndpoint : AbstractApiProvider
|
|||
|
||||
public async Task<Dictionary<string, Dictionary<string, string>>> GetHotfixesAsync(CancellationToken token, string language = "en-US")
|
||||
{
|
||||
var request = new RestRequest("https://benbot.app/api/v1/hotfixes", Method.GET)
|
||||
var request = new RestRequest("https://benbot.app/api/v1/hotfixes")
|
||||
{
|
||||
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
|
||||
};
|
||||
|
|
@ -65,7 +65,7 @@ public class BenbotApiEndpoint : AbstractApiProvider
|
|||
|
||||
public async Task DownloadFileAsync(string fileLink, string installationPath)
|
||||
{
|
||||
var request = new RestRequest(fileLink, Method.GET);
|
||||
var request = new RestRequest(fileLink);
|
||||
var data = _client.DownloadData(request);
|
||||
await File.WriteAllBytesAsync(installationPath, data);
|
||||
}
|
||||
|
|
@ -74,4 +74,4 @@ public class BenbotApiEndpoint : AbstractApiProvider
|
|||
{
|
||||
DownloadFileAsync(fileLink, installationPath).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public class EpicApiEndpoint : AbstractApiProvider
|
|||
private const string _BASIC_TOKEN = "basic MzQ0NmNkNzI2OTRjNGE0NDg1ZDgxYjc3YWRiYjIxNDE6OTIwOWQ0YTVlMjVhNDU3ZmI5YjA3NDg5ZDMxM2I0MWE=";
|
||||
private const string _LAUNCHER_ASSETS = "https://launcher-public-service-prod06.ol.epicgames.com/launcher/api/public/assets/v2/platform/Windows/namespace/fn/catalogItem/4fe75bbc5a674f4f9b356b5c90567da5/app/Fortnite/label/Live";
|
||||
|
||||
public EpicApiEndpoint(IRestClient client) : base(client)
|
||||
public EpicApiEndpoint(RestClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ public class EpicApiEndpoint : AbstractApiProvider
|
|||
}
|
||||
}
|
||||
|
||||
var request = new RestRequest(_LAUNCHER_ASSETS, Method.GET);
|
||||
var request = new RestRequest(_LAUNCHER_ASSETS);
|
||||
request.AddHeader("Authorization", $"bearer {UserSettings.Default.LastAuthResponse.AccessToken}");
|
||||
var response = await _client.ExecuteAsync(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, request.Resource);
|
||||
|
|
@ -44,7 +44,7 @@ public class EpicApiEndpoint : AbstractApiProvider
|
|||
|
||||
private async Task<AuthResponse> GetAuthAsync(CancellationToken token)
|
||||
{
|
||||
var request = new RestRequest(_OAUTH_URL, Method.POST);
|
||||
var request = new RestRequest(_OAUTH_URL, Method.Post);
|
||||
request.AddHeader("Authorization", _BASIC_TOKEN);
|
||||
request.AddParameter("grant_type", "client_credentials");
|
||||
var response = await _client.ExecuteAsync<AuthResponse>(request, token).ConfigureAwait(false);
|
||||
|
|
@ -57,4 +57,4 @@ public class EpicApiEndpoint : AbstractApiProvider
|
|||
if (string.IsNullOrEmpty(UserSettings.Default.LastAuthResponse.AccessToken)) return true;
|
||||
return DateTime.Now.Subtract(TimeSpan.FromHours(1)) >= UserSettings.Default.LastAuthResponse.ExpiresAt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ public class FModelApi : AbstractApiProvider
|
|||
private readonly IDictionary<string, CommunityDesign> _communityDesigns = new Dictionary<string, CommunityDesign>();
|
||||
private ApplicationViewModel _applicationView => ApplicationService.ApplicationView;
|
||||
|
||||
public FModelApi(IRestClient client) : base(client)
|
||||
public FModelApi(RestClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<News> GetNewsAsync(CancellationToken token)
|
||||
{
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/news/{Constants.APP_VERSION}", Method.GET);
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/news/{Constants.APP_VERSION}");
|
||||
var response = await _client.ExecuteAsync<News>(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, request.Resource);
|
||||
return response.Data;
|
||||
|
|
@ -47,7 +47,7 @@ public class FModelApi : AbstractApiProvider
|
|||
|
||||
public async Task<Info> GetInfosAsync(CancellationToken token, EUpdateMode updateMode)
|
||||
{
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/infos/{updateMode}", Method.GET);
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/infos/{updateMode}");
|
||||
var response = await _client.ExecuteAsync<Info>(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, request.Resource);
|
||||
return response.Data;
|
||||
|
|
@ -60,7 +60,7 @@ public class FModelApi : AbstractApiProvider
|
|||
|
||||
public async Task<Backup[]> GetBackupsAsync(CancellationToken token, string gameName)
|
||||
{
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/backups/{gameName}", Method.GET);
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/backups/{gameName}");
|
||||
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;
|
||||
|
|
@ -73,7 +73,7 @@ public class FModelApi : AbstractApiProvider
|
|||
|
||||
public async Task<Game> GetGamesAsync(CancellationToken token, string gameName)
|
||||
{
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/games/{gameName}", Method.GET);
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/games/{gameName}");
|
||||
var response = await _client.ExecuteAsync<Game>(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, request.Resource);
|
||||
return response.Data;
|
||||
|
|
@ -86,7 +86,7 @@ public class FModelApi : AbstractApiProvider
|
|||
|
||||
public async Task<CommunityDesign> GetDesignAsync(string designName)
|
||||
{
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/designs/{designName}", Method.GET);
|
||||
var request = new RestRequest($"https://api.fmodel.app/v1/designs/{designName}");
|
||||
var response = await _client.ExecuteAsync<Community>(request).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int) response.StatusCode, request.Resource);
|
||||
return response.Data != null ? new CommunityDesign(response.Data) : null;
|
||||
|
|
@ -172,7 +172,7 @@ public class FModelApi : AbstractApiProvider
|
|||
|
||||
private void ShowChangelog(UpdateInfoEventArgs args)
|
||||
{
|
||||
var request = new RestRequest(args.ChangelogURL, Method.GET);
|
||||
var request = new RestRequest(args.ChangelogURL);
|
||||
var response = _client.Execute(request);
|
||||
if (string.IsNullOrEmpty(response.Content)) return;
|
||||
|
||||
|
|
@ -181,4 +181,4 @@ public class FModelApi : AbstractApiProvider
|
|||
_applicationView.CUE4Parse.TabControl.SelectedTab.SetDocumentText(response.Content, false);
|
||||
UserSettings.Default.ShowChangelog = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ namespace FModel.ViewModels.ApiEndpoints;
|
|||
|
||||
public class FortniteApiEndpoint : AbstractApiProvider
|
||||
{
|
||||
public FortniteApiEndpoint(IRestClient client) : base(client)
|
||||
public FortniteApiEndpoint(RestClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<PlaylistResponse> GetPlaylistAsync(string playlistId)
|
||||
{
|
||||
var request = new RestRequest($"https://fortnite-api.com/v1/playlists/{playlistId}", Method.GET);
|
||||
var request = new RestRequest($"https://fortnite-api.com/v1/playlists/{playlistId}");
|
||||
var response = await _client.ExecuteAsync<PlaylistResponse>(request).ConfigureAwait(false);
|
||||
return response.Data;
|
||||
}
|
||||
|
|
@ -25,8 +25,8 @@ public class FortniteApiEndpoint : AbstractApiProvider
|
|||
|
||||
public bool TryGetBytes(Uri link, out byte[] data)
|
||||
{
|
||||
var request = new RestRequest(link, Method.GET);
|
||||
var request = new RestRequest(link);
|
||||
data = _client.DownloadData(request);
|
||||
return data != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,13 @@ public class ValorantApiEndpoint : AbstractApiProvider
|
|||
{
|
||||
private const string _URL = "https://fmodel.fortnite-api.com/valorant/v2/manifest";
|
||||
|
||||
public ValorantApiEndpoint(IRestClient client) : base(client)
|
||||
public ValorantApiEndpoint(RestClient client) : base(client)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<VManifest> GetManifestAsync(CancellationToken token)
|
||||
{
|
||||
var request = new RestRequest(_URL, Method.GET);
|
||||
var request = new RestRequest(_URL);
|
||||
var response = await _client.ExecuteAsync(request, token).ConfigureAwait(false);
|
||||
return new VManifest(response.RawBytes);
|
||||
}
|
||||
|
|
@ -310,4 +310,4 @@ public class VPakStream : Stream, ICloneable
|
|||
public override void Flush() => throw new NotSupportedException();
|
||||
public override void SetLength(long value) => throw new NotSupportedException();
|
||||
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ public class MapViewerViewModel : ViewModel
|
|||
}
|
||||
|
||||
public BitmapImage GetImageToSave() => GetImageSource(GetLayerBitmap(true));
|
||||
|
||||
|
||||
private SKBitmap GetLayerBitmap(bool withMap)
|
||||
{
|
||||
var ret = new SKBitmap(_widthHeight, _widthHeight, SKColorType.Rgba8888, SKAlphaType.Premul);
|
||||
|
|
@ -471,7 +471,7 @@ public class MapViewerViewModel : ViewModel
|
|||
var patrolsPathBitmap = new SKBitmap(_widthHeight, _widthHeight, SKColorType.Rgba8888, SKAlphaType.Premul);
|
||||
using var c = new SKCanvas(patrolsPathBitmap);
|
||||
|
||||
var exports = Utils.LoadExports("/NPCLibrary/LevelOverlays/Artemis_Overlay_S20_NPCLibrary");
|
||||
var exports = Utils.LoadExports("/NPCLibrary/LevelOverlays/Artemis_Overlay_S21_NPCLibrary");
|
||||
foreach (var export in exports)
|
||||
{
|
||||
if (!export.ExportType.Equals("FortAthenaPatrolPath", StringComparison.OrdinalIgnoreCase) ||
|
||||
|
|
@ -874,4 +874,4 @@ public class MapViewerViewModel : ViewModel
|
|||
_bitmaps[0]["ApolloGameplay_TagsLocation"] = new MapLayer { Layer = tagsLocationBitmap, IsEnabled = false };
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user