diff --git a/core/menu_view.js b/core/menu_view.js index 0220b6e7..7708c29f 100644 --- a/core/menu_view.js +++ b/core/menu_view.js @@ -36,7 +36,7 @@ function MenuView(client, options) { this.justify = this.options.justify || 'none'; this.moveSelection = function(fromIndex, toIndex) { - assert(!self.xPositionCacheExpired); + assert(!self.positionCacheExpired); assert(fromIndex >= 0 && fromIndex <= self.items.length); assert(toIndex >= 0 && toIndex <= self.items.length); @@ -48,13 +48,14 @@ function MenuView(client, options) { self.drawItem(toIndex); }; + /* this.cachePositions = function() { // :TODO: implement me! }; this.drawItem = function(index) { // :TODO: implement me! - }; + };*/ } util.inherits(MenuView, View); diff --git a/core/ticker_text_view.js b/core/ticker_text_view.js new file mode 100644 index 00000000..f141bf7b --- /dev/null +++ b/core/ticker_text_view.js @@ -0,0 +1,94 @@ +/* jslint node: true */ +'use strict'; + +var View = require('./view.js').View; +var miscUtil = require('./misc_util.js'); +var strUtil = require('./string_util.js'); +var ansi = require('./ansi_term.js'); +var util = require('util'); +var assert = require('assert'); + +exports.TickerTextView = TickerTextView; + +TickerTextView = function(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); + + // :TODO: Ticker |text| should have ANSI stripped before calculating any lengths/etc. + // strUtil.ansiTextLength(s) + // strUtil.pad(..., ignoreAnsi) + // strUtil.stylizeString(..., ignoreAnsi) + + this.tickerState = {}; + switch(this.tickerStyle) { + case 'rightToLeft' : + this.tickerState.pos = this.position.x + this.dimens.width; + break; + } + + + self.onTickerInterval = function() { + switch(self.tickerStyle) { + case 'rightToLeft' : self.updateRightToLeftTicker(); break; + } + }; + + self.updateRightToLeftTicker = function() { + // if pos < start + // drawRemain() + // if pos + remain > end + // drawRemain(0, spaceFor) + // else + // drawString() + remainPading + }; + +} + +util.inherits(TickerTextView, View); + +TickerTextView.TickerStyles = { + leftToRight : 1, + rightToLeft : 2, + bounce : 3, + slamLeft : 4, + slamRight : 5, + slamBounce : 6, + decrypt : 7, + typewriter : 8, +}; +Object.freeze(TickerTextView.TickerStyles); + +/* +TickerTextView.TICKER_STYLES = [ + 'leftToRight', + 'rightToLeft', + 'bounce', + 'slamLeft', + 'slamRight', + 'slamBounce', + 'decrypt', + 'typewriter', +]; +*/ + +TickerTextView.prototype.controllerAttached = function() { + // :TODO: call super +}; + +TickerTextView.prototype.controllerDetached = function() { + // :TODO: call super + +}; + +TickerTextView.prototype.setText = function(text) { + this.text = strUtil.stylizeString(text, this.textStyle); + + if(!this.dimens || !this.dimens.width) { + this.dimens.width = Math.ceil(this.text.length / 2); + } +}; \ No newline at end of file diff --git a/core/view_controller.js b/core/view_controller.js index 232e8513..d4078bbb 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -101,6 +101,10 @@ ViewController.prototype.detachClientEvents = function() { this.client.removeListener('key press', this.onClientKeyPress); this.client.removeListener('special key', this.onClientSpecialKeyPress); + for(var id in this.views) { + this.views[id].removeAllListeners(); + } + this.attached = false; }; @@ -179,7 +183,7 @@ ViewController.prototype.loadFromMCIMap = function(mciMap) { if(view) { view.on('action', self.onViewAction); - self.addView(view); // :TODO: Needs detached + self.addView(view); view.redraw(); // :TODO: This can result in double redraw() if we set focus on this item after } }); diff --git a/mods/matrix.js b/mods/matrix.js index 48fdbc6a..36073b22 100644 --- a/mods/matrix.js +++ b/mods/matrix.js @@ -29,7 +29,7 @@ function entryPoint(client) { //art.getArt('SO-CC1.ANS'/* 'MATRIX'*/, { types: ['.ans'], random: true}, function onArt(err, theArt) { //client.user.properties.art_theme_id = ''; - theme.getThemeArt('MATRIX_1.ANS', client.user.properties.art_theme_id, function onArt(err, theArt) { + theme.getThemeArt('MCI_ET1.ANS', client.user.properties.art_theme_id, function onArt(err, theArt) { //art.getArt('MATRIX_1.ANS', {}, function onArt(err, theArt) { if(!err) { diff --git a/mods/test_module1.js b/mods/test_module1.js index 8525a021..c8e3c981 100644 --- a/mods/test_module1.js +++ b/mods/test_module1.js @@ -35,6 +35,7 @@ function entryPoint(client) { function artDisplayed(mci, callback) { var vc = new viewController.ViewController(client); vc.loadFromMCIMap(mci); + vc.getView(1).setItems(['Item 1', 'Item Two', 'The Third']); vc.setViewOrder(); vc.switchFocus(1); }