v1.2.26
Documentation for the Unreal C++ Plugin
Loading...
Searching...
No Matches
BasicWidget.cpp
Go to the documentation of this file.
1
// Copyright(c) Pixo Group. All Rights Reserved.
2
3
#include "
UI/BasicWidget.h
"
4
5
#include "Blueprint/WidgetTree.h"
6
#include "
UI/ButtonWidget.h
"
7
8
PRAGMA_DISABLE_OPTIMIZATION
9
10
11
void
UBasicWidget::NativeOnInitialized
()
12
{
13
Super::NativeOnInitialized();
14
}
15
16
void
UBasicWidget::Init
(
UBasicWidgetInfo
* WidgetInfo)
17
{
18
if
(WidgetInfo)
19
{
20
this->
Heading
= WidgetInfo->
Heading
;
21
22
WidgetInfoName
= WidgetInfo->GetName();
23
24
bIsClosingByDistance
= WidgetInfo->
ClosingDistanceCm
> 0;
25
MaxSquaredClosingDistance
= WidgetInfo->
ClosingDistanceCm
* WidgetInfo->
ClosingDistanceCm
;
26
}
27
}
28
29
void
UBasicWidget::ProcessSquaredDistanceToPlayer
(
const
float
SquaredDistanceToPlayerCm,
const
float
DeltaSec)
30
{
31
if
(
bIsClosingByDistance
)
32
{
33
const
bool
IsAvailableByTime =
DistanceCalculationDelay
>=
MaxDistanceCalculationDelaySec
;
34
const
bool
IsAvailableByDistance = SquaredDistanceToPlayerCm >
MaxSquaredClosingDistance
;
35
if
(IsAvailableByTime && IsAvailableByDistance)
36
{
37
PlayerWentAwayHandler
(SquaredDistanceToPlayerCm);
38
}
39
else
40
{
41
DistanceCalculationDelay
+= DeltaSec;
42
}
43
}
44
}
45
46
void
UBasicWidget::PlayerWentAway_Implementation()
47
{
48
OnPlayerWentAway
.ExecuteIfBound();
49
}
50
51
void
UBasicWidget::OnClickExitMenuEvent
(FText ButtonName)
52
{
53
OnExitMenuEventDelegate
.ExecuteIfBound(
nullptr
);
54
}
55
PRAGMA_ENABLE_OPTIMIZATION
BasicWidget.h
ButtonWidget.h
UBasicWidget::NativeOnInitialized
virtual void NativeOnInitialized() override
Definition
BasicWidget.cpp:11
UBasicWidget::bIsClosingByDistance
bool bIsClosingByDistance
Flag indicating if the widget should be closed by distance.
Definition
BasicWidget.h:106
UBasicWidget::OnExitMenuEventDelegate
FExitMenuEventDelegate OnExitMenuEventDelegate
Event delegate for the "ExitMenu" event.
Definition
BasicWidget.h:86
UBasicWidget::MaxDistanceCalculationDelaySec
float MaxDistanceCalculationDelaySec
UPROPERTY(BlueprintReadWrite)
Definition
BasicWidget.h:99
UBasicWidget::Heading
FText Heading
UPROPERTY(BlueprintReadWrite)
Definition
BasicWidget.h:94
UBasicWidget::ProcessSquaredDistanceToPlayer
void ProcessSquaredDistanceToPlayer(const float SquaredDistanceToPlayerCm, const float DeltaSec)
Processes the squared distance to the player.
Definition
BasicWidget.cpp:29
UBasicWidget::PlayerWentAwayHandler
virtual void PlayerWentAwayHandler(const float SquaredDistanceToPlayerCm)
Handler for when the player goes away.
Definition
BasicWidget.h:68
UBasicWidget::OnClickExitMenuEvent
virtual void OnClickExitMenuEvent(FText ButtonName)
Event handler for the "ExitMenu" button click event.
Definition
BasicWidget.cpp:51
UBasicWidget::MaxSquaredClosingDistance
int32 MaxSquaredClosingDistance
Definition
BasicWidget.h:107
UBasicWidget::WidgetInfoName
FString WidgetInfoName
Name of widget info used for creating this widget.
Definition
BasicWidget.h:102
UBasicWidget::Init
virtual void Init(UBasicWidgetInfo *WidgetInfo)
Initializes the widget with the provided widget information.
Definition
BasicWidget.cpp:16
UBasicWidget::DistanceCalculationDelay
float DistanceCalculationDelay
Definition
BasicWidget.h:108
UBasicWidget::OnPlayerWentAway
FOnPlayerWentAway OnPlayerWentAway
Event for when the player goes away.
Definition
BasicWidget.h:87
UBasicWidgetInfo
UDataAsset class representing basic widget information.
Definition
UIData.h:56
UBasicWidgetInfo::Heading
FText Heading
UPROPERTY(EditAnywhere, BlueprintReadWrite)
Definition
UIData.h:103
UBasicWidgetInfo::ClosingDistanceCm
int32 ClosingDistanceCm
UPROPERTY(EditAnywhere, BlueprintReadWrite)
Definition
UIData.h:163
PixoCore
Source
PixoCore
Private
UI
BasicWidget.cpp
Generated
Wed Oct 9 2024 19:40:16
by Doxygen version
1.10.0