mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-28 11:42:29 +01:00
commit8ed95731cbAuthor: Phillip Thelen <phillip@habitica.com> Date: Tue Jul 23 17:59:56 2024 +0200 fix hatched dialog commit53242ad96cAuthor: Phillip Thelen <phillip@habitica.com> Date: Tue Jul 23 17:38:13 2024 +0200 fix popover not showing commitce4bfd25bdAuthor: Phillip Thelen <phillip@habitica.com> Date: Wed Jul 3 17:28:30 2024 +0200 move item popover to own component commit2e6a300c46Author: Phillip Thelen <phillip@habitica.com> Date: Mon Jul 1 18:48:24 2024 +0200 make scaled sprites look nice commita3cbadb8c2Author: Phillip Thelen <phillip@habitica.com> Date: Mon Jul 1 18:48:17 2024 +0200 fix hatching dialog commit0e5126df5eAuthor: Phillip Thelen <phillip@habitica.com> Date: Mon Jul 1 18:48:12 2024 +0200 fix popover alignment commit7362af9236Author: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 28 17:07:03 2024 +0200 fix item display commitcf353efdb7Author: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 28 16:59:13 2024 +0200 fix pet display commitcaf0cba9f2Author: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 28 15:24:39 2024 +0200 fix background icon display commit3b06febc01Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 26 12:30:04 2024 +0200 fix sprites for notifications commit160b2debdcAuthor: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 26 10:35:13 2024 +0200 fix gear display in profile commitb200a2f17dAuthor: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 26 10:28:11 2024 +0200 fix sprites for keys to the kennel commit3614e7a8fbAuthor: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 26 10:28:00 2024 +0200 fix sprites on avatar customization commit35f993d055Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 26 09:18:41 2024 +0200 fix hover icons commit28fc80115eAuthor: Phillip Thelen <phillip@habitica.com> Date: Tue Jun 11 16:50:37 2024 +0200 remove console commitb041c67679Author: Phillip Thelen <phillip@habitica.com> Date: Tue Jun 11 15:18:44 2024 +0200 more lint fixes commitf4261d0440Author: Phillip Thelen <phillip@habitica.com> Date: Tue Jun 11 15:18:16 2024 +0200 fix lint commit878ee8f77bAuthor: Phillip Thelen <phillip@habitica.com> Date: Tue Jun 11 13:23:08 2024 +0200 support gifs commitaac24715aaAuthor: Phillip Thelen <phillip@habitica.com> Date: Tue Jun 11 13:15:52 2024 +0200 move avatar customization to sprites commitf4d3663130Author: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 7 17:25:19 2024 +0200 Move more sprites out of css commit6e6b4c981aAuthor: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 7 16:59:30 2024 +0200 add new sprite to item and shopItem component commit8712413f5dAuthor: Phillip Thelen <phillip@habitica.com> Date: Fri Jun 7 16:37:24 2024 +0200 use new sprites for pets list commit1172893826Author: Phillip Thelen <phillip@habitica.com> Date: Wed Jun 5 09:43:51 2024 +0200 Begin building new system for loading sprites
107 lines
3.0 KiB
JavaScript
107 lines
3.0 KiB
JavaScript
import gulp from 'gulp';
|
|
import spritesmith from 'gulp.spritesmith';
|
|
import clean from 'rimraf';
|
|
import mergeStream from 'merge-stream';
|
|
import { sync } from 'glob';
|
|
|
|
const IMG_DIST_PATH = 'website/client/src/assets/images/sprites/';
|
|
const CSS_DIST_PATH = 'website/client/src/assets/css/sprites/';
|
|
|
|
function checkForSpecialTreatment (name) {
|
|
const regex = /^hair|skin|beard|mustach|shirt|flower|^headAccessory_special_\w+Ears|^eyewear_special_\w+TopFrame|^eyewear_special_\w+HalfMoon/;
|
|
return name.match(regex) || name === 'head_0';
|
|
}
|
|
|
|
function cssVarMap (sprite) {
|
|
// For hair, skins, beards, etc. we want to output a '.customize-options.WHATEVER' class,
|
|
// which works as a 60x60 image pointing at the proper part of the 90x90 sprite.
|
|
// We set up the custom info here, and the template makes use of it.
|
|
const requiresSpecialTreatment = checkForSpecialTreatment(sprite.name);
|
|
if (requiresSpecialTreatment) {
|
|
sprite.custom = {
|
|
px: {
|
|
offsetX: '-25px',
|
|
offsetY: '-15px',
|
|
width: '60px',
|
|
height: '60px',
|
|
},
|
|
};
|
|
}
|
|
|
|
// even more for shirts
|
|
if (sprite.name.indexOf('shirt') !== -1) {
|
|
sprite.custom.px.offsetX = '-29px';
|
|
sprite.custom.px.offsetY = '-42px';
|
|
}
|
|
|
|
if (sprite.name.indexOf('hair_base') !== -1) {
|
|
const styleArray = sprite.name.split('_').slice(2, 3);
|
|
if (Number(styleArray[0]) > 14) {
|
|
sprite.custom.px.offsetY = '0'; // don't crop updos
|
|
}
|
|
}
|
|
}
|
|
|
|
function filterFile (file) {
|
|
if (file.relative.indexOf('Mount_Icon_') !== -1) {
|
|
return false;
|
|
}
|
|
if (file.path.indexOf('shop/') !== -1) {
|
|
return false;
|
|
}
|
|
if (file.path.indexOf('stable/eggs') !== -1) {
|
|
return false;
|
|
}
|
|
if (file.path.indexOf('stable/food') !== -1) {
|
|
return false;
|
|
}
|
|
if (file.path.indexOf('stable/potions') !== -1) {
|
|
return false;
|
|
}
|
|
if (file.relative.indexOf('shop_') === 0) {
|
|
return false;
|
|
}
|
|
if (file.relative.indexOf('icon_background') === 0) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
async function createSpritesStream (name, src) {
|
|
const stream = mergeStream();
|
|
// need to import this way bc of weird dependency things
|
|
// eslint-disable-next-line global-require
|
|
const filter = require('gulp-filter');
|
|
|
|
const f = filter(filterFile);
|
|
|
|
const spriteData = gulp.src(src)
|
|
.pipe(f)
|
|
.pipe(spritesmith({
|
|
imgName: `spritesmith-${name}.png`,
|
|
cssName: `spritesmith-${name}.css`,
|
|
algorithm: 'binary-tree',
|
|
padding: 1,
|
|
cssTemplate: 'website/raw_sprites/css/css.template.handlebars',
|
|
cssVarMap,
|
|
}));
|
|
|
|
const cssStream = spriteData.css
|
|
.pipe(gulp.dest(CSS_DIST_PATH));
|
|
|
|
stream.add(cssStream);
|
|
|
|
return stream;
|
|
}
|
|
|
|
gulp.task('sprites:main', async () => {
|
|
const mainSrc = sync('habitica-images/**/*.png');
|
|
return createSpritesStream('main', mainSrc);
|
|
});
|
|
|
|
gulp.task('sprites:clean', done => {
|
|
clean(`${IMG_DIST_PATH}spritesmith*,${CSS_DIST_PATH}spritesmith*}`, done);
|
|
});
|
|
|
|
gulp.task('sprites:compile', gulp.series('sprites:clean', 'sprites:main', done => done()));
|