wabbajack/Wabbajack.App.Wpf/Settings.cs

55 lines
1.9 KiB
C#
Raw Normal View History

using Wabbajack.Downloaders;
using Wabbajack.DTOs.JsonConverters;
using Wabbajack.Paths;
2023-08-20 09:18:24 +00:00
using Wabbajack.RateLimiter;
using Wabbajack.Util;
namespace Wabbajack
{
[JsonName("Mo2ModListInstallerSettings")]
public class Mo2ModlistInstallationSettings
{
public AbsolutePath InstallationLocation { get; set; }
public AbsolutePath DownloadLocation { get; set; }
public bool AutomaticallyOverrideExistingInstall { get; set; }
}
public class PerformanceSettings : ViewModel
{
2023-08-20 09:18:24 +00:00
private readonly Configuration.MainSettings _settings;
private readonly int _defaultMaximumMemoryPerDownloadThreadMb;
2023-08-20 09:18:24 +00:00
public PerformanceSettings(Configuration.MainSettings settings, IResource<DownloadDispatcher> downloadResources, SystemParametersConstructor systemParams)
{
var p = systemParams.Create();
2023-08-20 09:18:24 +00:00
_settings = settings;
// Split half of available memory among download threads
_defaultMaximumMemoryPerDownloadThreadMb = (int)(p.SystemMemorySize / downloadResources.MaxTasks / 1024 / 1024) / 2;
_maximumMemoryPerDownloadThreadMb = settings.PerformanceSettings.MaximumMemoryPerDownloadThreadMb;
2023-08-20 09:18:24 +00:00
if (MaximumMemoryPerDownloadThreadMb < 0)
{
2023-08-20 09:18:24 +00:00
ResetMaximumMemoryPerDownloadThreadMb();
}
}
2023-08-20 09:18:24 +00:00
private int _maximumMemoryPerDownloadThreadMb;
public int MaximumMemoryPerDownloadThreadMb
{
2023-08-20 09:18:24 +00:00
get => _maximumMemoryPerDownloadThreadMb;
set
{
2023-08-20 09:18:24 +00:00
RaiseAndSetIfChanged(ref _maximumMemoryPerDownloadThreadMb, value);
_settings.PerformanceSettings.MaximumMemoryPerDownloadThreadMb = value;
}
}
2023-08-20 09:18:24 +00:00
public void ResetMaximumMemoryPerDownloadThreadMb()
{
2023-08-20 09:18:24 +00:00
MaximumMemoryPerDownloadThreadMb = _defaultMaximumMemoryPerDownloadThreadMb;
}
}
}