mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 09:44:21 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into package_models
This commit is contained in:
commit
d858956ad8
7 changed files with 70 additions and 31 deletions
|
@ -95,6 +95,21 @@ var isActive = false;
|
|||
|
||||
var placingEntityID = null;
|
||||
|
||||
IMPORTING_SVO_OVERLAY_WIDTH = 130;
|
||||
IMPORTING_SVO_OVERLAY_HEIGHT = 30;
|
||||
IMPORTING_SVO_OVERLAY_MARGIN = 6;
|
||||
var importingSVOOverlay = Overlays.addOverlay("text", {
|
||||
font: { size: 14 },
|
||||
text: "Importing SVO...",
|
||||
x: Window.innerWidth - IMPORTING_SVO_OVERLAY_WIDTH - IMPORTING_SVO_OVERLAY_MARGIN,
|
||||
y: Window.innerHeight - IMPORTING_SVO_OVERLAY_HEIGHT - IMPORTING_SVO_OVERLAY_MARGIN,
|
||||
width: IMPORTING_SVO_OVERLAY_WIDTH,
|
||||
height: IMPORTING_SVO_OVERLAY_HEIGHT,
|
||||
backgroundColor: { red: 80, green: 80, blue: 80 },
|
||||
backgroundAlpha: 0.7,
|
||||
visible: false,
|
||||
});
|
||||
|
||||
var toolBar = (function () {
|
||||
var that = {},
|
||||
toolBar,
|
||||
|
@ -753,6 +768,8 @@ Script.scriptEnding.connect(function() {
|
|||
tooltip.cleanup();
|
||||
selectionDisplay.cleanup();
|
||||
Entities.setLightsArePickable(originalLightsArePickable);
|
||||
|
||||
Overlays.deleteOverlay(importingSVOOverlay);
|
||||
});
|
||||
|
||||
// Do some stuff regularly, like check for placement of various overlays
|
||||
|
@ -816,24 +833,7 @@ function handeMenuEvent(menuItem) {
|
|||
}
|
||||
|
||||
if (importURL) {
|
||||
var success = Clipboard.importEntities(importURL);
|
||||
|
||||
if (success) {
|
||||
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
||||
var direction = Quat.getFront(Camera.orientation);
|
||||
var offset = Vec3.multiply(distance, direction);
|
||||
var position = Vec3.sum(Camera.position, offset);
|
||||
|
||||
position.x = Math.max(0, position.x);
|
||||
position.y = Math.max(0, position.y);
|
||||
position.z = Math.max(0, position.z);
|
||||
|
||||
var pastedEntityIDs = Clipboard.pasteEntities(position);
|
||||
|
||||
selectionManager.setSelections(pastedEntityIDs);
|
||||
} else {
|
||||
Window.alert("There was an error importing the entity file.");
|
||||
}
|
||||
importSVO(importURL);
|
||||
}
|
||||
} else if (menuItem == "Entity List...") {
|
||||
entityListTool.toggleVisible();
|
||||
|
@ -841,6 +841,34 @@ function handeMenuEvent(menuItem) {
|
|||
tooltip.show(false);
|
||||
}
|
||||
|
||||
function importSVO(importURL) {
|
||||
Overlays.editOverlay(importingSVOOverlay, { visible: true });
|
||||
|
||||
var success = Clipboard.importEntities(importURL);
|
||||
|
||||
if (success) {
|
||||
var distance = cameraManager.enabled ? cameraManager.zoomDistance : DEFAULT_ENTITY_DRAG_DROP_DISTANCE;
|
||||
var direction = Quat.getFront(Camera.orientation);
|
||||
var offset = Vec3.multiply(distance, direction);
|
||||
var position = Vec3.sum(Camera.position, offset);
|
||||
|
||||
position.x = Math.max(0, position.x);
|
||||
position.y = Math.max(0, position.y);
|
||||
position.z = Math.max(0, position.z);
|
||||
|
||||
var pastedEntityIDs = Clipboard.pasteEntities(position);
|
||||
|
||||
if (isActive) {
|
||||
selectionManager.setSelections(pastedEntityIDs);
|
||||
}
|
||||
} else {
|
||||
Window.alert("There was an error importing the entity file.");
|
||||
}
|
||||
|
||||
Overlays.editOverlay(importingSVOOverlay, { visible: false });
|
||||
}
|
||||
Window.svoImportRequested.connect(importSVO);
|
||||
|
||||
Menu.menuItemEvent.connect(handeMenuEvent);
|
||||
|
||||
Controller.keyPressEvent.connect(function(event) {
|
||||
|
|
|
@ -244,6 +244,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
auto bandwidthRecorder = DependencyManager::set<BandwidthRecorder>();
|
||||
auto resouceCacheSharedItems = DependencyManager::set<ResouceCacheSharedItems>();
|
||||
auto entityScriptingInterface = DependencyManager::set<EntityScriptingInterface>();
|
||||
auto windowScriptingInterface = DependencyManager::set<WindowScriptingInterface>();
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
auto speechRecognizer = DependencyManager::set<SpeechRecognizer>();
|
||||
#endif
|
||||
|
@ -882,9 +883,15 @@ bool Application::event(QEvent* event) {
|
|||
if (event->type() == QEvent::FileOpen) {
|
||||
|
||||
QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
|
||||
|
||||
QUrl url = fileEvent->url();
|
||||
|
||||
if (!fileEvent->url().isEmpty()) {
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
|
||||
if (!url.isEmpty()) {
|
||||
if (url.scheme() == HIFI_URL_SCHEME) {
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(fileEvent->url().toString());
|
||||
} else if (url.url().toLower().endsWith(SVO_EXTENSION)) {
|
||||
emit svoImportRequested(url.url());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1451,6 +1458,10 @@ void Application::dropEvent(QDropEvent *event) {
|
|||
if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {
|
||||
snapshotPath = url.toLocalFile();
|
||||
break;
|
||||
} else if (url.url().toLower().endsWith(SVO_EXTENSION)) {
|
||||
emit svoImportRequested(url.url());
|
||||
event->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3528,7 +3539,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
qScriptRegisterMetaType(scriptEngine, RayToOverlayIntersectionResultToScriptValue,
|
||||
RayToOverlayIntersectionResultFromScriptValue);
|
||||
|
||||
QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", WindowScriptingInterface::getInstance());
|
||||
QScriptValue windowValue = scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
||||
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
||||
LocationScriptingInterface::locationSetter, windowValue);
|
||||
// register `location` on the global object.
|
||||
|
|
|
@ -94,6 +94,7 @@ static const float NODE_KILLED_GREEN = 0.0f;
|
|||
static const float NODE_KILLED_BLUE = 0.0f;
|
||||
|
||||
static const QString SNAPSHOT_EXTENSION = ".jpg";
|
||||
static const QString SVO_EXTENSION = ".svo";
|
||||
|
||||
static const float BILLBOARD_FIELD_OF_VIEW = 30.0f; // degrees
|
||||
static const float BILLBOARD_DISTANCE = 5.56f; // meters
|
||||
|
@ -315,6 +316,8 @@ signals:
|
|||
|
||||
void scriptLocationChanged(const QString& newPath);
|
||||
|
||||
void svoImportRequested(const QString& url);
|
||||
|
||||
public slots:
|
||||
void domainChanged(const QString& domainHostname);
|
||||
void updateWindowTitle();
|
||||
|
|
|
@ -170,7 +170,8 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
|
|||
void GLCanvas::dragEnterEvent(QDragEnterEvent* event) {
|
||||
const QMimeData *mimeData = event->mimeData();
|
||||
foreach (QUrl url, mimeData->urls()) {
|
||||
if (url.url().toLower().endsWith(SNAPSHOT_EXTENSION)) {
|
||||
auto lower = url.url().toLower();
|
||||
if (lower.endsWith(SNAPSHOT_EXTENSION) || lower.endsWith(SVO_EXTENSION)) {
|
||||
event->acceptProposedAction();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ void WebWindowClass::setVisible(bool visible) {
|
|||
QScriptValue WebWindowClass::constructor(QScriptContext* context, QScriptEngine* engine) {
|
||||
WebWindowClass* retVal;
|
||||
QString file = context->argument(0).toString();
|
||||
QMetaObject::invokeMethod(WindowScriptingInterface::getInstance(), "doCreateWebWindow", Qt::BlockingQueuedConnection,
|
||||
QMetaObject::invokeMethod(DependencyManager::get<WindowScriptingInterface>().data(), "doCreateWebWindow", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(WebWindowClass*, retVal),
|
||||
Q_ARG(const QString&, file),
|
||||
Q_ARG(QString, context->argument(1).toString()),
|
||||
|
|
|
@ -25,11 +25,6 @@
|
|||
|
||||
#include "WindowScriptingInterface.h"
|
||||
|
||||
WindowScriptingInterface* WindowScriptingInterface::getInstance() {
|
||||
static WindowScriptingInterface sharedInstance;
|
||||
return &sharedInstance;
|
||||
}
|
||||
|
||||
WindowScriptingInterface::WindowScriptingInterface() :
|
||||
_editDialog(NULL),
|
||||
_nonBlockingFormActive(false),
|
||||
|
@ -37,6 +32,7 @@ WindowScriptingInterface::WindowScriptingInterface() :
|
|||
{
|
||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||
connect(&domainHandler, &DomainHandler::hostnameChanged, this, &WindowScriptingInterface::domainChanged);
|
||||
connect(Application::getInstance(), &Application::svoImportRequested, this, &WindowScriptingInterface::svoImportRequested);
|
||||
}
|
||||
|
||||
WebWindowClass* WindowScriptingInterface::doCreateWebWindow(const QString& title, const QString& url, int width, int height) {
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "WebWindowClass.h"
|
||||
|
||||
class WindowScriptingInterface : public QObject {
|
||||
class WindowScriptingInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(int innerWidth READ getInnerWidth)
|
||||
Q_PROPERTY(int innerHeight READ getInnerHeight)
|
||||
|
@ -29,7 +29,7 @@ class WindowScriptingInterface : public QObject {
|
|||
Q_PROPERTY(int y READ getY)
|
||||
Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible)
|
||||
public:
|
||||
static WindowScriptingInterface* getInstance();
|
||||
WindowScriptingInterface();
|
||||
int getInnerWidth();
|
||||
int getInnerHeight();
|
||||
int getX();
|
||||
|
@ -60,6 +60,7 @@ signals:
|
|||
void domainChanged(const QString& domainHostname);
|
||||
void inlineButtonClicked(const QString& name);
|
||||
void nonBlockingFormClosed();
|
||||
void svoImportRequested(const QString& url);
|
||||
|
||||
private slots:
|
||||
QScriptValue showAlert(const QString& message);
|
||||
|
@ -85,7 +86,6 @@ private slots:
|
|||
WebWindowClass* doCreateWebWindow(const QString& title, const QString& url, int width, int height);
|
||||
|
||||
private:
|
||||
WindowScriptingInterface();
|
||||
QString jsRegExp2QtRegExp(QString string);
|
||||
QDialog* createForm(const QString& title, QScriptValue form);
|
||||
|
||||
|
|
Loading…
Reference in a new issue