move avatar customization to sprites

This commit is contained in:
Phillip Thelen
2024-06-11 13:15:52 +02:00
parent f4d3663130
commit aac24715aa
2 changed files with 15 additions and 5 deletions
+9 -1
View File
@@ -10,6 +10,9 @@ export default {
imageName: {
type: String,
},
prefix: {
type: String,
},
},
methods: {
imageUrl () {
@@ -17,8 +20,13 @@ export default {
return '';
}
let name = this.imageName;
console.log(this.imageName);
if (name.indexOf(' ') !== -1) {
name = name.split(' ')[1];
const components = name.split(' ');
name = components[components.length - 1];
}
if (this.prefix) {
name = `${this.prefix}_${name}`;
}
return `https://habitica-assets.s3.amazonaws.com/mobileApp/images/${name}.png`;
},
@@ -31,7 +31,7 @@ export const avatarEditorUtilities = { // eslint-disable-line import/prefer-defa
option.key = key;
option.pathKey = pathKey;
option.active = userPreference === key;
option.class = this.createClass(type, subType, key);
option.imageName = this.createImageName(type, subType, key);
option.click = optionParam => (option.gemLocked ? this.unlock(`${optionParam.pathKey}.${key}`) : this.set({ [`preferences.${optionParam.pathKey}`]: optionParam.key }));
return option;
},
@@ -56,8 +56,10 @@ export const avatarEditorUtilities = { // eslint-disable-line import/prefer-defa
return option;
},
createClass (type, subType, key) {
let str = `${type} ${subType} `;
createImageName (type, subType, key) {
let str = '';
console.log(type, subType, key);
switch (type) {
case 'shirt': {
@@ -77,7 +79,7 @@ export const avatarEditorUtilities = { // eslint-disable-line import/prefer-defa
break;
}
case 'skin': {
str += `skin skin_${key}`;
str += `skin_${key}`;
break;
}
default: {