From b12d9aad0405bc1d646c4dcf17a0021bfb5c8f90 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Wed, 3 Aug 2016 21:46:38 -0600 Subject: [PATCH] sysStat for +op username vs old config value --- core/asset.js | 14 ++++++++++++++ core/view_controller.js | 4 ++++ mods/menu.hjson | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/asset.js b/core/asset.js index ae74e07b..0731a1b7 100644 --- a/core/asset.js +++ b/core/asset.js @@ -3,6 +3,7 @@ // ENiGMA½ const Config = require('./config.js').config; +const StatLog = require('./stat_log.js'); // deps const _ = require('lodash'); @@ -13,6 +14,7 @@ exports.getAssetWithShorthand = getAssetWithShorthand; exports.getArtAsset = getArtAsset; exports.getModuleAsset = getModuleAsset; exports.resolveConfigAsset = resolveConfigAsset; +exports.resolveSystemStatAsset = resolveSystemStatAsset; exports.getViewPropertyAsset = getViewPropertyAsset; const ALL_ASSETS = [ @@ -24,6 +26,7 @@ const ALL_ASSETS = [ 'systemModule', 'prompt', 'config', + 'sysStat', ]; const ASSET_RE = new RegExp('\\@(' + ALL_ASSETS.join('|') + ')\\:([\\w\\d\\.]*)(?:\\/([\\w\\d\\_]+))*'); @@ -101,7 +104,18 @@ function resolveConfigAsset(spec) { return conf; } else { return spec; + } +} + +function resolveSystemStatAsset(spec) { + const asset = parseAsset(spec); + if(!asset) { + return spec; } + + assert('sysStat' === asset.type); + + return StatLog.getSystemStat(asset.asset) || spec; } function getViewPropertyAsset(src) { diff --git a/core/view_controller.js b/core/view_controller.js index 3e968563..fa85a1b8 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -180,6 +180,10 @@ function ViewController(options) { case 'config' : propValue = asset.resolveConfigAsset(conf[propName]); break; + + case 'sysStat' : + propValue = asset.resolveSystemStatAsset(conf[propName]); + break; // :TODO: handle @art (e.g. text : @art ...) diff --git a/mods/menu.hjson b/mods/menu.hjson index 6738af82..92184ba1 100644 --- a/mods/menu.hjson +++ b/mods/menu.hjson @@ -405,7 +405,7 @@ ET2: { argName: to focus: true - text: @config:general.sysOp.username + text: @sysStat:sysop_username // :TODO: readOnly: true } ET3: { @@ -927,7 +927,7 @@ ET2: { argName: to focus: true - text: @config:general.sysOp.username + text: @sysStat:sysop_username // :TODO: readOnly: true } ET3: {