mirror of
https://github.com/4sval/FModel.git
synced 2026-04-18 23:57:42 -05:00
Add hotfix translations
This commit is contained in:
parent
f87fc8baeb
commit
8f4f501138
|
|
@ -1 +1 @@
|
|||
Subproject commit 29316b4ae38c3690fa24e39bcd48ac63a4a5805e
|
||||
Subproject commit 8d7538c5496ec62e04c622e662f056ab5faf10a7
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using FModel.ViewModels.ApiEndpoints.Models;
|
||||
|
|
@ -45,6 +46,23 @@ namespace FModel.ViewModels.ApiEndpoints
|
|||
return GetMappingsAsync(token).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
OnBeforeDeserialization = resp => { resp.ContentType = "application/json; charset=utf-8"; }
|
||||
};
|
||||
request.AddParameter("lang", language);
|
||||
var response = await _client.ExecuteAsync<Dictionary<string, Dictionary<string, string>>>(request, token).ConfigureAwait(false);
|
||||
Log.Information("[{Method}] [{Status}({StatusCode})] '{Resource}'", request.Method, response.StatusDescription, (int)response.StatusCode, request.Resource);
|
||||
return response.Data;
|
||||
}
|
||||
|
||||
public Dictionary<string, Dictionary<string, string>> GetHotfixes(CancellationToken token, string language = "en-US")
|
||||
{
|
||||
return GetHotfixesAsync(token, language).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task DownloadFileAsync(string fileLink, string installationPath)
|
||||
{
|
||||
var request = new RestRequest(fileLink, Method.GET);
|
||||
|
|
|
|||
|
|
@ -346,6 +346,36 @@ namespace FModel.ViewModels
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load hotfixed localized resources
|
||||
/// </summary>
|
||||
/// <remarks>Functions only when LoadLocalizedResources is used prior to this.</remarks>
|
||||
public async Task LoadHotfixedLocalizedResources()
|
||||
{
|
||||
var i = 0;
|
||||
if (LocalizedResourcesCount <= 0) return;
|
||||
await _threadWorkerView.Begin(cancellationToken =>
|
||||
{
|
||||
var hotfixes = ApplicationService.ApiEndpointView.BenbotApi.GetHotfixes(cancellationToken, Provider.GetLanguageCode(UserSettings.Default.AssetLanguage));
|
||||
|
||||
foreach (var entries in hotfixes)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
if (!Provider.LocalizedResources.ContainsKey(entries.Key))
|
||||
Provider.LocalizedResources[entries.Key] = new Dictionary<string, string>();
|
||||
|
||||
foreach (var keyValue in entries.Value)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
Provider.LocalizedResources[entries.Key][keyValue.Key] = keyValue.Value;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
LocalizedResourcesCount += i;
|
||||
}
|
||||
|
||||
public async Task LoadVirtualPaths()
|
||||
{
|
||||
if (VirtualPathCount > 0) return;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
@ -45,14 +45,14 @@ namespace FModel.ViewModels.Commands
|
|||
FLogger.AppendText("An encrypted file has been found. In order to decrypt it, please specify a working AES encryption key", Constants.WHITE, true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (_applicationView.CUE4Parse.Game == FGame.FortniteGame &&
|
||||
_applicationView.CUE4Parse.Provider.MappingsContainer == null)
|
||||
{
|
||||
FLogger.AppendError();
|
||||
FLogger.AppendText("Mappings could not get pulled, extracting assets might not work properly. If so, press F12 or please restart.", Constants.WHITE, true);
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG
|
||||
var loadingTime = Stopwatch.StartNew();
|
||||
#endif
|
||||
|
|
@ -61,6 +61,7 @@ namespace FModel.ViewModels.Commands
|
|||
MainWindow.YesWeCats.LeftTabControl.SelectedIndex = 1; // folders tab
|
||||
|
||||
await _applicationView.CUE4Parse.LoadLocalizedResources(); // load locres if not already loaded
|
||||
await _applicationView.CUE4Parse.LoadHotfixedLocalizedResources(); // load hofixed locres
|
||||
await _applicationView.CUE4Parse.LoadVirtualPaths(); // load virtual paths if not already loaded
|
||||
Helper.CloseWindow<AdonisWindow>("Search View"); // close search window if opened
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using FModel.Services;
|
||||
using FModel.Settings;
|
||||
|
|
@ -45,6 +45,7 @@ namespace FModel.Views
|
|||
{
|
||||
_applicationView.CUE4Parse.LocalizedResourcesCount = 0;
|
||||
await _applicationView.CUE4Parse.LoadLocalizedResources();
|
||||
await _applicationView.CUE4Parse.LoadHotfixedLocalizedResources();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user