fix(rendering): hint and message should render on the same layer

This commit is contained in:
maelstrom 2025-07-12 20:55:28 +02:00
parent bb2b0a2762
commit acc1f93f27

View file

@ -21,6 +21,7 @@
#include "handles.h" #include "handles.h"
#include "math_helper.h" #include "math_helper.h"
#include "objects/hint.h" #include "objects/hint.h"
#include "objects/message.h"
#include "objects/service/selection.h" #include "objects/service/selection.h"
#include "partassembly.h" #include "partassembly.h"
#include "rendering/font.h" #include "rendering/font.h"
@ -658,28 +659,24 @@ void renderMessages() {
// glEnable(GL_BLEND); // glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Render hints
for (auto it = gWorkspace()->GetDescendantsStart(); it != gWorkspace()->GetDescendantsEnd(); it++) { for (auto it = gWorkspace()->GetDescendantsStart(); it != gWorkspace()->GetDescendantsEnd(); it++) {
if (it->GetClass() != &Hint::TYPE) continue; if (!it->IsA<Message>()) continue;
std::shared_ptr<Hint> message = it->CastTo<Hint>().expect();
drawRect(0, 0, viewportWidth, 20, glm::vec4(0,0,0,1));
float textWidth = calcTextWidth(sansSerif, message->text);
drawText(sansSerif, message->text, (viewportWidth - textWidth) / 2, 0);
}
// Render messages
for (auto it = gWorkspace()->GetDescendantsStart(); it != gWorkspace()->GetDescendantsEnd(); it++) {
if (it->GetClass() != &Message::TYPE) continue;
std::shared_ptr<Message> message = it->CastTo<Message>().expect(); std::shared_ptr<Message> message = it->CastTo<Message>().expect();
float textWidth = calcTextWidth(sansSerif, message->text);
// Render hint
if (message->GetClass() == &Hint::TYPE) {
drawRect(0, 0, viewportWidth, 20, glm::vec4(0,0,0,1));
drawText(sansSerif, message->text, (viewportWidth - textWidth) / 2, 0);
} else {
// Don't draw if text is empty // Don't draw if text is empty
if (message->text == "") continue; if (message->text == "") continue;
drawRect(0, 0, viewportWidth, viewportHeight, glm::vec4(0.5)); drawRect(0, 0, viewportWidth, viewportHeight, glm::vec4(0.5));
float textWidth = calcTextWidth(sansSerif, message->text);
drawText(sansSerif, message->text, ((float)viewportWidth - textWidth) / 2, ((float)viewportHeight - sansSerif->height) / 2); drawText(sansSerif, message->text, ((float)viewportWidth - textWidth) / 2, ((float)viewportHeight - sansSerif->height) / 2);
} }
}
} }
tu_time_t renderTime; tu_time_t renderTime;