Skip to content

Commit

Permalink
feat: Additional Favorite Avatar Export Data vrcx-team#984
Browse files Browse the repository at this point in the history
  • Loading branch information
Map1en committed Dec 10, 2024
1 parent 9b24516 commit aa45692
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
56 changes: 42 additions & 14 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19811,6 +19811,16 @@ speechSynthesis.getVoices();
$app.data.avatarExportFavoriteGroup = null;
$app.data.avatarExportLocalFavoriteGroup = null;

// Storage of selected filtering options for model and world export
$app.data.exportSelectedOptions = ['ID','Name'];
$app.data.exportSelectOptions = [
{ label: 'ID', value: 'id' },
{ label: 'Name', value: 'name' },
{ label: 'Author ID', value: 'authorId' },
{ label: 'Author Name', value: 'authorName' },
{ label: 'Thumbnail', value: 'thumbnailImageUrl' }
];

$app.methods.showAvatarExportDialog = function () {
this.$nextTick(() =>
$app.adjustDialogZ(this.$refs.avatarExportDialogRef.$el)
Expand All @@ -19821,14 +19831,32 @@ speechSynthesis.getVoices();
this.avatarExportDialogVisible = true;
};

/**
* Update the content of the avatar export dialog based on the selected options
*/

$app.methods.updateAvatarExportDialog = function () {
var _ = function (str) {
const formatter = function (str) {
if (/[\x00-\x1f,"]/.test(str) === true) {
return `"${str.replace(/"/g, '""')}"`;
}
return str;
};
var lines = ['AvatarID,Name'];

function resText (ref) {
let resArr = []
propsForQuery.forEach((e) => {
resArr.push(formatter(ref.ref[e]))
});
return resArr.join(",")
}

const lines = [this.exportSelectedOptions.join(",")]
const propsForQuery =
this.exportSelectOptions
.filter(option => this.exportSelectedOptions.includes(option.label))
.map(option => option.value)

if (this.avatarExportFavoriteGroup) {
API.favoriteAvatarGroups.forEach((group) => {
if (
Expand All @@ -19837,31 +19865,31 @@ speechSynthesis.getVoices();
) {
$app.favoriteAvatars.forEach((ref) => {
if (group.key === ref.groupKey) {
lines.push(`${_(ref.id)},${_(ref.name)}`);
lines.push(resText(ref));
}
});
}
});
} else if (this.avatarExportLocalFavoriteGroup) {
var favoriteGroup =
const favoriteGroup =
this.localAvatarFavorites[this.avatarExportLocalFavoriteGroup];
if (!favoriteGroup) {
return;
}
for (var i = 0; i < favoriteGroup.length; ++i) {
var ref = favoriteGroup[i];
lines.push(`${_(ref.id)},${_(ref.name)}`);
for (let i = 0; i < favoriteGroup.length; ++i) {
const ref = favoriteGroup[i];
lines.push(resText(ref));
}
} else {
// export all
this.favoriteAvatars.forEach((ref1) => {
lines.push(`${_(ref1.id)},${_(ref1.name)}`);
this.favoriteAvatars.forEach((ref) => {
lines.push(resText(ref));
});
for (var i = 0; i < this.localAvatarFavoritesList.length; ++i) {
var avatarId = this.localAvatarFavoritesList[i];
var ref2 = API.cachedAvatars.get(avatarId);
if (typeof ref2 !== 'undefined') {
lines.push(`${_(ref2.id)},${_(ref2.name)}`);
for (let i = 0; i < this.localAvatarFavoritesList.length; ++i) {
const avatarId = this.localAvatarFavoritesList[i];
const ref = API.cachedAvatars.get(avatarId);
if (typeof ref !== 'undefined') {
lines.push(resText(ref));
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions html/src/mixins/dialogs/favoritesDialog.pug
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ mixin favoritesDialog()

//- dialog: export avatar list
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="avatarExportDialogRef" :visible.sync="avatarExportDialogVisible" :title="$t('dialog.avatar_export.header')" width="650px")
el-checkbox-group(v-model="exportSelectedOptions" @change="updateAvatarExportDialog()" style="margin-bottom:10px")
template(v-for="option in exportSelectOptions" :key="option.value")
el-checkbox(:label="option.label")
el-dropdown(@click.native.stop trigger="click" size="small")
el-button(size="mini")
span(v-if="avatarExportFavoriteGroup") {{ avatarExportFavoriteGroup.displayName }} ({{ avatarExportFavoriteGroup.count }}/{{ avatarExportFavoriteGroup.capacity }}) #[i.el-icon-arrow-down.el-icon--right]
Expand Down

0 comments on commit aa45692

Please sign in to comment.