mirror of
https://github.com/lubosz/overte.git
synced 2025-04-08 00:02:05 +02:00
Minor rewrite to make script clean up properly on exit, and added conditions to fix misbehavior in situation of going away with open tablet.
This commit is contained in:
parent
3daab28245
commit
a824fe01e0
1 changed files with 64 additions and 24 deletions
|
@ -6,13 +6,23 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
|||
|
||||
var oldMode;
|
||||
|
||||
var tabletUp;
|
||||
|
||||
var away;
|
||||
|
||||
var mouseLookEnabled = false;
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
|
||||
if (mouseLookEnabled) {
|
||||
mouseLookOn();
|
||||
if (!tablet.tabletShown){
|
||||
mouseLookOn();
|
||||
}
|
||||
}
|
||||
|
||||
Controller.keyPressEvent.connect(function(event) {
|
||||
Controller.keyPressEvent.connect(onKeyPressEvent);
|
||||
|
||||
function onKeyPressEvent(event) {
|
||||
if (event.text === 'm') {
|
||||
if (mouseLookEnabled) {
|
||||
if (!Camera.getCaptureMouse()){
|
||||
|
@ -35,31 +45,53 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
|||
mouseLookOff();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
tablet.tabletShownChanged.connect(function () {
|
||||
if (!tablet.toolbarMode) {
|
||||
if (tablet.tabletShown) {
|
||||
Window.displayAnnouncement("Tablet is up – mouse look temporarily off.");
|
||||
mouseLookOff();
|
||||
tablet.tabletShownChanged.connect(onTabletShownChanged);
|
||||
|
||||
} else if (!tablet.tabletShown) {
|
||||
Window.displayAnnouncement("Tablet hidden – mouse look on.");
|
||||
function onTabletShownChanged() {
|
||||
if (mouseLookEnabled) {
|
||||
if (!tablet.toolbarMode) {
|
||||
if (tablet.tabletShown) {
|
||||
tabletUp = true;
|
||||
if (!away) {
|
||||
Window.displayAnnouncement("Tablet is up – mouse look temporarily off.");
|
||||
mouseLookOff();
|
||||
}
|
||||
} else if (!tablet.tabletShown) {
|
||||
tabletUp = false;
|
||||
if (!away) {
|
||||
Window.displayAnnouncement("Tablet hidden – mouse look on.");
|
||||
mouseLookOn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MyAvatar.wentAway.connect(onWentAway);
|
||||
|
||||
function onWentAway() {
|
||||
if (mouseLookEnabled) {
|
||||
away = true;
|
||||
if (!tabletUp){
|
||||
Window.displayAnnouncement("Away state ON – mouse look temporarily off.")
|
||||
mouseLookOff()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MyAvatar.wentActive.connect(onWentActive);
|
||||
|
||||
function onWentActive() {
|
||||
if (mouseLookEnabled) {
|
||||
away = false;
|
||||
if (!tabletUp) {
|
||||
Window.displayAnnouncement("Away state OFF – mouse look on.");
|
||||
mouseLookOn();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
MyAvatar.wentAway.connect(function () {
|
||||
Window.displayAnnouncement("Away state ON – mouse look temporarily off.")
|
||||
mouseLookOff()
|
||||
});
|
||||
|
||||
MyAvatar.wentActive.connect(function () {
|
||||
Window.displayAnnouncement("Away state OFF – mouse look on.");
|
||||
mouseLookOn();
|
||||
});
|
||||
}
|
||||
|
||||
function mouseLookOn() {
|
||||
oldMode = Camera.mode;
|
||||
|
@ -80,8 +112,16 @@ by rampa3 (https://github.com/rampa3) and vegaslon (https://github.com/vegaslon)
|
|||
|
||||
Camera.modeUpdated.connect(onCameraModeUpdated);
|
||||
|
||||
Script.scriptEnding.connect(function() {
|
||||
Script.scriptEnding.connect(onScriptEnding);
|
||||
|
||||
function onScriptEnding() {
|
||||
Camera.captureMouse = false;
|
||||
});
|
||||
Controller.keyPressEvent.disconnect(onKeyPressEvent);
|
||||
tablet.tabletShownChanged.disconnect(onTabletShownChanged);
|
||||
MyAvatar.wentAway.disconnect(onWentAway);
|
||||
MyAvatar.wentActive.disconnect(onWentActive);
|
||||
Camera.modeUpdated.disconnect(onCameraModeUpdated);
|
||||
Script.scriptEnding.disconnect();
|
||||
}
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue