mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Add overlay getProperty() for text overlay "text" property
This commit is contained in:
parent
7b7fda5f1d
commit
4fa5447c85
9 changed files with 40 additions and 0 deletions
|
@ -166,6 +166,9 @@ var clipboardPreview = Overlays.addOverlay("clipboard", {
|
||||||
visible: true
|
visible: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Demonstrate retrieving overlay properties
|
||||||
|
print("Text overlay text property value =\n" + Overlays.getProperty(text, "text"));
|
||||||
|
print("Text overlay unknown property vale =\n" + Overlays.getProperty(text, "unknown")); // value = undefined
|
||||||
|
|
||||||
// When our script shuts down, we should clean up all of our overlays
|
// When our script shuts down, we should clean up all of our overlays
|
||||||
function scriptEnding() {
|
function scriptEnding() {
|
||||||
|
|
|
@ -104,6 +104,10 @@ void Overlay::setProperties(const QScriptValue& properties) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue Overlay::getProperty(const QString& property) {
|
||||||
|
return QScriptValue();
|
||||||
|
}
|
||||||
|
|
||||||
xColor Overlay::getColor() {
|
xColor Overlay::getColor() {
|
||||||
if (_colorPulse == 0.0f) {
|
if (_colorPulse == 0.0f) {
|
||||||
return _color;
|
return _color;
|
||||||
|
|
|
@ -77,6 +77,7 @@ public:
|
||||||
void setAlphaPulse(float value) { _alphaPulse = value; }
|
void setAlphaPulse(float value) { _alphaPulse = value; }
|
||||||
|
|
||||||
virtual void setProperties(const QScriptValue& properties);
|
virtual void setProperties(const QScriptValue& properties);
|
||||||
|
virtual QScriptValue getProperty(const QString& property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float updatePulse();
|
float updatePulse();
|
||||||
|
|
|
@ -64,3 +64,7 @@ void Overlay2D::setProperties(const QScriptValue& properties) {
|
||||||
//qDebug() << "set bounds to " << getBounds();
|
//qDebug() << "set bounds to " << getBounds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue Overlay2D::getProperty(const QString& property) {
|
||||||
|
return Overlay::getProperty(property);
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
void setBounds(const QRect& bounds) { _bounds = bounds; }
|
void setBounds(const QRect& bounds) { _bounds = bounds; }
|
||||||
|
|
||||||
virtual void setProperties(const QScriptValue& properties);
|
virtual void setProperties(const QScriptValue& properties);
|
||||||
|
virtual QScriptValue getProperty(const QString& property);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QRect _bounds; // where on the screen to draw
|
QRect _bounds; // where on the screen to draw
|
||||||
|
|
|
@ -241,6 +241,20 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
return 0; // not found
|
return 0; // not found
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScriptValue Overlays::getProperty(unsigned int id, const QString& property) {
|
||||||
|
Overlay* thisOverlay = NULL;
|
||||||
|
QReadLocker lock(&_lock);
|
||||||
|
if (_overlays2D.contains(id)) {
|
||||||
|
thisOverlay = _overlays2D[id];
|
||||||
|
} else if (_overlays3D.contains(id)) {
|
||||||
|
thisOverlay = _overlays3D[id];
|
||||||
|
}
|
||||||
|
if (thisOverlay) {
|
||||||
|
return thisOverlay->getProperty(property);
|
||||||
|
}
|
||||||
|
return QScriptValue();
|
||||||
|
}
|
||||||
|
|
||||||
RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) {
|
RayToOverlayIntersectionResult Overlays::findRayIntersection(const PickRay& ray) {
|
||||||
float bestDistance = std::numeric_limits<float>::max();
|
float bestDistance = std::numeric_limits<float>::max();
|
||||||
RayToOverlayIntersectionResult result;
|
RayToOverlayIntersectionResult result;
|
||||||
|
|
|
@ -59,6 +59,9 @@ public slots:
|
||||||
/// returns the top most 2D overlay at the screen point, or 0 if not overlay at that point
|
/// returns the top most 2D overlay at the screen point, or 0 if not overlay at that point
|
||||||
unsigned int getOverlayAtPoint(const glm::vec2& point);
|
unsigned int getOverlayAtPoint(const glm::vec2& point);
|
||||||
|
|
||||||
|
/// returns the value of specified property, or null if there is no such property
|
||||||
|
QScriptValue getProperty(unsigned int id, const QString& property);
|
||||||
|
|
||||||
/// returns details about the closest 3D Overlay hit by the pick ray
|
/// returns details about the closest 3D Overlay hit by the pick ray
|
||||||
RayToOverlayIntersectionResult findRayIntersection(const PickRay& ray);
|
RayToOverlayIntersectionResult findRayIntersection(const PickRay& ray);
|
||||||
|
|
||||||
|
|
|
@ -126,3 +126,12 @@ void TextOverlay::setProperties(const QScriptValue& properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QScriptValue TextOverlay::getProperty(const QString& property) {
|
||||||
|
if (property == "text") {
|
||||||
|
return _text;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Overlay::getProperty(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
void setFontSize(int fontSize) { _fontSize = fontSize; }
|
void setFontSize(int fontSize) { _fontSize = fontSize; }
|
||||||
|
|
||||||
virtual void setProperties(const QScriptValue& properties);
|
virtual void setProperties(const QScriptValue& properties);
|
||||||
|
virtual QScriptValue getProperty(const QString& property);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue