diff --git a/css/tetrio-skin.css b/css/tetrio-skin.css index 3d34db0..272dc35 100644 --- a/css/tetrio-skin.css +++ b/css/tetrio-skin.css @@ -1,7 +1,7 @@ :root { --cell-size: 30px; --sprite-size: round(100% / 11, 1px); - --skin-url: url(https://you.have.fail/ed/at/tetrioplus/data/content/skin/Haley%20Halcyon/tetrio_gameboy_plus.svg); + --skin-url: url(tetrio-skin/a_forest.png); } tr.matrix td:not(.mino) { diff --git a/css/tetrio-skin/415652c2.jpg b/css/tetrio-skin/415652c2.jpg new file mode 100644 index 0000000..e5da5cb Binary files /dev/null and b/css/tetrio-skin/415652c2.jpg differ diff --git a/css/tetrio-skin/a_forest.png b/css/tetrio-skin/a_forest.png new file mode 100644 index 0000000..b7bcb69 Binary files /dev/null and b/css/tetrio-skin/a_forest.png differ diff --git a/css/tetrio-skin/a_forest2.png b/css/tetrio-skin/a_forest2.png new file mode 100644 index 0000000..b0edf35 Binary files /dev/null and b/css/tetrio-skin/a_forest2.png differ diff --git a/index.html b/index.html index 947d8fc..8edf779 100644 --- a/index.html +++ b/index.html @@ -12,8 +12,9 @@ - - + + + @@ -21,7 +22,7 @@ - + @@ -79,8 +80,8 @@
- -
+ +
+ +
diff --git a/js/app.js b/js/app.js index 367b4eb..23947d4 100644 --- a/js/app.js +++ b/js/app.js @@ -361,6 +361,37 @@ stylesheetSelect.oninput = function (event) { $("#skinURLSelect").empty(); switch (this.value) { + case 'css/tetrio-skin.css': + skinURLSelect.disabled = false; + + const baseURL = "https://you.have.fail/tetrioplus/data" + fetch(`${baseURL}/data.json`) + .then((resp) => resp.json()) + .then((json) => { + json = json.filter((item) => (item.type == "skin" && item.format == "tetrioraster" && /\.(?:png|jpg|jpeg|gif|bmp|webp|svg)$/i.test(item.path))) + const groups = Map.groupBy(json, (skin) => skin.author) + const data = groups.entries().map(([author, skins]) => { + return { + text: author, + children: skins.map((skin) => { + return { + id: `${baseURL}/${encodeURI(skin.path)}`, + text:`${skin.name}\n${skin.description}` + } + }) + } + }).toArray() + data.push({ + text: "AdrienMalin", + children: [{ + id: `${document.location.href}/css/tetrio-skin/a_forest.png`, + text: "A forest" + }] + }) + $('#skinURLSelect').select2({data: data}); + }) + break; + case 'css/jstris-skin.css': skinURLSelect.disabled = false; @@ -373,35 +404,15 @@ stylesheetSelect.oninput = function (event) { text: group, children: json[group].map(skin => ({ id: skin.link, - text: `${skin.name} (${skin.author})`, + text: `${skin.name} by ${skin.author}`, })), }; data.push(groupData); } - $('#skinURLSelect').select2({data: data}); }); break; - case 'css/tetrio-skin.css': - skinURLSelect.disabled = false; - - fetch("https://you.have.fail/tetrioplus/data/data.json") - .then((resp) => resp.json()) - .then((json) => { - const data = json - .filter((item) => (item.type == "skin" && item.format == "tetrioraster")) - .map((skin) => { - return { - id: encodeURI(`https://you.have.fail/tetrioplus/data/${skin.path}`), - text:`${skin.name} (${skin.author})\n${skin.description}` - } - }) - .filter((option) => ImageURLPattern.test(option.id)) - $('#skinURLSelect').select2({data: data}); - }) - break; - default: skinURLSelect.disabled = true; break; diff --git a/js/interface.js b/js/interface.js index bc55542..592f5ea 100644 --- a/js/interface.js +++ b/js/interface.js @@ -41,12 +41,7 @@ class Settings { if ($('#skinURLSelect').find("option[value='" + localStorage['skinURL'] + "']").length) { $('#skinURLSelect').val(localStorage['skinURL']).trigger('change'); } else { - var option = new Option( - 'Source externe', - localStorage['skinURL'], - true, - true, - ); + var option = new Option('Sample sauvegardé', localStorage['skinURL']); $('#skinURLSelect').append(option).trigger('change'); } skinURLSelect.oninput(); @@ -399,6 +394,6 @@ Stats.prototype.timeFormat = new Intl.DateTimeFormat('fr-FR', { function playSound(sound, note = 0) { sound.currentTime = 0; - sound.playbackRate = Math.pow(5 / 4, note); + sound.playbackRate = note? Math.pow(5 / 4, note): 1; sound.play(); }