2023-10-12 18:33:06 +00:00
|
|
|
|
using Wabbajack.Downloaders;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
using Wabbajack.DTOs.JsonConverters;
|
|
|
|
|
using Wabbajack.Paths;
|
2023-10-12 18:33:06 +00:00
|
|
|
|
using Wabbajack.RateLimiter;
|
|
|
|
|
using Wabbajack.Util;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
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-10-12 18:33:06 +00:00
|
|
|
|
private readonly Configuration.MainSettings _settings;
|
|
|
|
|
private readonly int _defaultMaximumMemoryPerDownloadThreadMb;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
2023-10-12 18:33:06 +00:00
|
|
|
|
public PerformanceSettings(Configuration.MainSettings settings, IResource<DownloadDispatcher> downloadResources, SystemParametersConstructor systemParams)
|
|
|
|
|
{
|
|
|
|
|
var p = systemParams.Create();
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
2023-10-12 18:33:06 +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;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
2023-10-12 18:33:06 +00:00
|
|
|
|
if (MaximumMemoryPerDownloadThreadMb < 0)
|
2022-03-13 22:47:30 +00:00
|
|
|
|
{
|
2023-10-12 18:33:06 +00:00
|
|
|
|
ResetMaximumMemoryPerDownloadThreadMb();
|
2022-03-13 22:47:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-12 18:33:06 +00:00
|
|
|
|
private int _maximumMemoryPerDownloadThreadMb;
|
|
|
|
|
|
|
|
|
|
public int MaximumMemoryPerDownloadThreadMb
|
2022-03-13 22:47:30 +00:00
|
|
|
|
{
|
2023-10-12 18:33:06 +00:00
|
|
|
|
get => _maximumMemoryPerDownloadThreadMb;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-10-12 18:33:06 +00:00
|
|
|
|
RaiseAndSetIfChanged(ref _maximumMemoryPerDownloadThreadMb, value);
|
|
|
|
|
_settings.PerformanceSettings.MaximumMemoryPerDownloadThreadMb = value;
|
2022-03-13 22:47:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-12 18:33:06 +00:00
|
|
|
|
public void ResetMaximumMemoryPerDownloadThreadMb()
|
2022-03-13 22:47:30 +00:00
|
|
|
|
{
|
2023-10-12 18:33:06 +00:00
|
|
|
|
MaximumMemoryPerDownloadThreadMb = _defaultMaximumMemoryPerDownloadThreadMb;
|
|
|
|
|
}
|
2022-03-13 22:47:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|