Parse PLEDIT.txt

Fixes #128
This commit is contained in:
Jordan Eldredge 2015-01-20 02:27:31 -08:00
parent efd1381144
commit 06cc24419f
2 changed files with 31 additions and 3 deletions

View file

@ -7,7 +7,6 @@
margin-left: -137px;
top: 40%;
left: 20%;
background-color: black;
/* Background-image: pledit.bmp */
}
#playlist.closed { display: none; }
@ -33,11 +32,9 @@
}
#playlist #tracks li {
white-space: nowrap;
color: lightgreen;
font-size: 8px;
}
#playlist #tracks li.selected {
background-color: red;
}
#playlist .top {

View file

@ -36,6 +36,24 @@ SkinManager = {
}
}, this);
// Extract PLEDIT.txt values
var plRules = {
"Normal": { selector:'#tracks li', attribute:'color' },
"Current": { selector:'#tracks li.current', attribute:'color' },
"Current": { selector:'#tracks li.current', attribute:'color' },
"Font": { selector:'#tracks li', attribute:'font-family' },
"NormalBG": { selector:'#tracks, #tracks li', attribute:'background-color' },
"SelectedBG": { selector:'#tracks li.selected', attribute:'background-color' }
}
var plValues = this._parsePlEdit(zip);
for(key in plRules) {
var rule = plRules[key];
if(plValues[key]) {
promisedCssRules.push(rule.selector + "{" + rule.attribute + ":" + plValues[key] + "}");
}
}
// Extract sprite images
Promise.all(promisedCssRules).then(function(newCssRules) {
this._createNewStyleNode();
@ -64,6 +82,19 @@ SkinManager = {
this.visualizer.setColors(colors);
},
_parsePlEdit: function(zip) {
var entries = this._findFileInZip("PLEDIT.TXT", zip).asText().split("\n");
var regex = /^([^=]*)=([^=\r]*)\r?$/
var results = {};
for(var i = 0; i < entries.length; i++) {
var matches = regex.exec(entries[i]);
if(matches) {
results[matches[1]] = matches[2];
}
}
return results;
},
_findFileInZip: function(name, zip) {
return zip.filter(function (relativePath, file){
return new RegExp("(^|/)" + name, 'i').test(relativePath);