mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 14:59:14 +02:00
Use char array instead of QString in NodeBounds
This commit is contained in:
parent
91b1910b86
commit
e5d6a66ca9
2 changed files with 15 additions and 13 deletions
|
@ -23,7 +23,7 @@ NodeBounds::NodeBounds(QObject* parent) :
|
||||||
_showVoxelNodes(false),
|
_showVoxelNodes(false),
|
||||||
_showModelNodes(false),
|
_showModelNodes(false),
|
||||||
_showParticleNodes(false),
|
_showParticleNodes(false),
|
||||||
_overlayText("") {
|
_overlayText() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,12 +143,17 @@ void NodeBounds::draw() {
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
HifiSockAddr addr = selectedNode->getPublicSocket();
|
HifiSockAddr addr = selectedNode->getPublicSocket();
|
||||||
_overlayText = QString("%1:%2 %3ms")
|
QString overlay = QString("%1:%2 %3ms")
|
||||||
.arg(addr.getAddress().toString())
|
.arg(addr.getAddress().toString())
|
||||||
.arg(addr.getPort())
|
.arg(addr.getPort())
|
||||||
.arg(selectedNode->getPingMs());
|
.arg(selectedNode->getPingMs())
|
||||||
|
.left(MAX_OVERLAY_TEXT_LENGTH);
|
||||||
|
|
||||||
|
// Ideally we'd just use a QString, but I ran into weird blinking issues using
|
||||||
|
// constData() directly, as if the data was being overwritten.
|
||||||
|
strcpy(_overlayText, overlay.toLocal8Bit().constData());
|
||||||
} else {
|
} else {
|
||||||
_overlayText = QString();
|
_overlayText[0] = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +215,7 @@ void NodeBounds::getColorForNodeType(NodeType_t nodeType, float& red, float& gre
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeBounds::drawOverlay() {
|
void NodeBounds::drawOverlay() {
|
||||||
if (!_overlayText.isNull() && !_overlayText.isEmpty()) {
|
if (strlen(_overlayText) > 0) {
|
||||||
Application* application = Application::getInstance();
|
Application* application = Application::getInstance();
|
||||||
|
|
||||||
const float TEXT_COLOR[] = { 0.90f, 0.90f, 0.90f };
|
const float TEXT_COLOR[] = { 0.90f, 0.90f, 0.90f };
|
||||||
|
@ -223,17 +228,12 @@ void NodeBounds::drawOverlay() {
|
||||||
const int BACKGROUND_OFFSET_Y = -20;
|
const int BACKGROUND_OFFSET_Y = -20;
|
||||||
const int BACKGROUND_BEVEL = 3;
|
const int BACKGROUND_BEVEL = 3;
|
||||||
|
|
||||||
int textLength = _overlayText.length();
|
|
||||||
char textData[textLength + 1];
|
|
||||||
strcpy(textData, _overlayText.toLatin1().constData());
|
|
||||||
textData[textLength] = '\0';
|
|
||||||
|
|
||||||
int mouseX = application->getMouseX(),
|
int mouseX = application->getMouseX(),
|
||||||
mouseY = application->getMouseY(),
|
mouseY = application->getMouseY(),
|
||||||
textWidth = widthText(TEXT_SCALE, 0, textData);
|
textWidth = widthText(TEXT_SCALE, 0, _overlayText);
|
||||||
glColor4f(0.4, 0.4, 0.4, 0.6);
|
glColor4f(0.4, 0.4, 0.4, 0.6);
|
||||||
renderBevelCornersRect(mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING,
|
renderBevelCornersRect(mouseX + MOUSE_OFFSET, mouseY - TEXT_HEIGHT - PADDING,
|
||||||
textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL);
|
textWidth + (2 * PADDING), TEXT_HEIGHT + (2 * PADDING), BACKGROUND_BEVEL);
|
||||||
drawText(mouseX + MOUSE_OFFSET + PADDING, mouseY, TEXT_SCALE, ROTATION, FONT, textData, TEXT_COLOR);
|
drawText(mouseX + MOUSE_OFFSET + PADDING, mouseY, TEXT_SCALE, ROTATION, FONT, _overlayText, TEXT_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
|
|
||||||
|
const int MAX_OVERLAY_TEXT_LENGTH = 64;
|
||||||
|
|
||||||
class NodeBounds : public QObject {
|
class NodeBounds : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -41,7 +43,7 @@ private:
|
||||||
bool _showVoxelNodes;
|
bool _showVoxelNodes;
|
||||||
bool _showModelNodes;
|
bool _showModelNodes;
|
||||||
bool _showParticleNodes;
|
bool _showParticleNodes;
|
||||||
QString _overlayText;
|
char _overlayText[MAX_OVERLAY_TEXT_LENGTH + 1];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue