Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
AsyncTaskNotification.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Delegates/Delegate.h"
7#include "Internationalization/Text.h"
8#include "Logging/LogCategory.h"
9#include "Misc/Attribute.h"
10#include "Templates/SharedPointer.h"
11
13struct FLogCategoryBase;
14struct FSlateBrush;
15
16/**
17 * Configuration data for initializing an asynchronous task notification.
18 */
20{
21 /** The title text displayed in the notification */
23
24 /** The progress text displayed in the notification (if any) */
26
27 /** The fade in duration of the notification */
28 float FadeInDuration = 0.5f;
29
30 /** The fade out duration of the notification */
31 float FadeOutDuration = 2.0f;
32
33 /** The duration before a fadeout for the notification */
34 float ExpireDuration = 1.0f;
35
36 /** Should this notification be "headless"? (ie, not display any UI) */
37 bool bIsHeadless = false;
38
39 /** Can this task be canceled? Will show a cancel button for in-progress tasks (attribute queried from the game thread) */
40 TAttribute<bool> bCanCancel = false;
41
42 /** Keep this notification open on success? Will show a close button (attribute queried from the game thread) */
44
45 /** Keep this notification open on failure? Will show an close button (attribute queried from the game thread) */
47
48 /** The icon image to display next to the text, or null to use the default icon */
49 const FSlateBrush* Icon = nullptr;
50
51 /** Category this task should log its notifications under, or null to skip logging */
52 const FLogCategoryBase* LogCategory = nullptr;
53};
54
56{
57 None = 0,
58 Pending,
59 Success,
60 Failure,
61 Prompt,
62};
63
65{
66 /** No action taken for the ongoing task. */
67 None = 0,
68 /** Continue ongoing task after a prompt. */
70 /** Cancel ongoing task. */
71 Cancel,
72 /** No action can be taken, task is unattended. */
74};
75
76/**
77 * Async Notification State data
78 */
80{
83 {}
84
85 FAsyncNotificationStateData(const FText& InTitleText, const FText& InProgressText, EAsyncTaskNotificationState InState)
86 : State(InState)
89 {}
90
91 /** The notification state. */
93
94 /** The title text displayed in the notification */
96
97 /** The progress text displayed in the notification (if any) */
99
100 /** The prompt text displayed in the notification, follow the progress text in console notification, used on button for UI notification (if any) */
102
103 /** Text to display for the hyperlink message. */
105
106 /** Hyperlink callback. If not bound the hyperlink text won't be displayed. */
107 FSimpleDelegate Hyperlink;
108};
109
110/**
111 * Provides notifications for an on-going asynchronous task.
112 */
114{
115public:
116 /**
117 * Create an asynchronous task notification.
118 */
120
121 /**
122 * Destroy the asynchronous task notification.
123 */
125
126 /**
127 * Non-copyable.
128 */
131
132 /**
133 * Movable.
134 */
137
138 /**
139 * Set the title text of this notification.
140 */
141 void SetTitleText(const FText& InTitleText, const bool bClearProgressText = true);
142
143 /**
144 * Set the progress text of this notification.
145 */
146 void SetProgressText(const FText& InProgressText);
147
148 /**
149 * Set the prompt text of this notification, if needed.
150 */
151 void SetPromptText(const FText& InPromptText);
152
153 /**
154 * Set the Hyperlink for this notification.
155 */
156 void SetHyperlink(const FSimpleDelegate& InHyperlink, const FText& InHyperlinkText = FText());
157
158 /**
159 * Set the task as complete.
160 */
161 void SetComplete(const bool bSuccess = true);
162
163 /**
164 * Update the text and set the task as complete.
165 */
166 void SetComplete(const FText& InTitleText, const FText& InProgressText, const bool bSuccess = true);
167
168 /**
169 * Set the notification state. Provide finer control than SetComplete by setting every field of the state.
170 */
172
173 /**
174 * Set whether this task be canceled.
175 */
176 void SetCanCancel(const TAttribute<bool>& InCanCancel);
177
178 /**
179 * Set whether to keep this notification open on success.
180 */
181 void SetKeepOpenOnSuccess(const TAttribute<bool>& InKeepOpenOnSuccess);
182
183 /**
184 * Set whether to keep this notification open on failure.
185 */
186 void SetKeepOpenOnFailure(const TAttribute<bool>& InKeepOpenOnFailure);
187
188 /**
189 * Return the notification prompt action.
190 * The action resets to `None` when the notification state changes.
191 */
193
194private:
195 /** Pointer to the real notification implementation */
197};
EAsyncTaskNotificationPromptAction
Definition Enums.h:8508
EAsyncTaskNotificationState
Definition Enums.h:8431
void SetCanCancel(const TAttribute< bool > &InCanCancel)
void SetKeepOpenOnSuccess(const TAttribute< bool > &InKeepOpenOnSuccess)
void SetProgressText(const FText &InProgressText)
FAsyncTaskNotification(const FAsyncTaskNotificationConfig &InConfig)
void SetKeepOpenOnFailure(const TAttribute< bool > &InKeepOpenOnFailure)
void SetComplete(const FText &InTitleText, const FText &InProgressText, const bool bSuccess=true)
TSharedPtr< IAsyncTaskNotificationImpl > NotificationImpl
void SetComplete(const bool bSuccess=true)
void SetTitleText(const FText &InTitleText, const bool bClearProgressText=true)
void SetPromptText(const FText &InPromptText)
void SetNotificationState(const FAsyncNotificationStateData &InState)
FAsyncTaskNotification & operator=(const FAsyncTaskNotification &)=delete
FAsyncTaskNotification(FAsyncTaskNotification &&InOther)
FAsyncTaskNotification & operator=(FAsyncTaskNotification &&InOther)
void SetHyperlink(const FSimpleDelegate &InHyperlink, const FText &InHyperlinkText=FText())
EAsyncTaskNotificationPromptAction GetPromptAction() const
FAsyncTaskNotification(const FAsyncTaskNotification &)=delete
Definition Text.h:357
EAsyncTaskNotificationState State
FAsyncNotificationStateData(const FText &InTitleText, const FText &InProgressText, EAsyncTaskNotificationState InState)
const FLogCategoryBase * LogCategory