diff --git a/art/themes/luciano_blocktronics/theme.hjson b/art/themes/luciano_blocktronics/theme.hjson index 6555f417..2733e4c8 100644 --- a/art/themes/luciano_blocktronics/theme.hjson +++ b/art/themes/luciano_blocktronics/theme.hjson @@ -235,14 +235,12 @@ } messageAreaChangeCurrentConference: { - config: { - listFormat: "|00|15{index} |07- |03{name}" - focusListFormat: "|00|19|15{index} - {name}" - } mci: { VM1: { width: 26 height: 19 + itemFormat: "|00|15{index} |07- |03{name}" + focusItemFormat: "|00|19|15{index} - {name}" } } } diff --git a/config/menu.hjson b/config/menu.hjson index 8a14526b..1eb71f7b 100644 --- a/config/menu.hjson +++ b/config/menu.hjson @@ -1907,6 +1907,19 @@ } } + messageAreaChangeConfPreArt: { + module: show_art + config: { + method: messageConf + key: confTag + } + options: { + pause: true + cls: true + menuFlags: [ "popParent", "noHistory" ] + } + } + messageAreaChangeCurrentArea: { // :TODO: rename this art to ACHANGE art: CHANGE diff --git a/core/msg_area_list.js b/core/msg_area_list.js index 1b9870bd..a6ee7cc1 100644 --- a/core/msg_area_list.js +++ b/core/msg_area_list.js @@ -93,12 +93,6 @@ exports.getModule = class MessageAreaListModule extends MenuModule { }; } - prevMenuOnTimeout(timeout, cb) { - setTimeout( () => { - return this.prevMenu(cb); - }, timeout); - } - // :TODO: these concepts have been replaced with the {someKey} style formatting - update me! updateGeneralAreaInfoViews(areaIndex) { /* diff --git a/core/msg_conf_list.js b/core/msg_conf_list.js index c20d06ca..c0340fe4 100644 --- a/core/msg_conf_list.js +++ b/core/msg_conf_list.js @@ -2,12 +2,9 @@ 'use strict'; // ENiGMA½ -const MenuModule = require('./menu_module.js').MenuModule; -const ViewController = require('./view_controller.js').ViewController; -const messageArea = require('./message_area.js'); -const displayThemeArt = require('./theme.js').displayThemeArt; -const resetScreen = require('./ansi_term.js').resetScreen; -const stringFormat = require('./string_format.js'); +const { MenuModule } = require('./menu_module.js'); +const messageArea = require('./message_area.js'); +const { Errors } = require('./enig_error.js'); // deps const async = require('async'); @@ -20,57 +17,40 @@ exports.moduleInfo = { }; const MciViewIds = { - ConfList : 1, - - // :TODO: - // # areas in conf .... see Obv/2, iNiQ, ... - // + confList : 1, + confDesc : 2, // description updated @ index update + customRangeStart : 10, // updated @ index update }; exports.getModule = class MessageConfListModule extends MenuModule { constructor(options) { super(options); - this.messageConfs = messageArea.getSortedAvailMessageConferences(this.client); - const self = this; + this.initList(); this.menuMethods = { - changeConference : function(formData, extraArgs, cb) { + changeConference : (formData, extraArgs, cb) => { if(1 === formData.submitId) { - let conf = self.messageConfs[formData.value.conf]; - const confTag = conf.confTag; - conf = conf.conf; // what we want is embedded + const conf = this.messageConfs[formData.value.conf]; - messageArea.changeMessageConference(self.client, confTag, err => { + messageArea.changeMessageConference(this.client, conf.confTag, err => { if(err) { - self.client.term.pipeWrite(`\n|00Cannot change conference: ${err.message}\n`); - - setTimeout( () => { - return self.prevMenu(cb); - }, 1000); - } else { - if(_.isString(conf.art)) { - const dispOptions = { - client : self.client, - name : conf.art, - }; - - self.client.term.rawWrite(resetScreen()); - - displayThemeArt(dispOptions, () => { - // pause by default, unless explicitly told not to - if(_.has(conf, 'options.pause') && false === conf.options.pause) { - return self.prevMenuOnTimeout(1000, cb); - } else { - self.pausePrompt( () => { - return self.prevMenu(cb); - }); - } - }); - } else { - return self.prevMenu(cb); - } + this.client.term.pipeWrite(`\n|00Cannot change conference: ${err.message}\n`); + return this.prevMenuOnTimeout(1000, cb); } + + if(conf.hasArt) { + const menuOpts = { + extraArgs : { + confTag : conf.confTag, + }, + menuFlags : [ 'popParent', 'noHistory' ] + }; + + return this.gotoMenu(this.menuConfig.config.changeConfPreArtMenu || 'messageAreaChangeConfPreArt', menuOpts, cb); + } + + return this.prevMenu(cb); }); } else { return cb(null); @@ -79,70 +59,63 @@ exports.getModule = class MessageConfListModule extends MenuModule { }; } - prevMenuOnTimeout(timeout, cb) { - setTimeout( () => { - return this.prevMenu(cb); - }, timeout); - } - mciReady(mciData, cb) { super.mciReady(mciData, err => { if(err) { return cb(err); } - const self = this; - const vc = self.viewControllers.areaList = new ViewController( { client : self.client } ); - async.series( [ - function loadFromConfig(callback) { - let loadOpts = { - callingMenu : self, - mciMap : mciData.menu, - formId : 0, - }; - - vc.loadFromMenuConfig(loadOpts, callback); + (next) => { + return this.prepViewController('confList', 0, mciData.menu, next); }, - function populateConfListView(callback) { - const listFormat = self.menuConfig.config.listFormat || '{index} ) - {name}'; - const focusListFormat = self.menuConfig.config.focusListFormat || listFormat; + (next) => { + const confListView = this.viewControllers.confList.getView(MciViewIds.confList); + if(!confListView) { + return cb(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.onlineList}`)); + } - const confListView = vc.getView(MciViewIds.ConfList); - let i = 1; - confListView.setItems(_.map(self.messageConfs, v => { - return stringFormat(listFormat, { - index : i++, - confTag : v.conf.confTag, - name : v.conf.name, - desc : v.conf.desc, - }); - })); - - i = 1; - confListView.setFocusItems(_.map(self.messageConfs, v => { - return stringFormat(focusListFormat, { - index : i++, - confTag : v.conf.confTag, - name : v.conf.name, - desc : v.conf.desc, - }); - })); + confListView.on('index update', idx => { + this.selectionIndexUpdate(idx); + }); + confListView.setItems(this.messageConfs); confListView.redraw(); - - callback(null); - }, - function populateTextViews(callback) { - // :TODO: populate other avail MCI, e.g. current conf name - callback(null); + return next(null); } ], - function complete(err) { - cb(err); + err => { + if(err) { + this.client.log.error( { error : err.message }, 'Failed loading message conference list'); + } } ); }); } + + selectionIndexUpdate(idx) { + const conf = this.messageConfs[idx]; + if(!conf) { + return; + } + this.setViewText('confList', MciViewIds.confDesc, conf.desc); + this.updateCustomViewTextsWithFilter('confList', MciViewIds.customRangeStart, conf); + } + + initList() + { + let index = 1; + this.messageConfs = messageArea.getSortedAvailMessageConferences(this.client).map(conf => { + return { + index : index++, + confTag : conf.confTag, + name : conf.conf.name, + text : conf.conf.name, + desc : conf.conf.desc, + areaCount : Object.keys(conf.conf.areas || {}).length, + hasArt : _.isString(conf.conf.art), + }; + }); + } }; diff --git a/docs/_includes/nav.md b/docs/_includes/nav.md index d7ada9e2..5af16603 100644 --- a/docs/_includes/nav.md +++ b/docs/_includes/nav.md @@ -67,6 +67,7 @@ - [Last Callers]({{ site.baseurl }}{% link modding/last-callers.md %}) - [Who's Online]({{ site.baseurl }}{% link modding/whos-online.md %}) - [User List]({{ site.baseurl }}{% link modding/user-list.md %}) + - [Message Conference List]({{ site.baseurl }}{% link modding/msg-conf-list.md %}) - [Oputil]({{ site.baseurl }}{% link oputil/index.md %}) diff --git a/docs/modding/msg-conf-list.md b/docs/modding/msg-conf-list.md new file mode 100644 index 00000000..c00c890d --- /dev/null +++ b/docs/modding/msg-conf-list.md @@ -0,0 +1,18 @@ +--- +layout: page +title: Message Conference List +--- +## The Message Conference List Module +The built in `msg_conf_list` module provides a menu to display and change between message conferences. + +### Theming +The following `itemFormat` object is provided to MCI 1 (ie: `%VM1`): +* `index`: 1-based index into list. +* `confTag`: Conference tag. +* `name` or `text`: Display name. +* `desc`: Description. +* `areaCount`: Number of areas in this conference. + +The following additional MCIs are updated as the user changes selections in the main list: +* MCI 2 (ie: `%TL2` or `%M%2`) is updated with the conference description. +* MCI 10+ (ie `%TL10`...) are custom ranges updated with the same information available above in `itemFormat`. diff --git a/docs/modding/whos-online.md b/docs/modding/whos-online.md index 87a2b1ef..22fde0ff 100644 --- a/docs/modding/whos-online.md +++ b/docs/modding/whos-online.md @@ -2,7 +2,7 @@ layout: page title: Who's Online --- -## The Who's OnlineModule +## The Who's Online Module The built in `whos_online` module provides a basic who's online mod. ### Theming