Skip to content

Commit

Permalink
Additional fav world avatar/world export data (#1019)
Browse files Browse the repository at this point in the history
* feat: Additional Favorite Avatar Export Data #984

* feat: Additional Favorite World Export Data #984
  • Loading branch information
Map1en authored Dec 12, 2024
1 parent 615f3e1 commit 1d1651a
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 28 deletions.
100 changes: 72 additions & 28 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19596,43 +19596,58 @@ speechSynthesis.getVoices();
};

$app.methods.updateWorldExportDialog = function () {
var _ = function (str) {
const formatter = function (str) {
if (/[\x00-\x1f,"]/.test(str) === true) {
return `"${str.replace(/"/g, '""')}"`;
}
return str;
};
var lines = ['WorldID,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.worldExportFavoriteGroup) {
API.favoriteWorldGroups.forEach((group) => {
if (this.worldExportFavoriteGroup === group) {
$app.favoriteWorlds.forEach((ref) => {
if (group.key === ref.groupKey) {
lines.push(`${_(ref.id)},${_(ref.name)}`);
lines.push(resText(ref));
}
});
}
});
} else if (this.worldExportLocalFavoriteGroup) {
var favoriteGroup =
const favoriteGroup =
this.localWorldFavorites[this.worldExportLocalFavoriteGroup];
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.favoriteWorlds.forEach((ref1) => {
lines.push(`${_(ref1.id)},${_(ref1.name)}`);
this.favoriteWorlds.forEach((ref) => {
lines.push(resText(ref));
});
for (var i = 0; i < this.localWorldFavoritesList.length; ++i) {
var worldId = this.localWorldFavoritesList[i];
var ref2 = API.cachedWorlds.get(worldId);
if (typeof ref2 !== 'undefined') {
lines.push(`${_(ref2.id)},${_(ref2.name)}`);
for (let i = 0; i < this.localWorldFavoritesList.length; ++i) {
const worldId = this.localWorldFavoritesList[i];
const ref = API.cachedWorlds.get(worldId);
if (typeof ref !== 'undefined') {
lines.push(resText(ref));
}
}
}
Expand Down Expand Up @@ -19825,6 +19840,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 @@ -19835,14 +19860,33 @@ 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 @@ -19851,31 +19895,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
6 changes: 6 additions & 0 deletions html/src/mixins/dialogs/favoritesDialog.pug
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ mixin favoritesDialog()

//- dialog: export world list
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="worldExportDialogRef" :visible.sync="worldExportDialogVisible" :title="$t('dialog.world_export.header')" width="650px")
el-checkbox-group(v-model="exportSelectedOptions" @change="updateWorldExportDialog()" 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="worldExportFavoriteGroup") {{ worldExportFavoriteGroup.displayName }} ({{ worldExportFavoriteGroup.count }}/{{ worldExportFavoriteGroup.capacity }}) #[i.el-icon-arrow-down.el-icon--right]
Expand Down Expand Up @@ -106,6 +109,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 1d1651a

Please sign in to comment.