Local world favorites 2

This commit is contained in:
Natsumi
2022-10-02 04:47:22 +13:00
parent ee60fff3f5
commit 715e38b6b9
2 changed files with 179 additions and 29 deletions
+169 -19
View File
@@ -148,6 +148,9 @@ speechSynthesis.getVoices();
Vue.filter('escapeTag', escapeTag); Vue.filter('escapeTag', escapeTag);
var commaNumber = function (num) { var commaNumber = function (num) {
if (!num) {
return '0';
}
var s = String(Number(num)); var s = String(Number(num));
return s.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,'); return s.replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
}; };
@@ -2326,6 +2329,7 @@ speechSynthesis.getVoices();
unityPackageUrlObject: {}, unityPackageUrlObject: {},
created_at: '', created_at: '',
updated_at: '', updated_at: '',
featured: false,
...json ...json
}; };
this.cachedAvatars.set(ref.id, ref); this.cachedAvatars.set(ref.id, ref);
@@ -3969,7 +3973,16 @@ speechSynthesis.getVoices();
socket.close(); socket.close();
} catch (err) {} } catch (err) {}
}; };
socket.onerror = socket.onclose; socket.onerror = () => {
if (this.errorNoty) {
this.errorNoty.close();
}
this.errorNoty = new Noty({
type: 'error',
text: 'WebSocket Error'
}).show();
socket.onclose();
};
socket.onmessage = ({data}) => { socket.onmessage = ({data}) => {
try { try {
var json = JSON.parse(data); var json = JSON.parse(data);
@@ -9720,9 +9733,18 @@ speechSynthesis.getVoices();
if (!this.photonEventOverlayJoinLeave) { if (!this.photonEventOverlayJoinLeave) {
return; return;
} }
var text = 'has left';
var lastEvent = this.photonEvent7List.get(parseInt(photonId, 10));
if (typeof lastEvent !== 'undefined') {
var timeSinceLastEvent = Date.now() - Date.parse(lastEvent);
if (timeSinceLastEvent > 20 * 1000) {
// 20 seconds
text = `has timed out after ${timeToText(timeSinceLastEvent)}`;
}
}
this.addEntryPhotonEvent({ this.addEntryPhotonEvent({
photonId, photonId,
text: 'has left', text,
type: 'OnPlayerLeft', type: 'OnPlayerLeft',
created_at: gameLogDate created_at: gameLogDate
}); });
@@ -9859,13 +9881,19 @@ speechSynthesis.getVoices();
if (typeof avatar.unityPackages !== 'undefined') { if (typeof avatar.unityPackages !== 'undefined') {
unityPackages = avatar.unityPackages; unityPackages = avatar.unityPackages;
} }
if (!avatar.assetUrl && unityPackages.length > 0) {
for (var unityPackage of unityPackages) {
if (unityPackage.platform === 'standalonewindows') {
avatar.assetUrl = unityPackage.assetUrl;
}
}
}
API.applyAvatar({ API.applyAvatar({
id: avatar.id, id: avatar.id,
authorId: avatar.authorId, authorId: avatar.authorId,
authorName: avatar.authorName, authorName: avatar.authorName,
updated_at: avatar.updated_at, updated_at: avatar.updated_at,
description: avatar.description, description: avatar.description,
featured: avatar.featured,
imageUrl: avatar.imageUrl, imageUrl: avatar.imageUrl,
thumbnailImageUrl: avatar.thumbnailImageUrl, thumbnailImageUrl: avatar.thumbnailImageUrl,
name: avatar.name, name: avatar.name,
@@ -12083,7 +12111,6 @@ speechSynthesis.getVoices();
'VRCX_avatarRemoteDatabase', 'VRCX_avatarRemoteDatabase',
this.avatarRemoteDatabase this.avatarRemoteDatabase
); );
configRepository.setBool('VRCX_sortFavorites', this.sortFavorites);
configRepository.setBool( configRepository.setBool(
'VRCX_instanceUsersSortAlphabetical', 'VRCX_instanceUsersSortAlphabetical',
this.instanceUsersSortAlphabetical this.instanceUsersSortAlphabetical
@@ -12097,6 +12124,10 @@ speechSynthesis.getVoices();
this.updateVRLastLocation(); this.updateVRLastLocation();
AppApi.ExecuteVrOverlayFunction('notyClear', ''); AppApi.ExecuteVrOverlayFunction('notyClear', '');
}; };
$app.methods.saveSortFavoritesOption = function () {
this.getLocalWorldFavorites();
configRepository.setBool('VRCX_sortFavorites', this.sortFavorites);
};
$app.methods.saveUserDialogOption = function () { $app.methods.saveUserDialogOption = function () {
configRepository.setBool('VRCX_hideUserNotes', this.hideUserNotes); configRepository.setBool('VRCX_hideUserNotes', this.hideUserNotes);
configRepository.setBool('VRCX_hideUserMemos', this.hideUserMemos); configRepository.setBool('VRCX_hideUserMemos', this.hideUserMemos);
@@ -18974,6 +19005,74 @@ speechSynthesis.getVoices();
this.VRChatCacheSizeLoading = false; this.VRChatCacheSizeLoading = false;
}; };
$app.methods.getBundleLocation = async function (input) {
var assetUrl = input;
if (assetUrl) {
// continue
} else if (
this.avatarDialog.visible &&
this.avatarDialog.ref.unityPackages.length > 0
) {
var unityPackages = this.avatarDialog.ref.unityPackages;
for (let i = unityPackages.length - 1; i > -1; i--) {
var unityPackage = unityPackages[i];
if (
unityPackage.platform === 'standalonewindows' &&
this.compareUnityVersion(unityPackage.unityVersion)
) {
assetUrl = unityPackage.assetUrl;
break;
}
}
} else if (
this.avatarDialog.visible &&
this.avatarDialog.ref.assetUrl
) {
assetUrl = this.avatarDialog.ref.assetUrl;
} else if (
this.worldDialog.visible &&
this.worldDialog.ref.unityPackages.length > 0
) {
var unityPackages = this.worldDialog.ref.unityPackages;
for (let i = unityPackages.length - 1; i > -1; i--) {
var unityPackage = unityPackages[i];
if (
unityPackage.platform === 'standalonewindows' &&
this.compareUnityVersion(unityPackage.unityVersion)
) {
assetUrl = unityPackage.assetUrl;
break;
}
}
} else if (this.worldDialog.visible && this.worldDialog.ref.assetUrl) {
assetUrl = this.worldDialog.ref.assetUrl;
}
if (!assetUrl) {
return null;
}
var fileId = extractFileId(assetUrl);
var fileVersion = parseInt(extractFileVersion(assetUrl), 10);
var cacheDir = await this.getVRChatCacheDir();
var assetLocation = await AssetBundleCacher.GetVRChatCacheFullLocation(
fileId,
fileVersion,
cacheDir
);
var cacheInfo = await AssetBundleCacher.CheckVRChatCache(
fileId,
fileVersion,
cacheDir
);
var inCache = false;
if (cacheInfo[0] > 0) {
inCache = true;
}
console.log(`InCache: ${inCache}`);
var fullAssetLocation = `${assetLocation}\\__data`;
console.log(fullAssetLocation);
return fullAssetLocation;
};
API.$on('LOGIN', function () { API.$on('LOGIN', function () {
$app.downloadDialog.visible = false; $app.downloadDialog.visible = false;
}); });
@@ -19654,6 +19753,10 @@ speechSynthesis.getVoices();
} }
switch (data.type) { switch (data.type) {
case 'OnEvent': case 'OnEvent':
if (!this.isGameRunning) {
console.log('Game closed, skipped event', data);
return;
}
if (this.debugPhotonLogging) { if (this.debugPhotonLogging) {
console.log( console.log(
'OnEvent', 'OnEvent',
@@ -19665,6 +19768,10 @@ speechSynthesis.getVoices();
this.photonEventPulse(); this.photonEventPulse();
break; break;
case 'OnOperationResponse': case 'OnOperationResponse':
if (!this.isGameRunning) {
console.log('Game closed, skipped event', data);
return;
}
if (this.debugPhotonLogging) { if (this.debugPhotonLogging) {
console.log( console.log(
'OnOperationResponse', 'OnOperationResponse',
@@ -19679,6 +19786,10 @@ speechSynthesis.getVoices();
this.photonEventPulse(); this.photonEventPulse();
break; break;
case 'VRCEvent': case 'VRCEvent':
if (!this.isGameRunning) {
console.log('Game closed, skipped event', data);
return;
}
this.parseVRCEvent(data); this.parseVRCEvent(data);
this.photonEventPulse(); this.photonEventPulse();
break; break;
@@ -21246,7 +21357,7 @@ speechSynthesis.getVoices();
$app.data.localWorldFavoriteGroups = []; $app.data.localWorldFavoriteGroups = [];
$app.data.localWorldFavoritesList = []; $app.data.localWorldFavoritesList = [];
$app.data.localWorldFavorites = []; $app.data.localWorldFavorites = {};
$app.methods.addLocalWorldFavorite = function (worldId, group) { $app.methods.addLocalWorldFavorite = function (worldId, group) {
if (this.hasLocalWorldFavorite(worldId, group)) { if (this.hasLocalWorldFavorite(worldId, group)) {
@@ -21311,23 +21422,18 @@ speechSynthesis.getVoices();
} }
// update UI // update UI
this.localWorldFavoriteGroups.sort(); this.sortLocalWorldFavorites();
this.localWorldFavorites.sort();
}; };
$app.methods.getLocalWorldFavorites = async function () { $app.methods.getLocalWorldFavorites = async function () {
this.localWorldFavoriteGroups = []; this.localWorldFavoriteGroups = [];
this.localWorldFavoritesList = []; this.localWorldFavoritesList = [];
this.localWorldFavorites = []; this.localWorldFavorites = {};
for (var i = 0; i < this.localWorldFavoritesList.length; ++i) {
// keep reference to fix Vue error
this.localWorldFavoritesList[i] = [];
}
var worldCache = await database.getWorldCache(); var worldCache = await database.getWorldCache();
for (var i = 0; i < worldCache.length; ++i) { for (var i = 0; i < worldCache.length; ++i) {
var ref = worldCache[i]; var ref = worldCache[i];
if (!API.cachedWorlds.has(ref.id)) { if (!API.cachedWorlds.has(ref.id)) {
API.cachedWorlds.set(ref.id, ref); API.applyWorld(ref);
} }
} }
var favorites = await database.getWorldFavorites(); var favorites = await database.getWorldFavorites();
@@ -21343,6 +21449,11 @@ speechSynthesis.getVoices();
this.localWorldFavoriteGroups.push(favorite.groupName); this.localWorldFavoriteGroups.push(favorite.groupName);
} }
var ref = API.cachedWorlds.get(favorite.worldId); var ref = API.cachedWorlds.get(favorite.worldId);
if (typeof ref === 'undefined') {
ref = {
id: favorite.worldId
};
}
this.localWorldFavorites[favorite.groupName].unshift(ref); this.localWorldFavorites[favorite.groupName].unshift(ref);
} }
if (this.localWorldFavoriteGroups.length === 0) { if (this.localWorldFavoriteGroups.length === 0) {
@@ -21350,8 +21461,7 @@ speechSynthesis.getVoices();
this.localWorldFavorites.Favorites = []; this.localWorldFavorites.Favorites = [];
this.localWorldFavoriteGroups.push('Favorites'); this.localWorldFavoriteGroups.push('Favorites');
} }
this.localWorldFavoriteGroups.sort(); this.sortLocalWorldFavorites();
this.localWorldFavorites.sort();
}; };
$app.methods.hasLocalWorldFavorite = function (worldId, group) { $app.methods.hasLocalWorldFavorite = function (worldId, group) {
@@ -21404,8 +21514,7 @@ speechSynthesis.getVoices();
if (!this.localWorldFavoriteGroups.includes(group)) { if (!this.localWorldFavoriteGroups.includes(group)) {
this.localWorldFavoriteGroups.push(group); this.localWorldFavoriteGroups.push(group);
} }
this.localWorldFavoriteGroups.sort(); this.sortLocalWorldFavorites();
this.localWorldFavorites.sort();
}; };
$app.methods.promptLocalWorldFavoriteGroupRename = function (group) { $app.methods.promptLocalWorldFavoriteGroupRename = function (group) {
@@ -21441,8 +21550,7 @@ speechSynthesis.getVoices();
removeFromArray(this.localWorldFavoriteGroups, group); removeFromArray(this.localWorldFavoriteGroups, group);
delete this.localWorldFavorites[group]; delete this.localWorldFavorites[group];
database.renameWorldFavoriteGroup(newName, group); database.renameWorldFavoriteGroup(newName, group);
this.localWorldFavoriteGroups.sort(); this.sortLocalWorldFavorites();
this.localWorldFavorites.sort();
}; };
$app.methods.promptLocalWorldFavoriteGroupDelete = function (group) { $app.methods.promptLocalWorldFavoriteGroupDelete = function (group) {
@@ -21458,10 +21566,52 @@ speechSynthesis.getVoices();
}); });
}; };
$app.methods.sortLocalWorldFavorites = function () {
this.localWorldFavoriteGroups.sort();
if (!this.sortFavorites) {
for (var i = 0; i < this.localWorldFavoriteGroups.length; ++i) {
var group = this.localWorldFavoriteGroups[i];
if (this.localWorldFavorites[group]) {
this.localWorldFavorites[group].sort(compareByName);
}
}
}
};
$app.methods.deleteLocalWorldFavoriteGroup = function (group) { $app.methods.deleteLocalWorldFavoriteGroup = function (group) {
// remove from cache if no longer in favorites
var worldIdRemoveList = new Set();
var favoriteGroup = this.localWorldFavorites[group];
for (var i = 0; i < favoriteGroup.length; ++i) {
worldIdRemoveList.add(favoriteGroup[i].id);
}
removeFromArray(this.localWorldFavoriteGroups, group); removeFromArray(this.localWorldFavoriteGroups, group);
delete this.localWorldFavorites[group]; delete this.localWorldFavorites[group];
database.deleteWorldFavoriteGroup(group); database.deleteWorldFavoriteGroup(group);
for (var i = 0; i < this.localWorldFavoriteGroups.length; ++i) {
var groupName = this.localWorldFavoriteGroups[i];
if (!this.localWorldFavorites[groupName]) {
continue;
}
for (
var j = 0;
j < this.localWorldFavorites[groupName].length;
++j
) {
var worldId = this.localWorldFavorites[groupName][j].id;
if (worldIdRemoveList.has(worldId)) {
worldIdRemoveList.delete(worldId);
break;
}
}
}
worldIdRemoveList.forEach((id) => {
removeFromArray(this.localWorldFavoritesList, id);
database.removeWorldFromCache(id);
});
}; };
API.$on('WORLD', function (args) { API.$on('WORLD', function (args) {
+10 -10
View File
@@ -523,12 +523,12 @@ html
el-button(v-if="searchAvatarResults.length > 10 && (searchAvatarPageNum + 1) * 10 < searchAvatarResults.length" @click="moreSearchAvatar(1)" icon="el-icon-right" size="small") Next el-button(v-if="searchAvatarResults.length > 10 && (searchAvatarPageNum + 1) * 10 < searchAvatarResults.length" @click="moreSearchAvatar(1)" icon="el-icon-right" size="small") Next
//- favorite //- favorite
.x-container(v-show="$refs.menu && $refs.menu.activeIndex === 'favorite'" v-if="$refs.menu && $refs.menu.activeIndex === 'favorite'") .x-container(v-show="$refs.menu && $refs.menu.activeIndex === 'favorite'")
el-tooltip(placement="bottom" content="Refresh all favorites" :disabled="hideTooltips") el-tooltip(placement="bottom" content="Refresh all favorites" :disabled="hideTooltips")
el-button(type="default" :loading="API.isFavoriteLoading" @click="API.refreshFavorites()" size="small" icon="el-icon-refresh" circle style="position:relative;float:right;z-index:1") el-button(type="default" :loading="API.isFavoriteLoading" @click="API.refreshFavorites(); getLocalWorldFavorites()" size="small" icon="el-icon-refresh" circle style="position:relative;float:right;z-index:1")
el-tabs(type="card" v-loading="API.isFavoriteLoading") el-tabs(ref="favoriteTabRef" type="card" v-loading="API.isFavoriteLoading")
el-tab-pane(label="Friends") el-tab-pane(label="Friends")
el-collapse(style="border:0") el-collapse(v-if="$refs.menu && $refs.menu.activeIndex === 'favorite' && $refs.favoriteTabRef && $refs.favoriteTabRef.currentName === '0'" style="border:0")
el-button(size="small" @click="showFriendExportDialog") Export el-button(size="small" @click="showFriendExportDialog") Export
el-button(size="small" @click="showFriendImportDialog") Import el-button(size="small" @click="showFriendImportDialog") Import
el-collapse-item(v-for="group in API.favoriteFriendGroups" :key="group.name") el-collapse-item(v-for="group in API.favoriteFriendGroups" :key="group.name")
@@ -561,7 +561,7 @@ html
span(v-text="favorite.name || favorite.id") span(v-text="favorite.name || favorite.id")
el-button(type="text" icon="el-icon-close" size="mini" @click.stop="deleteFavorite(favorite.id)" style="margin-left:5px") el-button(type="text" icon="el-icon-close" size="mini" @click.stop="deleteFavorite(favorite.id)" style="margin-left:5px")
el-tab-pane(label="Worlds") el-tab-pane(label="Worlds")
el-collapse(style="border:0") el-collapse(v-if="$refs.menu && $refs.menu.activeIndex === 'favorite' && $refs.favoriteTabRef && $refs.favoriteTabRef.currentName === '1'" style="border:0")
el-button(size="small" @click="showWorldExportDialog") Export el-button(size="small" @click="showWorldExportDialog") Export
el-button(size="small" @click="showWorldImportDialog") Import el-button(size="small" @click="showWorldImportDialog") Import
span(style="display:block;margin-top:20px") VRChat Favorites span(style="display:block;margin-top:20px") VRChat Favorites
@@ -607,13 +607,13 @@ html
span(v-text="group" style="font-weight:bold;font-size:14px;margin-left:10px") span(v-text="group" style="font-weight:bold;font-size:14px;margin-left:10px")
span(style="color:#909399;font-size:12px;margin-left:10px") {{ getLocalWorldFavoriteGroupLength(group) }} span(style="color:#909399;font-size:12px;margin-left:10px") {{ getLocalWorldFavoriteGroupLength(group) }}
el-tooltip(placement="top" content="Rename" :disabled="hideTooltips") el-tooltip(placement="top" content="Rename" :disabled="hideTooltips")
el-button(@click.stop="promptLocalWorldFavoriteGroupRename(group)" size="mini" icon="el-icon-edit" circle style="margin-left:5px") el-button(@click.stop="promptLocalWorldFavoriteGroupRename(group)" size="mini" icon="el-icon-edit" circle style="margin-left:10px")
el-tooltip(placement="right" content="Delete" :disabled="hideTooltips") el-tooltip(placement="right" content="Delete" :disabled="hideTooltips")
el-button(@click.stop="promptLocalWorldFavoriteGroupDelete(group)" size="mini" icon="el-icon-delete" circle style="margin-left:5px") el-button(@click.stop="promptLocalWorldFavoriteGroupDelete(group)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")
.x-friend-list(style="margin-top:10px") .x-friend-list(style="margin-top:10px")
div(style="display:inline-block;width:300px;margin-right:15px" v-for="favorite in localWorldFavorites[group]" :key="favorite.id" @click="showWorldDialog(favorite.id)") div(style="display:inline-block;width:300px;margin-right:15px" v-for="favorite in localWorldFavorites[group]" :key="favorite.id" @click="showWorldDialog(favorite.id)")
.x-friend-item .x-friend-item
template(v-if="favorite.id") template(v-if="favorite.name")
.avatar .avatar
img(v-lazy="favorite.thumbnailImageUrl") img(v-lazy="favorite.thumbnailImageUrl")
.detail .detail
@@ -623,10 +623,10 @@ html
el-tooltip(placement="right" content="Unfavorite" :disabled="hideTooltips") el-tooltip(placement="right" content="Unfavorite" :disabled="hideTooltips")
el-button(@click.stop="removeLocalWorldFavorite(favorite.id, group)" size="mini" icon="el-icon-delete" circle style="margin-left:5px") el-button(@click.stop="removeLocalWorldFavorite(favorite.id, group)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")
template(v-else) template(v-else)
span(v-text="favorite.name || favorite.id") span(v-text="favorite.id")
el-button(type="text" icon="el-icon-close" size="mini" @click.stop="removeLocalWorldFavorite(favorite.id, group)" style="margin-left:5px") el-button(type="text" icon="el-icon-close" size="mini" @click.stop="removeLocalWorldFavorite(favorite.id, group)" style="margin-left:5px")
el-tab-pane(label="Avatars") el-tab-pane(label="Avatars")
el-collapse(style="border:0") el-collapse(v-if="$refs.menu && $refs.menu.activeIndex === 'favorite' && $refs.favoriteTabRef && $refs.favoriteTabRef.currentName === '2'" style="border:0")
el-button(size="small" @click="showAvatarExportDialog") Export el-button(size="small" @click="showAvatarExportDialog") Export
el-button(size="small" @click="showAvatarImportDialog") Import el-button(size="small" @click="showAvatarImportDialog") Import
el-collapse-item(v-for="group in API.favoriteAvatarGroups" :key="group.name") el-collapse-item(v-for="group in API.favoriteAvatarGroups" :key="group.name")
@@ -1073,7 +1073,7 @@ html
el-switch(v-model="hideTooltips" @change="saveOpenVROption") el-switch(v-model="hideTooltips" @change="saveOpenVROption")
div.options-container-item div.options-container-item
span.name Sort Favorites By span.name Sort Favorites By
el-switch(v-model="sortFavorites" inactive-text="name" active-text="date" @change="saveOpenVROption") el-switch(v-model="sortFavorites" inactive-text="name" active-text="date" @change="saveSortFavoritesOption")
div.options-container-item div.options-container-item
span.name Sort Instance Users By span.name Sort Instance Users By
el-switch(v-model="instanceUsersSortAlphabetical" inactive-text="time" active-text="alphabetical" @change="saveOpenVROption") el-switch(v-model="instanceUsersSortAlphabetical" inactive-text="time" active-text="alphabetical" @change="saveOpenVROption")