Clean up msg_area_list module (standardize/etc.), update and add docs
This commit is contained in:
parent
c3bd036509
commit
c625d25e2a
|
@ -1907,7 +1907,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
messageAreaChangeConfPreArt: {
|
changeMessageConfPreArt: {
|
||||||
module: show_art
|
module: show_art
|
||||||
config: {
|
config: {
|
||||||
method: messageConf
|
method: messageConf
|
||||||
|
|
|
@ -2,13 +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');
|
|
||||||
const Errors = require('./enig_error.js').Errors;
|
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
@ -20,71 +16,43 @@ exports.moduleInfo = {
|
||||||
author : 'NuSkooler',
|
author : 'NuSkooler',
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
// :TODO: Obv/2 others can show # of messages in area
|
||||||
:TODO:
|
|
||||||
|
|
||||||
Obv/2 has the following:
|
|
||||||
CHANGE .ANS - Message base changing ansi
|
|
||||||
|SN Current base name
|
|
||||||
|SS Current base sponsor
|
|
||||||
|NM Number of messages in current base
|
|
||||||
|UP Number of posts current user made (total)
|
|
||||||
|LR Last read message by current user
|
|
||||||
|DT Current date
|
|
||||||
|TI Current time
|
|
||||||
*/
|
|
||||||
|
|
||||||
const MciViewIds = {
|
const MciViewIds = {
|
||||||
AreaList : 1,
|
areaList : 1,
|
||||||
SelAreaInfo1 : 2,
|
areaDesc : 2, // area desc updated @ index update
|
||||||
SelAreaInfo2 : 3,
|
customRangeStart : 10, // updated @ index update
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getModule = class MessageAreaListModule extends MenuModule {
|
exports.getModule = class MessageAreaListModule extends MenuModule {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
|
|
||||||
this.messageAreas = messageArea.getSortedAvailMessageAreasByConfTag(
|
this.initList();
|
||||||
this.client.user.properties.message_conf_tag,
|
|
||||||
{ client : this.client }
|
|
||||||
);
|
|
||||||
|
|
||||||
const self = this;
|
|
||||||
this.menuMethods = {
|
this.menuMethods = {
|
||||||
changeArea : function(formData, extraArgs, cb) {
|
changeArea : (formData, extraArgs, cb) => {
|
||||||
if(1 === formData.submitId) {
|
if(1 === formData.submitId) {
|
||||||
let area = self.messageAreas[formData.value.area];
|
const area = this.messageAreas[formData.value.area];
|
||||||
const areaTag = area.areaTag;
|
|
||||||
area = area.area; // what we want is actually embedded
|
|
||||||
|
|
||||||
messageArea.changeMessageArea(self.client, areaTag, err => {
|
messageArea.changeMessageArea(this.client, area.areaTag, err => {
|
||||||
if(err) {
|
if(err) {
|
||||||
self.client.term.pipeWrite(`\n|00Cannot change area: ${err.message}\n`);
|
this.client.term.pipeWrite(`\n|00Cannot change area: ${err.message}\n`);
|
||||||
|
return this.prevMenuOnTimeout(1000, cb);
|
||||||
self.prevMenuOnTimeout(1000, cb);
|
|
||||||
} else {
|
|
||||||
if(_.isString(area.art)) {
|
|
||||||
const dispOptions = {
|
|
||||||
client : self.client,
|
|
||||||
name : area.art,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.client.term.rawWrite(resetScreen());
|
|
||||||
|
|
||||||
displayThemeArt(dispOptions, () => {
|
|
||||||
// pause by default, unless explicitly told not to
|
|
||||||
if(_.has(area, 'options.pause') && false === area.options.pause) {
|
|
||||||
return self.prevMenuOnTimeout(1000, cb);
|
|
||||||
} else {
|
|
||||||
self.pausePrompt( () => {
|
|
||||||
return self.prevMenu(cb);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
return self.prevMenu(cb);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(area.hasArt) {
|
||||||
|
const menuOpts = {
|
||||||
|
extraArgs : {
|
||||||
|
areaTag : area.areaTag,
|
||||||
|
},
|
||||||
|
menuFlags : [ 'popParent', 'noHistory' ]
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.gotoMenu(this.menuConfig.config.changeAreaPreArtMenu || 'changeMessageAreaPreArt', menuOpts, cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.prevMenu(cb);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return cb(null);
|
return cb(null);
|
||||||
|
@ -93,71 +61,66 @@ exports.getModule = class MessageAreaListModule extends MenuModule {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// :TODO: these concepts have been replaced with the {someKey} style formatting - update me!
|
|
||||||
updateGeneralAreaInfoViews(areaIndex) {
|
|
||||||
/*
|
|
||||||
const areaInfo = self.messageAreas[areaIndex];
|
|
||||||
|
|
||||||
[ MciViewIds.SelAreaInfo1, MciViewIds.SelAreaInfo2 ].forEach(mciId => {
|
|
||||||
const v = self.viewControllers.areaList.getView(mciId);
|
|
||||||
if(v) {
|
|
||||||
v.setFormatObject(areaInfo.area);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
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) => {
|
||||||
const loadOpts = {
|
return this.prepViewController('areaList', 0, mciData.menu, next);
|
||||||
callingMenu : self,
|
|
||||||
mciMap : mciData.menu,
|
|
||||||
formId : 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
vc.loadFromMenuConfig(loadOpts, function startingViewReady(err) {
|
|
||||||
callback(err);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
function populateAreaListView(callback) {
|
(next) => {
|
||||||
const areaListView = vc.getView(MciViewIds.AreaList);
|
const areaListView = this.viewControllers.areaList.getView(MciViewIds.areaList);
|
||||||
if(!areaListView) {
|
if(!areaListView) {
|
||||||
return callback(Errors.MissingMci('A MenuView compatible MCI code is required'));
|
return cb(Errors.MissingMci(`Missing area list MCI ${MciViewIds.areaList}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
let i = 1;
|
areaListView.on('index update', idx => {
|
||||||
areaListView.setItems(self.messageAreas.map(a => {
|
this.selectionIndexUpdate(idx);
|
||||||
return {
|
|
||||||
index : i++,
|
|
||||||
areaTag : a.area.areaTag,
|
|
||||||
text : a.area.name, // standard
|
|
||||||
name : a.area.name,
|
|
||||||
desc : a.area.desc,
|
|
||||||
};
|
|
||||||
}));
|
|
||||||
|
|
||||||
areaListView.on('index update', areaIndex => {
|
|
||||||
self.updateGeneralAreaInfoViews(areaIndex);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
areaListView.setItems(this.messageAreas);
|
||||||
areaListView.redraw();
|
areaListView.redraw();
|
||||||
return callback(null);
|
this.selectionIndexUpdate(0);
|
||||||
|
return next(null);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
function complete(err) {
|
err => {
|
||||||
|
if(err) {
|
||||||
|
this.client.log.error( { error : err.message }, 'Failed loading message area list');
|
||||||
|
}
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectionIndexUpdate(idx) {
|
||||||
|
const area = this.messageAreas[idx];
|
||||||
|
if(!area) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.setViewText('areaList', MciViewIds.areaDesc, area.desc);
|
||||||
|
this.updateCustomViewTextsWithFilter('areaList', MciViewIds.customRangeStart, area);
|
||||||
|
}
|
||||||
|
|
||||||
|
initList() {
|
||||||
|
let index = 1;
|
||||||
|
this.messageAreas = messageArea.getSortedAvailMessageAreasByConfTag(
|
||||||
|
this.client.user.properties.message_conf_tag,
|
||||||
|
{ client : this.client }
|
||||||
|
).map(area => {
|
||||||
|
return {
|
||||||
|
index : index++,
|
||||||
|
areaTag : area.area.areaTag,
|
||||||
|
name : area.area.name,
|
||||||
|
text : area.area.name, // standard
|
||||||
|
desc : area.area.desc,
|
||||||
|
hasArt : _.isString(area.area.art),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ exports.getModule = class MessageConfListModule extends MenuModule {
|
||||||
menuFlags : [ 'popParent', 'noHistory' ]
|
menuFlags : [ 'popParent', 'noHistory' ]
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.gotoMenu(this.menuConfig.config.changeConfPreArtMenu || 'messageAreaChangeConfPreArt', menuOpts, cb);
|
return this.gotoMenu(this.menuConfig.config.changeConfPreArtMenu || 'changeMessageConfPreArt', menuOpts, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prevMenu(cb);
|
return this.prevMenu(cb);
|
||||||
|
@ -73,7 +73,7 @@ exports.getModule = class MessageConfListModule extends MenuModule {
|
||||||
(next) => {
|
(next) => {
|
||||||
const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
|
const confListView = this.viewControllers.confList.getView(MciViewIds.confList);
|
||||||
if(!confListView) {
|
if(!confListView) {
|
||||||
return cb(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.onlineList}`));
|
return cb(Errors.MissingMci(`Missing conf list MCI ${MciViewIds.confList}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
confListView.on('index update', idx => {
|
confListView.on('index update', idx => {
|
||||||
|
@ -82,6 +82,7 @@ exports.getModule = class MessageConfListModule extends MenuModule {
|
||||||
|
|
||||||
confListView.setItems(this.messageConfs);
|
confListView.setItems(this.messageConfs);
|
||||||
confListView.redraw();
|
confListView.redraw();
|
||||||
|
this.selectionIndexUpdate(0);
|
||||||
return next(null);
|
return next(null);
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -6,6 +6,9 @@ const MenuModule = require('./menu_module.js').MenuModule;
|
||||||
const Errors = require('../core/enig_error.js').Errors;
|
const Errors = require('../core/enig_error.js').Errors;
|
||||||
const ANSI = require('./ansi_term.js');
|
const ANSI = require('./ansi_term.js');
|
||||||
const Config = require('./config.js').get;
|
const Config = require('./config.js').get;
|
||||||
|
const {
|
||||||
|
getMessageAreaByTag
|
||||||
|
} = require('./message_area.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
@ -104,7 +107,17 @@ exports.getModule = class ShowArtModule extends MenuModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
showByMessageArea(cb) {
|
showByMessageArea(cb) {
|
||||||
return cb(null); // NYI
|
this.getArtKeyValue( (err, key) => {
|
||||||
|
if(err) {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
const area = getMessageAreaByTag(key);
|
||||||
|
if(!area) {
|
||||||
|
return cb(Errors.DoesNotExist(`No area by areaTag ${key} found`));
|
||||||
|
}
|
||||||
|
return cb(null); // :TODO: REM OVE ME
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
displaySingleArtByConfigPath(configPath, cb) {
|
displaySingleArtByConfigPath(configPath, cb) {
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
- [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 %})
|
- [Message Conference List]({{ site.baseurl }}{% link modding/msg-conf-list.md %})
|
||||||
|
- [Message Area List]({{ site.baseurl }}{% link modding/msg-area-list.md %})
|
||||||
|
|
||||||
- [Oputil]({{ site.baseurl }}{% link oputil/index.md %})
|
- [Oputil]({{ site.baseurl }}{% link oputil/index.md %})
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
layout: page
|
||||||
|
title: Message Area List
|
||||||
|
---
|
||||||
|
## The Message Area List Module
|
||||||
|
The built in `msg_area_list` module provides a menu to display and change between message areas in the users current conference.
|
||||||
|
|
||||||
|
### Theming
|
||||||
|
The following `itemFormat` object is provided to MCI 1 (ie: `%VM1`):
|
||||||
|
* `index`: 1-based index into list.
|
||||||
|
* `areaTag`: Area tag.
|
||||||
|
* `name` or `text`: Display name.
|
||||||
|
* `desc`: Description.
|
||||||
|
|
||||||
|
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 area description.
|
||||||
|
* MCI 10+ (ie `%TL10`...) are custom ranges updated with the same information available above in `itemFormat`.
|
Loading…
Reference in New Issue