Compare commits
4 Commits
Canary-1.2
...
Canary-1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9fe0da345 | ||
|
|
1f0fa525a3 | ||
|
|
e15a207656 | ||
|
|
77ef82d92a |
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@@ -27,9 +28,14 @@ namespace Ryujinx.Common.Utilities
|
|||||||
ReadCommentHandling = JsonCommentHandling.Skip
|
ReadCommentHandling = JsonCommentHandling.Skip
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string Serialize<T>(T value, JsonTypeInfo<T> typeInfo) => JsonSerializer.Serialize(value, typeInfo);
|
public static string Serialize<T>(T value, JsonTypeInfo<T> typeInfo)
|
||||||
|
=> JsonSerializer.Serialize(value, typeInfo);
|
||||||
|
|
||||||
public static T Deserialize<T>(string value, JsonTypeInfo<T> typeInfo) => JsonSerializer.Deserialize(value, typeInfo);
|
public static T Deserialize<T>(string value, JsonTypeInfo<T> typeInfo)
|
||||||
|
=> JsonSerializer.Deserialize(value, typeInfo);
|
||||||
|
|
||||||
|
public static T Deserialize<T>(ReadOnlySpan<byte> utf8Value, JsonTypeInfo<T> typeInfo)
|
||||||
|
=> JsonSerializer.Deserialize<T>(utf8Value, typeInfo);
|
||||||
|
|
||||||
public static void SerializeToFile<T>(string filePath, T value, JsonTypeInfo<T> typeInfo)
|
public static void SerializeToFile<T>(string filePath, T value, JsonTypeInfo<T> typeInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2429,19 +2429,19 @@
|
|||||||
"el_GR": "",
|
"el_GR": "",
|
||||||
"en_US": "Firmware Version: {0}",
|
"en_US": "Firmware Version: {0}",
|
||||||
"es_ES": "",
|
"es_ES": "",
|
||||||
"fr_FR": "",
|
"fr_FR": "Version du Firmware: {0}",
|
||||||
"he_IL": "",
|
"he_IL": "",
|
||||||
"it_IT": "",
|
"it_IT": "",
|
||||||
"ja_JP": "",
|
"ja_JP": "",
|
||||||
"ko_KR": "",
|
"ko_KR": "",
|
||||||
"no_NO": "",
|
"no_NO": "",
|
||||||
"pl_PL": "",
|
"pl_PL": "",
|
||||||
"pt_BR": "",
|
"pt_BR": "Versão do firmware: {0}",
|
||||||
"ru_RU": "",
|
"ru_RU": "Версия прошивки: {0}",
|
||||||
"th_TH": "",
|
"th_TH": "",
|
||||||
"tr_TR": "",
|
"tr_TR": "",
|
||||||
"uk_UA": "",
|
"uk_UA": "",
|
||||||
"zh_CN": "",
|
"zh_CN": "系统固件版本:{0}",
|
||||||
"zh_TW": ""
|
"zh_TW": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Gommon;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
@@ -7,12 +8,7 @@ using System;
|
|||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.Encodings.Web;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Text.Unicode;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common.Locale
|
namespace Ryujinx.Ava.Common.Locale
|
||||||
{
|
{
|
||||||
@@ -147,39 +143,33 @@ namespace Ryujinx.Ava.Common.Locale
|
|||||||
LocaleChanged?.Invoke();
|
LocaleChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#nullable enable
|
||||||
|
|
||||||
|
private static LocalesJson? _localeData;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
private static Dictionary<LocaleKeys, string> LoadJsonLanguage(string languageCode)
|
private static Dictionary<LocaleKeys, string> LoadJsonLanguage(string languageCode)
|
||||||
{
|
{
|
||||||
var localeStrings = new Dictionary<LocaleKeys, string>();
|
var localeStrings = new Dictionary<LocaleKeys, string>();
|
||||||
string fileData = EmbeddedResources.ReadAllText($"Ryujinx/Assets/locales.json");
|
|
||||||
|
|
||||||
if (fileData == null)
|
_localeData ??= EmbeddedResources.ReadAllText("Ryujinx/Assets/locales.json")
|
||||||
|
.Into(it => JsonHelper.Deserialize(it, LocalesJsonContext.Default.LocalesJson));
|
||||||
|
|
||||||
|
foreach (LocalesEntry locale in _localeData.Value.Locales)
|
||||||
{
|
{
|
||||||
// We were unable to find file for that language code.
|
if (locale.Translations.Count != _localeData.Value.Languages.Count)
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
LocalesJson json = JsonHelper.Deserialize(fileData, LocalesJsonContext.Default.LocalesJson);
|
|
||||||
|
|
||||||
foreach (LocalesEntry locale in json.Locales)
|
|
||||||
{
|
|
||||||
if (locale.Translations.Count != json.Languages.Count)
|
|
||||||
{
|
{
|
||||||
Logger.Error?.Print(LogClass.UI, $"Locale key {{{locale.ID}}} is missing languages!");
|
throw new Exception($"Locale key {{{locale.ID}}} is missing languages! Has {locale.Translations.Count} translations, expected {_localeData.Value.Languages.Count}!");
|
||||||
throw new Exception("Missing locale data!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Enum.TryParse<LocaleKeys>(locale.ID, out var localeKey))
|
if (!Enum.TryParse<LocaleKeys>(locale.ID, out var localeKey))
|
||||||
{
|
continue;
|
||||||
if (locale.Translations.TryGetValue(languageCode, out string val) && val != "")
|
|
||||||
{
|
localeStrings[localeKey] =
|
||||||
localeStrings[localeKey] = val;
|
locale.Translations.TryGetValue(languageCode, out string val) && val != string.Empty
|
||||||
}
|
? val
|
||||||
else
|
: locale.Translations[DefaultLanguageCode];
|
||||||
{
|
|
||||||
locale.Translations.TryGetValue("en_US", out val);
|
|
||||||
localeStrings[localeKey] = val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return localeStrings;
|
return localeStrings;
|
||||||
@@ -200,5 +190,5 @@ namespace Ryujinx.Ava.Common.Locale
|
|||||||
|
|
||||||
[JsonSourceGenerationOptions(WriteIndented = true)]
|
[JsonSourceGenerationOptions(WriteIndented = true)]
|
||||||
[JsonSerializable(typeof(LocalesJson))]
|
[JsonSerializable(typeof(LocalesJson))]
|
||||||
internal partial class LocalesJsonContext : JsonSerializerContext { }
|
internal partial class LocalesJsonContext : JsonSerializerContext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -329,7 +329,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//private DateTimeOffset _currentDate;
|
||||||
|
//private TimeSpan _currentTime;
|
||||||
|
|
||||||
public DateTimeOffset CurrentDate { get; set; }
|
public DateTimeOffset CurrentDate { get; set; }
|
||||||
|
|
||||||
public TimeSpan CurrentTime { get; set; }
|
public TimeSpan CurrentTime { get; set; }
|
||||||
|
|
||||||
internal AvaloniaList<TimeZone> TimeZones { get; set; }
|
internal AvaloniaList<TimeZone> TimeZones { get; set; }
|
||||||
@@ -453,6 +457,18 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(PreferredGpuIndex)));
|
Dispatcher.UIThread.Post(() => OnPropertyChanged(nameof(PreferredGpuIndex)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MatchSystemTime()
|
||||||
|
{
|
||||||
|
var dto = DateTimeOffset.Now;
|
||||||
|
|
||||||
|
CurrentDate = new DateTimeOffset(dto.Year, dto.Month, dto.Day, 0, 0, 0, dto.Offset);
|
||||||
|
|
||||||
|
CurrentTime = dto.TimeOfDay;
|
||||||
|
|
||||||
|
OnPropertyChanged(nameof(CurrentDate));
|
||||||
|
OnPropertyChanged(nameof(CurrentTime));
|
||||||
|
}
|
||||||
|
|
||||||
public async Task LoadTimeZones()
|
public async Task LoadTimeZones()
|
||||||
{
|
{
|
||||||
_timeZoneContentManager = new TimeZoneContentManager();
|
_timeZoneContentManager = new TimeZoneContentManager();
|
||||||
|
|||||||
@@ -182,7 +182,20 @@
|
|||||||
Width="350"
|
Width="350"
|
||||||
ToolTip.Tip="{ext:Locale TimeTooltip}" />
|
ToolTip.Tip="{ext:Locale TimeTooltip}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Margin="0,0,0,10"
|
<StackPanel
|
||||||
|
Margin="250,0,0,10"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<Button
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Click="MatchSystemTime_OnClick"
|
||||||
|
Background="{DynamicResource SystemAccentColor}"
|
||||||
|
Width="350"
|
||||||
|
ToolTip.Tip="{ext:Locale TimeTooltip}">
|
||||||
|
<TextBlock Text="Match System Time" />
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
<Separator />
|
||||||
|
<StackPanel Margin="0,10,0,10"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<TextBlock
|
<TextBlock
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
using System;
|
||||||
using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
|
using TimeZone = Ryujinx.Ava.UI.Models.TimeZone;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Views.Settings
|
namespace Ryujinx.Ava.UI.Views.Settings
|
||||||
@@ -33,5 +35,7 @@ namespace Ryujinx.Ava.UI.Views.Settings
|
|||||||
ViewModel.ValidateAndSetTimeZone(timeZone.Location);
|
ViewModel.ValidateAndSetTimeZone(timeZone.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MatchSystemTime_OnClick(object sender, RoutedEventArgs e) => ViewModel.MatchSystemTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user