Skip to content

Commit

Permalink
Stickers and Focus view for world (vrcx-team#925)
Browse files Browse the repository at this point in the history
Add required elements for stickers
Add focus view tag for worlds
  • Loading branch information
Nekromateion authored and minunn committed Oct 22, 2024
1 parent c611ca0 commit f0787c8
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 5 deletions.
161 changes: 159 additions & 2 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15644,6 +15644,7 @@ speechSynthesis.getVoices();
},
layout: 'table'
};
$app.data.stickerTable = [];
$app.data.emojiTable = [];
$app.data.VRCPlusIconsTable = [];
$app.data.galleryTable = [];
Expand Down Expand Up @@ -18599,6 +18600,8 @@ speechSynthesis.getVoices();
isQuest: false,
isIos: false,
avatarScalingDisabled: false,
focusViewDisabled: false,
stickersDisabled: false,
inCache: false,
cacheSize: '',
bundleSizes: [],
Expand All @@ -18619,6 +18622,8 @@ speechSynthesis.getVoices();
isQuest: false,
isIos: false,
avatarScalingDisabled: false,
focusViewDisabled: false,
stickersDisabled: false,
inCache: false,
cacheSize: '',
bundleSizes: [],
Expand All @@ -18633,6 +18638,8 @@ speechSynthesis.getVoices();
isQuest: false,
isIos: false,
avatarScalingDisabled: false,
focusViewDisabled: false,
stickersDisabled: false,
inCache: false,
cacheSize: '',
bundleSizes: [],
Expand All @@ -18652,6 +18659,10 @@ speechSynthesis.getVoices();
this.currentInstanceWorld.isIos = isIos;
this.currentInstanceWorld.avatarScalingDisabled =
args.ref?.tags.includes('feature_avatar_scaling_disabled');
this.currentInstanceWorld.focusViewDisabled =
args.ref?.tags.includes('feature_focus_view_disabled');
this.currentInstanceWorld.stickersDisabled =
args.ref?.tags.includes('feature_stickers_disabled');
this.checkVRChatCache(args.ref).then((cacheInfo) => {
if (cacheInfo.Item1 > 0) {
this.currentInstanceWorld.inCache = true;
Expand Down Expand Up @@ -19327,6 +19338,8 @@ speechSynthesis.getVoices();
ref: {},
isFavorite: false,
avatarScalingDisabled: false,
focusViewDisabled: false,
stickersDisabled: false,
rooms: [],
treeData: [],
bundleSizes: [],
Expand Down Expand Up @@ -19368,6 +19381,12 @@ speechSynthesis.getVoices();
D.avatarScalingDisabled = ref.tags?.includes(
'feature_avatar_scaling_disabled'
);
D.focusViewDisabled = ref.tags?.includes(
'feature_focus_view_disabled'
);
D.stickersDisabled = ref.tags?.includes(
'feature_stickers_disabled'
);
$app.applyWorldDialogInstances();
for (var room of D.rooms) {
if ($app.isRealInstance(room.tag)) {
Expand Down Expand Up @@ -19507,6 +19526,8 @@ speechSynthesis.getVoices();
D.timeSpent = 0;
D.isFavorite = false;
D.avatarScalingDisabled = false;
D.focusViewDisabled = false;
D.stickersDisabled = false;
D.isPC = false;
D.isQuest = false;
D.isIos = false;
Expand Down Expand Up @@ -19566,6 +19587,12 @@ speechSynthesis.getVoices();
D.avatarScalingDisabled = args.ref?.tags.includes(
'feature_avatar_scaling_disabled'
);
D.focusViewDisabled = args.ref?.tags.includes(
'feature_focus_view_disabled'
);
D.stickersDisabled = args.ref?.tags.includes(
'feature_stickers_disabled'
);
D.isPC = isPC;
D.isQuest = isQuest;
D.isIos = isIos;
Expand Down Expand Up @@ -21392,6 +21419,8 @@ speechSynthesis.getVoices();
contentTags: [],
debugAllowed: false,
avatarScalingDisabled: false,
focusViewDisabled: false,
stickersDisabled: false,
contentHorror: false,
contentGore: false,
contentViolence: false,
Expand All @@ -21405,6 +21434,8 @@ speechSynthesis.getVoices();
D.visible = true;
D.debugAllowed = false;
D.avatarScalingDisabled = false;
D.focusViewDisabled = false;
D.stickersDisabled = false;
D.contentHorror = false;
D.contentGore = false;
D.contentViolence = false;
Expand Down Expand Up @@ -21443,6 +21474,12 @@ speechSynthesis.getVoices();
case 'feature_avatar_scaling_disabled':
D.avatarScalingDisabled = true;
break;
case 'feature_focus_view_disabled':
D.focusViewDisabled = true;
break;
case 'feature_stickers_disabled':
D.stickersDisabled = true;
break;
}
});
D.authorTags = authorTags.toString();
Expand Down Expand Up @@ -21495,6 +21532,12 @@ speechSynthesis.getVoices();
if (D.avatarScalingDisabled) {
tags.unshift('feature_avatar_scaling_disabled');
}
if (D.focusViewDisabled) {
tags.unshift('feature_focus_view_disabled');
}
if (D.stickersDisabled) {
tags.unshift('feature_stickers_disabled');
}
API.saveWorld({
id: this.worldDialog.id,
tags
Expand Down Expand Up @@ -25657,6 +25700,8 @@ speechSynthesis.getVoices();
$app.data.galleryDialogVisible = false;
$app.data.galleryDialogGalleryLoading = false;
$app.data.galleryDialogIconsLoading = false;
$app.data.galleryDialogEmojisLoading = false;
$app.data.galleryDialogStickersLoading = false;

API.$on('LOGIN', function () {
$app.galleryTable = [];
Expand All @@ -25668,6 +25713,7 @@ speechSynthesis.getVoices();
this.refreshGalleryTable();
this.refreshVRCPlusIconsTable();
this.refreshEmojiTable();
this.refreshStickerTable();
workerTimers.setTimeout(() => this.setGalleryTab(pageNum), 100);
};

Expand Down Expand Up @@ -25820,6 +25866,117 @@ speechSynthesis.getVoices();
}
});

// #endregion
// #endregion
// #region | Sticker
API.$on('LOGIN', function () {
$app.stickerTable = [];
});

$app.methods.refreshStickerTable = function () {
this.galleryDialogStickersLoading = true;
var params = {
n: 100,
tag: 'sticker'
};
API.getFileList(params);
};

API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'sticker') {
$app.stickerTable = args.json.reverse();
$app.galleryDialogStickersLoading = false;
}
});

$app.methods.deleteSticker = function (fileId) {
API.deleteFile(fileId).then((args) => {
API.$emit('STICKER:DELETE', args);
return args;
});
};

API.$on('STICKER:DELETE', function (args) {
var array = $app.stickerTable;
var { length } = array;
for (var i = 0; i < length; ++i) {
if (args.fileId === array[i].id) {
array.splice(i, 1);
break;
}
}
});

$app.methods.onFileChangeSticker = function (e) {
var clearFile = function () {
if (document.querySelector('#StickerUploadButton')) {
document.querySelector('#StickerUploadButton').value = '';
}
};
var files = e.target.files || e.dataTransfer.files;
if (!files.length) {
return;
}
if (files[0].size >= 100000000) {
// 100MB
$app.$message({
message: 'File size too large',
type: 'error'
});
clearFile();
return;
}
if (!files[0].type.match(/image.*/)) {
$app.$message({
message: "File isn't an image",
type: 'error'
});
clearFile();
return;
}
var r = new FileReader();
r.onload = function () {
var params = {
tag: 'sticker',
maskTag: 'square'
};
var base64Body = btoa(r.result);
API.uploadSticker(base64Body, params).then((args) => {
$app.$message({
message: 'Sticker uploaded',
type: 'success'
});
return args;
});
};
r.readAsBinaryString(files[0]);
clearFile();
};

$app.methods.displayStickerUpload = function () {
document.getElementById('StickerUploadButton').click();
};

API.uploadSticker = function (imageData, params) {
return this.call('file/image', {
uploadImage: true,
postData: JSON.stringify(params),
imageData
}).then((json) => {
var args = {
json,
params
};
this.$emit('STICKER:ADD', args);
return args;
});
};

API.$on('STICKER:ADD', function (args) {
if (Object.keys($app.stickerTable).length !== 0) {
$app.stickerTable.unshift(args.json);
}
});
// #endregion
// #region | Emoji

Expand All @@ -25828,7 +25985,7 @@ speechSynthesis.getVoices();
});

$app.methods.refreshEmojiTable = function () {
this.galleryDialogIconsLoading = true;
this.galleryDialogEmojisLoading = true;
var params = {
n: 100,
tag: 'emoji'
Expand All @@ -25839,7 +25996,7 @@ speechSynthesis.getVoices();
API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'emoji') {
$app.emojiTable = args.json.reverse();
$app.galleryDialogIconsLoading = false;
$app.galleryDialogEmojisLoading = false;
}
});

Expand Down
23 changes: 22 additions & 1 deletion html/src/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ html
el-tag.x-tag-platform-ios(v-if="worldDialog.isIos" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") iOS
span.x-grey(v-if="worldDialog.bundleSizes['ios']" style="margin-left:5px;border-left:inherit;padding-left:5px") {{ worldDialog.bundleSizes['ios'].fileSize }}
el-tag(v-if="worldDialog.avatarScalingDisabled" type="warning" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") {{ $t('dialog.world.tags.avatar_scaling_disabled') }}
el-tag(v-if="worldDialog.focusViewDisabled" type="warning" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") {{ $t('dialog.world.tags.focus_view_disabled') }}
el-tag(v-if="worldDialog.stickersDisabled" type="warning" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") {{ $t('dialog.world.tags.stickers_disabled') }}
el-tag(v-if="worldDialog.ref.unityPackageUrl" type="success" effect="plain" size="mini" style="margin-right:5px;margin-top:5px") {{ $t('dialog.world.tags.future_proofing') }}
el-tag.x-link(v-if="worldDialog.inCache" type="info" effect="plain" size="mini" style="margin-right:5px;margin-top:5px" @click="openFolderGeneric(worldDialog.cachePath)")
span(v-text="worldDialog.cacheSize")
Expand Down Expand Up @@ -1658,6 +1660,11 @@ html
//- dialog: Set World Tags
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="setWorldTagsDialog" :visible.sync="setWorldTagsDialog.visible" :title="$t('dialog.set_world_tags.header')" width="400px")
el-checkbox(v-model="setWorldTagsDialog.avatarScalingDisabled") {{ $t('dialog.set_world_tags.avatar_scaling_disabled') }}
br
el-checkbox(v-model="setWorldTagsDialog.focusViewDisabled") {{ $t('dialog.set_world_tags.focus_view_disabled') }}
br
el-checkbox(v-model="setWorldTagsDialog.stickersDisabled") {{ $t('dialog.set_world_tags.stickers_disabled') }}
br
el-checkbox(v-model="setWorldTagsDialog.debugAllowed") {{ $t('dialog.set_world_tags.enable_debugging') }}
div(style='font-size:12px;margin-top:10px')
| {{ $t('dialog.set_world_tags.author_tags') }} #[br]
Expand Down Expand Up @@ -2521,7 +2528,7 @@ html
div(style="float:right;margin-top:5px")
el-button(type="default" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)" size="mini" icon="el-icon-download" circle)
el-button(type="default" @click="deleteVRCPlusIcon(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")
el-tab-pane(v-if="galleryDialogVisible" v-loading="galleryDialogIconsLoading")
el-tab-pane(v-if="galleryDialogVisible" v-loading="galleryDialogEmojisLoading")
span(slot="label") {{ $t('dialog.gallery_icons.emojis') }}
span(style="color:#909399;font-size:12px;margin-left:5px") {{ emojiTable.length }}/9
input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangeEmoji" id="EmojiUploadButton" style="display:none")
Expand Down Expand Up @@ -2562,6 +2569,20 @@ html
div(style="float:right;margin-top:5px")
el-button(type="default" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)" size="mini" icon="el-icon-download" circle)
el-button(type="default" @click="deleteEmoji(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")
el-tab-pane(v-if="galleryDialogVisible" v-loading="galleryDialogStickersLoading")
span(slot="label") {{ $t('dialog.gallery_icons.stickers') }}
span(style="color:#909399;font-size:12px;margin-left:5px") {{ stickerTable.length }}/9
input(type="file" accept="image/png,image/jpg,image/jpeg,image/webp,image/bmp,image/gif" @change="onFileChangeSticker" id="StickerUploadButton" style="display:none")
el-button-group
el-button(type="default" size="small" @click="refreshStickerTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }}
el-button(type="default" size="small" @click="displayStickerUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }}
br
.x-friend-item(v-if="image.versions && image.versions.length > 0" v-for="image in stickerTable" :key="image.id" style="display:inline-block;margin-top:10px;width:unset;cursor:default")
.vrcplus-icon(v-if="image.versions[image.versions.length - 1].file.url" style="overflow:hidden" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)")
img.avatar(v-lazy="image.versions[image.versions.length - 1].file.url")
div(style="float:right;margin-top:5px")
el-button(type="default" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)" size="mini" icon="el-icon-download" circle)
el-button(type="default" @click="deleteSticker(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")

//- dialog Table: Previous Instances User
el-dialog.x-dialog(:before-close="beforeDialogClose" @mousedown.native="dialogMouseDown" @mouseup.native="dialogMouseUp" ref="previousInstancesUserDialog" :visible.sync="previousInstancesUserDialog.visible" :title="$t('dialog.previous_instances.header')" width="1000px")
Expand Down
9 changes: 7 additions & 2 deletions html/src/localization/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"v_bucks": "V-Bucks",
"refresh": "Click to refresh",
"logout": "Logout",
"manage_gallery_icon": "Manage Photos/Icons/Emojis",
"manage_gallery_icon": "Manage Photos/Icons/Emojis/Stickers",
"export_friend_list": "Export Friends List",
"export_own_avatars": "Export Own Avatars",
"discord_names": "Discord Names",
Expand Down Expand Up @@ -685,6 +685,8 @@
"public": "Public",
"private": "Private",
"avatar_scaling_disabled": "Avatar Scaling Disabled",
"focus_view_disabled": "Focus View Disabled",
"stickers_disabled": "Stickers Disabled",
"future_proofing": "Future Proofing",
"labs": "Labs",
"cache": "Cache",
Expand Down Expand Up @@ -1035,6 +1037,8 @@
"set_world_tags": {
"header": "Set World Tags",
"avatar_scaling_disabled": "Disable avatar scaling",
"focus_view_disabled": "Disable focus view",
"stickers_disabled": "Disable stickers",
"enable_debugging": "Enable world debugging for others",
"author_tags": "Author Tags (comma separated)",
"content_tags": "Content Warning Tags",
Expand Down Expand Up @@ -1243,11 +1247,12 @@
"send": "Send"
},
"gallery_icons": {
"header": "Photos, Icons and Emojis",
"header": "Photos, Icons, Emojis and Stickers",
"description": "Recommended image size: 1200x900px (4:3)",
"gallery": "Photos",
"icons": "Icons",
"emojis": "Emojis",
"stickers": "Stickers",
"refresh": "Refresh",
"upload": "Upload",
"clear": "Clear",
Expand Down

0 comments on commit f0787c8

Please sign in to comment.