CARLA
CarlaHUD.h
Go to the documentation of this file.
1 // Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 // Workaround to fix Windows conflict: Windows changes the name of some functions (DrawText, LoadLibrary...)
10 // with Unicode / ANSI versions for his own API (DrawTextW, DrawTextA, LoadLibraryW, LoadLibraryA...).
11 // But the changes are global for the compiler. Deep in headers, Windows has something like:
12 // #ifdef UNICODE
13 // #define DrawText DrawTextW
14 // #define LoadLibrary LoadLibraryW
15 // #else
16 // #define DrawText DrawTextA
17 // #define LoadLibrary LoadLibraryA
18 // #endif
19 // Then the linker tries to find the function DrawTextW on an external DLL and an unresolved external error happens because
20 // Unreal has no function DrawTextW, it has just DrawText.
21 // We can fix that by just undefining the function that conflicts with the name of the Windows API in Unicode.
22 #undef DrawText
23 
24 #include "Containers/Array.h"
25 #include "GameFramework/HUD.h"
26 #include "WheeledVehicleMovementComponent.h"
27 #include "CarlaHUD.generated.h"
28 
29 struct HUDString
30 {
31  FString Str { "" };
32  FVector Location;
33  FColor Color;
34  double TimeToDie;
35 };
36 
37 /// Class to draw on HUD
38 UCLASS()
39 class CARLA_API ACarlaHUD : public AHUD
40 {
41  GENERATED_BODY()
42 
43 public:
44 
45  ACarlaHUD(const FObjectInitializer& ObjectInitializer)
46  : Super(ObjectInitializer)
47  {
48  PrimaryActorTick.bCanEverTick = false;
49  }
50 
51  virtual void DrawHUD() override;
52 
53  UWheeledVehicleMovementComponent* DebugVehicle{nullptr};
54  void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent* Veh) { DebugVehicle = Veh; }
55 
56  void AddHUDString(const FString Str, const FVector Location, const FColor Color, double LifeTime);
57 
58 private:
59  TArray<HUDString> StringList;
60 };
double TimeToDie
Definition: CarlaHUD.h:34
FColor Color
Definition: CarlaHUD.h:33
ACarlaHUD(const FObjectInitializer &ObjectInitializer)
Definition: CarlaHUD.h:45
FString Str
Definition: CarlaHUD.h:31
void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent *Veh)
Definition: CarlaHUD.h:54
FVector Location
Definition: CarlaHUD.h:32
TArray< HUDString > StringList
Definition: CarlaHUD.h:59
Class to draw on HUD.
Definition: CarlaHUD.h:39