diff --git a/Ryujinx.Ava/Assets/Styles/Styles.xaml b/Ryujinx.Ava/Assets/Styles/Styles.xaml index 04412bf2e3..681b4feaf4 100644 --- a/Ryujinx.Ava/Assets/Styles/Styles.xaml +++ b/Ryujinx.Ava/Assets/Styles/Styles.xaml @@ -234,6 +234,9 @@ + diff --git a/Ryujinx.Ava/UI/Models/SaveModel.cs b/Ryujinx.Ava/UI/Models/SaveModel.cs index 7096f9d794..ab919c88d5 100644 --- a/Ryujinx.Ava/UI/Models/SaveModel.cs +++ b/Ryujinx.Ava/UI/Models/SaveModel.cs @@ -1,13 +1,9 @@ -using LibHac; using LibHac.Fs; -using LibHac.Fs.Shim; using LibHac.Ncm; -using Ryujinx.Ava.Common; -using Ryujinx.Ava.Common.Locale; -using Ryujinx.Ava.UI.Helpers; using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ava.UI.Windows; using Ryujinx.HLE.FileSystem; +using System; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -16,7 +12,6 @@ namespace Ryujinx.Ava.UI.Models { public class SaveModel : BaseModel { - private readonly HorizonClient _horizonClient; private long _size; public ulong SaveId { get; } @@ -41,11 +36,29 @@ namespace Ryujinx.Ava.UI.Models public bool SizeAvailable { get; set; } - public string SizeString => $"{((float)_size * 0.000000954):0.###}MB"; + public string SizeString => GetSizeString(); - public SaveModel(SaveDataInfo info, HorizonClient horizonClient, VirtualFileSystem virtualFileSystem) + private string GetSizeString() + { + const int scale = 1024; + string[] orders = { "GiB", "MiB", "KiB" }; + long max = (long)Math.Pow(scale, orders.Length); + + foreach (string order in orders) + { + if (Size > max) + { + return $"{decimal.Divide(Size, max):##.##} {order}"; + } + + max /= scale; + } + + return "0 KiB"; + } + + public SaveModel(SaveDataInfo info, VirtualFileSystem virtualFileSystem) { - _horizonClient = horizonClient; SaveId = info.SaveDataId; TitleId = info.ProgramId; UserId = info.UserId; diff --git a/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs b/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs index bd37435084..dad74230f6 100644 --- a/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs +++ b/Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs @@ -13,8 +13,8 @@ namespace Ryujinx.Ava.UI.ViewModels private int _sortIndex; private int _orderIndex; private string _search; - private ObservableCollection _saves; - private ObservableCollection _views; + private ObservableCollection _saves = new(); + private ObservableCollection _views = new(); private AccountManager _accountManager; public string SaveManagerHeading => @@ -77,8 +77,6 @@ namespace Ryujinx.Ava.UI.ViewModels public UserSaveManagerViewModel(AccountManager accountManager) { _accountManager = accountManager; - _saves = new ObservableCollection(); - _views = new ObservableCollection(); } public void Sort() diff --git a/Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml b/Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml index e83a650462..ac8ede7ae5 100644 --- a/Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml +++ b/Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml @@ -74,7 +74,6 @@ Margin="5,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Center" - VerticalContentAlignment="Center" DockPanel.Dock="Right" KeyUp="SearchBox_OnKeyUp" Text="{Binding SearchText}" diff --git a/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml b/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml index cdf74d52f1..b4f2e1014e 100644 --- a/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml +++ b/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml @@ -55,6 +55,11 @@ HorizontalContentAlignment="Left" Content="{locale:Locale Size}" /> + + + @@ -69,6 +74,11 @@ HorizontalContentAlignment="Left" Content="{locale:Locale OrderDescending}" /> + + +