Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
CoreAsyncTaskNotificationImpl.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Containers/Array.h"
6#include "Delegates/Delegate.h"
7#include "HAL/CriticalSection.h"
8#include "Internationalization/Text.h"
9#include "Misc/AsyncTaskNotification.h"
10#include "Misc/Attribute.h"
11#include "Templates/Function.h"
12#include "Templates/SharedPointer.h"
13#include "Templates/Tuple.h"
14#include "UObject/NameTypes.h"
15
16struct FLogCategoryBase;
17
18/**
19 * Implementation interface of notifications for an on-going asynchronous task.
20 */
22{
23public:
24 virtual ~IAsyncTaskNotificationImpl() = default;
25
26 /**
27 * Initialize this notification based on the given config.
28 */
29 virtual void Initialize(const FAsyncTaskNotificationConfig& InConfig) = 0;
30
31 /**
32 * Set the title text of this notification.
33 */
34 virtual void SetTitleText(const FText& InTitleText, const bool bClearProgressText) = 0;
35
36 /**
37 * Set the progress text of this notification.
38 */
39 virtual void SetProgressText(const FText& InProgressText) = 0;
40
41 /**
42 * Set the prompt text of this notification.
43 */
44 virtual void SetPromptText(const FText& InPromptText) = 0;
45
46 /**
47 * Set the hyperlink text of this notification.
48 */
49 virtual void SetHyperlink(const FSimpleDelegate& InHyperlink, const FText& InHyperlinkText) = 0;
50
51 /**
52 * Set the task as complete.
53 */
54 virtual void SetComplete(const bool bSuccess) = 0;
55
56 /**
57 * Update the text and set the task as complete.
58 */
59 virtual void SetComplete(const FText& InTitleText, const FText& InProgressText, const bool bSuccess) = 0;
60
61 /**
62 * Set the task notification state. provides finer control than SetComplete
63 */
64 virtual void SetNotificationState(const FAsyncNotificationStateData& InState) = 0;
65
66 /**
67 * Set whether this task be canceled.
68 */
69 virtual void SetCanCancel(const TAttribute<bool>& InCanCancel) = 0;
70
71 /**
72 * Set whether to keep this notification open on success.
73 */
74 virtual void SetKeepOpenOnSuccess(const TAttribute<bool>& InKeepOpenOnSuccess) = 0;
75
76 /**
77 * Set whether to keep this notification open on failure.
78 */
79 virtual void SetKeepOpenOnFailure(const TAttribute<bool>& InKeepOpenOnFailure) = 0;
80
81 /**
82 * Return the notification prompt action.
83 * The action resets to `None` when the notification state changes.
84 */
86};
87
88/**
89 * Basic asynchronous task notification that just logs status changes.
90 */
92{
93public:
96
97 //~ IAsyncTaskNotificationImpl
98 virtual void Initialize(const FAsyncTaskNotificationConfig& InConfig) override;
99 virtual void SetTitleText(const FText& InTitleText, const bool bClearProgressText) override;
100 virtual void SetProgressText(const FText& InProgressText) override;
101 virtual void SetPromptText(const FText& InPromptText) override;
102 virtual void SetHyperlink(const FSimpleDelegate& InHyperlink, const FText& InHyperlinkText) override;
103 virtual void SetComplete(const bool bSuccess) override;
104 virtual void SetComplete(const FText& InTitleText, const FText& InProgressText, const bool bSuccess) override;
105 virtual void SetNotificationState(const FAsyncNotificationStateData& InState) override;
106 virtual void SetCanCancel(const TAttribute<bool>& InCanCancel) override;
107 virtual void SetKeepOpenOnSuccess(const TAttribute<bool>& InKeepOpenOnSuccess) override;
108 virtual void SetKeepOpenOnFailure(const TAttribute<bool>& InKeepOpenOnFailure) override;
110
111protected:
112 /** Update the notification (the critical section is held while this function is called) */
113 virtual void UpdateNotification();
114
115 /** The current state of this notification */
117
118 /** The title text displayed in the notification (if any) */
120
121 /** The progress text displayed in the notification (if any) */
123
124 /** The progress text displayed in the notification (if any) */
126
127 /** When set this will display as a hyperlink on the right side of the notification. */
128 FSimpleDelegate Hyperlink;
129
130 /** Text to display for the hyperlink message */
132private:
133 /** Log the current notification state (if any, and if enabled) */
135
136 /** Category this task should log its notifications under, or null to skip logging */
137 const FLogCategoryBase* LogCategory = nullptr;
138
139 /** Critical section protecting concurrent access to this object state */
141};
142
143/**
144 * Factory to allow other systems (such as Slate) to override the default asynchronous task notification implementation.
145 */
147{
149
150public:
152 typedef TFunction<FImplPointerType()> FFactoryFunc;
153
154 /**
155 * Get the factory singleton.
156 */
158
159 /**
160 * Register a factory function.
161 */
162 void RegisterFactory(const FName InName, const FFactoryFunc& InFunc);
163
164 /**
165 * Unregister a factory function.
166 */
167 void UnregisterFactory(const FName InName);
168
169private:
170 /**
171 * Invoke the active factory function (if any), or return a default instance.
172 */
174
175 /** Registered factories */
177};
EAsyncTaskNotificationPromptAction
Definition Enums.h:8508
EAsyncTaskNotificationState
Definition Enums.h:8431
FWindowsCriticalSection FCriticalSection
void RegisterFactory(const FName InName, const FFactoryFunc &InFunc)
void UnregisterFactory(const FName InName)
TFunction< FImplPointerType()> FFactoryFunc
static FAsyncTaskNotificationFactory & Get()
TArray< TTuple< FName, FFactoryFunc > > Factories
TSharedPtr< IAsyncTaskNotificationImpl > FImplPointerType
FImplPointerType InvokeFactory() const
virtual void SetKeepOpenOnFailure(const TAttribute< bool > &InKeepOpenOnFailure) override
virtual void SetKeepOpenOnSuccess(const TAttribute< bool > &InKeepOpenOnSuccess) override
virtual void SetCanCancel(const TAttribute< bool > &InCanCancel) override
virtual void SetProgressText(const FText &InProgressText) override
virtual void SetTitleText(const FText &InTitleText, const bool bClearProgressText) override
virtual void SetNotificationState(const FAsyncNotificationStateData &InState) override
virtual void SetComplete(const FText &InTitleText, const FText &InProgressText, const bool bSuccess) override
virtual void SetHyperlink(const FSimpleDelegate &InHyperlink, const FText &InHyperlinkText) override
virtual EAsyncTaskNotificationPromptAction GetPromptAction() const override
virtual void SetComplete(const bool bSuccess) override
virtual void Initialize(const FAsyncTaskNotificationConfig &InConfig) override
virtual void SetPromptText(const FText &InPromptText) override
Definition Text.h:357
virtual void SetPromptText(const FText &InPromptText)=0
virtual void SetComplete(const FText &InTitleText, const FText &InProgressText, const bool bSuccess)=0
virtual ~IAsyncTaskNotificationImpl()=default
virtual void SetKeepOpenOnFailure(const TAttribute< bool > &InKeepOpenOnFailure)=0
virtual void SetHyperlink(const FSimpleDelegate &InHyperlink, const FText &InHyperlinkText)=0
virtual EAsyncTaskNotificationPromptAction GetPromptAction() const =0
virtual void SetProgressText(const FText &InProgressText)=0
virtual void SetKeepOpenOnSuccess(const TAttribute< bool > &InKeepOpenOnSuccess)=0
virtual void SetComplete(const bool bSuccess)=0
virtual void SetNotificationState(const FAsyncNotificationStateData &InState)=0
virtual void SetTitleText(const FText &InTitleText, const bool bClearProgressText)=0
virtual void SetCanCancel(const TAttribute< bool > &InCanCancel)=0
virtual void Initialize(const FAsyncTaskNotificationConfig &InConfig)=0