mirror of
https://github.com/overte-org/overte.git
synced 2025-08-16 05:50:41 +02:00
First checkpoint!
This commit is contained in:
parent
7ad940080e
commit
e9bb982651
3 changed files with 225 additions and 0 deletions
41
interface/resources/qml/hifi/SpectatorCamera.qml
Normal file
41
interface/resources/qml/hifi/SpectatorCamera.qml
Normal file
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// SpectatorCamera.qml
|
||||
// qml/hifi
|
||||
//
|
||||
// Spectator Camera
|
||||
//
|
||||
// Created by Zach Fox on 2017-06-05
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.5
|
||||
import QtQuick.Controls 1.4
|
||||
import "../styles-uit"
|
||||
import "../controls-uit" as HifiControlsUit
|
||||
import "../controls" as HifiControls
|
||||
|
||||
// references HMD, XXX from root context
|
||||
|
||||
Rectangle {
|
||||
id: spectatorCamera;
|
||||
// Size
|
||||
width: parent.width;
|
||||
height: parent.height;
|
||||
// Style
|
||||
color: "#E3E3E3";
|
||||
// Properties
|
||||
|
||||
HifiConstants { id: hifi; }
|
||||
|
||||
function fromScript(message) {
|
||||
switch (message.method) {
|
||||
case 'XXX':
|
||||
break;
|
||||
default:
|
||||
console.log('Unrecognized message from spectatorCamera.js:', JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ var DEFAULT_SCRIPTS_COMBINED = [
|
|||
"system/tablet-goto.js",
|
||||
"system/marketplaces/marketplaces.js",
|
||||
"system/edit.js",
|
||||
"system/spectatorCamera.js",
|
||||
"system/selectAudioDevice.js",
|
||||
"system/notifications.js",
|
||||
"system/dialTone.js",
|
||||
|
|
183
scripts/system/spectatorCamera.js
Normal file
183
scripts/system/spectatorCamera.js
Normal file
|
@ -0,0 +1,183 @@
|
|||
"use strict";
|
||||
/*jslint vars:true, plusplus:true, forin:true*/
|
||||
/*global Tablet, */
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
//
|
||||
// spectatorCamera.js
|
||||
//
|
||||
// Created by Zach Fox on 2017-06-05
|
||||
// Copyright 2017 High Fidelity, Inc
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
(function () { // BEGIN LOCAL_SCOPE
|
||||
|
||||
|
||||
//
|
||||
// Function Name: sendToQml()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// None
|
||||
//
|
||||
// Arguments:
|
||||
// message: The message to send to the SpectatorCamera QML.
|
||||
// Messages are in format "{method, params}", like json-rpc. See also fromQml().
|
||||
//
|
||||
// Description:
|
||||
// Use this function to send a message to the QML (i.e. to change appearances).
|
||||
//
|
||||
function sendToQml(message) {
|
||||
tablet.sendToQml(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: fromQml()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// None
|
||||
//
|
||||
// Arguments:
|
||||
// message: The message sent from the SpectatorCamera QML.
|
||||
// Messages are in format "{method, params}", like json-rpc. See also sendToQml().
|
||||
//
|
||||
// Description:
|
||||
// Called when a message is received from SpectatorCamera.qml.
|
||||
//
|
||||
function fromQml(message) { //
|
||||
var data;
|
||||
switch (message.method) {
|
||||
case 'XXX':
|
||||
break;
|
||||
default:
|
||||
print('Unrecognized message from SpectatorCamera.qml:', JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: onTabletButtonClicked()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// onSpectatorCameraScreen: true/false depending on whether we're looking at the spectator camera app
|
||||
// shouldActivateButton: true/false depending on whether we should show the button as white or gray the
|
||||
// next time we edit the button's properties
|
||||
//
|
||||
// Arguments:
|
||||
// None
|
||||
//
|
||||
// Description:
|
||||
// Fired when the Spectator Camera app button is pressed.
|
||||
//
|
||||
var onSpectatorCameraScreen = false;
|
||||
var shouldActivateButton = false;
|
||||
function onTabletButtonClicked() {
|
||||
if (onSpectatorCameraScreen) {
|
||||
// for toolbar-mode: go back to home screen, this will close the window.
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
shouldActivateButton = true;
|
||||
tablet.loadQMLSource("../SpectatorCamera.qml");
|
||||
onSpectatorCameraScreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: wireEventBridge()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// hasEventBridge: true/false depending on whether we've already connected the event bridge
|
||||
//
|
||||
// Arguments:
|
||||
// on: Enable or disable the event bridge
|
||||
//
|
||||
// Description:
|
||||
// Used to connect/disconnect the script's response to the tablet's "fromQml" signal.
|
||||
//
|
||||
var hasEventBridge = false;
|
||||
function wireEventBridge(on) {
|
||||
if (on) {
|
||||
if (!hasEventBridge) {
|
||||
tablet.fromQml.connect(fromQml);
|
||||
hasEventBridge = true;
|
||||
}
|
||||
} else {
|
||||
if (hasEventBridge) {
|
||||
tablet.fromQml.disconnect(fromQml);
|
||||
hasEventBridge = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: onTabletScreenChanged()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// None
|
||||
//
|
||||
// Arguments:
|
||||
// type: "Home", "Web", "Menu", "QML", "Closed"
|
||||
// url: Only valid for Web and QML.
|
||||
//
|
||||
// Description:
|
||||
// Called when the TabletScriptingInterface::screenChanged() signal is emitted.
|
||||
//
|
||||
function onTabletScreenChanged(type, url) {
|
||||
wireEventBridge(shouldActivateButton);
|
||||
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
||||
button.editProperties({ isActive: shouldActivateButton });
|
||||
shouldActivateButton = false;
|
||||
onSpectatorCameraScreen = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: shutdown()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// button: The tablet button.
|
||||
// buttonName: The name of the button.
|
||||
// tablet: The tablet instance to be modified.
|
||||
//
|
||||
// Arguments:
|
||||
// None
|
||||
//
|
||||
// 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);
|
||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
||||
}
|
||||
|
||||
//
|
||||
// Function Name: shutdown()
|
||||
//
|
||||
// Relevant Variables:
|
||||
// None
|
||||
//
|
||||
// Arguments:
|
||||
// None
|
||||
//
|
||||
// Description:
|
||||
// shutdown() will be called when the script ends (i.e. is stopped).
|
||||
//
|
||||
function shutdown() {
|
||||
tablet.removeButton(button);
|
||||
button.clicked.disconnect(onTabletButtonClicked);
|
||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||
}
|
||||
|
||||
//
|
||||
// These functions will be called when the script is loaded.
|
||||
//
|
||||
startup();
|
||||
Script.scriptEnding.connect(shutdown);
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue