From 7bac1b519319126d569524f176153e3344390995 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 9 Nov 2014 21:24:09 -0700 Subject: [PATCH] + Start of iCE color support... ish. * Initial NU-MAYA theme matrix --- core/ansi_term.js | 3 +++ core/art.js | 13 +++++++++++++ core/theme.js | 22 +++++++++++++++------- mods/art/themes/NU-MAYA/MATRIX.ANS | Bin 0 -> 3319 bytes mods/art/themes/NU-MAYA/theme_info.json | 4 ++++ mods/matrix.js | 4 ++++ 6 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 mods/art/themes/NU-MAYA/MATRIX.ANS create mode 100644 mods/art/themes/NU-MAYA/theme_info.json diff --git a/core/ansi_term.js b/core/ansi_term.js index 1bfb61a8..a135b023 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -51,6 +51,9 @@ var CONTROL = { goto : 'H', // row Pr, column Pc -- same as f gotoAlt : 'f', // same as H + blinkToBrightIntensity : '33h', + blinkNormal : '33l', + emulationSpeed : '*r' // Set output emulation speed. See cterm.txt }; diff --git a/core/art.js b/core/art.js index 399ff16e..c429c1da 100644 --- a/core/art.js +++ b/core/art.js @@ -173,6 +173,9 @@ function parseCharacterSAUCE(sauce) { result.fileType = SAUCE_CHARACTER_FILE_TYPES[sauce.fileType] || 'Unknown'; if(sauce.fileType === 0 || sauce.fileType === 1 || sauce.fileType === 2) { + // convience: create ansiFlags + sauce.ansiFlags = sauce.flags; + var i = 0; while(i < sauce.tinfos.length && sauce.tinfos[i] !== 0x00) { ++i; @@ -384,6 +387,7 @@ function display(options, cb) { var pauseKeys = miscUtil.valueWithDefault(options.pauseKeys, []); var pauseAtTermHeight = miscUtil.valueWithDefault(options.pauseAtTermHeight, false); var mciReplaceChar = miscUtil.valueWithDefault(options.mciReplaceChar, ' '); + var iceColors = miscUtil.valueWithDefault(options.iceColors, false); // :TODO: support pause/cancel & pause @ termHeight var canceled = false; @@ -414,6 +418,11 @@ function display(options, cb) { function completed() { options.client.removeListener('cursor position report', onCPR); parser.removeAllListeners(); // :TODO: Necessary??? + + if(iceColors) { + options.client.term.write(ansi.blinkNormal()); + } + cb(null, mci); } @@ -460,5 +469,9 @@ function display(options, cb) { } }); + if(iceColors) { + options.client.term.write(ansi.blinkToBrightIntensity()); + } + parser.parse(options.art); } \ No newline at end of file diff --git a/core/theme.js b/core/theme.js index ffe6b627..baf839f6 100644 --- a/core/theme.js +++ b/core/theme.js @@ -73,7 +73,7 @@ function initAvailableThemes(cb) { } function getRandomTheme(cb) { - if(availableThemes.length > 0) { + if(Object.getOwnPropertyNames(availableThemes).length > 0) { var themeIds = Object.keys(availableThemes); cb(null, themeIds[Math.floor(Math.random() * themeIds.length)]); } else { @@ -94,29 +94,37 @@ function getThemeArt(name, themeID, options, cb) { options.random = miscUtil.valueWithDefault(options.random, true); options.basePath = paths.join(Config.paths.themes, themeID); - art.getArt(name, options, function onThemeArt(err, theArt) { + 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, theArt) { + art.getArt(name, options, function onFallbackArt(err, artInfo) { if(err) { cb(err); } else { - cb(null, theArt.data); + cb(null, artInfo); } }); } else { - cb(null, theArt.data); + cb(null, artInfo); } }); } function displayThemeArt(name, client, cb) { - getThemeArt(name, client.user.properties.art_theme_id, function onArt(err, theArt) { + getThemeArt(name, client.user.properties.art_theme_id, function onArt(err, artInfo) { if(err) { cb(err); } else { - art.display( { art : theArt, client : client }, function onDisplayed(err, mci) { + var iceColors = false; + if(artInfo.sauce && artInfo.sauce.ansiFlags) { + if(artInfo.sauce.ansiFlags & (1 << 0)) { + iceColors = true; + } + } + + console.log(artInfo.sauce.flags); + art.display( { art : artInfo.data, client : client, iceColors : iceColors }, function onDisplayed(err, mci) { cb(err, mci); }); } diff --git a/mods/art/themes/NU-MAYA/MATRIX.ANS b/mods/art/themes/NU-MAYA/MATRIX.ANS new file mode 100644 index 0000000000000000000000000000000000000000..060300054b38f8f5bc6021908d3730ff160eb19a GIT binary patch literal 3319 zcma)8v2GMG5WVztG>B_Vfdt)d_HseGDntlTBtnXk=BgAF2u!4iAo#1h`<=D4zruSn z9xbob)%qU4&2(=2P;Gt4G~#^d_3*gtheE>r zWW-mri|uTY9B#U`pj!I_yujAl_mkn4+m;szhsg$)0|AW?u;eI2wty7TuwhaW7K`$9 z)GsuEh_Io!TKh1^t)8fbz*h(NI)B*faL#5?fPbS5Gk9ly5Qfh0oHPH5R01e@mhjQJ z>g^RlEo=Z)Ab`Iagk2_b3D}O)U4FNjeX*Pl?8mc7Hj2cY$a%+sS5x#7yb$&bpPRXe z@RPyOOiiSi_xorwq?DN9kurhlBu&I6ui5!%GG0132PI9qR1JP?5WbKx*geu&UYX{o zo&1BpTxcG}4k*4*v=G=IwAk1$7DCWJxes{`(l8VXvaGJmoeddOH;) zFHWF|op?>uax~hoMng-f#-Uo+i*ewQe2D#3$5PM5n3v!t%%$xD9o2FD z#=pL~Xx|*aU2ab{0Mp4j#!qx&Q#7o}&3JW7S%wGMBR4Gn2=$YZB>0LwxvO5(&{{ZS zxS@fDUBgM2jpwyfiXyc$m@*Z5C#p)nGIEIx^28e(#hz7<75G1J>I)MI5#vXmNC{g* zF^fb3?w-u zS`CndL5c=xvaq5TsuA;o!W9U%F8&wp8O0O|awhXi%8)FN_|z*GrV;hn;z}_sB)oWO zW>+rMvCYaW&*0^fQ|PIMav!v(7D5_C+E^hza z;^*i6*WY7v%x0GlSKsdLzJIyTWVPvW)2`aKdH3ttVsUizdGTT)