mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 23:14:34 +02:00
PR feedback
This commit is contained in:
parent
cd6abadc41
commit
d084623662
1 changed files with 21 additions and 47 deletions
|
@ -12,7 +12,10 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
var EDIT_TOGGLE_BUTTON = "com.highfidelity.interface.system.editButton";
|
||||||
|
var SYSTEM_TOOLBAR = "com.highfidelity.interface.toolbar.system";
|
||||||
|
var EDIT_TOOLBAR = "com.highfidelity.interface.toolbar.edit";
|
||||||
|
|
||||||
Script.include([
|
Script.include([
|
||||||
"libraries/stringHelpers.js",
|
"libraries/stringHelpers.js",
|
||||||
"libraries/dataViewHelpers.js",
|
"libraries/dataViewHelpers.js",
|
||||||
|
@ -92,8 +95,6 @@ var INSUFFICIENT_PERMISSIONS_IMPORT_ERROR_MSG = "You do not have the necessary p
|
||||||
var mode = 0;
|
var mode = 0;
|
||||||
var isActive = false;
|
var isActive = false;
|
||||||
|
|
||||||
var placingEntityID = null;
|
|
||||||
|
|
||||||
IMPORTING_SVO_OVERLAY_WIDTH = 144;
|
IMPORTING_SVO_OVERLAY_WIDTH = 144;
|
||||||
IMPORTING_SVO_OVERLAY_HEIGHT = 30;
|
IMPORTING_SVO_OVERLAY_HEIGHT = 30;
|
||||||
IMPORTING_SVO_OVERLAY_MARGIN = 5;
|
IMPORTING_SVO_OVERLAY_MARGIN = 5;
|
||||||
|
@ -170,24 +171,16 @@ var toolBar = (function() {
|
||||||
systemToolbar,
|
systemToolbar,
|
||||||
activeButton;
|
activeButton;
|
||||||
|
|
||||||
function createNewEntity(properties, dragOnCreate) {
|
function createNewEntity(properties) {
|
||||||
Settings.setValue(EDIT_SETTING, false);
|
Settings.setValue(EDIT_SETTING, false);
|
||||||
|
|
||||||
// Default to true if not passed in
|
|
||||||
// dragOnCreate = dragOnCreate == undefined ? true : dragOnCreate;
|
|
||||||
dragOnCreate = false;
|
|
||||||
|
|
||||||
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS;
|
||||||
var position = getPositionToCreateEntity();
|
var position = getPositionToCreateEntity();
|
||||||
var entityID = null;
|
var entityID = null;
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions),
|
position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions),
|
||||||
properties.position = position;
|
properties.position = position;
|
||||||
|
|
||||||
entityID = Entities.addEntity(properties);
|
entityID = Entities.addEntity(properties);
|
||||||
if (dragOnCreate) {
|
|
||||||
placingEntityID = entityID;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
Window.alert("Can't create " + properties.type + ": " + properties.type + " would be out of bounds.");
|
||||||
}
|
}
|
||||||
|
@ -201,7 +194,7 @@ var toolBar = (function() {
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
that.setActive(false);
|
that.setActive(false);
|
||||||
systemToolbar.removeButton("com.highfidelity.interface.system.editButton");
|
systemToolbar.removeButton(EDIT_TOGGLE_BUTTON);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addButton(name, image, handler) {
|
function addButton(name, image, handler) {
|
||||||
|
@ -214,7 +207,7 @@ var toolBar = (function() {
|
||||||
visible: true,
|
visible: true,
|
||||||
});
|
});
|
||||||
if (handler) {
|
if (handler) {
|
||||||
button.clicked.connect(function(){
|
button.clicked.connect(function() {
|
||||||
Script.setTimeout(handler, 100);
|
Script.setTimeout(handler, 100);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -236,32 +229,32 @@ var toolBar = (function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
systemToolbar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
|
systemToolbar = Toolbars.getToolbar(SYSTEM_TOOLBAR);
|
||||||
activeButton = systemToolbar.addButton({
|
activeButton = systemToolbar.addButton({
|
||||||
objectName: "com.highfidelity.interface.system.editButton",
|
objectName: EDIT_TOGGLE_BUTTON,
|
||||||
imageURL: TOOL_ICON_URL + "edit.svg",
|
imageURL: TOOL_ICON_URL + "edit.svg",
|
||||||
visible: true,
|
visible: true,
|
||||||
buttonState: 1,
|
buttonState: 1,
|
||||||
});
|
});
|
||||||
activeButton.clicked.connect(function(){
|
activeButton.clicked.connect(function() {
|
||||||
that.setActive(!isActive);
|
that.setActive(!isActive);
|
||||||
activeButton.writeProperty("buttonState", isActive ? 0 : 1);
|
activeButton.writeProperty("buttonState", isActive ? 0 : 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.edit");
|
toolBar = Toolbars.getToolbar(EDIT_TOOLBAR);
|
||||||
toolBar.writeProperty("shown", false);
|
toolBar.writeProperty("shown", false);
|
||||||
|
|
||||||
addButton("newModelButton", "model-01.svg", function(){
|
addButton("newModelButton", "model-01.svg", function() {
|
||||||
var url = Window.prompt("Model URL");
|
var url = Window.prompt("Model URL");
|
||||||
if (url !== null && url !== "") {
|
if (url !== null && url !== "") {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: url
|
modelURL: url
|
||||||
}, false);
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newCubeButton", "cube-01.svg", function(){
|
addButton("newCubeButton", "cube-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
dimensions: DEFAULT_DIMENSIONS,
|
dimensions: DEFAULT_DIMENSIONS,
|
||||||
|
@ -273,7 +266,7 @@ var toolBar = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newSphereButton", "sphere-01.svg", function(){
|
addButton("newSphereButton", "sphere-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
dimensions: DEFAULT_DIMENSIONS,
|
dimensions: DEFAULT_DIMENSIONS,
|
||||||
|
@ -285,7 +278,7 @@ var toolBar = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newLightButton", "light-01.svg", function(){
|
addButton("newLightButton", "light-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Light",
|
type: "Light",
|
||||||
dimensions: DEFAULT_LIGHT_DIMENSIONS,
|
dimensions: DEFAULT_LIGHT_DIMENSIONS,
|
||||||
|
@ -304,7 +297,7 @@ var toolBar = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newTextButton", "text-01.svg", function(){
|
addButton("newTextButton", "text-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Text",
|
type: "Text",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -327,7 +320,7 @@ var toolBar = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newWebButton", "web-01.svg", function(){
|
addButton("newWebButton", "web-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Web",
|
type: "Web",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -339,7 +332,7 @@ var toolBar = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newZoneButton", "zone-01.svg", function(){
|
addButton("newZoneButton", "zone-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "Zone",
|
type: "Zone",
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
@ -350,7 +343,7 @@ var toolBar = (function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
addButton("newParticleButton", "particle-01.svg", function(){
|
addButton("newParticleButton", "particle-01.svg", function() {
|
||||||
createNewEntity({
|
createNewEntity({
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
isEmitting: true,
|
isEmitting: true,
|
||||||
|
@ -409,8 +402,8 @@ var toolBar = (function() {
|
||||||
gridTool.setVisible(true);
|
gridTool.setVisible(true);
|
||||||
grid.setEnabled(true);
|
grid.setEnabled(true);
|
||||||
propertiesTool.setVisible(true);
|
propertiesTool.setVisible(true);
|
||||||
// Not sure what the following was meant to accomplish, but it currently causes
|
|
||||||
selectionDisplay.triggerMapping.enable();
|
selectionDisplay.triggerMapping.enable();
|
||||||
|
// Not sure what the following was meant to accomplish, but it currently causes
|
||||||
// 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();
|
||||||
}
|
}
|
||||||
|
@ -580,16 +573,6 @@ function mouseMove(event) {
|
||||||
mouseHasMovedSincePress = true;
|
mouseHasMovedSincePress = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placingEntityID) {
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
|
||||||
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
|
||||||
var offset = Vec3.multiply(distance, pickRay.direction);
|
|
||||||
var position = Vec3.sum(Camera.position, offset);
|
|
||||||
Entities.editEntity(placingEntityID, {
|
|
||||||
position: position,
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isActive) {
|
if (!isActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -624,16 +607,7 @@ function mouseReleaseEvent(event) {
|
||||||
if (propertyMenu.mouseReleaseEvent(event)) {
|
if (propertyMenu.mouseReleaseEvent(event)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (placingEntityID) {
|
|
||||||
|
|
||||||
if (isActive) {
|
|
||||||
|
|
||||||
selectionManager.setSelections([placingEntityID]);
|
|
||||||
}
|
|
||||||
placingEntityID = null;
|
|
||||||
}
|
|
||||||
if (isActive && selectionManager.hasSelection()) {
|
if (isActive && selectionManager.hasSelection()) {
|
||||||
|
|
||||||
tooltip.show(false);
|
tooltip.show(false);
|
||||||
}
|
}
|
||||||
if (mouseCapturedByTool) {
|
if (mouseCapturedByTool) {
|
||||||
|
|
Loading…
Reference in a new issue