+ Introduction of WIP asset system - menus, prompts, art, etc. @type:location/asset

This commit is contained in:
Bryan Ashby 2015-04-05 01:15:04 -06:00
parent 113e16df0d
commit 3336caeec9
6 changed files with 95 additions and 26 deletions

31
core/asset.js Normal file
View file

@ -0,0 +1,31 @@
/* jslint node: true */
'use strict';
exports.parseAsset = parseAsset;
var ALL_ASSETS = [
'art',
'menu',
'method',
'prompt',
];
// \@(art|menu|method)\:([\w\.]*)(?:\/?([\w\d\_]+))*
var ASSET_RE = new RegExp('\\@(' + ALL_ASSETS.join('|') + ')\\:([\\w\\.]*)(?:\\?/([\\w\\d\\_]+))*');
function parseAsset(s) {
var m = ASSET_RE.exec(s);
if(m) {
var result = { type : m[1] };
if(m[3]) {
result.location = m[2];
result.asset = m[3];
} else {
result.asset = m[2];
}
return result;
}
}