cleanups, attempt to get particle explorer to work right

This commit is contained in:
Seth Alves 2017-02-22 12:07:18 -08:00
parent 84b93826d0
commit 5bff2034c3
7 changed files with 79 additions and 173 deletions

View file

@ -313,6 +313,6 @@ Fadable {
} }
} }
onMouseEntered: console.log("Mouse entered " + window) // onMouseEntered: console.log("Mouse entered " + window)
onMouseExited: console.log("Mouse exited " + window) // onMouseExited: console.log("Mouse exited " + window)
} }

View file

@ -1,7 +1,6 @@
"use strict"; "use strict";
// newEditEntities.js // edit.js
// examples
// //
// Created by Brad Hefta-Gaub on 10/2/14. // Created by Brad Hefta-Gaub on 10/2/14.
// Persist toolbar by HRS 6/11/15. // Persist toolbar by HRS 6/11/15.
@ -13,7 +12,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EntityListTook, EntityListTool, Vec3, SelectionManager, Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera, progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, ParticleExplorerTool */ /* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EntityListTool, Vec3, SelectionManager, Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera, progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, ParticleExplorerTool */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
@ -208,28 +207,8 @@ var toolBar = (function () {
var buttonHandlers = {}; // only used to tablet mode var buttonHandlers = {}; // only used to tablet mode
function addButton(name, image, handler) { function addButton(name, image, handler) {
if (Settings.getValue("HUDUIEnabled")) {
var imageUrl = TOOLS_PATH + image;
var button = toolBar.addButton({
objectName: name,
imageURL: imageUrl,
imageOffOut: 1,
imageOffIn: 2,
imageOnOut: 0,
imageOnIn: 2,
alpha: 0.9,
visible: true
});
if (handler) {
button.clicked.connect(function () {
Script.setTimeout(handler, 100);
});
}
return button;
} else {
buttonHandlers[name] = handler; buttonHandlers[name] = handler;
} }
}
var SHAPE_TYPE_NONE = 0; var SHAPE_TYPE_NONE = 0;
var SHAPE_TYPE_SIMPLE_HULL = 1; var SHAPE_TYPE_SIMPLE_HULL = 1;
@ -272,7 +251,6 @@ var toolBar = (function () {
} }
function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml.
print("fromQml: " + JSON.stringify(message));
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.popFromStack(); tablet.popFromStack();
switch (message.method) { switch (message.method) {
@ -299,18 +277,6 @@ var toolBar = (function () {
} }
}); });
if (Settings.getValue("HUDUIEnabled")) {
systemToolbar = Toolbars.getToolbar(SYSTEM_TOOLBAR);
activeButton = systemToolbar.addButton({
objectName: EDIT_TOGGLE_BUTTON,
imageURL: TOOLS_PATH + "edit.svg",
visible: true,
alpha: 0.9,
defaultState: 1
});
systemToolbar.fromQml.connect(fromQml);
} else {
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
activeButton = tablet.addButton({ activeButton = tablet.addButton({
icon: "icons/tablet-icons/edit-i.svg", icon: "icons/tablet-icons/edit-i.svg",
@ -324,17 +290,11 @@ var toolBar = (function () {
} }
}); });
tablet.fromQml.connect(fromQml); tablet.fromQml.connect(fromQml);
}
activeButton.clicked.connect(function() { activeButton.clicked.connect(function() {
that.toggle(); that.toggle();
}); });
if (Settings.getValue("HUDUIEnabled")) {
toolBar = Toolbars.getToolbar(EDIT_TOOLBAR);
toolBar.writeProperty("shown", false);
}
addButton("openAssetBrowserButton", "assets-01.svg", function(){ addButton("openAssetBrowserButton", "assets-01.svg", function(){
Window.showAssetServer(); Window.showAssetServer();
}); });
@ -348,34 +308,9 @@ var toolBar = (function () {
SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons"; SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons";
var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH; var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH;
if (Settings.getValue("HUDUIEnabled")) {
// HUD-ui version of new-model dialog
var result = Window.customPrompt({
textInput: {
label: "Model URL"
},
comboBox: {
label: "Automatic Collisions",
index: SHAPE_TYPE_DEFAULT,
items: SHAPE_TYPES
},
checkBox: {
label: "Dynamic",
checked: DYNAMIC_DEFAULT,
disableForItems: [
SHAPE_TYPE_STATIC_MESH
],
checkStateOnDisable: false,
warningOnDisable: "Models with automatic collisions set to 'Exact' cannot be dynamic"
}
});
handleNewModelDialogResult(result);
} else {
// tablet version of new-model dialog // tablet version of new-model dialog
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.pushOntoStack("NewModelDialog.qml"); tablet.pushOntoStack("NewModelDialog.qml");
}
}); });
addButton("newCubeButton", "cube-01.svg", function () { addButton("newCubeButton", "cube-01.svg", function () {
@ -497,11 +432,11 @@ var toolBar = (function () {
entityListTool.clearEntityList(); entityListTool.clearEntityList();
}; };
that.toggle = function () { that.toggle = function () {
that.setActive(!isActive); that.setActive(!isActive);
if (Settings.getValue("HUDUIEnabled")) {
activeButton.editProperties({isActive: isActive}); activeButton.editProperties({isActive: isActive});
if (!isActive) {
tablet.gotoHomeScreen();
} }
}; };
@ -532,10 +467,8 @@ var toolBar = (function () {
cameraManager.disable(); cameraManager.disable();
selectionDisplay.triggerMapping.disable(); selectionDisplay.triggerMapping.disable();
} else { } else {
if (!Settings.getValue("HUDUIEnabled")) {
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.loadQMLSource("Edit.qml"); tablet.loadQMLSource("Edit.qml");
}
UserActivityLogger.enabledEdit(); UserActivityLogger.enabledEdit();
entityListTool.setVisible(true); entityListTool.setVisible(true);
gridTool.setVisible(true); gridTool.setVisible(true);
@ -546,15 +479,6 @@ var toolBar = (function () {
// everybody else to think that Interface has lost focus overall. fogbugzid:558 // everybody else to think that Interface has lost focus overall. fogbugzid:558
// Window.setFocus(); // Window.setFocus();
} }
if (Settings.getValue("HUDUIEnabled")) {
// Sets visibility of tool buttons, excluding the power button
toolBar.writeProperty("shown", active);
var visible = toolBar.readProperty("visible");
if (active && !visible) {
toolBar.writeProperty("shown", false);
toolBar.writeProperty("shown", true);
}
}
lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE)); lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE));
Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE)); Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE));
}; };
@ -815,6 +739,12 @@ function mouseClickEvent(event) {
orientation = MyAvatar.orientation; orientation = MyAvatar.orientation;
intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation)); intersection = rayPlaneIntersection(pickRay, P, Quat.getFront(orientation));
if (event.isShifted) {
particleExplorerTool.destroyWebView();
}
if (properties.type !== "ParticleEffect") {
particleExplorerTool.destroyWebView();
}
if (!event.isShifted) { if (!event.isShifted) {
selectionManager.setSelections([foundEntity]); selectionManager.setSelections([foundEntity]);
@ -1493,16 +1423,8 @@ var PropertiesTool = function (opts) {
var that = {}; var that = {};
var webView = null; var webView = null;
if (Settings.getValue("HUDUIEnabled")) {
webView = new OverlayWebWindow({
title: 'Entity Properties',
source: ENTITY_PROPERTIES_URL,
toolWindow: true
});
} else {
webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
webView.setVisible = function(value) {}; webView.setVisible = function(value) {};
}
var visible = false; var visible = false;
@ -1924,19 +1846,8 @@ function selectParticleEntity(entityID) {
selectedParticleEntity = entityID; selectedParticleEntity = entityID;
particleExplorerTool.setActiveParticleEntity(entityID); particleExplorerTool.setActiveParticleEntity(entityID);
if (Settings.getValue("HUDUIEnabled")) {
particleExplorerTool.webView.webEventReceived.connect(function (data) {
data = JSON.parse(data);
if (data.messageType === "page_loaded") {
particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData));
} }
});
} else {
// in the tablet version, the page was loaded earlier
particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData));
}
}
entityListTool.webView.webEventReceived.connect(function (data) { entityListTool.webView.webEventReceived.connect(function (data) {
data = JSON.parse(data); data = JSON.parse(data);
@ -1949,7 +1860,7 @@ entityListTool.webView.webEventReceived.connect(function (data) {
return; return;
} }
// Destroy the old particles web view first // Destroy the old particles web view first
selectParticleEntity(ids[0]) selectParticleEntity(ids[0]);
} else { } else {
selectedParticleEntity = 0; selectedParticleEntity = 0;
particleExplorerTool.destroyWebView(); particleExplorerTool.destroyWebView();

View file

@ -1,18 +1,22 @@
var ENTITY_LIST_HTML_URL = Script.resolvePath('../html/entityList.html'); "use strict";
// entityList.js
//
// Copyright 2014 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
//
/* global EntityListTool, Tablet, selectionManager, Entities, Camera, MyAvatar, Vec3, Menu, Messages,
cameraManager, MENU_EASE_ON_FOCUS, deleteSelectedEntities, toggleSelectedEntitiesLocked, toggleSelectedEntitiesVisible */
EntityListTool = function(opts) { EntityListTool = function(opts) {
var that = {}; var that = {};
var webView = null; var webView = null;
if (Settings.getValue("HUDUIEnabled")) {
var url = ENTITY_LIST_HTML_URL;
webView = new OverlayWebWindow({
title: 'Entity List', source: url, toolWindow: true
});
} else {
webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
webView.setVisible = function(value) {}; webView.setVisible = function(value) {};
}
var filterInView = false; var filterInView = false;
var searchRadius = 100; var searchRadius = 100;
@ -30,7 +34,7 @@ EntityListTool = function(opts) {
that.toggleVisible = function() { that.toggleVisible = function() {
that.setVisible(!visible); that.setVisible(!visible);
} };
selectionManager.addEventListener(function() { selectionManager.addEventListener(function() {
var selectedIDs = []; var selectedIDs = [];
@ -49,7 +53,7 @@ EntityListTool = function(opts) {
that.clearEntityList = function () { that.clearEntityList = function () {
var data = { var data = {
type: 'clearEntityList' type: 'clearEntityList'
} };
webView.emitScriptEvent(JSON.stringify(data)); webView.emitScriptEvent(JSON.stringify(data));
}; };
@ -91,8 +95,8 @@ EntityListTool = function(opts) {
} }
var selectedIDs = []; var selectedIDs = [];
for (var i = 0; i < selectionManager.selections.length; i++) { for (var j = 0; j < selectionManager.selections.length; j++) {
selectedIDs.push(selectionManager.selections[i].id); selectedIDs.push(selectionManager.selections[j].id);
} }
var data = { var data = {
@ -101,7 +105,7 @@ EntityListTool = function(opts) {
selectedIDs: selectedIDs, selectedIDs: selectedIDs,
}; };
webView.emitScriptEvent(JSON.stringify(data)); webView.emitScriptEvent(JSON.stringify(data));
} };
webView.webEventReceived.connect(function(data) { webView.webEventReceived.connect(function(data) {
data = JSON.parse(data); data = JSON.parse(data);

View file

@ -229,15 +229,8 @@ GridTool = function(opts) {
var listeners = []; var listeners = [];
var webView = null; var webView = null;
if (Settings.getValue("HUDUIEnabled")) {
var url = GRID_CONTROLS_HTML_URL;
webView = new OverlayWebWindow({
title: 'Grid', source: url, toolWindow: true
});
} else {
webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
webView.setVisible = function(value) {}; webView.setVisible = function(value) {};
}
horizontalGrid.addListener(function(data) { horizontalGrid.addListener(function(data) {
webView.emitScriptEvent(JSON.stringify(data)); webView.emitScriptEvent(JSON.stringify(data));

View file

@ -32,6 +32,8 @@ var gui = null;
var settings = new Settings(); var settings = new Settings();
var updateInterval; var updateInterval;
var active = false;
var currentInputField; var currentInputField;
var storedController; var storedController;
//CHANGE TO WHITELIST //CHANGE TO WHITELIST
@ -363,6 +365,19 @@ function listenForSettingsUpdates() {
} else { } else {
loadGUI(); loadGUI();
} }
if (!active) {
// gui.toggleHide();
gui.closed = false;
}
active = true;
} else if (data.messageType === "particle_close") {
// none of this seems to work.
// if (active) {
// gui.toggleHide();
// }
active = false;
gui.closed = true;
} }
}); });
} }

View file

@ -18,33 +18,21 @@ ParticleExplorerTool = function() {
var that = {}; var that = {};
that.createWebView = function() { that.createWebView = function() {
if (Settings.getValue("HUDUIEnabled")) {
var url = PARTICLE_EXPLORER_HTML_URL;
that.webView = new OverlayWebWindow({
title: 'Particle Explorer',
source: url,
toolWindow: true
});
} else {
that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system");
that.webView.setVisible = function(value) {}; that.webView.setVisible = function(value) {};
}
that.webView.setVisible(true);
that.webView.webEventReceived.connect(that.webEventReceived); that.webView.webEventReceived.connect(that.webEventReceived);
} }
that.destroyWebView = function() { that.destroyWebView = function() {
if (!that.webView) { if (!that.webView) {
return; return;
} }
if (Settings.getValue("HUDUIEnabled")) {
that.webView.close();
that.webView = null;
}
that.activeParticleEntity = 0; that.activeParticleEntity = 0;
var messageData = {
messageType: "particle_close"
};
that.webView.emitScriptEvent(JSON.stringify(messageData));
} }
that.webEventReceived = function(data) { that.webEventReceived = function(data) {
@ -58,9 +46,5 @@ ParticleExplorerTool = function() {
that.activeParticleEntity = id; that.activeParticleEntity = id;
} }
if (Settings.getValue("HUDUIEnabled")) {
that.createWebView();
}
return that; return that;
}; };

View file

@ -49,7 +49,6 @@
} }
function onWebEventReceived(event) { function onWebEventReceived(event) {
print("Script received a web event, its type is " + typeof event);
if (typeof event === "string") { if (typeof event === "string") {
event = JSON.parse(event); event = JSON.parse(event);
} }