UNPKG

samp-node-lib

Version:

NodeJS library for Scripting San Andreas Multiplayer:SAMP depends on samp-node plugin

120 lines 4.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextDraw = void 0; const TextDraws_1 = require("./TextDraws"); const SampFunctions_1 = require("./SampFunctions"); class TextDraw { constructor(playerid, config, name) { this.config = {}; this._callback = []; this.playerid = playerid; this.config = config; this._name = name; this._textid = (0, SampFunctions_1.CreatePlayerTextDraw)(playerid, config.x || 0, config.y || 0, config.text || ''); this.setState(config); TextDraws_1.TextDraws.add(playerid, this); return this; } get textid() { return this._textid; } get name() { return this._name; } get callback() { return this._callback; } onClick(callBack) { this._callback.push(callBack); if (this.config.setSelectable !== 1 && this._textid !== null) { this.config.setSelectable = 1; (0, SampFunctions_1.PlayerTextDrawSetSelectable)(this.playerid, this._textid, 1); } return this; } show() { if (this._textid === null) { return this; } (0, SampFunctions_1.PlayerTextDrawShow)(this.playerid, this._textid); return this; } hide() { if (this._textid === null) { return this; } (0, SampFunctions_1.PlayerTextDrawHide)(this.playerid, this._textid); return this; } setText(value) { if (this._textid === null) { return this; } (0, SampFunctions_1.PlayerTextDrawSetString)(this.playerid, this._textid, value); return this; } destroy() { if (this._textid === null) { return this; } (0, SampFunctions_1.PlayerTextDrawDestroy)(this.playerid, this._textid); this._textid = null; } setState(config) { if (this._textid === null) { return this; } this.config = Object.assign(Object.assign({}, this.config), config); if (config.text !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetString)(this.playerid, this._textid, config.text); } if (config.letterSize !== undefined) { (0, SampFunctions_1.PlayerTextDrawLetterSize)(this.playerid, this._textid, config.letterSize.x, config.letterSize.y); } if (config.textSize !== undefined) { (0, SampFunctions_1.PlayerTextDrawTextSize)(this.playerid, this._textid, config.textSize.x, config.textSize.y); } if (config.align !== undefined) { (0, SampFunctions_1.PlayerTextDrawAlignment)(this.playerid, this._textid, config.align); } if (config.color !== undefined) { (0, SampFunctions_1.PlayerTextDrawColor)(this.playerid, this._textid, config.color); } if (config.useBox !== undefined) { (0, SampFunctions_1.PlayerTextDrawUseBox)(this.playerid, this._textid, config.useBox); } if (config.boxColor !== undefined) { (0, SampFunctions_1.PlayerTextDrawBoxColor)(this.playerid, this._textid, config.boxColor); } if (config.shadowSize !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetShadow)(this.playerid, this._textid, config.shadowSize); } if (config.outlineSize !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetOutline)(this.playerid, this._textid, config.outlineSize); } if (config.backgroundColor !== undefined) { (0, SampFunctions_1.PlayerTextDrawBackgroundColor)(this.playerid, this._textid, config.backgroundColor); } if (config.font !== undefined) { (0, SampFunctions_1.PlayerTextDrawFont)(this.playerid, this._textid, config.font); } if (config.setProportional !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetProportional)(this.playerid, this._textid, config.setProportional); } if (config.setSelectable !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetSelectable)(this.playerid, this._textid, config.setSelectable); } if (config.previewRot !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetPreviewRot)(this.playerid, this._textid, config.previewRot.fRotX, config.previewRot.fRotY, config.previewRot.fRotZ, config.previewRot.fZoom); } if (config.vehicleColor !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetPreviewVehCol)(this.playerid, this._textid, config.vehicleColor.color1, config.vehicleColor.color2); } if (config.previewModel !== undefined) { (0, SampFunctions_1.PlayerTextDrawSetPreviewModel)(this.playerid, this._textid, config.previewModel); } return this; } } exports.TextDraw = TextDraw; //# sourceMappingURL=TextDraw.js.map