diff --git a/core/art.js b/core/art.js index 23cd19c2..399ff16e 100644 --- a/core/art.js +++ b/core/art.js @@ -368,26 +368,22 @@ function defaultEofFromExtension(ext) { // cb(err, mci) // :TODO: display({ art : art, client : client, ...}, cb) -function display(art, options, cb) { - if(!art || 0 === art.length) { - cb(new Error('Missing or empty art')); - return; - } +function display(options, cb) { + assert( + 'undefined' !== typeof options && + 'undefined' !== typeof options.client && + 'undefined' !== typeof options.art, + 'Missing required options'); - if('undefined' === typeof options) { - cb(new Error('Missing options')); - return; - } - - if('undefined' === typeof options.client) { - cb(new Error('Missing client in options')); + if(0 === options.art.length) { + cb(new Error('Empty art')); return; } var cancelKeys = miscUtil.valueWithDefault(options.cancelKeys, []); var pauseKeys = miscUtil.valueWithDefault(options.pauseKeys, []); var pauseAtTermHeight = miscUtil.valueWithDefault(options.pauseAtTermHeight, false); - var mciReplaceChar = miscUtil.valueWithDefault(options.mciReplaceChar, ''); + var mciReplaceChar = miscUtil.valueWithDefault(options.mciReplaceChar, ' '); // :TODO: support pause/cancel & pause @ termHeight var canceled = false; @@ -464,5 +460,5 @@ function display(art, options, cb) { } }); - parser.parse(art); + parser.parse(options.art); } \ No newline at end of file diff --git a/core/theme.js b/core/theme.js index 2878f68a..ffe6b627 100644 --- a/core/theme.js +++ b/core/theme.js @@ -12,6 +12,7 @@ exports.getThemeInfo = getThemeInfo; exports.getThemeArt = getThemeArt; exports.getRandomTheme = getRandomTheme; exports.initAvailableThemes = initAvailableThemes; +exports.displayThemeArt = displayThemeArt; function getThemeInfo(themeID, cb) { var path = paths.join(Config.paths.themes, themeID, 'theme_info.json'); @@ -108,4 +109,16 @@ function getThemeArt(name, themeID, options, cb) { cb(null, theArt.data); } }); +} + +function displayThemeArt(name, client, cb) { + getThemeArt(name, client.user.properties.art_theme_id, function onArt(err, theArt) { + if(err) { + cb(err); + } else { + art.display( { art : theArt, client : client }, function onDisplayed(err, mci) { + cb(err, mci); + }); + } + }); } \ No newline at end of file diff --git a/core/ticker_text_view.js b/core/ticker_text_view.js index f141bf7b..bbd1710c 100644 --- a/core/ticker_text_view.js +++ b/core/ticker_text_view.js @@ -10,14 +10,14 @@ var assert = require('assert'); exports.TickerTextView = TickerTextView; -TickerTextView = function(client, options) { +function TickerTextView(client, options) { View.call(this, client, options); var self = this; this.text = this.options.text || ''; this.tickerStyle = this.options.tickerStyle || 'rightToLeft'; - asssert(this.tickerStyle in TickerTextView.TickerStyles); + assert(this.tickerStyle in TickerTextView.TickerStyles); // :TODO: Ticker |text| should have ANSI stripped before calculating any lengths/etc. // strUtil.ansiTextLength(s) diff --git a/mods/art/MATRIX1.ANS b/mods/art/MATRIX1.ANS index b09c5ad7..8deafd58 100644 Binary files a/mods/art/MATRIX1.ANS and b/mods/art/MATRIX1.ANS differ diff --git a/mods/matrix.js b/mods/matrix.js index 36073b22..837d9a66 100644 --- a/mods/matrix.js +++ b/mods/matrix.js @@ -10,7 +10,9 @@ var modules = require('../core/modules.js'); //var view = require('../core/view.js'); var textView = require('../core/text_view.js'); var editTextView = require('../core/edit_text_view.js'); -var viewController = require('../core/view_controller.js'); +var ViewController = require('../core/view_controller.js').ViewController; + +var async = require('async'); exports.moduleInfo = { name : 'Matrix', @@ -20,6 +22,43 @@ exports.moduleInfo = { exports.entryPoint = entryPoint; +function entryPoint(client) { + + theme.displayThemeArt('MATRIX', client, function onMatrix(err, mciMap) { + if(mciMap.ET1 && mciMap.ET2 && mciMap.BN1 && mciMap.BN2 && mciMap.BN3) { + // + // Form via EditTextViews and ButtonViews + // * ET1 - userName + // * ET2 - password + // * BN1 - Login + // * BN2 - New + // * BN3 - Bye! + // + } else if(mciMap.VM1) { + // + // Menu via VerticalMenuView + // + // * VM1 - menu with the following items: + // 0 - Login + // 1 - New + // 2 - Bye! + // + var vc = new ViewController(client); + + vc.on('submit', function onSubmit(form) { + + }); + + vc.loadFromMCIMap(mciMap); + vc.setViewOrder(); + // :TODO: Localize + vc.getView(1).setItems(['Login', 'New User', 'Goodbye!']); + vc.switchFocus(1); + } + }); +} + +/* function entryPoint(client) { var term = client.term; @@ -27,8 +66,6 @@ function entryPoint(client) { // :TODO: types, random, and others? could come from conf.mods.matrix or such - //art.getArt('SO-CC1.ANS'/* 'MATRIX'*/, { types: ['.ans'], random: true}, function onArt(err, theArt) { - //client.user.properties.art_theme_id = ''; theme.getThemeArt('MCI_ET1.ANS', client.user.properties.art_theme_id, function onArt(err, theArt) { //art.getArt('MATRIX_1.ANS', {}, function onArt(err, theArt) { @@ -63,4 +100,5 @@ function entryPoint(client) { }); } }); -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/mods/test_module1.js b/mods/test_module1.js index c8e3c981..20d2e55a 100644 --- a/mods/test_module1.js +++ b/mods/test_module1.js @@ -28,7 +28,7 @@ function entryPoint(client) { }); }, function displayArt(theArt, callback) { - art.display(theArt, { client : client, mciReplaceChar : ' ' }, function onDisplayed(err, mci) { + art.display( { art : theArt, client : client }, function onDisplayed(err, mci) { callback(err, mci); }); },