mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-18 12:55:54 +01:00
misc: chore: Collapse XCIFileTrimmerLog implementations into a single class.
This commit is contained in:
parent
39252b7267
commit
9da97bc911
@ -1,24 +0,0 @@
|
|||||||
using Avalonia.Threading;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common
|
|
||||||
{
|
|
||||||
internal class XCIFileTrimmerMainWindowLog : Ryujinx.Common.Logging.XCIFileTrimmerLog
|
|
||||||
{
|
|
||||||
private readonly MainWindowViewModel _viewModel;
|
|
||||||
|
|
||||||
public XCIFileTrimmerMainWindowLog(MainWindowViewModel viewModel)
|
|
||||||
{
|
|
||||||
_viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Progress(long current, long total, string text, bool complete)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
_viewModel.StatusBarProgressMaximum = (int)(total);
|
|
||||||
_viewModel.StatusBarProgressValue = (int)(current);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
using Avalonia.Threading;
|
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
|
||||||
|
|
||||||
namespace Ryujinx.Ava.Common
|
|
||||||
{
|
|
||||||
internal class XCIFileTrimmerWindowLog : Ryujinx.Common.Logging.XCIFileTrimmerLog
|
|
||||||
{
|
|
||||||
private readonly XCITrimmerViewModel _viewModel;
|
|
||||||
|
|
||||||
public XCIFileTrimmerWindowLog(XCITrimmerViewModel viewModel)
|
|
||||||
{
|
|
||||||
_viewModel = viewModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Progress(long current, long total, string text, bool complete)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.Post(() =>
|
|
||||||
{
|
|
||||||
_viewModel.SetProgress((int)(current), (int)(total));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
45
src/Ryujinx/Common/XCITrimmerLog.cs
Normal file
45
src/Ryujinx/Common/XCITrimmerLog.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using Avalonia.Threading;
|
||||||
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.Common
|
||||||
|
{
|
||||||
|
public static class XCITrimmerLog
|
||||||
|
{
|
||||||
|
internal class MainWindow : Ryujinx.Common.Logging.XCIFileTrimmerLog
|
||||||
|
{
|
||||||
|
private readonly MainWindowViewModel _viewModel;
|
||||||
|
|
||||||
|
public MainWindow(MainWindowViewModel viewModel)
|
||||||
|
{
|
||||||
|
_viewModel = viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Progress(long current, long total, string text, bool complete)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
{
|
||||||
|
_viewModel.StatusBarProgressMaximum = (int)(total);
|
||||||
|
_viewModel.StatusBarProgressValue = (int)(current);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class TrimmerWindow : Ryujinx.Common.Logging.XCIFileTrimmerLog
|
||||||
|
{
|
||||||
|
private readonly XCITrimmerViewModel _viewModel;
|
||||||
|
|
||||||
|
public TrimmerWindow(XCITrimmerViewModel viewModel)
|
||||||
|
{
|
||||||
|
_viewModel = viewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Progress(long current, long total, string text, bool complete)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Post(() =>
|
||||||
|
{
|
||||||
|
_viewModel.SetProgress((int)(current), (int)(total));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -402,7 +402,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public bool OpenDeviceSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0;
|
public bool OpenDeviceSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.DeviceSaveDataSize > 0;
|
||||||
|
|
||||||
public bool TrimXCIEnabled => Ryujinx.Common.Utilities.XCIFileTrimmer.CanTrim(SelectedApplication.Path, new Common.XCIFileTrimmerMainWindowLog(this));
|
public bool TrimXCIEnabled => XCIFileTrimmer.CanTrim(SelectedApplication.Path, new XCITrimmerLog.MainWindow(this));
|
||||||
|
|
||||||
public bool OpenBcatSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
|
public bool OpenBcatSaveDirectoryEnabled => !SelectedApplication.ControlHolder.ByteSpan.IsZeros() && SelectedApplication.ControlHolder.Value.BcatDeliveryCacheStorageSize > 0;
|
||||||
|
|
||||||
@ -2165,7 +2165,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var trimmer = new XCIFileTrimmer(filename, new Common.XCIFileTrimmerMainWindowLog(this));
|
var trimmer = new XCIFileTrimmer(filename, new XCITrimmerLog.MainWindow(this));
|
||||||
|
|
||||||
if (trimmer.CanBeTrimmed)
|
if (trimmer.CanBeTrimmed)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
private const string _FileExtXCI = "XCI";
|
private const string _FileExtXCI = "XCI";
|
||||||
|
|
||||||
private readonly Ryujinx.Common.Logging.XCIFileTrimmerLog _logger;
|
private readonly Ryujinx.Common.Logging.XCIFileTrimmerLog _logger;
|
||||||
private readonly ApplicationLibrary _applicationLibrary;
|
private ApplicationLibrary ApplicationLibrary => _mainWindowViewModel.ApplicationLibrary;
|
||||||
private Optional<XCITrimmerFileModel> _processingApplication = null;
|
private Optional<XCITrimmerFileModel> _processingApplication = null;
|
||||||
private AvaloniaList<XCITrimmerFileModel> _allXCIFiles = new();
|
private AvaloniaList<XCITrimmerFileModel> _allXCIFiles = new();
|
||||||
private AvaloniaList<XCITrimmerFileModel> _selectedXCIFiles = new();
|
private AvaloniaList<XCITrimmerFileModel> _selectedXCIFiles = new();
|
||||||
@ -47,15 +47,14 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
|
|
||||||
public XCITrimmerViewModel(MainWindowViewModel mainWindowViewModel)
|
public XCITrimmerViewModel(MainWindowViewModel mainWindowViewModel)
|
||||||
{
|
{
|
||||||
_logger = new XCIFileTrimmerWindowLog(this);
|
_logger = new XCITrimmerLog.TrimmerWindow(this);
|
||||||
_mainWindowViewModel = mainWindowViewModel;
|
_mainWindowViewModel = mainWindowViewModel;
|
||||||
_applicationLibrary = _mainWindowViewModel.ApplicationLibrary;
|
|
||||||
LoadXCIApplications();
|
LoadXCIApplications();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadXCIApplications()
|
private void LoadXCIApplications()
|
||||||
{
|
{
|
||||||
var apps = _applicationLibrary.Applications.Items
|
var apps = ApplicationLibrary.Applications.Items
|
||||||
.Where(app => app.FileExtension == _FileExtXCI);
|
.Where(app => app.FileExtension == _FileExtXCI);
|
||||||
|
|
||||||
foreach (var xciApp in apps)
|
foreach (var xciApp in apps)
|
||||||
@ -68,7 +67,7 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
string path,
|
string path,
|
||||||
OperationOutcome operationOutcome = OperationOutcome.Undetermined)
|
OperationOutcome operationOutcome = OperationOutcome.Undetermined)
|
||||||
{
|
{
|
||||||
var xciApp = _applicationLibrary.Applications.Items.First(app => app.FileExtension == _FileExtXCI && app.Path == path);
|
var xciApp = ApplicationLibrary.Applications.Items.First(app => app.FileExtension == _FileExtXCI && app.Path == path);
|
||||||
return XCITrimmerFileModel.FromApplicationData(xciApp, _logger) with { ProcessingOutcome = operationOutcome };
|
return XCITrimmerFileModel.FromApplicationData(xciApp, _logger) with { ProcessingOutcome = operationOutcome };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,4 +537,4 @@ namespace Ryujinx.Ava.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user