diff --git a/src/localization/en.json b/src/localization/en.json index 42aa434f..03f3d48e 100644 --- a/src/localization/en.json +++ b/src/localization/en.json @@ -537,20 +537,23 @@ "automation": { "auto_change_status": "Auto Change Status", "auto_state_change_tooltip": "Automatically change status when there are other people in the instance (Alone / Company)", - "alone_condition": "Alone Condition", - "alone": "Alone", - "no_friends": "No Friends", + "alone_condition": "Consider alone when", + "alone": "No other players", + "no_friends": "No friends in instance", "alone_status": "Alone Status", "company_status": "Company Status", - "allowed_instance_types": "Allowed Instance Types", + "allowed_instance_types": "Active in instance types", "instance_type_placeholder": "All Instance Types", "auto_invite_request_accept": "Auto Accept Invite Requests", "auto_invite_request_accept_tooltip": "Automatically accept invite requests from favorite friends", - "auto_invite_request_accept_off": "Off", "auto_invite_request_accept_favs": "All Favorites", "auto_invite_request_accept_selected_favs": "VRCX Favorites", "change_status_description": "Override status description", - "status_description_placeholder": "Status description (max 32 characters)" + "status_description_placeholder": "Status description (max 32 characters)", + "auto_change_status_groups": "Only count friends from", + "auto_change_status_groups_placeholder": "Choose Groups", + "auto_accept_invite_groups": "Only accept from", + "auto_accept_invite_groups_placeholder": "Choose Groups" }, "legal_notice": { "header": "Legal Notice", diff --git a/src/stores/notification.js b/src/stores/notification.js index dc1f2efc..5bce77fe 100644 --- a/src/stores/notification.js +++ b/src/stores/notification.js @@ -247,10 +247,40 @@ export const useNotificationStore = defineStore('Notification', () => { } if ( generalSettingsStore.autoAcceptInviteRequests === - 'Selected Favorites' && - !friendStore.localFavoriteFriends.has(ref.senderUserId) + 'Selected Favorites' ) { - return; + const groups = generalSettingsStore.autoAcceptInviteGroups; + if (groups.length === 0) { + return; + } else { + let found = false; + for (const groupKey of groups) { + if (groupKey.startsWith('local:')) { + const localGroup = groupKey.slice(6); + const localFavs = + favoriteStore.localFriendFavorites.get(localGroup); + if (localFavs && localFavs.has(ref.senderUserId)) { + found = true; + break; + } + } else { + const remoteFavs = + favoriteStore.cachedFavorites.get(groupKey); + if ( + remoteFavs && + remoteFavs.some( + (f) => f.favoriteId === ref.senderUserId + ) + ) { + found = true; + break; + } + } + } + if (!found) { + return; + } + } } if (!checkCanInvite(currentLocation)) { return; diff --git a/src/stores/settings/general.js b/src/stores/settings/general.js index 54c14e1b..647280b7 100644 --- a/src/stores/settings/general.js +++ b/src/stores/settings/general.js @@ -39,7 +39,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { const autoStateChangeAloneDesc = ref(''); const autoStateChangeCompanyDescEnabled = ref(false); const autoStateChangeCompanyDesc = ref(''); + const autoStateChangeGroups = ref([]); const autoAcceptInviteRequests = ref('Off'); + const autoAcceptInviteGroups = ref([]); async function initGeneralSettings() { const [ @@ -64,7 +66,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { autoStateChangeAloneDescConfig, autoStateChangeCompanyDescEnabledConfig, autoStateChangeCompanyDescConfig, - autoAcceptInviteRequestsConfig + autoStateChangeGroupsStrConfig, + autoAcceptInviteRequestsConfig, + autoAcceptInviteGroupsStrConfig ] = await Promise.all([ configRepository.getBool('VRCX_StartAtWindowsStartup', false), VRCXStorage.Get('VRCX_StartAsMinimizedState'), @@ -102,7 +106,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { false ), configRepository.getString('VRCX_autoStateChangeCompanyDesc', ''), - configRepository.getString('VRCX_autoAcceptInviteRequests', 'Off') + configRepository.getString('VRCX_autoStateChangeGroups', '[]'), + configRepository.getString('VRCX_autoAcceptInviteRequests', 'Off'), + configRepository.getString('VRCX_autoAcceptInviteGroups', '[]') ]); isStartAtWindowsStartup.value = isStartAtWindowsStartupConfig; @@ -146,7 +152,13 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { autoStateChangeCompanyDescEnabled.value = autoStateChangeCompanyDescEnabledConfig; autoStateChangeCompanyDesc.value = autoStateChangeCompanyDescConfig; + autoStateChangeGroups.value = JSON.parse( + autoStateChangeGroupsStrConfig + ); autoAcceptInviteRequests.value = autoAcceptInviteRequestsConfig; + autoAcceptInviteGroups.value = JSON.parse( + autoAcceptInviteGroupsStrConfig + ); } initGeneralSettings(); @@ -322,6 +334,17 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { autoStateChangeCompanyDesc.value ); } + /** + * @param {Array} value + */ + function setAutoStateChangeGroups(value) { + autoStateChangeGroups.value = value; + configRepository.setString( + 'VRCX_autoStateChangeGroups', + JSON.stringify(autoStateChangeGroups.value) + ); + } + /** * @param {string} value */ @@ -333,6 +356,17 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { ); } + /** + * @param {string[]} value + */ + function setAutoAcceptInviteGroups(value) { + autoAcceptInviteGroups.value = value; + configRepository.setString( + 'VRCX_autoAcceptInviteGroups', + JSON.stringify(autoAcceptInviteGroups.value) + ); + } + function promptProxySettings() { // Element Plus: prompt(message, title, options) modalStore @@ -398,7 +432,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { autoStateChangeAloneDesc, autoStateChangeCompanyDescEnabled, autoStateChangeCompanyDesc, + autoStateChangeGroups, autoAcceptInviteRequests, + autoAcceptInviteGroups, setIsStartAtWindowsStartup, setIsStartAsMinimizedState, @@ -420,7 +456,9 @@ export const useGeneralSettingsStore = defineStore('GeneralSettings', () => { setAutoStateChangeAloneDesc, setAutoStateChangeCompanyDescEnabled, setAutoStateChangeCompanyDesc, + setAutoStateChangeGroups, setAutoAcceptInviteRequests, + setAutoAcceptInviteGroups, promptProxySettings }; }); diff --git a/src/stores/user.js b/src/stores/user.js index bada9678..8cf76321 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -1616,7 +1616,39 @@ export const useUserStore = defineStore('User', () => { let withCompany = locationStore.lastLocation.playerList.size > 1; if (generalSettingsStore.autoStateChangeNoFriends) { - withCompany = locationStore.lastLocation.friendList.size >= 1; + const selectedGroups = generalSettingsStore.autoStateChangeGroups; + if (selectedGroups.length > 0) { + const groupFriendIds = new Set(); + for (const ref of favoriteStore.cachedFavorites.values()) { + if ( + ref.type === 'friend' && + selectedGroups.includes(ref.$groupKey) + ) { + groupFriendIds.add(ref.favoriteId); + } + } + for (const selectedKey of selectedGroups) { + if (selectedKey.startsWith('local:')) { + const groupName = selectedKey.slice(6); + const userIds = + favoriteStore.localFriendFavorites[groupName]; + if (userIds) { + for (let i = 0; i < userIds.length; ++i) { + groupFriendIds.add(userIds[i]); + } + } + } + } + withCompany = false; + for (const friendId of locationStore.lastLocation.friendList.keys()) { + if (groupFriendIds.has(friendId)) { + withCompany = true; + break; + } + } + } else { + withCompany = locationStore.lastLocation.friendList.size >= 1; + } } const currentStatus = currentUser.value.status; diff --git a/src/views/Tools/dialogs/AutoChangeStatusDialog.vue b/src/views/Tools/dialogs/AutoChangeStatusDialog.vue index e2bce2ee..447d3756 100644 --- a/src/views/Tools/dialogs/AutoChangeStatusDialog.vue +++ b/src/views/Tools/dialogs/AutoChangeStatusDialog.vue @@ -12,6 +12,93 @@ :tooltip="t('view.settings.general.automation.auto_state_change_tooltip')" @change="setAutoStateChangeEnabled" /> + + {{ t('view.settings.general.automation.alone_condition') }} + + + + + + {{ t('view.settings.general.automation.alone') }} + + + + + + {{ t('view.settings.general.automation.no_friends') }} + + + + + + + + {{ t('view.settings.general.automation.auto_change_status_groups') }} + + + + + + + + + {{ group.displayName }} + + + + + + + {{ group }} + + + + + + + + + + {{ t('view.settings.general.automation.allowed_instance_types') }} + + + + + + + + {{ translateAccessType(instanceType) }} + + + + + + {{ t('view.settings.general.automation.alone_status') }} @@ -96,48 +183,32 @@ - - {{ t('view.settings.general.automation.allowed_instance_types') }} - - - - - - - - {{ instanceType }} - - - - - + + + - {{ t('view.settings.general.automation.alone_condition') }} + {{ t('view.settings.general.automation.auto_invite_request_accept') }} + @update:modelValue="handleAutoAcceptInviteModeChange"> - - - {{ t('view.settings.general.automation.alone') }} + + + {{ t('view.settings.general.automation.auto_invite_request_accept_favs') }} - - - {{ t('view.settings.general.automation.no_friends') }} + + + {{ t('view.settings.general.automation.auto_invite_request_accept_selected_favs') }} @@ -145,32 +216,41 @@ - - {{ t('view.settings.general.automation.auto_invite_request_accept') }} - - - - + {{ t('view.settings.general.automation.auto_accept_invite_groups') }} - - {{ - t('view.settings.general.automation.auto_invite_request_accept_off') - }} - {{ - t('view.settings.general.automation.auto_invite_request_accept_favs') - }} - {{ - t('view.settings.general.automation.auto_invite_request_accept_selected_favs') - }} - + + + + + + + + {{ group.displayName }} + + + + + + + {{ group }} + + + + + @@ -179,18 +259,25 @@