diff --git a/animation-server/src/AnimationServer.cpp b/animation-server/src/AnimationServer.cpp
index ffb98b4ae0..32a95b48ea 100644
--- a/animation-server/src/AnimationServer.cpp
+++ b/animation-server/src/AnimationServer.cpp
@@ -171,7 +171,7 @@ static void renderMovingBug() {
}
} else {
- //printf("bugPathCenter=(%f,%f,%f)\n", bugPathCenter.x, bugPathCenter.y, bugPathCenter.z);
+ //qDebug("bugPathCenter=(%f,%f,%f)", bugPathCenter.x, bugPathCenter.y, bugPathCenter.z);
bugPathTheta += bugAngleDelta; // move slightly
bugRotation -= bugAngleDelta; // rotate slightly
@@ -187,12 +187,12 @@ static void renderMovingBug() {
float y = bugPathCenter.y;
bugPosition = glm::vec3(x, y, z);
- //printf("bugPathTheta=%f\n", bugPathTheta);
- //printf("bugRotation=%f\n", bugRotation);
+ //qDebug("bugPathTheta=%f", bugPathTheta);
+ //qDebug("bugRotation=%f", bugRotation);
}
- //printf("bugPosition=(%f,%f,%f)\n", bugPosition.x, bugPosition.y, bugPosition.z);
- //printf("bugDirection=(%f,%f,%f)\n", bugDirection.x, bugDirection.y, bugDirection.z);
+ //qDebug("bugPosition=(%f,%f,%f)", bugPosition.x, bugPosition.y, bugPosition.z);
+ //qDebug("bugDirection=(%f,%f,%f)", bugDirection.x, bugDirection.y, bugDirection.z);
// would be nice to add some randomness here...
// Generate voxels for where bug is going to
@@ -690,32 +690,32 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
// Handle Local Domain testing with the --local command line
const char* NON_THREADED_PACKETSENDER = "--NonThreadedPacketSender";
::nonThreadedPacketSender = cmdOptionExists(argc, (const char**) argv, NON_THREADED_PACKETSENDER);
- printf("nonThreadedPacketSender=%s\n", debug::valueOf(::nonThreadedPacketSender));
+ qDebug("nonThreadedPacketSender=%s", debug::valueOf(::nonThreadedPacketSender));
// Handle Local Domain testing with the --local command line
const char* NO_BILLBOARD = "--NoBillboard";
::includeBillboard = !cmdOptionExists(argc, (const char**) argv, NO_BILLBOARD);
- printf("includeBillboard=%s\n", debug::valueOf(::includeBillboard));
+ qDebug("includeBillboard=%s", debug::valueOf(::includeBillboard));
const char* NO_BORDER_TRACER = "--NoBorderTracer";
::includeBorderTracer = !cmdOptionExists(argc, (const char**) argv, NO_BORDER_TRACER);
- printf("includeBorderTracer=%s\n", debug::valueOf(::includeBorderTracer));
+ qDebug("includeBorderTracer=%s", debug::valueOf(::includeBorderTracer));
const char* NO_MOVING_BUG = "--NoMovingBug";
::includeMovingBug = !cmdOptionExists(argc, (const char**) argv, NO_MOVING_BUG);
- printf("includeMovingBug=%s\n", debug::valueOf(::includeMovingBug));
+ qDebug("includeMovingBug=%s", debug::valueOf(::includeMovingBug));
const char* INCLUDE_BLINKING_VOXEL = "--includeBlinkingVoxel";
::includeBlinkingVoxel = cmdOptionExists(argc, (const char**) argv, INCLUDE_BLINKING_VOXEL);
- printf("includeBlinkingVoxel=%s\n", debug::valueOf(::includeBlinkingVoxel));
+ qDebug("includeBlinkingVoxel=%s", debug::valueOf(::includeBlinkingVoxel));
const char* NO_DANCE_FLOOR = "--NoDanceFloor";
::includeDanceFloor = !cmdOptionExists(argc, (const char**) argv, NO_DANCE_FLOOR);
- printf("includeDanceFloor=%s\n", debug::valueOf(::includeDanceFloor));
+ qDebug("includeDanceFloor=%s", debug::valueOf(::includeDanceFloor));
const char* BUILD_STREET = "--BuildStreet";
::buildStreet = cmdOptionExists(argc, (const char**) argv, BUILD_STREET);
- printf("buildStreet=%s\n", debug::valueOf(::buildStreet));
+ qDebug("buildStreet=%s", debug::valueOf(::buildStreet));
// Handle Local Domain testing with the --local command line
const char* showPPS = "--showPPS";
@@ -725,7 +725,7 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
const char* local = "--local";
::wantLocalDomain = cmdOptionExists(argc, (const char**) argv,local);
if (::wantLocalDomain) {
- printf("Local Domain MODE!\n");
+ qDebug("Local Domain MODE!");
nodeList->getDomainHandler().setIPToLocalhost();
}
@@ -738,7 +738,7 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
if (packetsPerSecondCommand) {
::packetsPerSecond = atoi(packetsPerSecondCommand);
}
- printf("packetsPerSecond=%d\n",packetsPerSecond);
+ qDebug("packetsPerSecond=%d",packetsPerSecond);
const char* animateFPSCommand = getCmdOption(argc, (const char**) argv, "--AnimateFPS");
const char* animateIntervalCommand = getCmdOption(argc, (const char**) argv, "--AnimateInterval");
@@ -753,8 +753,8 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs
}
}
- printf("ANIMATE_FPS=%d\n",ANIMATE_FPS);
- printf("ANIMATE_VOXELS_INTERVAL_USECS=%llu\n",ANIMATE_VOXELS_INTERVAL_USECS);
+ qDebug("ANIMATE_FPS=%d",ANIMATE_FPS);
+ qDebug("ANIMATE_VOXELS_INTERVAL_USECS=%llu",ANIMATE_VOXELS_INTERVAL_USECS);
const char* processingFPSCommand = getCmdOption(argc, (const char**) argv, "--ProcessingFPS");
const char* processingIntervalCommand = getCmdOption(argc, (const char**) argv, "--ProcessingInterval");
@@ -769,8 +769,8 @@ AnimationServer::AnimationServer(int &argc, char **argv) :
::PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000.0) - FUDGE_USECS; // converts from milliseconds to usecs
}
}
- printf("PROCESSING_FPS=%d\n",PROCESSING_FPS);
- printf("PROCESSING_INTERVAL_USECS=%llu\n",PROCESSING_INTERVAL_USECS);
+ qDebug("PROCESSING_FPS=%d",PROCESSING_FPS);
+ qDebug("PROCESSING_INTERVAL_USECS=%llu",PROCESSING_INTERVAL_USECS);
nodeList->linkedDataCreateCallback = NULL; // do we need a callback?
diff --git a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp
index 41158bf339..545c502036 100644
--- a/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp
+++ b/assignment-client/src/octree/OctreeInboundPacketProcessor.cpp
@@ -45,7 +45,7 @@ void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendin
bool debugProcessPacket = _myServer->wantsVerboseDebug();
if (debugProcessPacket) {
- printf("OctreeInboundPacketProcessor::processPacket() packetData=%p packetLength=%d\n", &packet, packet.size());
+ qDebug("OctreeInboundPacketProcessor::processPacket() packetData=%p packetLength=%d", &packet, packet.size());
}
int numBytesPacketHeader = numBytesForPacketHeader(packet);
@@ -78,8 +78,8 @@ void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendin
int maxSize = packet.size() - atByte;
if (debugProcessPacket) {
- printf("OctreeInboundPacketProcessor::processPacket() %c "
- "packetData=%p packetLength=%d voxelData=%p atByte=%d maxSize=%d\n",
+ qDebug("OctreeInboundPacketProcessor::processPacket() %c "
+ "packetData=%p packetLength=%d voxelData=%p atByte=%d maxSize=%d",
packetType, packetData, packet.size(), editData, atByte, maxSize);
}
@@ -105,8 +105,8 @@ void OctreeInboundPacketProcessor::processPacket(const SharedNodePointer& sendin
}
if (debugProcessPacket) {
- printf("OctreeInboundPacketProcessor::processPacket() DONE LOOPING FOR %c "
- "packetData=%p packetLength=%d voxelData=%p atByte=%d\n",
+ qDebug("OctreeInboundPacketProcessor::processPacket() DONE LOOPING FOR %c "
+ "packetData=%p packetLength=%d voxelData=%p atByte=%d",
packetType, packetData, packet.size(), editData, atByte);
}
diff --git a/interface/resources/icons/load-script.svg b/interface/resources/icons/load-script.svg
new file mode 100644
index 0000000000..21be61c321
--- /dev/null
+++ b/interface/resources/icons/load-script.svg
@@ -0,0 +1,125 @@
+
+
+
+
diff --git a/interface/resources/icons/new-script.svg b/interface/resources/icons/new-script.svg
new file mode 100644
index 0000000000..f68fcfa967
--- /dev/null
+++ b/interface/resources/icons/new-script.svg
@@ -0,0 +1,129 @@
+
+
+
+
diff --git a/interface/resources/icons/save-script.svg b/interface/resources/icons/save-script.svg
new file mode 100644
index 0000000000..04d41b8302
--- /dev/null
+++ b/interface/resources/icons/save-script.svg
@@ -0,0 +1,674 @@
+
+
+
+
diff --git a/interface/resources/icons/start-script.svg b/interface/resources/icons/start-script.svg
new file mode 100644
index 0000000000..86354a555d
--- /dev/null
+++ b/interface/resources/icons/start-script.svg
@@ -0,0 +1,557 @@
+
+
+
+
diff --git a/interface/resources/icons/stop-script.svg b/interface/resources/icons/stop-script.svg
new file mode 100644
index 0000000000..31cdcee749
--- /dev/null
+++ b/interface/resources/icons/stop-script.svg
@@ -0,0 +1,163 @@
+
+
+
+
diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp
index 1e3d3a2259..55933ce069 100644
--- a/interface/src/Application.cpp
+++ b/interface/src/Application.cpp
@@ -795,6 +795,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
if (activeWindow() == _window) {
bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier);
bool isMeta = event->modifiers().testFlag(Qt::ControlModifier);
+ bool isOption = event->modifiers().testFlag(Qt::AltModifier);
switch (event->key()) {
break;
case Qt::Key_BracketLeft:
@@ -839,9 +840,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
break;
case Qt::Key_S:
- if (isShifted && isMeta) {
+ if (isShifted && isMeta && !isOption) {
Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
- } else if (!isShifted && isMeta) {
+ } else if (isOption && !isShifted && !isMeta) {
+ Menu::getInstance()->triggerOption(MenuOption::ScriptEditor);
+ } else if (!isOption && !isShifted && isMeta) {
takeSnapshot();
} else {
_myAvatar->setDriveKeys(BACK, 1.f);
@@ -3115,7 +3118,7 @@ void Application::nodeKilled(SharedNodePointer node) {
VoxelPositionSize rootDetails;
voxelDetailsForCode(rootCode, rootDetails);
- printf("voxel server going away...... v[%f, %f, %f, %f]\n",
+ qDebug("voxel server going away...... v[%f, %f, %f, %f]",
rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
// Add the jurisditionDetails object to the list of "fade outs"
@@ -3146,7 +3149,7 @@ void Application::nodeKilled(SharedNodePointer node) {
VoxelPositionSize rootDetails;
voxelDetailsForCode(rootCode, rootDetails);
- printf("particle server going away...... v[%f, %f, %f, %f]\n",
+ qDebug("particle server going away...... v[%f, %f, %f, %f]",
rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
// Add the jurisditionDetails object to the list of "fade outs"
@@ -3227,7 +3230,7 @@ int Application::parseOctreeStats(const QByteArray& packet, const SharedNodePoin
if (jurisdiction->find(nodeUUID) == jurisdiction->end()) {
- printf("stats from new server... v[%f, %f, %f, %f]\n",
+ qDebug("stats from new server... v[%f, %f, %f, %f]",
rootDetails.x, rootDetails.y, rootDetails.z, rootDetails.s);
// Add the jurisditionDetails object to the list of "fade outs"
@@ -3299,13 +3302,14 @@ void Application::stopAllScripts() {
bumpSettings();
}
-void Application::stopScript(const QString &scriptName)
-{
- _scriptEnginesHash.value(scriptName)->stop();
- qDebug() << "stopping script..." << scriptName;
- _scriptEnginesHash.remove(scriptName);
- _runningScriptsWidget->setRunningScripts(getRunningScripts());
- bumpSettings();
+void Application::stopScript(const QString &scriptName) {
+ if (_scriptEnginesHash.contains(scriptName)) {
+ _scriptEnginesHash.value(scriptName)->stop();
+ qDebug() << "stopping script..." << scriptName;
+ _scriptEnginesHash.remove(scriptName);
+ _runningScriptsWidget->setRunningScripts(getRunningScripts());
+ bumpSettings();
+ }
}
void Application::reloadAllScripts() {
@@ -3366,7 +3370,10 @@ void Application::uploadSkeleton() {
uploadFST(false);
}
-void Application::loadScript(const QString& scriptName) {
+ScriptEngine* Application::loadScript(const QString& scriptName, bool loadScriptFromEditor) {
+ if(loadScriptFromEditor && _scriptEnginesHash.contains(scriptName) && !_scriptEnginesHash[scriptName]->isFinished()){
+ return _scriptEnginesHash[scriptName];
+ }
// start the script on a new thread...
ScriptEngine* scriptEngine = new ScriptEngine(QUrl(scriptName), &_controllerScriptingInterface);
@@ -3374,7 +3381,7 @@ void Application::loadScript(const QString& scriptName) {
if (!scriptEngine->hasScript()) {
qDebug() << "Application::loadScript(), script failed to load...";
- return;
+ return NULL;
}
_runningScriptsWidget->setRunningScripts(getRunningScripts());
@@ -3422,8 +3429,12 @@ void Application::loadScript(const QString& scriptName) {
workerThread->start();
// restore the main window's active state
- _window->activateWindow();
+ if (!loadScriptFromEditor) {
+ _window->activateWindow();
+ }
bumpSettings();
+
+ return scriptEngine;
}
void Application::loadDialog() {
diff --git a/interface/src/Application.h b/interface/src/Application.h
index 36758a26db..5983b0d1a9 100644
--- a/interface/src/Application.h
+++ b/interface/src/Application.h
@@ -121,7 +121,7 @@ public:
~Application();
void restoreSizeAndPosition();
- void loadScript(const QString& fileNameString);
+ ScriptEngine* loadScript(const QString& fileNameString, bool loadScriptFromEditor = false);
void loadScripts();
void storeSizeAndPosition();
void clearScriptsBeforeRunning();
@@ -247,6 +247,7 @@ public:
void skipVersion(QString latestVersion);
QStringList getRunningScripts() { return _scriptEnginesHash.keys(); }
+ ScriptEngine* getScriptEngine(QString scriptHash) { return _scriptEnginesHash.contains(scriptHash) ? _scriptEnginesHash[scriptHash] : NULL; }
signals:
diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp
index 92260ad9dc..6525e79cf2 100644
--- a/interface/src/DatagramProcessor.cpp
+++ b/interface/src/DatagramProcessor.cpp
@@ -78,7 +78,7 @@ void DatagramProcessor::processDatagrams() {
OCTREE_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
int flightTime = arrivedAt - sentAt;
- printf("got PacketType_VOXEL_DATA, sequence:%d flightTime:%d\n", sequence, flightTime);
+ qDebug("got PacketType_VOXEL_DATA, sequence:%d flightTime:%d", sequence, flightTime);
}
SharedNodePointer matchedNode = NodeList::getInstance()->sendingNodeForPacket(incomingPacket);
diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp
index 7cdd72afd5..b5b0f65d82 100644
--- a/interface/src/Menu.cpp
+++ b/interface/src/Menu.cpp
@@ -195,6 +195,7 @@ Menu::Menu() :
QMenu* toolsMenu = addMenu("Tools");
addActionToQMenuAndActionHash(toolsMenu, MenuOption::MetavoxelEditor, 0, this, SLOT(showMetavoxelEditor()));
+ addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, Qt::ALT | Qt::Key_S, this, SLOT(showScriptEditor()));
#ifdef HAVE_QXMPP
_chatAction = addActionToQMenuAndActionHash(toolsMenu,
@@ -1124,6 +1125,13 @@ void Menu::showMetavoxelEditor() {
_MetavoxelEditor->raise();
}
+void Menu::showScriptEditor() {
+ if(!_ScriptEditor || !_ScriptEditor->isVisible()) {
+ _ScriptEditor = new ScriptEditorWindow();
+ }
+ _ScriptEditor->raise();
+}
+
void Menu::showChat() {
QMainWindow* mainWindow = Application::getInstance()->getWindow();
if (!_chatWindow) {
diff --git a/interface/src/Menu.h b/interface/src/Menu.h
index 597ae4a74b..a55570afaf 100644
--- a/interface/src/Menu.h
+++ b/interface/src/Menu.h
@@ -26,6 +26,7 @@
#include "location/LocationManager.h"
#include "ui/PreferencesDialog.h"
#include "ui/ChatWindow.h"
+#include "ui/ScriptEditorWindow.h"
const float ADJUST_LOD_DOWN_FPS = 40.0;
const float ADJUST_LOD_UP_FPS = 55.0;
@@ -177,6 +178,7 @@ private slots:
void cycleFrustumRenderMode();
void runTests();
void showMetavoxelEditor();
+ void showScriptEditor();
void showChat();
void toggleChat();
void audioMuteToggled();
@@ -228,6 +230,7 @@ private:
FrustumDrawMode _frustumDrawMode;
ViewFrustumOffset _viewFrustumOffset;
QPointer _MetavoxelEditor;
+ QPointer _ScriptEditor;
QPointer _chatWindow;
OctreeStatsDialog* _octreeStatsDialog;
LodToolsDialog* _lodToolsDialog;
@@ -345,6 +348,7 @@ namespace MenuOption {
const QString ResetAvatarSize = "Reset Avatar Size";
const QString RunningScripts = "Running Scripts";
const QString RunTimingTests = "Run Timing Tests";
+ const QString ScriptEditor = "Script Editor...";
const QString SettingsExport = "Export Settings";
const QString SettingsImport = "Import Settings";
const QString Shadows = "Shadows";
diff --git a/interface/src/ScriptHighlighting.cpp b/interface/src/ScriptHighlighting.cpp
new file mode 100644
index 0000000000..3ab1394097
--- /dev/null
+++ b/interface/src/ScriptHighlighting.cpp
@@ -0,0 +1,95 @@
+//
+// ScriptHighlighting.cpp
+// interface/src
+//
+// Created by Thijs Wenker on 4/15/14.
+// Copyright 2014 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 "ScriptHighlighting.h"
+#include
+
+ScriptHighlighting::ScriptHighlighting(QTextDocument* parent) :
+ QSyntaxHighlighter(parent)
+{
+ _keywordRegex = QRegExp("\\b(break|case|catch|continue|debugger|default|delete|do|else|finally|for|function|if|in|instanceof|new|return|switch|this|throw|try|typeof|var|void|while|with)\\b");
+ _qoutedTextRegex = QRegExp("\".*\"");
+ _multiLineCommentBegin = QRegExp("/\\*");
+ _multiLineCommentEnd = QRegExp("\\*/");
+ _numberRegex = QRegExp("[0-9]+(\\.[0-9]+){0,1}");
+ _singleLineComment = QRegExp("//[^\n]*");
+ _truefalseRegex = QRegExp("\\b(true|false)\\b");
+}
+
+void ScriptHighlighting::highlightBlock(const QString& text) {
+ this->highlightKeywords(text);
+ this->formatNumbers(text);
+ this->formatTrueFalse(text);
+ this->formatQoutedText(text);
+ this->formatComments(text);
+}
+
+void ScriptHighlighting::highlightKeywords(const QString& text) {
+ int index = _keywordRegex.indexIn(text);
+ while (index >= 0) {
+ int length = _keywordRegex.matchedLength();
+ setFormat(index, length, Qt::blue);
+ index = _keywordRegex.indexIn(text, index + length);
+ }
+}
+
+void ScriptHighlighting::formatComments(const QString& text) {
+
+ setCurrentBlockState(BlockStateClean);
+
+ int start = (previousBlockState() != BlockStateInMultiComment) ? text.indexOf(_multiLineCommentBegin) : 0;
+
+ while (start > -1) {
+ int end = text.indexOf(_multiLineCommentEnd, start);
+ int length = (end == -1 ? text.length() : (end + _multiLineCommentEnd.matchedLength())) - start;
+ setFormat(start, length, Qt::lightGray);
+ start = text.indexOf(_multiLineCommentBegin, start + length);
+ if (end == -1) {
+ setCurrentBlockState(BlockStateInMultiComment);
+ }
+ }
+
+ int index = _singleLineComment.indexIn(text);
+ while (index >= 0) {
+ int length = _singleLineComment.matchedLength();
+ setFormat(index, length, Qt::lightGray);
+ index = _singleLineComment.indexIn(text, index + length);
+ }
+}
+
+void ScriptHighlighting::formatQoutedText(const QString& text){
+ int index = _qoutedTextRegex.indexIn(text);
+ while (index >= 0) {
+ int length = _qoutedTextRegex.matchedLength();
+ setFormat(index, length, Qt::red);
+ index = _qoutedTextRegex.indexIn(text, index + length);
+ }
+}
+
+void ScriptHighlighting::formatNumbers(const QString& text){
+ int index = _numberRegex.indexIn(text);
+ while (index >= 0) {
+ int length = _numberRegex.matchedLength();
+ setFormat(index, length, Qt::green);
+ index = _numberRegex.indexIn(text, index + length);
+ }
+}
+
+void ScriptHighlighting::formatTrueFalse(const QString& text){
+ int index = _truefalseRegex.indexIn(text);
+ while (index >= 0) {
+ int length = _truefalseRegex.matchedLength();
+ QFont* font = new QFont(this->document()->defaultFont());
+ font->setBold(true);
+ setFormat(index, length, *font);
+ index = _truefalseRegex.indexIn(text, index + length);
+ }
+}
diff --git a/interface/src/ScriptHighlighting.h b/interface/src/ScriptHighlighting.h
new file mode 100644
index 0000000000..d86d6f4d77
--- /dev/null
+++ b/interface/src/ScriptHighlighting.h
@@ -0,0 +1,46 @@
+//
+// ScriptHighlighting.h
+// interface/src
+//
+// Created by Thijs Wenker on 4/15/14.
+// Copyright 2014 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_ScriptHighlighting_h
+#define hifi_ScriptHighlighting_h
+
+#include
+
+class ScriptHighlighting : public QSyntaxHighlighter {
+ Q_OBJECT
+
+public:
+ ScriptHighlighting(QTextDocument* parent = NULL);
+
+ enum BlockState {
+ BlockStateClean,
+ BlockStateInMultiComment
+ };
+
+protected:
+ void highlightBlock(const QString& text);
+ void highlightKeywords(const QString& text);
+ void formatComments(const QString& text);
+ void formatQoutedText(const QString& text);
+ void formatNumbers(const QString& text);
+ void formatTrueFalse(const QString& text);
+
+private:
+ QRegExp _keywordRegex;
+ QRegExp _qoutedTextRegex;
+ QRegExp _multiLineCommentBegin;
+ QRegExp _multiLineCommentEnd;
+ QRegExp _numberRegex;
+ QRegExp _singleLineComment;
+ QRegExp _truefalseRegex;
+};
+
+#endif // hifi_ScriptHighlighting_h
diff --git a/interface/src/Util.cpp b/interface/src/Util.cpp
index 7913ff2f47..16dd35f316 100644
--- a/interface/src/Util.cpp
+++ b/interface/src/Util.cpp
@@ -63,7 +63,7 @@ void eulerToOrthonormals(glm::vec3 * angles, glm::vec3 * front, glm::vec3 * righ
}
void printVector(glm::vec3 vec) {
- printf("%4.2f, %4.2f, %4.2f\n", vec.x, vec.y, vec.z);
+ qDebug("%4.2f, %4.2f, %4.2f", vec.x, vec.y, vec.z);
}
// Return the azimuth angle (in radians) between two points.
diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp
index 8229611646..317f408aa7 100644
--- a/interface/src/avatar/MyAvatar.cpp
+++ b/interface/src/avatar/MyAvatar.cpp
@@ -432,7 +432,7 @@ void MyAvatar::renderDebugBodyPoints() {
glm::vec3 headPosition(getHead()->getEyePosition());
float torsoToHead = glm::length(headPosition - torsoPosition);
glm::vec3 position;
- printf("head-above-torso %.2f, scale = %0.2f\n", torsoToHead, getScale());
+ qDebug("head-above-torso %.2f, scale = %0.2f", torsoToHead, getScale());
// Torso Sphere
position = torsoPosition;
diff --git a/interface/src/devices/SixenseManager.cpp b/interface/src/devices/SixenseManager.cpp
index b950e6097c..f7c00411c1 100644
--- a/interface/src/devices/SixenseManager.cpp
+++ b/interface/src/devices/SixenseManager.cpp
@@ -96,7 +96,7 @@ void SixenseManager::update(float deltaTime) {
hand->getPalms().push_back(newPalm);
palm = &(hand->getPalms()[hand->getNumPalms() - 1]);
palm->setSixenseID(data->controller_index);
- printf("Found new Sixense controller, ID %i\n", data->controller_index);
+ qDebug("Found new Sixense controller, ID %i", data->controller_index);
}
palm->setActive(true);
diff --git a/interface/src/ui/ScriptEditorWidget.cpp b/interface/src/ui/ScriptEditorWidget.cpp
new file mode 100644
index 0000000000..1765a5ea1a
--- /dev/null
+++ b/interface/src/ui/ScriptEditorWidget.cpp
@@ -0,0 +1,158 @@
+//
+// ScriptEditorWidget.cpp
+// interface/src/ui
+//
+// Created by Thijs Wenker on 4/14/14.
+// Copyright 2014 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 "ui_scriptEditorWidget.h"
+#include "ScriptEditorWidget.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "Application.h"
+#include "ScriptHighlighting.h"
+
+ScriptEditorWidget::ScriptEditorWidget() :
+ _scriptEditorWidgetUI(new Ui::ScriptEditorWidget),
+ _scriptEngine(NULL)
+{
+ _scriptEditorWidgetUI->setupUi(this);
+
+ connect(_scriptEditorWidgetUI->scriptEdit->document(), SIGNAL(modificationChanged(bool)), this, SIGNAL(scriptModified()));
+ connect(_scriptEditorWidgetUI->scriptEdit->document(), SIGNAL(contentsChanged()), this, SLOT(onScriptModified()));
+
+ // remove the title bar (see the Qt docs on setTitleBarWidget)
+ setTitleBarWidget(new QWidget());
+ QFontMetrics fm(_scriptEditorWidgetUI->scriptEdit->font());
+ _scriptEditorWidgetUI->scriptEdit->setTabStopWidth(fm.width('0') * 4);
+ ScriptHighlighting* highlighting = new ScriptHighlighting(_scriptEditorWidgetUI->scriptEdit->document());
+ QTimer::singleShot(0, _scriptEditorWidgetUI->scriptEdit, SLOT(setFocus()));
+}
+
+ScriptEditorWidget::~ScriptEditorWidget() {
+ delete _scriptEditorWidgetUI;
+}
+
+void ScriptEditorWidget::onScriptModified() {
+ if(_scriptEditorWidgetUI->onTheFlyCheckBox->isChecked() && isRunning()) {
+ setRunning(false);
+ setRunning(true);
+ }
+}
+
+bool ScriptEditorWidget::isModified() {
+ return _scriptEditorWidgetUI->scriptEdit->document()->isModified();
+}
+
+bool ScriptEditorWidget::isRunning() {
+ return (_scriptEngine != NULL) ? _scriptEngine->isRunning() : false;
+}
+
+bool ScriptEditorWidget::setRunning(bool run) {
+ if (run && !save()) {
+ return false;
+ }
+ // Clean-up old connections.
+ disconnect(this, SLOT(onScriptError(const QString&)));
+ disconnect(this, SLOT(onScriptPrint(const QString&)));
+
+ if (run) {
+ _scriptEngine = Application::getInstance()->loadScript(_currentScript, true);
+ connect(_scriptEngine, SIGNAL(runningStateChanged()), this, SIGNAL(runningStateChanged()));
+
+ // Make new connections.
+ connect(_scriptEngine, SIGNAL(errorMessage(const QString&)), this, SLOT(onScriptError(const QString&)));
+ connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(onScriptPrint(const QString&)));
+ } else {
+ Application::getInstance()->stopScript(_currentScript);
+ _scriptEngine = NULL;
+ }
+ return true;
+}
+
+bool ScriptEditorWidget::saveFile(const QString &scriptPath) {
+ QFile file(scriptPath);
+ if (!file.open(QFile::WriteOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("Interface"), tr("Cannot write script %1:\n%2.").arg(scriptPath)
+ .arg(file.errorString()));
+ return false;
+ }
+
+ QTextStream out(&file);
+ out << _scriptEditorWidgetUI->scriptEdit->toPlainText();
+
+ setScriptFile(scriptPath);
+ return true;
+}
+
+void ScriptEditorWidget::loadFile(const QString& scriptPath) {
+ QFile file(scriptPath);
+ if (!file.open(QFile::ReadOnly | QFile::Text)) {
+ QMessageBox::warning(this, tr("Interface"), tr("Cannot read script %1:\n%2.").arg(scriptPath).arg(file.errorString()));
+ return;
+ }
+
+ QTextStream in(&file);
+ _scriptEditorWidgetUI->scriptEdit->setPlainText(in.readAll());
+
+ setScriptFile(scriptPath);
+
+ disconnect(this, SLOT(onScriptError(const QString&)));
+ disconnect(this, SLOT(onScriptPrint(const QString&)));
+
+ _scriptEngine = Application::getInstance()->getScriptEngine(scriptPath);
+ if (_scriptEngine != NULL) {
+ connect(_scriptEngine, SIGNAL(runningStateChanged()), this, SIGNAL(runningStateChanged()));
+ connect(_scriptEngine, SIGNAL(errorMessage(const QString&)), this, SLOT(onScriptError(const QString&)));
+ connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(onScriptPrint(const QString&)));
+ }
+}
+
+bool ScriptEditorWidget::save() {
+ return _currentScript.isEmpty() ? saveAs() : saveFile(_currentScript);
+}
+
+bool ScriptEditorWidget::saveAs() {
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Save script"), QString(), tr("Javascript (*.js)"));
+ return !fileName.isEmpty() ? saveFile(fileName) : false;
+}
+
+void ScriptEditorWidget::setScriptFile(const QString& scriptPath) {
+ _currentScript = scriptPath;
+ _scriptEditorWidgetUI->scriptEdit->document()->setModified(false);
+ setWindowModified(false);
+
+ emit scriptnameChanged();
+}
+
+bool ScriptEditorWidget::questionSave() {
+ if (_scriptEditorWidgetUI->scriptEdit->document()->isModified()) {
+ QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Interface"),
+ tr("The script has been modified.\nDo you want to save your changes?"), QMessageBox::Save | QMessageBox::Discard |
+ QMessageBox::Cancel, QMessageBox::Save);
+ return button == QMessageBox::Save ? save() : (button == QMessageBox::Cancel ? false : true);
+ }
+ return true;
+}
+
+void ScriptEditorWidget::onScriptError(const QString& message) {
+ _scriptEditorWidgetUI->debugText->appendPlainText("ERROR: " + message);
+}
+
+void ScriptEditorWidget::onScriptPrint(const QString& message) {
+ _scriptEditorWidgetUI->debugText->appendPlainText("> " + message);
+}
diff --git a/interface/src/ui/ScriptEditorWidget.h b/interface/src/ui/ScriptEditorWidget.h
new file mode 100644
index 0000000000..3e50280a62
--- /dev/null
+++ b/interface/src/ui/ScriptEditorWidget.h
@@ -0,0 +1,57 @@
+//
+// ScriptEditorWidget.h
+// interface/src/ui
+//
+// Created by Thijs Wenker on 4/14/14.
+// Copyright 2014 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_ScriptEditorWidget_h
+#define hifi_ScriptEditorWidget_h
+
+#include
+#include "ScriptEditorWidget.h"
+#include "ScriptEngine.h"
+
+namespace Ui {
+ class ScriptEditorWidget;
+}
+
+class ScriptEditorWidget : public QDockWidget {
+ Q_OBJECT
+
+public:
+ ScriptEditorWidget();
+ ~ScriptEditorWidget();
+
+ bool isModified();
+ bool isRunning();
+ bool setRunning(bool run);
+ bool saveFile(const QString& scriptPath);
+ void loadFile(const QString& scriptPath);
+ void setScriptFile(const QString& scriptPath);
+ bool save();
+ bool saveAs();
+ bool questionSave();
+ const QString getScriptName() const { return _currentScript; };
+
+signals:
+ void runningStateChanged();
+ void scriptnameChanged();
+ void scriptModified();
+
+private slots:
+ void onScriptError(const QString& message);
+ void onScriptPrint(const QString& message);
+ void onScriptModified();
+
+private:
+ Ui::ScriptEditorWidget* _scriptEditorWidgetUI;
+ ScriptEngine* _scriptEngine;
+ QString _currentScript;
+};
+
+#endif // hifi_ScriptEditorWidget_h
diff --git a/interface/src/ui/ScriptEditorWindow.cpp b/interface/src/ui/ScriptEditorWindow.cpp
new file mode 100644
index 0000000000..0c34959353
--- /dev/null
+++ b/interface/src/ui/ScriptEditorWindow.cpp
@@ -0,0 +1,200 @@
+//
+// ScriptEditorWindow.cpp
+// interface/src/ui
+//
+// Created by Thijs Wenker on 4/14/14.
+// Copyright 2014 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 "ui_scriptEditorWindow.h"
+#include "ScriptEditorWindow.h"
+#include "ScriptEditorWidget.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "Application.h"
+#include "FlowLayout.h"
+
+ScriptEditorWindow::ScriptEditorWindow() :
+ _ScriptEditorWindowUI(new Ui::ScriptEditorWindow),
+ _loadMenu(new QMenu),
+ _saveMenu(new QMenu)
+{
+ _ScriptEditorWindowUI->setupUi(this);
+ show();
+ addScriptEditorWidget("New script");
+ connect(_loadMenu, SIGNAL(aboutToShow()), this, SLOT(loadMenuAboutToShow()));
+ _ScriptEditorWindowUI->loadButton->setMenu(_loadMenu);
+
+ _saveMenu->addAction("Save as..", this, SLOT(saveScriptAsClicked()), Qt::CTRL | Qt::SHIFT | Qt::Key_S);
+
+ _ScriptEditorWindowUI->saveButton->setMenu(_saveMenu);
+
+ connect(new QShortcut(QKeySequence("Ctrl+N"), this), SIGNAL(activated()), this, SLOT(newScriptClicked()));
+ connect(new QShortcut(QKeySequence("Ctrl+S"), this), SIGNAL(activated()), this, SLOT(saveScriptClicked()));
+ connect(new QShortcut(QKeySequence("Ctrl+O"), this), SIGNAL(activated()), this, SLOT(loadScriptClicked()));
+ connect(new QShortcut(QKeySequence("F5"), this), SIGNAL(activated()), this, SLOT(toggleRunScriptClicked()));
+}
+
+ScriptEditorWindow::~ScriptEditorWindow() {
+ delete _ScriptEditorWindowUI;
+}
+
+void ScriptEditorWindow::setRunningState(bool run) {
+ if (_ScriptEditorWindowUI->tabWidget->currentIndex() != -1) {
+ static_cast(_ScriptEditorWindowUI->tabWidget->currentWidget())->setRunning(run);
+ }
+ this->updateButtons();
+}
+
+void ScriptEditorWindow::updateButtons() {
+ _ScriptEditorWindowUI->toggleRunButton->setEnabled(_ScriptEditorWindowUI->tabWidget->currentIndex() != -1);
+ _ScriptEditorWindowUI->toggleRunButton->setIcon(_ScriptEditorWindowUI->tabWidget->currentIndex() != -1 &&
+ static_cast(_ScriptEditorWindowUI->tabWidget->currentWidget())->isRunning() ?
+ QIcon("../resources/icons/stop-script.svg") : QIcon("../resources/icons/start-script.svg"));
+}
+
+void ScriptEditorWindow::loadScriptMenu(const QString& scriptName) {
+ addScriptEditorWidget("loading...")->loadFile(scriptName);
+ updateButtons();
+}
+
+void ScriptEditorWindow::loadScriptClicked() {
+ QString scriptName = QFileDialog::getOpenFileName(this, tr("Interface"), QString(), tr("Javascript (*.js)"));
+ if (!scriptName.isEmpty()) {
+ addScriptEditorWidget("loading...")->loadFile(scriptName);
+ updateButtons();
+ }
+}
+
+void ScriptEditorWindow::loadMenuAboutToShow() {
+ _loadMenu->clear();
+ QStringList runningScripts = Application::getInstance()->getRunningScripts();
+ if (runningScripts.count() > 0) {
+ QSignalMapper* signalMapper = new QSignalMapper(this);
+ foreach (const QString& runningScript, runningScripts) {
+ QAction* runningScriptAction = new QAction(runningScript, _loadMenu);
+ connect(runningScriptAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ signalMapper->setMapping(runningScriptAction, runningScript);
+ _loadMenu->addAction(runningScriptAction);
+ }
+ connect(signalMapper, SIGNAL(mapped(const QString &)), this, SLOT(loadScriptMenu(const QString&)));
+ } else {
+ QAction* naAction = new QAction("(no running scripts)", _loadMenu);
+ naAction->setDisabled(true);
+ _loadMenu->addAction(naAction);
+ }
+}
+
+void ScriptEditorWindow::newScriptClicked() {
+ addScriptEditorWidget(QString("New script"));
+}
+
+void ScriptEditorWindow::toggleRunScriptClicked() {
+ this->setRunningState(!(_ScriptEditorWindowUI->tabWidget->currentIndex() !=-1
+ && static_cast(_ScriptEditorWindowUI->tabWidget->currentWidget())->isRunning()));
+}
+
+void ScriptEditorWindow::saveScriptClicked() {
+ if (_ScriptEditorWindowUI->tabWidget->currentIndex() != -1) {
+ ScriptEditorWidget* currentScriptWidget = static_cast(_ScriptEditorWindowUI->tabWidget
+ ->currentWidget());
+ currentScriptWidget->save();
+ }
+}
+
+void ScriptEditorWindow::saveScriptAsClicked() {
+ if (_ScriptEditorWindowUI->tabWidget->currentIndex() != -1) {
+ ScriptEditorWidget* currentScriptWidget = static_cast(_ScriptEditorWindowUI->tabWidget
+ ->currentWidget());
+ currentScriptWidget->saveAs();
+ }
+}
+
+ScriptEditorWidget* ScriptEditorWindow::addScriptEditorWidget(QString title) {
+ ScriptEditorWidget* newScriptEditorWidget = new ScriptEditorWidget();
+ connect(newScriptEditorWidget, SIGNAL(scriptnameChanged()), this, SLOT(updateScriptNameOrStatus()));
+ connect(newScriptEditorWidget, SIGNAL(scriptModified()), this, SLOT(updateScriptNameOrStatus()));
+ connect(newScriptEditorWidget, SIGNAL(runningStateChanged()), this, SLOT(updateButtons()));
+ _ScriptEditorWindowUI->tabWidget->addTab(newScriptEditorWidget, title);
+ _ScriptEditorWindowUI->tabWidget->setCurrentWidget(newScriptEditorWidget);
+ newScriptEditorWidget->setUpdatesEnabled(true);
+ newScriptEditorWidget->adjustSize();
+ return newScriptEditorWidget;
+}
+
+void ScriptEditorWindow::tabSwitched(int tabIndex) {
+ this->updateButtons();
+ if (_ScriptEditorWindowUI->tabWidget->currentIndex() != -1) {
+ ScriptEditorWidget* currentScriptWidget = static_cast(_ScriptEditorWindowUI->tabWidget
+ ->currentWidget());
+ QString modifiedStar = (currentScriptWidget->isModified() ? "*" : "");
+ if (currentScriptWidget->getScriptName().length() > 0) {
+ this->setWindowTitle("Script Editor [" + currentScriptWidget->getScriptName() + modifiedStar + "]");
+ } else {
+ this->setWindowTitle("Script Editor [New script" + modifiedStar + "]");
+ }
+ } else {
+ this->setWindowTitle("Script Editor");
+ }
+}
+
+void ScriptEditorWindow::tabCloseRequested(int tabIndex) {
+ ScriptEditorWidget* closingScriptWidget = static_cast(_ScriptEditorWindowUI->tabWidget
+ ->widget(tabIndex));
+ if(closingScriptWidget->questionSave()) {
+ _ScriptEditorWindowUI->tabWidget->removeTab(tabIndex);
+ }
+}
+
+void ScriptEditorWindow::closeEvent(QCloseEvent *event) {
+ bool unsaved_docs_warning = false;
+ for (int i = 0; i < _ScriptEditorWindowUI->tabWidget->count(); i++){
+ if(static_cast(_ScriptEditorWindowUI->tabWidget->widget(i))->isModified()){
+ unsaved_docs_warning = true;
+ break;
+ }
+ }
+
+ if (!unsaved_docs_warning || QMessageBox::warning(this, tr("Interface"),
+ tr("There are some unsaved scripts, are you sure you want to close the editor? Changes will be lost!"),
+ QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel) == QMessageBox::Discard) {
+ event->accept();
+ } else {
+ event->ignore();
+ }
+}
+
+void ScriptEditorWindow::updateScriptNameOrStatus() {
+ ScriptEditorWidget* source = static_cast(QObject::sender());
+ QString modifiedStar = (source->isModified()? "*" : "");
+ if (source->getScriptName().length() > 0) {
+ for (int i = 0; i < _ScriptEditorWindowUI->tabWidget->count(); i++){
+ if (_ScriptEditorWindowUI->tabWidget->widget(i) == source) {
+ _ScriptEditorWindowUI->tabWidget->setTabText(i, modifiedStar + QFileInfo(source->getScriptName()).fileName());
+ _ScriptEditorWindowUI->tabWidget->setTabToolTip(i, source->getScriptName());
+ }
+ }
+ }
+
+ if (_ScriptEditorWindowUI->tabWidget->currentWidget() == source) {
+ if (source->getScriptName().length() > 0) {
+ this->setWindowTitle("Script Editor [" + source->getScriptName() + modifiedStar + "]");
+ } else {
+ this->setWindowTitle("Script Editor [New script" + modifiedStar + "]");
+ }
+ }
+}
diff --git a/interface/src/ui/ScriptEditorWindow.h b/interface/src/ui/ScriptEditorWindow.h
new file mode 100644
index 0000000000..0bf5015ccf
--- /dev/null
+++ b/interface/src/ui/ScriptEditorWindow.h
@@ -0,0 +1,54 @@
+//
+// ScriptEditorWindow.h
+// interface/src/ui
+//
+// Created by Thijs Wenker on 4/14/14.
+// Copyright 2014 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_ScriptEditorWindow_h
+#define hifi_ScriptEditorWindow_h
+
+#include "ScriptEditorWidget.h"
+
+namespace Ui {
+ class ScriptEditorWindow;
+}
+
+class ScriptEditorWindow : public QWidget {
+ Q_OBJECT
+
+public:
+ ScriptEditorWindow();
+ ~ScriptEditorWindow();
+
+protected:
+ void closeEvent(QCloseEvent* event);
+
+private:
+ Ui::ScriptEditorWindow* _ScriptEditorWindowUI;
+ QMenu* _loadMenu;
+ QMenu* _saveMenu;
+
+ ScriptEditorWidget* addScriptEditorWidget(QString title);
+ void setRunningState(bool run);
+ void setScriptName(const QString& scriptName);
+
+private slots:
+ void loadScriptMenu(const QString& scriptName);
+ void loadScriptClicked();
+ void newScriptClicked();
+ void toggleRunScriptClicked();
+ void saveScriptClicked();
+ void saveScriptAsClicked();
+ void loadMenuAboutToShow();
+ void tabSwitched(int tabIndex);
+ void tabCloseRequested(int tabIndex);
+ void updateScriptNameOrStatus();
+ void updateButtons();
+};
+
+#endif // hifi_ScriptEditorWindow_h
diff --git a/interface/src/voxels/VoxelSystem.cpp b/interface/src/voxels/VoxelSystem.cpp
index 692f299bdc..8d59f33674 100644
--- a/interface/src/voxels/VoxelSystem.cpp
+++ b/interface/src/voxels/VoxelSystem.cpp
@@ -117,7 +117,7 @@ void VoxelSystem::elementDeleted(OctreeElement* element) {
forceRemoveNodeFromArrays(voxel);
} else {
if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {
- printf("VoxelSystem::elementDeleted() while _voxelsInWriteArrays==0, is that expected? \n");
+ qDebug("VoxelSystem::elementDeleted() while _voxelsInWriteArrays==0, is that expected? ");
}
}
}
diff --git a/interface/ui/scriptEditorWidget.ui b/interface/ui/scriptEditorWidget.ui
new file mode 100644
index 0000000000..88761c91c5
--- /dev/null
+++ b/interface/ui/scriptEditorWidget.ui
@@ -0,0 +1,148 @@
+
+
+ ScriptEditorWidget
+
+
+
+ 0
+ 0
+ 691
+ 549
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 541
+ 238
+
+
+
+ font-family: Helvetica, Arial, sans-serif;
+
+
+ QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable
+
+
+ Qt::NoDockWidgetArea
+
+
+ Edit Script
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ Courier
+ 9
+ 50
+ false
+ false
+
+
+
+ font: 9pt "Courier";
+
+
+
+ -
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Debug Log:
+
+
+
+ -
+
+
+ Run on the fly (Careful: Any valid change made to the code will run immediately)
+
+
+
+ -
+
+
+ Clear
+
+
+
+ 16
+ 16
+
+
+
+
+
+
+ -
+
+
+ font: 8pt "Courier";
+
+
+ true
+
+
+
+
+
+
+
+
+
+ clearButton
+ clicked()
+ debugText
+ clear()
+
+
+ 663
+ 447
+
+
+ 350
+ 501
+
+
+
+
+
diff --git a/interface/ui/scriptEditorWindow.ui b/interface/ui/scriptEditorWindow.ui
new file mode 100644
index 0000000000..9e1b08de3e
--- /dev/null
+++ b/interface/ui/scriptEditorWindow.ui
@@ -0,0 +1,331 @@
+
+
+ ScriptEditorWindow
+
+
+ Qt::WindowModal
+
+
+
+ 0
+ 0
+ 706
+ 682
+
+
+
+
+ 400
+ 250
+
+
+
+ Script Editor
+
+
+ font-family: Helvetica, Arial, sans-serif;
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+ 3
+
+
+ QLayout::SetNoConstraint
+
+
+ 0
+
+
+ 0
+
+
-
+
+
+ New Script (Ctrl+N)
+
+
+ New
+
+
+
+ ../resources/icons/new-script.svg
+ ../resources/icons/new-script.svg../resources/icons/new-script.svg
+
+
+
+ 32
+ 32
+
+
+
+
+ -
+
+
+
+ 30
+ 0
+
+
+
+
+ 25
+ 0
+
+
+
+ Load Script (Ctrl+O)
+
+
+ Load
+
+
+
+ ../resources/icons/load-script.svg../resources/icons/load-script.svg
+
+
+
+ 32
+ 32
+
+
+
+ false
+
+
+ QToolButton::MenuButtonPopup
+
+
+ Qt::ToolButtonIconOnly
+
+
+
+ -
+
+
+
+ 30
+ 0
+
+
+
+
+ 32
+ 0
+
+
+
+ Qt::NoFocus
+
+
+ Qt::NoContextMenu
+
+
+ Save Script (Ctrl+S)
+
+
+ Save
+
+
+
+ ../resources/icons/save-script.svg../resources/icons/save-script.svg
+
+
+
+ 32
+ 32
+
+
+
+ 316
+
+
+ QToolButton::MenuButtonPopup
+
+
+
+ -
+
+
+ Toggle Run Script (F5)
+
+
+ Run/Stop
+
+
+
+ ../resources/icons/start-script.svg../resources/icons/start-script.svg
+
+
+
+ 32
+ 32
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ true
+
+
+
+ 250
+ 80
+
+
+
+ QTabWidget::West
+
+
+ QTabWidget::Triangular
+
+
+ -1
+
+
+ Qt::ElideNone
+
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+ saveButton
+ clicked()
+ ScriptEditorWindow
+ saveScriptClicked()
+
+
+ 236
+ 10
+
+
+ 199
+ 264
+
+
+
+
+ toggleRunButton
+ clicked()
+ ScriptEditorWindow
+ toggleRunScriptClicked()
+
+
+ 330
+ 10
+
+
+ 199
+ 264
+
+
+
+
+ newButton
+ clicked()
+ ScriptEditorWindow
+ newScriptClicked()
+
+
+ 58
+ 10
+
+
+ 199
+ 264
+
+
+
+
+ loadButton
+ clicked()
+ ScriptEditorWindow
+ loadScriptClicked()
+
+
+ 85
+ 10
+
+
+ 199
+ 264
+
+
+
+
+ tabWidget
+ currentChanged(int)
+ ScriptEditorWindow
+ tabSwitched(int)
+
+
+ 352
+ 360
+
+
+ 352
+ 340
+
+
+
+
+ tabWidget
+ tabCloseRequested(int)
+ ScriptEditorWindow
+ tabCloseRequested(int)
+
+
+ 352
+ 360
+
+
+ 352
+ 340
+
+
+
+
+
diff --git a/libraries/networking/src/Logging.cpp b/libraries/networking/src/Logging.cpp
index 17a4706de0..f42f1bda58 100644
--- a/libraries/networking/src/Logging.cpp
+++ b/libraries/networking/src/Logging.cpp
@@ -46,7 +46,7 @@ const HifiSockAddr& Logging::socket() {
// use the first IP address
_logstashSocket.setAddress(hostInfo.addresses().first());
} else {
- printf("Failed to lookup logstash IP - will try again on next log attempt.\n");
+ qDebug("Failed to lookup logstash IP - will try again on next log attempt.");
}
}
diff --git a/libraries/octree/src/Octree.cpp b/libraries/octree/src/Octree.cpp
index 696a65b4b5..d7fc7713cf 100644
--- a/libraries/octree/src/Octree.cpp
+++ b/libraries/octree/src/Octree.cpp
@@ -471,8 +471,8 @@ void Octree::processRemoveOctreeElementsBitstream(const unsigned char* bitstream
int codeLength = numberOfThreeBitSectionsInCode(voxelCode, maxSize);
if (codeLength == OVERFLOWED_OCTCODE_BUFFER) {
- printf("WARNING! Got remove voxel bitstream that would overflow buffer in numberOfThreeBitSectionsInCode(), ");
- printf("bailing processing of packet!\n");
+ qDebug("WARNING! Got remove voxel bitstream that would overflow buffer in numberOfThreeBitSectionsInCode(),"
+ " bailing processing of packet!");
break;
}
int voxelDataSize = bytesRequiredForCodeLength(codeLength) + SIZE_OF_COLOR_DATA;
@@ -482,7 +482,7 @@ void Octree::processRemoveOctreeElementsBitstream(const unsigned char* bitstream
voxelCode += voxelDataSize;
atByte += voxelDataSize;
} else {
- printf("WARNING! Got remove voxel bitstream that would overflow buffer, bailing processing!\n");
+ qDebug("WARNING! Got remove voxel bitstream that would overflow buffer, bailing processing!");
break;
}
}
@@ -1404,7 +1404,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElement* node,
outputBits(childrenExistInPacketBits, false, true);
printf(" childrenColored:");
outputBits(childrenColoredBits, false, true);
- printf("\n");
+ qDebug("");
**/
// if we were unable to fit this level in our packet, then rewind and add it to the node bag for
@@ -1620,7 +1620,7 @@ void Octree::copyFromTreeIntoSubTree(Octree* sourceTree, OctreeElement* destinat
}
void dumpSetContents(const char* name, std::set set) {
- printf("set %s has %ld elements\n", name, set.size());
+ qDebug("set %s has %ld elements", name, set.size());
/*
for (std::set::iterator i = set.begin(); i != set.end(); ++i) {
printOctalCode(*i);
diff --git a/libraries/octree/src/Octree.h b/libraries/octree/src/Octree.h
index 839e61d1c2..3c868ab172 100644
--- a/libraries/octree/src/Octree.h
+++ b/libraries/octree/src/Octree.h
@@ -129,17 +129,17 @@ public:
printf("StopReason: ");
switch (stopReason) {
default:
- case UNKNOWN: printf("UNKNOWN\n"); break;
+ case UNKNOWN: qDebug("UNKNOWN"); break;
- case DIDNT_FIT: printf("DIDNT_FIT\n"); break;
- case NULL_NODE: printf("NULL_NODE\n"); break;
- case TOO_DEEP: printf("TOO_DEEP\n"); break;
- case OUT_OF_JURISDICTION: printf("OUT_OF_JURISDICTION\n"); break;
- case LOD_SKIP: printf("LOD_SKIP\n"); break;
- case OUT_OF_VIEW: printf("OUT_OF_VIEW\n"); break;
- case WAS_IN_VIEW: printf("WAS_IN_VIEW\n"); break;
- case NO_CHANGE: printf("NO_CHANGE\n"); break;
- case OCCLUDED: printf("OCCLUDED\n"); break;
+ case DIDNT_FIT: qDebug("DIDNT_FIT"); break;
+ case NULL_NODE: qDebug("NULL_NODE"); break;
+ case TOO_DEEP: qDebug("TOO_DEEP"); break;
+ case OUT_OF_JURISDICTION: qDebug("OUT_OF_JURISDICTION"); break;
+ case LOD_SKIP: qDebug("LOD_SKIP"); break;
+ case OUT_OF_VIEW: qDebug("OUT_OF_VIEW"); break;
+ case WAS_IN_VIEW: qDebug("WAS_IN_VIEW"); break;
+ case NO_CHANGE: qDebug("NO_CHANGE"); break;
+ case OCCLUDED: qDebug("OCCLUDED"); break;
}
}
};
diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp
index b606dffe44..7e59b3ae7f 100644
--- a/libraries/octree/src/OctreeEditPacketSender.cpp
+++ b/libraries/octree/src/OctreeEditPacketSender.cpp
@@ -37,7 +37,7 @@ OctreeEditPacketSender::OctreeEditPacketSender() :
_serverJurisdictions(NULL),
_sequenceNumber(0),
_maxPacketSize(MAX_PACKET_SIZE) {
- //printf("OctreeEditPacketSender::OctreeEditPacketSender() [%p] created... \n", this);
+ //qDebug("OctreeEditPacketSender::OctreeEditPacketSender() [%p] created... ", this);
}
OctreeEditPacketSender::~OctreeEditPacketSender() {
@@ -53,7 +53,7 @@ OctreeEditPacketSender::~OctreeEditPacketSender() {
_preServerPackets.erase(_preServerPackets.begin());
}
_pendingPacketsLock.unlock();
- //printf("OctreeEditPacketSender::~OctreeEditPacketSender() [%p] destroyed... \n", this);
+ //qDebug("OctreeEditPacketSender::~OctreeEditPacketSender() [%p] destroyed... ", this);
}
diff --git a/libraries/octree/src/OctreeElement.cpp b/libraries/octree/src/OctreeElement.cpp
index e21148df5e..96311ceabd 100644
--- a/libraries/octree/src/OctreeElement.cpp
+++ b/libraries/octree/src/OctreeElement.cpp
@@ -204,7 +204,7 @@ void OctreeElement::calculateAABox() {
void OctreeElement::deleteChildAtIndex(int childIndex) {
OctreeElement* childAt = getChildAtIndex(childIndex);
if (childAt) {
- //printf("deleteChildAtIndex()... about to call delete childAt=%p\n",childAt);
+ //qDebug("deleteChildAtIndex()... about to call delete childAt=%p",childAt);
delete childAt;
setChildAtIndex(childIndex, NULL);
_isDirty = true;
@@ -1315,7 +1315,7 @@ OctreeElement* OctreeElement::getOrCreateChildElementAt(float x, float y, float
float halfOurScale = ourScale / 2.0f;
if(s > ourScale) {
- printf("UNEXPECTED -- OctreeElement::getOrCreateChildElementAt() s=[%f] > ourScale=[%f] \n", s, ourScale);
+ qDebug("UNEXPECTED -- OctreeElement::getOrCreateChildElementAt() s=[%f] > ourScale=[%f] ", s, ourScale);
}
if (s > halfOurScale) {
diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp
index 2edf560de6..b54a87bef8 100644
--- a/libraries/octree/src/OctreePacketData.cpp
+++ b/libraries/octree/src/OctreePacketData.cpp
@@ -125,7 +125,7 @@ const unsigned char* OctreePacketData::getFinalizedData() {
if (_dirty) {
if (_debug) {
- printf("getFinalizedData() _compressedBytes=%d _bytesInUse=%d\n",_compressedBytes, _bytesInUse);
+ qDebug("getFinalizedData() _compressedBytes=%d _bytesInUse=%d",_compressedBytes, _bytesInUse);
}
compressContent();
}
@@ -139,7 +139,7 @@ int OctreePacketData::getFinalizedSize() {
if (_dirty) {
if (_debug) {
- printf("getFinalizedSize() _compressedBytes=%d _bytesInUse=%d\n",_compressedBytes, _bytesInUse);
+ qDebug("getFinalizedSize() _compressedBytes=%d _bytesInUse=%d",_compressedBytes, _bytesInUse);
}
compressContent();
}
@@ -187,7 +187,7 @@ void OctreePacketData::discardLevel(LevelDetails key) {
_totalBytesOfColor -= reduceBytesOfColor;
if (_debug) {
- printf("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
+ qDebug("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d",
debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse);
}
@@ -196,7 +196,7 @@ void OctreePacketData::discardLevel(LevelDetails key) {
_dirty = true;
if (_debug) {
- printf("discardLevel() AFTER _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
+ qDebug("discardLevel() AFTER _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d",
debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse);
}
}
@@ -413,13 +413,13 @@ void OctreePacketData::loadFinalizedContent(const unsigned char* data, int lengt
}
} else {
if (_debug) {
- printf("OctreePacketData::loadCompressedContent()... length = 0, nothing to do...\n");
+ qDebug("OctreePacketData::loadCompressedContent()... length = 0, nothing to do...");
}
}
}
void OctreePacketData::debugContent() {
- printf("OctreePacketData::debugContent()... COMPRESSED DATA.... size=%d\n",_compressedBytes);
+ qDebug("OctreePacketData::debugContent()... COMPRESSED DATA.... size=%d",_compressedBytes);
int perline=0;
for (int i = 0; i < _compressedBytes; i++) {
printf("%.2x ",_compressed[i]);
@@ -431,7 +431,7 @@ void OctreePacketData::debugContent() {
}
printf("\n");
- printf("OctreePacketData::debugContent()... UNCOMPRESSED DATA.... size=%d\n",_bytesInUse);
+ qDebug("OctreePacketData::debugContent()... UNCOMPRESSED DATA.... size=%d",_bytesInUse);
perline=0;
for (int i = 0; i < _bytesInUse; i++) {
printf("%.2x ",_uncompressed[i]);
diff --git a/libraries/octree/src/OctreeProjectedPolygon.cpp b/libraries/octree/src/OctreeProjectedPolygon.cpp
index f86d598a87..92a5b2ac18 100644
--- a/libraries/octree/src/OctreeProjectedPolygon.cpp
+++ b/libraries/octree/src/OctreeProjectedPolygon.cpp
@@ -263,12 +263,12 @@ bool OctreeProjectedPolygon::pointInside(const glm::vec2& point, bool* matchesVe
}
void OctreeProjectedPolygon::printDebugDetails() const {
- printf("OctreeProjectedPolygon...");
- printf(" minX=%f maxX=%f minY=%f maxY=%f\n", getMinX(), getMaxX(), getMinY(), getMaxY());
- printf(" vertex count=%d distance=%f\n", getVertexCount(), getDistance());
+ qDebug("OctreeProjectedPolygon..."
+ " minX=%f maxX=%f minY=%f maxY=%f", getMinX(), getMaxX(), getMinY(), getMaxY());
+ qDebug(" vertex count=%d distance=%f", getVertexCount(), getDistance());
for (int i = 0; i < getVertexCount(); i++) {
glm::vec2 point = getVertex(i);
- printf(" vertex[%d] = %f, %f \n", i, point.x, point.y);
+ qDebug(" vertex[%d] = %f, %f ", i, point.x, point.y);
}
}
diff --git a/libraries/octree/src/Plane.cpp b/libraries/octree/src/Plane.cpp
index d7cb2c54ff..d9e5633233 100755
--- a/libraries/octree/src/Plane.cpp
+++ b/libraries/octree/src/Plane.cpp
@@ -14,6 +14,8 @@
#include "Plane.h"
+#include
+
#include
void Plane::set3Points(const glm::vec3 &v1, const glm::vec3 &v2, const glm::vec3 &v3) {
@@ -61,6 +63,6 @@ float Plane::distance(const glm::vec3 &point) const {
}
void Plane::print() const {
- printf("Plane - point (x=%f y=%f z=%f) normal (x=%f y=%f z=%f) d=%f\n",
+ qDebug("Plane - point (x=%f y=%f z=%f) normal (x=%f y=%f z=%f) d=%f",
_point.x, _point.y, _point.z, _normal.x, _normal.y, _normal.z, _dCoefficient);
}
diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp
index a36998aad4..59265c00dc 100644
--- a/libraries/particles/src/Particle.cpp
+++ b/libraries/particles/src/Particle.cpp
@@ -146,7 +146,7 @@ bool Particle::appendParticleData(OctreePacketData* packetData) const {
bool success = packetData->appendValue(getID());
- //printf("Particle::appendParticleData()... getID()=%d\n", getID());
+ //qDebug("Particle::appendParticleData()... getID()=%d", getID());
if (success) {
success = packetData->appendValue(getAge());
@@ -541,15 +541,15 @@ Particle Particle::fromEditPacket(const unsigned char* data, int length, int& pr
}
void Particle::debugDump() const {
- printf("Particle id :%u\n", _id);
- printf(" age:%f\n", getAge());
- printf(" edited ago:%f\n", getEditedAgo());
- printf(" should die:%s\n", debug::valueOf(getShouldDie()));
- printf(" position:%f,%f,%f\n", _position.x, _position.y, _position.z);
- printf(" radius:%f\n", getRadius());
- printf(" velocity:%f,%f,%f\n", _velocity.x, _velocity.y, _velocity.z);
- printf(" gravity:%f,%f,%f\n", _gravity.x, _gravity.y, _gravity.z);
- printf(" color:%d,%d,%d\n", _color[0], _color[1], _color[2]);
+ qDebug("Particle id :%u", _id);
+ qDebug(" age:%f", getAge());
+ qDebug(" edited ago:%f", getEditedAgo());
+ qDebug(" should die:%s", debug::valueOf(getShouldDie()));
+ qDebug(" position:%f,%f,%f", _position.x, _position.y, _position.z);
+ qDebug(" radius:%f", getRadius());
+ qDebug(" velocity:%f,%f,%f", _velocity.x, _velocity.y, _velocity.z);
+ qDebug(" gravity:%f,%f,%f", _gravity.x, _gravity.y, _gravity.z);
+ qDebug(" color:%d,%d,%d", _color[0], _color[1], _color[2]);
}
bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID id, const ParticleProperties& properties,
@@ -732,9 +732,9 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i
bool wantDebugging = false;
if (wantDebugging) {
- printf("encodeParticleEditMessageDetails()....\n");
- printf("Particle id :%u\n", id.id);
- printf(" nextID:%u\n", _nextID);
+ qDebug("encodeParticleEditMessageDetails()....");
+ qDebug("Particle id :%u", id.id);
+ qDebug(" nextID:%u", _nextID);
}
// cleanup
@@ -844,7 +844,7 @@ void Particle::update(const quint64& now) {
// handle damping
glm::vec3 dampingResistance = _velocity * _damping;
_velocity -= dampingResistance * timeElapsed;
- //printf("applying damping to Particle timeElapsed=%f\n",timeElapsed);
+ //qDebug("applying damping to Particle timeElapsed=%f",timeElapsed);
}
}
diff --git a/libraries/particles/src/ParticleTreeElement.cpp b/libraries/particles/src/ParticleTreeElement.cpp
index 19353c427a..d28ccf2f5e 100644
--- a/libraries/particles/src/ParticleTreeElement.cpp
+++ b/libraries/particles/src/ParticleTreeElement.cpp
@@ -142,7 +142,7 @@ bool ParticleTreeElement::updateParticle(const Particle& particle) {
bool localOlder = thisParticle.getLastUpdated() < particle.getLastUpdated();
if (changedOnServer || localOlder) {
if (wantDebug) {
- printf("local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s\n",
+ qDebug("local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s",
particle.getID(), (changedOnServer ? "CHANGED" : "same"),
(localOlder ? "OLDER" : "NEWER"),
difference, debug::valueOf(particle.isNewlyCreated()) );
@@ -150,8 +150,8 @@ bool ParticleTreeElement::updateParticle(const Particle& particle) {
thisParticle.copyChangedProperties(particle);
} else {
if (wantDebug) {
- printf(">>> IGNORING SERVER!!! Would've caused jutter! <<< "
- "local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s\n",
+ qDebug(">>> IGNORING SERVER!!! Would've caused jutter! <<< "
+ "local particle [id:%d] %s and %s than server particle by %d, particle.isNewlyCreated()=%s",
particle.getID(), (changedOnServer ? "CHANGED" : "same"),
(localOlder ? "OLDER" : "NEWER"),
difference, debug::valueOf(particle.isNewlyCreated()) );
diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp
index dcf64dfe2c..09c3c63ebd 100644
--- a/libraries/script-engine/src/ScriptEngine.cpp
+++ b/libraries/script-engine/src/ScriptEngine.cpp
@@ -43,6 +43,11 @@ static QScriptValue soundConstructor(QScriptContext* context, QScriptEngine* eng
return soundScriptValue;
}
+static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine){
+ qDebug() << "script:print()<<" << context->argument(0).toString();
+ engine->evaluate("Script.print('" + context->argument(0).toString() + "')");
+ return QScriptValue();
+}
ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNameString,
AbstractControllerScriptingInterface* controllerScriptingInterface) :
@@ -115,6 +120,7 @@ ScriptEngine::ScriptEngine(const QUrl& scriptURL,
_scriptContents = in.readAll();
} else {
qDebug() << "ERROR Loading file:" << fileName;
+ emit errorMessage("ERROR Loading file:" + fileName);
}
} else {
QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
@@ -200,6 +206,9 @@ void ScriptEngine::init() {
qScriptRegisterSequenceMetaType >(&_engine);
qScriptRegisterSequenceMetaType >(&_engine);
+ QScriptValue printConstructorValue = _engine.newFunction(debugPrint);
+ _engine.globalObject().setProperty("print", printConstructorValue);
+
QScriptValue soundConstructorValue = _engine.newFunction(soundConstructor);
QScriptValue soundMetaObject = _engine.newQMetaObject(&Sound::staticMetaObject, soundConstructorValue);
_engine.globalObject().setProperty("Sound", soundMetaObject);
@@ -246,6 +255,7 @@ void ScriptEngine::evaluate() {
if (_engine.hasUncaughtException()) {
int line = _engine.uncaughtExceptionLineNumber();
qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
+ emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
}
}
@@ -266,11 +276,14 @@ void ScriptEngine::run() {
init();
}
_isRunning = true;
+ emit runningStateChanged();
QScriptValue result = _engine.evaluate(_scriptContents);
if (_engine.hasUncaughtException()) {
int line = _engine.uncaughtExceptionLineNumber();
+
qDebug() << "Uncaught exception at line" << line << ":" << result.toString();
+ emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
}
QElapsedTimer startTime;
@@ -401,6 +414,7 @@ void ScriptEngine::run() {
if (_engine.hasUncaughtException()) {
int line = _engine.uncaughtExceptionLineNumber();
qDebug() << "Uncaught exception at line" << line << ":" << _engine.uncaughtException().toString();
+ emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + _engine.uncaughtException().toString());
}
}
emit scriptEnding();
@@ -436,10 +450,12 @@ void ScriptEngine::run() {
emit finished(_fileNameString);
_isRunning = false;
+ emit runningStateChanged();
}
void ScriptEngine::stop() {
_isFinished = true;
+ emit runningStateChanged();
}
void ScriptEngine::timerFired() {
@@ -510,6 +526,10 @@ QUrl ScriptEngine::resolveInclude(const QString& include) const {
return url;
}
+void ScriptEngine::print(const QString& message) {
+ emit printedMessage(message);
+}
+
void ScriptEngine::include(const QString& includeFile) {
QUrl url = resolveInclude(includeFile);
QString includeContents;
@@ -523,6 +543,7 @@ void ScriptEngine::include(const QString& includeFile) {
includeContents = in.readAll();
} else {
qDebug() << "ERROR Loading file:" << fileName;
+ emit errorMessage("ERROR Loading file:" + fileName);
}
} else {
QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
@@ -538,5 +559,6 @@ void ScriptEngine::include(const QString& includeFile) {
if (_engine.hasUncaughtException()) {
int line = _engine.uncaughtExceptionLineNumber();
qDebug() << "Uncaught exception at (" << includeFile << ") line" << line << ":" << result.toString();
+ emit errorMessage("Uncaught exception at (" + includeFile + ") line" + QString::number(line) + ":" + result.toString());
}
}
diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h
index 941c6bbe27..9ea99276d3 100644
--- a/libraries/script-engine/src/ScriptEngine.h
+++ b/libraries/script-engine/src/ScriptEngine.h
@@ -80,6 +80,9 @@ public:
bool hasScript() const { return !_scriptContents.isEmpty(); }
+ bool isFinished() const { return _isFinished; }
+ bool isRunning() const { return _isRunning; }
+
public slots:
void stop();
@@ -88,12 +91,16 @@ public slots:
void clearInterval(QObject* timer) { stopTimer(reinterpret_cast(timer)); }
void clearTimeout(QObject* timer) { stopTimer(reinterpret_cast(timer)); }
void include(const QString& includeFile);
+ void print(const QString& message);
signals:
void update(float deltaTime);
void scriptEnding();
void finished(const QString& fileNameString);
void cleanupMenuItem(const QString& menuItemString);
+ void printedMessage(const QString& message);
+ void errorMessage(const QString& message);
+ void runningStateChanged();
protected:
QString _scriptContents;
diff --git a/voxel-edit/src/SceneUtils.cpp b/voxel-edit/src/SceneUtils.cpp
index 19e227c71a..937b03cc39 100644
--- a/voxel-edit/src/SceneUtils.cpp
+++ b/voxel-edit/src/SceneUtils.cpp
@@ -20,7 +20,7 @@ void addCornersAndAxisLines(VoxelTree* tree) {
float voxelSize = 0.5f / TREE_SCALE;
// Now some more examples... a little more complex
- printf("creating corner points...\n");
+ qDebug("creating corner points...");
tree->createVoxel(0 , 0 , 0 , voxelSize, 255, 255 ,255);
tree->createVoxel(1.0 - voxelSize, 0 , 0 , voxelSize, 255, 0 ,0 );
tree->createVoxel(0 , 1.0 - voxelSize, 0 , voxelSize, 0 , 255 ,0 );
@@ -29,11 +29,11 @@ void addCornersAndAxisLines(VoxelTree* tree) {
tree->createVoxel(0 , 1.0 - voxelSize, 1.0 - voxelSize, voxelSize, 0 , 255 ,255);
tree->createVoxel(1.0 - voxelSize, 1.0 - voxelSize, 0 , voxelSize, 255, 255 ,0 );
tree->createVoxel(1.0 - voxelSize, 1.0 - voxelSize, 1.0 - voxelSize, voxelSize, 255, 255 ,255);
- printf("DONE creating corner points...\n");
+ qDebug("DONE creating corner points...");
}
void addSurfaceScene(VoxelTree * tree) {
- printf("adding surface scene...\n");
+ qDebug("adding surface scene...");
float voxelSize = 1.f / (8 * TREE_SCALE);
// color 1= blue, color 2=green
@@ -57,5 +57,5 @@ void addSurfaceScene(VoxelTree * tree) {
}
}
}
- printf("DONE adding surface scene...\n");
+ qDebug("DONE adding surface scene...");
}