Update message conf list with standardized + custom formats

This commit is contained in:
Bryan Ashby 2018-07-22 15:59:00 -06:00
parent 9f85a01a89
commit c3bd036509
7 changed files with 101 additions and 104 deletions

View File

@ -235,14 +235,12 @@
} }
messageAreaChangeCurrentConference: { messageAreaChangeCurrentConference: {
config: {
listFormat: "|00|15{index} |07- |03{name}"
focusListFormat: "|00|19|15{index} - {name}"
}
mci: { mci: {
VM1: { VM1: {
width: 26 width: 26
height: 19 height: 19
itemFormat: "|00|15{index} |07- |03{name}"
focusItemFormat: "|00|19|15{index} - {name}"
} }
} }
} }

View File

@ -1907,6 +1907,19 @@
} }
} }
messageAreaChangeConfPreArt: {
module: show_art
config: {
method: messageConf
key: confTag
}
options: {
pause: true
cls: true
menuFlags: [ "popParent", "noHistory" ]
}
}
messageAreaChangeCurrentArea: { messageAreaChangeCurrentArea: {
// :TODO: rename this art to ACHANGE // :TODO: rename this art to ACHANGE
art: CHANGE art: CHANGE

View File

@ -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! // :TODO: these concepts have been replaced with the {someKey} style formatting - update me!
updateGeneralAreaInfoViews(areaIndex) { updateGeneralAreaInfoViews(areaIndex) {
/* /*

View File

@ -2,12 +2,9 @@
'use strict'; 'use strict';
// ENiGMA½ // ENiGMA½
const MenuModule = require('./menu_module.js').MenuModule; const { MenuModule } = require('./menu_module.js');
const ViewController = require('./view_controller.js').ViewController;
const messageArea = require('./message_area.js'); const messageArea = require('./message_area.js');
const displayThemeArt = require('./theme.js').displayThemeArt; const { Errors } = require('./enig_error.js');
const resetScreen = require('./ansi_term.js').resetScreen;
const stringFormat = require('./string_format.js');
// deps // deps
const async = require('async'); const async = require('async');
@ -20,57 +17,40 @@ exports.moduleInfo = {
}; };
const MciViewIds = { const MciViewIds = {
ConfList : 1, confList : 1,
confDesc : 2, // description updated @ index update
// :TODO: customRangeStart : 10, // updated @ index update
// # areas in conf .... see Obv/2, iNiQ, ...
//
}; };
exports.getModule = class MessageConfListModule extends MenuModule { exports.getModule = class MessageConfListModule extends MenuModule {
constructor(options) { constructor(options) {
super(options); super(options);
this.messageConfs = messageArea.getSortedAvailMessageConferences(this.client); this.initList();
const self = this;
this.menuMethods = { this.menuMethods = {
changeConference : function(formData, extraArgs, cb) { changeConference : (formData, extraArgs, cb) => {
if(1 === formData.submitId) { if(1 === formData.submitId) {
let conf = self.messageConfs[formData.value.conf]; const conf = this.messageConfs[formData.value.conf];
const confTag = conf.confTag;
conf = conf.conf; // what we want is embedded
messageArea.changeMessageConference(self.client, confTag, err => { messageArea.changeMessageConference(this.client, conf.confTag, err => {
if(err) { if(err) {
self.client.term.pipeWrite(`\n|00Cannot change conference: ${err.message}\n`); this.client.term.pipeWrite(`\n|00Cannot change conference: ${err.message}\n`);
return this.prevMenuOnTimeout(1000, cb);
}
setTimeout( () => { if(conf.hasArt) {
return self.prevMenu(cb); const menuOpts = {
}, 1000); extraArgs : {
} else { confTag : conf.confTag,
if(_.isString(conf.art)) { },
const dispOptions = { menuFlags : [ 'popParent', 'noHistory' ]
client : self.client,
name : conf.art,
}; };
self.client.term.rawWrite(resetScreen()); return this.gotoMenu(this.menuConfig.config.changeConfPreArtMenu || 'messageAreaChangeConfPreArt', menuOpts, cb);
}
displayThemeArt(dispOptions, () => { return this.prevMenu(cb);
// 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);
}
}
}); });
} else { } else {
return cb(null); 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) { mciReady(mciData, cb) {
super.mciReady(mciData, err => { super.mciReady(mciData, err => {
if(err) { if(err) {
return cb(err); return cb(err);
} }
const self = this;
const vc = self.viewControllers.areaList = new ViewController( { client : self.client } );
async.series( async.series(
[ [
function loadFromConfig(callback) { (next) => {
let loadOpts = { return this.prepViewController('confList', 0, mciData.menu, next);
callingMenu : self,
mciMap : mciData.menu,
formId : 0,
};
vc.loadFromMenuConfig(loadOpts, callback);
}, },
function populateConfListView(callback) { (next) => {
const listFormat = self.menuConfig.config.listFormat || '{index} ) - {name}'; const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
const focusListFormat = self.menuConfig.config.focusListFormat || listFormat; if(!confListView) {
return cb(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.onlineList}`));
}
const confListView = vc.getView(MciViewIds.ConfList); confListView.on('index update', idx => {
let i = 1; this.selectionIndexUpdate(idx);
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.setItems(this.messageConfs);
confListView.redraw(); confListView.redraw();
return next(null);
callback(null);
},
function populateTextViews(callback) {
// :TODO: populate other avail MCI, e.g. current conf name
callback(null);
} }
], ],
function complete(err) { err => {
cb(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),
};
});
}
}; };

View File

@ -67,6 +67,7 @@
- [Last Callers]({{ site.baseurl }}{% link modding/last-callers.md %}) - [Last Callers]({{ site.baseurl }}{% link modding/last-callers.md %})
- [Who's Online]({{ site.baseurl }}{% link modding/whos-online.md %}) - [Who's Online]({{ site.baseurl }}{% link modding/whos-online.md %})
- [User List]({{ site.baseurl }}{% link modding/user-list.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 %}) - [Oputil]({{ site.baseurl }}{% link oputil/index.md %})

View File

@ -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`.