diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index e00d72bc6b..8d206f5586 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -12,7 +12,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EntityListTool, Vec3, SelectionManager, +/* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EditTools, EntityListTool, Vec3, SelectionManager, Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera, progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, OverlaySystemWindow, keyUpEventFromUIWindow:true */ @@ -37,7 +37,8 @@ Script.include([ "entityList/entityList.js", "entitySelectionTool/entitySelectionTool.js", "audioFeedback/audioFeedback.js", - "modules/brokenURLReport.js" + "modules/brokenURLReport.js", + "editModes/editModes.js" ]); var CreateWindow = Script.require('./modules/createWindow.js'); @@ -127,6 +128,10 @@ var gridTool = new GridTool({ }); gridTool.setVisible(false); +var editTools = new EditTools({ + createToolsWindow: createToolsWindow, +}); + var entityShapeVisualizerSessionName = "SHAPE_VISUALIZER_" + Uuid.generate(); var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js'); diff --git a/scripts/system/create/editModes/editModes.js b/scripts/system/create/editModes/editModes.js new file mode 100644 index 0000000000..d3a6b9d202 --- /dev/null +++ b/scripts/system/create/editModes/editModes.js @@ -0,0 +1,178 @@ +// +// editModes.js +// +// Created by Karol Suprynowicz on 2022.05.15. +// Copyright 2022 Overte e.V. +// +// Partially based on gridTool.js +// Created by Ryan Huffman on 6 Nov 2014 +// Copyright 2014 High Fidelity, Inc. +// Copyright 2020 Vircadia contributors. +// Copyright 2022 Overte e.V. +// +// This script implements a class for managing different edit modes +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +EditTools = function(options) { + var that = {}; + + var createAppMode = "object"; + var voxelEditMode = "single"; + var voxelSphereSize = 0.3; + var voxelEditDynamics = "click"; + var voxelRemove = false; + var voxelPointerMode = "single"; + var voxelBrushLength = 0.5; + var listeners = []; + + var createToolsWindow = options.createToolsWindow; + + that.emitUpdate = function() { + var dataString = JSON.stringify({ + createAppMode : createAppMode, + voxelEditMode : voxelEditMode, + voxelSphereSize : voxelSphereSize, + voxelEditDynamics : voxelEditDynamics, + voxelRemove : voxelRemove, + voxelPointerMode : voxelPointerMode, + voxelBrushLength : voxelBrushLength, + }); + webView.emitScriptEvent(dataString); + createToolsWindow.emitScriptEvent(dataString); + }; + + that.getCreateAppMode = function() { + return createAppMode; + } + + that.setCreateAppMode = function(value) { + createAppMode = value; + that.emitUpdate(); + } + + that.getVoxelEditMode = function() { + return voxelEditMode; + } + + that.setVoxelEditMode = function(value) { + voxelEditMode = value; + that.emitUpdate(); + } + + that.getVoxelSphereSize = function() { + return voxelSphereSize; + } + + that.setVoxelSphereSize = function(value) { + voxelSphereSize = value; + that.emitUpdate(); + } + + that.getVoxelEditDynamics = function() { + return voxelEditDynamics; + } + + that.setVoxelEditDynamics = function(value) { + voxelEditDynamics = value; + that.emitUpdate(); + } + + that.getVoxelRemove = function() { + return voxelRemove; + } + + that.setVoxelRemove = function(value) { + voxelRemove = value; + that.emitUpdate(); + } + + that.getVoxelPointerMode = function() { + return voxelPointerMode; + } + + that.setVoxelPointerMode = function(value) { + voxelPointerMode = value; + that.emitUpdate(); + } + + that.getVoxelBrushLength = function() { + return voxelBrushLength; + } + + that.setVoxelBrushLength = function(value) { + voxelBrushLength = value; + that.emitUpdate(); + } + + that.update = function(data) { + if (data.type !== "update-edit-tools") { + return; + } + + var needsUpdate = false; + + if (data.createAppMode) { + createAppMode = data.createAppMode; + needsUpdate = true; + } + if (data.voxelEditMode) { + voxelEditMode = data.voxelEditMode; + needsUpdate = true; + } + if (data.voxelSphereSize) { + voxelSphereSize = data.voxelSphereSize; + needsUpdate = true; + } + if (data.voxelEditDynamics) { + voxelEditDynamics = data.voxelEditDynamics; + needsUpdate = true; + } + if (data.voxelRemove) { + voxelRemove = data.voxelRemove; + needsUpdate = true; + } + if (data.voxelPointerMode) { + voxelPointerMode = data.voxelPointerMode; + needsUpdate = true; + } + if (data.voxelBrushLength) { + voxelBrushLength = data.voxelBrushLength; + needsUpdate = true; + } + } + + var webEventReceived = function(data) { + try { + data = JSON.parse(data); + } catch (e) { + return; + } + + if (data.type === "init") { + that.emitUpdate(); + } else if (data.type === "update-edit-tools") { + that.update(data); + for (var i = 0; i < listeners.length; i++) { + listeners[i] && listeners[i](data); + } + } + }; + + var webView = null; + webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + + webView.webEventReceived.connect(webEventReceived); + createToolsWindow.webEventReceived.addListener(webEventReceived); + + that.addListener = function(callback) { + listeners.push(callback); + }; + + function cleanup() { + } + + return that; +} diff --git a/scripts/system/create/qml/EditTabView.qml b/scripts/system/create/qml/EditTabView.qml index b122370192..96e66c109e 100644 --- a/scripts/system/create/qml/EditTabView.qml +++ b/scripts/system/create/qml/EditTabView.qml @@ -286,7 +286,7 @@ TabBar { } EditTabButton { - title: "GRID" + title: "TOOLS" active: true enabled: true property string originalUrl: "" diff --git a/scripts/system/create/qml/EditToolsTabView.qml b/scripts/system/create/qml/EditToolsTabView.qml index bd4d47ddea..998c3a3aac 100644 --- a/scripts/system/create/qml/EditToolsTabView.qml +++ b/scripts/system/create/qml/EditToolsTabView.qml @@ -276,7 +276,7 @@ TabBar { } EditTabButton { - title: "GRID" + title: "TOOLS" active: true enabled: true property string originalUrl: "" diff --git a/scripts/system/create/qml/NewPolyVoxDialog.qml b/scripts/system/create/qml/NewPolyVoxDialog.qml index bbc9e7281a..fde7d075e0 100644 --- a/scripts/system/create/qml/NewPolyVoxDialog.qml +++ b/scripts/system/create/qml/NewPolyVoxDialog.qml @@ -74,39 +74,39 @@ Rectangle { switch (currentIndex) { // Clear texture entries case 0: - xTextureURL.text = "" - yTextureURL.text = "" - zTextureURL.text = "" + xTextureURL.text = ""; + yTextureURL.text = ""; + zTextureURL.text = ""; break; // Grass + ground case 1: - xTextureURL.text = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg" - yTextureURL.text = "qrc:///serverless/Textures/ground_grass_gen_05.png" - zTextureURL.text = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg" + xTextureURL.text = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg"; + yTextureURL.text = "qrc:///serverless/Textures/ground_grass_gen_05.png"; + zTextureURL.text = "qrc:///serverless/Textures/ground_5-2K/2K-ground_5-diffuse.jpg"; break; // Bricks case 2: - xTextureURL.text = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg" - yTextureURL.text = "qrc:///serverless/Textures/2K-stone_floor_3-diffuse_l.jpg" - zTextureURL.text = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg" + xTextureURL.text = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg"; + yTextureURL.text = "qrc:///serverless/Textures/2K-stone_floor_3-diffuse_l.jpg"; + zTextureURL.text = "qrc:///serverless/Textures/2K-wall_stone_2-diffuse_l.jpg"; break; // Stone case 3: - xTextureURL.text = "qrc:///serverless/Textures/wall_l.png" - yTextureURL.text = "qrc:///serverless/Textures/floor_l.png" - zTextureURL.text = "qrc:///serverless/Textures/wall_l.png" + xTextureURL.text = "qrc:///serverless/Textures/wall_l.png"; + yTextureURL.text = "qrc:///serverless/Textures/floor_l.png"; + zTextureURL.text = "qrc:///serverless/Textures/wall_l.png"; break; // Concrete case 4: - xTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg" - yTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg" - zTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg" + xTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg"; + yTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg"; + zTextureURL.text = "qrc:///serverless/Textures/concrete_12-2K/2K-concrete_12-diffuse.jpg"; break; // Rock case 5: - xTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg" - yTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg" - zTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg" + xTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg"; + yTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg"; + zTextureURL.text = "qrc:///serverless/Textures/Rock026_2K-JPG/Rock026_2K_Color.jpg"; break; } } diff --git a/scripts/system/html/gridControls.html b/scripts/system/html/gridControls.html index 8d6ee34bc0..9c21fbdb0d 100644 --- a/scripts/system/html/gridControls.html +++ b/scripts/system/html/gridControls.html @@ -3,6 +3,7 @@ // // Created by Ryan Huffman on 6 Nov 2014 // Copyright 2014 High Fidelity, Inc. +// Copyright 2022 Overte e.V. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html @@ -20,7 +21,55 @@
+