UNPKG

fivem-js

Version:

Javascript/Typescript wrapper for the FiveM natives

37 lines (36 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UIMenuStatisticsPanelItem = void 0; const utils_1 = require("../../../../utils"); const __1 = require("../../../"); const enums_1 = require("../../../../enums"); class UIMenuStatisticsPanelItem { constructor(name, percentage = 0) { this.id = utils_1.uuidv4(); this.divider = []; this.text = new __1.Text('', new utils_1.Point(), 0.35, utils_1.Color.white, enums_1.Font.ChaletLondon, enums_1.Alignment.Left); this.backgroundBar = new __1.Rectangle(new utils_1.Point(), new utils_1.Size(200, 10), utils_1.Color.fromArgb(100, 87, 87, 87)); this.activeBar = new __1.Rectangle(new utils_1.Point(), new utils_1.Size(0, 10), utils_1.Color.white); for (let i = 1; i <= 4; i++) { this.divider.push(new __1.Rectangle(new utils_1.Point(), new utils_1.Size(2, 10), utils_1.Color.black)); } this.Name = name; this.Percentage = percentage; } get Name() { return this.text.caption; } set Name(value) { this.text.caption = value ? value.trim() : ''; } get Percentage() { return this.activeBar.size.width / 200; } set Percentage(value) { value = value || 0; value = Math.round(value * 100) / 100; value = value < 0 ? 0 : value > 1 ? 1 : value; this.activeBar.size.width = value * 200; } } exports.UIMenuStatisticsPanelItem = UIMenuStatisticsPanelItem;