Showing the changes to interface/src/ui/EntityScriptServerLogDialog.cpp (1 of 2 files). Show all
Unified · Split
| @@ -18,18 +18,21 @@ EntityScriptServerLogDialog::EntityScriptServerLogDialog(QWidget* parent) : Base · 17 unmodified lines | |||
| 18 | auto& packetReceiver = nodeList->getPacketReceiver(); | 18 | auto& packetReceiver = nodeList->getPacketReceiver(); |
| 19 | packetReceiver.registerListener(PacketType::EntityServerScriptLog, this, "handleEntityServerScriptLogPacket"); | 19 | packetReceiver.registerListener(PacketType::EntityServerScriptLog, this, "handleEntityServerScriptLogPacket"); |
| 20 | 20 | ||
| 21 | auto shouldEnableLog = [this] { | 21 | QObject::connect(nodeList.data(), &NodeList::nodeActivated, this, &EntityScriptServerLogDialog::nodeActivated); |
| 22 | auto nodeList = DependencyManager::get<NodeList>(); | 22 | QObject::connect(nodeList.data(), &NodeList::nodeKilled, this, &EntityScriptServerLogDialog::nodeKilled); |
| 23 | enableToEntityServerScriptLog(nodeList->getThisNodeCanRez() || nodeList->getThisNodeCanRezTmp()); | 23 | |
| 24 | }; | 24 | QObject::connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptServerLogDialog::shouldEnableLog); |
| 25 | QObject::connect(nodeList.data(), &NodeList::canRezChanged, this, shouldEnableLog); | 25 | QObject::connect(nodeList.data(), &NodeList::canRezTmpChanged, this, &EntityScriptServerLogDialog::shouldEnableLog); |
| 26 | QObject::connect(nodeList.data(), &NodeList::canRezTmpChanged, this, shouldEnableLog); | ||
| 27 | shouldEnableLog(); | 26 | shouldEnableLog(); |
| 28 | } | 27 | } |
| 29 | 28 | ||
| 30 | EntityScriptServerLogDialog::~EntityScriptServerLogDialog() { | 29 | EntityScriptServerLogDialog::~EntityScriptServerLogDialog() { |
| 31 | enableToEntityServerScriptLog(false); | 30 | enableToEntityServerScriptLog(false); |
| 32 | } | 31 | } |
| 32 | void EntityScriptServerLogDialog::shouldEnableLog() { | ||
| 33 | auto nodeList = DependencyManager::get<NodeList>(); | ||
| 34 | enableToEntityServerScriptLog(nodeList->getThisNodeCanRez() || nodeList->getThisNodeCanRezTmp()); | ||
| 35 | }; | ||
| 33 | 36 | ||
| 34 | void EntityScriptServerLogDialog::enableToEntityServerScriptLog(bool enable) { | 37 | void EntityScriptServerLogDialog::enableToEntityServerScriptLog(bool enable) { |
| 35 | auto nodeList = DependencyManager::get<NodeList>(); | 38 | auto nodeList = DependencyManager::get<NodeList>(); |
| @@ -56,3 +59,16 @@ void EntityScriptServerLogDialog::handleEntityServerScriptLogPacket(QSharedPoint · 20 unmodified lines | |||
| 56 | auto lines = QString::fromUtf8(message->readAll()); | 59 | auto lines = QString::fromUtf8(message->readAll()); |
| 57 | QMetaObject::invokeMethod(this, "appendLogLine", Q_ARG(QString, lines)); | 60 | QMetaObject::invokeMethod(this, "appendLogLine", Q_ARG(QString, lines)); |
| 58 | } | 61 | } |
| 62 | |||
| 63 | void EntityScriptServerLogDialog::nodeActivated(SharedNodePointer activatedNode) { | ||
| 64 | if (_subscribed && activatedNode->getType() == NodeType::EntityScriptServer) { | ||
| 65 | _subscribed = false; | ||
| 66 | shouldEnableLog(); | ||
| 67 | } | ||
| 68 | } | ||
| 69 | |||
| 70 | void EntityScriptServerLogDialog::nodeKilled(SharedNodePointer killedNode) { | ||
| 71 | if (killedNode->getType() == NodeType::EntityScriptServer) { | ||
| 72 | appendLogLine("====================== Connection to the Entity Script Server lost ======================"); | ||
| 73 | } | ||
| 74 | } | ||