mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-10-10 16:21:04 +02:00
[Ryujinx] Address dotnet-format issues (#5395)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address dotnet format CA1822 warnings * Make dotnet format succeed in style mode * Address dotnet format CA2208 warnings properly * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Another rebase, another dotnet format run * Run dotnet format whitespace after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Fix build issues * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Second dotnet format pass * Update src/Ryujinx/Modules/Updater/Updater.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas and improve formatting * Fix formatting and naming issues * Rename nvStutterWorkaround to nvidiaStutterWorkaround * Use using declarations and extend resource lifetimes * Fix GTK issues * Add formatting for generated files * Add trailing commas --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
@@ -14,21 +14,19 @@ using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AmiiboApi = Ryujinx.Ui.Common.Models.Amiibo.AmiiboApi;
|
||||
using AmiiboJsonSerializerContext = Ryujinx.Ui.Common.Models.Amiibo.AmiiboJsonSerializerContext;
|
||||
|
||||
namespace Ryujinx.Ui.Windows
|
||||
{
|
||||
public partial class AmiiboWindow : Window
|
||||
{
|
||||
private const string DEFAULT_JSON = "{ \"amiibo\": [] }";
|
||||
private const string DefaultJson = "{ \"amiibo\": [] }";
|
||||
|
||||
public string AmiiboId { get; private set; }
|
||||
|
||||
public int DeviceId { get; set; }
|
||||
public string TitleId { get; set; }
|
||||
public string LastScannedAmiiboId { get; set; }
|
||||
public bool LastScannedAmiiboShowAll { get; set; }
|
||||
public int DeviceId { get; set; }
|
||||
public string TitleId { get; set; }
|
||||
public string LastScannedAmiiboId { get; set; }
|
||||
public bool LastScannedAmiiboShowAll { get; set; }
|
||||
|
||||
public ResponseType Response { get; private set; }
|
||||
|
||||
@@ -41,13 +39,13 @@ namespace Ryujinx.Ui.Windows
|
||||
}
|
||||
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly string _amiiboJsonPath;
|
||||
private readonly string _amiiboJsonPath;
|
||||
|
||||
private readonly byte[] _amiiboLogoBytes;
|
||||
|
||||
private List<AmiiboApi> _amiiboList;
|
||||
|
||||
private static readonly AmiiboJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
private static readonly AmiiboJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||
|
||||
public AmiiboWindow() : base($"Ryujinx {Program.Version} - Amiibo")
|
||||
{
|
||||
@@ -57,18 +55,18 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
_httpClient = new HttpClient()
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(30)
|
||||
Timeout = TimeSpan.FromSeconds(30),
|
||||
};
|
||||
|
||||
Directory.CreateDirectory(System.IO.Path.Join(AppDataManager.BaseDirPath, "system", "amiibo"));
|
||||
|
||||
_amiiboJsonPath = System.IO.Path.Join(AppDataManager.BaseDirPath, "system", "amiibo", "Amiibo.json");
|
||||
_amiiboList = new List<AmiiboApi>();
|
||||
_amiiboList = new List<AmiiboApi>();
|
||||
|
||||
_amiiboLogoBytes = EmbeddedResources.Read("Ryujinx.Ui.Common/Resources/Logo_Amiibo.png");
|
||||
_amiiboLogoBytes = EmbeddedResources.Read("Ryujinx.Ui.Common/Resources/Logo_Amiibo.png");
|
||||
_amiiboImage.Pixbuf = new Gdk.Pixbuf(_amiiboLogoBytes);
|
||||
|
||||
_scanButton.Sensitive = false;
|
||||
_scanButton.Sensitive = false;
|
||||
_randomUuidCheckBox.Sensitive = false;
|
||||
|
||||
_ = LoadContentAsync();
|
||||
@@ -76,13 +74,13 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
private async Task LoadContentAsync()
|
||||
{
|
||||
string amiiboJsonString = DEFAULT_JSON;
|
||||
string amiiboJsonString = DefaultJson;
|
||||
|
||||
if (File.Exists(_amiiboJsonPath))
|
||||
{
|
||||
amiiboJsonString = await File.ReadAllTextAsync(_amiiboJsonPath);
|
||||
|
||||
if (await NeedsUpdate(JsonHelper.Deserialize(amiiboJsonString, SerializerContext.AmiiboJson).LastUpdated))
|
||||
if (await NeedsUpdate(JsonHelper.Deserialize(amiiboJsonString, _serializerContext.AmiiboJson).LastUpdated))
|
||||
{
|
||||
amiiboJsonString = await DownloadAmiiboJson();
|
||||
}
|
||||
@@ -103,7 +101,7 @@ namespace Ryujinx.Ui.Windows
|
||||
}
|
||||
}
|
||||
|
||||
_amiiboList = JsonHelper.Deserialize(amiiboJsonString, SerializerContext.AmiiboJson).Amiibo;
|
||||
_amiiboList = JsonHelper.Deserialize(amiiboJsonString, _serializerContext.AmiiboJson).Amiibo;
|
||||
_amiiboList = _amiiboList.OrderBy(amiibo => amiibo.AmiiboSeries).ToList();
|
||||
|
||||
if (LastScannedAmiiboShowAll)
|
||||
@@ -118,7 +116,7 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
private void ParseAmiiboData()
|
||||
{
|
||||
List<string> comboxItemList = new List<string>();
|
||||
List<string> comboxItemList = new();
|
||||
|
||||
for (int i = 0; i < _amiiboList.Count; i++)
|
||||
{
|
||||
@@ -149,7 +147,7 @@ namespace Ryujinx.Ui.Windows
|
||||
}
|
||||
|
||||
_amiiboSeriesComboBox.Changed += SeriesComboBox_Changed;
|
||||
_amiiboCharsComboBox.Changed += CharacterComboBox_Changed;
|
||||
_amiiboCharsComboBox.Changed += CharacterComboBox_Changed;
|
||||
|
||||
if (LastScannedAmiiboId != "")
|
||||
{
|
||||
@@ -219,7 +217,7 @@ namespace Ryujinx.Ui.Windows
|
||||
Close();
|
||||
}
|
||||
|
||||
return DEFAULT_JSON;
|
||||
return DefaultJson;
|
||||
}
|
||||
|
||||
private async Task UpdateAmiiboPreview(string imageUrl)
|
||||
@@ -228,14 +226,14 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
byte[] amiiboPreviewBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
Gdk.Pixbuf amiiboPreview = new Gdk.Pixbuf(amiiboPreviewBytes);
|
||||
byte[] amiiboPreviewBytes = await response.Content.ReadAsByteArrayAsync();
|
||||
Gdk.Pixbuf amiiboPreview = new(amiiboPreviewBytes);
|
||||
|
||||
float ratio = Math.Min((float)_amiiboImage.AllocatedWidth / amiiboPreview.Width,
|
||||
float ratio = Math.Min((float)_amiiboImage.AllocatedWidth / amiiboPreview.Width,
|
||||
(float)_amiiboImage.AllocatedHeight / amiiboPreview.Height);
|
||||
|
||||
int resizeHeight = (int)(amiiboPreview.Height * ratio);
|
||||
int resizeWidth = (int)(amiiboPreview.Width * ratio);
|
||||
int resizeWidth = (int)(amiiboPreview.Width * ratio);
|
||||
|
||||
_amiiboImage.Pixbuf = amiiboPreview.ScaleSimple(resizeWidth, resizeHeight, Gdk.InterpType.Bilinear);
|
||||
}
|
||||
@@ -245,7 +243,7 @@ namespace Ryujinx.Ui.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowInfoDialog()
|
||||
private static void ShowInfoDialog()
|
||||
{
|
||||
GtkDialog.CreateInfoDialog($"Amiibo API", "Unable to connect to Amiibo API server. The service may be down or you may need to verify your internet connection is online.");
|
||||
}
|
||||
@@ -261,7 +259,7 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
List<AmiiboApi> amiiboSortedList = _amiiboList.Where(amiibo => amiibo.AmiiboSeries == _amiiboSeriesComboBox.ActiveId).OrderBy(amiibo => amiibo.Name).ToList();
|
||||
|
||||
List<string> comboxItemList = new List<string>();
|
||||
List<string> comboxItemList = new();
|
||||
|
||||
for (int i = 0; i < amiiboSortedList.Count; i++)
|
||||
{
|
||||
@@ -295,7 +293,7 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
_amiiboCharsComboBox.Active = 0;
|
||||
|
||||
_scanButton.Sensitive = true;
|
||||
_scanButton.Sensitive = true;
|
||||
_randomUuidCheckBox.Sensitive = true;
|
||||
}
|
||||
|
||||
@@ -346,12 +344,12 @@ namespace Ryujinx.Ui.Windows
|
||||
_amiiboImage.Pixbuf = new Gdk.Pixbuf(_amiiboLogoBytes);
|
||||
|
||||
_amiiboSeriesComboBox.Changed -= SeriesComboBox_Changed;
|
||||
_amiiboCharsComboBox.Changed -= CharacterComboBox_Changed;
|
||||
_amiiboCharsComboBox.Changed -= CharacterComboBox_Changed;
|
||||
|
||||
_amiiboSeriesComboBox.RemoveAll();
|
||||
_amiiboCharsComboBox.RemoveAll();
|
||||
|
||||
_scanButton.Sensitive = false;
|
||||
_scanButton.Sensitive = false;
|
||||
_randomUuidCheckBox.Sensitive = false;
|
||||
|
||||
new Task(() => ParseAmiiboData()).Start();
|
||||
@@ -368,8 +366,8 @@ namespace Ryujinx.Ui.Windows
|
||||
|
||||
private void CancelButton_Pressed(object sender, EventArgs args)
|
||||
{
|
||||
AmiiboId = "";
|
||||
LastScannedAmiiboId = "";
|
||||
AmiiboId = "";
|
||||
LastScannedAmiiboId = "";
|
||||
LastScannedAmiiboShowAll = false;
|
||||
|
||||
Response = ResponseType.Cancel;
|
||||
@@ -384,4 +382,4 @@ namespace Ryujinx.Ui.Windows
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user