Apparatus Version 1.0.0
ECS-like data-driven workflow for Unreal Engine.
SubjectiveUserWidget.h
1 /*
2  * ░▒▓ APPARATUS ▓▒░
3  *
4  * File: SubjectiveUserWidget.h
5  * Created: Friday, 23rd October 2020 7:00:48 pm
6  * Author: Vladislav Dmitrievich Turbanov (vladislav@turbanov.ru)
7  * ───────────────────────────────────────────────────────────────────
8  * Last Modified: Saturday, 3rd April 2021 12:19:19 pm
9  * Modified By: Vladislav Dmitrievich Turbanov (vladislav@turbanov.ru)
10  * ───────────────────────────────────────────────────────────────────
11  *
12  * The Apparatus source code is for your internal usage only.
13  * Redistribution of this file is strictly prohibited.
14  *
15  * Community forums: https://talk.turbanov.ru
16  *
17  * Copyright 2020 - 2021, SP Vladislav Dmitrievich Turbanov
18  * Made in Russia, Moscow City, Chekhov City
19  */
20 
21 #pragma once
22 
23 #include "Blueprint/UserWidget.h"
24 #include "CoreMinimal.h"
25 
26 #include "Subjective.h"
27 
28 #include "SubjectiveUserWidget.generated.h"
29 
33 UCLASS(ClassGroup = "Apparatus")
34 class APPARATUSRUNTIME_API USubjectiveUserWidget : public UUserWidget,
35  public ISubjective
36 {
37  GENERATED_BODY()
38 
39 
42  UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Transient, Category = Subject,
43  Meta = (AllowPrivateAccess = "true"))
44  mutable FFingerprint Fingerprint;
45 
49  UPROPERTY(Transient)
50  class UBelt* Belt = nullptr;
51 
55  int32 SlotIndex = InvalidSlotIndex;
56 
60  UPROPERTY(EditAnywhere, Category = Subject,
61  Meta = (AllowPrivateAccess = "true"))
62  class UBelt* PreferredBelt = nullptr;
63 
64  friend class FSubjectDetails;
65 
69  UPROPERTY(EditAnywhere, Instanced, Category = Details,
70  Meta = (AllowPrivateAccess = "true"))
71  TArray<UDetail*> Details;
72 
73  public:
74 
75  FORCEINLINE struct FBeltSlot* GetSlot() const override
76  {
77  if (Belt == nullptr)
78  return nullptr;
79  if (SlotIndex == -1)
80  return nullptr;
81  return &(*Belt)[SlotIndex];
82  }
83 
84  public:
85  USubjectiveUserWidget(const FObjectInitializer& ObjectInitializer);
86 
87  protected:
88  virtual void NativeConstruct() override;
89 
90  virtual void NativeDestruct() override;
91 
92  FORCEINLINE void TakeBeltSlot(UBelt* InBelt, int32 InSlotIndex) override
93  {
94  if (InBelt == nullptr)
95  {
96  Belt = nullptr;
97  SlotIndex = InvalidSlotIndex;
98  }
99  else
100  {
101  Belt = InBelt;
102  SlotIndex = InSlotIndex;
103  }
104  }
105 
106  FORCEINLINE TArray<UDetail*>& GetDetailsRef() override
107  {
108  return Details;
109  }
110 
111  FORCEINLINE const TArray<UDetail*>& GetDetailsRef() const override
112  {
113  return Details;
114  }
115 
116  FORCEINLINE FFingerprint& GetFingerprint() override
117  {
118  return Fingerprint;
119  }
120 
121  public:
122 
123  FORCEINLINE const FFingerprint& GetFingerprint() const override
124  {
125  return Fingerprint;
126  }
127 
128  FORCEINLINE class UBelt* GetPreferredBelt() const override
129  {
130  return PreferredBelt;
131  }
132 }; // class USubjectiveUserWidget
133 
An interface for all sorts of subjects.
Definition: Subjective.h:42
The conveyor belt consisting of subjects.
Definition: Belt.h:60
static const int32 InvalidSlotIndex
Is this a special buffering belt?
Definition: Belt.h:96
The base subject detail (component) class.
Definition: Detail.h:35
A UI widget subject functionality.
Definition: SubjectiveUserWidget.h:36
const FFingerprint & GetFingerprint() const override
Get the active fingerprint of the subjective.
Definition: SubjectiveUserWidget.h:123
FFingerprint & GetFingerprint() override
Get the internal fingerprint of the subjective.
Definition: SubjectiveUserWidget.h:116
void TakeBeltSlot(UBelt *InBelt, int32 InSlotIndex) override
Set the current belt slot of the subjective (if any).
Definition: SubjectiveUserWidget.h:92
class UBelt * GetPreferredBelt() const override
Get the preferred belt of the subjective (if any).
Definition: SubjectiveUserWidget.h:128
const TArray< UDetail * > & GetDetailsRef() const override
Direct access for the internal details array.
Definition: SubjectiveUserWidget.h:111
TArray< UDetail * > & GetDetailsRef() override
Direct access for the internal details array.
Definition: SubjectiveUserWidget.h:106
The belt slot, containing the cached details.
Definition: BeltSlot.h:40
The details fingerprint.
Definition: Fingerprint.h:117