From 6e0a4e84afe36cb4826e2aca336e0a0dd757cfd9 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 11 Oct 2015 16:05:45 -0600 Subject: [PATCH] * Message list updated to be functional with new MCI/etc. (Still WIP, but working good) --- core/menu_view.js | 4 +- core/vertical_menu_view.js | 10 ++-- mods/menu.hjson | 56 +++++++++---------- mods/msg_list.js | 51 +++++++++++++++-- mods/themes/luciano_blocktronics/MSGEHLP.ANS | Bin 0 -> 950 bytes mods/themes/luciano_blocktronics/MSGLIST.ANS | Bin 0 -> 2316 bytes mods/themes/luciano_blocktronics/theme.hjson | 4 +- 7 files changed, 83 insertions(+), 42 deletions(-) create mode 100644 mods/themes/luciano_blocktronics/MSGEHLP.ANS create mode 100644 mods/themes/luciano_blocktronics/MSGLIST.ANS diff --git a/core/menu_view.js b/core/menu_view.js index 8d4e8308..e9fa468c 100644 --- a/core/menu_view.js +++ b/core/menu_view.js @@ -64,10 +64,12 @@ MenuView.prototype.getItem = function(index) { MenuView.prototype.focusNext = function() { // nothing @ base currently + this.emit('index update', this.focusedItemIndex); }; MenuView.prototype.focusPrevious = function() { // nothign @ base currently + this.emit('index update', this.focusedItemIndex); }; MenuView.prototype.setFocusItems = function(items) { @@ -79,7 +81,7 @@ MenuView.prototype.setFocusItems = function(items) { self.focusItems.push( { text : itemText } ); }); } -} +}; MenuView.prototype.setItemSpacing = function(itemSpacing) { itemSpacing = parseInt(itemSpacing); diff --git a/core/vertical_menu_view.js b/core/vertical_menu_view.js index 44b678bd..90fc566e 100644 --- a/core/vertical_menu_view.js +++ b/core/vertical_menu_view.js @@ -172,8 +172,6 @@ VerticalMenuView.prototype.setItems = function(items) { // :TODO: Apply draw optimizaitons when only two items need drawn vs entire view! VerticalMenuView.prototype.focusNext = function() { - VerticalMenuView.super_.prototype.focusNext.call(this); - if(this.items.length - 1 === this.focusedItemIndex) { this.focusedItemIndex = 0; @@ -191,11 +189,11 @@ VerticalMenuView.prototype.focusNext = function() { } this.redraw(); + + VerticalMenuView.super_.prototype.focusNext.call(this); }; VerticalMenuView.prototype.focusPrevious = function() { - VerticalMenuView.super_.prototype.focusPrevious.call(this); - if(0 === this.focusedItemIndex) { this.focusedItemIndex = this.items.length - 1; @@ -215,6 +213,8 @@ VerticalMenuView.prototype.focusPrevious = function() { } this.redraw(); + + VerticalMenuView.super_.prototype.focusPrevious.call(this); }; @@ -222,7 +222,7 @@ VerticalMenuView.prototype.setFocusItems = function(items) { VerticalMenuView.super_.prototype.setFocusItems.call(this, items); this.positionCacheExpired = true; -} +}; VerticalMenuView.prototype.setItemSpacing = function(itemSpacing) { VerticalMenuView.super_.prototype.setItemSpacing.call(this, itemSpacing); diff --git a/mods/menu.hjson b/mods/menu.hjson index eef2b59a..8432754b 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -528,41 +528,39 @@ } } }, - "messageAreaMessageList" : { - "module" : "msg_list", - "art" : "msg_list" - "config" : { - "listType" : "public" - }, - "form" : { - "0" : { - "VM" : { - "mci" : { - "VM1" : { - "height" : 10, - "focus" : true, - "submit" : true, - "argName" : "message" - } - }, - "submit" : { - "*": [ - { - "value" : { "message" : null }, - "action" : "@method:selectMessage" - } - ] - }, - "actionKeys" : [ + messageAreaMessageList: { + module: msg_list + art: MSGLIST + config: { + listType: public + } + form: { + 0: { + mci: { + VM1: { + height: 10 + focus: true + submit: true + argName: message + } + } + submit: { + *: [ { - "keys" : [ "escape", "q", "shift + q" ], - "action" : "@menu:messageArea" + value: { message: null } + action: @method:selectMessage } ] } + actionKeys: [ + { + keys: [ "escape", "q", "shift + q" ] + action: @menu:messageArea + } + ] } } - }, + } messageAreaViewPost: { module: msg_area_view_fse diff --git a/mods/msg_list.js b/mods/msg_list.js index fa02abe1..fc4e5f7a 100644 --- a/mods/msg_list.js +++ b/mods/msg_list.js @@ -10,6 +10,7 @@ var Message = require('../core/message.js'); var async = require('async'); var assert = require('assert'); var _ = require('lodash'); +var moment = require('moment'); exports.getModule = MessageListModule; @@ -38,9 +39,23 @@ exports.moduleInfo = { // * Multiple LV's in sync with keyboard input // * New Table LV (TV) // * + +// VM1 - message list +// TL2 - Message area desc + +// TL4 - message selected # +// TL5 - message total # // // See Obv/2, Iniq, and Mystic docs +var MciCodesIds = { + MsgList : 1, + MsgAreaDesc : 2, + + MsgSelNum : 4, + MsgTotal : 5, +}; + function MessageListModule(options) { MenuModule.call(this, options); @@ -67,6 +82,13 @@ function MessageListModule(options) { } } }; + + this.setViewText = function(id, text) { + var v = self.viewControllers.allViews.getView(id); + if(v) { + v.setText(text); + } + }; } require('util').inherits(MessageListModule, MenuModule); @@ -83,7 +105,7 @@ MessageListModule.prototype.enter = function(client) { MessageListModule.prototype.mciReady = function(mciData, cb) { var self = this; - var vc = self.viewControllers.msgList = new ViewController( { client : self.client } ); + var vc = self.viewControllers.allViews = new ViewController( { client : self.client } ); async.series( [ @@ -109,17 +131,22 @@ MessageListModule.prototype.mciReady = function(mciData, cb) { }); }, function populateList(callback) { - var msgListView = vc.getView(1); + var msgListView = vc.getView(MciCodesIds.MsgList); var listFormat = self.menuConfig.config.listFormat || '{msgNum:>4} - {subj:>35} |{to:>15}'; var focusListFormat = self.menuConfig.config.focusListFormat; var msgNum = 1; + var newMark = '*'; // :TODO: Make configurable + var dateFmt = 'ddd MMM DD'; // :TODO: Make configurable msgListView.setItems(_.map(self.messageList, function formatMsgListEntry(mle) { return listFormat.format( { msgNum : msgNum++, subj : mle.subject, - to : mle.toUserName + from : mle.fromUserName, + to : mle.toUserName, + ts : moment(mle.modTimestamp).format(dateFmt), + newMark : newMark, // :TODO: These should only be for actual new messages! } ); })); @@ -129,15 +156,29 @@ MessageListModule.prototype.mciReady = function(mciData, cb) { return focusListFormat.format( { msgNum : msgNum++, subj : mle.subject, - to : mle.toUserName + from : mle.fromUserName, + to : mle.toUserName, + ts : moment(mle.modTimestamp).format(dateFmt), + newMark : newMark, } ); })); } + msgListView.on('index update', function indexUpdated(idx) { + self.setViewText(MciCodesIds.MsgSelNum, (idx + 1).toString()); + }); + msgListView.redraw(); callback(null); - } + }, + function populateOtherMciViews(callback) { + + self.setViewText(MciCodesIds.MsgAreaDesc, messageArea.getMessageAreaByName(self.messageAreaName).desc); + self.setViewText(MciCodesIds.MsgTotal, self.messageList.length.toString()); + + callback(null); + }, ], function complete(err) { if(err) { diff --git a/mods/themes/luciano_blocktronics/MSGEHLP.ANS b/mods/themes/luciano_blocktronics/MSGEHLP.ANS new file mode 100644 index 0000000000000000000000000000000000000000..168d7b147246598fabe9580bde7d71b647ee8e4d GIT binary patch literal 950 zcmb_a%}T>S5Ki${C`^tnVIirX4q!LgBA~5UpDH^$o0D_Z$@^|@}*MEsKuqCJeR0>T~i5ME(^j+Rj2}R zpz;#sTxk>_iVkB8bs(Vu(ZF?(M+y$w6gr!%7Nn3%O)3>iVf(riMww~pB8Pnr4{8v> zcR{~4^{4W@P&r}%s}+a~s?op~58IN6TtP#c2->p%!z{)x8$*U1QHHZB8ue1bX&Hzo zb*pARN3QkEre#kK!qKSH3t4#Ee|mUicj5hzmWE+~z~0uRM~YZHrnE^?vez#oiL@uD zA{Loo@kb(vLpW`Xl5z3nsn*mn>V)#-aXhS}Smq)nb`0SeCM7 zHeO^bebZJOC))*Q&*|)Mr)m0`?7Yk*BAHfNA^+Q`eQ0!18nO9!Cicf@JBP^25~*7@ zLupQBL(9otLs>eT#ezwZtQz(6QRlfEa!xn#pN_-rw#~WMKC-M@ZD<`^`keG{2JEHR IG12z@0|mMo)&Kwi literal 0 HcmV?d00001 diff --git a/mods/themes/luciano_blocktronics/MSGLIST.ANS b/mods/themes/luciano_blocktronics/MSGLIST.ANS new file mode 100644 index 0000000000000000000000000000000000000000..9a8e6ce2653b7bf0a6e1920b8f93d95374a5d223 GIT binary patch literal 2316 zcmb_eOKuZE5OsD4i4_}yC74at%(U&Xz^hR_tMwV^0 znAT=4Ivy)dCQn&|jbaI`$Wa!aHfb~g?IeAXO(@wvwp%F4d?~hY2sTGncr+~2q(FAk z6>d$(N-Qr4Jj8&R*5)q8ZA}D(oU=kKwK6~@nI$0J&ZLyg`avoHZgxTo`3(9IOwx z)8$dM^@w$FKrP?vYfo*n6m4XmsBz@uV`=BUSSyv;_+!ilG$=VaHQFajxz+mu12T^t zQk6_;jn*9;W9o%P8U4h=_scIf6Nv};jgZ({2igfhoNGJASzT;f#>dr_lb6|OwXOga z3CvF$yCsKOSdf}IY!v5B^dZWiG6bD3=TY&LKA9Dd!TUid!O=ls3{bH!VTF~e%&x4C zJ?K1VjuY=52nV7T*Cj2jI5%WJdUxZ`jh=c`{cF(4e-2#U50CfXE)U9*fdA4} |22|37- |00|36{subj:>35} |01{to:>17}" - focusListFormat: "|00|01|42|37{msgNum:>4} |22|37- |36{subj:>35} |01{to:>17}" + listFormat: "|00|01|37{msgNum:>4} |00|37- |36{subj:<29.29} {from:<20.20} {ts} {newMark}" + focusListFormat: "|00|42|30{msgNum:>4} - {subj:<29.29} {from:<20.20} {ts} {newMark}" } }