mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 00:16:23 +02:00
Defaulted language if any errors occur when loading locale so that Avalonia Preview works. Added Status to Sort and Search for XCI File trimmer.
This commit is contained in:
parent
11cc80f7fc
commit
55adb63855
6 changed files with 94 additions and 21 deletions
|
@ -21272,6 +21272,31 @@
|
|||
"zh_TW": "節省的儲存空間"
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "XCITrimmerSortStatus",
|
||||
"Translations": {
|
||||
"ar_SA": "",
|
||||
"de_DE": "",
|
||||
"el_GR": "",
|
||||
"en_US": "Status",
|
||||
"es_ES": "",
|
||||
"fr_FR": "",
|
||||
"he_IL": "",
|
||||
"it_IT": "",
|
||||
"ja_JP": "",
|
||||
"ko_KR": "",
|
||||
"no_NO": "",
|
||||
"pl_PL": "",
|
||||
"pt_BR": "",
|
||||
"ru_RU": "",
|
||||
"sv_SE": "",
|
||||
"th_TH": "",
|
||||
"tr_TR": "",
|
||||
"uk_UA": "",
|
||||
"zh_CN": "",
|
||||
"zh_TW": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"ID": "XCITrimmerTrim",
|
||||
"Translations": {
|
||||
|
@ -24748,4 +24773,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,18 @@ namespace Ryujinx.Ava.Common.Locale
|
|||
|
||||
private void Load()
|
||||
{
|
||||
string localeLanguageCode = !string.IsNullOrEmpty(ConfigurationState.Instance.UI.LanguageCode.Value) ?
|
||||
ConfigurationState.Instance.UI.LanguageCode.Value : CultureInfo.CurrentCulture.Name.Replace('-', '_');
|
||||
|
||||
LoadLanguage(localeLanguageCode);
|
||||
try
|
||||
{
|
||||
string localeLanguageCode = !string.IsNullOrEmpty(ConfigurationState.Instance.UI.LanguageCode.Value)
|
||||
? ConfigurationState.Instance.UI.LanguageCode.Value
|
||||
: CultureInfo.CurrentCulture.Name.Replace('-', '_');
|
||||
|
||||
LoadLanguage(localeLanguageCode);
|
||||
}
|
||||
catch
|
||||
{
|
||||
LoadLanguage(DefaultLanguageCode);
|
||||
}
|
||||
|
||||
// Save whatever we ended up with.
|
||||
if (Program.PreviewerDetached)
|
||||
|
|
|
@ -25,19 +25,24 @@ namespace Ryujinx.Ava.UI.Helpers
|
|||
return null;
|
||||
}
|
||||
|
||||
if (value is not XCITrimmerFileModel app)
|
||||
if (value is not XCITrimmerFileModel model)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return app.PercentageProgress != null ? String.Empty :
|
||||
app.ProcessingOutcome != OperationOutcome.Successful && app.ProcessingOutcome != OperationOutcome.Undetermined ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusFailedLabel] :
|
||||
app.Trimmable & app.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusPartialLabel] :
|
||||
app.Trimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusTrimmableLabel] :
|
||||
app.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusUntrimmableLabel] :
|
||||
return model.PercentageProgress != null ? String.Empty :
|
||||
model.ProcessingOutcome != OperationOutcome.Successful && model.ProcessingOutcome != OperationOutcome.Undetermined ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusFailedLabel] :
|
||||
model.Trimmable & model.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusPartialLabel] :
|
||||
model.Trimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusTrimmableLabel] :
|
||||
model.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusUntrimmableLabel] :
|
||||
String.Empty;
|
||||
}
|
||||
|
||||
public static string From(XCITrimmerFileModel model)
|
||||
{
|
||||
return (string)Instance.Convert(model, typeof(string), null, CultureInfo.CurrentUICulture) ?? String.Empty;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
|
|
|
@ -10,6 +10,7 @@ using Ryujinx.Ava.Systems.AppLibrary;
|
|||
using Ryujinx.Common.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using static Ryujinx.Common.Utilities.XCIFileTrimmer;
|
||||
|
@ -28,6 +29,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
public enum SortField
|
||||
{
|
||||
Name,
|
||||
Status,
|
||||
Saved
|
||||
}
|
||||
|
||||
|
@ -246,6 +248,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
{
|
||||
return string.IsNullOrWhiteSpace(_search)
|
||||
|| content.Name.ToLower().Contains(_search.ToLower())
|
||||
|| XCITrimmerFileStatusConverter.From(content).ToLower().Contains(_search.ToLower())
|
||||
|| content.Path.ToLower().Contains(_search.ToLower());
|
||||
}
|
||||
|
||||
|
@ -270,17 +273,23 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
case SortField.Name:
|
||||
result = x.Name.CompareTo(y.Name);
|
||||
break;
|
||||
case SortField.Status:
|
||||
result = XCITrimmerFileStatusConverter.From(x).CompareTo(XCITrimmerFileStatusConverter.From(y));
|
||||
break;
|
||||
case SortField.Saved:
|
||||
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!_viewModel.SortingAscending)
|
||||
result = -result;
|
||||
|
||||
if (result == 0)
|
||||
result = x.Path.CompareTo(y.Path);
|
||||
|
||||
if (result == 0)
|
||||
result = x.Name.CompareTo(y.Name);
|
||||
|
||||
if (!_viewModel.SortingAscending)
|
||||
result = -result;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -467,6 +476,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
return SortingField switch
|
||||
{
|
||||
SortField.Name => LocaleManager.Instance[LocaleKeys.XCITrimmerSortName],
|
||||
SortField.Status => LocaleManager.Instance[LocaleKeys.XCITrimmerSortStatus],
|
||||
SortField.Saved => LocaleManager.Instance[LocaleKeys.XCITrimmerSortSaved],
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
@ -487,6 +497,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||
get => _sortField == SortField.Name;
|
||||
}
|
||||
|
||||
public bool IsSortedByStatus
|
||||
{
|
||||
get => _sortField == SortField.Status;
|
||||
}
|
||||
|
||||
public bool IsSortedBySaved
|
||||
{
|
||||
get => _sortField == SortField.Saved;
|
||||
|
|
|
@ -45,13 +45,19 @@
|
|||
Orientation="Vertical">
|
||||
<StackPanel>
|
||||
<RadioButton
|
||||
Checked="Sort_Checked"
|
||||
IsCheckedChanged="Sort_Checked"
|
||||
Content="{ext:Locale XCITrimmerSortName}"
|
||||
GroupName="Sort"
|
||||
IsChecked="{Binding IsSortedByName, Mode=OneTime}"
|
||||
Tag="Name" />
|
||||
<RadioButton
|
||||
Checked="Sort_Checked"
|
||||
IsCheckedChanged="Sort_Checked"
|
||||
Content="{ext:Locale XCITrimmerSortStatus}"
|
||||
GroupName="Sort"
|
||||
IsChecked="{Binding IsSortedByStatus, Mode=OneTime}"
|
||||
Tag="Status" />
|
||||
<RadioButton
|
||||
IsCheckedChanged="Sort_Checked"
|
||||
Content="{ext:Locale XCITrimmerSortSaved}"
|
||||
GroupName="Sort"
|
||||
IsChecked="{Binding IsSortedBySaved, Mode=OneTime}"
|
||||
|
@ -67,13 +73,13 @@
|
|||
<Separator Height="0" HorizontalAlignment="Stretch" />
|
||||
</Border>
|
||||
<RadioButton
|
||||
Checked="Order_Checked"
|
||||
IsCheckedChanged="Order_Checked"
|
||||
Content="{ext:Locale OrderAscending}"
|
||||
GroupName="Order"
|
||||
IsChecked="{Binding SortingAscending, Mode=OneTime}"
|
||||
Tag="Ascending" />
|
||||
<RadioButton
|
||||
Checked="Order_Checked"
|
||||
IsCheckedChanged="Order_Checked"
|
||||
Content="{ext:Locale OrderDescending}"
|
||||
GroupName="Order"
|
||||
IsChecked="{Binding !SortingAscending, Mode=OneTime}"
|
||||
|
@ -151,7 +157,7 @@
|
|||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
CornerRadius="5"
|
||||
IsVisible="{Binding $parent[UserControl].((viewModels:XciTrimmerViewModel)DataContext).Processing}"
|
||||
IsVisible="{Binding $parent[UserControl].((viewModels:XciTrimmerViewModel)DataContext).Processing, FallbackValue=False}"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
Value="{Binding PercentageProgress}" />
|
||||
|
|
|
@ -62,14 +62,28 @@ namespace Ryujinx.Ava.UI.Views.Dialog
|
|||
|
||||
public void Sort_Checked(object sender, RoutedEventArgs args)
|
||||
{
|
||||
if (sender is RadioButton { Tag: string sortField })
|
||||
if (sender is not RadioButton { Tag: string sortField, IsChecked: { } isChecked })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChecked)
|
||||
{
|
||||
ViewModel.SortingField = Enum.Parse<XciTrimmerViewModel.SortField>(sortField);
|
||||
}
|
||||
}
|
||||
|
||||
public void Order_Checked(object sender, RoutedEventArgs args)
|
||||
{
|
||||
if (sender is RadioButton { Tag: string sortOrder })
|
||||
if (sender is not RadioButton { Tag: string sortOrder, IsChecked: { } isChecked })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChecked)
|
||||
{
|
||||
ViewModel.SortingAscending = sortOrder is "Ascending";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue