mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-27 16:47:11 +02:00
misc: chore: Use explicit types in the Avalonia project
This commit is contained in:
parent
3b5f6170d1
commit
be3bd0bcb5
69 changed files with 367 additions and 348 deletions
|
@ -6,6 +6,7 @@ using Ryujinx.Ava.Utilities.AppLibrary;
|
|||
using Ryujinx.Ava.Utilities.Configuration;
|
||||
using Ryujinx.HLE.FileSystem;
|
||||
using Ryujinx.HLE.HOS;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -58,7 +59,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
int cheatAdded = 0;
|
||||
|
||||
var mods = new ModLoader.ModCache();
|
||||
ModLoader.ModCache mods = new ModLoader.ModCache();
|
||||
|
||||
ModLoader.QueryContentsDir(mods, new DirectoryInfo(Path.Combine(modsBasePath, "contents")), titleIdValue);
|
||||
|
||||
|
@ -67,7 +68,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
CheatNode currentGroup = null;
|
||||
|
||||
foreach (var cheat in mods.Cheats)
|
||||
foreach (ModLoader.Cheat cheat in mods.Cheats)
|
||||
{
|
||||
if (cheat.Path.FullName != currentCheatFile)
|
||||
{
|
||||
|
@ -80,7 +81,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
LoadedCheats.Add(currentGroup);
|
||||
}
|
||||
|
||||
var model = new CheatNode(cheat.Name, buildId, string.Empty, false, enabled.Contains($"{buildId}-{cheat.Name}"));
|
||||
CheatNode model = new CheatNode(cheat.Name, buildId, string.Empty, false, enabled.Contains($"{buildId}-{cheat.Name}"));
|
||||
currentGroup?.SubNodes.Add(model);
|
||||
|
||||
cheatAdded++;
|
||||
|
@ -101,7 +102,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
if (NoCheatsFound)
|
||||
return;
|
||||
|
||||
var enabledCheats = LoadedCheats.SelectMany(it => it.SubNodes)
|
||||
IEnumerable<string> enabledCheats = LoadedCheats.SelectMany(it => it.SubNodes)
|
||||
.Where(it => it.IsEnabled)
|
||||
.Select(it => it.BuildIdKey);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var content in e.AddedItems)
|
||||
foreach (object content in e.AddedItems)
|
||||
{
|
||||
if (content is DownloadableContentModel model)
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var content in e.RemovedItems)
|
||||
foreach (object content in e.RemovedItems)
|
||||
{
|
||||
if (content is DownloadableContentModel model)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
public static SKColor GetFilteredColor(SKBitmap image)
|
||||
{
|
||||
var color = GetColor(image);
|
||||
SKColor color = GetColor(image);
|
||||
|
||||
|
||||
// We don't want colors that are too dark.
|
||||
|
@ -49,10 +49,10 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
public static SKColor GetColor(SKBitmap image)
|
||||
{
|
||||
var colors = new PaletteColor[TotalColors];
|
||||
var dominantColorBin = new Dictionary<int, int>();
|
||||
PaletteColor[] colors = new PaletteColor[TotalColors];
|
||||
Dictionary<int, int> dominantColorBin = new Dictionary<int, int>();
|
||||
|
||||
var buffer = GetBuffer(image);
|
||||
SKColor[] buffer = GetBuffer(image);
|
||||
|
||||
int i = 0;
|
||||
int maxHitCount = 0;
|
||||
|
@ -70,7 +70,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
byte cg = pixel.Green;
|
||||
byte cb = pixel.Blue;
|
||||
|
||||
var qck = GetQuantizedColorKey(cr, cg, cb);
|
||||
int qck = GetQuantizedColorKey(cr, cg, cb);
|
||||
|
||||
if (dominantColorBin.TryGetValue(qck, out int hitCount))
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
for (i = 0; i < TotalColors; i++)
|
||||
{
|
||||
var score = GetColorScore(dominantColorBin, maxHitCount, colors[i]);
|
||||
int score = GetColorScore(dominantColorBin, maxHitCount, colors[i]);
|
||||
|
||||
if (highScore < score)
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
public static SKColor[] GetBuffer(SKBitmap image)
|
||||
{
|
||||
var pixels = new SKColor[image.Width * image.Height];
|
||||
SKColor[] pixels = new SKColor[image.Width * image.Height];
|
||||
|
||||
for (int y = 0; y < image.Height; y++)
|
||||
{
|
||||
|
@ -124,17 +124,17 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private static int GetColorScore(Dictionary<int, int> dominantColorBin, int maxHitCount, PaletteColor color)
|
||||
{
|
||||
var hitCount = dominantColorBin[color.Qck];
|
||||
var balancedHitCount = BalanceHitCount(hitCount, maxHitCount);
|
||||
var quantSat = (GetColorSaturation(color) >> SatQuantShift) << SatQuantShift;
|
||||
var value = GetColorValue(color);
|
||||
int hitCount = dominantColorBin[color.Qck];
|
||||
int balancedHitCount = BalanceHitCount(hitCount, maxHitCount);
|
||||
int quantSat = (GetColorSaturation(color) >> SatQuantShift) << SatQuantShift;
|
||||
int value = GetColorValue(color);
|
||||
|
||||
// If the color is rarely used on the image,
|
||||
// then chances are that there's a better candidate, even if the saturation value
|
||||
// is high. By multiplying the saturation value with a weight, we can lower
|
||||
// it if the color is almost never used (hit count is low).
|
||||
var satWeighted = quantSat;
|
||||
var satWeight = balancedHitCount << 5;
|
||||
int satWeighted = quantSat;
|
||||
int satWeight = balancedHitCount << 5;
|
||||
if (satWeight < 0x100)
|
||||
{
|
||||
satWeighted = (satWeighted * satWeight) >> 8;
|
||||
|
@ -142,7 +142,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
// Compute score from saturation and dominance of the color.
|
||||
// We prefer more vivid colors over dominant ones, so give more weight to the saturation.
|
||||
var score = ((satWeighted << 1) + balancedHitCount) * value;
|
||||
int score = ((satWeighted << 1) + balancedHitCount) * value;
|
||||
|
||||
return score;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ using DynamicData;
|
|||
using FluentAvalonia.UI.Controls;
|
||||
using FluentAvalonia.UI.Windowing;
|
||||
using Gommon;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem;
|
||||
using Ryujinx.Ava.Common;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
|
@ -171,11 +172,11 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
var ldnGameDataArray = e.LdnData.ToList();
|
||||
List<LdnGameData> ldnGameDataArray = e.LdnData.ToList();
|
||||
ViewModel.LdnData.Clear();
|
||||
foreach (var application in ViewModel.Applications.Where(it => it.HasControlHolder))
|
||||
foreach (ApplicationData application in ViewModel.Applications.Where(it => it.HasControlHolder))
|
||||
{
|
||||
ref var controlHolder = ref application.ControlHolder.Value;
|
||||
ref ApplicationControlProperty controlHolder = ref application.ControlHolder.Value;
|
||||
|
||||
ViewModel.LdnData[application.IdString] =
|
||||
LdnGameData.GetArrayForApp(
|
||||
|
@ -192,7 +193,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private void UpdateApplicationWithLdnData(ApplicationData application)
|
||||
{
|
||||
if (application.HasControlHolder && ViewModel.LdnData.TryGetValue(application.IdString, out var ldnGameDatas))
|
||||
if (application.HasControlHolder && ViewModel.LdnData.TryGetValue(application.IdString, out LdnGameData.Array ldnGameDatas))
|
||||
{
|
||||
application.PlayerCount = ldnGameDatas.PlayerCount;
|
||||
application.GameCount = ldnGameDatas.GameCount;
|
||||
|
@ -690,12 +691,12 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
ApplicationLibrary.LoadApplications(ConfigurationState.Instance.UI.GameDirs);
|
||||
|
||||
var autoloadDirs = ConfigurationState.Instance.UI.AutoloadDirs.Value;
|
||||
List<string> autoloadDirs = ConfigurationState.Instance.UI.AutoloadDirs.Value;
|
||||
autoloadDirs.ForEach(dir => Logger.Info?.Print(LogClass.Application, $"Auto loading DLC & updates from: {dir}"));
|
||||
if (autoloadDirs.Count > 0)
|
||||
{
|
||||
var updatesLoaded = ApplicationLibrary.AutoLoadTitleUpdates(autoloadDirs, out int updatesRemoved);
|
||||
var dlcLoaded = ApplicationLibrary.AutoLoadDownloadableContents(autoloadDirs, out int dlcRemoved);
|
||||
int updatesLoaded = ApplicationLibrary.AutoLoadTitleUpdates(autoloadDirs, out int updatesRemoved);
|
||||
int dlcLoaded = ApplicationLibrary.AutoLoadDownloadableContents(autoloadDirs, out int dlcRemoved);
|
||||
|
||||
ShowNewContentAddedDialog(dlcLoaded, dlcRemoved, updatesLoaded, updatesRemoved);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
{
|
||||
if (button.DataContext is ModModel model)
|
||||
{
|
||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
LocaleManager.Instance.UpdateAndGetDynamicValue(LocaleKeys.DialogModManagerDeletionWarningMessage, model.Name),
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
|
@ -83,7 +83,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private async void DeleteAll(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
UserResult result = await ContentDialogHelper.CreateConfirmationDialog(
|
||||
LocaleManager.Instance[LocaleKeys.DialogWarning],
|
||||
LocaleManager.Instance[LocaleKeys.DialogModManagerDeletionAllWarningMessage],
|
||||
LocaleManager.Instance[LocaleKeys.InputDialogYes],
|
||||
|
@ -109,11 +109,11 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var content in e.AddedItems)
|
||||
foreach (object content in e.AddedItems)
|
||||
{
|
||||
if (content is ModModel model)
|
||||
{
|
||||
var index = ViewModel.Mods.IndexOf(model);
|
||||
int index = ViewModel.Mods.IndexOf(model);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
|
@ -122,11 +122,11 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var content in e.RemovedItems)
|
||||
foreach (object content in e.RemovedItems)
|
||||
{
|
||||
if (content is ModModel model)
|
||||
{
|
||||
var index = ViewModel.Mods.IndexOf(model);
|
||||
int index = ViewModel.Mods.IndexOf(model);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
foreach (var content in e.AddedItems)
|
||||
foreach (object content in e.AddedItems)
|
||||
{
|
||||
if (content is XCITrimmerFileModel applicationData)
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ namespace Ryujinx.Ava.UI.Windows
|
|||
}
|
||||
}
|
||||
|
||||
foreach (var content in e.RemovedItems)
|
||||
foreach (object content in e.RemovedItems)
|
||||
{
|
||||
if (content is XCITrimmerFileModel applicationData)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue