mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:24:08 +02:00
Put the javascript methods on Script, not Entities, and other minimum-diff cleanup.
This commit is contained in:
parent
2b12f0bcd0
commit
4266a99d78
5 changed files with 6 additions and 28 deletions
|
@ -121,7 +121,7 @@ public slots:
|
|||
void setDisplayModelBounds(bool value) { _displayModelBounds = value; }
|
||||
void setDisplayModelElementProxy(bool value) { _displayModelElementProxy = value; }
|
||||
void setDontDoPrecisionPicking(bool value) { _dontDoPrecisionPicking = value; }
|
||||
|
||||
|
||||
protected:
|
||||
virtual Octree* createTree() { return new EntityTree(true); }
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "ModelEntityItem.h"
|
||||
#include "ZoneEntityItem.h"
|
||||
#include "EntitiesLogging.h"
|
||||
#include "../../script-engine/src/ScriptEngine.h" // FIXME
|
||||
|
||||
|
||||
EntityScriptingInterface::EntityScriptingInterface() :
|
||||
_entityTree(NULL)
|
||||
|
@ -204,19 +202,6 @@ void EntityScriptingInterface::dumpTree() const {
|
|||
}
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::addEventHandler(EntityItemID entityID, QString entityEventName, QScriptValue handler) {
|
||||
ScriptEngine* engine = static_cast<ScriptEngine*>(handler.engine());
|
||||
if (engine) { // In case it's gone by the time we get the signal
|
||||
engine->addEntityEventHandler(entityID, entityEventName, handler);
|
||||
}
|
||||
}
|
||||
void EntityScriptingInterface::removeEventHandler(EntityItemID entityID, QString entityEventName, QScriptValue handler) {
|
||||
ScriptEngine* engine = static_cast<ScriptEngine*>(handler.engine());
|
||||
if (engine) {
|
||||
engine->removeEntityEventHandler(entityID, entityEventName, handler);
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QUuid> EntityScriptingInterface::findEntities(const glm::vec3& center, float radius) const {
|
||||
QVector<QUuid> result;
|
||||
if (_entityTree) {
|
||||
|
|
|
@ -119,14 +119,7 @@ public slots:
|
|||
|
||||
Q_INVOKABLE void dumpTree() const;
|
||||
|
||||
// Register a function that will handle the given entityEventName on entityID
|
||||
Q_INVOKABLE void addEventHandler(EntityItemID entityID, QString entityEventName, QScriptValue handler);
|
||||
Q_INVOKABLE void removeEventHandler(EntityItemID entityID, QString entityEventName, QScriptValue handler);
|
||||
|
||||
signals:
|
||||
void addEntityEventHandler(EntityItemID entityID, QString entityEventName, QScriptValue handler);
|
||||
void removeEntityEventHandler(EntityItemID entityID, QString entityEventName, QScriptValue handler);
|
||||
|
||||
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ void ScriptEngine::generalHandler(const EntityItemID& entityID, const QString& e
|
|||
}
|
||||
}
|
||||
// Unregister the handlers for this eventName and entityID.
|
||||
void ScriptEngine::removeEntityEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) {
|
||||
void ScriptEngine::removeEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) {
|
||||
if (!_registeredHandlers.contains(entityID)) return;
|
||||
RegisteredEventHandlers& handlersOnEntity = _registeredHandlers[entityID];
|
||||
QScriptValueList& handlersForEvent = handlersOnEntity[eventName];
|
||||
|
@ -417,7 +417,7 @@ void ScriptEngine::removeEntityEventHandler(const EntityItemID& entityID, const
|
|||
}
|
||||
}
|
||||
// Register the handler.
|
||||
void ScriptEngine::addEntityEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) {
|
||||
void ScriptEngine::addEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler) {
|
||||
if (_registeredHandlers.count() == 0) { // First time any per-entity handler has been added in this script...
|
||||
// Connect up ALL the handlers to the global entities object's signals.
|
||||
// (We could go signal by signal, or even handler by handler, but I don't think the efficiency is worth the complexity.)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <AvatarData.h>
|
||||
#include <AvatarHashMap.h>
|
||||
#include <LimitedNodeList.h>
|
||||
#include <EntityItemID.h>
|
||||
|
||||
#include "AbstractControllerScriptingInterface.h"
|
||||
#include "ArrayBufferClass.h"
|
||||
|
@ -31,7 +32,6 @@
|
|||
#include "ScriptCache.h"
|
||||
#include "ScriptUUID.h"
|
||||
#include "Vec3.h"
|
||||
#include "../../entities/src/EntityItem.h" // FIXME
|
||||
|
||||
const QString NO_SCRIPT("");
|
||||
|
||||
|
@ -101,8 +101,8 @@ public:
|
|||
virtual void scriptContentsAvailable(const QUrl& url, const QString& scriptContents);
|
||||
virtual void errorInLoadingScript(const QUrl& url);
|
||||
|
||||
void addEntityEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler);
|
||||
void removeEntityEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler);
|
||||
Q_INVOKABLE void addEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler);
|
||||
Q_INVOKABLE void removeEventHandler(const EntityItemID& entityID, const QString& eventName, QScriptValue handler);
|
||||
|
||||
public slots:
|
||||
void loadURL(const QUrl& scriptURL);
|
||||
|
|
Loading…
Reference in a new issue