mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 05:03:52 +02:00
Add HMD friendly window for the ESS log
This commit is contained in:
parent
0f39356e94
commit
43d2501993
6 changed files with 165 additions and 63 deletions
|
@ -134,6 +134,7 @@
|
|||
#include "devices/Faceshift.h"
|
||||
#include "devices/Leapmotion.h"
|
||||
#include "DiscoverabilityManager.h"
|
||||
#include "EntityScriptServerLogClient.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "InterfaceActionFactory.h"
|
||||
#include "InterfaceLogging.h"
|
||||
|
@ -520,6 +521,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
DependencyManager::set<CompositorHelper>();
|
||||
DependencyManager::set<OffscreenQmlSurfaceCache>();
|
||||
DependencyManager::set<EntityScriptClient>();
|
||||
DependencyManager::set<EntityScriptServerLogClient>();
|
||||
return previousSessionCrashed;
|
||||
}
|
||||
|
||||
|
@ -5524,6 +5526,9 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();
|
||||
scriptEngine->registerGlobalObject("Recording", recordingInterface.data());
|
||||
|
||||
auto entityScriptServerLog = DependencyManager::get<EntityScriptServerLogClient>();
|
||||
scriptEngine->registerGlobalObject("EntityScriptServerLog", entityScriptServerLog.data());
|
||||
|
||||
// connect this script engines printedMessage signal to the global ScriptEngines these various messages
|
||||
connect(scriptEngine, &ScriptEngine::printedMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onPrintedMessage);
|
||||
connect(scriptEngine, &ScriptEngine::errorMessage, DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage);
|
||||
|
|
83
interface/src/EntityScriptServerLogClient.cpp
Normal file
83
interface/src/EntityScriptServerLogClient.cpp
Normal file
|
@ -0,0 +1,83 @@
|
|||
//
|
||||
// EntityScriptServerLogClient.cpp
|
||||
// interface/src
|
||||
//
|
||||
// Created by Clement Brisset on 2/1/17.
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
#include "EntityScriptServerLogClient.h"
|
||||
|
||||
EntityScriptServerLogClient::EntityScriptServerLogClient() {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||
packetReceiver.registerListener(PacketType::EntityServerScriptLog, this, "handleEntityServerScriptLogPacket");
|
||||
|
||||
QObject::connect(nodeList.data(), &NodeList::nodeActivated, this, &EntityScriptServerLogClient::nodeActivated);
|
||||
QObject::connect(nodeList.data(), &NodeList::nodeKilled, this, &EntityScriptServerLogClient::nodeKilled);
|
||||
|
||||
QObject::connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptServerLogClient::canRezChanged);
|
||||
}
|
||||
|
||||
|
||||
void EntityScriptServerLogClient::connectNotify(const QMetaMethod& signal) {
|
||||
auto numReceivers = receivers(SIGNAL(receivedNewLogLines(QString)));
|
||||
if (!_subscribed && numReceivers > 0) {
|
||||
enableToEntityServerScriptLog(DependencyManager::get<NodeList>()->getThisNodeCanRez());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogClient::disconnectNotify(const QMetaMethod& signal) {
|
||||
auto numReceivers = receivers(SIGNAL(receivedNewLogLines(QString)));
|
||||
if (_subscribed && numReceivers == 0) {
|
||||
enableToEntityServerScriptLog(false);
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogClient::enableToEntityServerScriptLog(bool enable) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
if (auto node = nodeList->soloNodeOfType(NodeType::EntityScriptServer)) {
|
||||
auto packet = NLPacket::create(PacketType::EntityServerScriptLog, sizeof(bool), true);
|
||||
packet->writePrimitive(enable);
|
||||
nodeList->sendPacket(std::move(packet), *node);
|
||||
|
||||
if (_subscribed != enable) {
|
||||
if (enable) {
|
||||
emit receivedNewLogLines("====================== Subscribded to the Entity Script Server's log ======================");
|
||||
} else {
|
||||
emit receivedNewLogLines("==================== Unsubscribded from the Entity Script Server's log ====================");
|
||||
}
|
||||
}
|
||||
_subscribed = enable;
|
||||
} else {
|
||||
qWarning() << "Entity Script Server not found";
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogClient::handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
|
||||
emit receivedNewLogLines(QString::fromUtf8(message->readAll()));
|
||||
}
|
||||
|
||||
void EntityScriptServerLogClient::nodeActivated(SharedNodePointer activatedNode) {
|
||||
if (_subscribed && activatedNode->getType() == NodeType::EntityScriptServer) {
|
||||
_subscribed = false;
|
||||
enableToEntityServerScriptLog(DependencyManager::get<NodeList>()->getThisNodeCanRez());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogClient::nodeKilled(SharedNodePointer killedNode) {
|
||||
if (killedNode->getType() == NodeType::EntityScriptServer) {
|
||||
emit receivedNewLogLines("====================== Connection to the Entity Script Server lost ======================");
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogClient::canRezChanged(bool canRez) {
|
||||
auto numReceivers = receivers(SIGNAL(receivedNewLogLines(QString)));
|
||||
if (numReceivers > 0) {
|
||||
enableToEntityServerScriptLog(canRez);
|
||||
}
|
||||
}
|
44
interface/src/EntityScriptServerLogClient.h
Normal file
44
interface/src/EntityScriptServerLogClient.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
//
|
||||
// EntityScriptServerLogClient.h
|
||||
// interface/src
|
||||
//
|
||||
// Created by Clement Brisset on 2/1/17.
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
#ifndef hifi_EntityScriptServerLogClient_h
|
||||
#define hifi_EntityScriptServerLogClient_h
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <NodeList.h>
|
||||
|
||||
class EntityScriptServerLogClient : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EntityScriptServerLogClient();
|
||||
|
||||
signals:
|
||||
void receivedNewLogLines(QString logLines);
|
||||
|
||||
protected:
|
||||
void connectNotify(const QMetaMethod& signal) override;
|
||||
void disconnectNotify(const QMetaMethod& signal) override;
|
||||
|
||||
private slots:
|
||||
void enableToEntityServerScriptLog(bool enable);
|
||||
void handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||
|
||||
void nodeActivated(SharedNodePointer activatedNode);
|
||||
void nodeKilled(SharedNodePointer killedNode);
|
||||
void canRezChanged(bool canRez);
|
||||
|
||||
private:
|
||||
bool _subscribed { false };
|
||||
};
|
||||
|
||||
#endif // hifi_EntityScriptServerLogClient_h
|
|
@ -11,58 +11,13 @@
|
|||
|
||||
#include "EntityScriptServerLogDialog.h"
|
||||
|
||||
#include <EntityScriptServerLogClient.h>
|
||||
|
||||
EntityScriptServerLogDialog::EntityScriptServerLogDialog(QWidget* parent) : BaseLogDialog(parent) {
|
||||
setWindowTitle("Entity Script Server Log");
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
auto& packetReceiver = nodeList->getPacketReceiver();
|
||||
packetReceiver.registerListener(PacketType::EntityServerScriptLog, this, "handleEntityServerScriptLogPacket");
|
||||
|
||||
QObject::connect(nodeList.data(), &NodeList::nodeActivated, this, &EntityScriptServerLogDialog::nodeActivated);
|
||||
QObject::connect(nodeList.data(), &NodeList::nodeKilled, this, &EntityScriptServerLogDialog::nodeKilled);
|
||||
|
||||
QObject::connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptServerLogDialog::enableToEntityServerScriptLog);
|
||||
enableToEntityServerScriptLog(nodeList->getThisNodeCanRez());
|
||||
}
|
||||
|
||||
EntityScriptServerLogDialog::~EntityScriptServerLogDialog() {
|
||||
enableToEntityServerScriptLog(false);
|
||||
}
|
||||
void EntityScriptServerLogDialog::enableToEntityServerScriptLog(bool enable) {
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
if (auto node = nodeList->soloNodeOfType(NodeType::EntityScriptServer)) {
|
||||
auto packet = NLPacket::create(PacketType::EntityServerScriptLog, sizeof(bool), true);
|
||||
packet->writePrimitive(enable);
|
||||
nodeList->sendPacket(std::move(packet), *node);
|
||||
|
||||
if (_subscribed != enable) {
|
||||
if (enable) {
|
||||
appendLogLine("====================== Subscribded to the Entity Script Server's log ======================");
|
||||
} else {
|
||||
appendLogLine("==================== Unsubscribded from the Entity Script Server's log ====================");
|
||||
}
|
||||
}
|
||||
_subscribed = enable;
|
||||
} else {
|
||||
qWarning() << "Entity Script Server not found";
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogDialog::handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) {
|
||||
auto lines = QString::fromUtf8(message->readAll());
|
||||
QMetaObject::invokeMethod(this, "appendLogLine", Q_ARG(QString, lines));
|
||||
}
|
||||
|
||||
void EntityScriptServerLogDialog::nodeActivated(SharedNodePointer activatedNode) {
|
||||
if (_subscribed && activatedNode->getType() == NodeType::EntityScriptServer) {
|
||||
_subscribed = false;
|
||||
enableToEntityServerScriptLog(DependencyManager::get<NodeList>()->getThisNodeCanRez());
|
||||
}
|
||||
}
|
||||
|
||||
void EntityScriptServerLogDialog::nodeKilled(SharedNodePointer killedNode) {
|
||||
if (killedNode->getType() == NodeType::EntityScriptServer) {
|
||||
appendLogLine("====================== Connection to the Entity Script Server lost ======================");
|
||||
}
|
||||
auto client = DependencyManager::get<EntityScriptServerLogClient>();
|
||||
QObject::connect(client.data(), &EntityScriptServerLogClient::receivedNewLogLines,
|
||||
this, &EntityScriptServerLogDialog::appendLogLine);
|
||||
}
|
||||
|
|
|
@ -14,27 +14,14 @@
|
|||
|
||||
#include "BaseLogDialog.h"
|
||||
|
||||
#include <NodeList.h>
|
||||
|
||||
class EntityScriptServerLogDialog : public BaseLogDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EntityScriptServerLogDialog(QWidget* parent = nullptr);
|
||||
~EntityScriptServerLogDialog();
|
||||
|
||||
protected:
|
||||
QString getCurrentLog() override { return QString(); };
|
||||
|
||||
private slots:
|
||||
void enableToEntityServerScriptLog(bool enable);
|
||||
void handleEntityServerScriptLogPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
|
||||
|
||||
void nodeActivated(SharedNodePointer activatedNode);
|
||||
void nodeKilled(SharedNodePointer killedNode);
|
||||
|
||||
private:
|
||||
bool _subscribed { false };
|
||||
};
|
||||
|
||||
#endif // hifi_EntityScriptServerLogDialog_h
|
||||
|
|
28
scripts/developer/debugging/essDebugWindow.js
Normal file
28
scripts/developer/debugging/essDebugWindow.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// essDebugWindow.js
|
||||
//
|
||||
// Created by Clement Brisset on 2/2/17.
|
||||
// Copyright 2017 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
|
||||
//
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
// Set up the qml ui
|
||||
var qml = Script.resolvePath('debugWindow.qml');
|
||||
var window = new OverlayWindow({
|
||||
title: 'Debug Window',
|
||||
source: qml,
|
||||
width: 400, height: 900,
|
||||
});
|
||||
window.setPosition(25, 50);
|
||||
window.closed.connect(function() { Script.stop(); });
|
||||
|
||||
EntityScriptServerLog.receivedNewLogLines.connect(function(message) {
|
||||
window.sendToQml(message);
|
||||
});
|
||||
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue