1.14.0.5
Coherent HB for UE4
A modern user interface library for games
HummingbirdJSEvent.h
1 /*
2 This file is part of Hummingbird, modern user interface library for
3 games. Release $RELEASE$. Build $VERSION$ for $LICENSEE$.
4 
5 Copyright (c) 2012-2018 Coherent Labs AD and/or its licensors. All
6 rights reserved in all media.
7 
8 The coded instructions, statements, computer programs, and/or related
9 material (collectively the "Data") in these files contain confidential
10 and unpublished information proprietary Coherent Labs and/or its
11 licensors, which is protected by United States of America federal
12 copyright law and by international treaties.
13 
14 This software or source code is supplied under the terms of a license
15 agreement and nondisclosure agreement with Coherent Labs Limited and may
16 not be copied, disclosed, or exploited except in accordance with the
17 terms of that agreement. The Data may not be disclosed or distributed to
18 third parties, in whole or in part, without the prior written consent of
19 Coherent Labs Limited.
20 
21 COHERENT LABS MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS
22 SOURCE CODE FOR ANY PURPOSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23 HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, ITS AFFILIATES,
27 PARENT COMPANIES, LICENSORS, SUPPLIERS, OR CONTRIBUTORS BE LIABLE FOR
28 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 ANY WAY OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE OR SOURCE CODE,
34 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */
36 #pragma once
37 
38 #if !defined(HUMMINGBIRD_UE4_419_SUPPORT)
39 // Needed because UE 4.20.0 seems to have a missing-include-bug.
40 // Adding a BlueprintCallable function taking an FText tries to use UTextProperty
41 // which seems not to be included.
42 #include <UObject/TextProperty.h>
43 #endif
44 #include "HummingbirdJSEvent.generated.h"
45 
50 UCLASS(MinimalAPI, BlueprintType, Blueprintable, notplaceable)
51 class UHummingbirdJSEvent : public UObject
52 {
53  GENERATED_UCLASS_BODY()
54 public:
55 
57  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
58  void AddByte(uint8 byte);
59 
61  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
62  void AddInt32(int32 integer);
63 
65  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
66  void AddString(const FString& str);
67 
69  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
70  void AddName(const FName& name);
71 
73  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
74  void AddText(const FText& text);
75 
77  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
78  void AddFloat(float fl);
79 
81  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
82  void AddBool(bool b);
83 
85  UFUNCTION(BlueprintCallable, CustomThunk, meta = (CustomStructureParam = "Arg"), Category = "ViewScripting")
86  void AddStructArg(const UStructProperty* Arg);
87 
89  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
90  void AddObject(UObject* object);
91 
93  UFUNCTION(BlueprintCallable, CustomThunk, meta = (ArrayParm = "Array"), Category = "ViewScripting")
94  void AddArray(const TArray<int32>& Array);
95 
96  enum EVariableType
97  {
98  VT_Int32,
99  VT_Float,
100  VT_Bool,
101  VT_String,
102  VT_Struct,
103  VT_Object,
104  VT_Array,
105 
106  VT_Count
107  };
108 
110  void AddArrayInternal(void* Array, EVariableType ArrayType);
111  void AddArrayOfStructsInternal(void* Array, UStruct* StructType);
112  void AddStructInternal(const UStructProperty* PropertyType, void* ArgAddress);
113 
114  TArray<int32> Ints;
115  TArray<FString> Strings;
116  TArray<float> Floats;
117  TArray<bool> Bools;
118  TArray<TWeakObjectPtr<UObject>> Objects;
119 
120  struct FBoundStructArg
121  {
122  const UStruct* StructType;
123  TArray<uint8> Data;
124  };
125  TArray<FBoundStructArg> StructArgs;
126 
127  struct FBoundArrayData
128  {
129  const void* Data;
130  EVariableType VariableType;
131  // Only used when the array is of type VT_Struct as we need to know the actual element type
132  UStruct* StructType;
133 
134  FBoundArrayData()
135  : Data(nullptr)
136  , StructType(nullptr)
137  {}
138  };
139  TArray<FBoundArrayData> Arrays;
140 
141  struct FVariablePair
142  {
143  EVariableType Type;
144  int32 Id;
145  };
146  TArray<FVariablePair> OrderedVariables;
147 
148  UPROPERTY(Transient)
149  TArray<const UStruct*> StructTypes;
150 
151 private:
152  void AddGenericArray(const UArrayProperty* ArrayProperty, void* ArrayAddress);
153  void AddGenericStructArg(const UStructProperty* PropertyType, void* ArgAddress);
154 
155 public:
156 
157 #if defined(HUMMINGBIRD_UE4_418_SUPPORT)
158  DECLARE_FUNCTION(execAddArray)
159  {
160  Stack.MostRecentProperty = nullptr;
161  Stack.StepCompiledIn<UArrayProperty>(NULL);
162  void* ArrayAddress = Stack.MostRecentPropertyAddress;
163  UArrayProperty* ArrayProperty = Cast<UArrayProperty>(Stack.MostRecentProperty);
164  if (!ArrayProperty)
165  {
166  Stack.bArrayContextFailed = true;
167  return;
168  }
169  AddGenericArray(ArrayProperty, ArrayAddress);
170  P_FINISH;
171  }
172 
173  DECLARE_FUNCTION(execAddStructArg)
174  {
175  Stack.MostRecentProperty = nullptr;
176  Stack.StepCompiledIn<UStructProperty>(NULL);
177  void* ArgAddress = Stack.MostRecentPropertyAddress;
178  UStructProperty* Prop = ExactCast<UStructProperty>(Stack.MostRecentProperty);
179  AddGenericStructArg(Prop, ArgAddress);
180  P_FINISH;
181  }
182 #else
183  //declared here and defined in the cpp file
184  DECLARE_FUNCTION(execAddArray);
185  DECLARE_FUNCTION(execAddStructArg);
186 #endif
187 
188  virtual void BeginDestroy();
189 
191 };
Definition: HummingbirdJSEvent.h:51