@nativewrappers/fivem 0.0.64 → 0.0.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/Audio.d.ts +2 -2
  2. package/Blip.d.ts +2 -2
  3. package/Camera.d.ts +1 -1
  4. package/Game.d.ts +1 -1
  5. package/GameplayCamera.d.ts +1 -1
  6. package/Model.d.ts +1 -1
  7. package/ParticleEffect.d.ts +2 -2
  8. package/ParticleEffectAsset.d.ts +1 -1
  9. package/README.md +45 -0
  10. package/Raycast.d.ts +2 -2
  11. package/RelationshipGroup.d.ts +1 -1
  12. package/Tasks.d.ts +3 -3
  13. package/World.d.ts +2 -2
  14. package/cfx/StateBagChangeHandler.d.ts +1 -3
  15. package/common/Command.d.ts +30 -0
  16. package/common/Convar.d.ts +13 -0
  17. package/common/GlobalData.d.ts +8 -0
  18. package/common/Kvp.d.ts +69 -0
  19. package/common/Resource.d.ts +14 -0
  20. package/common/decors/Events.d.ts +54 -0
  21. package/common/index.d.ts +8 -0
  22. package/common/net/NetworkedMap.d.ts +28 -0
  23. package/common/types.d.ts +5 -0
  24. package/common/utils/ClassTypes.d.ts +11 -0
  25. package/common/utils/Color.d.ts +14 -0
  26. package/common/utils/Maths.d.ts +4 -0
  27. package/common/utils/PointF.d.ts +12 -0
  28. package/common/utils/Quaternion.d.ts +10 -0
  29. package/common/utils/Vector.d.ts +429 -0
  30. package/common/utils/Vector2.d.ts +1 -0
  31. package/common/utils/Vector3.d.ts +1 -0
  32. package/common/utils/Vector4.d.ts +1 -0
  33. package/common/utils/cleanPlayerName.d.ts +6 -0
  34. package/common/utils/enumValues.d.ts +12 -0
  35. package/{utils/getStringFromUInt8Array.js → common/utils/getStringFromUInt8Array.d.ts} +1 -3
  36. package/{utils/getUInt32FromUint8Array.js → common/utils/getUInt32FromUint8Array.d.ts} +1 -1
  37. package/common/utils/index.d.ts +12 -0
  38. package/index.d.ts +1 -1
  39. package/index.js +20136 -26
  40. package/interfaces/Dimensions.d.ts +1 -1
  41. package/models/BaseEntity.d.ts +3 -3
  42. package/models/Ped.d.ts +2 -2
  43. package/models/PedBone.d.ts +1 -1
  44. package/models/PedBoneCollection.d.ts +1 -1
  45. package/models/Player.d.ts +1 -1
  46. package/models/Vehicle.d.ts +2 -2
  47. package/models/VehicleDoor.d.ts +2 -2
  48. package/models/VehicleDoorCollection.d.ts +1 -1
  49. package/models/VehicleMod.d.ts +2 -2
  50. package/models/VehicleModCollection.d.ts +2 -2
  51. package/models/VehicleToggleMod.d.ts +2 -2
  52. package/models/VehicleWheel.d.ts +1 -1
  53. package/models/VehicleWheelCollection.d.ts +1 -1
  54. package/models/VehicleWindow.d.ts +2 -2
  55. package/models/VehicleWindowCollection.d.ts +1 -1
  56. package/package.json +6 -4
  57. package/ui/Container.d.ts +2 -2
  58. package/ui/Effects.d.ts +1 -1
  59. package/ui/Hud.d.ts +2 -2
  60. package/ui/InstructionalButtons.d.ts +1 -1
  61. package/ui/Rectangle.d.ts +2 -2
  62. package/ui/Scaleform.d.ts +1 -1
  63. package/ui/Screen.d.ts +1 -1
  64. package/ui/Text.d.ts +1 -1
  65. package/ui/interfaces/IButton.d.ts +1 -1
  66. package/ui/interfaces/IDrawable.d.ts +1 -1
  67. package/ui/menu/items/UIMenuItem.d.ts +1 -1
  68. package/ui/menu/items/UIMenuListItem.d.ts +1 -1
  69. package/ui/menu/items/panels/AbstractUIMenuPanel.d.ts +2 -2
  70. package/ui/menu/items/panels/UIMenuStatisticsPanel.d.ts +1 -1
  71. package/utils/LiteEvent.d.ts +2 -6
  72. package/utils/index.d.ts +1 -1
  73. package/weapon/DlcWeaponData.d.ts +1 -1
  74. package/weapon/Weapon.d.ts +7 -7
  75. package/weapon/WeaponAsset.d.ts +1 -1
  76. package/weapon/WeaponCollection.d.ts +2 -2
  77. package/weaponComponent/DlcWeaponComponentData.d.ts +1 -1
  78. package/weaponComponent/InvalidWeaponComponent.d.ts +1 -1
  79. package/weaponComponent/WeaponComponent.d.ts +3 -3
  80. package/weaponComponent/WeaponComponentCollection.d.ts +3 -3
  81. package/Audio.js +0 -93
  82. package/Blip.js +0 -105
  83. package/Camera.js +0 -162
  84. package/Checkpoint.js +0 -43
  85. package/Events.js +0 -74
  86. package/Game.js +0 -474
  87. package/GameplayCamera.js +0 -141
  88. package/Model.js +0 -213
  89. package/NetworkedScene.js +0 -18
  90. package/ParticleEffect.js +0 -123
  91. package/ParticleEffectAsset.js +0 -105
  92. package/Pickup.js +0 -19
  93. package/Raycast.js +0 -123
  94. package/RelationshipGroup.js +0 -67
  95. package/Rope.js +0 -129
  96. package/TaskSequence.js +0 -48
  97. package/Tasks.js +0 -241
  98. package/World.js +0 -765
  99. package/cfx/StateBagChangeHandler.js +0 -1
  100. package/cfx/index.js +0 -1
  101. package/enums/Alignment.js +0 -6
  102. package/enums/AnimationFlags.js +0 -35
  103. package/enums/AudioFlag.js +0 -38
  104. package/enums/BadgeStyle.js +0 -183
  105. package/enums/Blip.js +0 -225
  106. package/enums/Bone.js +0 -103
  107. package/enums/CameraShake.js +0 -14
  108. package/enums/CameraTypes.js +0 -8
  109. package/enums/CheckboxStyle.js +0 -5
  110. package/enums/Checkpoint.js +0 -67
  111. package/enums/CloudHat.js +0 -27
  112. package/enums/Control.js +0 -361
  113. package/enums/CursorSprite.js +0 -15
  114. package/enums/Driving.js +0 -34
  115. package/enums/ExplosionType.js +0 -45
  116. package/enums/FiringPattern.js +0 -20
  117. package/enums/Font.js +0 -8
  118. package/enums/ForceType.js +0 -9
  119. package/enums/Gender.js +0 -5
  120. package/enums/HelmetType.js +0 -6
  121. package/enums/HudColor.js +0 -184
  122. package/enums/HudComponent.js +0 -54
  123. package/enums/InputMode.js +0 -5
  124. package/enums/InvertAxis.js +0 -7
  125. package/enums/Language.js +0 -15
  126. package/enums/LeaveVehicleFlags.js +0 -11
  127. package/enums/LoadingSpinnerType.js +0 -8
  128. package/enums/MarkerType.js +0 -50
  129. package/enums/MenuAlignment.js +0 -5
  130. package/enums/NotificationType.js +0 -11
  131. package/enums/Parachute.js +0 -15
  132. package/enums/PickupType.js +0 -74
  133. package/enums/RadioStation.js +0 -25
  134. package/enums/RagdollType.js +0 -7
  135. package/enums/RaycastEnums.js +0 -32
  136. package/enums/Relationship.js +0 -10
  137. package/enums/RopeType.js +0 -6
  138. package/enums/ScreenEffect.js +0 -84
  139. package/enums/SpeechModifier.js +0 -40
  140. package/enums/Vehicle.js +0 -376
  141. package/enums/Weather.js +0 -22
  142. package/enums/ZoneID.js +0 -95
  143. package/enums/index.js +0 -42
  144. package/hashes/MaterialHash.js +0 -217
  145. package/hashes/PedHash.js +0 -725
  146. package/hashes/VehicleHash.js +0 -523
  147. package/hashes/WeaponHash.js +0 -161
  148. package/hashes/WeatherTypeHash.js +0 -22
  149. package/hashes/index.js +0 -5
  150. package/interfaces/Dimensions.js +0 -1
  151. package/models/BaseEntity.js +0 -477
  152. package/models/Entity.js +0 -25
  153. package/models/EntityBone.js +0 -26
  154. package/models/EntityBoneCollection.js +0 -18
  155. package/models/Ped.js +0 -692
  156. package/models/PedBone.js +0 -9
  157. package/models/PedBoneCollection.js +0 -21
  158. package/models/Player.js +0 -186
  159. package/models/Prop.js +0 -26
  160. package/models/Vehicle.js +0 -576
  161. package/models/VehicleDoor.js +0 -44
  162. package/models/VehicleDoorCollection.js +0 -62
  163. package/models/VehicleMod.js +0 -35
  164. package/models/VehicleModCollection.js +0 -227
  165. package/models/VehicleToggleMod.js +0 -29
  166. package/models/VehicleWheel.js +0 -23
  167. package/models/VehicleWheelCollection.js +0 -57
  168. package/models/VehicleWindow.js +0 -35
  169. package/models/VehicleWindowCollection.js +0 -57
  170. package/models/index.js +0 -19
  171. package/ui/Container.js +0 -31
  172. package/ui/Effects.js +0 -106
  173. package/ui/Fading.js +0 -69
  174. package/ui/Hud.js +0 -39
  175. package/ui/InstructionalButtons.js +0 -54
  176. package/ui/LoadingPrompt.js +0 -45
  177. package/ui/Notification.js +0 -9
  178. package/ui/Rectangle.js +0 -40
  179. package/ui/Scaleform.js +0 -236
  180. package/ui/Screen.js +0 -72
  181. package/ui/Sprite.js +0 -60
  182. package/ui/Text.js +0 -115
  183. package/ui/Timerbar.js +0 -248
  184. package/ui/index.js +0 -15
  185. package/ui/interfaces/IButton.js +0 -1
  186. package/ui/interfaces/IDrawable.js +0 -1
  187. package/ui/interfaces/index.js +0 -1
  188. package/ui/menu/Menu.js +0 -831
  189. package/ui/menu/MenuControl.js +0 -12
  190. package/ui/menu/MenuControls.js +0 -9
  191. package/ui/menu/MenuSettings.js +0 -54
  192. package/ui/menu/index.js +0 -6
  193. package/ui/menu/items/UIMenuCheckboxItem.js +0 -59
  194. package/ui/menu/items/UIMenuItem.js +0 -1111
  195. package/ui/menu/items/UIMenuListItem.js +0 -119
  196. package/ui/menu/items/UIMenuSeparatorItem.js +0 -29
  197. package/ui/menu/items/UIMenuSliderItem.js +0 -191
  198. package/ui/menu/items/index.js +0 -6
  199. package/ui/menu/items/panels/AbstractUIMenuPanel.js +0 -44
  200. package/ui/menu/items/panels/UIMenuColorPanel.js +0 -217
  201. package/ui/menu/items/panels/UIMenuGridPanel.js +0 -261
  202. package/ui/menu/items/panels/UIMenuPercentagePanel.js +0 -124
  203. package/ui/menu/items/panels/UIMenuStatisticsPanel.js +0 -79
  204. package/ui/menu/items/panels/UIMenuStatisticsPanelItem.js +0 -35
  205. package/ui/menu/items/panels/index.js +0 -6
  206. package/ui/menu/modules/ListItem.js +0 -10
  207. package/ui/menu/modules/index.js +0 -1
  208. package/utils/Animations.js +0 -55
  209. package/utils/Crypto.js +0 -25
  210. package/utils/LiteEvent.js +0 -19
  211. package/utils/Maths.js +0 -10
  212. package/utils/Point.js +0 -30
  213. package/utils/PointF.js +0 -14
  214. package/utils/Quaternion.js +0 -27
  215. package/utils/Size.js +0 -8
  216. package/utils/String.js +0 -25
  217. package/utils/enumValues.js +0 -14
  218. package/utils/index.js +0 -9
  219. package/weapon/DlcWeaponData.js +0 -44
  220. package/weapon/Mk2WeaponHash.js +0 -25
  221. package/weapon/Weapon.js +0 -270
  222. package/weapon/WeaponAsset.js +0 -84
  223. package/weapon/WeaponCollection.js +0 -187
  224. package/weapon/WeaponDisplayNameByHash.js +0 -75
  225. package/weapon/WeaponGroup.js +0 -19
  226. package/weapon/WeaponHudStats.js +0 -38
  227. package/weapon/WeaponLivery.js +0 -14
  228. package/weapon/WeaponLiveryColor.js +0 -35
  229. package/weapon/WeaponTint.js +0 -43
  230. package/weapon/index.js +0 -8
  231. package/weaponComponent/ComponentAttachmentPoint.js +0 -19
  232. package/weaponComponent/ComponentAttachmentPointByHash.js +0 -573
  233. package/weaponComponent/ComponentDisplayNameByHash.js +0 -280
  234. package/weaponComponent/DlcWeaponComponentData.js +0 -44
  235. package/weaponComponent/InvalidWeaponComponent.js +0 -28
  236. package/weaponComponent/WeaponComponent.js +0 -123
  237. package/weaponComponent/WeaponComponentCollection.js +0 -174
  238. package/weaponComponent/WeaponComponentHash.js +0 -887
  239. package/weaponComponent/WeaponComponentHashesByWeaponHash.js +0 -829
  240. package/weaponComponent/WeaponComponentHudStats.js +0 -34
  241. package/weaponComponent/index.js +0 -5
@@ -1,54 +0,0 @@
1
- import { Scaleform } from "./Scaleform";
2
- /**
3
- * Draw native instructional buttons in the bottom left of the screen using scaleform
4
- *
5
- * Example:
6
- *
7
- * ```typescript
8
- * import { InstructionalButtons, Control } from '@nativewrappers/client';
9
- *
10
- * const buttons = new InstructionalButtons([
11
- * {controls: [Control.Context], label: "Interact with Bob"},
12
- * {controls: [Control.Detonate], label: "Say hello to Alice"}
13
- * ])
14
- *
15
- * setTick(() => {
16
- * buttons.draw()
17
- * })
18
- * ```
19
- */
20
- export class InstructionalButtons {
21
- scaleform;
22
- /**
23
- * Draws native instructional buttons
24
- *
25
- * @param buttons Array of instructional buttons to be drawn
26
- */
27
- constructor(buttons) {
28
- this.scaleform = new Scaleform("INSTRUCTIONAL_BUTTONS");
29
- this.scaleform.callFunction("CLEAR_ALL");
30
- this.scaleform.callFunction("SET_CLEAR_SPACE", 200);
31
- buttons.forEach((button, index) => {
32
- this.pushButton(button, index);
33
- });
34
- this.scaleform.callFunction("DRAW_INSTRUCTIONAL_BUTTONS");
35
- this.scaleform.callFunction("SET_BACKGROUND_COLOUR", 0, 0, 0, 80);
36
- }
37
- pushButton(button, index) {
38
- BeginScaleformMovieMethod(this.scaleform.Handle, "SET_DATA_SLOT");
39
- PushScaleformMovieFunctionParameterInt(index);
40
- // Looping backwards here since scaleform is using a stack so the first control ends up being the last
41
- // So looping backwards makes more sense here so that the controls are rendered in the order they're defined
42
- for (let i = button.controls.length - 1; i >= 0; i--) {
43
- PushScaleformMovieMethodParameterButtonName(GetControlInstructionalButton(2, button.controls[i], true));
44
- }
45
- PushScaleformMovieMethodParameterString(button.label);
46
- EndScaleformMovieMethod();
47
- }
48
- /**
49
- * Renders the instructional button scaleform
50
- */
51
- async draw() {
52
- await this.scaleform.render2D();
53
- }
54
- }
@@ -1,45 +0,0 @@
1
- import { LoadingSpinnerType } from "../enums";
2
- /**
3
- * Show and hide loading prompt on the bottom right of the screen.
4
- *
5
- * Example:
6
- *
7
- * ```typescript
8
- * import { LoadingPrompt } from '@nativewrappers/client/ui';
9
- *
10
- * LoadingPrompt.show("Hello World");
11
- *
12
- * setTimeout(() => {
13
- * LoadingPrompt.hide();
14
- * }, 10000)'
15
- * ```
16
- */
17
- export class LoadingPrompt {
18
- /**
19
- * Shows a loading prompt.
20
- *
21
- * @param loadingText Text to be displayed inside loading prompt.
22
- * @param spinnerType Type of spinner.
23
- */
24
- static show(loadingText = "", spinnerType = LoadingSpinnerType.RegularClockwise) {
25
- if (this.IsActive) {
26
- this.hide();
27
- }
28
- if (loadingText === "") {
29
- BeginTextCommandBusyString("");
30
- }
31
- else {
32
- BeginTextCommandBusyString("STRING");
33
- AddTextComponentSubstringPlayerName(loadingText);
34
- }
35
- EndTextCommandBusyString(Number(spinnerType));
36
- }
37
- static hide() {
38
- if (this.IsActive) {
39
- RemoveLoadingPrompt();
40
- }
41
- }
42
- static get IsActive() {
43
- return IsLoadingPromptBeingDisplayed();
44
- }
45
- }
@@ -1,9 +0,0 @@
1
- export class Notification {
2
- handle;
3
- constructor(handle) {
4
- this.handle = handle;
5
- }
6
- hide() {
7
- RemoveNotification(this.handle);
8
- }
9
- }
package/ui/Rectangle.js DELETED
@@ -1,40 +0,0 @@
1
- import { Point, Size } from "../utils";
2
- import { Screen } from "./";
3
- export class Rectangle {
4
- pos;
5
- size;
6
- color;
7
- constructor(pos, size, color) {
8
- this.pos = pos;
9
- this.size = size;
10
- this.color = color;
11
- }
12
- draw(arg1, arg2, color, resolution) {
13
- resolution = color === undefined ? arg2 : resolution;
14
- resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
15
- if (color === undefined) {
16
- if (arg1 && arg1 instanceof Size) {
17
- arg1 = new Point(this.pos.X + arg1.width, this.pos.Y + arg1.height);
18
- }
19
- else {
20
- arg1 = this.pos;
21
- }
22
- arg2 = this.size;
23
- }
24
- else {
25
- if (!arg1) {
26
- arg1 = this.pos;
27
- }
28
- else {
29
- arg1 = arg1;
30
- }
31
- arg2 = arg2 || this.size;
32
- }
33
- color = color || this.color;
34
- const w = arg2.width / resolution.width;
35
- const h = arg2.height / resolution.height;
36
- const x = arg1.X / resolution.width + w * 0.5;
37
- const y = arg1.Y / resolution.height + h * 0.5;
38
- DrawRect(x, y, w, h, color.r, color.g, color.b, color.a);
39
- }
40
- }
package/ui/Scaleform.js DELETED
@@ -1,236 +0,0 @@
1
- /**
2
- * Scaleforms will automatically load when calling any of the render functions.
3
- *
4
- * Example:
5
- *
6
- * ```typescript
7
- * import { Scaleform } from '@nativewrappers/client/ui';
8
- *
9
- * const scaleform = new Cfx.Scaleform("MIDSIZED_MESSAGE");
10
- *
11
- * scaleform.callFunction("SHOW_MIDSIZED_MESSAGE", ["Title", "Message"]);
12
- *
13
- * setTick(() => {
14
- * await scaleform.render2D();
15
- * });
16
- * ```
17
- */
18
- export class Scaleform {
19
- static render2DMasked(scaleform1, scaleform2) {
20
- return new Promise(async (resolve) => {
21
- if (scaleform1.IsLoaded && scaleform2.IsLoaded) {
22
- DrawScaleformMovieFullscreenMasked(scaleform1.Handle, scaleform2.Handle, 255, 255, 255, 255);
23
- }
24
- else {
25
- await scaleform1.load();
26
- await scaleform2.load();
27
- }
28
- resolve();
29
- });
30
- }
31
- handle;
32
- name;
33
- loaded = false;
34
- constructor(name) {
35
- this.name = name;
36
- this.handle = RequestScaleformMovie(this.name);
37
- }
38
- /**
39
- * Get the handle of the scaleform.
40
- */
41
- get Handle() {
42
- return this.handle;
43
- }
44
- /**
45
- * Get whether the handle is a valid handle.
46
- */
47
- get IsValid() {
48
- return this.handle !== 0;
49
- }
50
- /**
51
- * Get whether the scaleform is loaded.
52
- */
53
- get IsLoaded() {
54
- if (!this.loaded) {
55
- this.loaded = HasScaleformMovieLoaded(this.handle);
56
- }
57
- return this.loaded;
58
- }
59
- /**
60
- * Dispose the scaleform allowing the GTA engine to free memory when wanted.
61
- */
62
- dispose() {
63
- if (this.IsLoaded) {
64
- SetScaleformMovieAsNoLongerNeeded(this.handle);
65
- this.loaded = false;
66
- }
67
- }
68
- /**
69
- * Call a function on the scaleform.
70
- *
71
- * @param name Name of the function
72
- * @param args Additional arguments
73
- */
74
- callFunction(name, ...args) {
75
- BeginScaleformMovieMethod(this.handle, name);
76
- args.forEach((arg) => {
77
- switch (typeof arg) {
78
- case "number":
79
- PushScaleformMovieFunctionParameterInt(arg);
80
- break;
81
- case "string":
82
- PushScaleformMovieFunctionParameterString(arg);
83
- break;
84
- case "boolean":
85
- PushScaleformMovieFunctionParameterBool(arg);
86
- break;
87
- default:
88
- throw new Error(`Unknown argument type [${typeof arg}] passed to scaleform with handle [${this.handle}], had value of ${arg}`);
89
- }
90
- });
91
- EndScaleformMovieMethod();
92
- }
93
- /**
94
- * Calls a void method on the scaleform.
95
- *
96
- * @param name Name of the function
97
- */
98
- callVoidMethod(name) {
99
- CallScaleformMovieMethod(this.handle, name);
100
- }
101
- /**
102
- * Calls a string method on the scaleform.
103
- *
104
- * @param name Name of the function
105
- * @param param1
106
- * @param param2
107
- * @param param3
108
- * @param param4
109
- * @param param5
110
- */
111
- callStringMethod(name, param1 = "", param2 = "", param3 = "", param4 = "", param5 = "") {
112
- CallScaleformMovieMethodWithString(this.handle, name, param1, param2, param3, param4, param5);
113
- }
114
- /**
115
- * Calls a number method on the scaleform.
116
- *
117
- * @param name Name of the function
118
- * @param param1
119
- * @param param2
120
- * @param param3
121
- * @param param4
122
- * @param param5
123
- */
124
- callNumberMethod(name, param1 = -1.0, param2 = -1.0, param3 = -1.0, param4 = -1.0, param5 = -1.0) {
125
- CallScaleformMovieMethodWithNumber(this.handle, name, param1, param2, param3, param4, param5);
126
- }
127
- /**
128
- * Calls a number & string method on the scaleform.
129
- *
130
- * @param name Name of the function
131
- * @param fParam1
132
- * @param fParam2
133
- * @param fParam3
134
- * @param fParam4
135
- * @param fParam5
136
- * @param sParam1
137
- * @param sParam2
138
- * @param sParam3
139
- * @param sParam4
140
- * @param sParam5
141
- */
142
- callSharedMethod(name, fParam1 = -1.0, fParam2 = -1.0, fParam3 = -1.0, fParam4 = -1.0, fParam5 = -1.0, sParam1 = "", sParam2 = "", sParam3 = "", sParam4 = "", sParam5 = "") {
143
- CallScaleformMovieMethodWithNumberAndString(this.handle, name, fParam1, fParam2, fParam3, fParam4, fParam5, sParam1, sParam2, sParam3, sParam4, sParam5);
144
- }
145
- /**
146
- * Sets a duration the scaleform should be shown.
147
- * Useful for showing a scaleform for a known amount of time, such as messages.
148
- *
149
- * This only works for any scaleform using {@linkcode render2D};
150
- *
151
- * @param duration Duration in milliseconds
152
- */
153
- setDuration(duration) {
154
- if (duration <= 0) {
155
- return;
156
- }
157
- const start = GetGameTimer();
158
- const interval = setInterval(async () => {
159
- if (GetGameTimer() - start < duration) {
160
- await this.render2D();
161
- }
162
- else {
163
- clearInterval(interval);
164
- }
165
- }, 0);
166
- }
167
- render2D() {
168
- return new Promise(async (resolve) => {
169
- if (this.IsLoaded) {
170
- DrawScaleformMovieFullscreen(this.handle, 255, 255, 255, 255, 0);
171
- }
172
- else {
173
- await this.load();
174
- }
175
- resolve();
176
- });
177
- }
178
- render2DScreenSpace(location, size) {
179
- return new Promise(async (resolve) => {
180
- if (this.IsLoaded) {
181
- const x = location.x; /* UI.Screen.Width*/
182
- const y = location.y; /* UI.Screen.Height*/
183
- const width = size.x; /* UI.Screen.Width*/
184
- const height = size.y; /* UI.Screen.Height*/
185
- DrawScaleformMovie(this.handle, x + width / 2, y + height / 2, width, height, 255, 255, 255, 255, 0);
186
- }
187
- else {
188
- await this.load();
189
- }
190
- resolve();
191
- });
192
- }
193
- render3D(position, rotation, scale) {
194
- return new Promise(async (resolve) => {
195
- if (this.IsLoaded) {
196
- DrawScaleformMovie_3dNonAdditive(this.handle, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, 2, 2, 1, scale.x, scale.y, scale.z, 2);
197
- }
198
- else {
199
- await this.load();
200
- }
201
- resolve();
202
- });
203
- }
204
- render3DAdditive(position, rotation, scale) {
205
- return new Promise(async (resolve) => {
206
- if (this.IsLoaded) {
207
- DrawScaleformMovie_3d(this.handle, position.x, position.y, position.z, rotation.x, rotation.y, rotation.z, 2, 2, 1, scale.x, scale.y, scale.z, 2);
208
- }
209
- else {
210
- await this.load();
211
- }
212
- resolve();
213
- });
214
- }
215
- load() {
216
- return new Promise((resolve) => {
217
- if (this.IsLoaded) {
218
- resolve(true);
219
- }
220
- else {
221
- const start = GetGameTimer();
222
- const interval = setInterval(() => {
223
- if (this.IsLoaded) {
224
- clearInterval(interval);
225
- resolve(true);
226
- }
227
- else if (GetGameTimer() - start > 5000) {
228
- clearInterval(interval);
229
- console.log(`^1[fivemjs/client] Could not load scaleform ${this.name}!^7`);
230
- resolve(false);
231
- }
232
- }, 0);
233
- }
234
- });
235
- }
236
- }
package/ui/Screen.js DELETED
@@ -1,72 +0,0 @@
1
- import { Audio } from "../Audio";
2
- import { HudColor, NotificationType } from "../enums";
3
- import { Color, Size, String } from "../utils";
4
- import { Notification } from "./";
5
- export class Screen {
6
- static get Resolution() {
7
- const [width, height] = GetScreenActiveResolution();
8
- return new Size(width, height);
9
- }
10
- static get ScaledResolution() {
11
- const height = this.Height;
12
- return new Size(height * this.AspectRatio, height);
13
- }
14
- static get Width() {
15
- return this.Resolution.width;
16
- }
17
- static get ScaledWidth() {
18
- return this.Height * this.AspectRatio;
19
- }
20
- static get Height() {
21
- return this.Resolution.height;
22
- }
23
- static get AspectRatio() {
24
- return GetAspectRatio(false);
25
- }
26
- static showSubtitle(message, duration = 2500) {
27
- const strings = String.stringToArray(message);
28
- BeginTextCommandPrint("CELL_EMAIL_BCON");
29
- strings.forEach((element) => {
30
- AddTextComponentSubstringPlayerName(element);
31
- });
32
- EndTextCommandPrint(duration, true);
33
- }
34
- static displayHelpTextThisFrame(message) {
35
- const strings = String.stringToArray(message);
36
- BeginTextCommandDisplayHelp("CELL_EMAIL_BCON");
37
- strings.forEach((element) => {
38
- AddTextComponentSubstringPlayerName(element);
39
- });
40
- EndTextCommandDisplayHelp(0, false, false, -1);
41
- }
42
- static showNotification(message, blinking = false) {
43
- const strings = String.stringToArray(message);
44
- SetNotificationTextEntry("CELL_EMAIL_BCON");
45
- strings.forEach((element) => {
46
- AddTextComponentSubstringPlayerName(element);
47
- });
48
- return new Notification(DrawNotification(blinking, true));
49
- }
50
- static showAdvancedNotification(message, title, subtitle, iconSet, icon, bgColor = HudColor.NONE, flashColor = Color.Transparent, blinking = false, type = NotificationType.Default, showInBrief = true, sound = true) {
51
- const strings = String.stringToArray(message);
52
- SetNotificationTextEntry("CELL_EMAIL_BCON");
53
- strings.forEach((element) => {
54
- AddTextComponentSubstringPlayerName(element);
55
- });
56
- if (bgColor !== HudColor.NONE) {
57
- SetNotificationBackgroundColor(Number(bgColor));
58
- }
59
- if (flashColor !== Color.Transparent && blinking) {
60
- SetNotificationFlashColor(flashColor.r, flashColor.g, flashColor.b, flashColor.a);
61
- }
62
- if (sound) {
63
- Audio.playSoundFrontEnd("DELETE", "HUD_DEATHMATCH_SOUNDSET");
64
- }
65
- SetNotificationMessage(iconSet, icon, true, Number(type), title, subtitle);
66
- return new Notification(DrawNotification(blinking, showInBrief));
67
- }
68
- static worldToScreen(position, scaleWidth = false) {
69
- const coords = GetScreenCoordFromWorldCoord(position.x, position.y, position.z);
70
- return new Size(coords[1] * (scaleWidth ? this.ScaledWidth : this.Width), coords[2] * this.Height);
71
- }
72
- }
package/ui/Sprite.js DELETED
@@ -1,60 +0,0 @@
1
- import { Color, Point, Size } from "../utils";
2
- import { Screen } from "./";
3
- export class Sprite {
4
- textureName;
5
- pos;
6
- size;
7
- heading;
8
- color;
9
- visible;
10
- _textureDict;
11
- constructor(textureDict, textureName, pos, size, heading = 0, color = Color.White) {
12
- this._textureDict = textureDict;
13
- this.textureName = textureName;
14
- this.pos = pos || new Point();
15
- this.size = size || new Size();
16
- this.heading = heading || 0;
17
- this.color = color || Color.White;
18
- this.visible = true;
19
- }
20
- loadTextureDictionary() {
21
- RequestStreamedTextureDict(this._textureDict, true);
22
- const interval = setInterval(() => {
23
- if (this.IsTextureDictionaryLoaded) {
24
- clearInterval(interval);
25
- }
26
- }, 0);
27
- }
28
- set TextureDict(v) {
29
- this._textureDict = v;
30
- if (!this.IsTextureDictionaryLoaded) {
31
- this.loadTextureDictionary();
32
- }
33
- }
34
- get TextureDict() {
35
- return this._textureDict;
36
- }
37
- get IsTextureDictionaryLoaded() {
38
- return HasStreamedTextureDictLoaded(this._textureDict);
39
- }
40
- draw(arg1, textureName, pos, size, heading, color, loadTexture = true, resolution) {
41
- const textureDictionary = arg1 && typeof arg1 === "string" ? arg1 : this.TextureDict;
42
- textureName = textureName || this.textureName;
43
- pos = pos || this.pos;
44
- size = size || this.size;
45
- heading = heading || this.heading;
46
- color = color || this.color;
47
- if (loadTexture) {
48
- if (!HasStreamedTextureDictLoaded(textureDictionary)) {
49
- RequestStreamedTextureDict(textureDictionary, false);
50
- }
51
- }
52
- resolution = arg1 instanceof Size ? arg1 : resolution;
53
- resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
54
- const w = size.width / resolution.width;
55
- const h = size.height / resolution.height;
56
- const x = pos.X / resolution.width + w * 0.5;
57
- const y = pos.Y / resolution.height + h * 0.5;
58
- DrawSprite(textureDictionary, textureName, x, y, w, h, heading, color.r, color.g, color.b, color.a);
59
- }
60
- }
package/ui/Text.js DELETED
@@ -1,115 +0,0 @@
1
- import { Alignment, Font } from "../enums";
2
- import { Color, Point, Size } from "../utils";
3
- import { Screen } from "./";
4
- export class Text {
5
- static draw(caption, pos, scale = 1, color = Color.White, font = Font.ChaletLondon, alignment = Alignment.Left, dropShadow = false, outline = false, wordWrap, resolution) {
6
- resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
7
- const x = pos.X / resolution.width;
8
- const y = pos.Y / resolution.height;
9
- SetTextFont(Number(font));
10
- SetTextScale(1.0, scale);
11
- SetTextColour(color.r, color.g, color.b, color.a);
12
- if (dropShadow) {
13
- SetTextDropshadow(2, 0, 0, 0, 0);
14
- }
15
- if (outline) {
16
- SetTextOutline();
17
- }
18
- switch (alignment) {
19
- case Alignment.Centered:
20
- SetTextCentre(true);
21
- break;
22
- case Alignment.Right:
23
- SetTextRightJustify(true);
24
- if (!wordWrap) {
25
- SetTextWrap(0.0, x);
26
- }
27
- break;
28
- }
29
- if (wordWrap) {
30
- SetTextWrap(x, (pos.X + wordWrap.width) / resolution.width);
31
- }
32
- SetTextEntry("STRING");
33
- Text.addLongString(caption);
34
- DrawText(x, y);
35
- }
36
- static addLongString(str) {
37
- const strLen = 99;
38
- for (let i = 0; i < str.length; i += strLen) {
39
- // TODO: Fix deprecation warning
40
- const substr = str.substr(i, Math.min(strLen, str.length - i));
41
- AddTextComponentSubstringPlayerName(substr);
42
- }
43
- }
44
- caption;
45
- pos;
46
- scale;
47
- color;
48
- font;
49
- alignment;
50
- dropShadow;
51
- outline;
52
- wordWrap;
53
- /**
54
- *
55
- * @param caption Text to display
56
- * @param pos Position of text relative to alignment. In pixels.
57
- * @param scale Size of text. Default 1.0
58
- * @param color Color of text. Default black.
59
- * @param font Font of text. Default Chalet London.
60
- * @param alignment Alignment of text. Default Left.
61
- * @param dropShadow
62
- * @param outline
63
- * @param wordWrap
64
- */
65
- constructor(caption, pos, scale = 1, color = Color.White, font = Font.ChaletLondon, alignment = Alignment.Left, dropShadow = false, outline = false, wordWrap = new Size(500, 300)) {
66
- this.caption = caption;
67
- this.pos = pos;
68
- this.scale = scale;
69
- this.color = color;
70
- this.font = font;
71
- this.alignment = alignment;
72
- this.dropShadow = dropShadow;
73
- this.outline = outline;
74
- this.wordWrap = wordWrap;
75
- }
76
- draw(arg1, arg2, scale, color, font, alignment, dropShadow, outline, wordWrap, resolution) {
77
- resolution = arg2 instanceof Size ? arg2 : resolution;
78
- if (scale === undefined) {
79
- if (arg1 && arg1 instanceof Size) {
80
- arg2 = new Point(this.pos.X + arg1.width, this.pos.Y + arg1.height);
81
- }
82
- else {
83
- arg2 = this.pos;
84
- }
85
- arg1 = this.caption;
86
- scale = this.scale;
87
- color = this.color;
88
- font = this.font;
89
- alignment = this.alignment;
90
- dropShadow = this.dropShadow;
91
- outline = this.outline;
92
- wordWrap = this.wordWrap;
93
- }
94
- else {
95
- arg1 = arg1 || this.caption;
96
- if (!arg2) {
97
- arg2 = this.pos;
98
- }
99
- else {
100
- arg2 = arg2;
101
- }
102
- scale = scale !== undefined && scale !== null ? scale : this.scale;
103
- color = color || this.color;
104
- font = font !== undefined && font !== null ? font : this.font;
105
- alignment =
106
- alignment !== undefined && alignment !== null
107
- ? alignment
108
- : this.alignment;
109
- dropShadow = typeof dropShadow === "boolean" ? dropShadow : dropShadow;
110
- outline = typeof outline === "boolean" ? outline : outline;
111
- wordWrap = wordWrap || this.wordWrap;
112
- }
113
- Text.draw(arg1, arg2, scale, color, font, alignment, dropShadow, outline, wordWrap, resolution);
114
- }
115
- }