Compare commits

...

3 Commits

Author SHA1 Message Date
Evan Husted
8259f790d7 misc: Cleanup locale validator 2024-12-22 13:19:10 -06:00
Evan Husted
1ea345faa7 UI: Move Match PC Time to next to the time selector & change label & tooltip to clarify behavior further. 2024-12-22 12:53:48 -06:00
Marco Carvalho
5913ceda40 Avoid zero-length array allocations (#427) 2024-12-22 11:36:05 -06:00
6 changed files with 18 additions and 25 deletions

View File

@@ -14,20 +14,20 @@ namespace Ryujinx.BuildValidationTasks
{ {
string path = System.Reflection.Assembly.GetExecutingAssembly().Location; string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
if (path.Split(new string[] { "src" }, StringSplitOptions.None).Length == 1 ) if (path.Split(["src"], StringSplitOptions.None).Length == 1)
{ {
//i assume that we are in a build directory in the solution dir //i assume that we are in a build directory in the solution dir
path = new FileInfo(path).Directory.Parent.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName; path = new FileInfo(path).Directory!.Parent!.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
} }
else else
{ {
path = path.Split(new string[] { "src" }, StringSplitOptions.None)[0]; path = path.Split(["src"], StringSplitOptions.None)[0];
path = new FileInfo(path).Directory.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName; path = new FileInfo(path).Directory!.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
} }
string data; string data;
using (StreamReader sr = new StreamReader(path)) using (StreamReader sr = new(path))
{ {
data = sr.ReadToEnd(); data = sr.ReadToEnd();
} }
@@ -38,13 +38,10 @@ namespace Ryujinx.BuildValidationTasks
{ {
LocalesEntry locale = json.Locales[i]; LocalesEntry locale = json.Locales[i];
foreach (string language in json.Languages) foreach (string langCode in json.Languages.Where(it => !locale.Translations.ContainsKey(it)))
{ {
if (!locale.Translations.ContainsKey(language)) locale.Translations.Add(langCode, string.Empty);
{ Log.LogMessage(MessageImportance.High, $"Added '{langCode}' to Locale '{locale.ID}'");
locale.Translations.Add(language, "");
Log.LogMessage(MessageImportance.High, $"Added {{{language}}} to Locale {{{locale.ID}}}");
}
} }
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value); locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
@@ -53,7 +50,7 @@ namespace Ryujinx.BuildValidationTasks
string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented); string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented);
using (StreamWriter sw = new StreamWriter(path)) using (StreamWriter sw = new(path))
{ {
sw.Write(jsonString); sw.Write(jsonString);
} }

View File

@@ -341,7 +341,7 @@ namespace Ryujinx.HLE.HOS
{ {
if (VirtualAmiibo.ApplicationBytes.Length > 0) if (VirtualAmiibo.ApplicationBytes.Length > 0)
{ {
VirtualAmiibo.ApplicationBytes = new byte[0]; VirtualAmiibo.ApplicationBytes = Array.Empty<byte>();
VirtualAmiibo.InputBin = string.Empty; VirtualAmiibo.InputBin = string.Empty;
} }
if (NfpDevices[nfpDeviceId].State == NfpDeviceState.SearchingForTag) if (NfpDevices[nfpDeviceId].State == NfpDeviceState.SearchingForTag)
@@ -356,7 +356,7 @@ namespace Ryujinx.HLE.HOS
VirtualAmiibo.InputBin = path; VirtualAmiibo.InputBin = path;
if (VirtualAmiibo.ApplicationBytes.Length > 0) if (VirtualAmiibo.ApplicationBytes.Length > 0)
{ {
VirtualAmiibo.ApplicationBytes = new byte[0]; VirtualAmiibo.ApplicationBytes = Array.Empty<byte>();
} }
byte[] encryptedData = File.ReadAllBytes(path); byte[] encryptedData = File.ReadAllBytes(path);
VirtualAmiiboFile newFile = AmiiboBinReader.ReadBinFile(encryptedData); VirtualAmiiboFile newFile = AmiiboBinReader.ReadBinFile(encryptedData);

View File

@@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
static class VirtualAmiibo static class VirtualAmiibo
{ {
public static uint OpenedApplicationAreaId; public static uint OpenedApplicationAreaId;
public static byte[] ApplicationBytes = new byte[0]; public static byte[] ApplicationBytes = Array.Empty<byte>();
public static string InputBin = string.Empty; public static string InputBin = string.Empty;
public static string NickName = string.Empty; public static string NickName = string.Empty;
private static readonly AmiiboJsonSerializerContext _serializerContext = AmiiboJsonSerializerContext.Default; private static readonly AmiiboJsonSerializerContext _serializerContext = AmiiboJsonSerializerContext.Default;
@@ -137,7 +137,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
if (ApplicationBytes.Length > 0) if (ApplicationBytes.Length > 0)
{ {
byte[] bytes = ApplicationBytes; byte[] bytes = ApplicationBytes;
ApplicationBytes = new byte[0]; ApplicationBytes = Array.Empty<byte>();
return bytes; return bytes;
} }
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId); VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);

View File

@@ -3771,7 +3771,7 @@
"ar_SA": "", "ar_SA": "",
"de_DE": "", "de_DE": "",
"el_GR": "", "el_GR": "",
"en_US": "Match PC Time", "en_US": "Resync to PC Date & Time",
"es_ES": "", "es_ES": "",
"fr_FR": "", "fr_FR": "",
"he_IL": "", "he_IL": "",
@@ -14571,7 +14571,7 @@
"ar_SA": "", "ar_SA": "",
"de_DE": "", "de_DE": "",
"el_GR": "", "el_GR": "",
"en_US": "Change System Time to match your PC's date & time.", "en_US": "Resync System Time to match your PC's current date & time.\n\nThis is not an active setting, it can still fall out of sync; in which case just click this button again.",
"es_ES": "", "es_ES": "",
"fr_FR": "", "fr_FR": "",
"he_IL": "", "he_IL": "",
@@ -21574,4 +21574,4 @@
} }
} }
] ]
} }

View File

@@ -181,15 +181,11 @@
SelectedTime="{Binding CurrentTime}" SelectedTime="{Binding CurrentTime}"
Width="350" Width="350"
ToolTip.Tip="{ext:Locale TimeTooltip}" /> ToolTip.Tip="{ext:Locale TimeTooltip}" />
</StackPanel>
<StackPanel
Margin="350,0,0,10"
Orientation="Horizontal">
<Button <Button
Margin="10, 0, 0, 0"
VerticalAlignment="Center" VerticalAlignment="Center"
Click="MatchSystemTime_OnClick" Click="MatchSystemTime_OnClick"
Background="{DynamicResource SystemAccentColor}" Background="{DynamicResource SystemAccentColor}"
Width="150"
ToolTip.Tip="{ext:Locale MatchTimeTooltip}"> ToolTip.Tip="{ext:Locale MatchTimeTooltip}">
<TextBlock Text="{ext:Locale SettingsTabSystemSystemTimeMatch}" /> <TextBlock Text="{ext:Locale SettingsTabSystemSystemTimeMatch}" />
</Button> </Button>

View File

@@ -1,7 +1,7 @@
using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Interactivity; 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