diff --git a/core/config.js b/core/config.js index 2e122f47..a3bd36e3 100644 --- a/core/config.js +++ b/core/config.js @@ -91,7 +91,7 @@ function getDefaultConfig() { } */ defaults : { - theme : 'NU-MAYA', // :TODO: allow "*" here + theme : 'luciano_blocktronics', passwordChar : '*', // TODO: move to user ? dateFormat : { short : 'MM/DD/YYYY', diff --git a/core/menu_util.js b/core/menu_util.js index ad89e3f3..401c94f8 100644 --- a/core/menu_util.js +++ b/core/menu_util.js @@ -261,10 +261,11 @@ function handleNext(client, nextSpec, conf) { function applyThemeCustomization(options) { // // options.name : menu/prompt name - // options.configMci : menu or prompt config (menu.json / prompt.json) specific mci section + // options.mci : menu/prompt .mci section // options.client : client // options.type : menu|prompt // options.formId : (optional) form ID in cases where multiple forms may exist wanting their own customization + // options.config : menu/prompt .config section // // In the case of formId, the theme must include the ID as well, e.g.: // { @@ -278,8 +279,12 @@ function applyThemeCustomization(options) { assert("menus" === options.type || "prompts" === options.type); assert(_.isObject(options.client)); - if(_.isUndefined(options.configMci)) { - options.configMci = {}; + if(_.isUndefined(options.mci)) { + options.mci = {}; + } + + if(_.isUndefined(options.config)) { + options.config = {}; } if(_.has(options.client.currentTheme, [ 'customization', options.type, options.name ])) { @@ -290,9 +295,17 @@ function applyThemeCustomization(options) { themeConfig = themeConfig[options.formId]; } - Object.keys(themeConfig).forEach(function mciEntry(mci) { - _.defaults(options.configMci[mci], themeConfig[mci]); - }); + if(themeConfig.mci) { + Object.keys(themeConfig.mci).forEach(function mciEntry(mci) { + _.defaults(options.mci[mci], themeConfig.mci[mci]); + }); + } + + if(themeConfig.config) { + Object.keys(themeConfig.config).forEach(function confEntry(conf) { + _.defaultsDeep(options.config[conf], themeConfig.config[conf]); + }); + } } // :TODO: apply generic stuff, e.g. "VM" (vs "VM1") diff --git a/core/theme.js b/core/theme.js index 8cde3fa0..b09c6b98 100644 --- a/core/theme.js +++ b/core/theme.js @@ -153,37 +153,73 @@ function getRandomTheme() { } } -function getThemeArt(name, themeID, options, cb) { - // allow options to be optional - if(_.isUndefined(cb)) { - cb = options; - options = {}; +function getThemeArt(options, cb) { + // + // options - required: + // name + // client + // + // options - optional + // themeId + // asAnsi + // readSauce + // random + // + if(!options.themeId && _.has(options.client, 'user.properties.theme_id')) { + options.themeId = options.client.user.properties.theme_id; + } else { + options.themeId = Config.defaults.theme; } - // set/override some options - // :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ... // :TODO: Some of these options should only be set if not provided! - options.asAnsi = true; - options.readSauce = true; // encoding/fonts/etc. - options.random = miscUtil.valueWithDefault(options.random, true); - options.basePath = paths.join(Config.paths.themes, themeID); + options.asAnsi = true; // always convert to ANSI + options.readSauce = true; // read SAUCE, if avail + options.random = _.isBoolean(options.random) ? options.random : true; // FILENAME.EXT support - art.getArt(name, options, function onThemeArt(err, artInfo) { - if(err) { - // try fallback of art directory - options.basePath = Config.paths.art; - art.getArt(name, options, function onFallbackArt(err, artInfo) { - if(err) { - cb(err); + // + // We look for themed art in the following manor: + // * Supplied theme via |themeId| + // * Fallback 1: Default theme (if different than |themeId|) + // * General art directory + // + async.waterfall( + [ + function fromSuppliedTheme(callback) { + options.basePath = paths.join(Config.paths.themes, options.themeId); + + art.getArt(options.name, options, function artLoaded(err, artInfo) { + callback(null, artInfo); + }); + }, + function fromDefaultTheme(artInfo, callback) { + if(artInfo || Config.defaults.theme === options.themeId) { + callback(null, artInfo); } else { - cb(null, artInfo); + console.log('trying default theme') + options.basePath = paths.join(Config.paths.themes, Config.defaults.theme); + + art.getArt(options.name, options, function artLoaded(err, artInfo) { + callback(null, artInfo); + }); } - }); - } else { - cb(null, artInfo); - } - }); + }, + function fromGeneralArtDir(artInfo, callback) { + if(artInfo) { + callback(null, artInfo); + } else { + console.log('using general art dir') + options.basePath = Config.paths.art; + + art.getArt(options.name, options, function artLoaded(err, artInfo) { + console.log('cannot find art: ' + options.name) + callback(err, artInfo); + }); + } + } + ], + cb // cb(err, artInfo) + ); } function displayThemeArt(options, cb) { @@ -191,7 +227,7 @@ function displayThemeArt(options, cb) { assert(_.isObject(options.client)); assert(_.isString(options.name)); - getThemeArt(options.name, options.client.user.properties.theme_id, function themeArt(err, artInfo) { + getThemeArt(options, function themeArt(err, artInfo) { if(err) { cb(err); } else { diff --git a/core/view_controller.js b/core/view_controller.js index 2c9e5bc2..e76a0083 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -462,7 +462,8 @@ ViewController.prototype.loadFromPromptConfig = function(options, cb) { name : promptName, type : "prompts", client : self.client, - configMci : promptConfig.mci, + mci : promptConfig.mci, + config : promptConfig.config, }); } callback(null); @@ -574,11 +575,14 @@ ViewController.prototype.loadFromMenuConfig = function(options, cb) { //if(_.isObject(formConfig)) { formConfig = formConfig || {} + console.log(formConfig) + menuUtil.applyThemeCustomization({ name : self.client.currentMenuModule.menuName, type : 'menus', client : self.client, - configMci : formConfig.mci, + mci : formConfig.mci, + config : formConfig.config, formId : formIdKey, }); //} diff --git a/mods/menu.hjson b/mods/menu.hjson index ce01b920..12d9cccb 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -213,7 +213,7 @@ } TM12: { argName: submission - items: [ "Apply", "Cancel" ] + items: [ "apply", "cancel" ] submit: true } } diff --git a/mods/themes/luciano_blocktronics/NUA.ANS b/mods/themes/luciano_blocktronics/NUA.ANS new file mode 100644 index 00000000..c1f00e41 Binary files /dev/null and b/mods/themes/luciano_blocktronics/NUA.ANS differ diff --git a/mods/themes/luciano_blocktronics/theme.hjson b/mods/themes/luciano_blocktronics/theme.hjson index 0d3dcd81..24970aae 100644 --- a/mods/themes/luciano_blocktronics/theme.hjson +++ b/mods/themes/luciano_blocktronics/theme.hjson @@ -19,27 +19,54 @@ menus: { matrix: { - VM1: { - focusTextStyle: first lower + mci: { + VM1: { + focusTextStyle: first lower + } + } + } + + newUserApplication: { + mci: { + ET1: { width: 23 } + ET2: { width: 23 } + ET5: { width: 23 } + ET6: { width: 23 } + + ET7: { width: 23 } + ET8: { width: 23 } + ET9: { width: 23 } + ET10: { width: 23 } + + TM12: { + focusTextStyle: first lower + } } } login2: { - ET1: { width: 14 } - ET2: { width: 14 } + mci: { + ET1: { width: 14 } + ET2: { width: 14 } + } } mainMenuUserStats: { - UN1: { width: 17 } - UR2: { width: 17 } - LO3: { width: 17 } - UF4: { width: 17 } - UG5: { width: 17 } - UT6: { width: 17 } - UC7: { width: 17 } + mci: { + UN1: { width: 17 } + UR2: { width: 17 } + LO3: { width: 17 } + UF4: { width: 17 } + UG5: { width: 17 } + UT6: { width: 17 } + UC7: { width: 17 } + } } mainMenuLastCallers: { + config: { + dateTimeFormat: MMM Do H:mm a + } } } }