mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-24 02:27:37 +00:00
Finish abstracting sprite data
This commit is contained in:
parent
24eca69581
commit
a9900a6df8
3 changed files with 18 additions and 55 deletions
|
|
@ -94,6 +94,14 @@ var SKIN_SPRITES = [
|
|||
{ selectors: ["#playlist.shade"], x: 72, y: 57, width: 25, height: 14}
|
||||
]
|
||||
}, */
|
||||
{
|
||||
img: "POSBAR",
|
||||
sprites: [
|
||||
{ selectors: ["#position"], x: 0, y: 0, width: 248, height: 10},
|
||||
{ selectors: ["#position::-webkit-slider-thumb", "#position::-moz-range-thumb"], x: 248, y: 0, width: 29, height: 10},
|
||||
{ selectors: ["#position:active::-webkit-slider-thumb", "#position:active::-moz-range-thumb"], x: 278, y: 0, width: 29, height: 10},
|
||||
]
|
||||
},
|
||||
{
|
||||
img: "SHUFREP",
|
||||
sprites: [
|
||||
|
|
@ -105,6 +113,10 @@ var SKIN_SPRITES = [
|
|||
{ selectors: ["#repeat:active"], x: 0, y: 15, width: 28, height: 15},
|
||||
{ selectors: ["#repeat.selected"], x: 0, y: 30, width: 28, height: 15},
|
||||
{ selectors: ["#repeat.selected:active"], x: 0, y: 45, width: 28, height: 15},
|
||||
{ selectors: ["#equalizer-button"], x: 0, y: 61, width: 23, height: 12},
|
||||
{ selectors: ["#equalizer-button:active"], x: 46, y: 61, width: 23, height: 12},
|
||||
{ selectors: ["#playlist-button"], x: 23, y: 61, width: 23, height: 12},
|
||||
{ selectors: ["#playlist-button:active"], x: 69, y: 61, width: 23, height: 12},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
29
js/skin.js
29
js/skin.js
|
|
@ -7,14 +7,6 @@ SkinManager = {
|
|||
return this;
|
||||
},
|
||||
|
||||
_skinImages: {
|
||||
"#position": "POSBAR.BMP",
|
||||
"#position::-webkit-slider-thumb": "POSBAR.BMP",
|
||||
"#position::-moz-range-thumb": "POSBAR.BMP",
|
||||
// Put this second, since it will trump .digit
|
||||
".digit-ex": "NUMS_EX.BMP"
|
||||
},
|
||||
|
||||
// For sprites that tile, we need to use just the sprite, not the whole image
|
||||
_skinSprites: SKIN_SPRITES,
|
||||
|
||||
|
|
@ -30,30 +22,19 @@ SkinManager = {
|
|||
var zip = new JSZip(buffer);
|
||||
document.getElementById('time').classList.remove('ex');
|
||||
|
||||
var promisedCssRules = [];
|
||||
for(var selector in this._skinImages) {
|
||||
var fileName = this._skinImages[selector];
|
||||
var file = this._findFileInZip(fileName, zip);
|
||||
var promisedCssRules = this._skinSprites.map(function(spriteObj) {
|
||||
|
||||
if (file) {
|
||||
var value = "background-image: url(data:image/bmp;base64," + btoa(file.asBinary()) + ")";
|
||||
promisedCssRules.push(selector + "{" + value + "}");
|
||||
|
||||
// CSS has to change if this file is present
|
||||
if(fileName == 'NUMS_EX.BMP') {
|
||||
document.getElementById('time').classList.add('ex');
|
||||
}
|
||||
// CSS has to change if this file is present
|
||||
if(spriteObj.img == 'NUMS_EX') {
|
||||
document.getElementById('time').classList.add('ex');
|
||||
}
|
||||
}
|
||||
|
||||
Array.prototype.push.apply(promisedCssRules, this._skinSprites.map(function(spriteObj) {
|
||||
var file = this._findFileInZip(spriteObj.img, zip);
|
||||
if (file) {
|
||||
var src = "data:image/bmp;base64," + btoa(file.asBinary());
|
||||
return this._spriteCssRule(src, spriteObj);
|
||||
}
|
||||
}, this));
|
||||
|
||||
}, this);
|
||||
|
||||
// Extract sprite images
|
||||
Promise.all(promisedCssRules).then(function(newCssRules) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue