UNPKG

node-insim

Version:

An InSim library for NodeJS with TypeScript support

104 lines (103 loc) 4.28 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ScreenshotError = exports.IS_SSH = void 0; var decorators_1 = require("../decorators"); var base_1 = require("./base"); var enums_1 = require("./enums"); /** * ScreenSHot * * You can instruct LFS to save a screenshot in data\shots using the IS_SSH packet. * * It will be saved as bmp / jpg / png as set in Misc Options. * Name can be a filename (excluding extension) or zero - LFS will create a name. * * LFS will reply with another IS_SSH when the request is completed. */ var IS_SSH = /** @class */ (function (_super) { __extends(IS_SSH, _super); function IS_SSH(data) { var _this = _super.call(this) || this; _this.Size = 40; _this.Type = enums_1.PacketType.ISP_SSH; /** Request: non-zero / reply: same value returned */ _this.ReqI = 0; /** 0 = OK / other values see {@link ScreenshotError} */ _this.Error = 0; _this.Sp0 = 0; _this.Sp1 = 0; _this.Sp2 = 0; _this.Sp3 = 0; /** Name of screenshot file - last byte must be zero */ _this.Name = ''; _this.initialize(data); return _this; } IS_SSH.prototype.pack = function () { if (this.ReqI === 0) { throw new RangeError('IS_SSH - ReqI must be greater than 0'); } return _super.prototype.pack.call(this); }; __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Size", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Type", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "ReqI", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Error", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Sp0", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Sp1", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Sp2", void 0); __decorate([ (0, decorators_1.byte)() ], IS_SSH.prototype, "Sp3", void 0); __decorate([ (0, decorators_1.stringNull)(32) ], IS_SSH.prototype, "Name", void 0); return IS_SSH; }(base_1.SendablePacket)); exports.IS_SSH = IS_SSH; var ScreenshotError; (function (ScreenshotError) { /** OK: completed instruction */ ScreenshotError[ScreenshotError["SSH_OK"] = 0] = "SSH_OK"; /** Can't save a screenshot - dedicated host */ ScreenshotError[ScreenshotError["SSH_DEDICATED"] = 1] = "SSH_DEDICATED"; /** {@link IS_SSH} corrupted (e.g. Name does not end with zero) */ ScreenshotError[ScreenshotError["SSH_CORRUPTED"] = 2] = "SSH_CORRUPTED"; /** Could not save the screenshot */ ScreenshotError[ScreenshotError["SSH_NO_SAVE"] = 3] = "SSH_NO_SAVE"; })(ScreenshotError || (exports.ScreenshotError = ScreenshotError = {}));