UNPKG

@mixer/interactive-node

Version:

A NodeJS and Browser compatible client for mixer.com's interactive 2 Protocol

115 lines 4.07 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Control_1 = require("./Control"); /** * Buttons can be pushed by participants with their mouse or activated with their keyboards. */ var Button = /** @class */ (function (_super) { __extends(Button, _super); function Button() { return _super !== null && _super.apply(this, arguments) || this; } /** * Sets a new text value for this button. */ Button.prototype.setText = function (text) { return this.updateAttribute('text', text); }; /** * Sets a progress value for this button. * A decimalized percentage (0.0 - 1.0) */ Button.prototype.setTextSize = function (textSize) { return this.updateAttribute('textSize', textSize); }; /** * Sets a new border color for this button. */ Button.prototype.setBorderColor = function (borderColor) { return this.updateAttribute('borderColor', borderColor); }; /** * Sets a new background color for this button. */ Button.prototype.setBackgroundColor = function (backgroundColor) { return this.updateAttribute('backgroundColor', backgroundColor); }; /** * Sets a new focus color for this button. */ Button.prototype.setFocusColor = function (focusColor) { return this.updateAttribute('focusColor', focusColor); }; /** * Sets a new accent color for this button. */ Button.prototype.setAccentColor = function (accentColor) { return this.updateAttribute('accentColor', accentColor); }; /** * Sets a new text color for this button. */ Button.prototype.setTextColor = function (textColor) { return this.updateAttribute('textColor', textColor); }; /** * Sets a new tooltip value for this button. */ Button.prototype.setTooltip = function (tooltip) { return this.updateAttribute('tooltip', tooltip); }; /** * Sets a progress value for this button. * A decimalized percentage (0.0 - 1.0) */ Button.prototype.setProgress = function (progress) { return this.updateAttribute('progress', progress); }; /** * Sets the cooldown for this button. Specified in Milliseconds. * The Client will convert this to a Unix timestamp for you. */ Button.prototype.setCooldown = function (duration) { var target = this.client.state.synchronizeLocalTime().getTime() + duration; return this.updateAttribute('cooldown', target); }; /** * Sets the spark cost for this button. * An Integer greater than 0 */ Button.prototype.setCost = function (cost) { return this.updateAttribute('cost', cost); }; /** * Sends an input event from a participant to the server for consumption. */ Button.prototype.giveInput = function (input) { return this.sendInput(input); }; /** * Update this button on the server. */ Button.prototype.update = function (controlUpdate) { // Clone to prevent mutations // XXX: Typescript 2.4 is strict, let the compiler be clever. var changedData = Object.assign({}, controlUpdate); if (changedData.cooldown) { changedData.cooldown = this.client.state.synchronizeLocalTime().getTime() + changedData.cooldown; } return _super.prototype.update.call(this, changedData); }; return Button; }(Control_1.Control)); exports.Button = Button; //# sourceMappingURL=Button.js.map