UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WebImage.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Misc/DateTime.h"
10#include "Misc/Attribute.h"
14#include "IImageWrapper.h"
15
16class IHttpRequest;
17struct FSlateBrush;
18
21
43 : public TSharedFromThis<FWebImage>
44{
45public:
48
54
56 inline FWebImage& SetStandInBrush(TAttribute<const FSlateBrush*> StandInBrushIn) { StandInBrush = StandInBrushIn; DownloadedBrush.Reset(); return *this; }
57
60
66
69
70public:
71
74
76 inline const FSlateBrush* GetBrush() const { return DownloadedBrush.IsValid() ? DownloadedBrush.Get() : StandInBrush.Get(); }
77
79 inline const FSlateBrush* GetDownloadedBrush() const { return DownloadedBrush.IsValid() ? DownloadedBrush.Get() : nullptr; }
80
82 inline bool IsDownloadPending() const { return PendingRequest.IsValid(); }
83
85 inline bool DidDownloadSucceed() const { return bDownloadSuccess; }
86
88 inline bool DidDownloadFail() const { return !IsDownloadPending() && !DidDownloadSucceed(); }
89
91 inline const FString& GetUrl() const { return Url; }
92
94 inline const TOptional<FString>& GetETag() const { return ETag; }
95
96private:
98 IMAGEDOWNLOAD_API void HttpRequestComplete(FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded);
99 IMAGEDOWNLOAD_API bool ProcessHttpResponse(const FString& RequestUrl, FHttpResponsePtr HttpResponse);
100
101private:
103 FString Url;
104
107
110
113
115 FOnImageDownloaded PendingCallback;
116
118 bool bDownloadSuccess;
119
121 FDateTime DownloadTimeUtc;
122
125};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
TSharedPtr< class IHttpResponse, ESPMode::ThreadSafe > FHttpResponsePtr
Definition WebImage.h:20
TSharedPtr< IHttpRequest, ESPMode::ThreadSafe > FHttpRequestPtr
Definition WebImage.h:19
Definition WebImage.h:44
bool DidDownloadFail() const
Definition WebImage.h:88
IMAGEDOWNLOAD_API ~FWebImage()
Definition WebImage.cpp:19
IMAGEDOWNLOAD_API void CancelDownload()
Definition WebImage.cpp:133
bool BeginDownload(const FString &InUrl, const FOnImageDownloaded &DownloadCallback)
Definition WebImage.h:62
IMAGEDOWNLOAD_API bool BeginDownload(const FString &InUrl, const TOptional< FString > &StandInETag=TOptional< FString >(), const FOnImageDownloaded &DownloadCallback=FOnImageDownloaded())
Definition WebImage.cpp:29
bool IsDownloadPending() const
Definition WebImage.h:82
const TOptional< FString > & GetETag() const
Definition WebImage.h:94
FWebImage & SetStandInBrush(TAttribute< const FSlateBrush * > StandInBrushIn)
Definition WebImage.h:56
IMAGEDOWNLOAD_API FWebImage()
Definition WebImage.cpp:13
const FSlateBrush * GetDownloadedBrush() const
Definition WebImage.h:79
const FSlateBrush * GetBrush() const
Definition WebImage.h:76
bool DidDownloadSucceed() const
Definition WebImage.h:85
const FString & GetUrl() const
Definition WebImage.h:91
IMAGEDOWNLOAD_API TAttribute< const FSlateBrush * > Attr() const
Definition WebImage.cpp:24
DECLARE_DELEGATE_OneParam(FOnImageDownloaded, bool)
Definition IHttpRequest.h:171
Definition Attribute.h:17
const ObjectType & Get() const
Definition Attribute.h:241
Definition SharedPointer.h:1640
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT ObjectType * Get() const
Definition SharedPointer.h:1065
UE_FORCEINLINE_HINT void Reset()
Definition SharedPointer.h:1120
UE_FORCEINLINE_HINT const bool IsValid() const
Definition SharedPointer.h:1085
Definition DateTime.h:76
Definition SlateBrush.h:239
Definition Optional.h:131