From cee7983c5acd9276a1fc5248958e4d3d47039ed3 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 14 Sep 2015 22:40:00 -0600 Subject: [PATCH] * Progress on FSE quote builder... WIP! --- core/fse.js | 58 +++++++++++++++++++++++++++++--- core/view_controller.js | 10 ++++-- mods/menu.hjson | 45 +++++++++++++++++++------ mods/themes/NU-MAYA/MSGQUOT.ANS | Bin 346 -> 310 bytes 4 files changed, 96 insertions(+), 17 deletions(-) diff --git a/core/fse.js b/core/fse.js index 32628cd4..d1939b7b 100644 --- a/core/fse.js +++ b/core/fse.js @@ -134,6 +134,7 @@ function FullScreenEditorModule(options) { footerEditor : 2, footerEditorMenu : 3, footerView : 4, + quoteBuilder : 5, help : 50, }[name]; @@ -268,7 +269,7 @@ function FullScreenEditorModule(options) { this.switchFooter = function(cb) { var footerName = self.getFooterName(); - + self.redrawFooter( { footerName : footerName, clear : true }, function artDisplayed(err, artData) { if(err) { cb(err); @@ -567,9 +568,58 @@ function FullScreenEditorModule(options) { // // Clear body area // - self.client.term.rawWrite( - ansi.goto(self.header.height, 1) + - ansi.eraseLine(self.body.height)); + async.waterfall( + [ + function clearAndDisplayArt(callback) { + console.log(self.header.height); + self.client.term.rawWrite( + ansi.goto(self.header.height + 1, 1)); + //ansi.eraseLine(2)); + + theme.displayThemeArt( { name : self.menuConfig.config.art.quote, client : self.client }, function displayed(err, artData) { + callback(err, artData); + }); + }, + function createViewsIfNecessary(artData, callback) { + var formId = self.getFormId('quoteBuilder'); + + if(_.isUndefined(self.viewControllers.quoteBuilder)) { + var menuLoadOpts = { + callingMenu : self, + formId : formId, + mciMap : artData.mciMap, + }; + + self.addViewController( + 'quoteBuilder', + new ViewController( { client : self.client, formId : formId } ) + ).loadFromMenuConfig(menuLoadOpts, function quoteViewsReady(err) { + callback(err); + }); + } else { + self.viewControllers.quoteBuilder.redrawAll(); + callback(null); + } + }, + function loadQuoteLines(callback) { + // :TODO: MLTEV's word wrapping -> line[] stuff needs to be made a public API. This can then be used here and elsewhere. + // ...should not be too bad to do at all + self.viewControllers.quoteBuilder.getView(3).setItems(['Someone said some shit', 'then they said more shit', 'and what not...', 'hurp durp']); + callback(null); + }, + function setViewFocus(callback) { + self.viewControllers.quoteBuilder.getView(1).setFocus(false); + self.viewControllers.quoteBuilder.switchFocus(3); + + callback(null); + } + ], + function complete(err) { + if(err) { + console.log(err) // :TODO: needs real impl. + } + } + ); }; this.observeEditorEvents = function() { diff --git a/core/view_controller.js b/core/view_controller.js index b7cc43f8..5ea2f713 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -215,10 +215,14 @@ function ViewController(options) { var initialFocusId = 1; async.each(Object.keys(config.mci), function entry(mci, nextItem) { - var mciMatch = mci.match(MCI_REGEXP); // :TODO: How to handle auto-generated IDs???? + var mciMatch = mci.match(MCI_REGEXP); // :TODO: How to handle auto-generated IDs???? + if(null === mciMatch) { + self.client.log.warn( { mci : mci }, 'Unable to parse MCI code'); + return; + } - var viewId = parseInt(mciMatch[2]); - assert(!isNaN(viewId)); + var viewId = parseInt(mciMatch[2]); + assert(!isNaN(viewId), 'Cannot parse view ID: ' + mciMatch[2]); // shouldn't be possible with RegExp used if(viewId > highestId) { highestId = viewId; diff --git a/mods/menu.hjson b/mods/menu.hjson index 7cbc323b..dab90520 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -521,7 +521,7 @@ "action" : "@method:nextMessage" }, { - value: { 1: 2 }, + value: { 1: 2 } action: @method:replyMessage extraArgs: { menu: messageAreaReplyPost @@ -546,15 +546,16 @@ "action" : "@method:prevMessage" }, { - "keys" : [ "n", "shift + n" ], - "action" : "@method:nextMessage" + keys: [ "n", "shift + n" ] + action: @method:nextMessage }, { "keys" : [ "escape", "q", "shift + q" ], "action" : "@menu:messageArea" }, + // :TODO: why the fuck is 'r' not working but 'n' for example does? { - keys: : [ "r", "shift + r" ], + keys: : [ "r", "shift + r" ] action: @method:replyMessage extraArgs: { menu: messageAreaReplyPost @@ -636,19 +637,43 @@ ] } - 4: { - mci: { - HM1: { - items: [ "Save", "Discard", "Quote", "Help" ] - }, + 3: { + HM: { + mci: { + HM1: { + items: [ "Save", "Discard", "Quote", "Help" ] + } + } + submit: { *: [ { value: { 1: 2 }, - action: @method:editModeQuote + action: @method:editModeMenuQuote } ] } + + actionKeys: [ + { + keys: [ "escape" ] + action: @method:editModeEscPressed + } + ] + } + } + + 5: { + mci: { + MT1: { + width: 79 + height: 7 + } + VM3: { + //items: [ "just", "testing", "some", "things" ] + width: 79 + height: 4 + } } } } diff --git a/mods/themes/NU-MAYA/MSGQUOT.ANS b/mods/themes/NU-MAYA/MSGQUOT.ANS index d5b028a18d292519278de02ed67ef6f4a53cd68b..16d1be42ad8970cf4ca2bdb8af1be77b0efd1b26 100644 GIT binary patch delta 26 icmcb`w2f(k+(d)v6K_UyZe?I#U}Own;F@g9C<_34&DG=sxiRi=dH#p{aqn Tf$>cS1_nmP00xQ4l8mwdX_XI&