@nativewrappers/fivem 0.0.28 → 0.0.30

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.
package/README.md CHANGED
@@ -1,37 +1,36 @@
1
1
  <h1 align="center">Monorepo for a FiveM server/client wrapper</h1>
2
2
 
3
3
  <p align="center">
4
- <i>:fire: A Javascript/Typescript wrapper for the FiveM server natives :video_game:</i>
5
- <br>
6
- <br>
7
- <a href="https://github.com/nativewrappers/fivem/blob/master/LICENSE">
8
- <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat" alt="License: MIT">
9
- </a>
10
- <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
11
- <img src="https://img.shields.io/npm/v/@nativewrappers/fivem?style=flat" alt="npm version">
12
- </a>
13
- <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
14
- <img src="https://img.shields.io/npm/dm/@nativewrappers/fivem?style=flat">
15
- </a>
16
- <a href="https://github.com/nativewrappers/fivem/actions/workflows/config.yml">
17
- <img src="https://github.com/nativewrappers/fivem/actions/workflows/config.yml/badge.svg" alt="Workflow Status">
18
- </a>
19
- <a href="https://github.com/nativewrappers/fivem/commits/master">
20
- <img src="https://img.shields.io/github/last-commit/nativewrappers/fivem.svg?style=flat" alt="Last commit">
21
- </a>
4
+ <i>🔥 A Javascript/Typescript package for FiveM resource development 🎮</i>
5
+ <br>
6
+ <small>This project is in no way affiliated with FiveM or the Cfx.re Collective.</small>
7
+ </br></br>
8
+ <a href="https://github.com/nativewrappers/fivem/blob/master/LICENSE">
9
+ <img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat" alt="License: MIT">
10
+ </a>
11
+ <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
12
+ <img src="https://img.shields.io/npm/v/@nativewrappers/fivem?style=flat" alt="npm version">
13
+ </a>
14
+ <a href="https://www.npmjs.com/package/@nativewrappers/fivem">
15
+ <img src="https://img.shields.io/npm/dm/@nativewrappers/fivem?style=flat">
16
+ </a>
17
+ <a href="https://github.com/nativewrappers/fivem/actions/workflows/config.yml">
18
+ <img src="https://github.com/nativewrappers/fivem/actions/workflows/config.yml/badge.svg" alt="Workflow Status">
19
+ </a>
20
+ <a href="https://github.com/nativewrappers/fivem/commits/master">
21
+ <img src="https://img.shields.io/github/last-commit/nativewrappers/fivem.svg?style=flat" alt="Last commit">
22
+ </a>
22
23
  </p>
23
24
 
25
+ <h3 align="center">This project is currently interating rapidly, there will be breaking changes.</h3>
26
+
24
27
  <p align="center">
25
- <a href="https://fivemjs-server.avarian.dev/">Documentation</a>
26
- -
28
+ <h2 align="center"><a href="https://github.com/nativewrappers/fivem/tree/main/docs">Documentation</a></h2>
27
29
  <!-- <a href="https://forum.fivem.net/t/fivem-js-v1-3-2-javascript-typescript-wrapper-now-with-menu-class-nativeui/268640">Forum</a> -->
28
30
  </p>
29
31
 
30
- ## This project is currently interating rapidly, there will be breaking changes.
31
-
32
- This project is in no way affiliated with FiveM or the Cfx.re Collective.
33
-
34
32
  ## Features
33
+
35
34
  - No runtime dependencies
36
35
  - Abstracts common used FiveM practices
37
36
  - Entity management through class objects (i.e. `Vehicle` and `Ped` entities)
@@ -14,7 +14,7 @@ export class ParticleEffect {
14
14
  constructor(asset, effectName) {
15
15
  this.offset = new Vector3(0, 0, 0);
16
16
  this.rotation = new Vector3(0, 0, 0);
17
- this.color = Color.empty;
17
+ this.color = Color.Transparent;
18
18
  this.scale = 1.0;
19
19
  this.range = 1.0;
20
20
  this.invertAxis = { flags: InvertAxisFlags.None };
@@ -1,4 +1,3 @@
1
- /// <reference types="@citizenfx/client" />
2
1
  export { StateBagChangeHandler } from './StateBagChangeHandler';
3
2
  declare const _default: {
4
3
  Entity: typeof Entity;
@@ -1,4 +1,3 @@
1
- /// <reference types="@citizenfx/client" />
2
1
  import { Blip } from '../Blip';
3
2
  import { ForceType } from '../enums';
4
3
  import { MaterialHash, WeaponHash } from '../hashes';
@@ -133,12 +132,36 @@ export declare class BaseEntity {
133
132
  isNearEntity(entity: BaseEntity, bounds: Vector3): boolean;
134
133
  isTouching(entity: BaseEntity): boolean;
135
134
  isTouchingModel(model: Model): boolean;
135
+ /**
136
+ * @deprecated use [[getAbsolutePositionOffset]]
137
+ */
138
+ getOffsetPosition(offset: Vector3): Vector3;
136
139
  /**
137
140
  * @param offset: the amount to offset from the entity
138
141
  * @returns the offset position from the entity in world coords
139
142
  */
140
- getOffsetPosition(offset: Vector3): Vector3;
143
+ getAbsolutePositionOffset(offset: Vector3): Vector3;
144
+ /**
145
+ * @deprecated use [[getRelativePositionOffset]] instead
146
+ */
141
147
  getPositionOffset(worldCoords: Vector3): Vector3;
148
+ /**
149
+ * @example
150
+ * ```typescript
151
+ * const ply = Game.PlayerPed;
152
+ * const plyPos = ply.Position;
153
+ * const bag = await World.createProp(new Model('ba_prop_battle_bag_01b'), plyPos, true, true, true);
154
+ * bag.attachToBone(
155
+ * ply.Bones.getBone(64113),
156
+ * new Vector3(0.12, -0.25, 0.0),
157
+ * new Vector3(105.0, 50.0, 190.0)
158
+ * )
159
+ * const offset = bag.getRelativePositionOffset(plyPos);
160
+ * ```
161
+ * @param worldCoords: the offset given the world coords
162
+ * @returns the offset position from the entity in relative coords
163
+ */
164
+ getRelativePositionOffset(worldCoords: Vector3): Vector3;
142
165
  attachTo(entity: BaseEntity, position: Vector3, rotation: Vector3, collisions?: boolean, unk9?: boolean, useSoftPinning?: boolean, rotationOrder?: number): void;
143
166
  attachToBone(entityBone: EntityBone, position: Vector3, rotation: Vector3, collisions?: boolean, unk9?: boolean, useSoftPinning?: boolean, rotationOrder?: number): void;
144
167
  detach(): void;
@@ -362,14 +362,43 @@ export class BaseEntity {
362
362
  isTouchingModel(model) {
363
363
  return IsEntityTouchingModel(this.handle, model.Hash);
364
364
  }
365
+ /**
366
+ * @deprecated use [[getAbsolutePositionOffset]]
367
+ */
368
+ getOffsetPosition(offset) {
369
+ return Vector3.fromArray(GetOffsetFromEntityInWorldCoords(this.handle, offset.x, offset.y, offset.z));
370
+ }
365
371
  /**
366
372
  * @param offset: the amount to offset from the entity
367
373
  * @returns the offset position from the entity in world coords
368
374
  */
369
- getOffsetPosition(offset) {
375
+ getAbsolutePositionOffset(offset) {
370
376
  return Vector3.fromArray(GetOffsetFromEntityInWorldCoords(this.handle, offset.x, offset.y, offset.z));
371
377
  }
378
+ /**
379
+ * @deprecated use [[getRelativePositionOffset]] instead
380
+ */
372
381
  getPositionOffset(worldCoords) {
382
+ return this.getRelativePositionOffset(worldCoords);
383
+ }
384
+ // TODO: Better example
385
+ /**
386
+ * @example
387
+ * ```typescript
388
+ * const ply = Game.PlayerPed;
389
+ * const plyPos = ply.Position;
390
+ * const bag = await World.createProp(new Model('ba_prop_battle_bag_01b'), plyPos, true, true, true);
391
+ * bag.attachToBone(
392
+ * ply.Bones.getBone(64113),
393
+ * new Vector3(0.12, -0.25, 0.0),
394
+ * new Vector3(105.0, 50.0, 190.0)
395
+ * )
396
+ * const offset = bag.getRelativePositionOffset(plyPos);
397
+ * ```
398
+ * @param worldCoords: the offset given the world coords
399
+ * @returns the offset position from the entity in relative coords
400
+ */
401
+ getRelativePositionOffset(worldCoords) {
373
402
  return Vector3.fromArray(GetOffsetFromEntityGivenWorldCoords(this.handle, worldCoords.x, worldCoords.y, worldCoords.z));
374
403
  }
375
404
  attachTo(entity, position, rotation, collisions = false, unk9 = true, useSoftPinning = true, rotationOrder = 1) {
@@ -1,4 +1,3 @@
1
- /// <reference types="@citizenfx/client" />
2
1
  import { Model, Color } from '..';
3
2
  import { StateBagChangeHandler } from '../cfx';
4
3
  import { BaseEntity, Ped } from './';
@@ -47,7 +47,7 @@ export class Screen {
47
47
  });
48
48
  return new Notification(DrawNotification(blinking, true));
49
49
  }
50
- static showAdvancedNotification(message, title, subtitle, iconSet, icon, bgColor = HudColor.NONE, flashColor = Color.empty, blinking = false, type = NotificationType.Default, showInBrief = true, sound = true) {
50
+ static showAdvancedNotification(message, title, subtitle, iconSet, icon, bgColor = HudColor.NONE, flashColor = Color.Transparent, blinking = false, type = NotificationType.Default, showInBrief = true, sound = true) {
51
51
  const strings = String.stringToArray(message);
52
52
  SetNotificationTextEntry('CELL_EMAIL_BCON');
53
53
  strings.forEach(element => {
@@ -56,7 +56,7 @@ export class Screen {
56
56
  if (bgColor !== HudColor.NONE) {
57
57
  SetNotificationBackgroundColor(Number(bgColor));
58
58
  }
59
- if (flashColor !== Color.empty && blinking) {
59
+ if (flashColor !== Color.Transparent && blinking) {
60
60
  SetNotificationFlashColor(flashColor.r, flashColor.g, flashColor.b, flashColor.a);
61
61
  }
62
62
  if (sound) {
@@ -1,13 +1,13 @@
1
1
  import { Color, Point, Size } from '../utils';
2
2
  import { Screen } from './';
3
3
  export class Sprite {
4
- constructor(textureDict, textureName, pos, size, heading = 0, color = Color.white) {
4
+ constructor(textureDict, textureName, pos, size, heading = 0, color = Color.White) {
5
5
  this._textureDict = textureDict;
6
6
  this.textureName = textureName;
7
7
  this.pos = pos || new Point();
8
8
  this.size = size || new Size();
9
9
  this.heading = heading || 0;
10
- this.color = color || Color.white;
10
+ this.color = color || Color.White;
11
11
  this.visible = true;
12
12
  }
13
13
  loadTextureDictionary() {
package/client/ui/Text.js CHANGED
@@ -2,7 +2,7 @@ import { Alignment, Font } from '../enums';
2
2
  import { Color, Point, Size } from '../utils';
3
3
  import { Screen } from './';
4
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) {
5
+ static draw(caption, pos, scale = 1, color = Color.White, font = Font.ChaletLondon, alignment = Alignment.Left, dropShadow = false, outline = false, wordWrap, resolution) {
6
6
  resolution = resolution || new Size(Screen.ScaledWidth, Screen.Height);
7
7
  const x = pos.X / resolution.width;
8
8
  const y = pos.Y / resolution.height;
@@ -36,6 +36,7 @@ export class Text {
36
36
  static addLongString(str) {
37
37
  const strLen = 99;
38
38
  for (let i = 0; i < str.length; i += strLen) {
39
+ // TODO: Fix deprecation warning
39
40
  const substr = str.substr(i, Math.min(strLen, str.length - i));
40
41
  AddTextComponentSubstringPlayerName(substr);
41
42
  }
@@ -52,7 +53,7 @@ export class Text {
52
53
  * @param outline
53
54
  * @param wordWrap
54
55
  */
55
- constructor(caption, pos, scale = 1, color = Color.white, font = Font.ChaletLondon, alignment = Alignment.Left, dropShadow = false, outline = false, wordWrap = new Size(500, 300)) {
56
+ constructor(caption, pos, scale = 1, color = Color.White, font = Font.ChaletLondon, alignment = Alignment.Left, dropShadow = false, outline = false, wordWrap = new Size(500, 300)) {
56
57
  this.caption = caption;
57
58
  this.pos = pos;
58
59
  this.scale = scale;
@@ -87,7 +87,7 @@ export class Timerbar {
87
87
  const safeZone = GetSafeZoneSize();
88
88
  const safeZoneX = (1.0 - safeZone) * 0.5;
89
89
  const safeZoneY = (1.0 - safeZone) * 0.5;
90
- this.sprite = new Sprite('timerbars', 'all_black_bg', new Point(Screen.ScaledWidth * 0.918 - safeZoneX, Screen.Height * 0.984 - safeZoneY), new Size(Screen.ScaledWidth * 0.165, Screen.Height * 0.035), 0, new Color(160, 255, 255, 255));
90
+ this.sprite = new Sprite('timerbars', 'all_black_bg', new Point(Screen.ScaledWidth * 0.918 - safeZoneX, Screen.Height * 0.984 - safeZoneY), new Size(Screen.ScaledWidth * 0.165, Screen.Height * 0.035), 0, new Color(255, 255, 255, 160));
91
91
  if (!this.sprite.IsTextureDictionaryLoaded) {
92
92
  this.sprite.loadTextureDictionary();
93
93
  }
@@ -38,26 +38,26 @@ export class Menu {
38
38
  this._settings = new MenuSettings();
39
39
  this._offset = offset;
40
40
  // Create everything
41
- this._mainMenu = new Container(new Point(), new Size(700, 500), Color.transparent);
41
+ this._mainMenu = new Container(new Point(), new Size(700, 500), Color.Transparent);
42
42
  this._logo = new Sprite(spriteLibrary || '', spriteName || '', new Point(this._offset.X, this._offset.Y), new Size(431, 107));
43
43
  this._mainMenu.addItem([
44
- (this._title = new Text(title || '', new Point(431 / 2 + this._offset.X, 20 + this._offset.Y), 1.15, Color.white, 1, Alignment.Centered)),
45
- (this._subtitleResRectangle = new Rectangle(new Point(this._offset.X, 107 + this._offset.Y), new Size(431, 37), Color.black)),
46
- (this._subtitle = new Text(subtitle || '', new Point(8 + this._offset.X, 110 + this._offset.Y), 0.35, Color.white, 0, Alignment.Left)),
44
+ (this._title = new Text(title || '', new Point(431 / 2 + this._offset.X, 20 + this._offset.Y), 1.15, Color.White, 1, Alignment.Centered)),
45
+ (this._subtitleResRectangle = new Rectangle(new Point(this._offset.X, 107 + this._offset.Y), new Size(431, 37), Color.Black)),
46
+ (this._subtitle = new Text(subtitle || '', new Point(8 + this._offset.X, 110 + this._offset.Y), 0.35, Color.White, 0, Alignment.Left)),
47
47
  ]);
48
48
  if (this._subtitle.caption.startsWith('~')) {
49
49
  this._counterPretext = this._subtitle.caption.substr(0, 3);
50
50
  }
51
- this._counterText = new Text('', new Point(425 + this._offset.X, 110 + this._offset.Y), 0.35, Color.white, 0, Alignment.Right);
51
+ this._counterText = new Text('', new Point(425 + this._offset.X, 110 + this._offset.Y), 0.35, Color.White, 0, Alignment.Right);
52
52
  this._upAndDownSprite = new Sprite('commonmenu', 'shop_arrows_upanddown', new Point(), new Size(50, 50));
53
53
  const extraRectanglePos = new Point(this._offset.X);
54
54
  const extraRectangleSize = new Size(431, 18);
55
- const extraRectangleColor = new Color(200, 0, 0, 0);
55
+ const extraRectangleColor = new Color(0, 0, 0, 200);
56
56
  this._extraRectangleUp = new Rectangle(extraRectanglePos, extraRectangleSize, extraRectangleColor);
57
57
  this._extraRectangleDown = new Rectangle({ ...extraRectanglePos }, { ...extraRectangleSize }, { ...extraRectangleColor });
58
- this._descriptionBar = new Rectangle(new Point(this._offset.X), new Size(431, 4), Color.black);
58
+ this._descriptionBar = new Rectangle(new Point(this._offset.X), new Size(431, 4), Color.Black);
59
59
  this._descriptionRectangle = new Sprite('commonmenu', 'gradient_bgd', new Point(this._offset.X), new Size(431, 30));
60
- this._descriptionText = new Text('Description', new Point(this._offset.X + 8), 0.35, Color.white, Font.ChaletLondon, Alignment.Left);
60
+ this._descriptionText = new Text('Description', new Point(this._offset.X + 8), 0.35, Color.White, Font.ChaletLondon, Alignment.Left);
61
61
  this._background = new Sprite('commonmenu', 'gradient_bgd', new Point(this._offset.X, 144 + this._offset.Y), new Size(290, 25));
62
62
  setTick(() => {
63
63
  this._render();
@@ -560,7 +560,7 @@ export class Menu {
560
560
  }
561
561
  }
562
562
  else {
563
- this._extraRectangleUp.color = new Color(200, 0, 0, 0);
563
+ this._extraRectangleUp.color = new Color(0, 0, 0, 200);
564
564
  }
565
565
  if (this._mousePressed) {
566
566
  return;
@@ -581,7 +581,7 @@ export class Menu {
581
581
  }
582
582
  }
583
583
  else {
584
- this._extraRectangleDown.color = new Color(200, 0, 0, 0);
584
+ this._extraRectangleDown.color = new Color(0, 0, 0, 200);
585
585
  }
586
586
  }
587
587
  _processControl() {
@@ -52,6 +52,6 @@ export class UIMenuCheckboxItem extends UIMenuItem {
52
52
  return `shop_box_${name}${this.selected ? 'b' : ''}`;
53
53
  }
54
54
  _getSpriteColor() {
55
- return this.enabled ? Color.white : Color.fromRgb(109, 109, 109);
55
+ return this.enabled ? Color.White : Color.fromRgb(109, 109, 109);
56
56
  }
57
57
  }
@@ -1004,10 +1004,10 @@ export class UIMenuItem {
1004
1004
  case BadgeStyle.BrandRune:
1005
1005
  return selected
1006
1006
  ? enabled
1007
- ? Color.black
1007
+ ? Color.Black
1008
1008
  : Color.fromRgb(50, 50, 50)
1009
1009
  : enabled
1010
- ? Color.white
1010
+ ? Color.White
1011
1011
  : Color.fromRgb(109, 109, 109);
1012
1012
  case BadgeStyle.GlobeBlue:
1013
1013
  return enabled ? Color.fromRgb(10, 103, 166) : Color.fromRgb(11, 62, 117);
@@ -1020,7 +1020,7 @@ export class UIMenuItem {
1020
1020
  case BadgeStyle.GlobeYellow:
1021
1021
  return enabled ? Color.fromRgb(232, 207, 14) : Color.fromRgb(131, 133, 12);
1022
1022
  default:
1023
- return enabled ? Color.white : Color.fromRgb(109, 109, 109);
1023
+ return enabled ? Color.White : Color.fromRgb(109, 109, 109);
1024
1024
  }
1025
1025
  }
1026
1026
  setVerticalPosition(y) {
@@ -1050,7 +1050,7 @@ export class UIMenuItem {
1050
1050
  : this.hovered
1051
1051
  ? UIMenuItem.defaultHoveredForeColor
1052
1052
  : this._foreColor
1053
- : new Color(255, 163, 159, 148);
1053
+ : new Color(163, 159, 148);
1054
1054
  if (this.supportsLeftBadge && this._leftBadge !== BadgeStyle.None) {
1055
1055
  const widthOffset = UIMenuItem.getBadgeSpriteWidthOffset(this.badgeLeft);
1056
1056
  this.badgeLeft.pos.X = this.offset.X + widthOffset;
@@ -1082,9 +1082,9 @@ export class UIMenuItem {
1082
1082
  this.text.draw(undefined, Menu.screenResolution);
1083
1083
  }
1084
1084
  }
1085
- UIMenuItem.defaultBackColor = Color.empty;
1086
- UIMenuItem.defaultHighlightedBackColor = Color.white;
1087
- UIMenuItem.defaultHoveredBackColor = new Color(20, 255, 255, 255);
1088
- UIMenuItem.defaultForeColor = Color.whiteSmoke;
1085
+ UIMenuItem.defaultBackColor = Color.Transparent;
1086
+ UIMenuItem.defaultHighlightedBackColor = Color.White;
1087
+ UIMenuItem.defaultHoveredBackColor = new Color(255, 255, 255, 25);
1088
+ UIMenuItem.defaultForeColor = Color.WhiteSmoke;
1089
1089
  UIMenuItem.defaultHoveredForeColor = UIMenuItem.defaultForeColor;
1090
- UIMenuItem.defaultHighlightedForeColor = Color.black;
1090
+ UIMenuItem.defaultHighlightedForeColor = Color.Black;
@@ -15,7 +15,7 @@ export class UIMenuListItem extends UIMenuItem {
15
15
  this._textWidth = 0;
16
16
  this._leftArrow = new Sprite('commonmenu', 'arrowleft', new Point(), new Size(30, 30));
17
17
  this._rightArrow = new Sprite('commonmenu', 'arrowright', new Point(), new Size(30, 30));
18
- this._itemText = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Right);
18
+ this._itemText = new Text('', new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Right);
19
19
  this.ArrowOnlyOnSelected = arrowOnlyOnSelected;
20
20
  this.Items = items;
21
21
  this.Index = startIndex;
@@ -89,7 +89,7 @@ export class UIMenuListItem extends UIMenuItem {
89
89
  ? this.selected
90
90
  ? this.HighlightedForeColor
91
91
  : this.ForeColor
92
- : new Color(255, 163, 159, 148);
92
+ : new Color(163, 159, 148);
93
93
  if (this._arrowOnlyOnSelected && !this.selected) {
94
94
  this._itemText.pos.X += this._rightArrow.size.width / 2;
95
95
  }
@@ -15,9 +15,9 @@ export class UIMenuSliderItem extends UIMenuItem {
15
15
  this._arrowOnlyOnSelected = false;
16
16
  this._leftSliderBadge = BadgeStyle.None;
17
17
  this._rightSliderBadge = BadgeStyle.None;
18
- this._background = new Rectangle(new Point(), new Size(150, 9), new Color(255, 4, 32, 57));
19
- this._slider = new Rectangle(new Point(), new Size(75, 9), new Color(255, 57, 116, 200));
20
- this._divider = new Rectangle(new Point(), new Size(2.5, 20), Color.whiteSmoke);
18
+ this._background = new Rectangle(new Point(), new Size(150, 9), new Color(4, 32, 57));
19
+ this._slider = new Rectangle(new Point(), new Size(75, 9), new Color(57, 116, 200));
20
+ this._divider = new Rectangle(new Point(), new Size(2.5, 20), Color.WhiteSmoke);
21
21
  this._leftArrow = new Sprite('commonmenutu', 'arrowleft', new Point(), new Size(15, 15));
22
22
  this._rightArrow = new Sprite('commonmenutu', 'arrowright', new Point(), new Size(15, 15));
23
23
  this._leftSliderBadgeSprite = new Sprite('', '');
@@ -58,19 +58,19 @@ export class UIMenuSliderItem extends UIMenuItem {
58
58
  return this._background.color;
59
59
  }
60
60
  set BackgroundColor(value) {
61
- this._background.color = value || new Color(255, 4, 32, 57);
61
+ this._background.color = value || new Color(4, 32, 57);
62
62
  }
63
63
  get SliderColor() {
64
64
  return this._slider.color;
65
65
  }
66
66
  set SliderColor(value) {
67
- this._slider.color = value || new Color(255, 57, 116, 200);
67
+ this._slider.color = value || new Color(57, 116, 200);
68
68
  }
69
69
  get DividerColor() {
70
70
  return this._divider.color;
71
71
  }
72
72
  set DividerColor(value) {
73
- this._divider.color = value || Color.whiteSmoke;
73
+ this._divider.color = value || Color.WhiteSmoke;
74
74
  }
75
75
  get LeftSliderBadge() {
76
76
  return this._leftSliderBadge;
@@ -153,9 +153,9 @@ export class UIMenuSliderItem extends UIMenuItem {
153
153
  this._slider.pos.X = this._background.pos.X + sliderXOffset;
154
154
  this._leftArrow.color = this.enabled
155
155
  ? this.selected
156
- ? Color.black
157
- : Color.whiteSmoke
158
- : new Color(255, 163, 159, 148);
156
+ ? Color.Black
157
+ : Color.WhiteSmoke
158
+ : new Color(163, 159, 148);
159
159
  this._rightArrow.color = this._leftArrow.color;
160
160
  this._background.draw(undefined, Menu.screenResolution);
161
161
  this._slider.draw(undefined, Menu.screenResolution);
@@ -9,7 +9,7 @@ export class UIMenuColorPanel extends AbstractUIMenuPanel {
9
9
  this._title = '';
10
10
  this._colors = [];
11
11
  this._bar = [];
12
- this._lastColor = Color.empty;
12
+ this._lastColor = Color.Transparent;
13
13
  // Pagination
14
14
  this._min = 0;
15
15
  this._max = 8;
@@ -18,8 +18,8 @@ export class UIMenuColorPanel extends AbstractUIMenuPanel {
18
18
  this.background = new Sprite('commonmenu', 'gradient_bgd', new Point(), new Size(431, 112));
19
19
  this._leftArrow = new Sprite('commonmenu', 'arrowleft', new Point(), new Size(30, 30));
20
20
  this._rightArrow = new Sprite('commonmenu', 'arrowright', new Point(), new Size(30, 30));
21
- this._selectedRectangle = new Rectangle(new Point(), new Size(44.5, 8), Color.white);
22
- this._text = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Centered);
21
+ this._selectedRectangle = new Rectangle(new Point(), new Size(44.5, 8), Color.White);
22
+ this._text = new Text('', new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Centered);
23
23
  this.Title = title;
24
24
  this.Colors = colors;
25
25
  }
@@ -160,7 +160,7 @@ export class UIMenuGridPanel extends AbstractUIMenuPanel {
160
160
  // @ts-ignore
161
161
  if (!this[name]) {
162
162
  // @ts-ignore
163
- this[name] = new Text(value, new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Centered);
163
+ this[name] = new Text(value, new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Centered);
164
164
  }
165
165
  else {
166
166
  // @ts-ignore
@@ -11,9 +11,9 @@ export class UIMenuPercentagePanel extends AbstractUIMenuPanel {
11
11
  const barSize = new Size(413, 10);
12
12
  this._activeBar = new Rectangle(new Point(), barSize, Color.fromRgb(245, 245, 245));
13
13
  this._backgroundBar = new Rectangle(new Point(), { ...barSize }, Color.fromRgb(87, 87, 87));
14
- this._title = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Centered);
15
- this._minText = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Centered);
16
- this._maxText = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Centered);
14
+ this._title = new Text('', new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Centered);
15
+ this._minText = new Text('', new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Centered);
16
+ this._maxText = new Text('', new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Centered);
17
17
  this.Title = title;
18
18
  this.MinText = minText || '0%';
19
19
  this.MaxText = maxText || '100%';
@@ -6,7 +6,7 @@ export class UIMenuStatisticsPanel extends AbstractUIMenuPanel {
6
6
  super();
7
7
  this._divider = true;
8
8
  this._items = [];
9
- this.background = new Rectangle(new Point(), new Size(431, 47), new Color(170, 0, 0, 0));
9
+ this.background = new Rectangle(new Point(), new Size(431, 47), new Color(0, 0, 0, 170));
10
10
  if (item) {
11
11
  this.addItem(item);
12
12
  }
@@ -5,11 +5,11 @@ export class UIMenuStatisticsPanelItem {
5
5
  constructor(name, percentage = 0) {
6
6
  this.id = Crypto.uuidv4();
7
7
  this.divider = [];
8
- this.text = new Text('', new Point(), 0.35, Color.white, Font.ChaletLondon, Alignment.Left);
8
+ this.text = new Text('', new Point(), 0.35, Color.White, Font.ChaletLondon, Alignment.Left);
9
9
  this.backgroundBar = new Rectangle(new Point(), new Size(200, 10), Color.fromArgb(100, 87, 87, 87));
10
- this.activeBar = new Rectangle(new Point(), new Size(0, 10), Color.white);
10
+ this.activeBar = new Rectangle(new Point(), new Size(0, 10), Color.White);
11
11
  for (let i = 1; i <= 4; i++) {
12
- this.divider.push(new Rectangle(new Point(), new Size(2, 10), Color.black));
12
+ this.divider.push(new Rectangle(new Point(), new Size(2, 10), Color.Black));
13
13
  }
14
14
  this.Name = name;
15
15
  this.Percentage = percentage;
@@ -4,7 +4,6 @@ export { PointF } from './PointF';
4
4
  export { Crypto } from './Crypto';
5
5
  export { Point } from './Point';
6
6
  export { Size } from './Size';
7
- export { Color } from './Color';
8
- export { Vector2, Vector3, Vector4, Maths, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from '../../common/utils/index';
7
+ export { Vector2, Vector3, Vector4, Maths, Color, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from '../../common/utils/index';
9
8
  export declare const Wait: (milliseconds: number) => Promise<void>;
10
9
  export * from './Animations';
@@ -4,7 +4,6 @@ export { PointF } from './PointF';
4
4
  export { Crypto } from './Crypto';
5
5
  export { Point } from './Point';
6
6
  export { Size } from './Size';
7
- export { Color } from './Color';
8
- export { Vector2, Vector3, Vector4, Maths, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from '../../common/utils/index';
7
+ export { Vector2, Vector3, Vector4, Maths, Color, Quaternion, Delay, enumValues, getStringFromUInt8Array, getUInt32FromUint8Array, } from '../../common/utils/index';
9
8
  export const Wait = (milliseconds) => new Promise(resolve => setTimeout(resolve, milliseconds));
10
9
  export * from './Animations';
package/common/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="@types/node" />
2
1
  import type { Buffer } from 'buffer';
3
2
  export type MsgpackBuffer = {
4
3
  buffer: Buffer;
@@ -1,4 +1,8 @@
1
1
  export declare class Color {
2
+ static Transparent: Color;
3
+ static Black: Color;
4
+ static White: Color;
5
+ static WhiteSmoke: Color;
2
6
  static fromArgb(a: number, r: number, g: number, b: number): Color;
3
7
  static fromRgb(r: number, g: number, b: number): Color;
4
8
  static fromArray(primitive: [number, number, number] | number[]): Color;
@@ -1,9 +1,9 @@
1
1
  export class Color {
2
2
  static fromArgb(a, r, g, b) {
3
- return new Color(a, r, g, b);
3
+ return new Color(r, g, b, a);
4
4
  }
5
5
  static fromRgb(r, g, b) {
6
- return new Color(255, r, g, b);
6
+ return new Color(r, g, b);
7
7
  }
8
8
  static fromArray(primitive) {
9
9
  return new Color(primitive[0], primitive[1], primitive[2], 255);
@@ -15,3 +15,7 @@ export class Color {
15
15
  this.a = a;
16
16
  }
17
17
  }
18
+ Color.Transparent = new Color(0, 0, 0, 0);
19
+ Color.Black = new Color(0, 0, 0);
20
+ Color.White = new Color(255, 255, 255);
21
+ Color.WhiteSmoke = new Color(245, 245, 245);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Remco Troost <d0p3t>",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.0.28",
7
+ "version": "0.0.30",
8
8
  "publishConfig": {
9
9
  "directory": "lib"
10
10
  },
@@ -33,23 +33,24 @@
33
33
  "./**/*.d.ts"
34
34
  ],
35
35
  "devDependencies": {
36
- "@citizenfx/client": "2.0.7604-1",
37
- "@citizenfx/server": "2.0.7604-1",
38
- "@types/node": "^16.18.87",
36
+ "@citizenfx/client": "^2.0.7604-1",
37
+ "@citizenfx/server": "^2.0.7604-1",
38
+ "@types/node": "^16.18.103",
39
39
  "buffer": "^6.0.3",
40
- "prettier": "^2.8.8",
40
+ "prettier": "^3.3.3",
41
41
  "prettier-linter-helpers": "^1.0.0",
42
- "typedoc": "^0.25.11",
42
+ "tsc-alias": "^1.8.10",
43
+ "typedoc": "^0.26.5",
43
44
  "typedoc-fivemjs-theme": "^0.2.7",
44
- "typescript": "^5.4.2",
45
- "tsc-alias": "^1.8.8"
45
+ "typedoc-plugin-markdown": "^4.2.1",
46
+ "typescript": "^5.5.3"
46
47
  },
47
48
  "scripts": {
48
49
  "delete": "rm -rf lib",
49
50
  "build": "pnpm run delete && tsc --build && tsc-alias && pnpm run copy-data",
50
51
  "copy-data": "cp package.json lib/package.json && cp README.md lib/README.md",
51
52
  "watch": "tsc --watch",
52
- "ci": "pnpm run prettier && pnpm run build",
53
+ "ci": "pnpm run prettier && pnpm run build && pnpm typedoc",
53
54
  "prettier": "prettier */**/*.ts --check",
54
55
  "prettier-fix": "prettier */**/*.ts --write"
55
56
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="@citizenfx/server" />
2
1
  export { StateBagChangeHandler } from './StateBagChangeHandler';
3
2
  declare const _default: {
4
3
  Entity: typeof Entity;
@@ -1,4 +1,3 @@
1
- /// <reference types="@citizenfx/server" />
2
1
  import { ClassTypes } from '../../common/utils/ClassTypes';
3
2
  import { eEntityType } from '../enum/eEntityType';
4
3
  import { PopulationType } from '../enum/PopulationType';
@@ -1,4 +1,3 @@
1
- /// <reference types="@citizenfx/server" />
2
1
  import { ClassTypes } from '../../common/utils/ClassTypes';
3
2
  import { Vector3 } from '../utils';
4
3
  import { Ped } from './Ped';
@@ -1,15 +0,0 @@
1
- export declare class Color {
2
- static empty: Color;
3
- static transparent: Color;
4
- static black: Color;
5
- static white: Color;
6
- static whiteSmoke: Color;
7
- static fromArgb(a: number, r: number, g: number, b: number): Color;
8
- static fromRgb(r: number, g: number, b: number): Color;
9
- static fromArray(primitive: [number, number, number] | number[]): Color;
10
- a: number;
11
- r: number;
12
- g: number;
13
- b: number;
14
- constructor(a: number | undefined, r: number, g: number, b: number);
15
- }
@@ -1,22 +0,0 @@
1
- export class Color {
2
- static fromArgb(a, r, g, b) {
3
- return new Color(a, r, g, b);
4
- }
5
- static fromRgb(r, g, b) {
6
- return new Color(255, r, g, b);
7
- }
8
- static fromArray(primitive) {
9
- return new Color(255, primitive[0], primitive[1], primitive[2]);
10
- }
11
- constructor(a = 255, r, g, b) {
12
- this.a = a;
13
- this.r = r;
14
- this.g = g;
15
- this.b = b;
16
- }
17
- }
18
- Color.empty = new Color(0, 0, 0, 0);
19
- Color.transparent = new Color(0, 0, 0, 0);
20
- Color.black = new Color(255, 0, 0, 0);
21
- Color.white = new Color(255, 255, 255, 255);
22
- Color.whiteSmoke = new Color(255, 245, 245, 245);