Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion FModel/Framework/FRestRequest.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using FModel.Settings;
using RestSharp;

namespace FModel.Framework;

public class FRestRequest : RestRequest
{
private const int TimeoutSeconds = 5;
private int TimeoutSeconds = UserSettings.Default.HttpRequestTimeout;

public FRestRequest(string url, Method method = Method.Get) : base(url, method)
{
Expand Down
7 changes: 7 additions & 0 deletions FModel/Settings/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,5 +544,12 @@ public bool PreviewTexturesAssetExplorer
get => _previewTexturesAssetExplorer;
set => SetProperty(ref _previewTexturesAssetExplorer, value);
}

private int _httpRequestTimeout = 30;
public int HttpRequestTimeout
{
get => _httpRequestTimeout;
set => SetProperty(ref _httpRequestTimeout, Math.Max(value, 30));
}
}
}
2 changes: 1 addition & 1 deletion FModel/ViewModels/CUE4ParseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ await _threadWorkerView.Begin(cancellationToken =>
{
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.HttpRequestTimeout)
};

switch (Provider)
Expand Down
4 changes: 3 additions & 1 deletion FModel/ViewModels/SettingsViewModel.cs
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont need this

Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ public ulong CriwareDecryptionKey
private string _codeSnapshot;
private string _modelSnapshot;
private string _gameSnapshot;
private int _httpRequestTimeout;
private ETexturePlatform _uePlatformSnapshot;
private EGame _ueGameSnapshot;
private IList<FCustomVersion> _customVersionsSnapshot;
Expand Down Expand Up @@ -231,6 +232,7 @@ public void Initialize()
_codeSnapshot = UserSettings.Default.CodeDirectory;
_modelSnapshot = UserSettings.Default.ModelDirectory;
_gameSnapshot = UserSettings.Default.GameDirectory;
_httpRequestTimeout = UserSettings.Default.HttpRequestTimeout;
_uePlatformSnapshot = UserSettings.Default.CurrentDir.TexturePlatform;
_ueGameSnapshot = UserSettings.Default.CurrentDir.UeVersion;
_customVersionsSnapshot = UserSettings.Default.CurrentDir.Versioning.CustomVersions;
Expand Down Expand Up @@ -314,7 +316,7 @@ public bool Save(out List<SettingsOut> whatShouldIDo)
UserSettings.Default.CurrentDir.Versioning.Options = SelectedOptions;
UserSettings.Default.CurrentDir.Versioning.MapStructTypes = SelectedMapStructTypes;
UserSettings.Default.CurrentDir.CriwareDecryptionKey = CriwareDecryptionKey;

UserSettings.Default.AssetLanguage = SelectedAssetLanguage;
UserSettings.Default.CompressedAudioMode = SelectedCompressedAudio;
UserSettings.Default.CosmeticStyle = SelectedCosmeticStyle;
Expand Down
23 changes: 23 additions & 0 deletions FModel/Views/SettingsView.xaml
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the correct input control

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -268,6 +269,28 @@
TextChanged="CriwareKeyBox_TextChanged"
Loaded="CriwareKeyBox_Loaded"/>


<TextBlock Grid.Row="21"
Grid.Column="0"
Text="HTTP Request Timeout"
VerticalAlignment="Center"
Margin="0 0 0 10" />

<TextBox x:Name="HttpRequestTimeoutBox"
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 HTTP requests to complete before aborting."
TextAlignment="Right"
PreviewTextInput="HttpRequestTimeoutBox_PreviewTextInput"
DataObject.Pasting="HttpRequestTimeoutBox_Pasting"
Loaded="HttpRequestTimeoutBox_Loaded"
TextChanged="HttpRequestTimeoutBox_TextChanged"/>

</Grid>
</DataTemplate>
<DataTemplate x:Key="CreatorTemplate">
Expand Down
43 changes: 43 additions & 0 deletions FModel/Views/SettingsView.xaml.cs
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont need this

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using FModel.Services;
using FModel.Settings;
using FModel.ViewModels;
Expand Down Expand Up @@ -274,4 +275,46 @@ private void OnHyperlinkClick(object sender, RoutedEventArgs e)

Process.Start(new ProcessStartInfo(hyperlink.NavigateUri.AbsoluteUri) { UseShellExecute = true });
}

private void HttpRequestTimeoutBox_Loaded(object sender, RoutedEventArgs e)
{
if (sender is not TextBox textBox)
return;
textBox.Text = UserSettings.Default.HttpRequestTimeout.ToString();
}

private void HttpRequestTimeoutBox_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 (int.TryParse(input, out int seconds))
UserSettings.Default.HttpRequestTimeout = seconds;
else
textBox.Text = int.MaxValue.ToString();
}

private void HttpRequestTimeoutBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = !e.Text.All(char.IsDigit);
}

private void HttpRequestTimeoutBox_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();
}
}
}