mirror of
https://github.com/overte-org/overte.git
synced 2025-04-10 17:22:25 +02:00
Add setting to force virtual window in VR.
This commit is contained in:
parent
71c85d3889
commit
624ceefc24
2 changed files with 51 additions and 8 deletions
|
@ -7,8 +7,6 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
// TODO: Message trimming
|
||||
|
||||
(() => {
|
||||
("use strict");
|
||||
|
||||
|
@ -20,8 +18,10 @@
|
|||
var settings = {
|
||||
external_window: false,
|
||||
maximum_messages: 200,
|
||||
join_notification: true
|
||||
join_notification: true,
|
||||
switchToInternalOnHeadsetUsed: true
|
||||
};
|
||||
let temporaryChangeModeToVirtual = false;
|
||||
|
||||
// Global vars
|
||||
var tablet;
|
||||
|
@ -38,6 +38,7 @@
|
|||
Messages.messageReceived.connect(receivedMessage);
|
||||
AvatarManager.avatarAddedEvent.connect((sessionId) => { _avatarAction("connected", sessionId); });
|
||||
AvatarManager.avatarRemovedEvent.connect((sessionId) => { _avatarAction("left", sessionId); });
|
||||
HMD.displayModeChanged.connect(_onHMDDisplayModeChanged);
|
||||
|
||||
startup();
|
||||
|
||||
|
@ -135,15 +136,16 @@
|
|||
break;
|
||||
case "setting_change":
|
||||
// Set the setting value, and save the config
|
||||
settings[event.setting] = event.value; // Update local settings
|
||||
_saveSettings(); // Save local settings
|
||||
settings[event.setting] = event.value; // Update local settings
|
||||
_saveSettings(); // Save local settings
|
||||
|
||||
// Extra actions to preform.
|
||||
switch (event.setting) {
|
||||
case "external_window":
|
||||
chatOverlayWindow.presentationMode = event.value
|
||||
? Desktop.PresentationMode.NATIVE
|
||||
: Desktop.PresentationMode.VIRTUAL;
|
||||
_changePresentationMode(event.value);
|
||||
break;
|
||||
case "switchToInternalOnHeadsetUsed":
|
||||
_onHMDDisplayModeChanged(HMD.active);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -177,6 +179,22 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
function _onHMDDisplayModeChanged(isHMDActive){
|
||||
// If the user enabled automatic switching to internal when they put on a headset...
|
||||
if (!settings.switchToInternalOnHeadsetUsed) return;
|
||||
|
||||
if (isHMDActive) temporaryChangeModeToVirtual = true;
|
||||
else temporaryChangeModeToVirtual = false;
|
||||
|
||||
_changePresentationMode(settings.external_window);
|
||||
}
|
||||
function _changePresentationMode(changeToExternal){
|
||||
if (temporaryChangeModeToVirtual) changeToExternal = false;
|
||||
|
||||
chatOverlayWindow.presentationMode = changeToExternal
|
||||
? Desktop.PresentationMode.NATIVE
|
||||
: Desktop.PresentationMode.VIRTUAL;
|
||||
}
|
||||
function _sendMessage(message, channel) {
|
||||
if (message.length == 0) return;
|
||||
|
||||
|
|
|
@ -369,6 +369,29 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Switch to internal on VR Mode
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 40
|
||||
color: "transparent"
|
||||
|
||||
Text {
|
||||
text: "Force Virtual window in VR"
|
||||
color: "white"
|
||||
font.pointSize: 12
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: s_force_vw_in_vr
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
onCheckedChanged: {
|
||||
toScript({type: 'setting_change', setting: 'switchToInternalOnHeadsetUsed', value: checked})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,9 +456,11 @@ Rectangle {
|
|||
domain.clear();
|
||||
break;
|
||||
case "initial_settings":
|
||||
print(JSON.stringify(message.settings));
|
||||
if (message.settings.external_window) s_external_window.checked = true;
|
||||
if (message.settings.maximum_messages) s_maximum_messages.value = message.settings.maximum_messages;
|
||||
if (message.settings.join_notification) s_join_notification.checked = true;
|
||||
if (message.settings.switchToInternalOnHeadsetUsed) s_force_vw_in_vr.checked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue