0
0
Fork 0

Ava UI: Various Fixes (#4268)

* 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>
This commit is contained in:
Isaac Marovitz 2023-01-12 07:23:24 -05:00 committed by GitHub
parent fe29a2ff6e
commit 9f57747c57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 18 deletions

View file

@ -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>

View file

@ -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;

View file

@ -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()

View file

@ -74,7 +74,6 @@
Margin="5,0,5,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
DockPanel.Dock="Right"
KeyUp="SearchBox_OnKeyUp"
Text="{Binding SearchText}"

View file

@ -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"

View file

@ -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);
}
}
}