mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-06-28 06:46:24 +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": "節省的儲存空間"
|
"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",
|
"ID": "XCITrimmerTrim",
|
||||||
"Translations": {
|
"Translations": {
|
||||||
|
|
|
@ -47,10 +47,18 @@ namespace Ryujinx.Ava.Common.Locale
|
||||||
|
|
||||||
private void Load()
|
private void Load()
|
||||||
{
|
{
|
||||||
string localeLanguageCode = !string.IsNullOrEmpty(ConfigurationState.Instance.UI.LanguageCode.Value) ?
|
try
|
||||||
ConfigurationState.Instance.UI.LanguageCode.Value : CultureInfo.CurrentCulture.Name.Replace('-', '_');
|
{
|
||||||
|
string localeLanguageCode = !string.IsNullOrEmpty(ConfigurationState.Instance.UI.LanguageCode.Value)
|
||||||
|
? ConfigurationState.Instance.UI.LanguageCode.Value
|
||||||
|
: CultureInfo.CurrentCulture.Name.Replace('-', '_');
|
||||||
|
|
||||||
LoadLanguage(localeLanguageCode);
|
LoadLanguage(localeLanguageCode);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
LoadLanguage(DefaultLanguageCode);
|
||||||
|
}
|
||||||
|
|
||||||
// Save whatever we ended up with.
|
// Save whatever we ended up with.
|
||||||
if (Program.PreviewerDetached)
|
if (Program.PreviewerDetached)
|
||||||
|
|
|
@ -25,19 +25,24 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value is not XCITrimmerFileModel app)
|
if (value is not XCITrimmerFileModel model)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.PercentageProgress != null ? String.Empty :
|
return model.PercentageProgress != null ? String.Empty :
|
||||||
app.ProcessingOutcome != OperationOutcome.Successful && app.ProcessingOutcome != OperationOutcome.Undetermined ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusFailedLabel] :
|
model.ProcessingOutcome != OperationOutcome.Successful && model.ProcessingOutcome != OperationOutcome.Undetermined ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusFailedLabel] :
|
||||||
app.Trimmable & app.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusPartialLabel] :
|
model.Trimmable & model.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusPartialLabel] :
|
||||||
app.Trimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusTrimmableLabel] :
|
model.Trimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusTrimmableLabel] :
|
||||||
app.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusUntrimmableLabel] :
|
model.Untrimmable ? LocaleManager.Instance[LocaleKeys.TitleXCIStatusUntrimmableLabel] :
|
||||||
String.Empty;
|
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)
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
{
|
{
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
|
|
|
@ -10,6 +10,7 @@ using Ryujinx.Ava.Systems.AppLibrary;
|
||||||
using Ryujinx.Common.Utilities;
|
using Ryujinx.Common.Utilities;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using static Ryujinx.Common.Utilities.XCIFileTrimmer;
|
using static Ryujinx.Common.Utilities.XCIFileTrimmer;
|
||||||
|
@ -28,6 +29,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
public enum SortField
|
public enum SortField
|
||||||
{
|
{
|
||||||
Name,
|
Name,
|
||||||
|
Status,
|
||||||
Saved
|
Saved
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,6 +248,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
{
|
{
|
||||||
return string.IsNullOrWhiteSpace(_search)
|
return string.IsNullOrWhiteSpace(_search)
|
||||||
|| content.Name.ToLower().Contains(_search.ToLower())
|
|| content.Name.ToLower().Contains(_search.ToLower())
|
||||||
|
|| XCITrimmerFileStatusConverter.From(content).ToLower().Contains(_search.ToLower())
|
||||||
|| content.Path.ToLower().Contains(_search.ToLower());
|
|| content.Path.ToLower().Contains(_search.ToLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,17 +273,23 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
case SortField.Name:
|
case SortField.Name:
|
||||||
result = x.Name.CompareTo(y.Name);
|
result = x.Name.CompareTo(y.Name);
|
||||||
break;
|
break;
|
||||||
|
case SortField.Status:
|
||||||
|
result = XCITrimmerFileStatusConverter.From(x).CompareTo(XCITrimmerFileStatusConverter.From(y));
|
||||||
|
break;
|
||||||
case SortField.Saved:
|
case SortField.Saved:
|
||||||
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
|
result = x.PotentialSavingsB.CompareTo(y.PotentialSavingsB);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_viewModel.SortingAscending)
|
|
||||||
result = -result;
|
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
result = x.Path.CompareTo(y.Path);
|
result = x.Path.CompareTo(y.Path);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
result = x.Name.CompareTo(y.Name);
|
||||||
|
|
||||||
|
if (!_viewModel.SortingAscending)
|
||||||
|
result = -result;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,6 +476,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
return SortingField switch
|
return SortingField switch
|
||||||
{
|
{
|
||||||
SortField.Name => LocaleManager.Instance[LocaleKeys.XCITrimmerSortName],
|
SortField.Name => LocaleManager.Instance[LocaleKeys.XCITrimmerSortName],
|
||||||
|
SortField.Status => LocaleManager.Instance[LocaleKeys.XCITrimmerSortStatus],
|
||||||
SortField.Saved => LocaleManager.Instance[LocaleKeys.XCITrimmerSortSaved],
|
SortField.Saved => LocaleManager.Instance[LocaleKeys.XCITrimmerSortSaved],
|
||||||
_ => string.Empty,
|
_ => string.Empty,
|
||||||
};
|
};
|
||||||
|
@ -487,6 +497,11 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
get => _sortField == SortField.Name;
|
get => _sortField == SortField.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsSortedByStatus
|
||||||
|
{
|
||||||
|
get => _sortField == SortField.Status;
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsSortedBySaved
|
public bool IsSortedBySaved
|
||||||
{
|
{
|
||||||
get => _sortField == SortField.Saved;
|
get => _sortField == SortField.Saved;
|
||||||
|
|
|
@ -45,13 +45,19 @@
|
||||||
Orientation="Vertical">
|
Orientation="Vertical">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
Checked="Sort_Checked"
|
IsCheckedChanged="Sort_Checked"
|
||||||
Content="{ext:Locale XCITrimmerSortName}"
|
Content="{ext:Locale XCITrimmerSortName}"
|
||||||
GroupName="Sort"
|
GroupName="Sort"
|
||||||
IsChecked="{Binding IsSortedByName, Mode=OneTime}"
|
IsChecked="{Binding IsSortedByName, Mode=OneTime}"
|
||||||
Tag="Name" />
|
Tag="Name" />
|
||||||
<RadioButton
|
<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}"
|
Content="{ext:Locale XCITrimmerSortSaved}"
|
||||||
GroupName="Sort"
|
GroupName="Sort"
|
||||||
IsChecked="{Binding IsSortedBySaved, Mode=OneTime}"
|
IsChecked="{Binding IsSortedBySaved, Mode=OneTime}"
|
||||||
|
@ -67,13 +73,13 @@
|
||||||
<Separator Height="0" HorizontalAlignment="Stretch" />
|
<Separator Height="0" HorizontalAlignment="Stretch" />
|
||||||
</Border>
|
</Border>
|
||||||
<RadioButton
|
<RadioButton
|
||||||
Checked="Order_Checked"
|
IsCheckedChanged="Order_Checked"
|
||||||
Content="{ext:Locale OrderAscending}"
|
Content="{ext:Locale OrderAscending}"
|
||||||
GroupName="Order"
|
GroupName="Order"
|
||||||
IsChecked="{Binding SortingAscending, Mode=OneTime}"
|
IsChecked="{Binding SortingAscending, Mode=OneTime}"
|
||||||
Tag="Ascending" />
|
Tag="Ascending" />
|
||||||
<RadioButton
|
<RadioButton
|
||||||
Checked="Order_Checked"
|
IsCheckedChanged="Order_Checked"
|
||||||
Content="{ext:Locale OrderDescending}"
|
Content="{ext:Locale OrderDescending}"
|
||||||
GroupName="Order"
|
GroupName="Order"
|
||||||
IsChecked="{Binding !SortingAscending, Mode=OneTime}"
|
IsChecked="{Binding !SortingAscending, Mode=OneTime}"
|
||||||
|
@ -151,7 +157,7 @@
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
CornerRadius="5"
|
CornerRadius="5"
|
||||||
IsVisible="{Binding $parent[UserControl].((viewModels:XciTrimmerViewModel)DataContext).Processing}"
|
IsVisible="{Binding $parent[UserControl].((viewModels:XciTrimmerViewModel)DataContext).Processing, FallbackValue=False}"
|
||||||
Maximum="100"
|
Maximum="100"
|
||||||
Minimum="0"
|
Minimum="0"
|
||||||
Value="{Binding PercentageProgress}" />
|
Value="{Binding PercentageProgress}" />
|
||||||
|
|
|
@ -62,14 +62,28 @@ namespace Ryujinx.Ava.UI.Views.Dialog
|
||||||
|
|
||||||
public void Sort_Checked(object sender, RoutedEventArgs args)
|
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);
|
ViewModel.SortingField = Enum.Parse<XciTrimmerViewModel.SortField>(sortField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Order_Checked(object sender, RoutedEventArgs args)
|
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";
|
ViewModel.SortingAscending = sortOrder is "Ascending";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue