Merge pull request #9372 from druiz17/removeHud

Completely removed HUD
This commit is contained in:
Seth Alves 2017-01-12 14:24:40 -08:00 committed by GitHub
commit b4870a14fa
5 changed files with 35 additions and 135 deletions

View file

@ -48,14 +48,7 @@ OriginalDesktop.Desktop {
// This used to create sysToolbar dynamically with a call to getToolbar() within onCompleted. // This used to create sysToolbar dynamically with a call to getToolbar() within onCompleted.
// Beginning with QT 5.6, this stopped working, as anything added to toolbars too early got // Beginning with QT 5.6, this stopped working, as anything added to toolbars too early got
// wiped during startup. // wiped during startup.
Toolbar {
id: sysToolbar;
objectName: "com.highfidelity.interface.toolbar.system";
anchors.horizontalCenter: settings.constrainToolbarToCenterX ? desktop.horizontalCenter : undefined;
// Literal 50 is overwritten by settings from previous session, and sysToolbar.x comes from settings when not constrained.
x: sysToolbar.x
y: 50
}
Settings { Settings {
id: settings; id: settings;
category: "toolbar"; category: "toolbar";
@ -65,7 +58,6 @@ OriginalDesktop.Desktop {
settings.constrainToolbarToCenterX = constrain; settings.constrainToolbarToCenterX = constrain;
} }
property var toolbars: (function (map) { // answer dictionary preloaded with sysToolbar property var toolbars: (function (map) { // answer dictionary preloaded with sysToolbar
map[sysToolbar.objectName] = sysToolbar;
return map; })({}); return map; })({});
@ -74,27 +66,6 @@ OriginalDesktop.Desktop {
WebEngine.settings.javascriptCanAccessClipboard = false; WebEngine.settings.javascriptCanAccessClipboard = false;
WebEngine.settings.spatialNavigationEnabled = false; WebEngine.settings.spatialNavigationEnabled = false;
WebEngine.settings.localContentCanAccessRemoteUrls = true; WebEngine.settings.localContentCanAccessRemoteUrls = true;
[ // Allocate the standard buttons in the correct order. They will get images, etc., via scripts.
"hmdToggle", "mute", "pal", "bubble", "help",
"hudToggle",
"com.highfidelity.interface.system.editButton", "marketplace", "snapshot", "goto"
].forEach(function (name) {
sysToolbar.addButton({objectName: name});
});
var toggleHudButton = sysToolbar.findButton("hudToggle");
toggleHudButton.imageURL = "../../../icons/hud.svg";
toggleHudButton.pinned = true;
sysToolbar.updatePinned(); // automatic when adding buttons only IFF button is pinned at creation.
toggleHudButton.buttonState = Qt.binding(function(){
return desktop.pinned ? 1 : 0
});
toggleHudButton.clicked.connect(function(){
console.log("Clicked on hud button")
var overlayMenuItem = "Overlays"
MenuInterface.setIsOptionChecked(overlayMenuItem, !MenuInterface.isOptionChecked(overlayMenuItem));
});
} }
// Accept a download through the webview // Accept a download through the webview

View file

@ -38,7 +38,7 @@
defaultTab = "gamepad"; defaultTab = "gamepad";
} }
var queryParameters = "handControllerName=" + handControllerName + "&defaultTab=" + defaultTab; var queryParameters = "handControllerName=" + handControllerName + "&defaultTab=" + defaultTab;
tablet.gotoWebScreen(HELP_URL + "?" + queryParameters); Menu.triggerOption('Help...');
} }
button.clicked.connect(onClicked); button.clicked.connect(onClicked);

View file

@ -23,6 +23,7 @@ var CAMERA_MATRIX = -7;
var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0}; var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0};
var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1-x.fbx"; var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1-x.fbx";
var HOME_BUTTON_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-home-button.fbx";
// returns object with two fields: // returns object with two fields:
// * position - position in front of the user // * position - position in front of the user
// * rotation - rotation of entity so it faces the user. // * rotation - rotation of entity so it faces the user.
@ -98,10 +99,10 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
var HOME_BUTTON_Y_OFFSET = -0.25; var HOME_BUTTON_Y_OFFSET = -0.25;
this.homeButtonEntity = Entities.addEntity({ this.homeButtonEntity = Entities.addEntity({
name: "homeButton", name: "homeButton",
type: "Sphere", type: "Model",
modelURL: HOME_BUTTON_URL,
collisionless: true, collisionless: true,
localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: 0}, localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: -0.01},
dimensions: {x: 0.05, y: 0.05, z: 0.05},
parentID: this.tabletEntityID, parentID: this.tabletEntityID,
script: Script.resolvePath("../tablet-ui/HomeButton.js") script: Script.resolvePath("../tablet-ui/HomeButton.js")
}, clientOnly); }, clientOnly);
@ -110,13 +111,6 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
this.receive = function (channel, senderID, senderUUID, localOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) {
if (_this.homeButtonEntity == senderID) { if (_this.homeButtonEntity == senderID) {
if (_this.clicked) {
Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}});
_this.clicked = false;
} else {
Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}});
_this.clicked = true;
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.gotoHomeScreen(); tablet.gotoHomeScreen();
} }

View file

@ -58,94 +58,39 @@ var marketplaceWebTablet;
// To keep things consistent, we pickle the tablet data in Settings, and kill any existing such on restart and domain change. // To keep things consistent, we pickle the tablet data in Settings, and kill any existing such on restart and domain change.
var persistenceKey = "io.highfidelity.lastDomainTablet"; var persistenceKey = "io.highfidelity.lastDomainTablet";
function shouldShowWebTablet() {
var rightPose = Controller.getPoseValue(Controller.Standard.RightHand);
var leftPose = Controller.getPoseValue(Controller.Standard.LeftHand);
var hasHydra = !!Controller.Hardware.Hydra;
return HMD.active && (leftPose.valid || rightPose.valid || hasHydra);
}
function showMarketplace() { function showMarketplace() {
if (shouldShowWebTablet()) { tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL);
updateButtonState(true);
marketplaceWebTablet = new WebTablet(MARKETPLACE_URL_INITIAL, null, null, true);
Settings.setValue(persistenceKey, marketplaceWebTablet.pickle());
marketplaceWebTablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
marketplaceWebTablet.getOverlayObject().webEventReceived.connect(function (message) {
if (message === GOTO_DIRECTORY) {
marketplaceWebTablet.setURL(MARKETPLACES_URL);
}
if (message === QUERY_CAN_WRITE_ASSETS) {
marketplaceWebTablet.getOverlayObject().emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
}
if (message === WARN_USER_NO_PERMISSIONS) {
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
}
});
} else {
marketplaceWindow.setURL(MARKETPLACE_URL_INITIAL);
marketplaceWindow.setVisible(true);
}
marketplaceVisible = true;
UserActivityLogger.openedMarketplace(); UserActivityLogger.openedMarketplace();
}
function hideTablet(tablet) { // FIXME - the code to support the following is not yet implented
if (!tablet) { /*tablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL);
return; tablet.webEventRecieved.connect(function (message) {
} if (message === GOTO_DIRECTORY) {
updateButtonState(false); tablet.gotoWebScreen(MATKETPLACES_URL);
tablet.destroy(); }
marketplaceWebTablet = null;
Settings.setValue(persistenceKey, ""); if (message === QUERY_CAN_WRITE_ASSESTS) {
tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets());
}
if (message === WARN_USER_NO_PERMISSIONS) {
Window.alert(NO_PERMISSIONS_ERROR_MESSAGE);
}
});*/
} }
function clearOldTablet() { // If there was a tablet from previous domain or session, kill it and let it be recreated
var tablet = WebTablet.unpickle(Settings.getValue(persistenceKey, ""));
hideTablet(tablet);
}
function hideMarketplace() {
if (marketplaceWindow.visible) {
marketplaceWindow.setVisible(false);
marketplaceWindow.setURL("about:blank");
} else if (marketplaceWebTablet) {
hideTablet(marketplaceWebTablet);
}
marketplaceVisible = false;
}
marketplaceWindow.closed.connect(function () {
marketplaceWindow.setURL("about:blank");
});
function toggleMarketplace() { function toggleMarketplace() {
if (marketplaceVisible) { showMarketplace();
hideMarketplace();
} else {
showMarketplace();
}
} }
var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var browseExamplesButton = toolBar.addButton({ var browseExamplesButton = tablet.addButton({
imageURL: toolIconUrl + "market.svg", icon: "icons/tablet-icons/market-i.svg",
objectName: "marketplace", text: "MARKET"
buttonState: 1,
defaultState: 1,
hoverState: 3,
alpha: 0.9
}); });
function updateButtonState(visible) {
browseExamplesButton.writeProperty('buttonState', visible ? 0 : 1);
browseExamplesButton.writeProperty('defaultState', visible ? 0 : 1);
browseExamplesButton.writeProperty('hoverState', visible ? 2 : 3);
}
function onMarketplaceWindowVisibilityChanged() {
updateButtonState(marketplaceWindow.visible);
marketplaceVisible = marketplaceWindow.visible;
}
function onCanWriteAssetsChanged() { function onCanWriteAssetsChanged() {
var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets(); var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets();
if (marketplaceWindow.visible) { if (marketplaceWindow.visible) {
@ -161,16 +106,11 @@ function onClick() {
} }
browseExamplesButton.clicked.connect(onClick); browseExamplesButton.clicked.connect(onClick);
marketplaceWindow.visibleChanged.connect(onMarketplaceWindowVisibilityChanged);
Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged); Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged);
clearOldTablet(); // Run once at startup, in case there's anything laying around from a crash.
// We could also optionally do something like Window.domainChanged.connect(function () {Script.setTimeout(clearOldTablet, 2000)}),
// but the HUD version stays around, so lets do the same.
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {
toolBar.removeButton("marketplace");
browseExamplesButton.clicked.disconnect(onClick); browseExamplesButton.clicked.disconnect(onClick);
tablet.removeButton(browseExamplesButton);
marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged); marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged);
Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged); Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged);
}); });

View file

@ -361,16 +361,11 @@ triggerMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Cont
// //
// Manage the connection between the button and the window. // Manage the connection between the button and the window.
// //
var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var buttonName = "pal"; var buttonName = "PAL";
var button = toolBar.addButton({ var button = tablet.addButton({
objectName: buttonName, text: buttonName,
imageURL: Script.resolvePath("assets/images/tools/people.svg"), icon: "icons/tablet-icons/people-i.svg"
visible: true,
hoverState: 2,
defaultState: 1,
buttonState: 1,
alpha: 0.9
}); });
var isWired = false; var isWired = false;
function off() { function off() {
@ -502,7 +497,7 @@ Window.domainConnectionRefused.connect(clearIgnoredInQMLAndClosePAL);
// //
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {
button.clicked.disconnect(onClicked); button.clicked.disconnect(onClicked);
toolBar.removeButton(buttonName); tablet.removeButton(buttonName);
pal.visibleChanged.disconnect(onVisibleChanged); pal.visibleChanged.disconnect(onVisibleChanged);
pal.closed.disconnect(off); pal.closed.disconnect(off);
Users.usernameFromIDReply.disconnect(usernameFromIDReply); Users.usernameFromIDReply.disconnect(usernameFromIDReply);