Make on-demand download timeout configurable.

This commit is contained in:
SternI 2026-04-02 17:03:33 +02:00
parent bd83589915
commit e09ab5e433
5 changed files with 84 additions and 5 deletions

View File

@ -106,6 +106,13 @@ public class DirectorySettings : ViewModel, ICloneable
set => SetProperty(ref _criwareDecryptionKey, value);
}
private uint _onDemandTimeout = 120;
public uint OnDemandTimeout
{
get => Math.Max(_onDemandTimeout, 60);
set => SetProperty(ref _onDemandTimeout, Math.Max(_onDemandTimeout, 60));
}
private bool Equals(DirectorySettings other)
{
return GameDirectory == other.GameDirectory && UeVersion == other.UeVersion;

View File

@ -231,7 +231,7 @@ public class CUE4ParseViewModel : ViewModel
{
ChunkHostUri = new Uri("https://download.epicgames.com/", UriKind.Absolute),
ChunkCacheDirectory = Directory.CreateDirectory(Path.Combine(UserSettings.Default.OutputDirectory, ".data")),
Timeout = TimeSpan.FromSeconds(30)
Timeout = TimeSpan.FromSeconds(UserSettings.Default.CurrentDir.OnDemandTimeout)
};
switch (Provider)

View File

@ -172,6 +172,13 @@ public class SettingsViewModel : ViewModel
set => SetProperty(ref _criwareDecryptionKey, value);
}
private uint _onDemandTimeout = 120;
public uint OnDemandTimeout
{
get => Math.Max(_onDemandTimeout, 60);
set => SetProperty(ref _onDemandTimeout, Math.Max(_onDemandTimeout, 60));
}
public bool SocketSettingsEnabled => SelectedMeshExportFormat == EMeshFormat.ActorX;
public bool CompressionSettingsEnabled => SelectedMeshExportFormat == EMeshFormat.UEFormat;
@ -237,6 +244,7 @@ public class SettingsViewModel : ViewModel
_optionsSnapshot = UserSettings.Default.CurrentDir.Versioning.Options;
_mapStructTypesSnapshot = UserSettings.Default.CurrentDir.Versioning.MapStructTypes;
_criwareDecryptionKey = UserSettings.Default.CurrentDir.CriwareDecryptionKey;
_onDemandTimeout = UserSettings.Default.CurrentDir.OnDemandTimeout;
AesEndpoint = UserSettings.Default.CurrentDir.Endpoints[0];
MappingEndpoint = UserSettings.Default.CurrentDir.Endpoints[1];
@ -273,6 +281,7 @@ public class SettingsViewModel : ViewModel
SelectedMaterialExportFormat = _materialExportFormatSnapshot;
SelectedTextureExportFormat = _textureExportFormatSnapshot;
CriwareDecryptionKey = _criwareDecryptionKey;
OnDemandTimeout = _onDemandTimeout;
SelectedAesReload = UserSettings.Default.AesReload;
SelectedDiscordRpc = UserSettings.Default.DiscordRpc;
@ -314,7 +323,8 @@ public class SettingsViewModel : ViewModel
UserSettings.Default.CurrentDir.Versioning.Options = SelectedOptions;
UserSettings.Default.CurrentDir.Versioning.MapStructTypes = SelectedMapStructTypes;
UserSettings.Default.CurrentDir.CriwareDecryptionKey = CriwareDecryptionKey;
UserSettings.Default.CurrentDir.OnDemandTimeout = OnDemandTimeout;
UserSettings.Default.AssetLanguage = SelectedAssetLanguage;
UserSettings.Default.CompressedAudioMode = SelectedCompressedAudio;
UserSettings.Default.CosmeticStyle = SelectedCosmeticStyle;

View File

@ -44,6 +44,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -268,6 +269,28 @@
TextChanged="CriwareKeyBox_TextChanged"
Loaded="CriwareKeyBox_Loaded"/>
<TextBlock Grid.Row="21"
Grid.Column="0"
Text="OnDemand Timeout"
VerticalAlignment="Center"
Margin="0 0 0 10" />
<TextBox x:Name="OnDemandTimeoutBox"
Grid.Row="21"
Grid.Column="2"
Grid.ColumnSpan="5"
Margin="0 5 0 10"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
MaxLength="10"
ToolTip="Maximum time in seconds to wait for on-demand downloads to complete before aborting the request."
TextAlignment="Right"
PreviewTextInput="OnDemandTimeout_PreviewTextInput"
DataObject.Pasting="OnDemandTimeout_Pasting"
Loaded="OnDemandTimeout_Loaded"
TextChanged="OnDemandTimeout_TextChanged"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="CreatorTemplate">

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using FModel.Services;
using FModel.Settings;
using FModel.ViewModels;
@ -61,8 +62,6 @@ public partial class SettingsView
_applicationView.CUE4Parse.Provider.ReadScriptData = UserSettings.Default.ReadScriptData;
_applicationView.CUE4Parse.Provider.ReadShaderMaps = UserSettings.Default.ReadShaderMaps;
UserSettings.Save();
}
private void OnBrowseOutput(object sender, RoutedEventArgs e)
@ -76,7 +75,6 @@ public partial class SettingsView
UserSettings.Default.PropertiesDirectory = path;
UserSettings.Default.TextureDirectory = path;
UserSettings.Default.AudioDirectory = path;
UserSettings.Default.CodeDirectory = path;
}
private void OnBrowseDirectories(object sender, RoutedEventArgs e)
@ -274,4 +272,45 @@ public partial class SettingsView
Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri) { UseShellExecute = true });
}
private void OnDemandTimeout_Loaded(object sender, RoutedEventArgs e)
{
if (sender is not TextBox textBox)
return;
textBox.Text = _applicationView.SettingsView.OnDemandTimeout.ToString();
}
private void OnDemandTimeout_TextChanged(object sender, TextChangedEventArgs e)
{
if (sender is not TextBox textBox)
return;
string input = textBox.Text?.Trim() ?? string.Empty;
if (string.IsNullOrEmpty(input))
return;
if (uint.TryParse(input, out uint seconds))
_applicationView.SettingsView.OnDemandTimeout = seconds;
else
textBox.Text = uint.MaxValue.ToString();
}
private void OnDemandTimeout_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !e.Text.All(char.IsDigit);
}
private void OnDemandTimeout_Pasting(object sender, DataObjectPastingEventArgs e)
{
if (e.DataObject.GetDataPresent(typeof(string)))
{
var text = (string)e.DataObject.GetData(typeof(string));
if (!text.All(char.IsDigit))
e.CancelCommand();
}
else
{
e.CancelCommand();
}
}
}