Implement auto state change (#590)

* Implement auto state change

* fix
This commit is contained in:
pypy
2023-07-02 03:56:33 +09:00
committed by GitHub
parent 9d720770c0
commit 21e8b30380
4 changed files with 102 additions and 0 deletions

View File

@@ -5190,6 +5190,7 @@ speechSynthesis.getVoices();
ipcTimeout: 0,
nextClearVRCXCacheCheck: 0,
nextDiscordUpdate: 0,
nextAutoStateChange: 0,
isDiscordActive: false,
isGameRunning: false,
isGameNoVR: configRepository.getBool('isGameNoVR'),
@@ -5400,6 +5401,10 @@ speechSynthesis.getVoices();
this.updateDiscord();
}
}
if (--this.nextAutoStateChange <= 0) {
this.nextAutoStateChange = 7;
this.updateAutoStateChange();
}
}
} catch (err) {
API.isRefreshFriendsLoading = false;
@@ -12405,6 +12410,51 @@ speechSynthesis.getVoices();
}
};
$app.methods.updateAutoStateChange = function () {
if (
!this.isGameRunning ||
!this.lastLocation.playerList.size ||
this.lastLocation.location === '' ||
this.lastLocation.location === 'traveling'
) {
return;
}
const otherPeopleExists = this.lastLocation.playerList.size > 1;
const prevStatus = API.currentUser.status;
let nextStatus = prevStatus;
switch (this.autoStateChange) {
case 'Active or Ask Me':
nextStatus = otherPeopleExists ? 'ask me' : 'active';
break;
case 'Active or Busy':
nextStatus = otherPeopleExists ? 'busy' : 'active';
break;
case 'Join Me or Ask Me':
nextStatus = otherPeopleExists ? 'ask me' : 'join me';
break;
case 'Join Me or Busy':
nextStatus = otherPeopleExists ? 'busy' : 'join me';
break;
case 'Ask Me or Busy':
nextStatus = otherPeopleExists ? 'ask me' : 'busy';
break;
}
if (prevStatus === nextStatus) {
return;
}
API.saveCurrentUser({
status: nextStatus
});
};
$app.methods.lookupUser = async function (ref) {
if (ref.userId) {
this.showUserDialog(ref.userId);
@@ -14262,6 +14312,16 @@ speechSynthesis.getVoices();
$app.methods.saveGameLogOptions = function () {
configRepository.setBool('VRCX_logResourceLoad', this.logResourceLoad);
};
$app.data.autoStateChange = configRepository.getString(
'VRCX_autoStateChange',
'Off'
);
$app.methods.saveAutomationOptions = function () {
configRepository.setString(
'VRCX_autoStateChange',
this.autoStateChange
);
};
$app.data.orderFriendsGroup0 = configRepository.getBool(
'orderFriendGroup0',
true