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
26UCLASS()
27class AGRARSENSE_API AWindowActor : public AActor
28{
29 GENERATED_BODY()
30
31public:
32
33 AWindowActor(const FObjectInitializer& ObjectInitializer);
34
35 UFUNCTION(BlueprintCallable)
36 void SetupWindow(int32 Width = 1280, int32 Height = 720, FString Title = "Window", UTextureRenderTarget2D* TextureRenderTarget = nullptr);
37
38 UFUNCTION(BlueprintCallable)
39 void SetupTextureRenderTarget(UTextureRenderTarget2D* TextureRenderTarget);
40
41 UFUNCTION(BlueprintCallable)
42 void AddWidgetToWindow(UWidget* WidgetToAdd);
43
44 UFUNCTION(BlueprintCallable)
45 void RemoveWidgetFromWindow(UWidget* WidgetToAdd);
46
47 UFUNCTION(BlueprintCallable)
48 void ResizeWindow(int32 Width = 1280, int32 Height = 720);
49
53 UFUNCTION(BlueprintCallable)
54 void BringFront();
55
56 TSharedPtr<FUnrealWindow> GetUnrealWindow()
57 {
58 return UnrealWindow;
59 }
60
61 FOnWindowClosed OnWindowClosedDelegate;
62
63protected:
64
65 virtual void BeginPlay() override;
66
67 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
68
69private:
70
71 void OnWindowClosed(const TSharedRef<SWindow>& Window);
72
73 TSharedPtr<FUnrealWindow> UnrealWindow;
74
75};
FOnWindowClosed OnWindowClosedDelegate
Definition: WindowActor.h:61
TSharedPtr< FUnrealWindow > GetUnrealWindow()
Definition: WindowActor.h:56
TSharedPtr< FUnrealWindow > UnrealWindow
Definition: WindowActor.h:73