-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Screen.ts
65 lines (48 loc) · 1.74 KB
/
Screen.ts
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
62
63
64
65
import { PointF, stringToArray, Vector3 } from '../utils';
import { Notification } from './';
export abstract class Screen {
public static get Width(): number {
return GetScreenActiveResolution()[0];
}
public static get Height(): number {
return GetScreenActiveResolution()[1];
}
public static get AspectRatio(): number {
return GetAspectRatio(false);
}
public static get ScaledWidth(): number {
return this.Height * this.AspectRatio;
}
public static showSubtitle(message: string, duration: number = 2500) {
const strings: string[] = stringToArray(message);
BeginTextCommandPrint('CELL_EMAIL_BCON');
strings.forEach((element) => {
AddTextComponentSubstringPlayerName(element);
});
EndTextCommandPrint(duration, true);
}
public static displayHelpTextThisFrame(message: string) {
const strings: string[] = stringToArray(message);
BeginTextCommandDisplayHelp('CELL_EMAIL_BCON');
strings.forEach((element) => {
AddTextComponentSubstringPlayerName(element);
});
EndTextCommandDisplayHelp(0, false, false, -1);
}
public static showNotification(message: string, blinking = false): Notification {
const strings: string[] = stringToArray(message);
SetNotificationTextEntry('CELL_EMAIL_BCON');
strings.forEach((element) => {
AddTextComponentSubstringPlayerName(element);
});
return new Notification(DrawNotification(blinking, true));
}
public static worldToScreen(position: Vector3, scaleWidth: boolean = false) {
const coords = GetScreenCoordFromWorldCoord(position.x, position.y, position.z);
return new PointF(
coords[0] * (scaleWidth ? this.ScaledWidth : this.Width),
coords[1] * this.Height,
coords[2],
);
}
}