From 171ee75043c05de625d203968d786ab115bcec77 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Tue, 13 Oct 2015 00:35:37 -0600 Subject: [PATCH] * pipeWrite() can now parse Renegade via spec='renegade' * WIP on user config --- core/client_term.js | 12 +++++-- core/user_config.js | 36 ++++++++++++++++++- core/view_controller.js | 2 +- mods/menu.hjson | 26 ++++++++++++++ mods/themes/luciano_blocktronics/CONFSCR.ANS | Bin 1565 -> 2219 bytes 5 files changed, 72 insertions(+), 4 deletions(-) diff --git a/core/client_term.js b/core/client_term.js index e3e5f7a5..179d83f1 100644 --- a/core/client_term.js +++ b/core/client_term.js @@ -4,6 +4,7 @@ // ENiGMA½ var Log = require('./logger.js').log; var enigmaToAnsi = require('./color_codes.js').enigmaToAnsi; +var renegadeToAnsi = require('./color_codes.js').renegadeToAnsi; var iconv = require('iconv-lite'); var assert = require('assert'); @@ -137,8 +138,15 @@ ClientTerminal.prototype.rawWrite = function(s) { this.output.write(s); }; -ClientTerminal.prototype.pipeWrite = function(s) { - this.write(enigmaToAnsi(s, this)); +ClientTerminal.prototype.pipeWrite = function(s, spec) { + spec = spec || 'enigma'; + + var conv = { + enigma : enigmaToAnsi, + renegade : renegadeToAnsi, + }[spec] || enigmaToAnsi; + + this.write(conv(s, this)); }; ClientTerminal.prototype.encode = function(s, convertLineFeeds) { diff --git a/core/user_config.js b/core/user_config.js index 4248e840..0b93a35f 100644 --- a/core/user_config.js +++ b/core/user_config.js @@ -7,6 +7,7 @@ var ViewController = require('./view_controller.js').ViewController; var async = require('async'); var assert = require('assert'); var _ = require('lodash'); +var moment = require('moment'); exports.getModule = UserConfigModule; @@ -16,11 +17,30 @@ exports.moduleInfo = { author : 'NuSkooler', }; +var MciCodeIds = { + Email : 1, + Loc : 2, + Web : 3, + Affils : 4, + + BirthDate : 5, + Sex : 6, + + Theme : 10, + ScreenSize : 11, +}; + function UserConfigModule(options) { MenuModule.call(this, options); var self = this; + self.setViewText = function(viewId, text) { + var v = self.viewControllers.menu.getView(viewId); + if(v) { + v.setText(text); + } + }; } @@ -28,12 +48,26 @@ require('util').inherits(UserConfigModule, MenuModule); UserConfigModule.prototype.mciReady = function(mciData, cb) { var self = this; - var vc = self.viewControllers.allViews = new ViewController( { client : self.client} ); + var vc = self.viewControllers.menu = new ViewController( { client : self.client} ); async.series( [ function callParentMciReady(callback) { UserConfigModule.super_.prototype.mciReady.call(self, mciData, callback); + }, + function loadFromConfig(callback) { + vc.loadFromMenuConfig( { callingMenu : self, mciMap : mciData.menu }, callback); + }, + function populateViews(callback) { + var user = self.client.user; + + self.setViewText(MciCodeIds.Email, user.properties.email_address); + self.setViewText(MciCodeIds.Loc, user.properties.location); + self.setViewText(MciCodeIds.Web, user.properties.web_address); + self.setViewText(MciCodeIds.Affils, user.properties.affiliation); + self.setViewText(MciCodeIds.BirthDate, moment(user.properties.birthdate).format('YYYYMMDD')); + self.setViewText(MciCodeIds.Sex, user.properties.sex); + } ] ); diff --git a/core/view_controller.js b/core/view_controller.js index f08652e2..16deb4a8 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -559,7 +559,7 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) { if(err) { // non-fatal self.client.log.trace( - { error : err, mci : Object.keys(options.mciMap), formId : formIdKey }, + { error : err.toString(), mci : Object.keys(options.mciMap), formId : formIdKey }, 'Unable to find matching form configuration'); } diff --git a/mods/menu.hjson b/mods/menu.hjson index ae30e309..98ff2646 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -460,6 +460,32 @@ mainMenuUserConfig: { module: @systemModule:user_config art: CONFSCR + form: { + 0: { + mci: { + ET1: { + argName: email + } + ET2: { + argName: location + } + ET3: { + argName: webAddress + } + ET4: { + argName: affils + } + ME5: { + maskPattern: "####/##/##" + argName: birthdate + } + ME11: { + maskPattern: "##x##" + argName: termSize + } + } + } + } } /////////////////////////////////////////////////////////////////////// // Message Area Related diff --git a/mods/themes/luciano_blocktronics/CONFSCR.ANS b/mods/themes/luciano_blocktronics/CONFSCR.ANS index f43c59a6861104e31f07112975a4109b8b085665..0e9dc5c487cd9389f8dd27467bac78a8d5b1cfd1 100644 GIT binary patch literal 2219 zcmb_dyKdV+5R|(hK&qsQnrqyoI#PVVQ6&?M;X+9e%WhQ3HU$gN*?=V=M!w4M?~uU# ziILgeJMt(gNfQ>*?LB5^X7|Y9T#pky9%=LL?QkBY#c)2#Ow%+Q0&8 z{}<~$4C#eV*iIu<4FXANTA+OJ!wa(V(5~G)Uf9cv&)b!g_KWp=j=Rhm;0xZ9B>{fL zr=U%RVVJvf+EuxAOLQylCG>7?xMo~N)o>y6qE=jFA%_BF1-G+Y1hSJ|CjQ{^{Oo<$ zli?SjiW(mTy-2Sc=h-#t2hy$$+lvuZI5;1ixiTzeT?vWz!m1urtTHs}f9*c#Vc5#u~5=ssZV>KmI^;gOlk zi}HsmzJ2|2eugP9$C`s-vZOv9u~R4rR%nb(v&ktpp!)2O-B(XrwOm!}+xEQ6$_y;A zksHgHafg{|T;)E$$}CoEheKE0Wy#EOIg4nXjLlsnZ3kPKU;<#)vAwHI6=Jw~5XK!k zzM4ilK$1{i(3l3LjxV|Lv$}4vPI`Re0HvHE`U9WM&0|&FtIg_{XXVWUn`s$^x+HX; z3KHh6BP#2Mo5gnZaPRn_P61Fk8};}g>cL1=31+ceuGX7YRMr!f^gs}KXX1$brLNFj z1z{I|OX$0@Tit^PPNd@0%s4@8u2+xSyW7RK^@fn#b-v=KC{JcLuovN#|iA3%1Zt7*w-Ta}zUjc)6gaDco03sE1ioo|*)= z#N5Cc=m_a(Q)j3fa`KZCOEUBG;3~{aAkMf0GyBa4CYV_AA)^*|ITd? Qm@L3i$~1>{ayy3#019+l)Bpeg