Agrarsense
WindowActor.h
Go to the documentation of this file.
1// Copyright (c) 2024 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "GameFramework/Actor.h"
10#include "Engine/TextureRenderTarget2D.h"
11
12#include "UnrealWindow.h"
13
14#include "WindowActor.generated.h"
15
16class UWidget;
17
25UCLASS()
26class AGRARSENSE_API AWindowActor : public AActor
27{
28 GENERATED_BODY()
29
30public:
31
32 AWindowActor(const FObjectInitializer& ObjectInitializer);
33
34 UFUNCTION(BlueprintCallable)
35 void SetupWindow(int Width = 1280, int Height = 720, FString Title = "Window", UTextureRenderTarget2D* TextureRenderTarget = nullptr);
36
37 UFUNCTION(BlueprintCallable)
38 void SetupTextureRenderTarget(UTextureRenderTarget2D* TextureRenderTarget);
39
40 UFUNCTION(BlueprintCallable)
41 void AddWidgetToWindow(UWidget* WidgetToAdd);
42
43 UFUNCTION(BlueprintCallable)
44 void RemoveWidgetFromWindow(UWidget* WidgetToAdd);
45
46 UFUNCTION(BlueprintCallable)
47 void ResizeWindow(int Width = 1280, int Height = 720);
48
49 TSharedPtr<FUnrealWindow> GetUnrealWindow()
50 {
51 return UnrealWindow;
52 }
53
54 FOnWindowClosed OnWindowClosedDelegate;
55
56protected:
57
58 virtual void BeginPlay() override;
59
60 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
61
62private:
63
64 void OnWindowClosed(const TSharedRef<SWindow>& Window);
65
66 TSharedPtr<FUnrealWindow> UnrealWindow;
67
68};
FOnWindowClosed OnWindowClosedDelegate
Definition: WindowActor.h:54
TSharedPtr< FUnrealWindow > GetUnrealWindow()
Definition: WindowActor.h:49
TSharedPtr< FUnrealWindow > UnrealWindow
Definition: WindowActor.h:66