mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-16 01:36:57 +00:00
Amiibo Window Layout Adjustments + Other
This commit is contained in:
parent
39653c5250
commit
ed8cda4b0e
5 changed files with 154 additions and 160 deletions
|
|
@ -317,28 +317,21 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
_amiiboSeries.Clear();
|
||||
_amiibos.Clear();
|
||||
|
||||
for (int i = 0; i < _amiiboList.Count; i++)
|
||||
foreach (var amiibo in _amiiboList)
|
||||
{
|
||||
if (!_amiiboSeries.Contains(_amiiboList[i].AmiiboSeries))
|
||||
if (!_amiiboSeries.Contains(amiibo.AmiiboSeries))
|
||||
{
|
||||
if (!ShowAllAmiibo)
|
||||
{
|
||||
foreach (AmiiboApiGamesSwitch game in _amiiboList[i].GamesSwitch)
|
||||
bool compatible = amiibo.GamesSwitch.Any(game => game != null && game.GameId.Contains(TitleId));
|
||||
if (compatible)
|
||||
{
|
||||
if (game != null)
|
||||
{
|
||||
if (game.GameId.Contains(TitleId))
|
||||
{
|
||||
AmiiboSeries.Add(_amiiboList[i].AmiiboSeries);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
_amiiboSeries.Add(amiibo.AmiiboSeries);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AmiiboSeries.Add(_amiiboList[i].AmiiboSeries);
|
||||
_amiiboSeries.Add(amiibo.AmiiboSeries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -347,10 +340,16 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
SelectLastScannedAmiibo();
|
||||
}
|
||||
else
|
||||
else if (_amiiboSeries.Count > 0)
|
||||
{
|
||||
SeriesSelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
SeriesSelectedIndex = -1;
|
||||
}
|
||||
|
||||
FilterAmiibo();
|
||||
}
|
||||
|
||||
private void SelectLastScannedAmiibo()
|
||||
|
|
@ -360,59 +359,59 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
SeriesSelectedIndex = AmiiboSeries.IndexOf(scanned.AmiiboSeries);
|
||||
AmiiboSelectedIndex = AmiiboList.IndexOf(scanned);
|
||||
}
|
||||
|
||||
|
||||
private void FilterAmiibo()
|
||||
{
|
||||
_amiibos.Clear();
|
||||
|
||||
List<AmiiboApi> amiiboSortedList;
|
||||
|
||||
// If no series selected, just display all available amiibos
|
||||
if (_seriesSelectedIndex < 0)
|
||||
{
|
||||
amiiboSortedList = _amiiboList
|
||||
.OrderBy(amiibo => amiibo.AmiiboSeries)
|
||||
.ThenBy(x => x.Name)
|
||||
.ThenBy(amiibo => amiibo.Name)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
string selectedSeries = _amiiboSeries[SeriesSelectedIndex];
|
||||
|
||||
amiiboSortedList = _amiiboList
|
||||
.Where(amiibo => amiibo.AmiiboSeries == _amiiboSeries[SeriesSelectedIndex])
|
||||
.OrderBy(amiibo => amiibo.Name).ToList();
|
||||
.Where(amiibo => amiibo.AmiiboSeries == selectedSeries)
|
||||
.OrderBy(amiibo => amiibo.Name)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < amiiboSortedList.Count; i++)
|
||||
foreach (var amiibo in amiiboSortedList)
|
||||
{
|
||||
if (!_amiibos.Contains(amiiboSortedList[i]))
|
||||
if (!_showAllAmiibo)
|
||||
{
|
||||
if (!_showAllAmiibo)
|
||||
{
|
||||
foreach (AmiiboApiGamesSwitch game in amiiboSortedList[i].GamesSwitch)
|
||||
{
|
||||
if (game != null)
|
||||
{
|
||||
if (game.GameId.Contains(TitleId))
|
||||
{
|
||||
_amiibos.Add(amiiboSortedList[i]);
|
||||
bool compatible = amiibo.GamesSwitch.Any(game => game != null && game.GameId.Contains(TitleId));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (compatible)
|
||||
{
|
||||
_amiibos.Add(amiiboSortedList[i]);
|
||||
_amiibos.Add(amiibo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_amiibos.Add(amiibo);
|
||||
}
|
||||
}
|
||||
|
||||
AmiiboSelectedIndex = 0;
|
||||
}
|
||||
int restoredIndex = -1;
|
||||
for (int i = 0; i < _amiibos.Count; i++)
|
||||
{
|
||||
if (_amiibos[i].GetId() == LastScannedAmiiboId)
|
||||
{
|
||||
restoredIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
AmiiboSelectedIndex = restoredIndex != -1 ? restoredIndex : (_amiibos.Count > 0 ? 0 : -1);
|
||||
}
|
||||
private void SetAmiiboDetails()
|
||||
{
|
||||
ResetAmiiboPreview();
|
||||
|
|
@ -420,44 +419,32 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
Usage = string.Empty;
|
||||
|
||||
if (_amiiboSelectedIndex < 0 || _amiibos.Count < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AmiiboApi selected = _amiibos[_amiiboSelectedIndex];
|
||||
|
||||
string imageUrl = _amiiboList.FirstOrDefault(amiibo => amiibo.Equals(selected)).Image;
|
||||
string imageUrl = selected.Image;
|
||||
|
||||
StringBuilder usageStringBuilder = new();
|
||||
|
||||
for (int i = 0; i < _amiiboList.Count; i++)
|
||||
foreach (var game in selected.GamesSwitch)
|
||||
{
|
||||
if (_amiiboList[i].Equals(selected))
|
||||
if (game != null && game.GameId.Contains(TitleId))
|
||||
{
|
||||
bool writable = false;
|
||||
|
||||
foreach (AmiiboApiGamesSwitch item in _amiiboList[i].GamesSwitch)
|
||||
foreach (var usageItem in game.AmiiboUsage)
|
||||
{
|
||||
if (item.GameId.Contains(TitleId))
|
||||
{
|
||||
foreach (AmiiboApiUsage usageItem in item.AmiiboUsage)
|
||||
{
|
||||
usageStringBuilder.Append($"{Environment.NewLine}- {usageItem.Usage.Replace("/", Environment.NewLine + "-")}");
|
||||
|
||||
writable = usageItem.Write;
|
||||
}
|
||||
}
|
||||
usageStringBuilder.Append($"{Environment.NewLine}- {usageItem.Usage.Replace("/", Environment.NewLine + "-")}");
|
||||
}
|
||||
|
||||
if (usageStringBuilder.Length == 0)
|
||||
{
|
||||
usageStringBuilder.Append($"{LocaleManager.Instance[LocaleKeys.Unknown]}.");
|
||||
}
|
||||
|
||||
Usage = $"{LocaleManager.Instance[LocaleKeys.AmiiboUsage]}{(writable ? $"({LocaleManager.Instance[LocaleKeys.Writable]})" : string.Empty)}{usageStringBuilder}";
|
||||
}
|
||||
}
|
||||
|
||||
if (usageStringBuilder.Length == 0)
|
||||
{
|
||||
usageStringBuilder.Append($"{LocaleManager.Instance[LocaleKeys.Unknown]}.");
|
||||
}
|
||||
|
||||
Usage = $"{LocaleManager.Instance[LocaleKeys.AmiiboUsage]}{usageStringBuilder}";
|
||||
|
||||
_ = UpdateAmiiboPreview(imageUrl);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue