snake-cli-ts
Version:
Nodejs cli snake game
40 lines (39 loc) • 1.32 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var _1 = __importDefault(require("."));
var MenuOption = (function () {
function MenuOption(settings, menu) {
this.menu = menu;
this.name = settings.name || '';
this.disabled = settings.disabled || false;
this.value = settings.value;
if (settings.submenu) {
this.submenu = new _1.default({
title: this.menu.title,
options: settings.submenu,
parent: this.menu,
});
}
this._callback = settings.callback;
this.onInit = settings.onInit;
}
MenuOption.prototype.callback = function () {
var _a;
(_a = this._callback) === null || _a === void 0 ? void 0 : _a.call(this);
if (this.submenu) {
this.menu.destroy();
this.submenu.init();
}
};
MenuOption.prototype.back = function () {
if (this.menu.parent) {
this.menu.destroy();
this.menu.parent.init();
}
};
return MenuOption;
}());
exports.default = MenuOption;