Create VRConfigVars

This commit is contained in:
Natsumi
2021-01-20 06:14:10 +13:00
parent af2897947e
commit 363d864534
3 changed files with 60 additions and 50 deletions
+34 -6
View File
@@ -5769,7 +5769,7 @@ speechSynthesis.getVoices();
configRepository.setBool('VRCX_desktopToast', this.desktopToast); configRepository.setBool('VRCX_desktopToast', this.desktopToast);
configRepository.setBool('VRCX_minimalFeed', this.minimalFeed); configRepository.setBool('VRCX_minimalFeed', this.minimalFeed);
configRepository.setBool('displayVRCPlusIconsAsAvatar', this.displayVRCPlusIconsAsAvatar); configRepository.setBool('displayVRCPlusIconsAsAvatar', this.displayVRCPlusIconsAsAvatar);
AppApi.RefreshVR(); this.updateVRConfigVars();
}; };
$app.data.TTSvoices = speechSynthesis.getVoices(); $app.data.TTSvoices = speechSynthesis.getVoices();
var saveNotificationTTS = function () { var saveNotificationTTS = function () {
@@ -5778,7 +5778,7 @@ speechSynthesis.getVoices();
if (this.notificationTTS) { if (this.notificationTTS) {
this.speak('Notification text-to-speech enabled'); this.speak('Notification text-to-speech enabled');
} }
AppApi.RefreshVR(); this.updateVRConfigVars();
}; };
$app.watch.openVR = saveOpenVROption; $app.watch.openVR = saveOpenVROption;
$app.watch.openVRAlways = saveOpenVROption; $app.watch.openVRAlways = saveOpenVROption;
@@ -5796,7 +5796,7 @@ speechSynthesis.getVoices();
$app.watch.isDarkMode = function () { $app.watch.isDarkMode = function () {
configRepository.setBool('isDarkMode', this.isDarkMode); configRepository.setBool('isDarkMode', this.isDarkMode);
$appDarkStyle.disabled = this.isDarkMode === false; $appDarkStyle.disabled = this.isDarkMode === false;
AppApi.RefreshVR(); this.updateVRConfigVars();
}; };
$app.data.isStartAtWindowsStartup = configRepository.getBool('VRCX_StartAtWindowsStartup'); $app.data.isStartAtWindowsStartup = configRepository.getBool('VRCX_StartAtWindowsStartup');
$app.data.isStartAsMinimizedState = (VRCXStorage.Get('VRCX_StartAsMinimizedState') === 'true'); $app.data.isStartAsMinimizedState = (VRCXStorage.Get('VRCX_StartAsMinimizedState') === 'true');
@@ -5946,7 +5946,7 @@ speechSynthesis.getVoices();
this.notyFeedFiltersDialog.visible = false; this.notyFeedFiltersDialog.visible = false;
this.wristFeedFiltersDialog.visible = false; this.wristFeedFiltersDialog.visible = false;
configRepository.setString('sharedFeedFilters', JSON.stringify(this.sharedFeedFilters)); configRepository.setString('sharedFeedFilters', JSON.stringify(this.sharedFeedFilters));
AppApi.RefreshVR(); this.updateVRConfigVars();
} }
$app.methods.cancelSharedFeedFilters = function () { $app.methods.cancelSharedFeedFilters = function () {
@@ -5958,7 +5958,7 @@ speechSynthesis.getVoices();
$app.data.notificationPosition = configRepository.getString('VRCX_notificationPosition'); $app.data.notificationPosition = configRepository.getString('VRCX_notificationPosition');
$app.methods.changeNotificationPosition = function () { $app.methods.changeNotificationPosition = function () {
configRepository.setString('VRCX_notificationPosition', this.notificationPosition); configRepository.setString('VRCX_notificationPosition', this.notificationPosition);
AppApi.RefreshVR(); this.updateVRConfigVars();
}; };
sharedRepository.setBool('is_game_running', false); sharedRepository.setBool('is_game_running', false);
@@ -5987,6 +5987,34 @@ speechSynthesis.getVoices();
} }
$app.watch.lastLocation = lastLocationStateChange; $app.watch.lastLocation = lastLocationStateChange;
$app.methods.updateVRConfigVars = function () {
if (configRepository.getBool('isDarkMode')) {
var notificationTheme = 'sunset';
} else {
var notificationTheme = 'relax';
}
var VRConfigVars = {
notificationTTS: this.notificationTTS,
notificationTTSVoice: this.notificationTTSVoice,
overlayNotifications: this.overlayNotifications,
desktopToast: this.desktopToast,
hidePrivateFromFeed: this.hidePrivateFromFeed,
hideOnPlayerJoined: this.hideOnPlayerJoined,
hideDevicesFromFeed: this.hideDevicesFromFeed,
minimalFeed: this.minimalFeed,
displayVRCPlusIconsAsAvatar: this.displayVRCPlusIconsAsAvatar,
sharedFeedFilters: this.sharedFeedFilters,
notificationPosition: this.notificationPosition,
notificationTimeout: this.notificationTimeout,
notificationTheme: notificationTheme
}
sharedRepository.setObject('VRConfigVars', VRConfigVars);
}
API.$on('LOGIN', function () {
$app.updateVRConfigVars();
});
API.$on('LOGIN', function () { API.$on('LOGIN', function () {
$app.currentUserTreeData = []; $app.currentUserTreeData = [];
$app.pastDisplayNameTable.data = []; $app.pastDisplayNameTable.data = [];
@@ -6053,7 +6081,7 @@ speechSynthesis.getVoices();
var voiceName = voices[index].name; var voiceName = voices[index].name;
speechSynthesis.cancel(); speechSynthesis.cancel();
this.speak(voiceName); this.speak(voiceName);
AppApi.RefreshVR(); this.updateVRConfigVars();
}; };
$app.methods.speak = function (text) { $app.methods.speak = function (text) {
+25 -43
View File
@@ -680,24 +680,14 @@ speechSynthesis.getVoices();
currentTime: new Date().toJSON(), currentTime: new Date().toJSON(),
currentUserStatus: null, currentUserStatus: null,
cpuUsage: 0, cpuUsage: 0,
config: {},
isGameRunning: false, isGameRunning: false,
isGameNoVR: false, isGameNoVR: false,
lastLocation: '', lastLocation: '',
lastFeedEntry: [], lastFeedEntry: [],
feedFilters: [],
wristFeed: [], wristFeed: [],
notyMap: [], notyMap: [],
devices: [], devices: [],
desktopToastToggle: false,
overlayNotificationsToggle: false,
notificationTTSToggle: false,
notificationTTSVoice: '0',
hideDevicesToggle: false,
isMinimalFeed: false,
displayVRCPlusIconsAsAvatar: false,
notificationPosition: 'topCenter',
notificationTimeout: '3000',
notificationTheme: 'relax'
}, },
computed: {}, computed: {},
methods: {}, methods: {},
@@ -722,7 +712,6 @@ speechSynthesis.getVoices();
// FIXME: 어케 복구하냐 이건 // FIXME: 어케 복구하냐 이건
throw err; throw err;
}).then((args) => { }).then((args) => {
this.initConfigVars();
if (this.appType === '1') { if (this.appType === '1') {
this.updateCpuUsageLoop(); this.updateCpuUsageLoop();
} }
@@ -735,23 +724,11 @@ speechSynthesis.getVoices();
} }
}; };
$app.methods.initConfigVars = function () { $app.methods.updateVRConfigVars = function () {
this.notificationTTSToggle = configRepository.getBool('VRCX_notificationTTS'); var newConfig = sharedRepository.getObject('VRConfigVars');
this.notificationTTSVoice = configRepository.getString('VRCX_notificationTTSVoice'); if ((newConfig) && (JSON.stringify(newConfig) !== JSON.stringify(this.config))) {
this.overlayNotificationsToggle = configRepository.getBool('VRCX_overlayNotifications'); this.config = newConfig;
this.desktopToastToggle = configRepository.getBool('VRCX_desktopToast'); this.lastFeedEntry = [];
this.hidePrivateFromFeed = configRepository.getBool('VRCX_hidePrivateFromFeed');
this.hideOnPlayerJoined = configRepository.getBool('VRCX_hideOnPlayerJoined');
this.hideDevicesToggle = configRepository.getBool('VRCX_hideDevicesFromFeed');
this.isMinimalFeed = configRepository.getBool('VRCX_minimalFeed');
this.displayVRCPlusIconsAsAvatar = configRepository.getBool('displayVRCPlusIconsAsAvatar');
this.feedFilters = JSON.parse(configRepository.getString('sharedFeedFilters'));
this.notificationPosition = configRepository.getString('VRCX_notificationPosition');
this.notificationTimeout = configRepository.getString('VRCX_notificationTimeout');
if (configRepository.getBool('isDarkMode')) {
this.notificationTheme = 'sunset';
} else {
this.notificationTheme = 'relax';
} }
}; };
@@ -760,7 +737,8 @@ speechSynthesis.getVoices();
if (feeds === null) { if (feeds === null) {
return; return;
} }
var filter = this.feedFilters.noty; var sharedFeedFilters = JSON.parse(configRepository.getString('sharedFeedFilters'));
var filter = sharedFeedFilters.noty;
var filtered = []; var filtered = [];
feeds.forEach((feed) => { feeds.forEach((feed) => {
if (filter[feed.type]) { if (filter[feed.type]) {
@@ -791,12 +769,16 @@ speechSynthesis.getVoices();
$app.methods.updateLoop = async function () { $app.methods.updateLoop = async function () {
try { try {
this.updateVRConfigVars();
if (!this.config) {
return;
}
this.currentTime = new Date().toJSON(); this.currentTime = new Date().toJSON();
this.currentUserStatus = sharedRepository.getString('current_user_status'); this.currentUserStatus = sharedRepository.getString('current_user_status');
this.isGameRunning = sharedRepository.getBool('is_game_running'); this.isGameRunning = sharedRepository.getBool('is_game_running');
this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR'); this.isGameNoVR = sharedRepository.getBool('is_Game_No_VR');
this.lastLocation = sharedRepository.getString('last_location'); this.lastLocation = sharedRepository.getString('last_location');
if ((!this.hideDevicesToggle) && (this.appType === '1')) { if ((!this.config.hideDevicesFromFeed) && (this.appType === '1')) {
AppApi.GetVRDevices().then((devices) => { AppApi.GetVRDevices().then((devices) => {
devices.forEach((device) => { devices.forEach((device) => {
device[2] = parseInt(device[2], 10); device[2] = parseInt(device[2], 10);
@@ -870,7 +852,7 @@ speechSynthesis.getVoices();
} }
//on Location change remove OnPlayerJoined //on Location change remove OnPlayerJoined
if (this.hideOnPlayerJoined) { if (this.config.hideOnPlayerJoined) {
for (i = 0; i < feeds.length; i++) { for (i = 0; i < feeds.length; i++) {
var ctx = feeds[i]; var ctx = feeds[i];
if (ctx.type === 'Location') { if (ctx.type === 'Location') {
@@ -889,7 +871,7 @@ speechSynthesis.getVoices();
} }
} }
if (this.hidePrivateFromFeed) { if (this.config.hidePrivateFromFeed) {
for (var i = 0; i < feeds.length; i++) { for (var i = 0; i < feeds.length; i++) {
var feed = feeds[i]; var feed = feeds[i];
if ((feed.type === 'GPS') && (feed.location[0] === 'private')) { if ((feed.type === 'GPS') && (feed.location[0] === 'private')) {
@@ -909,7 +891,7 @@ speechSynthesis.getVoices();
}; };
$app.methods.updateSharedFeedWrist = async function (feeds) { $app.methods.updateSharedFeedWrist = async function (feeds) {
var filter = this.feedFilters.wrist; var filter = this.config.sharedFeedFilters.wrist;
var filtered = []; var filtered = [];
feeds.forEach((feed) => { feeds.forEach((feed) => {
if (filter[feed.type]) { if (filter[feed.type]) {
@@ -928,7 +910,7 @@ speechSynthesis.getVoices();
}; };
$app.methods.updateSharedFeedNoty = async function (feeds) { $app.methods.updateSharedFeedNoty = async function (feeds) {
var filter = this.feedFilters.noty; var filter = this.config.sharedFeedFilters.noty;
var filtered = []; var filtered = [];
feeds.forEach((feed) => { feeds.forEach((feed) => {
if (filter[feed.type]) { if (filter[feed.type]) {
@@ -972,7 +954,7 @@ speechSynthesis.getVoices();
if (noty.created_at < bias) { if (noty.created_at < bias) {
continue; continue;
} }
if ((this.overlayNotificationsToggle) && (!this.isGameNoVR)) { if ((this.config.overlayNotifications) && (!this.isGameNoVR)) {
var text = ''; var text = '';
switch (noty.type) { switch (noty.type) {
case 'OnPlayerJoined': case 'OnPlayerJoined':
@@ -1036,14 +1018,14 @@ speechSynthesis.getVoices();
if (text) { if (text) {
new Noty({ new Noty({
type: 'alert', type: 'alert',
theme: this.notificationTheme, theme: this.config.notificationTheme,
timeout: this.notificationTimeout, timeout: this.config.notificationTimeout,
layout: this.notificationPosition, layout: this.config.notificationPosition,
text: text text: text
}).show(); }).show();
} }
} }
if (this.notificationTTSToggle) { if (this.config.notificationTTS) {
switch (noty.type) { switch (noty.type) {
case 'OnPlayerJoined': case 'OnPlayerJoined':
this.speak(`${noty.data} has joined`); this.speak(`${noty.data} has joined`);
@@ -1104,7 +1086,7 @@ speechSynthesis.getVoices();
break; break;
} }
} }
if ((this.desktopToastToggle) && (this.isGameNoVR)) { if ((this.config.desktopToast) && (this.isGameNoVR)) {
var imageURL = ''; var imageURL = '';
if (noty.userId) { if (noty.userId) {
await API.getCachedUser({ await API.getCachedUser({
@@ -1113,7 +1095,7 @@ speechSynthesis.getVoices();
throw err; throw err;
}).then((args) => { }).then((args) => {
imageURL = args.json.currentAvatarThumbnailImageUrl; imageURL = args.json.currentAvatarThumbnailImageUrl;
if ((this.displayVRCPlusIconsAsAvatar) && (args.json.userIcon)) { if ((this.config.displayVRCPlusIconsAsAvatar) && (args.json.userIcon)) {
imageURL = args.json.userIcon; imageURL = args.json.userIcon;
} }
}); });
@@ -1215,7 +1197,7 @@ speechSynthesis.getVoices();
$app.methods.speak = function (text) { $app.methods.speak = function (text) {
var tts = new SpeechSynthesisUtterance(); var tts = new SpeechSynthesisUtterance();
var voices = speechSynthesis.getVoices(); var voices = speechSynthesis.getVoices();
var voiceIndex = this.notificationTTSVoice; var voiceIndex = this.config.notificationTTSVoice;
tts.voice = voices[voiceIndex]; tts.voice = voices[voiceIndex];
tts.text = text; tts.text = text;
speechSynthesis.speak(tts); speechSynthesis.speak(tts);
+1 -1
View File
@@ -15,7 +15,7 @@ html
.x-app#x-app(v-if="appType === '1'" class="x-app-type") .x-app#x-app(v-if="appType === '1'" class="x-app-type")
.x-container(style="flex:1") .x-container(style="flex:1")
.x-friend-list(ref="list" style="color:#aaa") .x-friend-list(ref="list" style="color:#aaa")
template(v-if="isMinimalFeed") template(v-if="config.minimalFeed")
template(v-for="feed in wristFeed") template(v-for="feed in wristFeed")
.x-friend-item(v-if="feed.type === 'GPS'" :class="{ friend: feed.isFriend, favorite: feed.isFavorite }") .x-friend-item(v-if="feed.type === 'GPS'" :class="{ friend: feed.isFriend, favorite: feed.isFavorite }")
.detail .detail