mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 15:30:38 +02:00
Merge pull request #32 from huffman/feat/entity-server-script-property
PR FIxes
This commit is contained in:
commit
95f07f3917
5 changed files with 45 additions and 42 deletions
|
@ -254,13 +254,13 @@ public:
|
|||
using SpatiallyNestable::getQueryAACube;
|
||||
virtual AACube getQueryAACube(bool& success) const override;
|
||||
|
||||
const QString getScript() const { return _script; }
|
||||
QString getScript() const { return _script; }
|
||||
void setScript(const QString& value) { _script = value; }
|
||||
|
||||
quint64 getScriptTimestamp() const { return _scriptTimestamp; }
|
||||
void setScriptTimestamp(const quint64 value) { _scriptTimestamp = value; }
|
||||
|
||||
const QString getServerScripts() const { return _serverScripts; }
|
||||
QString getServerScripts() const { return _serverScripts; }
|
||||
void setServerScripts(const QString& serverScripts) { _serverScripts = serverScripts; }
|
||||
|
||||
const QString& getCollisionSoundURL() const { return _collisionSoundURL; }
|
||||
|
|
|
@ -147,19 +147,19 @@ static bool hasCorrectSyntax(const QScriptProgram& program, ScriptEngine* report
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine) {
|
||||
static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName, ScriptEngine* reportingEngine, QString& exceptionMessage = QString()) {
|
||||
if (engine.hasUncaughtException()) {
|
||||
const auto backtrace = engine.uncaughtExceptionBacktrace();
|
||||
const auto exception = engine.uncaughtException().toString();
|
||||
const auto line = QString::number(engine.uncaughtExceptionLineNumber());
|
||||
engine.clearExceptions();
|
||||
|
||||
auto message = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line);
|
||||
exceptionMessage = QString(SCRIPT_EXCEPTION_FORMAT).arg(exception, fileName, line);
|
||||
if (!backtrace.empty()) {
|
||||
static const auto lineSeparator = "\n ";
|
||||
message += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator));
|
||||
exceptionMessage += QString("\n[Backtrace]%1%2").arg(lineSeparator, backtrace.join(lineSeparator));
|
||||
}
|
||||
reportingEngine->scriptErrorMessage(qPrintable(message));
|
||||
reportingEngine->scriptErrorMessage(qPrintable(exceptionMessage));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1469,9 +1469,11 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co
|
|||
});
|
||||
testConstructor = sandbox.evaluate(program);
|
||||
}
|
||||
if (hadUncaughtExceptions(sandbox, program.fileName(), this)) {
|
||||
|
||||
QString exceptionMessage;
|
||||
if (hadUncaughtExceptions(sandbox, program.fileName(), this, exceptionMessage)) {
|
||||
newDetails.status = ERROR_RUNNING_SCRIPT;
|
||||
newDetails.errorInfo = "Exception";
|
||||
newDetails.errorInfo = exceptionMessage;
|
||||
_entityScripts[entityID] = newDetails;
|
||||
|
||||
return;
|
||||
|
|
|
@ -1443,7 +1443,6 @@ var PropertiesTool = function (opts) {
|
|||
};
|
||||
|
||||
function updateScriptStatus(info) {
|
||||
print("Got status: ", info);
|
||||
info.type = "server_script_status";
|
||||
webView.emitScriptEvent(JSON.stringify(info));
|
||||
};
|
||||
|
@ -1457,26 +1456,28 @@ var PropertiesTool = function (opts) {
|
|||
});
|
||||
}
|
||||
|
||||
selectionManager.addEventListener(function () {
|
||||
selectionManager.addEventListener(function (selectionUpdated) {
|
||||
var data = {
|
||||
type: 'update'
|
||||
};
|
||||
|
||||
resetScriptStatus();
|
||||
if (selectionUpdated) {
|
||||
resetScriptStatus();
|
||||
|
||||
if (selectionManager.selections.length !== 1) {
|
||||
if (statusMonitor !== null) {
|
||||
statusMonitor.stop();
|
||||
statusMonitor = null;
|
||||
if (selectionManager.selections.length !== 1) {
|
||||
if (statusMonitor !== null) {
|
||||
statusMonitor.stop();
|
||||
statusMonitor = null;
|
||||
}
|
||||
currentSelectedEntityID = null;
|
||||
} else if (currentSelectedEntityID != selectionManager.selections[0]) {
|
||||
if (statusMonitor !== null) {
|
||||
statusMonitor.stop();
|
||||
}
|
||||
var entityID = selectionManager.selections[0];
|
||||
currentSelectedEntityID = entityID;
|
||||
statusMonitor = new ServerScriptStatusMonitor(entityID, updateScriptStatus);
|
||||
}
|
||||
currentSelectedEntityID = null;
|
||||
} else if (currentSelectedEntityID != selectionManager.selections[0]) {
|
||||
if (statusMonitor !== null) {
|
||||
statusMonitor.stop();
|
||||
}
|
||||
var entityID = selectionManager.selections[0];
|
||||
currentSelectedEntityID = entityID;
|
||||
statusMonitor = new ServerScriptStatusMonitor(entityID, updateScriptStatus);
|
||||
}
|
||||
|
||||
var selections = [];
|
||||
|
|
|
@ -113,7 +113,7 @@ SelectionManager = (function() {
|
|||
that.selections.push(entityID);
|
||||
}
|
||||
|
||||
that._update();
|
||||
that._update(true);
|
||||
};
|
||||
|
||||
that.addEntity = function(entityID, toggleSelection) {
|
||||
|
@ -132,7 +132,7 @@ SelectionManager = (function() {
|
|||
}
|
||||
}
|
||||
|
||||
that._update();
|
||||
that._update(true);
|
||||
};
|
||||
|
||||
that.removeEntity = function(entityID) {
|
||||
|
@ -140,15 +140,15 @@ SelectionManager = (function() {
|
|||
if (idx >= 0) {
|
||||
that.selections.splice(idx, 1);
|
||||
}
|
||||
that._update();
|
||||
that._update(true);
|
||||
};
|
||||
|
||||
that.clearSelections = function() {
|
||||
that.selections = [];
|
||||
that._update();
|
||||
that._update(true);
|
||||
};
|
||||
|
||||
that._update = function() {
|
||||
that._update = function(selectionUpdated) {
|
||||
if (that.selections.length == 0) {
|
||||
that.localDimensions = null;
|
||||
that.localPosition = null;
|
||||
|
@ -205,7 +205,7 @@ SelectionManager = (function() {
|
|||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
try {
|
||||
listeners[i]();
|
||||
listeners[i](selectionUpdated === true);
|
||||
} catch (e) {
|
||||
print("EntitySelectionTool got exception: " + JSON.stringify(e));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue