mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
Merge pull request #10697 from zfox23/spectatorCamera_HMDOnly
Make the Spectator button only appear in HMD (also add a debug mode for devs)
This commit is contained in:
commit
70569021a8
1 changed files with 65 additions and 17 deletions
|
@ -17,7 +17,8 @@
|
|||
//
|
||||
// FUNCTION VAR DECLARATIONS
|
||||
//
|
||||
var sendToQml, onTabletScreenChanged, fromQml, onTabletButtonClicked, wireEventBridge, startup, shutdown;
|
||||
var sendToQml, addOrRemoveButton, onTabletScreenChanged, fromQml,
|
||||
onTabletButtonClicked, wireEventBridge, startup, shutdown;
|
||||
|
||||
|
||||
|
||||
|
@ -186,18 +187,50 @@
|
|||
setDisplay(monitorShowsCameraView);
|
||||
}
|
||||
|
||||
function onHMDChanged(isHMDMode) {
|
||||
// Will also eventually enable disable app, camera, etc.
|
||||
setDisplay(monitorShowsCameraView);
|
||||
//
|
||||
// Function Name: addOrRemoveButton()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// button: The tablet button.
|
||||
// buttonName: The name of the button.
|
||||
// tablet: The tablet instance to be modified.
|
||||
// showInDesktop: Set to "true" to show the "SPECTATOR" app in desktop mode
|
||||
//
|
||||
// Arguments:
|
||||
// isShuttingDown: Set to "true" if you're calling this function upon script shutdown
|
||||
// isHMDMode: "true" if user is in HMD; false otherwise
|
||||
//
|
||||
// Description:
|
||||
// Used to add or remove the "SPECTATOR" app button from the HUD/tablet
|
||||
//
|
||||
var button = false;
|
||||
var buttonName = "SPECTATOR";
|
||||
var tablet = null;
|
||||
var showSpectatorInDesktop = true;
|
||||
function addOrRemoveButton(isShuttingDown, isHMDMode) {
|
||||
if (!button) {
|
||||
if ((isHMDMode || showSpectatorInDesktop) && !isShuttingDown) {
|
||||
button = tablet.addButton({
|
||||
text: buttonName
|
||||
});
|
||||
button.clicked.connect(onTabletButtonClicked);
|
||||
}
|
||||
} else if (button) {
|
||||
if ((!showSpectatorInDesktop || isShuttingDown) && !isHMDMode) {
|
||||
button.clicked.disconnect(onTabletButtonClicked);
|
||||
tablet.removeButton(button);
|
||||
button = false;
|
||||
}
|
||||
} else {
|
||||
print("ERROR adding/removing Spectator button!");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: startup()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// button: The tablet button.
|
||||
// buttonName: The name of the button.
|
||||
// tablet: The tablet instance to be modified.
|
||||
// None
|
||||
//
|
||||
// Arguments:
|
||||
// None
|
||||
|
@ -205,15 +238,9 @@
|
|||
// Description:
|
||||
// startup() will be called when the script is loaded.
|
||||
//
|
||||
var button;
|
||||
var buttonName = "SPECTATOR";
|
||||
var tablet = null;
|
||||
function startup() {
|
||||
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
button = tablet.addButton({
|
||||
text: buttonName
|
||||
});
|
||||
button.clicked.connect(onTabletButtonClicked);
|
||||
addOrRemoveButton(false, HMD.active);
|
||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
||||
Window.domainChanged.connect(spectatorCameraOff);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
|
@ -320,7 +347,9 @@
|
|||
function onTabletScreenChanged(type, url) {
|
||||
wireEventBridge(shouldActivateButton);
|
||||
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
||||
button.editProperties({ isActive: shouldActivateButton });
|
||||
if (button) {
|
||||
button.editProperties({ isActive: shouldActivateButton });
|
||||
}
|
||||
shouldActivateButton = false;
|
||||
onSpectatorCameraScreen = false;
|
||||
}
|
||||
|
@ -374,6 +403,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: onHMDChanged()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// None
|
||||
//
|
||||
// Arguments:
|
||||
// isHMDMode: "true" if HMD is on; "false" otherwise
|
||||
//
|
||||
// Description:
|
||||
// Called from C++ when HMD mode is changed
|
||||
//
|
||||
function onHMDChanged(isHMDMode) {
|
||||
setDisplay(monitorShowsCameraView);
|
||||
addOrRemoveButton(false, isHMDMode);
|
||||
if (!isHMDMode && !showSpectatorInDesktop) {
|
||||
spectatorCameraOff();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: shutdown()
|
||||
//
|
||||
|
@ -389,8 +438,7 @@
|
|||
function shutdown() {
|
||||
spectatorCameraOff();
|
||||
Window.domainChanged.disconnect(spectatorCameraOff);
|
||||
tablet.removeButton(button);
|
||||
button.clicked.disconnect(onTabletButtonClicked);
|
||||
addOrRemoveButton(true, HMD.active);
|
||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||
HMD.displayModeChanged.disconnect(onHMDChanged);
|
||||
Controller.keyPressEvent.disconnect(keyPressEvent);
|
||||
|
|
Loading…
Reference in a new issue