Cesium for Unreal 2.12.0
Loading...
Searching...
No Matches
CesiumCreditSystem.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "Components/WidgetComponent.h"
6#include "Engine/Blueprint.h"
7#include "GameFramework/Actor.h"
8#include "UObject/Class.h"
9#include "UObject/ConstructorHelpers.h"
10#include <memory>
11#include <string>
12#include <unordered_map>
13
14#if WITH_EDITOR
15#include "IAssetViewport.h"
16#include "UnrealEdMisc.h"
17#endif
18
19#include "CesiumCreditSystem.generated.h"
20
21namespace CesiumUtility {
22class CreditSystem;
23}
24
30UCLASS(Abstract)
31class CESIUMRUNTIME_API ACesiumCreditSystem : public AActor {
32 GENERATED_BODY()
33
34public:
36 GetDefaultCreditSystem(const UObject* WorldContextObject);
37
39
40 virtual void BeginPlay() override;
41 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
42
43 virtual void OnConstruction(const FTransform& Transform) override;
44 virtual void BeginDestroy() override;
45
46 UPROPERTY(EditDefaultsOnly, Category = "Cesium")
47 TSubclassOf<class UScreenCreditsWidget> CreditsWidgetClass;
48
52 UPROPERTY(BlueprintReadOnly, Category = "Cesium")
53 bool CreditsUpdated = false;
54
55 UPROPERTY(BlueprintReadOnly, Transient, Category = "Cesium")
56 class UScreenCreditsWidget* CreditsWidget;
57
58 // Called every frame
59 virtual bool ShouldTickIfViewportsOnly() const override;
60 virtual void Tick(float DeltaTime) override;
61
62 const std::shared_ptr<CesiumUtility::CreditSystem>&
63 GetExternalCreditSystem() const {
64 return _pCreditSystem;
65 }
66
67 void updateCreditsViewport(bool recreateWidget);
69
70#if WITH_EDITOR
71 void OnRedrawLevelEditingViewports(bool);
72 void OnPreBeginPIE(bool bIsSimulating);
73 void OnEndPIE();
74 void OnCleanseEditor();
75#endif
76
77private:
78 static UObject* CesiumCreditSystemBP;
79
84 static FName DEFAULT_CREDITSYSTEM_TAG;
85
86 // the underlying cesium-native credit system that is managed by this actor.
87 std::shared_ptr<CesiumUtility::CreditSystem> _pCreditSystem;
88
89 size_t _lastCreditsCount;
90
91 FString ConvertHtmlToRtf(std::string html);
92 std::unordered_map<std::string, FString> _htmlToRtf;
93
94#if WITH_EDITOR
95 TWeakPtr<IAssetViewport> _pLastEditorViewport;
96#endif
97};
Manages credits / atttribution for Cesium data sources.
void removeCreditsFromViewports()
virtual void OnConstruction(const FTransform &Transform) override
void updateCreditsViewport(bool recreateWidget)
virtual void BeginPlay() override
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
virtual void BeginDestroy() override
static ACesiumCreditSystem * GetDefaultCreditSystem(const UObject *WorldContextObject)
STL namespace.