-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathQLHUD.cpp
More file actions
61 lines (54 loc) · 2.03 KB
/
QLHUD.cpp
File metadata and controls
61 lines (54 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//----------------------------------------
// Quarter Life
//
// MIT license
//
// (\-/)
// (='.'=)
// (")-(")o
//----------------------------------------
#include "QL.h"
#include "QLHUD.h"
//------------------------------------------------------------
//------------------------------------------------------------
AQLHUD::AQLHUD()
{
}
//------------------------------------------------------------
//------------------------------------------------------------
void AQLHUD::DrawHUD()
{
Super::DrawHUD();
DrawWeaponCrosshairIfAny();
}
//------------------------------------------------------------
//------------------------------------------------------------
void AQLHUD::DrawWeaponCrosshairIfAny()
{
AQLCharacter* QLCharacter = Cast<AQLCharacter>(GetOwningPawn());
// if owning pawn exists
if (QLCharacter)
{
AQLWeapon* CurrentWeapon = QLCharacter->GetCurrentWeapon();
// if owning pawn's weapon exists
if (CurrentWeapon)
{
CrosshairTextureList = CurrentWeapon->CurrentCrosshairTextureList;
// if owning pawn's weapon' crosshair exists
if (CrosshairTextureList.Num())
{
for (int32 i = 0; i < CrosshairTextureList.Num(); ++i)
{
// Find the center of our canvas.
FVector2D Center(Canvas->ClipX * 0.5f, Canvas->ClipY * 0.5f);
// Offset by half of the texture's dimensions so that the center of the texture aligns with the center of the Canvas.
FVector2D CrossHairDrawPosition(Center.X - (CrosshairTextureList[i]->GetSurfaceWidth() * 0.5f), Center.Y - (CrosshairTextureList[i]->GetSurfaceHeight() * 0.5f));
// Draw the crosshair at the centerpoint.
FCanvasTileItem TileItem(CrossHairDrawPosition, CrosshairTextureList[i]->Resource, FLinearColor::White);
TileItem.BlendMode = SE_BLEND_Translucent;
Canvas->DrawItem(TileItem);
}
}
}
}
}