mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-08-06 01:35:04 +02:00
+ Very start of theme support. Various changes
This commit is contained in:
parent
46875ccddd
commit
8119c1688a
8 changed files with 95 additions and 34 deletions
|
@ -76,8 +76,10 @@ function ANSIEscapeParser(options) {
|
|||
};
|
||||
|
||||
self.resetColor = function() {
|
||||
self.fgColor = 7;
|
||||
self.bgColor = 0;
|
||||
//self.fgColor = 7;
|
||||
//self.bgColor = 0;
|
||||
self.fgColor = 39;
|
||||
self.bgColor = 49;
|
||||
};
|
||||
|
||||
self.rowUpdated = function() {
|
||||
|
|
|
@ -437,6 +437,7 @@ function display(art, options, cb) {
|
|||
|
||||
mciPosQueue.push(mciCode);
|
||||
|
||||
// :TODO: Move this out of the loop
|
||||
if(!emitter) {
|
||||
emitter = options.client.on('onPosition', function onPosition(pos) {
|
||||
if(mciPosQueue.length > 0) {
|
||||
|
|
|
@ -41,7 +41,8 @@ function createUserTables() {
|
|||
' user_id INTEGER NOT NULL,' +
|
||||
' prop_name VARCHAR NOT NULL,' +
|
||||
' prop_value VARCHAR,' +
|
||||
' UNIQUE(user_id, prop_name)' +
|
||||
' UNIQUE(user_id, prop_name),' +
|
||||
' FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE' +
|
||||
');'
|
||||
);
|
||||
}
|
|
@ -44,12 +44,13 @@ TextView.prototype.redraw = function() {
|
|||
|
||||
var color = this.hasFocus ? this.getFocusColor() : this.getColor();
|
||||
|
||||
this.client.term.write(ansi.sgr(color.flags, color.fg, color.bg));
|
||||
//this.client.term.write(ansi.sgr(color.flags, color.fg, color.bg));
|
||||
this.client.term.write(this.getANSIColor(color));
|
||||
|
||||
if(this.isPasswordTextStyle) {
|
||||
this.client.term.write(strUtil.pad(new Array(this.text.length).join(this.textMaskChar), this.dimens.width));
|
||||
this.client.term.write(strUtil.pad(new Array(this.text.length + 1).join(this.textMaskChar), this.dimens.width));
|
||||
} else {
|
||||
this.client.term.write(strUtil.pad(this.text, this.dimens.width));
|
||||
this.client.term.write(strUtil.pad(this.text, this.dimens.width));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
68
core/theme.js
Normal file
68
core/theme.js
Normal file
|
@ -0,0 +1,68 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
var Config = require('./config.js').config;
|
||||
var art = require('./art.js');
|
||||
var miscUtil = require('./misc_util.js');
|
||||
var fs = require('fs');
|
||||
var paths = require('path');
|
||||
var async = require('async');
|
||||
|
||||
exports.getThemeInfo = getThemeInfo;
|
||||
exports.getThemeArt = getThemeArt;
|
||||
|
||||
|
||||
// getThemeInfo(themeName)
|
||||
/*
|
||||
// getThemeFile(themeShortName, name)
|
||||
// getArt(name, {
|
||||
basePath : themeDir,
|
||||
}
|
||||
*/
|
||||
|
||||
function getThemeInfo(themeID, cb) {
|
||||
var path = paths.join(Config.paths.art, themeID, 'theme_info.json');
|
||||
|
||||
fs.readFile(path, function onData(err, data) {
|
||||
if(err) {
|
||||
cb(err);
|
||||
} else {
|
||||
try {
|
||||
var info = JSON.parse(data);
|
||||
return info;
|
||||
} catch(e) {
|
||||
cb(err);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getThemeArt(name, themeID, options, cb) {
|
||||
// allow options to be optional
|
||||
if(typeof cb === 'undefined') {
|
||||
cb = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
// set/override some options
|
||||
options.asAnsi = true;
|
||||
options.readSauce = true; // can help with encoding
|
||||
options.random = miscUtil.valueWithDefault(options.random, true);
|
||||
options.basePath = paths.join(Config.paths.art, themeID);
|
||||
|
||||
art.getArt(name, options, function onThemeArt(err, theArt) {
|
||||
if(err) {
|
||||
// try fallback
|
||||
options.basePath = Config.paths.art;
|
||||
art.getArt(name, options, function onFallbackArt(err, theArt) {
|
||||
if(err) {
|
||||
cb(err);
|
||||
} else {
|
||||
cb(null, theArt.data);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
cb(null, theArt.data);
|
||||
}
|
||||
});
|
||||
}
|
|
@ -121,12 +121,13 @@ function createNew(user, cb) {
|
|||
],
|
||||
function onComplete(err) {
|
||||
if(err) {
|
||||
var originalError = err;
|
||||
userDb.run('ROLLBACK;', function onRollback(err) {
|
||||
cb(err);
|
||||
assert(!err);
|
||||
cb(originalError);
|
||||
});
|
||||
} else {
|
||||
userDb.run('COMMIT;', function onCommit(err) {
|
||||
|
||||
if(err) {
|
||||
cb(err);
|
||||
} else {
|
||||
|
|
|
@ -60,6 +60,14 @@ function View(client, options) {
|
|||
this.isSpecialKeyMapped = function(keySet, keyName) {
|
||||
return this.specialKeyMap[keySet].indexOf(keyName) > -1;
|
||||
};
|
||||
|
||||
this.getANSIColor = function(color) {
|
||||
var sgr = [ color.flags, color.fg ];
|
||||
if(color.bg !== color.flags) {
|
||||
sgr.push(color.bg);
|
||||
}
|
||||
return ansi.sgr(sgr);
|
||||
};
|
||||
}
|
||||
|
||||
util.inherits(View, events.EventEmitter);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue