Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
SlowTask.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreGlobals.h"
6#include "CoreTypes.h"
7#include "Internationalization/Text.h"
8#include "Misc/Optional.h"
9
11
12/** Enum to specify a particular slow task section should be shown */
14{
15 /** Default visibility (inferred by some heuristic of remaining work/time open) */
16 Default,
17 /** Force this particular slow task to be visible on the UI */
19 /** Forcibly prevent this slow task from being shown, but still use it for work progress calculations */
21};
22
23/**
24 * Data type used to store information about a currently running slow task. Direct use is not advised, use FScopedSlowTask instead
25 */
27{
28 /** Default message to display to the user when not overridden by a frame */
30
31 /** Message pertaining to the current frame's work */
33
34 /** The amount of work to do in this scope */
36
37 /** The amount of work we have already completed in this scope */
39
40 /** The amount of work the current frame is responsible for */
42
43 /** The visibility of this slow task */
45
46 /** The time that this scope was created */
47 double StartTime;
48
49 /** Threshold before dialog is opened */
51
52private:
53
54 /** Boolean flag to control whether this scope actually does anything (unset for quiet operations etc) */
56
57 /** Flag that specifies whether this feedback scope created a new slow task dialog */
59
60 /** The feedback context that we belong to */
62
63 /** Specify whether the delayed dialog should show a cancel button */
65
66 /** Specify whether the delayed dialog is allowed in PIE */
68
69 /** Avoid calling hierarchical dialog creation if not required */
71
72 /** Prevent copying */
74
75 /** Whenever we encounter edge condition requiring to force a UI refresh */
76 static void ForceRefresh(FFeedbackContext& Context);
77
78 /** Handle dialog and delayed dialog creation logic */
80
81 /** Call MakeDialogIfNeeded on all scopes recursively to give them a chance to create a delayed dialog in the hierarchy */
83
84public:
85
86 /**
87 * True if a slow task should be created. False if a slow task should not be created because another was created recently.
88 */
90
91 /**
92 * Construct this scope from an amount of work to do, and a message to display
93 * @param InAmountOfWork Arbitrary number of work units to perform (can be a percentage or number of steps).
94 * 0 indicates that no progress frames are to be entered in this scope (automatically enters a frame encompassing the entire scope)
95 * @param InDefaultMessage A message to display to the user to describe the purpose of the scope
96 * @param bInVisible When false, this scope will have no effect. Allows for proper scoped objects that are conditionally hidden.
97 */
98 FSlowTask(float InAmountOfWork, const FText& InDefaultMessage = FText(), bool bInEnabled = true, FFeedbackContext& InContext = *GWarn);
99
100 /** Function that initializes the scope by adding it to its context's stack */
102
103 /** Function that finishes any remaining work and removes itself from the global scope stack */
104 void Destroy();
105
106 /**
107 * Creates a new dialog for this slow task after the given time threshold. If the task completes before this time, no dialog will be shown.
108 * @param Threshold Time in seconds before dialog will be shown.
109 * @param bShowCancelButton Whether to show a cancel button on the dialog or not
110 * @param bAllowInPIE Whether to allow this dialog in PIE. If false, this dialog will not appear during PIE sessions.
111 */
112 void MakeDialogDelayed(float Threshold, bool bShowCancelButton = false, bool bAllowInPIE = false);
113
114 /**
115 * Creates a new dialog for this slow task, if there is currently not one open
116 * @param bShowCancelButton Whether to show a cancel button on the dialog or not
117 * @param bAllowInPIE Whether to allow this dialog in PIE. If false, this dialog will not appear during PIE sessions.
118 */
119 void MakeDialog(bool bShowCancelButton = false, bool bAllowInPIE = false);
120
121 /**
122 * Indicate that we are to enter a frame that will take up the specified amount of work. Completes any previous frames (potentially contributing to parent scopes' progress).
123 * @param ExpectedWorkThisFrame The amount of work that will happen between now and the next frame, as a numerator of TotalAmountOfWork.
124 * @param Text Optional text to describe this frame's purpose.
125 */
126 void EnterProgressFrame(float ExpectedWorkThisFrame = 1.f, const FText& Text = FText());
127
128 /**
129 * Let the UI refresh but doesn't advance progress. This should be called at regular intervals even when no progress is being made to keep the UI responsive.
130 */
132
133 /**
134 * Get the frame message or default message if empty
135 */
136 const FText& GetCurrentMessage() const;
137
138 /**
139 * True if the user has requested that the slow task be canceled
140 */
141 bool ShouldCancel() const;
142};
class FFeedbackContext * GWarn
ESlowTaskVisibility
Definition Enums.h:8537
Definition Text.h:357
bool bCreatedDialog
Definition SlowTask.h:58
bool bSkipRecursiveDialogCreation
Definition SlowTask.h:70
void MakeRecursiveDialogIfNeeded()
FText DefaultMessage
Definition SlowTask.h:29
void MakeDialogDelayed(float Threshold, bool bShowCancelButton=false, bool bAllowInPIE=false)
ESlowTaskVisibility Visibility
Definition SlowTask.h:44
static bool ShouldCreateThrottledSlowTask()
bool MakeDialogIfNeeded()
bool bDelayedDialogAllowInPIE
Definition SlowTask.h:67
static void ForceRefresh(FFeedbackContext &Context)
double StartTime
Definition SlowTask.h:47
FFeedbackContext & Context
Definition SlowTask.h:61
FSlowTask(const FSlowTask &)
bool bEnabled
Definition SlowTask.h:55
FText FrameMessage
Definition SlowTask.h:32
bool ShouldCancel() const
FSlowTask(float InAmountOfWork, const FText &InDefaultMessage=FText(), bool bInEnabled=true, FFeedbackContext &InContext= *GWarn)
bool bDelayedDialogShowCancelButton
Definition SlowTask.h:64
void TickProgress()
void Destroy()
float TotalAmountOfWork
Definition SlowTask.h:35
float CurrentFrameScope
Definition SlowTask.h:41
void Initialize()
const FText & GetCurrentMessage() const
void EnterProgressFrame(float ExpectedWorkThisFrame=1.f, const FText &Text=FText())
TOptional< float > OpenDialogThreshold
Definition SlowTask.h:50
float CompletedWork
Definition SlowTask.h:38
void MakeDialog(bool bShowCancelButton=false, bool bAllowInPIE=false)