mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-02 13:06:08 +02:00
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:
+55
-13
@@ -9389,6 +9389,11 @@ console.log(`isLinux: ${LINUX}`);
|
||||
true
|
||||
);
|
||||
|
||||
$app.data.showConfirmationOnSwitchAvatar = await configRepository.getBool(
|
||||
'VRCX_showConfirmationOnSwitchAvatar',
|
||||
false
|
||||
);
|
||||
|
||||
$app.methods.updateVRConfigVars = function () {
|
||||
var notificationTheme = 'relax';
|
||||
if (this.isDarkMode) {
|
||||
@@ -12405,19 +12410,23 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (action !== 'confirm') {
|
||||
return;
|
||||
}
|
||||
API.selectAvatar({
|
||||
avatarId: id
|
||||
}).then((args) => {
|
||||
this.$message({
|
||||
message: 'Avatar changed',
|
||||
type: 'success'
|
||||
});
|
||||
return args;
|
||||
});
|
||||
$app.selectAvatarWithoutConfirmation(id);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$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) {
|
||||
var D = this.avatarDialog;
|
||||
if (D.visible === false) {
|
||||
@@ -17361,6 +17370,25 @@ console.log(`isLinux: ${LINUX}`);
|
||||
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
|
||||
|
||||
$app.methods.updateVRChatWorldCache = function () {
|
||||
@@ -18634,7 +18662,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
console.log(`Print saved to file: ${monthFolder}\\${fileName}`);
|
||||
|
||||
if (this.cropInstancePrints) {
|
||||
if (!await AppApi.CropPrintImage(filePath)) {
|
||||
if (!(await AppApi.CropPrintImage(filePath))) {
|
||||
console.error('Failed to crop print image');
|
||||
}
|
||||
}
|
||||
@@ -19217,7 +19245,6 @@ console.log(`isLinux: ${LINUX}`);
|
||||
this.externalNotifierVersion = data.version;
|
||||
break;
|
||||
case 'LaunchCommand':
|
||||
AppApi.FocusWindow();
|
||||
this.eventLaunchCommand(data.command);
|
||||
break;
|
||||
case 'VRCXLaunch':
|
||||
@@ -19389,6 +19416,7 @@ console.log(`isLinux: ${LINUX}`);
|
||||
var args = input.split('/');
|
||||
var command = args[0];
|
||||
var commandArg = args[1];
|
||||
var shouldFocusWindow = true;
|
||||
switch (command) {
|
||||
case 'world':
|
||||
this.directAccessWorld(input.replace('world/', ''));
|
||||
@@ -19414,6 +19442,16 @@ console.log(`isLinux: ${LINUX}`);
|
||||
case 'addavatardb':
|
||||
this.addAvatarProvider(input.replace('addavatardb/', ''));
|
||||
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':
|
||||
var type = args[1];
|
||||
if (!type) break;
|
||||
@@ -19430,6 +19468,9 @@ console.log(`isLinux: ${LINUX}`);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (shouldFocusWindow) {
|
||||
AppApi.FocusWindow();
|
||||
}
|
||||
};
|
||||
|
||||
$app.methods.toggleAvatarCopying = function () {
|
||||
@@ -23392,14 +23433,15 @@ console.log(`isLinux: ${LINUX}`);
|
||||
if (friend.ref?.$location.isRealInstance) {
|
||||
locationTag = friend.ref.$location.tag;
|
||||
} 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.tag === 'private') {
|
||||
locationTag = this.lastLocation.name;
|
||||
} else {
|
||||
locationTag = $location.tag;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (!locationTag) return;
|
||||
|
||||
Reference in New Issue
Block a user