Profiles - Added workshop installing

This commit is contained in:
Robert committed 2023-08-26 20:47:48 +02:00
1 parent 4143cc2de8
commit 671c587df6
21 files changed
+401 -73

No files matched your search

@@ -3,10 +3,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:steps="clr-namespace:Artemis.UI.Screens.Workshop.SubmissionWizard.Steps"
mc:Ignorable="d" d:DesignWidth="970" d:DesignHeight="900"
mc:Ignorable="d" d:DesignWidth="970" d:DesignHeight="900"
x:Class="Artemis.UI.Screens.Workshop.SubmissionWizard.Steps.UploadStepView"
x:DataType="steps:UploadStepViewModel">
<StackPanel Margin="0 50 0 0" >
<StackPanel Margin="0 50 0 0">
<StackPanel.Styles>
<Styles>
<Style Selector="TextBlock">
@@ -15,23 +15,31 @@
</Style>
</Styles>
</StackPanel.Styles>
<TextBlock Theme="{StaticResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap">
<TextBlock IsVisible="{CompiledBinding !Finished}" Theme="{StaticResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap">
Uploading your submission...
</TextBlock>
<TextBlock TextAlignment="Center" TextWrapping="Wrap">
Wooo, the final step, that was pretty easy, right!?
</TextBlock>
<ProgressBar Margin="0 15 0 0"
Width="380"
IsVisible="{CompiledBinding !Finished}"
IsIndeterminate="{CompiledBinding ProgressIndeterminate}"
Value="{CompiledBinding ProgressPercentage}"></ProgressBar>
<StackPanel IsVisible="{CompiledBinding Finished}" Margin="0 100 0 0">
<Lottie Path="/Assets/Animations/success.json" RepeatCount="1" Width="300" Height="300"></Lottie>
<ProgressBar IsVisible="{CompiledBinding !Finished}"
Margin="0 15 0 0"
Width="380"
IsIndeterminate="{CompiledBinding ProgressIndeterminate}"
Value="{CompiledBinding ProgressPercentage}">
</ProgressBar>
<StackPanel IsVisible="{CompiledBinding Succeeded}">
<Lottie Path="/Assets/Animations/success.json" RepeatCount="1" Width="250" Height="250" Margin="0 100"></Lottie>
<TextBlock Theme="{StaticResource TitleTextBlockStyle}">All done! Hit finish to view your submission.</TextBlock>
</StackPanel>
<StackPanel IsVisible="{CompiledBinding Failed}">
<TextBlock FontSize="140" Margin="0 100">😢</TextBlock>
<TextBlock Theme="{StaticResource SubtitleTextBlockStyle}">
Unfortunately something went wrong while uploading your submission.
</TextBlock>
<TextBlock>Hit finish to view your submission, from there you can try to upload a new release.</TextBlock>
<TextBlock Margin="0 10" Classes="subtitle">If this keeps occuring, hit us up on Discord</TextBlock>
</StackPanel>
</StackPanel>
</UserControl>
</UserControl>
@@ -28,8 +28,10 @@ public class UploadStepViewModel : SubmissionViewModel
private readonly ObservableAsPropertyHelper<int> _progressPercentage;
private readonly ObservableAsPropertyHelper<bool> _progressIndeterminate;
private bool _finished;
private Guid? _entryId;
private bool _finished;
private bool _succeeded;
private bool _failed;
/// <inheritdoc />
public UploadStepViewModel(IWorkshopClient workshopClient, IWorkshopService workshopService, EntryUploadHandlerFactory entryUploadHandlerFactory, IWindowService windowService, IRouter router)
@@ -43,14 +45,14 @@ public class UploadStepViewModel : SubmissionViewModel
ShowGoBack = false;
ContinueText = "Finish";
Continue = ReactiveCommand.CreateFromTask(ExecuteContinue, this.WhenAnyValue(vm => vm.Finished));
_progressPercentage = Observable.FromEventPattern<StreamProgress>(x => _progress.ProgressChanged += x, x => _progress.ProgressChanged -= x)
.Select(e => e.EventArgs.ProgressPercentage)
.ToProperty(this, vm => vm.ProgressPercentage);
_progressIndeterminate = Observable.FromEventPattern<StreamProgress>(x => _progress.ProgressChanged += x, x => _progress.ProgressChanged -= x)
.Select(e => e.EventArgs.ProgressPercentage == 0)
.ToProperty(this, vm => vm.ProgressIndeterminate);
this.WhenActivated(d => Observable.FromAsync(ExecuteUpload).Subscribe().DisposeWith(d));
}
@@ -69,6 +71,18 @@ public class UploadStepViewModel : SubmissionViewModel
set => RaiseAndSetIfChanged(ref _finished, value);
}
public bool Succeeded
{
get => _succeeded;
set => RaiseAndSetIfChanged(ref _succeeded, value);
}
public bool Failed
{
get => _failed;
set => RaiseAndSetIfChanged(ref _failed, value);
}
public async Task ExecuteUpload(CancellationToken cancellationToken)
{
IOperationResult<IAddEntryResult> result = await _workshopClient.AddEntry.ExecuteAsync(new CreateEntryInput
@@ -85,12 +99,13 @@ public class UploadStepViewModel : SubmissionViewModel
if (result.IsErrorResult() || entryId == null)
{
await _windowService.ShowConfirmContentDialog("Failed to create workshop entry", result.Errors.ToString() ?? "Not even an error message", "Close", null);
State.ChangeScreen<SubmitStepViewModel>();
return;
}
if (cancellationToken.IsCancellationRequested)
return;
// Upload image
if (State.Icon != null)
await _workshopService.SetEntryIcon(entryId.Value, _progress, State.Icon, cancellationToken);
@@ -113,21 +128,27 @@ public class UploadStepViewModel : SubmissionViewModel
}
_entryId = entryId;
Finished = true;
Succeeded = true;
}
catch (Exception e)
{
// Something went wrong when creating a release :c
// We'll keep the workshop entry so that the user can make changes and try again
Failed = true;
}
finally
{
Finished = true;
}
}
private async Task ExecuteContinue()
{
State.Finish();
if (_entryId == null)
return;
State.Finish();
switch (State.EntryType)
{
case EntryType.Layout: