Coherent UI for Unreal Engine 4  2.5.5.0
A modern user interface library for games
 All Classes Functions Variables Pages
CoherentBaseComponent.h
1 /*
2 This file is part of Coherent UI, modern user interface library for
3 games.
4 
5 Copyright (c) 2012-2014 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 #include "CoherentUIViewListener.h"
39 #include "CoherentMediaRequestHandler.h"
40 #include "CoherentUIJSEvent.h"
41 #include "CoherentUIJSPayload.h"
42 
43 #include "CoherentBaseComponent.generated.h"
44 
45 USTRUCT()
46 struct FCoherentComponentTickFunction : public FTickFunction
47 {
48  GENERATED_USTRUCT_BODY()
49 
50  class UCoherentBaseComponent* Target;
51 
52  virtual void ExecuteTick(float DeltaTime, enum ELevelTick TickType, ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent) override;
53  virtual FString DiagnosticMessage();
54 };
55 
56 DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FUIReadyForBindingsSignature, int32, frameId, const FString&, Path, bool, isMainFrame);
57 DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FUIBindingsReleasedSignature, int32, frameId, const FString&, validatedPath, bool, isMainFrame);
58 DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FUIFinishLoadSignature, int32, frameId, const FString&, validatedPath, bool, isMainFrame, int32, statusCode);
59 DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FUIFailLoad, int32, frameId, const FString&, validatedPath, bool, isMainFrame, const FString&, error);
60 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUIOnNavigate, const FString&, url);
61 DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FUIScriptMessage, const FString&, message, const FString&, sourceId, int32, line);
62 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUICursorChanged, int32, cursorId);
63 DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FUIJavaScriptMesssage, const FString&, message, const FString&, defaultPrompt, const FString&, frameURL, int32, type);
64 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUIOnError, const FString&, error);
65 DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUIOnJavaScriptEvent, UCoherentUIJSPayload*, payload);
66 DECLARE_DYNAMIC_MULTICAST_DELEGATE(FUIScriptingReady);
67 DECLARE_DYNAMIC_MULTICAST_DELEGATE(FUIOnViewCreated);
68 
75 UCLASS(BlueprintType)
76 class COHERENTUIPLUGIN_API UCoherentBaseComponent : public UActorComponent, public FCoherentUIViewListener
77 {
78  GENERATED_UCLASS_BODY()
79 public:
81  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
82  FString URL;
83 
84  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View", meta = (ClampMin = "0", UIMin = "0", UIMax = "4096"))
85  int32 Width;
86 
87  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View", meta = (ClampMin = "0", UIMin = "0", UIMax = "4096"))
88  int32 Height;
89 
91  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
92  bool Transparent;
93 
95  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
96  bool SupportClickThrough;
97 
99  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View", meta = (ClampMin = "1", UIMin = "1", UIMax = "120"))
100  int32 MaxFPS;
101 
103  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
104  bool ForceSoftwareRendering;
105 
107  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
108  bool UseSharedMemory;
109 
111  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
112  bool IsOnDemand;
113 
115  UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "View")
116  bool bReceiveInput;
117 
119  UPROPERTY(BlueprintAssignable)
120  FUIReadyForBindingsSignature ReadyForBindings;
121 
123  UPROPERTY(BlueprintAssignable)
124  FUIBindingsReleasedSignature BindingsReleased;
125 
127  UPROPERTY(BlueprintAssignable)
128  FUIFinishLoadSignature FinishLoad;
129 
131  UPROPERTY(BlueprintAssignable)
132  FUIFailLoad FailLoad;
133 
135  UPROPERTY(BlueprintAssignable)
136  FUIOnNavigate OnNavigate;
137 
139  UPROPERTY(BlueprintAssignable)
140  FUIScriptMessage ScriptMessage;
141 
143  UPROPERTY(BlueprintAssignable)
144  FUICursorChanged CursorChanged;
145 
147  UPROPERTY(BlueprintAssignable)
148  FUIJavaScriptMesssage JavaScriptMessage;
149 
151  UPROPERTY(BlueprintAssignable)
152  FUIOnError ErrorOccured;
153 
155  UPROPERTY(BlueprintAssignable)
156  FUIOnJavaScriptEvent JavaScriptEvent;
157 
159  UPROPERTY(BlueprintAssignable)
160  FUIScriptingReady UIScriptingReady;
161 
163  UPROPERTY(BlueprintAssignable)
164  FUIOnViewCreated UIOnViewCreated;
165 
167  UFUNCTION(BlueprintCallable, Category = "View")
168  UCoherentMediaRequestHandler* GetMediaRequestHandler();
169 
171  UFUNCTION(BlueprintCallable, Category = "View")
172  void Resize(int32 resizeWidth, int32 resizeHeight);
173 
175  UFUNCTION(BlueprintCallable, Category = "View")
176  void IssueMouseOnUIQuery(float normX, float normY);
177 
179  UFUNCTION(BlueprintCallable, Category = "View")
180  bool HasMouseQueryFinished();
181 
183  UFUNCTION(BlueprintCallable, Category = "View")
184  void FetchMouseOnUIQuery();
185 
187  UFUNCTION(BlueprintCallable, Category = "View")
188  bool IsMouseOnView();
189 
191  UFUNCTION(BlueprintCallable, Category = "View")
192  void SetClickThroughAlphaThreshold(float threshold);
193 
195  UFUNCTION(BlueprintCallable, Category = "View")
196  float GetClickThroughAlphaThreshold() const;
197 
199  UFUNCTION(BlueprintCallable, Category = "View")
200  void SetTargetFramerate(int32 target);
201 
203  UFUNCTION(BlueprintCallable, Category = "View")
204  int32 GetTargetFramerate() const;
205 
207  UFUNCTION(BlueprintCallable, Category = "View")
208  bool IsViewOnDemand() const;
209 
211  UFUNCTION(BlueprintCallable, Category = "View")
212  bool IsTransparent() const;
213 
215  UFUNCTION(BlueprintCallable, Category = "View")
216  void Redraw() const;
217 
219  UFUNCTION(BlueprintCallable, Category = "View")
220  void Load(const FString& path);
221 
223  UFUNCTION(BlueprintCallable, Category = "View")
224  void Reload(bool ignoreCache);
225 
227  UFUNCTION(BlueprintCallable, Category = "View")
228  FString GetCurentViewPath() const;
229 
231  UFUNCTION(BlueprintCallable, Category = "View")
232  FString GetLastRequestedPath() const;
233 
235  UFUNCTION(BlueprintCallable, Category = "View")
236  FString GetLastLoadedPath() const;
237 
239  UFUNCTION(BlueprintCallable, Category = "View")
240  FString GetLastFailedPath() const;
241 
243  UFUNCTION(BlueprintCallable, Category = "View")
244  UTexture2D* GetTexture() const;
245 
247  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
248  UCoherentUIJSEvent* CreateJSEvent();
249 
251  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
252  void TriggerJSEvent(const FString& name, UCoherentUIJSEvent* eventData) const;
253 
255  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
256  bool IsReadyForBindings() const;
257 
259  UFUNCTION(BlueprintCallable, Category = "ViewScripting")
260  bool IsReadyForScripting() const;
261 
262 public:
263  virtual void InitializeComponent();
264  virtual void TickCustom(FCoherentComponentTickFunction* function);
265 
266  FCoherentComponentTickFunction PostPhysicsComponentTick;
267 
268  void RegisterTickFunctions(bool bRegister);
269 
270  virtual void OnRegister() override;
271  virtual void OnUnregister() override;
272  virtual void OnComponentDestroyed() override;
273 
274  virtual void BeginDestroy() override;
275  virtual bool IsReadyForFinishDestroy() override;
276 
277 public:
278  virtual void OnViewCreated(Coherent::UI::View* View) override;
279  void OnScriptingReady();
280  virtual void OnReadyForBindings(int frameId,
281  const wchar_t* path,
282  bool isMainFrame) override;
283  virtual void OnFinishLoad(int frameId,
284  const wchar_t* validatedPath,
285  bool isMainFrame,
286  int statusCode,
287  Coherent::UI::HTTPHeader* headers,
288  unsigned headersCount) override;
289  virtual void OnFailLoad(int frameId,
290  const wchar_t* validatedPath,
291  bool isMainFrame,
292  const char* error) override;
293  virtual void OnBindingsReleased(int frameId,
294  const wchar_t* path,
295  bool isMainFrame) override;
296  virtual void OnNavigateTo(const wchar_t* path) override;
297  virtual void OnScriptMessage(MessageLevel level, const wchar_t* message, const wchar_t* sourceId, int line) override;
298  virtual void OnCursorChanged(Coherent::UI::CursorTypes cursor) override;
299  virtual void OnJavaScriptMessage(const wchar_t* message, const wchar_t* defaultPrompt, const wchar_t* frameUrl, int messageType) override;
300  virtual void OnError(const Coherent::UI::ViewError& error) override;
301  virtual void OnCallback(const char* eventName, const Coherent::UI::EventArguments& arguments) override;
302  virtual void OnRequestMediaStream(Coherent::UI::MediaStreamRequest* request) override;
303 
304  virtual void Release() override;
305 
306 public:
307  typedef TArray<TWeakObjectPtr<UCoherentBaseComponent>> WeakCoherentComponentsArray;
308  static WeakCoherentComponentsArray::TIterator GetUCoherentBaseComponentIterator(UWorld* world);
309  void ViewRequested();
310 private:
311  bool bIsReadyForBindings;
312  bool bIsReadyForScripting;
313  bool bIsMouseOnUI;
314  bool bIsReadyForFinishDestroy;
315 
316  UPROPERTY()
317  UCoherentMediaRequestHandler* m_MediaRequestHandler;
318 
319 };
Definition: CoherentUIJSPayload.h:47
Definition: CoherentUIJSEvent.h:45
Definition: CoherentMediaRequestHandler.h:65
Definition: CoherentBaseComponent.h:76