mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 20:55:52 +02:00
add a way to get a SpatiallyNestable's name without knowing what its type is
This commit is contained in:
parent
ed09dcbdc9
commit
69944cc76d
6 changed files with 30 additions and 2 deletions
interface/src/ui/overlays
libraries
avatars/src
entities/src
shared/src
|
@ -81,6 +81,10 @@ QVariantMap convertOverlayLocationFromScriptSemantics(const QVariantMap& propert
|
|||
void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
||||
QVariantMap properties = originalProperties;
|
||||
|
||||
if (properties["name"].isValid()) {
|
||||
setName(properties["name"].toString());
|
||||
}
|
||||
|
||||
// carry over some legacy keys
|
||||
if (!properties["position"].isValid() && !properties["localPosition"].isValid()) {
|
||||
if (properties["p1"].isValid()) {
|
||||
|
@ -207,6 +211,9 @@ void Base3DOverlay::setProperties(const QVariantMap& originalProperties) {
|
|||
}
|
||||
|
||||
QVariant Base3DOverlay::getProperty(const QString& property) {
|
||||
if (property == "name") {
|
||||
return _name;
|
||||
}
|
||||
if (property == "position" || property == "start" || property == "p1" || property == "point") {
|
||||
return vec3toVariant(getPosition());
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ public:
|
|||
virtual OverlayID getOverlayID() const override { return OverlayID(getID().toString()); }
|
||||
void setOverlayID(OverlayID overlayID) override { setID(overlayID); }
|
||||
|
||||
virtual QString getName() const override { return QString("Overlay:") + _name; }
|
||||
void setName(QString name) { _name = name; }
|
||||
|
||||
// getters
|
||||
virtual bool is3D() const override { return true; }
|
||||
|
||||
|
@ -74,6 +77,8 @@ protected:
|
|||
bool _drawInFront;
|
||||
bool _isAA;
|
||||
bool _isGrabbable { false };
|
||||
|
||||
QString _name;
|
||||
};
|
||||
|
||||
#endif // hifi_Base3DOverlay_h
|
||||
|
|
|
@ -357,6 +357,8 @@ class AvatarData : public QObject, public SpatiallyNestable {
|
|||
|
||||
public:
|
||||
|
||||
virtual QString getName() const override { return QString("Avatar:") + _displayName; }
|
||||
|
||||
static const QString FRAME_NAME;
|
||||
|
||||
static void fromFrame(const QByteArray& frameData, AvatarData& avatar, bool useFrameSkeleton = true);
|
||||
|
|
|
@ -281,7 +281,7 @@ public:
|
|||
float getAngularDamping() const;
|
||||
void setAngularDamping(float value);
|
||||
|
||||
QString getName() const;
|
||||
virtual QString getName() const override;
|
||||
void setName(const QString& value);
|
||||
QString getDebugName();
|
||||
|
||||
|
|
|
@ -469,7 +469,19 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
if (entityFound) {
|
||||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||
} else {
|
||||
qCWarning(entities) << "attempted edit on unknown entity: " << id;
|
||||
QString name = "unknown";
|
||||
QSharedPointer<SpatialParentFinder> parentFinder = DependencyManager::get<SpatialParentFinder>();
|
||||
if (parentFinder) {
|
||||
bool success;
|
||||
auto nestableWP = parentFinder->find(id, success, static_cast<SpatialParentTree*>(_entityTree.get()));
|
||||
if (success) {
|
||||
auto nestable = nestableWP.lock();
|
||||
if (nestable) {
|
||||
name = nestable->getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
qCWarning(entities) << "attempted edit on unknown entity: " << id << name;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
virtual const QUuid getID() const;
|
||||
virtual void setID(const QUuid& id);
|
||||
|
||||
virtual QString getName() const { return "SpatiallyNestable"; }
|
||||
|
||||
virtual const QUuid getParentID() const;
|
||||
virtual void setParentID(const QUuid& parentID);
|
||||
|
||||
|
|
Loading…
Reference in a new issue