aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com>2023-01-12 07:23:24 -0500
committerGitHub <noreply@github.com>2023-01-12 12:23:24 +0000
commit9f57747c57a6d20f3e0787fae744ae97aeeae4af (patch)
treeabf6202227fdcc3b5398c17629e643496f86e974
parentfe29a2ff6e7ae94b9e1f8cedc93d7fd0187de3cf (diff)
Ava UI: Various Fixes (#4268)1.1.547
* Fix saves disappearing * Better size formatter * Move TextBox alignment fix to Styles * Fix bug * Left align * Add border * Update Ryujinx.Ava/UI/Models/SaveModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Update Ryujinx.Ava/UI/Models/SaveModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Update Ryujinx.Ava/UI/Models/SaveModel.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * Whitespace Co-authored-by: Ac_K <Acoustik666@gmail.com>
-rw-r--r--Ryujinx.Ava/Assets/Styles/Styles.xaml3
-rw-r--r--Ryujinx.Ava/UI/Models/SaveModel.cs31
-rw-r--r--Ryujinx.Ava/UI/ViewModels/UserSaveManagerViewModel.cs6
-rw-r--r--Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml1
-rw-r--r--Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml12
-rw-r--r--Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs7
6 files changed, 42 insertions, 18 deletions
diff --git a/Ryujinx.Ava/Assets/Styles/Styles.xaml b/Ryujinx.Ava/Assets/Styles/Styles.xaml
index 04412bf2..681b4fea 100644
--- a/Ryujinx.Ava/Assets/Styles/Styles.xaml
+++ b/Ryujinx.Ava/Assets/Styles/Styles.xaml
@@ -234,6 +234,9 @@
<Setter Property="BorderBrush" Value="{DynamicResource MenuFlyoutPresenterBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource MenuFlyoutPresenterBorderThemeThickness}" />
</Style>
+ <Style Selector="TextBox">
+ <Setter Property="VerticalContentAlignment" Value="Center" />
+ </Style>
<Style Selector="TextBox.NumberBoxTextBoxStyle">
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundColor}" />
</Style>
diff --git a/Ryujinx.Ava/UI/Models/SaveModel.cs b/Ryujinx.Ava/UI/Models/SaveModel.cs
index 7096f9d7..ab919c88 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 bd374350..dad74230 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<SaveModel> _saves;
- private ObservableCollection<SaveModel> _views;
+ private ObservableCollection<SaveModel> _saves = new();
+ private ObservableCollection<SaveModel> _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<SaveModel>();
- _views = new ObservableCollection<SaveModel>();
}
public void Sort()
diff --git a/Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml b/Ryujinx.Ava/UI/Views/Main/MainViewControls.axaml
index e83a6504..ac8ede7a 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 cdf74d52..b4f2e101 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}" />
</ComboBoxItem>
+ <ComboBox.Styles>
+ <Style Selector="ContentControl#ContentPresenter">
+ <Setter Property="HorizontalAlignment" Value="Left" />
+ </Style>
+ </ComboBox.Styles>
</ComboBox>
<ComboBox SelectedIndex="{Binding OrderIndex}" Width="150">
<ComboBoxItem>
@@ -69,6 +74,11 @@
HorizontalContentAlignment="Left"
Content="{locale:Locale OrderDescending}" />
</ComboBoxItem>
+ <ComboBox.Styles>
+ <Style Selector="ContentControl#ContentPresenter">
+ <Setter Property="HorizontalAlignment" Value="Left" />
+ </Style>
+ </ComboBox.Styles>
</ComboBox>
</StackPanel>
<Grid
@@ -122,6 +132,8 @@
Height="42"
Width="42"
Padding="10"
+ BorderBrush="{DynamicResource AppListHoverBackgroundColor}"
+ BorderThickness="1"
IsVisible="{Binding !InGameList}">
<ui:SymbolIcon
Symbol="Help"
diff --git a/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs b/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
index 9d955326..074ca30e 100644
--- a/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
+++ b/Ryujinx.Ava/UI/Views/User/UserSaveManagerView.axaml.cs
@@ -94,7 +94,7 @@ namespace Ryujinx.Ava.UI.Views.User
var save = saveDataInfo[i];
if (save.ProgramId.Value != 0)
{
- var saveModel = new SaveModel(save, _horizonClient, _virtualFileSystem);
+ var saveModel = new SaveModel(save, _virtualFileSystem);
saves.Add(saveModel);
}
}
@@ -137,10 +137,9 @@ namespace Ryujinx.Ava.UI.Views.User
if (result == UserResult.Yes)
{
_horizonClient.Fs.DeleteSaveData(SaveDataSpaceId.User, saveModel.SaveId);
+ ViewModel.Saves.Remove(saveModel);
+ ViewModel.Sort();
}
-
- ViewModel.Saves.Remove(saveModel);
- ViewModel.Views.Remove(saveModel);
}
}
}