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 "Carla.h"
25 #include "Containers/Array.h"
26 #include "GameFramework/HUD.h"
27 #include "WheeledVehicleMovementComponent.h"
28 #include "CarlaHUD.generated.h"
29 
30 struct HUDString
31 {
32  FString Str { "" };
33  FVector Location;
34  FColor Color;
35  double TimeToDie;
36 };
37 
38 /// Class to draw on HUD
39 UCLASS()
40 class CARLA_API ACarlaHUD : public AHUD
41 {
42  GENERATED_BODY()
43 
44 public:
45 
46  ACarlaHUD(const FObjectInitializer& ObjectInitializer)
47  : Super(ObjectInitializer)
48  {
49  PrimaryActorTick.bCanEverTick = false;
50  }
51 
52  virtual void DrawHUD() override;
53 
54  UWheeledVehicleMovementComponent* DebugVehicle{nullptr};
55  void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent* Veh) { DebugVehicle = Veh; }
56 
57  void AddHUDString(const FString Str, const FVector Location, const FColor Color, double LifeTime);
58 
59 private:
60  TArray<HUDString> StringList;
61 };
double TimeToDie
Definition: CarlaHUD.h:35
FColor Color
Definition: CarlaHUD.h:34
ACarlaHUD(const FObjectInitializer &ObjectInitializer)
Definition: CarlaHUD.h:46
FString Str
Definition: CarlaHUD.h:32
void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent *Veh)
Definition: CarlaHUD.h:55
FVector Location
Definition: CarlaHUD.h:33
TArray< HUDString > StringList
Definition: CarlaHUD.h:60
Class to draw on HUD.
Definition: CarlaHUD.h:40