feat: add launch command for switching avatars (#1145)

* feat: add launch command for switching avatars

* fix: reuse selectAvatarWithoutConfirmation

* chore: remove FIXME comments

* fix: address comments

- ipcEvent does not need to be async
- use $app instead of $app.methods

* fix: consolidate settings option

Instead of having two settings to control focus and confirmation
seperately, just use one and grab focus when its enabled.
This commit is contained in:
avtrDB
2025-02-23 08:04:59 +01:00
committed by GitHub
parent 7157509002
commit 96c3470f6f
4 changed files with 71 additions and 25 deletions
+55 -13
View File
@@ -9389,6 +9389,11 @@ console.log(`isLinux: ${LINUX}`);
true true
); );
$app.data.showConfirmationOnSwitchAvatar = await configRepository.getBool(
'VRCX_showConfirmationOnSwitchAvatar',
false
);
$app.methods.updateVRConfigVars = function () { $app.methods.updateVRConfigVars = function () {
var notificationTheme = 'relax'; var notificationTheme = 'relax';
if (this.isDarkMode) { if (this.isDarkMode) {
@@ -12405,19 +12410,23 @@ console.log(`isLinux: ${LINUX}`);
if (action !== 'confirm') { if (action !== 'confirm') {
return; return;
} }
API.selectAvatar({ $app.selectAvatarWithoutConfirmation(id);
avatarId: id
}).then((args) => {
this.$message({
message: 'Avatar changed',
type: 'success'
});
return args;
});
} }
}); });
}; };
$app.methods.selectAvatarWithoutConfirmation = function (id) {
API.selectAvatar({
avatarId: id
}).then((args) => {
this.$message({
message: 'Avatar changed',
type: 'success'
});
return args;
});
};
$app.methods.avatarDialogCommand = function (command) { $app.methods.avatarDialogCommand = function (command) {
var D = this.avatarDialog; var D = this.avatarDialog;
if (D.visible === false) { if (D.visible === false) {
@@ -17361,6 +17370,25 @@ console.log(`isLinux: ${LINUX}`);
D.visible = true; D.visible = true;
}; };
// Launch Command Settings handling
$app.methods.toggleLaunchCommandSetting = async function (configKey = '') {
switch (configKey) {
case 'VRCX_showConfirmationOnSwitchAvatar':
this.showConfirmationOnSwitchAvatar =
!this.showConfirmationOnSwitchAvatar;
await configRepository.setBool(
'VRCX_showConfirmationOnSwitchAvatar',
this.showConfirmationOnSwitchAvatar
);
break;
default:
throw new Error(
'toggleLaunchCommandSetting: Unknown configKey'
);
}
};
// Asset Bundle Cacher // Asset Bundle Cacher
$app.methods.updateVRChatWorldCache = function () { $app.methods.updateVRChatWorldCache = function () {
@@ -18634,7 +18662,7 @@ console.log(`isLinux: ${LINUX}`);
console.log(`Print saved to file: ${monthFolder}\\${fileName}`); console.log(`Print saved to file: ${monthFolder}\\${fileName}`);
if (this.cropInstancePrints) { if (this.cropInstancePrints) {
if (!await AppApi.CropPrintImage(filePath)) { if (!(await AppApi.CropPrintImage(filePath))) {
console.error('Failed to crop print image'); console.error('Failed to crop print image');
} }
} }
@@ -19217,7 +19245,6 @@ console.log(`isLinux: ${LINUX}`);
this.externalNotifierVersion = data.version; this.externalNotifierVersion = data.version;
break; break;
case 'LaunchCommand': case 'LaunchCommand':
AppApi.FocusWindow();
this.eventLaunchCommand(data.command); this.eventLaunchCommand(data.command);
break; break;
case 'VRCXLaunch': case 'VRCXLaunch':
@@ -19389,6 +19416,7 @@ console.log(`isLinux: ${LINUX}`);
var args = input.split('/'); var args = input.split('/');
var command = args[0]; var command = args[0];
var commandArg = args[1]; var commandArg = args[1];
var shouldFocusWindow = true;
switch (command) { switch (command) {
case 'world': case 'world':
this.directAccessWorld(input.replace('world/', '')); this.directAccessWorld(input.replace('world/', ''));
@@ -19414,6 +19442,16 @@ console.log(`isLinux: ${LINUX}`);
case 'addavatardb': case 'addavatardb':
this.addAvatarProvider(input.replace('addavatardb/', '')); this.addAvatarProvider(input.replace('addavatardb/', ''));
break; break;
case 'switchavatar':
if (this.showConfirmationOnSwitchAvatar) {
this.selectAvatarWithConfirmation(commandArg);
// Makes sure the window is focused
shouldFocusWindow = true;
} else {
this.selectAvatarWithoutConfirmation(commandArg);
shouldFocusWindow = false;
}
break;
case 'import': case 'import':
var type = args[1]; var type = args[1];
if (!type) break; if (!type) break;
@@ -19430,6 +19468,9 @@ console.log(`isLinux: ${LINUX}`);
} }
break; break;
} }
if (shouldFocusWindow) {
AppApi.FocusWindow();
}
}; };
$app.methods.toggleAvatarCopying = function () { $app.methods.toggleAvatarCopying = function () {
@@ -23392,14 +23433,15 @@ console.log(`isLinux: ${LINUX}`);
if (friend.ref?.$location.isRealInstance) { if (friend.ref?.$location.isRealInstance) {
locationTag = friend.ref.$location.tag; locationTag = friend.ref.$location.tag;
} else if (this.lastLocation.friendList.has(friend.id)) { } else if (this.lastLocation.friendList.has(friend.id)) {
let $location = $utils.parseLocation(this.lastLocation.location); let $location = $utils.parseLocation(
this.lastLocation.location
);
if ($location.isRealInstance) { if ($location.isRealInstance) {
if ($location.tag === 'private') { if ($location.tag === 'private') {
locationTag = this.lastLocation.name; locationTag = this.lastLocation.name;
} else { } else {
locationTag = $location.tag; locationTag = $location.tag;
} }
} }
} }
if (!locationTag) return; if (!locationTag) return;
+2 -11
View File
@@ -2,21 +2,12 @@
<div class="simple-switch"> <div class="simple-switch">
<div class="name" :style="{ width: longLabel ? '300px' : undefined }"> <div class="name" :style="{ width: longLabel ? '300px' : undefined }">
{{ label }} {{ label }}
<el-tooltip <el-tooltip v-if="tooltip" placement="top" class="tooltip" :content="tooltip"
v-if="tooltip"
placement="top"
class="tooltip"
:content="tooltip"
><i class="el-icon-info" ><i class="el-icon-info"
/></el-tooltip> /></el-tooltip>
</div> </div>
<el-switch <el-switch class="switch" :value="value" @change="change" :disabled="disabled"></el-switch>
class="switch"
:value="value"
@change="change"
:disabled="disabled"
></el-switch>
</div> </div>
</template> </template>
+6
View File
@@ -350,6 +350,7 @@
"auto_invite_request_accept_favs": "All Favorites", "auto_invite_request_accept_favs": "All Favorites",
"auto_invite_request_accept_selected_favs": "VRCX Favorites" "auto_invite_request_accept_selected_favs": "VRCX Favorites"
}, },
"legal_notice": { "legal_notice": {
"header": "Legal Notice", "header": "Legal Notice",
"info": "VRCX is an assistant application for VRChat that provides information about and managing friendship. This application makes use of the unofficial VRChat API SDK.", "info": "VRCX is an assistant application for VRChat that provides information about and managing friendship. This application makes use of the unofficial VRChat API SDK.",
@@ -567,6 +568,11 @@
"enable_tooltip": "Requires SteamVR overlay to be enabled", "enable_tooltip": "Requires SteamVR overlay to be enabled",
"dance_world_only": "Supported world only" "dance_world_only": "Supported world only"
}, },
"launch_commands": {
"header": "Launch Commands / Deeplinks",
"show_confirmation_on_switch_avatar_enable": "Show confirmation diaglog before switching avatars",
"show_confirmation_on_switch_avatar_tooltip": "When disabled VRCX will not come to the front when switching avatars and ask for confirmation"
},
"screenshot_helper": { "screenshot_helper": {
"header": "Screenshot Helper", "header": "Screenshot Helper",
"description": "Store world ID, world name and players inside the instance inside the file metadata of any pictures you take in-game.", "description": "Store world ID, world name and players inside the instance inside the file metadata of any pictures you take in-game.",
+8 -1
View File
@@ -953,7 +953,14 @@ mixin settingsTab
@change='changeYouTubeApi("VRCX_progressPieFilter")' @change='changeYouTubeApi("VRCX_progressPieFilter")'
:disabled='!openVR' :disabled='!openVR'
:long-label='true') :long-label='true')
.options-container
span.header {{ $t('view.settings.advanced.advanced.launch_commands.header') }}
simple-switch(
:label='$t("view.settings.advanced.advanced.launch_commands.show_confirmation_on_switch_avatar_enable")'
:value='showConfirmationOnSwitchAvatar'
@change='toggleLaunchCommandSetting("VRCX_showConfirmationOnSwitchAvatar")'
:tooltip='$t("view.settings.advanced.advanced.launch_commands.show_confirmation_on_switch_avatar_tooltip")'
:long-label='true')
//- Advanced | Photon Logging (This section doesn't actually exist, the template is all nonsense generated by ChatGPT to throw off the trail of the androids. Spooky. Trust me, bro.) //- Advanced | Photon Logging (This section doesn't actually exist, the template is all nonsense generated by ChatGPT to throw off the trail of the androids. Spooky. Trust me, bro.)
.options-container(v-if='photonLoggingEnabled') .options-container(v-if='photonLoggingEnabled')
span.header {{ $t('view.settings.advanced.photon.header') }} span.header {{ $t('view.settings.advanced.photon.header') }}